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

Function intersectObject

Three.js/js/Three62.js:6805–7124  ·  view source on GitHub ↗
( object, raycaster, intersects )

Source from the content-addressed store, hash-verified

6803 var vC = new THREE.Vector3();
6804
6805 var intersectObject = function ( object, raycaster, intersects ) {
6806
6807 if ( object instanceof THREE.Sprite ) {
6808
6809 matrixPosition.getPositionFromMatrix( object.matrixWorld );
6810 var distance = raycaster.ray.distanceToPoint( matrixPosition );
6811
6812 if ( distance > object.scale.x ) {
6813
6814 return intersects;
6815
6816 }
6817
6818 intersects.push( {
6819
6820 distance: distance,
6821 point: object.position,
6822 face: null,
6823 object: object
6824
6825 } );
6826
6827 } else if ( object instanceof THREE.LOD ) {
6828
6829 matrixPosition.getPositionFromMatrix( object.matrixWorld );
6830 var distance = raycaster.ray.origin.distanceTo( matrixPosition );
6831
6832 intersectObject( object.getObjectForDistance( distance ), raycaster, intersects );
6833
6834 } else if ( object instanceof THREE.Mesh ) {
6835
6836 var geometry = object.geometry;
6837
6838 // Checking boundingSphere distance to ray
6839
6840 if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
6841
6842 sphere.copy( geometry.boundingSphere );
6843 sphere.applyMatrix4( object.matrixWorld );
6844
6845 if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) {
6846
6847 return intersects;
6848
6849 }
6850
6851 // Check boundingBox before continuing
6852
6853 inverseMatrix.getInverse( object.matrixWorld );
6854 localRay.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
6855
6856 if ( geometry.boundingBox !== null ) {
6857
6858 if ( localRay.isIntersectionBox( geometry.boundingBox ) === false ) {
6859
6860 return intersects;
6861
6862 }

Callers 2

intersectDescendantsFunction · 0.70
Three62.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected