Setting isDirty on TransformNode.rotate

(beware: complete novice, probably don’t know what I’m talking about)

I’m currently debugging a weird problem with objects rotating around their axes. I’m using TransformNode’ s rotate method and the problem is that in some cases after rotation there is no change in the model, i.e. it’s not visually rotated, while the rotationQuaternion has changed to the right value.

From what I’ve seen in the source code and from my understanding, the property _isDirty should be set on the TransformNode for an update to trigger. This property is set in the setter of rotationQuaternion, however, the rotate method does not actually set the rotationQuaternion reference to a new value, it updates the inner values with rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion) instead.

Am I missing something major? How is the rotate method supposed to work, should I be setting some other properties somewhere?

1 Like

aren’t we all? :slight_smile:

Are you able to reproduce this so we can see exactly what the issue is?

The new rotationQuaternion should be applied in the next render loop when computing the world matrix. You can force-compute the matrix if the value was not set, but this should happen automatically for you. Would be great to see a playground and understand what went wrong.


Thanks for your patience, we’ve solved the problem. As expected, it has been a mistake in own code.

At one point we are re-shuffling and cloning meshes from imported GLTFs around to get them into a shape we expect. When cloning we make sure to copy several properties from one mesh to another including rotation and rotationQuaternion. However, what we failed to do is to actually clone these properties instead of just assigning them. So when I’ve said there was no visible rotation, it seems I’ve been rotating the wrong (currently invisible) object all along. Adding .clone() to rotationQuaternion when copying resolved the problem.