Changing Object Opacity (dynamically)

Sorry I cannot post all my code here as its too long but essentially I have a MeshBasicMaterial added to the scene, with transparent = true.

If I try to change the Mesh’s other values such as depthTest = false instead of true, or change whether it is double sided or not, I can dynamically do this with my simple button. However, in that same button, if I try to change the opacity of the mesh dynamically, it does not work.

I have tried to change the opacity in multiple ways such as:

videoMesh.material.opacity = 0.5;, 2, { opacity: 0.5 });, 2, { opacity: 0.5 });

However, none of these dynamically change the opacity when the button is pressed. Any tips on why this isn’t working and is opacity a special case?

Do you mind modifying the following live example in order to demonstrate the issue:

It seems changing the opacity value with a simple setTimeout() works as intended.

1 Like

Hey Mugen,

Thanks to playing with your solution I have seen that I was trying to change the videoMesh.material instead of videoMaterial which was the material used to build the actual mesh.

Changing what I was targetting to the below code worked:, 2, { opacity: 0 });

Also it seems when using Tween you don’t need to put .opacity as well as state {opacity: 0.5} as they it breaks the code.

1 Like