chore: Check types and add draft full typing for x_ite. (#18)

Enabling type checking involves a full rearrangement of the
  build process, as well as supplying types for some of the
  dependencies.

  Now that (hopefully) all of the methods are typed, can call
  (for example) browser.setBrowserOption to manage the
  viewer navigation.

  Resolves #14.
  Resolves #17.

Reviewed-on: #18
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-11 01:52:39 +00:00 committed by Glen Whitney
parent a8707386aa
commit b5478254af
15 changed files with 2767 additions and 33 deletions

View file

@ -4,17 +4,20 @@ X3D from https://create3000.github.io/code/x_ite/latest/x_ite.mjs
certainlyHandled := '.x3d .gltf .glb .obj .stl .ply'.split ' '
canvas := X3D.createBrowser()
browser := X3D.getBrowser canvas
browser.setBrowserOption 'StraightenHorizon', false
site := $('a[href^="http"]')
url := site.attr 'href'
url := site.attr('href') ?? ''
if certainlyHandled.some((ext) => url.includes ext)
canvas.setAttribute 'src', site.attr 'href'
canvas.setAttribute 'src', url
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)