|
@@ -155,13 +155,15 @@ class Mesh extends Object3D {
|
|
|
|
|
|
if ( material === undefined ) return;
|
|
if ( material === undefined ) return;
|
|
|
|
|
|
- // Checking boundingSphere distance to ray
|
|
|
|
|
|
+ // test with bounding sphere in world space
|
|
|
|
|
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
|
|
|
_sphere.copy( geometry.boundingSphere );
|
|
_sphere.copy( geometry.boundingSphere );
|
|
_sphere.applyMatrix4( matrixWorld );
|
|
_sphere.applyMatrix4( matrixWorld );
|
|
|
|
|
|
|
|
+ // check distance from ray origin to bounding sphere
|
|
|
|
+
|
|
_ray.copy( raycaster.ray ).recast( raycaster.near );
|
|
_ray.copy( raycaster.ray ).recast( raycaster.near );
|
|
|
|
|
|
if ( _sphere.containsPoint( _ray.origin ) === false ) {
|
|
if ( _sphere.containsPoint( _ray.origin ) === false ) {
|
|
@@ -172,12 +174,12 @@ class Mesh extends Object3D {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- //
|
|
|
|
|
|
+ // convert ray to local space of mesh
|
|
|
|
|
|
_inverseMatrix.copy( matrixWorld ).invert();
|
|
_inverseMatrix.copy( matrixWorld ).invert();
|
|
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
|
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
|
|
|
|
|
- // Check boundingBox before continuing
|
|
|
|
|
|
+ // test with bounding box in local space
|
|
|
|
|
|
if ( geometry.boundingBox !== null ) {
|
|
if ( geometry.boundingBox !== null ) {
|
|
|
|
|
|
@@ -185,11 +187,13 @@ class Mesh extends Object3D {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- this._computeIntersections( raycaster, intersects );
|
|
|
|
|
|
+ // test for intersections with geometry
|
|
|
|
+
|
|
|
|
+ this._computeIntersections( raycaster, intersects, _ray );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- _computeIntersections( raycaster, intersects ) {
|
|
|
|
|
|
+ _computeIntersections( raycaster, intersects, rayLocalSpace ) {
|
|
|
|
|
|
let intersection;
|
|
let intersection;
|
|
|
|
|
|
@@ -224,7 +228,7 @@ class Mesh extends Object3D {
|
|
const b = index.getX( j + 1 );
|
|
const b = index.getX( j + 1 );
|
|
const c = index.getX( j + 2 );
|
|
const c = index.getX( j + 2 );
|
|
|
|
|
|
- intersection = checkGeometryIntersection( this, groupMaterial, raycaster, _ray, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
+ intersection = checkGeometryIntersection( this, groupMaterial, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
if ( intersection ) {
|
|
|
|
|
|
@@ -249,7 +253,7 @@ class Mesh extends Object3D {
|
|
const b = index.getX( i + 1 );
|
|
const b = index.getX( i + 1 );
|
|
const c = index.getX( i + 2 );
|
|
const c = index.getX( i + 2 );
|
|
|
|
|
|
- intersection = checkGeometryIntersection( this, material, raycaster, _ray, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
+ intersection = checkGeometryIntersection( this, material, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
if ( intersection ) {
|
|
|
|
|
|
@@ -282,7 +286,7 @@ class Mesh extends Object3D {
|
|
const b = j + 1;
|
|
const b = j + 1;
|
|
const c = j + 2;
|
|
const c = j + 2;
|
|
|
|
|
|
- intersection = checkGeometryIntersection( this, groupMaterial, raycaster, _ray, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
+ intersection = checkGeometryIntersection( this, groupMaterial, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
if ( intersection ) {
|
|
|
|
|
|
@@ -307,7 +311,7 @@ class Mesh extends Object3D {
|
|
const b = i + 1;
|
|
const b = i + 1;
|
|
const c = i + 2;
|
|
const c = i + 2;
|
|
|
|
|
|
- intersection = checkGeometryIntersection( this, material, raycaster, _ray, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
+ intersection = checkGeometryIntersection( this, material, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
if ( intersection ) {
|
|
|
|
|