Hi there!
Is it basically possible to fade out / in batched entities? I have an 3d object with a bunch of similar child entities, which sharing the same materials.
i used:
// update code called every frame
GameController.prototype.update = function(dt) {
if(this.canFade)
{
this.children.forEach(function(child) {
// acess the material of the render component
var material1 = child.render.meshInstances[0].material;
var material2 = child.render.meshInstances[1].material;
// adjust opacity
if(fadeOut && material1.opacity >= 0 || !fadeOut && material1.opacity <= 1)
{
adjustOpacity(material1, fadeValue);
adjustOpacity(material2, fadeValue);
// avoid update from executing if not necessary
if(fadeOut && material1.opacity <= 0.001 || !fadeOut && material1.opacity >= 0.999)
{
this.canFade = false;
}
}
}, this);
}
};
function adjustOpacity(material, increment) {
material.setParameter('material_opacity', material.opacity += increment);
material.update();
}
this works if the entities are not batched but if theyre batched within a group it doesnt work. Im not sure about how to handle batched groups but i thought it may increase the perfermance if i group those meshes together. (its around 65 child entities, so i think i would decrease the drawcalls if theyre batched)
Thanks in advance for each input!