使用 Skeleton 和 Skeletonhelper

编程入门 行业动态 更新时间:2024-10-27 01:22:27
本文介绍了使用 Skeleton 和 Skeletonhelper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

所以我一直在尝试使用 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/f2Lommf5/13483/

这篇关于使用 Skeleton 和 Skeletonhelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 15:07:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395741.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Skeleton   Skeletonhelper

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!