Transparency failing after r137

I’ve recently upgraded from r131 to r142 only to find that setting a material’s transparency no longer works for me. The migration guide says that beginning with r137 changing transparency requires setting needsUpdate to true. Okay, but it’s not working for me. Although the parent Material object is documented as having the needsUpdate property, my code issues the error
THREE.MeshStandardMaterial: ‘needsUpdate’ is not a property of this material.
Do I need to switch materials or what? If so, what is the closest thing to MeshStandardMaterial that will work?

Thanks.

Could you share the code you’re referring to? There’s more than one transparency-related property, so knowing exactly what code you’re using would help.

Note that ‘needsUpdate’ is not a constructor parameter, you’ll need to imperatively set it:

material.needsUpdate = true;

MeshStandardMaterial (and all other built-in materials) supports the property.

Thanks. That fixed it.

I was using material.setValues ({transparent: true, needsUpdate: true});

Both .transparent and .needsUpdate are documented identically in three.js docs, so it’s not clear to me why needsUpdate must be set like this instead:

material.setValues ({transparent: true});
material.needsUpdate = true;

but that fixed my problem. Any further explanation would be welcome. Thanks again.

Hm, that’s an interesting point. I think it’s always true in three.js that the .needsUpdate flag is a setter method that increments some internal state to make sure the object is updated on the GPU. But it doesn’t really have a ‘value’ to read back, so you can’t check if ( material.needsUpdate === true ). I guess that’s why setValues(...) isn’t accepting it, but I don’t really know whether that’s intentional or not.