diff --git a/src/objects/InstancedMesh.js b/src/objects/InstancedMesh.js index 5cf45f4fb8bf36..dcf64fc5c8df12 100644 --- a/src/objects/InstancedMesh.js +++ b/src/objects/InstancedMesh.js @@ -136,6 +136,17 @@ class InstancedMesh extends Mesh { if ( _mesh.material === undefined ) return; + // test with bounding sphere first + + if ( this.boundingSphere === null ) this.computeBoundingSphere(); + + _sphere.copy( this.boundingSphere ); + _sphere.applyMatrix4( matrixWorld ); + + if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return; + + // now test each instance + for ( let instanceId = 0; instanceId < raycastTimes; instanceId ++ ) { // calculate the world matrix for each instance