javascript 如何在 Three.js 中处理动画模型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16276747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 04:01:55  来源:igfitidea点击:

How do I handle animated models in Three.js?

javascriptanimationmodelthree.jswebgl

提问by user1066278

I have a basic question about Three.js. I've googled but didn't find anything useful... How do I handle animated models in Three.js? I know how to import .js files, and I have an animated cube exported from blender to .js format. I've imported it with the JSONLoader, but the animation wont play by itself. So that's where I am, I don't know how to play it.

我有一个关于 Three.js 的基本问题。我用谷歌搜索但没有找到任何有用的东西......我如何处理 Three.js 中的动画模型?我知道如何导入 .js 文件,并且我有一个从搅拌机导出为 .js 格式的动画立方体。我已经用 JSONLoader 导入了它,但是动画不会自己播放。所以这就是我的位置,我不知道怎么玩。

I've checked the documentation but I don't know what I should use... Tried the MorphAnimationMesh, and when I log the length, it finds 250 frames. So I guess the export went well.

我检查了文档,但我不知道我应该使用什么...尝试了 MorphAnimationMesh,当我记录长度时,它找到了 250 帧。所以我猜出口进展顺利。

I'm using WebMatrix and it doesn't seem to recognize dae-files, so I haven't tried with them yet. And for them as well I do not know how to handle animations.

我正在使用 WebMatrix,它似乎无法识别 dae 文件,所以我还没有尝试过。对于他们,我也不知道如何处理动画。

Please help!

请帮忙!

回答by Tapio

There are plenty of examples in the three.js sources. You can also view them online, e.g.

Three.js 源代码中有很多示例。您也可以在线查看它们,例如

There's also another style of animation, called skeleton animation or "skinning". However, if you found 250 frames of morphs, then you don't need to worry about it at this point, but it's good to be aware of it. Blender can export both - morphs are more foolproof but skinning takes less space.

还有另一种动画风格,称为骨架动画或“蒙皮”。但是,如果您发现 250 帧的变形,那么此时您无需担心,但了解它是很好的。Blender 可以导出两者 - 变形更万无一失,但蒙皮占用的空间更少。

回答by Damjan Pavlica

I found this one example pretty useful for game dev:

我发现这个例子对游戏开发非常有用:

https://threejs.org/examples/webgl_animation_skinning_blending.html

https://threejs.org/examples/webgl_animation_skinning_blending.html