|
@@ -126,6 +126,10 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
var tempB = new Vector3();
|
|
|
var tempC = new Vector3();
|
|
|
|
|
|
+ var morphA = new Vector3();
|
|
|
+ var morphB = new Vector3();
|
|
|
+ var morphC = new Vector3();
|
|
|
+
|
|
|
var uvA = new Vector2();
|
|
|
var uvB = new Vector2();
|
|
|
var uvC = new Vector2();
|
|
@@ -164,12 +168,43 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function checkBufferGeometryIntersection( object, material, raycaster, ray, position, uv, a, b, c ) {
|
|
|
+ function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, uv, a, b, c ) {
|
|
|
|
|
|
vA.fromBufferAttribute( position, a );
|
|
|
vB.fromBufferAttribute( position, b );
|
|
|
vC.fromBufferAttribute( position, c );
|
|
|
|
|
|
+ var morphInfluences = object.morphTargetInfluences;
|
|
|
+
|
|
|
+ if ( material.morphTargets && morphPosition && morphInfluences ) {
|
|
|
+
|
|
|
+ morphA.set( 0, 0, 0 );
|
|
|
+ morphB.set( 0, 0, 0 );
|
|
|
+ morphC.set( 0, 0, 0 );
|
|
|
+
|
|
|
+ for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ var influence = morphInfluences[ i ];
|
|
|
+ var morphAttribute = morphPosition[ i ];
|
|
|
+
|
|
|
+ if ( influence === 0 ) continue;
|
|
|
+
|
|
|
+ tempA.fromBufferAttribute( morphAttribute, a );
|
|
|
+ tempB.fromBufferAttribute( morphAttribute, b );
|
|
|
+ tempC.fromBufferAttribute( morphAttribute, c );
|
|
|
+
|
|
|
+ morphA.addScaledVector( tempA.sub( vA ), influence );
|
|
|
+ morphB.addScaledVector( tempB.sub( vB ), influence );
|
|
|
+ morphC.addScaledVector( tempC.sub( vC ), influence );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ vA.add( morphA );
|
|
|
+ vB.add( morphB );
|
|
|
+ vC.add( morphC );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var intersection = checkIntersection( object, material, raycaster, ray, vA, vB, vC, intersectionPoint );
|
|
|
|
|
|
if ( intersection ) {
|
|
@@ -232,6 +267,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
var a, b, c;
|
|
|
var index = geometry.index;
|
|
|
var position = geometry.attributes.position;
|
|
|
+ var morphPosition = geometry.morphAttributes.position;
|
|
|
var uv = geometry.attributes.uv;
|
|
|
var groups = geometry.groups;
|
|
|
var drawRange = geometry.drawRange;
|
|
@@ -259,7 +295,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
b = index.getX( j + 1 );
|
|
|
c = index.getX( j + 2 );
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, uv, a, b, c );
|
|
|
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, morphPosition, uv, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
|
|
|
@@ -284,7 +320,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
b = index.getX( i + 1 );
|
|
|
c = index.getX( i + 2 );
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, uv, a, b, c );
|
|
|
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, morphPosition, uv, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
|
|
|
@@ -317,7 +353,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
b = j + 1;
|
|
|
c = j + 2;
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, uv, a, b, c );
|
|
|
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, morphPosition, uv, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
|
|
|
@@ -342,7 +378,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
b = i + 1;
|
|
|
c = i + 2;
|
|
|
|
|
|
- intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, uv, a, b, c );
|
|
|
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, morphPosition, uv, a, b, c );
|
|
|
|
|
|
if ( intersection ) {
|
|
|
|