An active animation pauses while a separate node matrix is being updated onTick.
I have created a minimized sandcastle to replicate this.
The left propeller spins via animation. The right propeller spins via matrix manipulation onTick.
(Click the checkmark in the top left to start/stop the right propeller.)
This is not a duplicate of this post, as that person is trying to manipulate an animating node, while I am manipulating a separate node, and it is still causing animations to pause.
I wanted to let you know that we are investigating this issue and someone from our team will be in contact when we know more.
Based on code and the documentation for
ModelNode, I believe the
matrix property is intended to override the existing animation:
A model node with a modifiable transform to allow users to define their own animations. While a model’s asset can contain animations that target a node’s transform, this class allows users to change a node’s transform externally. In this way, animation can be driven by another source, not just by the model’s asset.
Setting the matrix to undefined will restore the
node’s original transform, and allow the node to be animated by
any animations in the model again.
So this is the intended behavior.
Can I ask for a bit more information on your intended use case? It may make sense to take a different approach, or perhaps there is a workaround that can be used.
Hi @Gabby_Getz, thanks for looking into this.
I am not changing the matrix of the animating node; I am changing the matrix of a different node.
In the sandcastle I provided, I only play the animation of the left propeller. The right propeller is untouched until you click the checkbox to start rotating via matrix manipulation.
But upon starting the matrix changes on the right propeller (by clicking the checkbox), the left propeller stops animating, and it will continue its animation once you uncheck that checkbox.
The two nodes are unrelated, but updating one freezes the other.
The use-case for this is playing a propeller animation and also updating a landing gear position (based on “current position” defined elsewhere). In this scenario, I found that the landing gear matrix changing caused the propeller animation to freeze until the matrix stopped being updated:
if (modelNode.matrix.equals(newMatrix)) return
I have considered an alternative solution like defining animations in the model for landing gear moving and jumping to a specific frame along the animation based on “current position”, but that is a layer of abstraction which adds complication and is less accurate than direct matrix manipulation.
This is a hack, but it might help us understand where the problem is:
// Update node position/orientation matrix
modelNode.matrix = newMatrix;
// Prevent change to existing animations
model._userAnimationDirty = false;
See this updated Sandcastle.
Interesting, thank you @jjhembd.
Perhaps I misunderstood @Gabby_Getz about intentional behavior. I assumed a specific node playing an animation would appear to have the animation stop if the node’s matrix was updated (overriding the animation’s matrix update).
The existence of a
model._userAnimationDirty property leads me to believe the logic is “if any node has been touched, skip all animation updates”, but this is a weak assumption.
Surely this is not the intended behavior.
Thanks @Tawm, understood. I’ve written up a bug report. @jjhembd’s workaround will work in the meantime.