提交 cfc73cc5 编写于 作者: M Mr.doob

Simplified normal matrix in GeometryUtils.merge.

上级 bde8b68e
......@@ -9,7 +9,7 @@ THREE.GeometryUtils = {
merge: function ( geometry1, object2 /* mesh | geometry */ ) {
var matrix, matrixRotation,
var matrix, normalMatrix,
vertexOffset = geometry1.vertices.length,
uvPosition = geometry1.faceVertexUvs[ 0 ].length,
geometry2 = object2 instanceof THREE.Mesh ? object2.geometry : object2,
......@@ -25,8 +25,10 @@ THREE.GeometryUtils = {
object2.matrixAutoUpdate && object2.updateMatrix();
matrix = object2.matrix;
matrixRotation = new THREE.Matrix4();
matrixRotation.extractRotation( matrix, object2.scale );
normalMatrix = new THREE.Matrix3();
normalMatrix.getInverse( matrix );
normalMatrix.transpose();
}
......@@ -64,13 +66,21 @@ THREE.GeometryUtils = {
faceCopy.normal.copy( face.normal );
if ( matrixRotation ) faceCopy.normal.multiplyMatrix4( matrixRotation );
if ( normalMatrix ) {
faceCopy.normal.multiplyMatrix3( normalMatrix ).normalize();
}
for ( var j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {
normal = faceVertexNormals[ j ].clone();
if ( matrixRotation ) normal.multiplyMatrix4( matrixRotation );
if ( normalMatrix ) {
normal.multiplyMatrix3( normalMatrix ).normalize();
}
faceCopy.vertexNormals.push( normal );
......@@ -88,7 +98,12 @@ THREE.GeometryUtils = {
faceCopy.materialIndex = face.materialIndex;
faceCopy.centroid.copy( face.centroid );
if ( matrix ) faceCopy.centroid.multiplyMatrix4( matrix );
if ( matrix ) {
faceCopy.centroid.multiplyMatrix4( matrix );
}
faces1.push( faceCopy );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册