Ray collision fails with THREE.Sprite

775 Views Asked by At

I'm using projector and raycaster to intersect a Three.Sprite object, however, I could get the object even if I touch outside of the image bounding. So, I deep into the three.js file, and I found a piece of source:

var intersectObject = function ( object, raycaster, intersects ) {  
if ( object instanceof THREE.Sprite ) {  
   matrixPosition.getPositionFromMatrix( object.matrixWorld ); 
var distance = raycaster.ray.distanceToPoint( matrixPosition );
if ( distance > object.scale.x ) {
    return intersects;
} 
intersects.push( { 
    distance: distance, 
    point: object.position, 
    face: null, 
    object: object 
});

I couldn't understand if ( distance > object.scale.x ), I think it's the problem I meet. I am a newbie with Threejs. Does I go worng? Thanks for any help!!

0

There are 0 best solutions below