Kaynağa Gözat

DecalGeometry: Transform normal with normal matrix (#29476)

* Transform normal with normal matrix

* Transform normal with normal matrix
WestLangley 1 yıl önce
ebeveyn
işleme
8f765f9e19

+ 4 - 1
examples/jsm/geometries/DecalGeometry.js

@@ -1,6 +1,7 @@
 import {
 	BufferGeometry,
 	Float32BufferAttribute,
+	Matrix3,
 	Matrix4,
 	Vector3
 } from 'three';
@@ -36,6 +37,8 @@ class DecalGeometry extends BufferGeometry {
 
 		const plane = new Vector3();
 
+		const normalMatrix = new Matrix3().getNormalMatrix( mesh.matrixWorld );
+
 		// this matrix represents the transformation of the decal projector
 
 		const projectorMatrix = new Matrix4();
@@ -146,7 +149,7 @@ class DecalGeometry extends BufferGeometry {
 			vertex.applyMatrix4( mesh.matrixWorld );
 			vertex.applyMatrix4( projectorMatrixInverse );
 
-			normal.transformDirection( mesh.matrixWorld );
+			normal.applyNormalMatrix( normalMatrix );
 
 			decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
 

+ 3 - 1
examples/webgl_decals.html

@@ -187,8 +187,10 @@
 						mouseHelper.position.copy( p );
 						intersection.point.copy( p );
 
+						const normalMatrix = new THREE.Matrix3().getNormalMatrix( mesh.matrixWorld );
+
 						const n = intersects[ 0 ].face.normal.clone();
-						n.transformDirection( mesh.matrixWorld );
+						n.applyNormalMatrix( normalMatrix );
 						n.multiplyScalar( 10 );
 						n.add( intersects[ 0 ].point );
 

粤ICP备19079148号