Context.graphics.
Importing Three.js
The subpaths only re-export
three. three is a peer dependency that the app installs, so the library, the game and the add-ons resolve the same copy. Add-ons import three, which shares its core classes with three/webgpu. For add-on types, add @types/three at the same version.
Loading a model
Load project files throughctx.assets. It returns the URL the game serves the file at.
__init: start them and add the objects when they arrive.
Node materials and TSL
WebGPURenderer compiles node materials to WGSL (WebGPU) and GLSL (WebGL2) from one source.
Cameras
Assign any camera tographics.camera. The viewport is applied to it at once, and again on every change. For a PerspectiveCamera, the library sets aspect. For an OrthographicCamera, you choose left/right/top/bottom in design proportions.
fov, near or far, call camera.updateProjectionMatrix().
Picking
raycast takes page coordinates, the ones pointer events give:
worldToScreen goes the other way, for example to place an HTML label over an object.
Render loop
Never callrenderer.setAnimationLoop or render from requestAnimationFrame. The engine renders once per tick, and the editor relies on this: pause freezes the image, and step draws exactly one frame. To draw something else than scene through camera, such as a post-processing pipeline, replace the library’s render step. The library still calls it once per tick, and for editor screenshots:
undefined to go back to the default render. The custom render is reset when the game restarts.
Editor bridge
When the editor starts the game, the library adds to the editor protocol:
The projection includes the viewport crop, so its normalized device coordinates span the canvas. The canvas is drawn
visibleWidth × visibleHeight CSS px at (contentLeft, contentTop) of the container (see the viewport event).