|
@@ -20,6 +20,7 @@ THREE.Points.prototype.raycast = ( function () {
|
|
|
|
|
|
var inverseMatrix = new THREE.Matrix4();
|
|
|
var ray = new THREE.Ray();
|
|
|
+ var sphere = new THREE.Sphere();
|
|
|
|
|
|
return function raycast( raycaster, intersects ) {
|
|
|
|
|
@@ -27,14 +28,19 @@ THREE.Points.prototype.raycast = ( function () {
|
|
|
var geometry = object.geometry;
|
|
|
var threshold = raycaster.params.Points.threshold;
|
|
|
|
|
|
- inverseMatrix.getInverse( this.matrixWorld );
|
|
|
- ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
|
|
|
+ // Checking boundingSphere distance to ray
|
|
|
|
|
|
- if ( geometry.boundingBox !== null ) {
|
|
|
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
|
|
|
- if ( ray.intersectsBox( geometry.boundingBox ) === false ) return;
|
|
|
+ var matrixWorld = this.matrixWorld;
|
|
|
|
|
|
- }
|
|
|
+ sphere.copy( geometry.boundingSphere );
|
|
|
+ sphere.applyMatrix4( matrixWorld );
|
|
|
+
|
|
|
+ if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
|
|
|
+
|
|
|
+ inverseMatrix.getInverse( matrixWorld );
|
|
|
+ ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
|
|
|
|
|
|
var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
|
var localThresholdSq = localThreshold * localThreshold;
|
|
@@ -47,7 +53,7 @@ THREE.Points.prototype.raycast = ( function () {
|
|
|
if ( rayPointDistanceSq < localThresholdSq ) {
|
|
|
|
|
|
var intersectPoint = ray.closestPointToPoint( point );
|
|
|
- intersectPoint.applyMatrix4( object.matrixWorld );
|
|
|
+ intersectPoint.applyMatrix4( matrixWorld );
|
|
|
|
|
|
var distance = raycaster.ray.origin.distanceTo( intersectPoint );
|
|
|
|