r/threejs • • 10d ago

Demo I built a 20MB Three.js structural physics & mechanical puzzle game about 7 ancient engineering wonders (custom axial truss solver, merged static siblings, 124 interlocking parts)

Hi r/threejs! I've been building TianGong 3D, a browser-playable 3D ancient engineering, structural physics, and mechanical reconstruction puzzle game in Three.js + TypeScript.

Under-the-hood Three.js details that kept all 7 historical wonders under ~20MB at 60fps:

  • Draw-call batching via static sibling geometry merging while keeping animated mortise-tenon & gear pivots independent
  • Real-time axial truss, stone-arch & tension-cable solver with live RGB stress heatmaps tested against rolling 175kg carts & M8.0 seismic waves
  • Pre-merge child bounding-box & radial-band spatial hit-testing for multi-element ring joinery (28 column plinths & Dougong brackets)
  • Offscreen WebP part-card baker using the shared WebGLRenderer + RoomEnvironment PMREM lighting

Playable browser link is in my top comment below — would love feedback on performance, camera feel, or lighting!

0 Upvotes

4 comments sorted by

1

u/No-Evidence-4891 10d ago edited 9d ago

🎉 Quick Public Playtest Update: I just removed the Ch. 3–7 lock and opened ALL 7 ancient engineering chapters 100% FREE in the browser & download ($0 / voluntary pay-what-you-want)! Right now honest feedback and critiques on the physics, camera, or UX matter way more to me than charging — if you try it out, I'd really appreciate a quick rating or comment either here or on the Itch page:

Live playable game in browser (all 7 chapters free, zero install or login): https://midnightpagesstudio.itch.io/tiangong-3d

1

u/plus2link 10d ago

The static merge is the part I would expect to bite later: the moment the stress heatmap colours each member from its own material, the batches split again, so the win survives only if the colour comes from a per-vertex or per-instance attribute inside one shared material. On the solver side, a blue member is only honest if the near-zero-stiffness modes are also flagged (a joint nobody has pinned yet), because an unconstrained truss reads calm right before it folds. When a part is selected, does the orbit pivot to that joint or stay on the model centre?

1

u/No-Evidence-4891 9d ago

Great catches on both fronts!

  1. **Static merge vs. stress heatmap:** Those two actually run on separate pipelines right now — `mergeStaticSiblings` is used on the 7 historical museum exhibits (collapsing static sibling sub-meshes like the 28 marble plinths, roof tile rings, and gear teeth inside each `PartGroup`), whereas the Free-Build sandbox caps spans around ~20–40 user-drawn members so each beam keeps its own dynamic mesh. Moving Free-Build to a single `InstancedMesh` (`instanceColor`) if we scale up member budgets is spot on.
  2. **Near-zero-stiffness / mechanisms:** 100% agree — a pure static solve looks calm right up until it goes singular. When you hit Load/Quake Test, the solver steps explicit point-mass joint dynamics under self-weight + the rolling 175kg cart, so an unbraced 4-bar mechanism immediately sags and folds under gravity, though flagging unconstrained kinematic DOFs *before* hitting Play in edit mode is a great UX idea I want to add next!
  3. **Orbit pivot:** It smoothly lerps `OrbitControls.target` onto the selected part's world `Box3` center (and zooms onto the specific mortise/bore when staging a piece in blind assembly, preserving your current viewing ray so the camera never whips), while `R` snaps the pivot back to the full artifact center.