I am trying to simulate a blinking light on an object, so I am animating the material color. I then export the blender model into three.js via the collada exporter.
To demonstrate the problem, I have created a model with a single cube on which I change the color from red to green and back to red. I also move the cube a little.
At frame 0, I make the cube red with no displacement:
At frame 12, I make it green and displace it a little:
When I play the animation within blender, I see the color change and the cube displace. However, when I export it with collada into three.js, the cube moves, but it stays one color (the color of the cube that was active at the time I exported it e.g it can be either red or green, but always one color). I have created a plunker demonstrating the problem. My collada code is based on the three.js collada pump example. Here is the code used to load the model:
factory.loadColladaModel = function () {
console.log(`now in loadColladaModel`);
var loader = new THREE.ColladaLoader();
loader.options.convertUpAxis = true;
var promise = new Promise( (resolve, reject) => {
loader.load( 'color_animation.dae', (collada) => {
console.log(`now in collada load closure`);
let model = collada.scene;
factory.scene.add(model);
factory.animations = collada.animations;
model.scale.x = model.scale.y = model.scale.z = 5.0;
for ( var i = 0; i < factory.animations.length; ++i ) {
var animation = factory.animations[ i ];
var kfAnimation = new THREE.KeyFrameAnimation( animation );
kfAnimation.timeScale = 1;
factory.kfAnimations.push( kfAnimation );
}
resolve('loaded');
})
})
return promise;
}
What do I do have to do in order to get three.js to animate the material (color) changes as well as the motion? I do see color entries under the 'animation' tag of the collada file, so I assume collada supports it. I saw this prior question where someone had to set morphTargets in order to get materials to work. Do I need to do something like this too? Is morphTargets only for motion, or is it for color too?
three.js r84 blender 2.78b
Many Thanks.