update method
Advances all registered clips by deltaSeconds and applies their
blended result to the bound nodes.
Resets each animated node to its bind pose, advances every clip by
the delta, normalizes weights when their sum exceeds 1, and then
writes the resulting (translation, rotation, scale) decomposition
back to Node.localTransform.
Implementation
void update(double deltaSeconds) {
// Reset the animated pose state.
for (final transforms in _targetTransforms.values) {
transforms.animatedPose = transforms.bindPose.clone();
}
// Compute a weight multiplier for normalizing the animation.
double totalWeight = 0.0;
for (final clip in _clips.values) {
totalWeight += clip.weight;
}
double weightMultiplier = totalWeight > 1.0 ? 1.0 / totalWeight : 1.0;
// Update and apply all clips to the animation pose state.
for (final clip in _clips.values) {
clip.advance(deltaSeconds);
clip.applyToBindings(_targetTransforms, weightMultiplier);
}
// Apply the animated pose to the bound joints.
for (final entry in _targetTransforms.entries) {
final node = entry.key;
final transforms = entry.value;
node.localTransform = transforms.animatedPose.toMatrix4();
}
}