首页 > 解决方案 > THREE.js 什么是从搅拌机导出的 gltf 添加照明的最佳方法

问题描述

我想找到将搅拌机场景中的灯光添加到 THREE.js 项目中的最佳方法。我在任何地方都找不到关于如何将照明从搅拌机导入到 THREE.js 的解释。你应该已经在你的 THREE.js 项目中有光照。这在处理大型场景时效率不高。

使用 gltf 格式从搅拌机导入的 THREE.js 输出 使用 gltf 格式从搅拌机导入的输出

Blender 的场景渲染 我正在寻找的输出

这是我的进口声明

initGLTFLoader(){

    this.gltfLoader = new THREE.GLTFLoader();



}

loadCTF(){


    // Load a glTF resource
    this.gltfLoader.load(
        // resource URL
        'ctf.gltf',
        // called when the resource is loaded
        function ( gltf ) {

            // this console.log indicates that the light are actually in the import, 
            // but dont get added to the scene
            console.log(gltf);

            this.scene.add( gltf.scene );


        }.bind(this),
        // called while loading is progressing
        function ( xhr ) {

            console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

        },
        // called when loading has errors
        function ( error ) {

            console.log( 'An error happened', error );

        }
    
    );
}

标签: three.jsblenderlightinggltf3d-model

解决方案


推荐阅读