MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / intersectObject

Function intersectObject

Three.js/js/Three60.js:6791–7078  ·  view source on GitHub ↗
( object, raycaster, intersects )

Source from the content-addressed store, hash-verified

6789 var vC = new THREE.Vector3();
6790
6791 var intersectObject = function ( object, raycaster, intersects ) {
6792
6793 if ( object instanceof THREE.Particle ) {
6794
6795 matrixPosition.getPositionFromMatrix( object.matrixWorld );
6796 var distance = raycaster.ray.distanceToPoint( matrixPosition );
6797
6798 if ( distance > object.scale.x ) {
6799
6800 return intersects;
6801
6802 }
6803
6804 intersects.push( {
6805
6806 distance: distance,
6807 point: object.position,
6808 face: null,
6809 object: object
6810
6811 } );
6812
6813 } else if ( object instanceof THREE.LOD ) {
6814
6815 matrixPosition.getPositionFromMatrix( object.matrixWorld );
6816 var distance = raycaster.ray.origin.distanceTo( matrixPosition );
6817
6818 intersectObject( object.getObjectForDistance( distance ), raycaster, intersects );
6819
6820 } else if ( object instanceof THREE.Mesh ) {
6821
6822 var geometry = object.geometry;
6823
6824 // Checking boundingSphere distance to ray
6825
6826 if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
6827
6828 sphere.copy( geometry.boundingSphere );
6829 sphere.applyMatrix4( object.matrixWorld );
6830
6831 if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) {
6832
6833 return intersects;
6834
6835 }
6836
6837 // Check boundingBox before continuing
6838
6839 inverseMatrix.getInverse( object.matrixWorld );
6840 localRay.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
6841
6842 if ( geometry.boundingBox !== null ) {
6843
6844 if ( localRay.isIntersectionBox( geometry.boundingBox ) === false ) {
6845
6846 return intersects;
6847
6848 }

Callers 2

intersectDescendantsFunction · 0.70
Three60.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected