Tiny sphere-physics engine for three.js games: spawn, step, raycast, InstancedMesh-ready positions
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent โ or use 1-click editor setup below.
One-click editor setup isnโt available for this listing yet โ we donโt have a confirmed install command, and weโd rather show nothing than point your editor at the wrong package or host. Follow the projectโs own setup instructions, linked above.
Flit is a tiny little physics engine for 3js. It doesn't do much yet! but I believe!
Spheres, collisions, raycasts, gravity, and a spatial-hash broadphase โ nothing more, on purpose.
All simulation state lives in flat Float32Arrays (structure-of-arrays), so
the CPU path doubles as the reference implementation for a future WebGPU
compute backend: same buffers, same kernels, no re-architecting.
World โ point-sphere particles, semi-implicit Euler integration,
impulse + positional-correction contact solver, infinite ground plane.
Bodies that stay quiet SETTLE (per-body sleep driven by a stiction
threshold), so resting piles cost ~nothing; a fast-enough impact wakes
them, a slow push is held by static friction.Heightfield โ 2.5D terrain as a grid of height posts, no meshing:
bilinear height + central-difference normals sampled directly for
collision, and a 2D Amanatides-Woo DDA for raycasts (index: -1).SpatialHash โ uniform grid broadphase keyed by Morton (Z-order)
cell codes. This is the Euclidean cousin in the LSH family: MinHash
buckets documents by Jaccard similarity; this buckets positions so
nearby points collide in the same bucket. Morton keys are bijective
(no hash-collision pair bloat), invertible (no side table), and
locality-ordered for a future sorted-array GPU backend.THIRD_PARTY_NOTICES.md for provenance and licenses.Building a little three.js game or demo? Two ways in:
skills/flit/SKILL.md โ copy the skills/flit/ directory into
your agent's skills path (e.g. .claude/skills/, ~/.code_puppy/skills/).
It carries the 30-second integration recipe, the MCP option, measured
performance envelope, and contributor rules.npm run mcp, or point your client at it:Tools: flit_info, flit_reset (gravity/restitution/ground/bounds/
settleSpeed/heightfield), flit_spawn (rain/explosion/grid/fountain
presets), flit_add_particles, flit_step, flit_state, flit_raycast
โ step/state return flat xyz positions shaped for InstancedMesh syncing
plus settledCount, so you can watch a pile go quiet.
Terrain and sleep are one option each:
Deterministic seeds; numbers from a local dev machine, recorded at commit time (see commit messages for the full series, including rejected designs).
bench/broadphase.bench.ts โ broadphase only, N=4096:
xor-hash 3.4โ3.7 ms (444 pairs, ~90% collision bloat) โ Morton keys
with ordered probing 3.5โ3.7 ms (234 pairs, exact).bench/world.bench.ts โ full World.step, N=1024:
xor-hash 0.85 ms/step โ Morton ordered-probing 0.83 ms/step โ
0.93 ms/step with the sequential-impulse velocity solver
(4 iterations + LUT friction). Exact keys, real contacts, +11%.bench/scaling.bench.ts โ two regimes. Fixed box (density rises):
pairs scale ~Nยฒ from crowding physics. Scaled box (constant spawn
density): flat O(N) โ 1.2 ms per 1000 through N=8000 while bodies are
scattered. With gravity on, everything rains into a dense floor pile
over ~2-4s (WARMUP=240 to reproduce) โ and since 0.3.0 the pile
SETTLES: 34.2 โ 9.2 ms/step at N=8000 (3.7x, inside the 60fps
budget) as bodies fall asleep bottom-up. Settled bodies are skipped
by integration, planes, and mutual contacts until a >1 m/s impact
wakes them. (docs/issues/001 โ resolved; brief kept for the
analysis and the remaining ideas: warm starting, adaptive iterations.)bench/raycast.bench.ts โ 2000 seeded rays at N=4096:
63โ68 ยตs/ray (vs ~160 ยตs for a brute-force O(N) oracle at the
same density; the grid walk pulls further ahead as N grows).bench/morton-libs.bench.ts โ codec bake-off vs npm libs
(npm run bench:libs): ours 3.8 ns/encode, fast-morton MB 26.1,
fast-morton LUT 43.8, @thi.ng/morton 539.9. In-house wins; the libs
stay as devDependencies purely so the bake-off stays runnable.bench/threaded.bench.ts โ WorkerWorld over a real worker thread
(SAB ping-pong): kick() costs 0.014 ms on the main thread; with a
4 ms render workload a frame costs 8.84 ms pipelined vs 14.96 ms
serial at N=8192 (113 fps vs 67). At N=1024 the 0.8 ms step hides
entirely behind render (4.03 vs 4.80 ms).npm run demo, 220 balls in a box
(?terrain for heightfield hills, ?n=8000 for load testing)WorkerWorld: kick/waitForUpdate, SAB
ping-pong zero-copy rendering3173a6f for the analysisMIT โ see LICENSE. Third-party portions and their licenses are listed in
THIRD_PARTY_NOTICES.md.
No reviews yet โ be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/flit-2)<a href="https://allmcps.com/mcp/flit-2"><img src="https://allmcps.com/api/badge/flit-2?style=directory" alt="Flit on AllMCPs" /></a>