The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.
Renderers: Path Tracer (path), WebGPU (webgpu), and native scene-graph renderers
Status: active (2026-11-28). Both the
pathrenderer (renderer/) and thewebgpurenderer (runtime/+webgpu/, built vianode tools/build.ts --renderer webgpu, gated bynode tools/check-webgpu-gate.ts) live in this repository on macOS (Metal) and Linux (Vulkan + WebKitGTK JavaScriptCore + pure-Rusttiny-skia/cosmic-text/image).webgpuruns three.js r187'sWebGPURenderernatively on PocketJS's JavaScriptCore guest (pocket-nexus/pocketjs#773,#774,#775), originally proven inpocket-nexus/pocket-agents-island#28,#29. Windows support remains planned. A native renderer for three.js's scene graph runs, experimentally, on a PlayStation 3 (2026-12-02). It is built in PocketJS, not in this repository: Native scene-graph renderers.
ThreeRT is one engine and one runtime with two renderers in this repository, chosen per project and
per build. They differ in what they keep of three.js: path keeps its scene API and replaces the renderer;
webgpu keeps three.js and its renderer and replaces the browser. A third way, for hardware with neither ray
tracing nor WebGPU, keeps three.js's scene graph and replaces its renderer
(below).
path (Path Tracer) |
webgpu (WebGPU rasterization on macOS and Linux) |
|
|---|---|---|
| Keeps of three.js | its scene API, as @threert/scene |
three.js and its WebGPURenderer, unchanged |
| Replaces | the renderer | the browser |
| What draws | ThreeRT's wgpu compute path tracer: hardware ray queries, OIDN, DLSS / MetalFX, the physical sky and post chain | three.js r187's own WebGPURenderer, running natively: navigator.gpu implemented over wgpu inside the engine's JavaScript guest |
| Scene code | @threert/scene (physical units) |
plain three.js + TSL node materials |
| GPU | ray-tracing hardware (Apple M-series, RTX, RDNA2+) | any GPU wgpu supports (Metal, Vulkan, D3D12) |
| Interface | the game HUD (docs/RUNTIME.md "HUD") |
PocketJS (Solid JSX + Tailwind) drawn by PocketJS's wgpu renderer over the 3D frame |
| Footprint | the ThreeRT clients | 9.9 MB installed, 4.5 MB to download (Pocket Island desktop app, measured below) |
| For | production scenes lit by traced light at 60 fps | native three.js apps and games that ship small and run on any GPU, with zero ray-tracing code |
Following Godot (Forward+ / Mobile / Compatibility) and Blender (Cycles / EEVEE), ThreeRT stays a
single product with one brand (ThreeRT: Three + Ray Tracing, Real Time,
Runtime). There is no "ThreeRT Lite" or split brand — choosing --renderer webgpu simply
builds the clean native runtime with the WebGPU renderer and links zero path-tracer code.
Why a webgpu renderer
ThreeRT's runtime already does what a small native 3D app needs besides ray tracing: a JavaScript
guest, window and frame pacing, input, audio, networking, assets and UI. Adding the webgpu
renderer completes the native three.js story — standard three.js scenes running natively on any GPU
at a fraction of a browser's size and power:
- Measured on Pocket Island (
pocket-nexus/pocket-agents-island#28,apps/desktop/REPORT.md; Apple M5, 1200 × 800 @ 2×, foreground 60 fps, Agent Host running, whole process tree):- CPU (one core): 34.7 % vs Electron's 64.8 %
- Foreground RSS / footprint: 471 MB / 533 MB vs Electron's 1007 MB / 932 MB
- Window closed RSS / footprint: 81 MB / 16 MB vs Electron's 433 MB / 104 MB
- Installed / download: 9.9 MB / 4.5 MB vs Electron's 445 MB / 170 MB
- Visual parity: the native WebGPU binding renders three.js test scenes identically to Chrome's WebGPU (mean absolute difference 0.000 / 255).
- A three.js developer can ship a native desktop build without Electron and without rewriting their
scene for
@threert/scene, while keeping the same ThreeRT runtime and path to hardware ray tracing when a project wantspath.
Code layout
renderer/ threert-render (path tracer crate; unchanged API)
runtime/ runtime/crates/* threert-jsc, threert-rt, threert-canvas2d,
threert-net, threert-pocket-host
runtime/js/ web-platform globals (events, timers, window,
Canvas 2D, net; never imports webgpu/ or renderer/)
webgpu/ threert-webgpu WebGPU (`navigator.gpu`) over wgpu for JSC,
window canvas + headless Offscreen (`webgpu-shot`)
webgpu/js/ JS WebGPU binding + runtime entrypoint
webgpu/sample/ threert-webgpu-sample (minimal three.js r187 + TSL)
Dependencies point one way: threert-path → threert-runtime ← threert-webgpu.
- A
webgpubuild never links path-tracer code: no ray-query kernels, OIDN, DLSS, MetalFX, sky baker, or voxel traversal. - A
pathbuild never links the WebGPU guest binding. - A build selects one renderer:
node tools/build.ts --renderer webgpu # clean native three.js app: runtime + webgpu (zero path-tracer code)
node tools/build.ts --renderer path # hardware ray tracing (default): runtime + path tracer
node tools/check-webgpu-gate.ts --render # cargo tree isolation, JS layering, binary size & headless Metal check
Size and dependency gates hold webgpu clean. CI builds the webgpu sample app (release, LTO,
stripped) and checks both binary size against its budget (Pocket Island's size at extraction plus an
explicit margin) and cargo tree to verify no threert-path / denoiser / upscaler crates enter the
webgpu dependency graph. path builds have no size gate.
path users see no change. threert-render, @threert/scene, @threert/gameplay, the clients,
the dlss / oidn / net / audio features, and the default build stay as they are.
What moves from pocket-agents-island
apps/desktop today |
ThreeRT |
|---|---|
crates/webgpu, runtime/webgpu.ts (navigator.gpu over wgpu) |
webgpu/ (threert-webgpu) |
crates/canvas2d (Canvas 2D, images, fonts on CoreGraphics / CoreText) |
webgpu/ (textures) and runtime/ (UI text) |
crates/pocket-host (PocketJS runtime + JavaScriptCore guest + wgpu display + native text) |
runtime/ (threert-runtime) |
crates/net, crates/rt, runtime/pocket.ts (timers, fetch, WebSocket, storage, audio) |
runtime/ (threert-runtime) |
crates/app window, frame pacing, shell |
runtime/ (window, pacing); app-specific shell stays with the app |
crates/agent-host, Pocket Island's game and UI |
stay in pocket-agents-island |
The JavaScriptCore guest and native text path live in PocketJS (pocket-guest-jsc,
pocket-wgpu-render's TextPainter); ThreeRT depends on them rather than copying them.
Native scene-graph renderers
webgpu needs two things from a device: a GPU that wgpu drives, and a JavaScript engine fast enough for
WebGPURenderer's per-frame work. A PlayStation 3 has neither: its RSX predates WebGPU's feature set, and
homebrew has no JIT (PocketJS runs QuickJS on the Cell's PPU). There a native renderer draws three.js's scene
graph instead of three.js's own renderer:
- The scene code is unchanged three.js: it imports
three(0.187.0) and buildsObject3Ds, geometries, materials and lights. - Once a frame,
RSXRenderer(TypeScript, about 800 lines) callsupdateMatrixWorld, walks the graph, and packs each object's matrix and material parameters into typed arrays. Geometry and textures are uploaded once and cached by id. - Native code (
rsx3d.c) draws them on the RSX with three hand-written shader pairs: PBR (metalness and roughness, an environment map, a directional, a hemisphere and three point lights, fog), a sky dome, and unlit points and lines. A planar mirror uses the stencil buffer. - PocketJS draws its UI into the same 1920 × 1080 frame after the 3D pass, without a clear.
What it draws: Mesh, InstancedMesh, Points, Line and LineSegments; MeshStandardMaterial,
MeshPhysicalMaterial, MeshPhongMaterial, MeshLambertMaterial, MeshBasicMaterial and
MeshNormalMaterial, mapped onto the PBR or the unlit shader; ambient, hemisphere, directional and point
lights; Fog and FogExp2; PerspectiveCamera. What lives in three.js's renderer does not carry over:
shadows, ShaderMaterial, onBeforeCompile and TSL, render targets and post-processing. The mirror is
the renderer's own option, not three.js's Reflector.
Measured on a PlayStation 3 (CECH-2500, system software 4.81 with custom firmware), 1920 × 1080, from the demos' own counters. "Submit" is PPU time spent writing the 3D pass's commands, not GPU time.
| Demo | Triangles | Draws | Submit | fps |
|---|---|---|---|---|
| Showroom: torus knot, PBR satellites, planar mirror | 25,990 | 26 | 0.1 ms | 20 |
| Material grid: 20 spheres, metalness × roughness, mirror | 58,886 | 43 | 0.1 ms | 26 |
| Galaxy: planet, rings, 2,400 point sprites | 5,678 | 7 | 0.1 ms | 30 |
| Instanced wave: 196 instances | 2,362 | 199 | 28.9 ms | 16 |
The RSX has no hardware instancing, so an InstancedMesh costs one draw and one constant upload an instance:
that is the 28.9 ms. Where the other demos' frames go (QuickJS walking the graph, the RSX shading 1080p with
a mirror pass, or waiting on vsync) is not measured yet, and the Cell's six SPUs are not used.
It is not a --renderer of this repository. It shares no crate with runtime/: the PS3 build is PocketJS's
(PSL1GHT, ppu-gcc, a C host program), and the code is in pocket-nexus/pocketjs (platforms/ps3/,
apps/ps3-three-showcase/). A shared interface for scene-graph renderers waits for a second device that needs
one. It sits between webgpu, which keeps all of three.js, and a port, which keeps a game's rules
and replaces everything else.
Open questions
- The guest on Windows. Linux uses JavaScriptCore from WebKitGTK. The Windows port still needs
a JIT-capable guest for the JavaScript work that three.js's
WebGPURendererdoes each frame. - TSL coverage.
webgpuruns three.jsWebGPURendereras written; materials that rely ononBeforeCompileor GLSLShaderMaterialneed TSL equivalents (Pocket Island's port is the worked example). - One scene, both renderers. Whether
@threert/scenescenes should also targetwebgpu(its three.js fallback already runs in browsers) orwebgpustays plain three.js.