The live demo starts when it’s in view.Move over the site · click to place · drag posts or tiles · R turns · Copy, then paste
The answer a building game needs under the cursor: where a piece goes and whether it may go there.
It tries sockets first, then grids carried by placed pieces (tilted for roofs and ramps), then world grids, then bare ground, scores each and keeps one, with stable tie-breaks so a still cursor never flickers between two. A refusal stays at the socket you aimed for and says why in words: the volumes overlap, a port’s approach is blocked, the ground is too steep, the footpath is protected, nothing holds it up. Collision uses one oriented box per part, so a doorway stays open. On bare ground a machine stands level on feet, with props where the ground falls away. Rows and areas are dragged out with their total cost and checked against each other; a selection copies as a rigid blueprint that pastes turned, in one edit. Plain TypeScript, no dependencies, about 0.03 ms a cursor query.
What it costs a frame
GPU
1.51 ms
CPU
0.66 ms
02468101216.7 ms
GPU
1.51 ms
CPU, median
0.66 ms
CPU, 95th pct
1.51 ms
Draw calls
0
Weight
Moderate
Measured 25 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.49–1.55, CPU 0.60–0.70 ms). What ran: Alone: the cursor circles the bare grid and every frame runs the solver for a post (explain, then the query with its validation), draws the board, the hosts, the ghost and a marker for every candidate. CPU is mostly the solver; GPU one shadow map and a small instanced scene. 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.86 ms
1% low ?
55 fps
Varies by ?
±0.47 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · referenceHow 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.86 ms
p95 ?
17.73 ms
p99 ?
18.02 ms
Slowest ?
18.55 ms
Mean ?
16.87 ms
Standard deviation ?
0.47 ms
1% low ?
55 fps
0.1% low ?
54 fps
Hitches ?
0 of 600
Over budget ?
0 of 600
Main thread
Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.0 / 1.7 / 1.9 ms
Input
No input during this run.
Memory
JavaScript heap ?
33.6 → 33.3 MB
Growth ?
-0.26 MB
Browser
JavaScript a frame ?
0.61 ms
All tasks a frame ?
2.20 ms
Layout / style ?
0.51 / 0.30 ms
Main thread busy ?
13%
Garbage collection
Collections ?
18 (12 minor, 6 major)
Pauses ?
32.4 ms in all, longest 1.2
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("placement-solver")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up
What it’s for
A base-building or colony game: slabs, walls, roofs and machines that snap under the cursor and refuse with a reason
A factory or farm builder on uneven ground: machines on feet and props instead of a slab under everything
Dragging out fences, pipes, rows of posts or a floor of tiles with the cost shown before the click
Copying a finished building as a blueprint and pasting it turned, every join kept
A level editor or a room planner: sockets, grids and collision that leaves openings open
Scrapping safely: warn before removing the post a deck stands on
Pitfalls, in brief
The demo needs WebGPU to draw its build site; the solver itself is plain TypeScript and runs anywhere (a server, a worker, a Canvas 2D or three.js page).
Pass the visible hit as the aim, and the camera ray with it.
Stand pieces on the ground the renderer draws.
A still cursor must give one ghost.
Socket direction decides the turn.
9 more in brief
Keep visible gaps between collision volumes.
Pinwheel walls round a room.
Load paths come from compatible sockets, bearing faces, fitted feet and bracket fastenings.
Clip a carried grid to the polygon of a triangular face.
Machines on bare ground stand at the highest ground under them, clearance (30 cm) above it, on a foot at each corner: a base flush with the grass reads as floating.
Terrace pieces (levels) quantize their top against the highest ground and report the gap along each edge instead of feet: draw a plinth or skirt down to the lowest ground under them, as the demo’s slabs do, or the low side hangs in the air.
Paste the anchor where the copied slab would itself snap (query the slab at the cursor and use its pose): a grounded part must meet the terrain at its new level, and refitting each part on its own after a paste breaks the joins.
Commit the preview you showed: world.commit revalidates it against the current world, so a socket that moved or was taken since the hover refuses as “The attachment moved”.
Prepare placements once per world edit.
14 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.
Hannes Andersson: The HaTac engine’s placement, spatial and ground-props modules and their measurements; the library’s host and demo.
Comment threads pinned to items or to spots, with replies, @mentions (the longest name wins), edit, resolve and reopen; task cards with a status, an assignee…