|
@@ -30712,6 +30712,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
|
|
|
|
|
|
const _vector3 = /*@__PURE__*/ new Vector3();
|
|
|
const _matrix4 = /*@__PURE__*/ new Matrix4();
|
|
|
+ const _vertex = /*@__PURE__*/ new Vector3();
|
|
|
|
|
|
class SkinnedMesh extends Mesh {
|
|
|
|
|
@@ -30727,6 +30728,57 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
|
|
|
this.bindMatrix = new Matrix4();
|
|
|
this.bindMatrixInverse = new Matrix4();
|
|
|
|
|
|
+ this.boundingBox = null;
|
|
|
+ this.boundingSphere = null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ computeBoundingBox() {
|
|
|
+
|
|
|
+ const geometry = this.geometry;
|
|
|
+
|
|
|
+ if ( this.boundingBox === null ) {
|
|
|
+
|
|
|
+ this.boundingBox = new Box3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.boundingBox.makeEmpty();
|
|
|
+
|
|
|
+ const positionAttribute = geometry.getAttribute( 'position' );
|
|
|
+
|
|
|
+ for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
|
|
+
|
|
|
+ _vertex.fromBufferAttribute( positionAttribute, i );
|
|
|
+ this.applyBoneTransform( i, _vertex );
|
|
|
+ this.boundingBox.expandByPoint( _vertex );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ computeBoundingSphere() {
|
|
|
+
|
|
|
+ const geometry = this.geometry;
|
|
|
+
|
|
|
+ if ( this.boundingSphere === null ) {
|
|
|
+
|
|
|
+ this.boundingSphere = new Sphere();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.boundingSphere.makeEmpty();
|
|
|
+
|
|
|
+ const positionAttribute = geometry.getAttribute( 'position' );
|
|
|
+
|
|
|
+ for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
|
|
+
|
|
|
+ _vertex.fromBufferAttribute( positionAttribute, i );
|
|
|
+ this.applyBoneTransform( i, _vertex );
|
|
|
+ this.boundingSphere.expandByPoint( _vertex );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
copy( source, recursive ) {
|
|
@@ -31331,6 +31383,17 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
|
|
|
|
|
|
if ( _mesh.material === undefined ) return;
|
|
|
|
|
|
+ // test with bounding sphere first
|
|
|
+
|
|
|
+ if ( this.boundingSphere === null ) this.computeBoundingSphere();
|
|
|
+
|
|
|
+ _sphere$2.copy( this.boundingSphere );
|
|
|
+ _sphere$2.applyMatrix4( matrixWorld );
|
|
|
+
|
|
|
+ if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) return;
|
|
|
+
|
|
|
+ // now test each instance
|
|
|
+
|
|
|
for ( let instanceId = 0; instanceId < raycastTimes; instanceId ++ ) {
|
|
|
|
|
|
// calculate the world matrix for each instance
|