How does onBeforeDrawPhaseObservable work? (possible bug)

Not sure if this is a bug, but I noticed something strange.

Child nodes like mixamorig:LeftEye that do not have a corresponding bone are always dirty during the onBeforeDrawPhaseObservable phase. Do they not get de-flagged during this phase? What makes these nodes different from regular TransformNodes/Meshes?

PG: https://playground.babylonjs.com/#SYQW69#878

Only nodes for which we compute the world matrix have their isDirty flag reset, as this flag is only of use here. If the computeWorldMatrix method is never called for a node, the flag won’t be reset (but it’s not a problem).

What is the best way to know if a node has been updated per frame? My use-case is a function that reads and displays the values of a node on the frontend, ideally only if the node matrix has changed. In this case, the let node = scene.getNodeByName("mixamorig:LeftEye"); is always dirty so it will always cause the frontend to update every frame, which is what I’m trying to avoid

node is “mixamorig:Hips” which does get updated each frame because it’s a node which is updated by the animation. If you set node2._isDirty = false instead (node2 = “mixamorig:LeftEye”), you will see it remains false.

See my previous answer, you should set node._isDirty to false, not node2._isDirty.

Yea yea I know that was a typo (that’s why I removed that post)

I guess I was asking a more general question, maybe you could provide some expertise :stuck_out_tongue:

Basically, what is an efficient way to display the transform values of a node on some frontend. Obviously, updating the frontend values each frame might not be a good idea, so I do a _isDirty check in onBeforeDrawPhaseObservable. But this seems hacky
Setting ._isDirty = false is probably also not a good idea before the render phase
My question is, what is the better way to do this?

actually, does setting .isDirty = false for TransformNodes (not AbstractMeshes etc) even matter for the render phase?

I think the best way would be to add an observer to TransformNode.onAfterWorldMatrixUpdateObservable, as this observer will be triggered only if the world matrix has been updated, meaning if the transform node has been updated.

2 Likes

That makes a lot of sense, will test it. Thanks Evgeni!

1 Like