Skip to content

Commit f2b8b44

Browse files
committed
[HUBS] [r148] GLTFLoader: Clean up Skeleton binding (mrdoob#25033)
[HUBS] This change is needed for glTF LOD support. This commit will be in r148. We can remove this commit when upgrading our Three.js fork to r148 or newer.
1 parent c4ee322 commit f2b8b44

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

examples/jsm/loaders/GLTFLoader.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,8 @@ function getImageURIMimeType( uri ) {
22292229

22302230
}
22312231

2232+
const _identityMatrix = new Matrix4();
2233+
22322234
/* GLTF PARSER */
22332235

22342236
class GLTFParser {
@@ -3997,7 +3999,23 @@ class GLTFParser {
39973999

39984000
parser.associations.get( node ).nodes = nodeIndex;
39994001

4000-
return node;
4002+
if ( nodeDef.skin === undefined ) return node;
4003+
4004+
return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skeleton ) {
4005+
4006+
// This full traverse should be fine because
4007+
// child glTF nodes have not been added to this node yet.
4008+
node.traverse( function ( mesh ) {
4009+
4010+
if ( ! mesh.isSkinnedMesh ) return;
4011+
4012+
mesh.bind( skeleton, _identityMatrix );
4013+
4014+
} );
4015+
4016+
return node;
4017+
4018+
} );
40014019

40024020
} );
40034021

@@ -4084,26 +4102,6 @@ function buildNodeHierarchy( nodeId, parentObject, json, parser ) {
40844102

40854103
return parser.getDependency( 'node', nodeId ).then( function ( node ) {
40864104

4087-
if ( nodeDef.skin === undefined ) return node;
4088-
4089-
// build skeleton here as well
4090-
4091-
return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skeleton ) {
4092-
4093-
node.traverse( function ( mesh ) {
4094-
4095-
if ( ! mesh.isSkinnedMesh ) return;
4096-
4097-
mesh.bind( skeleton, mesh.matrixWorld );
4098-
4099-
} );
4100-
4101-
return node;
4102-
4103-
} );
4104-
4105-
} ).then( function ( node ) {
4106-
41074105
// build node hierachy
41084106

41094107
parentObject.add( node );

0 commit comments

Comments
 (0)