I have two squares in space which are something like front and back wall of cube
one vith 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
second
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 distanceTo from camera like this
var point1 = this.camera.matrixWorld.getPosition().clone();
var point2 = this.mesh.cubePlane3.children[0].matrixWorld.getPosition().clone();
var distance = point1.distanceTo( point2 );
I have always the same distance for both 20,09. These squres are rotated in space, so only rotation is changed and I would need somehow find out which wall is closer to camera to be able to do something that in cube 3 walls closer to camera are not displayed and next 3 walls are displayed.
And obviously I do not understand math behind this, for example why walls which are next to each other one have positive coordinates for y and next negative + why distance is the same value, when one is closer on z axis than second. Can you pls someone help me how I can get closer walls? Thank you