Browse Source

GLTFLoader: Do not make duplicate morphTargetDictionary entries

Takahiro 7 years ago
parent
commit
19ffcd8202
1 changed files with 11 additions and 2 deletions
  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.
 		// .extras has user-defined data, so check that .extras.targetNames is an array.
 		if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
 		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;
 
 
 			}
 			}