瀏覽代碼

GLTFLoader: Do not make duplicate morphTargetDictionary entries

Takahiro 7 年之前
父節點
當前提交
19ffcd8202
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      examples/js/loaders/GLTFLoader.js

+ 11 - 2
examples/js/loaders/GLTFLoader.js

@@ -1251,9 +1251,18 @@ THREE.GLTFLoader = ( function () {
 		// .extras has user-defined data, so check that .extras.targetNames is an array.
 		if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
 
-			for ( var i = 0, il = meshDef.extras.targetNames.length; i < il; i ++ ) {
+			var targetNames = meshDef.extras.targetNames;
+			var dictionary = mesh.morphTargetDictionary;
 
-				mesh.morphTargetDictionary[ meshDef.extras.targetNames[ i ] ] = i;
+			for ( var key in dictionary ) {
+
+				if ( dictionary[ key ] < targetNames.length ) delete dictionary[ key ];
+
+			}
+
+			for ( var i = 0, il = targetNames.length; i < il; i ++ ) {
+
+				dictionary[ targetNames[ i ] ] = i;
 
 			}