Skip to main content
The library adds no layer between you and Three.js. Everything below is plain Three.js on the objects of 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 through ctx.assets. It returns the URL the game serves the file at.
Do not await asset loads in a library’s __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 to graphics.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.
After changing 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 call renderer.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:
Assign 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).