使用 OBJMTLoader 更改不透明度 [英] Changing opacity with OBJMTLoader

查看:28
本文介绍了使用 OBJMTLoader 更改不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用three.js进行一个项目,其中包括OBJMTLloader.js的使用,加载obj和mtl文件

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

这是我的代码:

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.

推荐答案

在你的加载器回调中,你可以使用这样的模式:

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

three.js r.64

这篇关于使用 OBJMTLoader 更改不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆