In my latest project, I've created a unique scene that involves placing my camera inside a sphere geometry.
var mat = new THREE.MeshBasicMaterial({map: THREE.ImageUtils.loadTexture('0.jpg') , overdraw:true, color: 0xffffff, wireframe: false });
var sphereGeo = new THREE.SphereGeometry(1000,50,50);
var sphere = new THREE.Mesh(sphereGeo,mat);
sphere.scale.x = -1;
sphere.doubleSided = false;
scene.add(sphere);
One of the features I'm trying to implement allows me to move around within the sphere and cast a ray on mouse down to determine the coordinates of the point where the ray hits the sphere. However, I'm facing an issue with empty intersects when I cast the ray.
var vector = new THREE.Vector3();
vector.set( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
vector.unproject( camera );
raycaster.ray.set( camera.position, vector.sub( camera.position ).normalize());
var intersects = raycaster.intersectObjects(scene.children, true);
I have successfully tested this functionality with a cube placed inside the sphere. Now, I'm wondering if it matters whether you hit the object from the inside or not, as this could be a potential explanation for the issue I'm encountering.
Any insights or suggestions would be greatly appreciated. Thank you!