How can I dynamically change object’s opacity?

This is my object:

var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( {  map: THREE.ImageUtils.loadTexture( "image.png" ) } ) );
object.position.set(2, 3, 1.5);

now after I’ve created this object in init(); function, I can directly go to the object and change his position,like this:

object.position.x = 15;

Now the question is how can I change the opacity of the texture???

Thanks 🙂

Author: Fantashit

1 thought on “How can I dynamically change object’s opacity?

  1. For transparent materials you need first to set transparent flag (before first render of the object):

    var map = THREE.ImageUtils.loadTexture( "image.png" );
    var material = new THREE.MeshLambertMaterial( { map: map, transparent: true } );
    var object = new THREE.Mesh( geometry, material );

    Opacity is material parameter:

    material.opacity = 0.5;

Comments are closed.