Currently: I have a sphere with a texture on it that rotates around the y axis. I also have a position that was pressed in 3D space, as well as a rotated position on the sphere (I think).
Purpose: to get a position on the texture, for example: I want to get the square of the image that I click on. (See Example Spheres and image below)
In practice, I will not use this image, but I felt that it would be a good starting point.
Code To obtain a position in a sphere based on this example :
function onDocumentMouseDown( event ) {
event.preventDefault();
mouse.x = ( event.clientX / renderer.domElement.clientWidth ) * 2 - 1;
mouse.y = - ( event.clientY / renderer.domElement.clientHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
var intersects = raycaster.intersectObjects( objects );
if ( intersects.length > 0 ) {
console.log(intersects[ 0 ].point);
var vector = new THREE.Vector3( 1, 0, 0 );
var axis = new THREE.Vector3( 0, 1, 0 );
var angle = objects[ 0 ].rotation.y;
intersects[ 0 ].point = vector.applyAxisAngle( axis, angle );
console.log(intersects[ 0 ].point);
}
}
Scope:

Image Capture:

Chris source
share