Preffered way of accessing the world position of a TransformNode

Hey there,

I have been thinking about a recent comment from @georgie in this PR about not using globalPosition for the cameras:

since globalPosition must be explicitly set by the camera class extension (its happening in targetCamera, but if someone is extending camera directly they wouldn’t have that code) i would recommend instead we use the camera’s worldMatrix this.activeCamera.getWorldMatrix().getTranslation()

Now I wonder if that applies to TransformNode objects as well.

Should I use node.getWorldMatrix().getTranslation() or node.getAbsolutePosition()?

They give the same result as shown in this PG:

Is there a preferred way nowadays?

getAbsolutePosition is guaranteed to be available on all TranformNode as the computeWorldMatrix is setting it up.

So for TN and their children I would recommend getAbsolutePosition

1 Like

Thanks for the answer, getAbsolutePosition it is then!

1 Like