I am working with two squares positioned in space, resembling the front and back walls of a cube with specific vertices:
x=-2 y=-1138 z=-2;
x=-2 y=-1134 z=-2;
x=2 y=-1138 z=-2;
x=2 y=-1134 z=-2
The second square is defined by the following vertices:
x=-2 y=1134 z=2;
x=-2 y=1138 z=2;
x=2 y=1134 z=2;
x=2 y=1138 z=2
When I calculate the distance from the camera using the following code snippet:
var point1 = this.camera.matrixWorld.getPosition().clone();
var point2 = this.mesh.cubePlane3.children[0].matrixWorld.getPosition().clone();
var distance = point1.distanceTo( point2 );
I consistently get the same distance of 20.09 for both squares. These squares are rotated in space, so only the rotation changes. I am trying to determine which wall is closer to the camera in order to selectively display walls in the cube. However, I am struggling to understand the mathematics behind this. For instance, I am puzzled by the fact that adjacent walls have different y-coordinates (positive and negative) and why the distance remains the same even when one wall is closer along the z-axis than the other. Can someone please help me figure out how to identify the closer walls? Thank you.