fix(doors): correct folding fold direction + make open-clip names unique per node

Two issues surfaced testing the baked viewer:

- Folding door folded toward +z (into the room) — the joint rotation sign
  was inverted, so the accordion opened the wrong way ("weird position").
  Flip to `(prevDirection - direction) * foldAngle` so leaves fold toward
  −z, matching the original inline rig. Verified panel-for-panel against the
  original formula at every operationState.

- Openable clips were named by display name (`<name>: open`), but the baked
  viewer drives playback by clip name (`useAnimations` maps name → action).
  Several windows share the name "Window 1", so their clips collapsed to one
  action and triggering any one opened the first. Key the clip name by node
  id (`<id>: open`) — unique, matching the item-loop convention; the
  human-readable name still lives in `extras.label`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wassim SAMAD
2026-06-26 11:12:47 -04:00
co-authored by Claude Opus 4.8
parent c629171607
commit 4c81435e3b
3 changed files with 23 additions and 19 deletions
@@ -1401,7 +1401,8 @@ export function poseDoorMovingParts(
const foldAngle = Math.PI * 0.44 * t
// Each panel group is parented to the previous, so its rotation is the
// joint angle (the change in absolute segment direction), not the absolute
// angle: alternating panels target ±foldAngle, so joints fold by ±2·angle.
// angle: alternating panels target foldAngle, so joints fold by ±2·angle.
// The leading sign folds the leaves toward z (matching the original rig).
let posed = false
let prevDirection = 0
for (let index = 0; index < panelCount; index++) {
@@ -1409,7 +1410,7 @@ export function poseDoorMovingParts(
const direction = index % 2 === 0 ? -1 : 1
if (group) {
posed = true
group.rotation.y = (direction - prevDirection) * foldAngle
group.rotation.y = (prevDirection - direction) * foldAngle
}
prevDirection = direction
}