Skip to content

Commit

Permalink
Merge pull request #14111 from takahirox/GLTFLoaderLessMeshClone
Browse files Browse the repository at this point in the history
GLTFLoader: No mesh clone if it is referenced only once
  • Loading branch information
mrdoob committed Jul 31, 2018
2 parents 5ce3326 + 6c93edc commit 45528f5
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions examples/js/loaders/GLTFLoader.js
Expand Up @@ -2903,36 +2903,26 @@ THREE.GLTFLoader = ( function () {

var mesh = dependencies.meshes[ nodeDef.mesh ];

node = mesh.clone();

// for Specular-Glossiness
if ( mesh.isGroup === true ) {
if ( meshReferences[ nodeDef.mesh ] > 1 ) {

for ( var i = 0, il = mesh.children.length; i < il; i ++ ) {
var instanceNum = meshUses[ nodeDef.mesh ] ++;

var child = mesh.children[ i ];
node = mesh.clone();
node.name += '_instance_' + instanceNum;

if ( child.material && child.material.isGLTFSpecularGlossinessMaterial === true ) {
// onBeforeRender copy for Specular-Glossiness
node.onBeforeRender = mesh.onBeforeRender;

node.children[ i ].onBeforeRender = child.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;

}

} else {

if ( mesh.material && mesh.material.isGLTFSpecularGlossinessMaterial === true ) {

node.onBeforeRender = mesh.onBeforeRender;

}

}

if ( meshReferences[ nodeDef.mesh ] > 1 ) {

node.name += '_instance_' + meshUses[ nodeDef.mesh ] ++;
node = mesh;

}

Expand Down

0 comments on commit 45528f5

Please sign in to comment.