Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person

Categories

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)
       })

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

1 Answer


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

       //场景中添加模型文件

                scene.add(model);

                model.traverse(function (gltf) {

                    if (gltf.isMesh) {

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

                    }

                }); 

              //设置整体场景的比例

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

            });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...