问题描述
所以我一直在尝试使用 SkeletonHelper 来渲染动画可视化器的基本骨架,但无法弄清楚如何让 SkeletonHelper 接受我传递给构造函数的 Skeleton 变量 armSkeleton.文档指出 SkeletonHelper 确实接受 Skeleton 类型的对象,这让我很伤心.我得到的控制台错误是TypeError: object.children is undefined".有人能指出我解决这个问题的正确方向吗?
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>
推荐答案
SkeletonHelper
不接受骨架作为构造函数参数.在您的情况下,您必须传入最顶部的骨骼.请查看以下示例以获取更多信息:
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/
这篇关于使用 Skeleton 和 Skeletonhelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!