SkeletonHelper未呈现

时间:2019-04-03 05:47:48

标签: three.js

我正在尝试使用SkeletonHelper显示三个JS骨架。

根据此answer,SkeletonHelper()取得了根骨骼。我已经做到了。但是它没有被显示。为什么会这样?

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);

skeleton = new THREE.Skeleton(bones)

skeleton_helper = new THREE.SkeletonHelper(shoulder)
scene.add(skeleton_helper)
}

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

THREE.SkeletonHelper假定骨骼的世界矩阵是最新的。因此,通过将变形添加到骨骼,然后将最顶部的骨骼添加到场景中,您应该看到所需的结果。之所以可行,是因为渲染器确保了整个场景图的正确世界矩阵。

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 = 0;
elbow.position.y = - 1;
hand.position.y = - 0.5;

var armSkeleton = new THREE.Skeleton( bones );
var skeleton_helper = new THREE.SkeletonHelper( shoulder );

scene.add( skeleton_helper );
scene.add( shoulder );

https://jsfiddle.net/xvbLwyaq/3/

three.js R103