I encountered a strange behaviour, when I set position of one mesh as position of another and then lerp it, it will only move one of the meshes. Unfortunately for me, it is even the wrong mesh thats position get lerped (group has to move not spawnpoint). Maybe someone knows from if it is a bug or anything else?
By the following lines the group-node position is set to spawnpoint-mesh position:
group.position = spawn.position; // behaviour is as expected by using clone()
If you don’t want all the group’s positions and the spawn position to share the same Vector3 object, then I would use clone() or copyFrom() instead of assigning the same object to all of them. Usually I would use copyFrom to copy the wanted values to the existing object rather than creating a new object with clone().
You are right, clone() or copyFrom() would be a solution, like I posted above. Might switch like you say to copyFrom. I just wondered and wanted to share (if it is really a bug) why only one mesh (spawnpoint) would move, but maybe reference is lost somehow for unit group?
For me at least, it would be hard to look into without downloading and running the repo and looking over the project more… It would be better to create a small playground repro that’s easier to investigate IMO.
If you eg call markDirty() on each mesh after lerping their shared position then computeWorld matrix will know that each mesh need its world matrix updated. Otherwise position._isDirty is reset to false after the world matrix is computed for the first mesh so the next meshes’ world matrices are thought to be up to date when computeWorldMatrix is called for them. EG you could also fix it by calling computeWordMatrix(true) for each mesh after lerping them (edit: but I would call markDirty() instead like I showed below)…
I see. Good to know there is this functionality with _isDirty and markDirty() to control world matrix update. In my case copyFrom() seems to be best solution, because I don’t want both to move.
Hey!
This is because in this case both objects share the same dirty flag which means that when one object computes his world matrix, it resets the dirty flags and thus the second object does not update his own matrix because he thinks he is not dirty