From 6a53e95c2257c39d8a15b76779f38175c899ed8c Mon Sep 17 00:00:00 2001 From: Takahiro Date: Sun, 8 Jan 2017 20:27:15 -0800 Subject: [PATCH] Add bone graph to SkinnedMesh --- examples/js/loaders/GLTFLoader.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index 75e1a5d956..dca6020e70 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -1622,6 +1622,31 @@ THREE.GLTFLoader = ( function () { child.bind( new THREE.Skeleton( bones, boneInverses, false ), skinEntry.bindShapeMatrix ); + var buildBoneGraph = function ( parentJson, parentObject, property ) { + + var children = parentJson[ property ]; + + if ( children === undefined ) return; + + for ( var i = 0, il = children.length; i < il; i ++ ) { + + var nodeId = children[ i ]; + var bone = __nodes[ nodeId ]; + var boneJson = json.nodes[ nodeId ]; + + if ( bone !== undefined && bone.isBone === true && boneJson !== undefined ) { + + parentObject.add( bone ); + buildBoneGraph( boneJson, bone, 'children' ); + + } + + } + + } + + buildBoneGraph( node, child, 'skeletons' ); + } _node.add( child ); -- GitLab