# three js Get position in space of 2 objects

If you have found a bug, or have a suggestion/comment then leave it here

### » Wed Jan 30, 2013 10:36 am

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
B
1
Posts: 1
Reputation: 227

### » Wed Jan 30, 2013 5:56 pm

I think you're on the wrong forum. This forum is not for general purpose javascript, but for construct 2, which does not have three.js integrated.
Moderator
B
90
S
32
G
33
Posts: 3,005
Reputation: 27,492

### » Thu Jan 31, 2013 1:36 am

you better ask question in stack overflow
B
104
S
29
G
23
Posts: 3,070
Reputation: 24,781