[SOLVED] Setting opacity of an object

Hello there, im trying to set opacity of my model to be half transparent, using this lines of code:

image

im receiving error: “opacity.setParameter is not a function

can somebody set me on a right path ? :slight_smile:

Hello @smokys,

meshInstances

is an array :slight_smile:

:rocket:

I forgot to mention that i also used this code:

image

but wanted sombody to explain from the start

Any ideas? Still havent figured out :slight_smile:

Try this:

var meshInstance = meshInstances[i];
var material = meshInstance.material;
material.opacity = 0.5;
material.blendType = pc.BLEND_NORMAL;
material.update();

By default, the materials has no blend type,so they not use the opacity parameter. You need to specify which blend function will be used to render one object above other

2 Likes