Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

threejs中加载的gltf模型如何设置他的透明度?

let GLTFLoader1 = new GLTFLoader();/实例化加载器/

            GLTFLoader1.load(`/gltf/${data.pathName}/${data.pathName}.gltf`, (obj) => {
                console.log(obj)
                scene.add(obj.scene)
                obj.scene.position.x = 0;
                obj.scene.position.y = 0;
                obj.scene.position.z = 0;
                obj.scene.scale.set(4,4,4);
                obj.scene.name = data.name
                obj.scene.order = data.order
                group.add(obj.scene)
       })

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

loader.load('模型文件路径', function (gltf) {
 
      model = gltf.scene;

       //场景中添加模型文件

                scene.add(model);

                model.traverse(function (gltf) {

                    if (gltf.isMesh) {

                        //设置mesh的一些属性(比如透明度)

                    }

                }); 

              //设置整体场景的比例

                model.scale.set(10, 10, 10); 

            });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...