I'm using ThreeJS, how can you create an object / mesh on mouse click. Currently the object is not created on the exact mouse x and y position.
var ge = new THREE.BoxBufferGeometry( 2, 2, 2 );
ge.scale(2, 2, 2);
var my = new THREE.MeshBasicMaterial( {
map: new THREE.TextureLoader().load( 'crate.gif' )
} );
ms = new THREE.Mesh( ge, my );
var raycaster = new THREE.Raycaster();
var mouse = new THREE.Vector2();
mouse.x = ( event.clientX / renderer.domElement.width ) * 2 - 1;
mouse.y = - ( event.clientY / renderer.domElement.height ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
ms.position.x=raycaster.ray.direction.x;
ms.position.y=raycaster.ray.direction.y;
ms.position.z=raycaster.ray.direction.z;
scene.add( ms );
