Changing opacity with OBJMTLoader

梦想与她 提交于 2019-12-13 06:42:25

问题


I am currently working on a project with three.js which include the usage of the OBJMTLloader.js, loading the obj and the mtl file

Here is my code:

var loader = new THREE.OBJMTLLoader();
loader.load( './three/obj/Colonne/Vertebres.obj','./three/obj/Colonne/Vertebres.mtl', function ( object ) {
    object.position.y = - 70;
    scene.add( object );
} ); 

I want to know if it is possible to change the opacity of the object/material once it's loaded. Thank you.


回答1:


In your loader callback, you can use a pattern like this one:

object.traverse( function( node ) {
    if( node.material ) {
        node.material.opacity = 0.5;
        node.material.transparent = true;
    }
} );

three.js r.64



来源:https://stackoverflow.com/questions/20825479/changing-opacity-with-objmtloader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!