Models opacity

Hi, I’m trying to find a generic way to change a model opacity.
My idea was to loop through all materials in a model and the ‘alpha’ property.
It seems that it does not work, gives an exception saying the material does not have an alpha property.
Given that transparency is not done in shaders but rather part of a renderstate, every material should have an configurable alpha/opacity no?

Here’s my code:
var obj = this._materials;
for (var mat in obj) {
if (obj.hasOwnProperty(mat)) {
obj[mat].setValue(‘alpha’, alpha);

Hi Sergio,

If a member starts with an underscore, it is considered private so we don’t want to use it outside the class. To get a material, use Model.getMaterial.

There is no convention that all materials will have an alpha property or that all materials will have blending enabled in the renderstate. To support this robustly will require support in the converter. We have plans on the roadmap (#927) that will make this easier, but I can’t promise we’ll get to them soon (chime in on the roadmap thread). In the meantime, consider post-processing your glTF models so, for example, we add an alpha parameter (and update the shader) for all materials with blending enabled.