三个js - 你能克隆从collada文件加载的动画吗? [英] Three js - Can you clone animations loaded from a collada file?

查看:106
本文介绍了三个js - 你能克隆从collada文件加载的动画吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上问的问题与此处的问题相同 - https:// github.com/mrdoob/three.js/issues/1883 - 使用三个j我可以导入具有基本关键帧动画的collada场景并轻松播放这些动画,但是想从一个场景复制动画数据反对另一个。

I'm essentially asking the same question as the one found here - https://github.com/mrdoob/three.js/issues/1883 - Using three js I can import a collada scene with basic keyframe animation and play back those animations easily enough, but would like to copy the animation data from one scene object to another.

这可能吗?

在运行时我注意到collada.animations对象包含一个 - collada .animations [n] .node - 它似乎是一个THREEJS.Mesh对象,我一直试图在运行时替换它(无济于事)。我还注意到collada.animations [n] .hierarchy [n]对象,也包含如下所示的节点属性:

At runtime I've noticed that the collada.animations objects contains a - collada.animations[n].node - which appears to be a THREEJS.Mesh object, which I've been trying to replace at runtime (to no avail). I've also noticed that the collada.animations[n].hierarchy[n] object, also contains node property that looks like this:

cameras: Array[0]
channels: Array[9]
controllers: Array[0]
endTime: 2.5
geometries: Array[1]
id: "name_of_exported_object"
keys: Array[2]
matrix: THREE.Matrix4
name: "name_of_exported_object"
nodes: Array[0]
sid: null
sids: Array[9]
startTime: 0
transforms: Array[5]
type: "NODE"

此对象由.name和.id显示,与我使用3D包(Blender)创建的name_of_exported_object绑定...我不喜欢我完全知道这个节点对象的用途。如何更改collada.animation [n]对象以在动态创建的场景对象上使用相同的动画?

This object appears, by .name and .id, to be tied to the "name_of_exported_object" which I created with my 3D package (Blender)... I don't quite know what this node object is for. How can I change the collada.animation[n] object sufficiently to use the same animation on a dynamically created scene object?

推荐答案

由于这个问题是几年前写的,所以three.js动画系统已被重写。您不再需要克隆动画,只需使用不同的混音器将它们应用于其他对象即可。示例:

Since this question was written a few years ago, the three.js animation system has been rewritten. You no longer need to "clone" animations, you can simply apply them to other objects using different mixers. Example:

var clip; // some THREE.AnimationClip instance.

var mixer1 = new THREE.AnimationMixer( object1 );
var mixer2 = new THREE.AnimationMixer( object2 );

var action1 = mixer1.clipAction( clip );
var action2 = mixer2.clipAction( clip );

action1.play();
action2.play();

这不是COLLADA特有的,适用于FBX,glTF和其他三种格式.js支持动画。

This isn't unique to COLLADA, it works for FBX, glTF, and any other formats that three.js supports animation for.

这篇关于三个js - 你能克隆从collada文件加载的动画吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆