Browse Source

GLTFLoader: Append _instance_num to the children name of cloned Group

Takahiro 7 years ago
parent
commit
6c93edc1aa
1 changed files with 5 additions and 2 deletions
  1. 5 2
      examples/js/loaders/GLTFLoader.js

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

@@ -2942,14 +2942,17 @@ THREE.GLTFLoader = ( function () {
 
 				if ( meshReferences[ nodeDef.mesh ] > 1 ) {
 
+					var instanceNum = meshUses[ nodeDef.mesh ] ++;
+
 					node = mesh.clone();
-					node.name += '_instance_' + meshUses[ nodeDef.mesh ] ++;
+					node.name += '_instance_' + instanceNum;
 
-					// for Specular-Glossiness
+					// onBeforeRender copy for Specular-Glossiness
 					node.onBeforeRender = mesh.onBeforeRender;
 
 					for ( var i = 0, il = node.children.length; i < il; i ++ ) {
 
+						node.children[ i ].name += '_instance_' + instanceNum;
 						node.children[ i ].onBeforeRender = mesh.children[ i ].onBeforeRender;
 
 					}