feat: Proof of concept for displaying wrl files (#10)

Mostly works on VRML97 and up files. Unfortunately, many of the target files are VRML 1.0,
so an on-the-fly converter will be needed. The strategy for that is to translate the converter in Wings 3D.

Resolves #9.

Reviewed-on: #10
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>
This commit is contained in:
Glen Whitney 2023-08-31 05:30:41 +00:00 committed by Glen Whitney
parent 97f7138d7b
commit 9107c82f13
12 changed files with 2827 additions and 0 deletions

21
src/giveAwrl.civet Normal file
View file

@ -0,0 +1,21 @@
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)