Feature Library

GLB stage: imported models in crowds on show time (engine-free WebGPU)

1.52 GPU · 1.13 CPU ms
A still of the GLB stage: imported models in crowds on show time (engine-free WebGPU) demo
Still
The live demo starts when it’s in view.Play and scrub the show · Camera: over the square, inside the first ring, ride with the leader · Ripple per ring · Colour by level of detail

The HaTac engine’s model import, lifted whole and engine-free, with a standalone WebGPU stage to draw it.

A self-contained glTF 2.0 binary is checked before anything is allocated (file, JSON and decoded byte budgets, triangle, vertex, node, joint and image limits, no external URIs, opaque materials only, meshopt and quantized data decoded in plain TypeScript), packed into one compact vertex layout, fitted to a height, length or largest size with its feet on the ground, given three simplified index ranges per primitive by the engine’s own quadric simplifier, and its embedded PNG or JPEG maps read into three texture arrays. Skins (four influences), node animation (linear, step and cubic-spline clips) and recorded transform tracks are evaluated at absolute show time, so playing and scrubbing give the same vertices; a batch of placed copies shares one pose, and copies on different clocks are different batches. The stage, written for the library, picks each copy’s level by projected size on the engine’s curve with its rate limit and dithered cross-fade, culls by the view, draws one fixed shadow map, a contact shadow under each footprint and the engine’s material code, and exports its light model’s WGSL so a page’s own ground and sky light the same way. A camera can ride any node. The demo is a crowd of one generated GLB, a jointed wooden toy dancer, in a round square: a leader and six rings, each ring a batch a little behind the one inside, so every move ripples outward.

What it costs a frame

1.52 ms
1.13 ms
GPU
1.52 ms
CPU, median
1.13 ms
CPU, 95th pct
1.64 ms
Draw calls
0
Weight
Moderate

Measured 28 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 158, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 1.50–1.53, CPU 1.13–1.23 ms). What ran: Alone: one batch of four copies of the generated dancer (6,820 source triangles, 3,700 vertices, 12 joints) pinned to levels 0–3, posed on the CPU each frame from the show programme, drawn with its shadow map, ground contact and the square’s ground and sky, at golden hour. Phones: tiers are being measured next.

How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference

Typical frame ?
16.80 ms
1% low ?
48 fps
Varies by ?
±0.85 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.02 ms18.18 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.80 ms
p95 ?
17.68 ms
p99 ?
18.05 ms
Slowest ?
34.36 ms
Mean ?
16.87 ms
Standard deviation ?
0.85 ms
1% low ?
48 fps
0.1% low ?
29 fps
Hitches ?
1 of 600
Over budget ?
1 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.0 / 1.4 / 1.5 ms

Input

No input during this run.

Memory

JavaScript heap ?
48.3 → 50.3 MB
Growth ?
+2.00 MB

Browser

JavaScript a frame ?
1.08 ms
All tasks a frame ?
1.92 ms
Layout / style ?
0.20 / 0.06 ms
Main thread busy ?
11%

Garbage collection

Collections ?
9 (9 minor, 0 major)
Pauses ?
6.8 ms in all, longest 1.3

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages
With an agent
install("glb-stage")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. A show, an exhibit or a game scene that loads GLB models from people you do not fully trust, refusing oversized, external or damaged files with a reason before allocating anything
  2. A crowd, a parade, a stadium or a herd: hundreds of copies of one rigged model in a few batches, each batch on its own clock so motion ripples or staggers
  3. A scrubbed timeline or a replay where a model must be in exactly the same pose at the same moment, played or sought
  4. Automatic levels of detail for imported models, with a dithered fade between levels and a tint that shows which level each copy is at
  5. A raw WebGPU page with no three.js that needs imported models lit like its own procedural ground and sky
  6. A camera that rides a model’s node (a driver’s head, a crane’s hook, a dancer) through the same pose the model is drawn in
  7. Measuring a model before choosing to load it: bytes, triangles, vertices, nodes and the decoders it needs

Pitfalls, in brief

  1. The demo needs WebGPU: the stage draws with WGSL pipelines, texture arrays and a comparison-sampled shadow map.
  2. Check before you allocate. inspectModel gates the declared and the expanded sizes (accessors, decoded meshopt, image pixels) before any array is made; a compressed file’s size alone cannot bound what it expands to.
  3. Only opaque triangle meshes, one UV set, at most four influences, no morph targets, no sparse accessors: export to fit (alpha-blended and cut-out materials are refused with a reason, not drawn wrong).
  4. One batch shares one pose.
  5. Seek with absolute show time, never by adding frame steps: the pose is a function of the time, so a scrub, a replay or a dropped frame gives the same vertices.
11 more in brief
  1. Give a looping clip the same first and last pose.
  2. Fit to the rest pose once.
  3. Keep the imported source immutable and shared; each animated batch needs its own packed vertices and its own culling sphere and footprint (createBatch makes them).
  4. Simplified levels keep the source’s vertices: skinning, UVs and joints stay right on every level because a level is only another index range.
  5. The engine’s import fails the whole model when the simplifier refuses one primitive (a degenerate triangle: “Degenerate input triangle”; a non-manifold or inconsistently wound one: “Expected an oriented manifold mesh”), which real exports often have.
  6. Material maps share one size: every material gets a layer as large as the largest map (up to mapSize) in each of three arrays, mapped or not.
  7. The engine uploads one mip level, so small texture detail (a painted face, a logo) sparkles on distant copies.
  8. Pick levels by projected size and let them move a little each frame (LOD_RATE) with a dithered cross-fade over the band, or copies pop as the camera moves; pass cut: true to the stage on a camera cut so levels jump to where they belong.
  9. Keep the shadow box fixed round the scene (shadowBounds) rather than fitted to the view: the map then never crawls as the camera moves.
  10. Light the page’s own surfaces with STAGE_FRAME_WGSL and STAGE_LIGHT_WGSL (stageLight, stageFog, stageOut) and the stage’s frame bind group, or the models will not sit in the same light as the ground and the sky.
  11. Image maps are decoded with createImageBitmap and OffscreenCanvas: a window or a worker, not Node.
16 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Adapted from published work, named below.

Hannes Andersson: The HaTac engine’s model import, mesh simplifier, structure drawer and their tests (built for his game and proven there); the library’s stage, demo and generated models.

The Khronos Group, glTF 2.0: The binary container, accessors, skins, animation samplers and materials the reader follows, and the meshopt compression extensions its decoder is written from.

Arseny Kapoulkine, meshoptimizer (MIT): The compression format the plain-TypeScript decoder reads (its licence travels in module/model/meshoptimizer-LICENSE.md).

Michael Garland & Paul S. Heckbert, Surface simplification using quadric error metrics (SIGGRAPH 1997): The error quadrics mesh-lod’s edge collapses rank by.

Brian Karis, Real shading in Unreal Engine 4 (SIGGRAPH 2013): The GGX distribution, Schlick–Smith visibility and Fresnel in the stage’s light model.

Krzysztof Narkowicz, ACES filmic tone mapping curve (2016): The fitted curve the stage tone-maps with.

gltfglbmodel importmodel loaderasset pipelinepreflightvalidationbudgetssecurityno external urismeshoptEXT_meshopt_compressionKHR_mesh_quantizationemissive strengthskinningskeletal animationskinned meshnode animationcubic splinemotion trackrecorded motionshow timedeterministicscrub

Near it in the frame