Speculating a little here about what exactly you may have encountered, one nuance of this system is that Babylon (I think) doesn’t proactively update world matrices when things like position/rotation/scale variables are changed. They’re updated eventually, but it’s often done “lazily” as a part of rendering unless you explicitly tell Babylon to recompute now. As a consequence of this, if you change a position/rotation/scale variable and then immediately query the world matrix without explicitly telling Babylon to recompute it, it may not reflect your changes yet.
Because you have a node hierarchy, then under certain circumstances if you call
nodeA.position.x += 1;
the output will not reflect your change because it hasn’t been propagated up the hierarchy yet. I made a quick Playground to explore this nuance.
Babylon.js Playground (babylonjs.com)
All four of the test cases should be interesting, but I think the ones you’ll care about most are cases 1 and 3. Case 1 sort of goes through the steps of the nuance manually. It starts by computing a world matrix for
nodeC so that that gets cached, then updates
nodeA and checks again. The updated value isn’t reflected because the cached value is being queried. It then recomputes the world matrix for
nodeA and tries again, but this doesn’t help because
nodeC is still recomputing itself from the cached world matrix on
nodeB. This is validated by then recomputing
nodeB's world matrix and trying again, at which point the updated value is shown.
Test case 3 shows a more practical approach than manually updating each level in the hierarchy. After updating
nodeA, we only have to call
computeWorldMatrix once with
force true because that will update
nodeB's cached world matrix. We can then call
force false on
nodeD and still get the correct result (though
getWorldMatrix will of course initially return the un-updated cached value) because
computeWorldMatrix will recompute the world matrix from
nodeB's cached world matrix, which was updated by the force call on
nodeC. I believe that test case 3 shows a way to get the updated world matrices on the same frame while only force-computing the world matrix for each node once, then reusing the cached values for the
Does this sound similar to the behavior you were seeing?