Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Three.js GLTF模型太暗_Three.js - Fatal编程技术网

Three.js GLTF模型太暗

Three.js GLTF模型太暗,three.js,Three.js,尝试将此车型加载到我的场景中,以下是它在glTF查看器中的外观: 我遵循了这个例子。使用这种更新的加载方法,模型仍然是暗的,如果我尝试缩放或定位它,它将完全消失 下面是如何加载的: const loader = new THREE.GLTFLoader(); const roughnessMipmapper = new RoughnessMipmapper( renderer ); loader.load( 'models/car_datsun/scene.gltf', function (

尝试将此车型加载到我的场景中,以下是它在glTF查看器中的外观:

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

下面是如何加载的:

 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;

是否可以尝试将环境贴图添加到材质(类似于此示例)?它可能具有较高的金属度值,因此不会像您预期的那样反射平行光。@Mugen87我更新了加载方法,使其与示例类似,但仍然是暗的。另外,现在我无法缩放或定位模型,因为这会使它消失。请将您的代码作为一个实例或git存储库进行共享,以便研究此问题。