Hi guys
I would like to know how can i get the 3d coordinates from a collision point mouse 2d
from this code
function onDocumentMouseDown( event ) {
event.preventDefault();
mouse2d.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse2d.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
mouse2d.z = 1;
var r = new THREE.Ray();
r.origin.copy( mouse2d );
var matrix = camera.matrixWorld.clone();
matrix.multiplySelf( THREE.Matrix4.makeInvert( camera.projectionMatrix ) );
matrix.multiplyVector3( r.origin );
r.direction = r.origin.clone().subSelf( camera.position );
var c = THREE.Collisions.rayCastNearest( r );
if( c ) {
//////////////////HERE GET THE 3D POINT COORDINATES////////////////////////
c.mesh.materials[ 0 ].color.setHex( 0xaa0000 );
} else {
plane.materials[0].color.setHex( 0xF9EFD7 );
}
};
The collision object is a plane which i use as ground and i want to know the collision point 3d coords in order to set an object’s position.
Thanks in advance
Never mind found it