archematics/src/giveAwrl.civet

22 lines
862 B
Plaintext
Raw Normal View History

import https://code.jquery.com/jquery-3.7.1.js
certainlyHandled := '.x3d .gltf .glb .obj .stl .ply'.split ' '
jQuery.getScript 'https://create3000.github.io/code/x_ite/latest/x_ite.js',
async =>
canvas := X3D.createBrowser()
site := $('a[href^="http"]')
url := site.attr 'href'
if certainlyHandled.some((ext) => url.includes ext)
canvas.setAttribute 'src', site.attr 'href'
else if url.includes '.wrl'
// Need to obtain the text and check what level it is
response := await fetch url
text := await response.text()
if /#\s*VRML\s*V?1./i.test(text)
console.log('VRML 1 not yet supported')
else
browser := X3D.getBrowser canvas
scene := await browser.createX3DFromString text
browser.replaceWorld(scene)
site.after(canvas)