reloadParsedAnimations method

void reloadParsedAnimations(
  1. List<Animation> animations, {
  2. Matrix4? restPoseOf(
    1. Node node
    )?,
})

Replaces this node's parsed animations with animations and re-binds any AnimationClips created from the old set (matched by name), keeping their playback state.

Used by scene hot reload when a reloaded scene's animations changed. The re-bind recaptures each bound node's rest pose from its current local transform; pass restPoseOf to supply the authored rest transform instead, so a node frozen mid-playback does not have its animated pose captured as the rest pose.

Implementation

void reloadParsedAnimations(
  List<Animation> animations, {
  Matrix4? Function(Node node)? restPoseOf,
}) {
  _animations
    ..clear()
    ..addAll(animations);
  final player = _animationPlayer;
  if (player == null) return;
  if (restPoseOf != null) {
    for (final animation in _animations) {
      for (final channel in animation.channels) {
        final nodeName = channel.bindTarget.nodeName;
        final target = nodeName == name ? this : getChildByName(nodeName);
        if (target == null) continue;
        final pose = restPoseOf(target);
        if (pose != null) target.localTransform = pose;
      }
    }
  }
  player.rebind(this, animations: _animations);
}