Skip to content

Scene: AnimationMixer and AnimationAction, as three.js has them - #254

Open
kvnloo wants to merge 3 commits into
meshy-dev:mainfrom
kvnloo:swarm/b05-parity-mixer
Open

kvnloo wants to merge 3 commits into
meshy-dev:mainfrom
kvnloo:swarm/b05-parity-mixer

Conversation

@kvnloo

@kvnloo kvnloo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Depends on #250. This branch is #250's commit plus one more. Review the last commit (Scene: AnimationMixer and AnimationAction). Once #250 lands, the diff shrinks to that commit.

Adds three.js's clip player to the scene package (packages/scene/src/animation-mixer.ts), ported from r187:

  • AnimationMixer: clipAction (by clip or by name from root.animations), existingAction, update, setTime, stopAllAction, uncacheClip / uncacheRoot / uncacheAction, getRoot, timeScale, stats, and the loop / finished events.
  • AnimationAction: play / stop / reset, setLoop (LoopOnce, LoopRepeat, LoopPingPong, repetitions), clampWhenFinished, startAt, weights and fades (fadeIn, fadeOut, crossFadeFrom / crossFadeTo with warp), time scale (warp, halt, setDuration, syncWith), and normal and additive blending.
  • PropertyBinding (track-name parsing, finding nodes by name, and .material.* / .materials[i] / .map paths) and PropertyMixer (weighted accumulation, slerp for quaternions, restore on stop).

Why: mixer = new THREE.AnimationMixer(root); mixer.clipAction(clip).play(); mixer.update(dt) is how three.js code animates doors, lights, props and material fades. With this it runs on ThreeRT scene objects. The writes go through position.set / quaternion.set / Color.fromArray, so the binding sees them the same way it sees edits made by hand.

Differences from three.js, all forced by ThreeRT's objects:

  • Roots are keyed by uuid when they have one, and otherwise by a key the mixer assigns. ThreeRT objects have no uuid.
  • matrixWorldNeedsUpdate is not set on objects. ThreeRT's transforms report their own changes, and its objects have no such flag.
  • toArray reads accept the package's Vector3 / Quaternion.toArray(), which return a new array instead of writing into one.
  • The mixer has its own small event dispatcher.
  • Not ported: AnimationObjectGroup, and the skeleton/morph-target paths. ThreeRT scene objects have no bones or morph targets, and glTF models animate through GLTFModel.animation.

Merge gate: tier T. This adds TypeScript API and changes nothing the renderer draws.

  • npm run typecheck: passes
  • npm test: passes, 0 failures. Each scenario in the new packages/scene/test/three-compat-animation-mixer.test.ts builds the same rig (a group, a mesh with a standard material, a child) with ThreeRT and with three r187, runs the same mixer calls, and requires the written state to be deep-equal at every step: position, quaternion, scale, visible, opacity, colour and the child's position. The scenarios cover repeat/loop events/stop-restore, LoopOnce+clamp, ping-pong with repetitions, running backwards, a warped cross-fade, additive over a half-weight base, setTime/startAt/halt/setDuration/uncache, and track-name parsing. As a mutation check, changing the bool select threshold and the loop-count rounding makes 2 of the 7 tests fail.
  • test:render was not run. No engine encoding or scene description changes.

Drafted with AI assistance.

🤖 Generated with Claude Code

kvnloo and others added 2 commits November 24, 2026 00:07
… has them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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