You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[RFC] WebGPU / TSL support for generated interactive scenes
#2221
Generated interactive scenes load three.js from the deployment-hosted copy, pinned at 0.160.0 (packages/@openmaic/generation/src/interactive-libraries.ts). That pin decides which API a generated page is written against, so it is a product decision rather than a dependency-hygiene one. I would like to discuss what it should be, because two things have changed since it was set: three.js moved WebGPU and TSL from experimental addons to first-class entry points, and models' knowledge of three.js keeps moving as well.
I am not asking for a version bump as such. I would like to know whether the single pinned version is deliberate, and whether version coexistence is acceptable.
Related: #423 introduced the visualization3d widget type, which is where three.js entered generated content. This thread is about the runtime that type loads, not about adding more types.
How the pin works today
interactive-libraries.ts is the single source of truth: version, compatibility, entry, files.
scripts/sync-interactive-assets.mjs copies build/ + examples/jsm/ out of node_modules into public/vendor/interactive/three@0.160.0/, and throws if the installed version does not match the declared one.
interactiveLibraryPrompt() tells the model to use /vendor/interactive/three@0.160.0/build/three.module.js, with import-map keys "three" and "three/addons/".
interactive-library-mapper.ts rewrites CDN URLs onto that hosted copy, but only for requests on the same release line (compatibility: 'minor' for three).
What changed in three.js
path
0.160.0
0.187.0
examples/jsm/renderers/webgpu/WebGPURenderer.js
200
404
examples/jsm/nodes/Nodes.js (three/nodes)
200
404
build/three.webgpu.js (three/webgpu)
404
200, 1.35 MB
build/three.tsl.js (three/tsl)
404
200
So 0.160 is not "without WebGPU": it has an experimental renderer behind the addons path and a three/nodes export that has never been a stable API. Newer releases replaced that with three/webgpu and three/tsl, and removed the experimental paths in the process. Generated scenes are therefore written against an API surface that no longer exists in current three.js, and cannot be written against the one that does.
Two failure modes I can reproduce
1. three/webgpu cannot resolve at all. The import map only declares three and three/addons/, so a generated page that writes import { WebGPURenderer } from 'three/webgpu' fails as an unresolved bare specifier — the page goes blank, not partial.
2. The addon surface has moved on. Anything the model writes against the current addon layout 404s against the hosted copy: RGBELoader became HDRLoader in r180 and RGBMLoader was removed; TransformControls stopped being an Object3D in r169, so scene.add(controls) throws. mapInteractiveLibraryUrl rewrites URLs by string prefix and never checks that the file exists, so these surface at playback time in the audience's browser rather than at generation time.
Both are silent-to-the-author failures with a blank page as the visible symptom.
The constraint nobody can bump past
render-service/src/preview-renderer.ts launches chromium-headless-shell with headless: true and args: ['--no-sandbox', '--disable-dev-shm-usage']. There is no --enable-unsafe-webgpu and no GPU passthrough, and headless-shell has no GPU process. A WebGPU-rendered scene would therefore work in the classroom and fail in MP4 export.
That makes "support WebGPU in generated scenes" depend on the export renderer first, which is a bigger change than the pin. Worth knowing before anyone spends time on the pin.
Why one version cannot serve everything
The reasoning behind a single pin is sound: generated pages have no fallback, so the runtime has to be a known-good API surface. But it is one value for two populations that move in opposite directions:
Classrooms generated earlier were written against 0.160.0 and hardcode /vendor/interactive/three@0.160.0/... in their import maps.
Classrooms generated later are written by models whose three.js knowledge keeps moving; anything aimed at a newer layout 404s today.
Bumping the pin forward breaks the first population — public/vendor/interactive is regenerated on every build, and cross-minor requests are deliberately not rewritten, so those pages lose their three.js entirely. Keeping the pin breaks the second. No single value satisfies both.
A staged proposal
Let one package have several vendored versions.INTERACTIVE_LIBRARIES is already an array; a package would get one entry per hosted version, the prompt would name the current default, and mapSelfHostedPath would resolve an exact-version request to the copy that exists. Existing classrooms keep working by construction.
Add three/webgpu and three/tsl as additional hosted targets, still defaulting to 0.160.0 for new scenes. This makes WebGPU authoring possible without touching what already works.
Move the default forward only after that. By then a bump is additive.
Cost to be explicit about: each hosted three.js version is about 27 MB in public/ (build/ 5 MB + examples/jsm/ 22 MB), and 0.187 adds three.core.js, three.webgpu.js and three.tsl.js on top. files: ['build', 'examples/jsm'] copies the whole build directory, so a newer version needs an explicit file list to stay bounded.
Would several vendored versions of the same package be acceptable, given the size cost?
Is WebGPU in the export renderer something you would consider, or is the renderer intentionally GPU-free?
If the pin is deliberate and staying, that is a perfectly good answer — I would then suggest documenting it as such, because "three 0.160.0" currently reads as neglected maintenance rather than as a compatibility contract.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
What this is about
Generated interactive scenes load three.js from the deployment-hosted copy, pinned at
0.160.0(packages/@openmaic/generation/src/interactive-libraries.ts). That pin decides which API a generated page is written against, so it is a product decision rather than a dependency-hygiene one. I would like to discuss what it should be, because two things have changed since it was set: three.js moved WebGPU and TSL from experimental addons to first-class entry points, and models' knowledge of three.js keeps moving as well.I am not asking for a version bump as such. I would like to know whether the single pinned version is deliberate, and whether version coexistence is acceptable.
Related: #423 introduced the
visualization3dwidget type, which is where three.js entered generated content. This thread is about the runtime that type loads, not about adding more types.How the pin works today
interactive-libraries.tsis the single source of truth:version,compatibility,entry,files.scripts/sync-interactive-assets.mjscopiesbuild/+examples/jsm/out ofnode_modulesintopublic/vendor/interactive/three@0.160.0/, and throws if the installed version does not match the declared one.interactiveLibraryPrompt()tells the model to use/vendor/interactive/three@0.160.0/build/three.module.js, with import-map keys"three"and"three/addons/".interactive-library-mapper.tsrewrites CDN URLs onto that hosted copy, but only for requests on the same release line (compatibility: 'minor'for three).What changed in three.js
examples/jsm/renderers/webgpu/WebGPURenderer.jsexamples/jsm/nodes/Nodes.js(three/nodes)build/three.webgpu.js(three/webgpu)build/three.tsl.js(three/tsl)So 0.160 is not "without WebGPU": it has an experimental renderer behind the addons path and a
three/nodesexport that has never been a stable API. Newer releases replaced that withthree/webgpuandthree/tsl, and removed the experimental paths in the process. Generated scenes are therefore written against an API surface that no longer exists in current three.js, and cannot be written against the one that does.Two failure modes I can reproduce
1.
three/webgpucannot resolve at all. The import map only declaresthreeandthree/addons/, so a generated page that writesimport { WebGPURenderer } from 'three/webgpu'fails as an unresolved bare specifier — the page goes blank, not partial.2. The addon surface has moved on. Anything the model writes against the current addon layout 404s against the hosted copy:
RGBELoaderbecameHDRLoaderin r180 andRGBMLoaderwas removed;TransformControlsstopped being anObject3Din r169, soscene.add(controls)throws.mapInteractiveLibraryUrlrewrites URLs by string prefix and never checks that the file exists, so these surface at playback time in the audience's browser rather than at generation time.Both are silent-to-the-author failures with a blank page as the visible symptom.
The constraint nobody can bump past
render-service/src/preview-renderer.tslauncheschromium-headless-shellwithheadless: trueandargs: ['--no-sandbox', '--disable-dev-shm-usage']. There is no--enable-unsafe-webgpuand no GPU passthrough, and headless-shell has no GPU process. A WebGPU-rendered scene would therefore work in the classroom and fail in MP4 export.That makes "support WebGPU in generated scenes" depend on the export renderer first, which is a bigger change than the pin. Worth knowing before anyone spends time on the pin.
Why one version cannot serve everything
The reasoning behind a single pin is sound: generated pages have no fallback, so the runtime has to be a known-good API surface. But it is one value for two populations that move in opposite directions:
/vendor/interactive/three@0.160.0/...in their import maps.Bumping the pin forward breaks the first population —
public/vendor/interactiveis regenerated on every build, and cross-minor requests are deliberately not rewritten, so those pages lose their three.js entirely. Keeping the pin breaks the second. No single value satisfies both.A staged proposal
INTERACTIVE_LIBRARIESis already an array; a package would get one entry per hosted version, the prompt would name the current default, andmapSelfHostedPathwould resolve an exact-version request to the copy that exists. Existing classrooms keep working by construction.three/webgpuandthree/tslas additional hosted targets, still defaulting to 0.160.0 for new scenes. This makes WebGPU authoring possible without touching what already works.Cost to be explicit about: each hosted three.js version is about 27 MB in
public/(build/5 MB +examples/jsm/22 MB), and 0.187 addsthree.core.js,three.webgpu.jsandthree.tsl.json top.files: ['build', 'examples/jsm']copies the whole build directory, so a newer version needs an explicit file list to stay bounded.Questions
If the pin is deliberate and staying, that is a perfectly good answer — I would then suggest documenting it as such, because "three 0.160.0" currently reads as neglected maintenance rather than as a compatibility contract.
All reactions