feat: Convert VRML 1 files with vrml1to97 (#13)

Now that the vrml1to97 package has been published, uses it to convert
  any VRML 1 files it encounters. Also uses the new x_ite module

  Resolves #12

Reviewed-on: #13
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>
This commit is contained in:
Glen Whitney 2023-09-05 01:50:52 +00:00 committed by Glen Whitney
parent 9107c82f13
commit 545c5f550f
4 changed files with 33 additions and 28 deletions

View file

@ -1,21 +1,20 @@
import https://code.jquery.com/jquery-3.7.1.js
X3D from https://create3000.github.io/code/x_ite/latest/x_ite.mjs
{convert} from ./deps/vrml1to97/index.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)
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)
text = convert(text)
browser := X3D.getBrowser canvas
scene := await browser.createX3DFromString text
browser.replaceWorld(scene)
site.after(canvas)

View file

@ -1,9 +0,0 @@
{
"compilerOptions": {
"strict": true,
"lib": ["esnext"],
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"esModuleInterop": true
}
}