4

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.

Is that possible?

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"

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?

gman
  • 100,619
  • 31
  • 269
  • 393
Charlie
  • 4,197
  • 5
  • 42
  • 59
  • Have you found a way to this? I am facing the same problem – ThisIsSparta Dec 12 '13 at 10:03
  • No, not as I wanted to anyway. I had a very simple use case, which I was able to address by using Tween JS (https://github.com/sole/tween.js/). Not quite sure what you have in mind, but if I wanted to try to clone a complicated animation, I'd start by looking at this example - http://threejs.org/examples/#webgl_shadowmap – Charlie Dec 13 '13 at 12:52
  • Alright thanks for the link I will try to adapt it to the collada model and see if it works. – ThisIsSparta Dec 13 '13 at 13:37

1 Answers1

3

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

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

Don McCurdy
  • 10,975
  • 2
  • 37
  • 75