Feature Library

Shape kit

0.22 GPU · 0.25 CPU ms
A still of the Shape kit demo
Still
The live demo starts when it’s in view.Drag to turn the yard · change the roof, pitch, storeys and windows · turn on the hand-built roof to see what the check finds

Closed shapes from a few numbers, so a scene made in code never needs a hand-built mesh.

Closed shapes from a few numbers, so a scene made in code never needs a hand-built mesh: bevelled boxes, blocks over any footprint with windows and doors set in as recesses with a pane, roofs (gable, hipped over any convex footprint, shed, flat) that are a slab of even thickness and build their own gable walls, so nothing is left open under the slope, a lathe, a sweep with mitred joints, and a sphere to roughen into rocks. Every solid is closed and wound outward, normals split at creases by an angle and are smooth elsewhere, UVs are in world metres (a texture keeps its size from wall to roof to post) and every part has a material slot: a built scene is one draw per slot, and a shape placed many times becomes instances. check() finds open seams, flipped faces, solids inside out, slivers and stretched UVs in any triangles, and draws them as lines. The core is plain arrays and imports nothing; a small adapter makes three meshes.

What it costs a frame

0.22 ms
0.25 ms
GPU
0.22 ms
CPU, median
0.25 ms
CPU, 95th pct
0.36 ms
Draw calls
19
Weight
Light

Measured 19 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 (rounds ranged GPU 0.22–0.23, CPU 0.24–0.26 ms). What ran: The default yard: a two-storey house with 28 windows and a door, a gable roof and chimney, a turned tower, a pavilion on eight instanced posts, a curved garden wall and six instanced crates, with the check overlay on. Built once at start; the frame cost is drawing it, about a dozen draws. 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 ?
3.22 ms
1% low ?
149 fps
Varies by ?
±0.87 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p990.10 ms6.85 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run back to back, each starting once the GPU has finished the last, so frame times show the work itself. They have a floor of about 4–5 ms from the browser’s own scheduling: GPU and CPU ms stay the measure of cost.

Frames

Median (p50) ?
3.22 ms
p95 ?
5.05 ms
p99 ?
6.25 ms
Slowest ?
7.10 ms
Mean ?
3.59 ms
Standard deviation ?
0.87 ms
1% low ?
149 fps
0.1% low ?
141 fps
Hitches ?
4 of 600
Over budget ?
0 of 600

Main thread

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

Input

No input during this run.

Memory

JavaScript heap ?
40.4 → 42.7 MB
Growth ?
+2.32 MB

Browser

JavaScript a frame ?
0.01 ms
All tasks a frame ?
0.46 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
13%

Garbage collection

Collections ?
3 (3 minor, 0 major)
Pauses ?
1.2 ms in all, longest 0.5

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.0No other packages
With an agent
install("shape-kit")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. Houses, sheds, towers, quays and walls made in code for a scene that must load at once
  2. An agent or a generator that builds geometry and must not leave gaps or flipped faces
  3. Checking a hand-built or imported mesh for open seams, flipped faces and stretched UVs
  4. Textures that keep one size across walls, roofs and posts (bricks, planks, tiles)
  5. Building geometry on a server or in a worker, without three

Pitfalls, in brief

  1. Closed is per solid. A shape is a list of closed solids that may overlap or touch (a chimney through a roof, a house on a plinth); check() tests each one alone.
  2. Open seams come from shapes that stop where another begins: walls that end flat under a sloping roof, a roof that is only its top.
  3. Flipped faces: a polygon given in the wrong order faces in.
  4. Stretched UVs: UVs are metres in each face’s own plane (or round a lathe, or along a sweep), so a texture keeps its size.
  5. Too many draws: one draw per slot for everything added once, one per slot for each repeated shape.
3 more in brief
  1. Gable and shed roofs need a rectangular footprint, and hipped and flat roofs a convex one: build an L-shaped house from two rectangles with a roof each, overlapping.
  2. A sweep keeps its profile upright: it is for things that run along the ground (walls, quays, kerbs, rails).
  3. Vertex colours: a slot with any coloured solid gets a colour attribute; its material needs vertexColors: true, and white is used for the solids without one.
8 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

Written for the library. Fully custom code.

Petr Felkel and Štěpán Obdržálek, “Straight Skeleton Implementation” (1998): the wavefront idea behind the hipped roofs: edges move inward at one speed and an edge that shrinks away leaves a node. Written here for convex footprints only (edge events, no splits)

Martin Newell: the polygon normal from summed edge cross terms, used to face every polygon the right way

David Eberly, “Triangulation by Ear Clipping” (Geometric Tools, 2002): ear clipping; here the fullest ear is taken first, and points on straight edges are set aside and put back by splitting, so no flat triangle is made

proceduralgeometrymeshclosed meshwatertightnormalscrease angleuvworld uvroofstraight skeletonlathesweepbevelwindowsinstancingdraw callsmesh checkthree.jswebgpuwebglno dependencies

Near it in the frame