Browse Source

Sprite: Fix raycast bug

Raycasting with sprites is an approximation in that the sprite is treated as a disk. In addition, sprites can be non-square, and can be rotated.

With this change, if the sprite is square, the "clickable" region is inside the inscribed circle. If the sprite is non-square, the approximation is not very good, but it is better than before.
WestLangley 9 years ago
parent
commit
4112664807
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/objects/Sprite.js

+ 1 - 1
src/objects/Sprite.js

@@ -39,7 +39,7 @@ THREE.Sprite.prototype.raycast = ( function () {
 		matrixPosition.setFromMatrixPosition( this.matrixWorld );
 
 		var distanceSq = raycaster.ray.distanceSqToPoint( matrixPosition );
-		var guessSizeSq = this.scale.x * this.scale.y;
+		var guessSizeSq = this.scale.x * this.scale.y / 4;
 
 		if ( distanceSq > guessSizeSq ) {