three js Get position in space of 2 objects

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

Post » 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

Post » 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
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Jan 31, 2013 1:36 am

you better ask question in stack overflow
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613


Return to Website Issues and Feedback

Who is online

Users browsing this forum: No registered users and 1 guest