( object, raycaster, intersects )
| 7019 | var vC = new THREE.Vector3(); |
| 7020 | |
| 7021 | var intersectObject = function ( object, raycaster, intersects ) { |
| 7022 | |
| 7023 | if ( object instanceof THREE.Sprite ) { |
| 7024 | |
| 7025 | matrixPosition.setFromMatrixPosition( object.matrixWorld ); |
| 7026 | |
| 7027 | var distance = raycaster.ray.distanceToPoint( matrixPosition ); |
| 7028 | |
| 7029 | if ( distance > object.scale.x ) { |
| 7030 | |
| 7031 | return intersects; |
| 7032 | |
| 7033 | } |
| 7034 | |
| 7035 | intersects.push( { |
| 7036 | |
| 7037 | distance: distance, |
| 7038 | point: object.position, |
| 7039 | face: null, |
| 7040 | object: object |
| 7041 | |
| 7042 | } ); |
| 7043 | |
| 7044 | } else if ( object instanceof THREE.LOD ) { |
| 7045 | |
| 7046 | matrixPosition.setFromMatrixPosition( object.matrixWorld ); |
| 7047 | var distance = raycaster.ray.origin.distanceTo( matrixPosition ); |
| 7048 | |
| 7049 | intersectObject( object.getObjectForDistance( distance ), raycaster, intersects ); |
| 7050 | |
| 7051 | } else if ( object instanceof THREE.Mesh ) { |
| 7052 | |
| 7053 | var geometry = object.geometry; |
| 7054 | |
| 7055 | // Checking boundingSphere distance to ray |
| 7056 | |
| 7057 | if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); |
| 7058 | |
| 7059 | sphere.copy( geometry.boundingSphere ); |
| 7060 | sphere.applyMatrix4( object.matrixWorld ); |
| 7061 | |
| 7062 | if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) { |
| 7063 | |
| 7064 | return intersects; |
| 7065 | |
| 7066 | } |
| 7067 | |
| 7068 | // Check boundingBox before continuing |
| 7069 | |
| 7070 | inverseMatrix.getInverse( object.matrixWorld ); |
| 7071 | localRay.copy( raycaster.ray ).applyMatrix4( inverseMatrix ); |
| 7072 | |
| 7073 | if ( geometry.boundingBox !== null ) { |
| 7074 | |
| 7075 | if ( localRay.isIntersectionBox( geometry.boundingBox ) === false ) { |
| 7076 | |
| 7077 | return intersects; |
| 7078 |
no outgoing calls
no test coverage detected