Forum

User posts alexmuir
07 August 2017 15:30
Yes, I guess this is the only method currently available in Blend4Web.

Ah, ok. This is going to be tricky then because I have some multi-material objects. Is there a way to replace or assign an object's material at runtime?
07 August 2017 13:36
Hi,

This is my first post as I'm getting started on what will be a long blend4web project!

I have a scene with lots of bolts. I need to animate them being removed in groups, and I would like to transform them a few cm and then fade them out. I've got the transform done, as you can see in this gif.



The way the scene is constructed, I place an empty everywhere that there should be a bolt. I also place a single 'template bolt' in the scene. At runtime, I make instances of the template and append them where the empties are - it works great.

To fade out the bolts I was animating the diffuse color on the template bolt, like this:

var newAlpha = newAlpha - 0.1;
var color = m_material.get_diffuse_color(templateBolt, "BoltMaterial")
m_material.set_diffuse_color(templateBolt, "BoltMaterial", [color[0], color[1], color[2],newAlpha]);


That worked but all the bolts fade at once. I need a way to fade out only a single group of bolts.

And as a side question, is animating the material the only way to fade these objects out?