Skip to content

Harden the 3D runtime: multi-mount hooks, cycle breaking, group order - #149

Open
peluche20-code wants to merge 1 commit into
wheresryan22:mainfrom
peluche20-code:fix/turn-runtime-hardening
Open

peluche20-code wants to merge 1 commit into
wheresryan22:mainfrom
peluche20-code:fix/turn-runtime-hardening

Conversation

@peluche20-code

Copy link
Copy Markdown

What

Three small fixes in the 3D runtime, applied identically to kit/turn.mjs and kit/turn-fixed.mjs, plus some dead-code cleanup.

  1. window.__isoTurn with several figures. A second TURN.mount overwrote the first one's hook, so drive/turn-check could only reach the last figure. Every mount is now also listed in window.__isoTurns. __isoTurn still points at the latest mount, so existing scripts are unchanged. destroy() removes the mount from the list and falls back to the previous one instead of deleting the hook.
  2. breakCycle in t3Order. It returned as soon as it found the first cycle, even when every edge of that cycle had already been checked. The caller then went straight to a forced pick, and other cycles that could be resolved were never examined. It now keeps scanning when the first cycle has no droppable edge.
  3. t3Poses. A group whose parent index is not smaller than its own was silently treated as a root, giving a wrong pose. It now throws a clear error. The builder always creates parents first, so valid data is unaffected.
  4. Cleanup. Removed unused x0/x1/buf in t3EmitPrism and a duplicated, mis-indented lines.key.length = 0; (prism and tube emitters).

Testing

node --test scripts/*.test.mjs with the CI's test dependencies (react 19.3.0, react-dom 19.3.0, typescript 5.9.3, esbuild 0.28.2): 290/290 pass, both before and after the change.

Note: no existing test forces a cycle that the old breakCycle could not resolve, so change 2 is not covered by a test. I can add a regression fixture if you point me at the preferred place.

Not changed

t3Gjk approximates separation over sampled point clouds rather than the full solids, so its margin can be overestimated in edge cases. I left it alone, since changing it needs the orbit audits.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EkT8JhFhSNjE5CbJJiP1Zh

- window.__isoTurns lists every mounted figure; window.__isoTurn still
  points at the latest one, and destroy() falls back to the previous
  mount instead of deleting the hook.
- t3Order/breakCycle keeps scanning for other cycles when the first one
  has no droppable edge, instead of going straight to a forced pick.
- t3Poses throws a clear error when a group's parent does not come
  before it, instead of silently treating it as a root.
- Remove unused variables and a duplicated line.

Applied identically to kit/turn.mjs and kit/turn-fixed.mjs.
All 290 tests in scripts/*.test.mjs pass before and after.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EkT8JhFhSNjE5CbJJiP1Zh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant