|
@@ -11025,6 +11025,10 @@ var _inverseMatrix = new Matrix4();
|
|
|
var _ray = new Ray();
|
|
|
var _sphere = new Sphere();
|
|
|
|
|
|
+var _matrixWorld = new Matrix4();
|
|
|
+var _instanceMatrix = new Matrix4();
|
|
|
+var _executionTimes = 1;
|
|
|
+
|
|
|
var _vA = new Vector3();
|
|
|
var _vB = new Vector3();
|
|
|
var _vC = new Vector3();
|
|
@@ -11147,163 +11151,194 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
if ( material === undefined ) return;
|
|
|
|
|
|
- // Checking boundingSphere distance to ray
|
|
|
+ //Determine how many times raycast will execute
|
|
|
|
|
|
- if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
+ if ( this.isInstancedMesh ) {
|
|
|
|
|
|
- _sphere.copy( geometry.boundingSphere );
|
|
|
- _sphere.applyMatrix4( matrixWorld );
|
|
|
+ _executionTimes = this.count;
|
|
|
|
|
|
- if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
|
|
+ } else {
|
|
|
|
|
|
- //
|
|
|
+ _executionTimes = 1;
|
|
|
|
|
|
- _inverseMatrix.getInverse( matrixWorld );
|
|
|
- _ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
|
|
+ }
|
|
|
|
|
|
- // Check boundingBox before continuing
|
|
|
+ for ( var instanceId = 0; instanceId < _executionTimes; instanceId ++ ) {
|
|
|
|
|
|
- if ( geometry.boundingBox !== null ) {
|
|
|
+ //Determine the world matrix for this calculation
|
|
|
|
|
|
- if ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;
|
|
|
+ if ( this.isInstancedMesh ) {
|
|
|
|
|
|
- }
|
|
|
+ _instanceMatrix = this.getMatrixAt( instanceId );
|
|
|
+ _matrixWorld.multiplyMatrices( matrixWorld, _instanceMatrix );
|
|
|
|
|
|
- // check unsupported draw modes
|
|
|
+ } else {
|
|
|
|
|
|
- if ( this.drawMode !== TrianglesDrawMode ) {
|
|
|
+ _matrixWorld = matrixWorld;
|
|
|
|
|
|
- console.warn( 'THREE.Mesh: TriangleStripDrawMode and TriangleFanDrawMode are not supported by .raycast().' );
|
|
|
- return;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ // Checking boundingSphere distance to ray
|
|
|
|
|
|
- var intersection;
|
|
|
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
|
|
|
- if ( geometry.isBufferGeometry ) {
|
|
|
+ _sphere.copy( geometry.boundingSphere );
|
|
|
+ _sphere.applyMatrix4( _matrixWorld );
|
|
|
|
|
|
- var a, b, c;
|
|
|
- var index = geometry.index;
|
|
|
- var position = geometry.attributes.position;
|
|
|
- var morphPosition = geometry.morphAttributes.position;
|
|
|
- var morphTargetsRelative = geometry.morphTargetsRelative;
|
|
|
- var uv = geometry.attributes.uv;
|
|
|
- var uv2 = geometry.attributes.uv2;
|
|
|
- var groups = geometry.groups;
|
|
|
- var drawRange = geometry.drawRange;
|
|
|
- var i, j, il, jl;
|
|
|
- var group, groupMaterial;
|
|
|
- var start, end;
|
|
|
+ if ( raycaster.ray.intersectsSphere( _sphere ) === false ) continue;
|
|
|
|
|
|
- if ( index !== null ) {
|
|
|
+ //Transform the ray into the local space of the model
|
|
|
|
|
|
- // indexed buffer geometry
|
|
|
+ _inverseMatrix.getInverse( _matrixWorld );
|
|
|
+ _ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
|
|
|
|
|
- if ( Array.isArray( material ) ) {
|
|
|
+ // Check boundingBox before continuing
|
|
|
|
|
|
- for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
|
+ if ( geometry.boundingBox !== null ) {
|
|
|
|
|
|
- group = groups[ i ];
|
|
|
- groupMaterial = material[ group.materialIndex ];
|
|
|
+ if ( _ray.intersectsBox( geometry.boundingBox ) === false ) continue;
|
|
|
|
|
|
- start = Math.max( group.start, drawRange.start );
|
|
|
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
|
|
|
+ }
|
|
|
|
|
|
- for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
|
+ var intersection;
|
|
|
|
|
|
- a = index.getX( j );
|
|
|
- b = index.getX( j + 1 );
|
|
|
- c = index.getX( j + 2 );
|
|
|
+ if ( geometry.isBufferGeometry ) {
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
|
|
|
+ var a, b, c;
|
|
|
+ var index = geometry.index;
|
|
|
+ var position = geometry.attributes.position;
|
|
|
+ var morphPosition = geometry.morphAttributes.position;
|
|
|
+ var uv = geometry.attributes.uv;
|
|
|
+ var uv2 = geometry.attributes.uv2;
|
|
|
+ var groups = geometry.groups;
|
|
|
+ var drawRange = geometry.drawRange;
|
|
|
+ var i, j, il, jl;
|
|
|
+ var group, groupMaterial;
|
|
|
+ var start, end;
|
|
|
|
|
|
- if ( intersection ) {
|
|
|
+ if ( index !== null ) {
|
|
|
|
|
|
- intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
|
|
|
- intersection.face.materialIndex = group.materialIndex;
|
|
|
- intersects.push( intersection );
|
|
|
+ // indexed buffer geometry
|
|
|
+
|
|
|
+ if ( Array.isArray( material ) ) {
|
|
|
+
|
|
|
+ for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ group = groups[ i ];
|
|
|
+ groupMaterial = material[ group.materialIndex ];
|
|
|
+
|
|
|
+ start = Math.max( group.start, drawRange.start );
|
|
|
+ end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
|
|
|
+
|
|
|
+ for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
|
+
|
|
|
+ a = index.getX( j );
|
|
|
+ b = index.getX( j + 1 );
|
|
|
+ c = index.getX( j + 2 );
|
|
|
+
|
|
|
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
|
|
|
+
|
|
|
+ if ( intersection ) {
|
|
|
+
|
|
|
+ intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
|
|
|
+ intersection.face.materialIndex = group.materialIndex;
|
|
|
+
|
|
|
+ intersection.instanceId = instanceId;
|
|
|
+
|
|
|
+ intersects.push( intersection );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- } else {
|
|
|
+ start = Math.max( 0, drawRange.start );
|
|
|
+ end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
|
|
|
|
|
- start = Math.max( 0, drawRange.start );
|
|
|
- end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
|
|
+ for ( i = start, il = end; i < il; i += 3 ) {
|
|
|
|
|
|
- for ( i = start, il = end; i < il; i += 3 ) {
|
|
|
+ a = index.getX( i );
|
|
|
+ b = index.getX( i + 1 );
|
|
|
+ c = index.getX( i + 2 );
|
|
|
+
|
|
|
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
|
|
|
+
|
|
|
+ if ( intersection ) {
|
|
|
|
|
|
- a = index.getX( i );
|
|
|
- b = index.getX( i + 1 );
|
|
|
- c = index.getX( i + 2 );
|
|
|
+ intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
|
|
|
+ intersection.instanceId = instanceId;
|
|
|
|
|
|
- if ( intersection ) {
|
|
|
+ intersects.push( intersection );
|
|
|
|
|
|
- intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
|
|
|
- intersects.push( intersection );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ } else if ( position !== undefined ) {
|
|
|
|
|
|
- } else if ( position !== undefined ) {
|
|
|
+ // non-indexed buffer geometry
|
|
|
|
|
|
- // non-indexed buffer geometry
|
|
|
+ if ( Array.isArray( material ) ) {
|
|
|
|
|
|
- if ( Array.isArray( material ) ) {
|
|
|
+ for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
|
|
|
|
- for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
|
+ group = groups[ i ];
|
|
|
+ groupMaterial = material[ group.materialIndex ];
|
|
|
|
|
|
- group = groups[ i ];
|
|
|
- groupMaterial = material[ group.materialIndex ];
|
|
|
+ start = Math.max( group.start, drawRange.start );
|
|
|
+ end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
|
|
|
|
|
|
- start = Math.max( group.start, drawRange.start );
|
|
|
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
|
|
|
+ for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
|
|
|
|
- for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
|
+ a = j;
|
|
|
+ b = j + 1;
|
|
|
+ c = j + 2;
|
|
|
|
|
|
- a = j;
|
|
|
- b = j + 1;
|
|
|
- c = j + 2;
|
|
|
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
|
|
|
+ if ( intersection ) {
|
|
|
|
|
|
- if ( intersection ) {
|
|
|
+ intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
|
|
|
+ intersection.face.materialIndex = group.materialIndex;
|
|
|
|
|
|
- intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
|
|
|
- intersection.face.materialIndex = group.materialIndex;
|
|
|
- intersects.push( intersection );
|
|
|
+ intersection.instanceId = instanceId;
|
|
|
+
|
|
|
+ intersects.push( intersection );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- } else {
|
|
|
+ start = Math.max( 0, drawRange.start );
|
|
|
+ end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
|
|
|
|
|
|
- start = Math.max( 0, drawRange.start );
|
|
|
- end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
|
|
|
+ for ( i = start, il = end; i < il; i += 3 ) {
|
|
|
|
|
|
- for ( i = start, il = end; i < il; i += 3 ) {
|
|
|
+ a = i;
|
|
|
+ b = i + 1;
|
|
|
+ c = i + 2;
|
|
|
+
|
|
|
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
|
|
|
|
|
|
- a = i;
|
|
|
- b = i + 1;
|
|
|
- c = i + 2;
|
|
|
+ if ( intersection ) {
|
|
|
+
|
|
|
+ intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
|
|
|
+ intersection.instanceId = instanceId;
|
|
|
|
|
|
- if ( intersection ) {
|
|
|
+ intersects.push( intersection );
|
|
|
|
|
|
- intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
|
|
|
- intersects.push( intersection );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -11311,49 +11346,49 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ } else if ( geometry.isGeometry ) {
|
|
|
|
|
|
- } else if ( geometry.isGeometry ) {
|
|
|
+ var fvA, fvB, fvC;
|
|
|
+ var isMultiMaterial = Array.isArray( material );
|
|
|
|
|
|
- var fvA, fvB, fvC;
|
|
|
- var isMultiMaterial = Array.isArray( material );
|
|
|
+ var vertices = geometry.vertices;
|
|
|
+ var faces = geometry.faces;
|
|
|
+ var uvs;
|
|
|
|
|
|
- var vertices = geometry.vertices;
|
|
|
- var faces = geometry.faces;
|
|
|
- var uvs;
|
|
|
+ var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
|
|
|
+ if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
|
|
|
|
|
|
- var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
|
|
|
- if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
|
|
|
+ for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
|
|
|
|
|
|
- for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
|
|
|
+ var face = faces[ f ];
|
|
|
+ var faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;
|
|
|
|
|
|
- var face = faces[ f ];
|
|
|
- var faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;
|
|
|
+ if ( faceMaterial === undefined ) continue;
|
|
|
|
|
|
- if ( faceMaterial === undefined ) continue;
|
|
|
+ fvA = vertices[ face.a ];
|
|
|
+ fvB = vertices[ face.b ];
|
|
|
+ fvC = vertices[ face.c ];
|
|
|
|
|
|
- fvA = vertices[ face.a ];
|
|
|
- fvB = vertices[ face.b ];
|
|
|
- fvC = vertices[ face.c ];
|
|
|
+ intersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );
|
|
|
|
|
|
- intersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );
|
|
|
+ if ( intersection ) {
|
|
|
|
|
|
- if ( intersection ) {
|
|
|
+ if ( uvs && uvs[ f ] ) {
|
|
|
|
|
|
- if ( uvs && uvs[ f ] ) {
|
|
|
+ var uvs_f = uvs[ f ];
|
|
|
+ _uvA.copy( uvs_f[ 0 ] );
|
|
|
+ _uvB.copy( uvs_f[ 1 ] );
|
|
|
+ _uvC.copy( uvs_f[ 2 ] );
|
|
|
|
|
|
- var uvs_f = uvs[ f ];
|
|
|
- _uvA.copy( uvs_f[ 0 ] );
|
|
|
- _uvB.copy( uvs_f[ 1 ] );
|
|
|
- _uvC.copy( uvs_f[ 2 ] );
|
|
|
+ intersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );
|
|
|
|
|
|
- intersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ intersection.face = face;
|
|
|
+ intersection.faceIndex = f;
|
|
|
+ intersects.push( intersection );
|
|
|
|
|
|
- intersection.face = face;
|
|
|
- intersection.faceIndex = f;
|
|
|
- intersects.push( intersection );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -11388,7 +11423,7 @@ function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point
|
|
|
if ( intersect === null ) return null;
|
|
|
|
|
|
_intersectionPointWorld.copy( point );
|
|
|
- _intersectionPointWorld.applyMatrix4( object.matrixWorld );
|
|
|
+ _intersectionPointWorld.applyMatrix4( _matrixWorld );
|
|
|
|
|
|
var distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );
|
|
|
|
|
@@ -11402,7 +11437,7 @@ function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point
|
|
|
|
|
|
}
|
|
|
|
|
|
-function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) {
|
|
|
+function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, uv, uv2, a, b, c ) {
|
|
|
|
|
|
_vA.fromBufferAttribute( position, a );
|
|
|
_vB.fromBufferAttribute( position, b );
|
|
@@ -11427,19 +11462,9 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi
|
|
|
_tempB.fromBufferAttribute( morphAttribute, b );
|
|
|
_tempC.fromBufferAttribute( morphAttribute, c );
|
|
|
|
|
|
- if ( morphTargetsRelative ) {
|
|
|
-
|
|
|
- _morphA.addScaledVector( _tempA, influence );
|
|
|
- _morphB.addScaledVector( _tempB, influence );
|
|
|
- _morphC.addScaledVector( _tempC, influence );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _morphA.addScaledVector( _tempA.sub( _vA ), influence );
|
|
|
- _morphB.addScaledVector( _tempB.sub( _vB ), influence );
|
|
|
- _morphC.addScaledVector( _tempC.sub( _vC ), influence );
|
|
|
-
|
|
|
- }
|
|
|
+ _morphA.addScaledVector( _tempA.sub( _vA ), influence );
|
|
|
+ _morphB.addScaledVector( _tempB.sub( _vB ), influence );
|
|
|
+ _morphC.addScaledVector( _tempC.sub( _vC ), influence );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -27288,21 +27313,6 @@ Bone.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-var _inverseMatrix$1 = new Matrix4();
|
|
|
-var _ray$1 = new Ray();
|
|
|
-var _sphere$2 = new Sphere();
|
|
|
-
|
|
|
-var _vA$2 = new Vector3();
|
|
|
-var _vB$2 = new Vector3();
|
|
|
-var _vC$2 = new Vector3();
|
|
|
-
|
|
|
-var _uvA$2 = new Vector2();
|
|
|
-var _uvB$2 = new Vector2();
|
|
|
-var _uvC$2 = new Vector2();
|
|
|
-
|
|
|
-var _intersectionPoint$1 = new Vector3();
|
|
|
-var _intersectionPointWorld$1 = new Vector3();
|
|
|
-
|
|
|
function InstancedMesh( geometry, material, count ) {
|
|
|
|
|
|
Mesh.call( this, geometry, material );
|
|
@@ -27319,203 +27329,9 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
|
|
|
|
|
|
isInstancedMesh: true,
|
|
|
|
|
|
- raycast: function ( raycaster, intersects ) {
|
|
|
-
|
|
|
- var geometry = this.geometry;
|
|
|
- var material = this.material;
|
|
|
- var matrixWorld = this.matrixWorld;
|
|
|
-
|
|
|
- if ( material === undefined ) return;
|
|
|
-
|
|
|
- for ( var instanceID = 0; instanceID < this.count; instanceID ++ ) {
|
|
|
-
|
|
|
- //Calculate the world matrix for each instance
|
|
|
-
|
|
|
- var instanceMatrixWorld = new Matrix4();
|
|
|
-
|
|
|
- var instanceMatrix = this.getMatrixAt( instanceID );
|
|
|
-
|
|
|
- instanceMatrixWorld.multiplyMatrices( matrixWorld, instanceMatrix );
|
|
|
-
|
|
|
- // Checking boundingSphere distance to ray
|
|
|
-
|
|
|
- if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
-
|
|
|
- _sphere$2.copy( geometry.boundingSphere );
|
|
|
- _sphere$2.applyMatrix4( instanceMatrixWorld );
|
|
|
-
|
|
|
- if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) continue;
|
|
|
-
|
|
|
- //Transform the ray into the local space of the model
|
|
|
-
|
|
|
- _inverseMatrix$1.getInverse( instanceMatrixWorld );
|
|
|
- _ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 );
|
|
|
-
|
|
|
- // Check boundingBox before continuing
|
|
|
-
|
|
|
- if ( geometry.boundingBox !== null ) {
|
|
|
-
|
|
|
- if ( _ray$1.intersectsBox( geometry.boundingBox ) === false ) continue;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- var intersection;
|
|
|
-
|
|
|
- if ( geometry.isBufferGeometry ) {
|
|
|
-
|
|
|
- var a, b, c;
|
|
|
- var index = geometry.index;
|
|
|
- var position = geometry.attributes.position;
|
|
|
- var uv = geometry.attributes.uv;
|
|
|
- var uv2 = geometry.attributes.uv2;
|
|
|
- var groups = geometry.groups;
|
|
|
- var drawRange = geometry.drawRange;
|
|
|
- var i, j, il, jl;
|
|
|
- var group, groupMaterial;
|
|
|
- var start, end;
|
|
|
-
|
|
|
- if ( index !== null ) {
|
|
|
-
|
|
|
- // indexed buffer geometry
|
|
|
-
|
|
|
- if ( Array.isArray( material ) ) {
|
|
|
-
|
|
|
- for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- group = groups[ i ];
|
|
|
- groupMaterial = material[ group.materialIndex ];
|
|
|
-
|
|
|
- start = Math.max( group.start, drawRange.start );
|
|
|
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
|
|
|
-
|
|
|
- for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
|
-
|
|
|
- a = index.getX( j );
|
|
|
- b = index.getX( j + 1 );
|
|
|
- c = index.getX( j + 2 );
|
|
|
-
|
|
|
- intersection = checkBufferGeometryIntersection$1( this, instanceMatrixWorld, groupMaterial, raycaster, _ray$1, position, uv, uv2, a, b, c );
|
|
|
-
|
|
|
- if ( intersection ) {
|
|
|
-
|
|
|
- intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
|
|
|
- intersection.face.materialIndex = group.materialIndex;
|
|
|
-
|
|
|
- intersection.instanceID = instanceID;
|
|
|
-
|
|
|
- intersects.push( intersection );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- start = Math.max( 0, drawRange.start );
|
|
|
- end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
|
|
-
|
|
|
- for ( i = start, il = end; i < il; i += 3 ) {
|
|
|
-
|
|
|
- a = index.getX( i );
|
|
|
- b = index.getX( i + 1 );
|
|
|
- c = index.getX( i + 2 );
|
|
|
-
|
|
|
- intersection = checkBufferGeometryIntersection$1( this, instanceMatrixWorld, material, raycaster, _ray$1, position, uv, uv2, a, b, c );
|
|
|
-
|
|
|
- if ( intersection ) {
|
|
|
-
|
|
|
- intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
|
|
|
-
|
|
|
- intersection.instanceID = instanceID;
|
|
|
-
|
|
|
- intersects.push( intersection );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( position !== undefined ) {
|
|
|
-
|
|
|
- // non-indexed buffer geometry
|
|
|
-
|
|
|
- if ( Array.isArray( material ) ) {
|
|
|
-
|
|
|
- for ( i = 0, il = groups.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- group = groups[ i ];
|
|
|
- groupMaterial = material[ group.materialIndex ];
|
|
|
-
|
|
|
- start = Math.max( group.start, drawRange.start );
|
|
|
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
|
|
|
-
|
|
|
- for ( j = start, jl = end; j < jl; j += 3 ) {
|
|
|
-
|
|
|
- a = j;
|
|
|
- b = j + 1;
|
|
|
- c = j + 2;
|
|
|
-
|
|
|
- intersection = checkBufferGeometryIntersection$1( this, instanceMatrixWorld, groupMaterial, raycaster, _ray$1, position, uv, uv2, a, b, c );
|
|
|
-
|
|
|
- if ( intersection ) {
|
|
|
-
|
|
|
- intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
|
|
|
- intersection.face.materialIndex = group.materialIndex;
|
|
|
-
|
|
|
- intersection.instanceID = instanceID;
|
|
|
-
|
|
|
- intersects.push( intersection );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- start = Math.max( 0, drawRange.start );
|
|
|
- end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
|
|
|
-
|
|
|
- for ( i = start, il = end; i < il; i += 3 ) {
|
|
|
-
|
|
|
- a = i;
|
|
|
- b = i + 1;
|
|
|
- c = i + 2;
|
|
|
-
|
|
|
- intersection = checkBufferGeometryIntersection$1( this, instanceMatrixWorld, material, raycaster, _ray$1, position, uv, uv2, a, b, c );
|
|
|
-
|
|
|
- if ( intersection ) {
|
|
|
-
|
|
|
- intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
|
|
|
+ getMatrixAt: function ( index, matrix ) {
|
|
|
|
|
|
- intersection.instanceID = instanceID;
|
|
|
-
|
|
|
- intersects.push( intersection );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- getMatrixAt: function ( index ) {
|
|
|
-
|
|
|
- var matrix = new Matrix4();
|
|
|
+ var matrix = matrix || new Matrix4();
|
|
|
|
|
|
matrix.fromArray( this.instanceMatrix.array, index * 16 );
|
|
|
|
|
@@ -27529,84 +27345,12 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
|
|
|
|
|
|
},
|
|
|
|
|
|
- updateMorphTargets: function () {
|
|
|
-
|
|
|
- }
|
|
|
+ // updateMorphTargets: function () {
|
|
|
+ //
|
|
|
+ // }
|
|
|
|
|
|
} );
|
|
|
|
|
|
-function checkIntersection$1( object, matrixWorld, material, raycaster, ray, pA, pB, pC, point ) {
|
|
|
-
|
|
|
- var intersect;
|
|
|
-
|
|
|
- if ( material.side === BackSide ) {
|
|
|
-
|
|
|
- intersect = ray.intersectTriangle( pC, pB, pA, true, point );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( intersect === null ) return null;
|
|
|
-
|
|
|
- _intersectionPointWorld$1.copy( point );
|
|
|
- _intersectionPointWorld$1.applyMatrix4( matrixWorld );
|
|
|
-
|
|
|
- var distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld$1 );
|
|
|
-
|
|
|
- if ( distance < raycaster.near || distance > raycaster.far ) return null;
|
|
|
-
|
|
|
- return {
|
|
|
- distance: distance,
|
|
|
- point: _intersectionPointWorld$1.clone(),
|
|
|
- object: object
|
|
|
- };
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function checkBufferGeometryIntersection$1( object, matrixWorld, material, raycaster, ray, position, uv, uv2, a, b, c ) {
|
|
|
-
|
|
|
- _vA$2.fromBufferAttribute( position, a );
|
|
|
- _vB$2.fromBufferAttribute( position, b );
|
|
|
- _vC$2.fromBufferAttribute( position, c );
|
|
|
-
|
|
|
- var intersection = checkIntersection$1( object, matrixWorld, material, raycaster, ray, _vA$2, _vB$2, _vC$2, _intersectionPoint$1 );
|
|
|
-
|
|
|
- if ( intersection ) {
|
|
|
-
|
|
|
- if ( uv ) {
|
|
|
-
|
|
|
- _uvA$2.fromBufferAttribute( uv, a );
|
|
|
- _uvB$2.fromBufferAttribute( uv, b );
|
|
|
- _uvC$2.fromBufferAttribute( uv, c );
|
|
|
-
|
|
|
- intersection.uv = Triangle.getUV( _intersectionPoint$1, _vA$2, _vB$2, _vC$2, _uvA$2, _uvB$2, _uvC$2, new Vector2() );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( uv2 ) {
|
|
|
-
|
|
|
- _uvA$2.fromBufferAttribute( uv2, a );
|
|
|
- _uvB$2.fromBufferAttribute( uv2, b );
|
|
|
- _uvC$2.fromBufferAttribute( uv2, c );
|
|
|
-
|
|
|
- intersection.uv2 = Triangle.getUV( _intersectionPoint$1, _vA$2, _vB$2, _vC$2, _uvA$2, _uvB$2, _uvC$2, new Vector2() );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- var face = new Face3( a, b, c );
|
|
|
- Triangle.getNormal( _vA$2, _vB$2, _vC$2, face.normal );
|
|
|
-
|
|
|
- intersection.face = face;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return intersection;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
* @author alteredq / http://alteredqualia.com/
|
|
@@ -27662,9 +27406,9 @@ LineBasicMaterial.prototype.copy = function ( source ) {
|
|
|
|
|
|
var _start = new Vector3();
|
|
|
var _end = new Vector3();
|
|
|
-var _inverseMatrix$2 = new Matrix4();
|
|
|
-var _ray$2 = new Ray();
|
|
|
-var _sphere$3 = new Sphere();
|
|
|
+var _inverseMatrix$1 = new Matrix4();
|
|
|
+var _ray$1 = new Ray();
|
|
|
+var _sphere$2 = new Sphere();
|
|
|
|
|
|
function Line( geometry, material, mode ) {
|
|
|
|
|
@@ -27751,16 +27495,16 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
|
|
|
- _sphere$3.copy( geometry.boundingSphere );
|
|
|
- _sphere$3.applyMatrix4( matrixWorld );
|
|
|
- _sphere$3.radius += precision;
|
|
|
+ _sphere$2.copy( geometry.boundingSphere );
|
|
|
+ _sphere$2.applyMatrix4( matrixWorld );
|
|
|
+ _sphere$2.radius += precision;
|
|
|
|
|
|
- if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
|
|
|
+ if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) return;
|
|
|
|
|
|
//
|
|
|
|
|
|
- _inverseMatrix$2.getInverse( matrixWorld );
|
|
|
- _ray$2.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$2 );
|
|
|
+ _inverseMatrix$1.getInverse( matrixWorld );
|
|
|
+ _ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 );
|
|
|
|
|
|
var localPrecision = precision / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
|
var localPrecisionSq = localPrecision * localPrecision;
|
|
@@ -27789,7 +27533,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
vStart.fromArray( positions, a * 3 );
|
|
|
vEnd.fromArray( positions, b * 3 );
|
|
|
|
|
|
- var distSq = _ray$2.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
|
|
|
+ var distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
|
|
|
|
|
|
if ( distSq > localPrecisionSq ) continue;
|
|
|
|
|
@@ -27821,7 +27565,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
vStart.fromArray( positions, 3 * i );
|
|
|
vEnd.fromArray( positions, 3 * i + 3 );
|
|
|
|
|
|
- var distSq = _ray$2.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
|
|
|
+ var distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
|
|
|
|
|
|
if ( distSq > localPrecisionSq ) continue;
|
|
|
|
|
@@ -27855,7 +27599,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
for ( var i = 0; i < nbVertices - 1; i += step ) {
|
|
|
|
|
|
- var distSq = _ray$2.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
|
|
|
+ var distSq = _ray$1.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
|
|
|
|
|
|
if ( distSq > localPrecisionSq ) continue;
|
|
|
|
|
@@ -28053,9 +27797,9 @@ PointsMaterial.prototype.copy = function ( source ) {
|
|
|
* @author alteredq / http://alteredqualia.com/
|
|
|
*/
|
|
|
|
|
|
-var _inverseMatrix$3 = new Matrix4();
|
|
|
-var _ray$3 = new Ray();
|
|
|
-var _sphere$4 = new Sphere();
|
|
|
+var _inverseMatrix$2 = new Matrix4();
|
|
|
+var _ray$2 = new Ray();
|
|
|
+var _sphere$3 = new Sphere();
|
|
|
var _position$1 = new Vector3();
|
|
|
|
|
|
function Points( geometry, material ) {
|
|
@@ -28087,16 +27831,16 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
|
|
|
|
- _sphere$4.copy( geometry.boundingSphere );
|
|
|
- _sphere$4.applyMatrix4( matrixWorld );
|
|
|
- _sphere$4.radius += threshold;
|
|
|
+ _sphere$3.copy( geometry.boundingSphere );
|
|
|
+ _sphere$3.applyMatrix4( matrixWorld );
|
|
|
+ _sphere$3.radius += threshold;
|
|
|
|
|
|
- if ( raycaster.ray.intersectsSphere( _sphere$4 ) === false ) return;
|
|
|
+ if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
|
|
|
|
|
|
//
|
|
|
|
|
|
- _inverseMatrix$3.getInverse( matrixWorld );
|
|
|
- _ray$3.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$3 );
|
|
|
+ _inverseMatrix$2.getInverse( matrixWorld );
|
|
|
+ _ray$2.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$2 );
|
|
|
|
|
|
var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
|
var localThresholdSq = localThreshold * localThreshold;
|
|
@@ -28203,13 +27947,13 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {
|
|
|
|
|
|
- var rayPointDistanceSq = _ray$3.distanceSqToPoint( point );
|
|
|
+ var rayPointDistanceSq = _ray$2.distanceSqToPoint( point );
|
|
|
|
|
|
if ( rayPointDistanceSq < localThresholdSq ) {
|
|
|
|
|
|
var intersectPoint = new Vector3();
|
|
|
|
|
|
- _ray$3.closestPointToPoint( point, intersectPoint );
|
|
|
+ _ray$2.closestPointToPoint( point, intersectPoint );
|
|
|
intersectPoint.applyMatrix4( matrixWorld );
|
|
|
|
|
|
var distance = raycaster.ray.origin.distanceTo( intersectPoint );
|