Three js. Can you clone an animation downloaded from a collada file?

I essentially ask the same question as here - https://github.com/mrdoob/three.js/issues/1883 - Using three js, I can import a collada scene with a basic keyframe animation and easily play these animations , but I’d like to copy the animation data from one scene object to another.

Is it possible?

At runtime, I noticed that collada.animations objects contain a - collada.animations [n] .node - which looks like a THREEJS.Mesh object that I am trying to replace at runtime (no no helped). I also noticed that the collada.animations [n] .hierarchy [n] object also contains a node property, which 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" 

This object appears using .name and .id to bind to the "name_of_exported_object" that I created using my 3D package (Blender) ... I do not quite know what this node object is for. How can I change the collada.animation [n] object enough to use the same animation on a dynamically created scene object?

+4
source share
1 answer

Since this question was written several years ago, the three.js animation system was 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(); 

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

+1
source

All Articles