问题
So I've been trying to use the SkeletonHelper to render a basic skeleton for an animation visualizer, but can't figure out how to get SkeletonHelper to accept the Skeleton variable armSkeleton I pass into the constructor. The documentation states that the SkeletonHelper does accept Skeleton type objects, which is causing me much grief. The console error I get is "TypeError: object.children is undefined". Could anyone point me in the right direction as to fixing this?
var bones = [];
var shoulder = new THREE.Bone();
var elbow = new THREE.Bone();
var hand = new THREE.Bone();
shoulder.add( elbow );
elbow.add( hand );
bones.push( shoulder );
bones.push( elbow );
bones.push( hand );
shoulder.position.y = -5;
elbow.position.y = 0;
hand.position.y = 5;
armSkeleton = new THREE.Skeleton( bones );
var helper = new THREE.SkeletonHelper(armSkeleton); <Error at this line>
回答1:
SkeletonHelper
does not accept a skeleton as the constructor parameter. In your case, you have to pass in the top most bone. Have a look at the following example for more information:
https://jsfiddle.net/f2Lommf5/13483/
来源:https://stackoverflow.com/questions/52231144/using-a-skeleton-with-skeletonhelper