Why a grid of objects has different z-coordinates in Lens Studio

Hey guys,

Glad to be here!

Quick question regarding objects’ position. I have a grid of individual objects, and all of them have the same Z-coordinate. However when I access objects’ position through getLocalPosition() or getWorldPosition() objects’ Z-coordinates differ from one another. How does this work and why is that so in general?

X and Y coordinates are also different, but this is obvious since objects have different X and Y location in the grid, but with Z I’m a little bit confused.

Do you have a test case you can share? It’s hard to say what the problem is just from your description. Are you using device tracking? It’s possible that the objects in the world are being transformed around the camera (like the camera is in a fixed position and the world moves around it)

Hey Josh,

Thank you for the reply! I’ve also asked this question in the Snap forum and got explanation from there. Here is what they’ve said:

"The Z-coordinate typically represents the depth or distance of an object from the viewer. Even though all of the objects in your grid have the same Z-coordinate when you create them, the Z-coordinate can change when the objects are transformed in relation to the camera or other objects.

For example, if you are using a 3D camera to view the objects, the Z-coordinate will change based on the distance between the camera and each object. Similarly, if you apply any kind of transformation such as rotation or scaling to any of the objects, it will affect its Z-coordinate."

1 Like