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:
parent
9107c82f13
commit
545c5f550f
@ -4,7 +4,9 @@
|
|||||||
description: 'Uncovering lost digital mathematical treasures',
|
description: 'Uncovering lost digital mathematical treasures',
|
||||||
scripts: {
|
scripts: {
|
||||||
test: 'echo "Error: no test specified" && exit 1',
|
test: 'echo "Error: no test specified" && exit 1',
|
||||||
build: 'civet --js -c src/*.civet -o public/js/.js',
|
build_js: 'civet --js -c src/*.civet -o public/js/.js',
|
||||||
|
build_deps: 'cp -r node_modules/vrml1to97 public/js/deps',
|
||||||
|
build: 'pnpm --sequential /build_/',
|
||||||
start: 'node public/js',
|
start: 'node public/js',
|
||||||
go: 'pnpm --sequential "/build|start/"',
|
go: 'pnpm --sequential "/build|start/"',
|
||||||
serve: 'pnpm build && http-server',
|
serve: 'pnpm build && http-server',
|
||||||
@ -25,4 +27,7 @@
|
|||||||
'@danielx/civet': '^0.6.26',
|
'@danielx/civet': '^0.6.26',
|
||||||
'http-server': '^14.1.1',
|
'http-server': '^14.1.1',
|
||||||
},
|
},
|
||||||
|
dependencies: {
|
||||||
|
vrml1to97: '^0.1.0',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,11 @@ settings:
|
|||||||
autoInstallPeers: true
|
autoInstallPeers: true
|
||||||
excludeLinksFromLockfile: false
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
vrml1to97:
|
||||||
|
specifier: ^0.1.0
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@danielx/civet':
|
'@danielx/civet':
|
||||||
specifier: ^0.6.26
|
specifier: ^0.6.26
|
||||||
@ -303,6 +308,11 @@ packages:
|
|||||||
resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==}
|
resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vrml1to97@0.1.0:
|
||||||
|
resolution: {integrity: sha512-D+nE1qYhldWlsSYF2br9Dylmn6zO1BBJimXO5SJ+wlnYo0pKRpQUepc8b0Rz1jWMjXjfP4UPx6s+UZNA9YDoDA==}
|
||||||
|
hasBin: true
|
||||||
|
dev: false
|
||||||
|
|
||||||
/whatwg-encoding@2.0.0:
|
/whatwg-encoding@2.0.0:
|
||||||
resolution: {integrity: sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==}
|
resolution: {integrity: sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
import https://code.jquery.com/jquery-3.7.1.js
|
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 ' '
|
certainlyHandled := '.x3d .gltf .glb .obj .stl .ply'.split ' '
|
||||||
jQuery.getScript 'https://create3000.github.io/code/x_ite/latest/x_ite.js',
|
canvas := X3D.createBrowser()
|
||||||
async =>
|
site := $('a[href^="http"]')
|
||||||
canvas := X3D.createBrowser()
|
url := site.attr 'href'
|
||||||
site := $('a[href^="http"]')
|
if certainlyHandled.some((ext) => url.includes ext)
|
||||||
url := site.attr 'href'
|
canvas.setAttribute 'src', site.attr 'href'
|
||||||
if certainlyHandled.some((ext) => url.includes ext)
|
else if url.includes '.wrl'
|
||||||
canvas.setAttribute 'src', site.attr 'href'
|
// Need to obtain the text and check what level it is
|
||||||
else if url.includes '.wrl'
|
response := await fetch url
|
||||||
// Need to obtain the text and check what level it is
|
text .= await response.text()
|
||||||
response := await fetch url
|
if /#\s*VRML\s*V?1./i.test(text)
|
||||||
text := await response.text()
|
text = convert(text)
|
||||||
if /#\s*VRML\s*V?1./i.test(text)
|
browser := X3D.getBrowser canvas
|
||||||
console.log('VRML 1 not yet supported')
|
scene := await browser.createX3DFromString text
|
||||||
else
|
browser.replaceWorld(scene)
|
||||||
browser := X3D.getBrowser canvas
|
site.after(canvas)
|
||||||
scene := await browser.createX3DFromString text
|
|
||||||
browser.replaceWorld(scene)
|
|
||||||
site.after(canvas)
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"strict": true,
|
|
||||||
"lib": ["esnext"],
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"esModuleInterop": true
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user