Currently working with three.js r67 on Chrome Version 35.0.1916.153 m
I am trying to intersect some custom meshes I created in my scene, but the raycaster doesn't seem to be detecting them even though they are present in scene.children.
Here is my mesh creation code:
if (modelVertices != null && modelVertices.length >= 3) {
triangles = THREE.Shape.Utils.triangulateShape( modelVertices, holes );
for( var i = 0; i < triangles.length; i++ ){
modelGeometry.faces.push( new THREE.Face3( triangles[i][0], triangles[i][1], triangles[i][2] ));
}
modelGeometry.computeFaceNormals();
var modelMesh = new THREE.Mesh(modelGeometry, material);
modelMesh.material.side = THREE.DoubleSide;
polyhedralzGroup.add(modelMesh)
}
Raycasting code:
var projector = new THREE.Projector();
projector.unprojectVector( vector, camera );
var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
var intersects = raycaster.intersectObjects( scene.children, true );
helper.position.set( 0, 0, 0 );
if (intersects.length > 0 ) {
if (intersects[ 0 ].face != null) {
helper.lookAt( intersects[ 0 ].face.normal );
helper.position.copy( intersects[ 0 ].point );
}
It's worth noting that although computeFaceNormals() is used, it doesn't seem to be the issue (source). Interestingly, the scene does intersect other geometries made up of simple triangles without any issues. This rules out canvas offset as a problem and upon inspection, both types of geometries appear to be similar.
Any thoughts on what might be causing this issue?