浏览代码

Merge pull request #13290 from looeee/FBXLoader_apply_pretransform_to_normals

FBXLoader: apply pre transform to normals
Mr.doob 7 年之前
父节点
当前提交
3612603e42
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      examples/js/loaders/FBXLoader.js

+ 10 - 1
examples/js/loaders/FBXLoader.js

@@ -1097,7 +1097,16 @@
 
 		if ( normalBuffer.length > 0 ) {
 
-			geo.addAttribute( 'normal', new THREE.Float32BufferAttribute( normalBuffer, 3 ) );
+			var normalAttribute = new THREE.Float32BufferAttribute( normalBuffer, 3 );
+
+			var normalsPreTransform = preTransform.clone().setPosition( new THREE.Vector3() );
+
+			// required when preTransform has a non-uniform scale component
+			normalsPreTransform.getInverse( normalsPreTransform ).transpose();
+
+			normalsPreTransform.applyToBufferAttribute( normalAttribute );
+
+			geo.addAttribute( 'normal', normalAttribute );
 
 		}