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


Hey everyone!

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.

Best Answer

  • Bakari Mustafa
    Bakari Mustafa Posts: 178 🔥🔥🔥
    #2 Answer ✓

    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.


  • Daria Keller

    Ah, got it! So in that case the coordinates are calculated relative to the camera, but not to scene 0, 0, 0.