I downloaded the model using OBJLoader, here is the code to download the obj file:
var loader = new THREE.OBJLoader();
loader.load('obj/teeth/teeth4_5.obj', function(object) {
model = object;
scene.add( model );
objects.push( model );
});
And I'm trying to use raycaster to find the intersection. I executed my code from the canvas_interactive_cubes example ( http://mrdoob.imtqy.com/three.js/examples/canvas_interactive_cubes.html ) in the three.js file. Here is the code to find the intersection:
function onDocumentMouseDown( event ){
event.preventDefault();
var mouseX = (event.clientX / window.innerWidth)*2-1;
var mouseY = -(event.clientY /window.innerHeight)*2+1;
var vector = new THREE.Vector3( mouseX, mouseY, 0.5 );
projector.unprojectVector( vector, camera );
var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
var intersects = raycaster.intersectObjects( scene.children );
console.log( intersects[0].point);
}
Unfortunately, I can’t get the x, y, z coordinates of the intersection, no matter where I clicked, it always showed “TypeError: intersects [0] is undefined”.
I have been stuck here for several days. Can someone tell me a way to get the intersection in the downloaded obj file? I appreciate your help.
source
share