Feature Library

glTF models with recorded motion

1.02 GPU · 0.41 CPU ms
A still of the glTF models with recorded motion demo
Still
The live demo starts when it’s in view.Record a lap live and watch the convoy replay it · drag to orbit · Gate: pick a broken file to see why it is refused

GLB models ready for a stage: gated before loading (header, size and count budgets, allowed extensions, nothing outside the file, each refusal with a plain…

What it costs a frame

1.02 ms
0.41 ms
GPU
1.02 ms
CPU, median
0.41 ms
CPU, 95th pct
0.58 ms
Draw calls
67
Weight
Moderate

Measured 11 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Playback: the rover and a convoy of 20 copies replaying a recorded lap (six nodes at 30 Hz) and two clips baked from the GLB; the convoy is 15 instanced meshes, its matrices composed on the CPU each frame. The lap is recorded time-compressed at load. Shadows on. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool1.020.410.58
apple · Apple A19 Proin a browser tab · 16 November 20262.630.501.16
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20263.801.652.23

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0three/addons GLTFLoader and SkeletonUtils

What it’s for

  1. Vehicles and machines on a live stage, replaying motion a game made
  2. A convoy, a crowd or a field of machines from one model
  3. Scrubbing or replaying a show and getting the same frame
  4. Turning a simulation into a small file that needs no simulation to play
  5. Checking models (size, decoders) before a show loads them
  6. Accepting a GLB someone uploads or picks, refused with a reason they can act on before any loader runs
  7. Models from any tool in any unit, shown at the size you want

Pitfalls, in brief

  1. GLTFLoader fetches whatever a file names: a buffer or image uri can point at another host or a path beside your page, and the request goes out before anything fails.
  2. Gate budgets count what the file declares, not what it draws: meshes are the file’s mesh entries (shared ones once), so the gate’s count can be lower than glbInfo’s meshCount, which counts each node that draws one; vertices are the POSITION accessors’ counts.
  3. Allow an extension in extensionsRequired only when the loader can read it: the gate allows three’s built-in material and quantisation extensions and meshopt; add KHR_texture_basisu or KHR_draco_mesh_compression to allowedExtensions only when you give the loader a KTX2Loader or DRACOLoader.
  4. data: URIs pass the gate (they are inside the file), but under a strict connect-src GLTFLoader cannot fetch a data: buffer (the embeddedImages plugin handles data: images).
  5. Record in fixed steps.
11 more in brief
  1. A recording is not a loop.
  2. Make the period a whole number of frames: choose the speed (or the rate) so the lap ends exactly on a frame, or the loop is a fraction of a frame short and drifts.
  3. Tracks hold local transforms in the model’s own units.
  4. Recorded node names must be unique in the model: the player and the instancing find nodes by name.
  5. AnimationMixer.update(dt) makes a clip depend on how many frames ran.
  6. InstancedMesh: never culled here (its bounds would be the first copies’), its capacity fixed at creation, and a per-copy colour attribute is in the shader’s key: decide colours before the first compile, and change count, never capacity.
  7. Instancing composes every shown copy’s nodes on the CPU (about 15 meshes × 20 copies is nothing; thousands of copies of a deep model is not).
  8. A file with KHR_draco needs its decoder, and KHR_texture_basisu a KTX2Loader with detectSupport(renderer) called: the loader says which is missing before parsing.
  9. Under a strict Content Security Policy (no 'wasm-unsafe-eval', no blob: in connect-src or img-src) three’s meshopt decoder cannot compile its WebAssembly, and GLTFLoader’s blob: URLs for embedded images are refused: the model fails, or loads untextured.
  10. warmUp draws one frame cut to a pixel: do it behind your loader or a still. compileUnseen alone never stalls a frame and is safe mid-show; the shadow pass’s pipelines only build in a real draw.
  11. compileAsync culls by the camera, so what starts out of view (or hidden, or not yet in the scene) is not built at load and stalls when it arrives: warm such objects explicitly. three r187 keeps one compile state: never run two compileAsync calls at once. warmUp compiles in the renderer’s one queue (compile-turn.ts); send your own compiles through it too: inTurn(renderer, () => renderer.compileAsync(…)).
16 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Khronos glTF 2.0 specification: The GLB container (header, JSON and BIN chunks), accessor min/max and node transforms the measurer reads, and the extension names it checks.

Ken Shoemake, Animating rotation with quaternion curves (SIGGRAPH 1985): Spherical linear interpolation (slerp), which the track sampler uses between frames.

Khronos EXT_meshopt_compression and KHR_meshopt_compression specifications: The bitstreams (attributes v0 and v1, triangles, index sequences) and the four filters the TypeScript decoder (meshopt-decoder.ts) is written from.

Arseny Kapoulkine, meshoptimizer: The compression format (MIT), and three’s WebAssembly MeshoptDecoder, which meshopt-auto.ts prefers and the TypeScript decoder matches byte for byte; the tests encode with its npm encoder.

gltfglbGLTFLoaderAnimationMixeranimation clipsmotion capturerecorded tracksseamless loopinstancingcrowdnormaliseboundsmeshoptktx2warm-upvalidationuploaduntrusted filesdeterministiceffect speedthree

Near it in the frame