GLTF模型太暗

时间:2020-02-19 20:11:06

标签: three.js

尝试将此汽车模型加载到我的场景中,这是它在glTF Viewer中的外观:

enter image description here

我遵循了这个例子。使用这种更新的加载方法,模型仍然很暗,如果我尝试缩放或定位它,它会完全消失。

这是它的加载方式:

 const loader = new THREE.GLTFLoader();
const roughnessMipmapper = new RoughnessMipmapper( renderer );
loader.load( 'models/car_datsun/scene.gltf', function ( gltf ) { 
    gltf.scene.traverse( function (child) {
        if (child.isMesh) {
            roughnessMipmapper.generateMipmaps(child.material);
        }
        child.scale.set(0.5,0.5,0.5); //must comment this line out to appear 
        child.position.y += 10; //must comment this line out to appear
        child.position.z += 20; //must comment this line out to appear
    });
    scene.add(gltf.scene);
}, undefined, function ( error ) {
    console.error(error);
});
roughnessMipmapper.dispose();

我还有一盏灯,用来模拟太阳:

 const light = new THREE.DirectionalLight(0xffffff, 0.5);
 light.position.set(500,200,500); //looking at 0,0,0
 scene.add(light);

渲染器设置为使用sRGB:

renderer.outputEncoding = THREE.sRGBEncoding;

0 个答案:

没有答案