ThreeJS 加載gltf模型過暗問題解決
用ThreeJS加載了兩個gltf模型结榄,明顯比在3Dc查看器中的暗
var loader = new GLTFLoader();
loader.load('/static/models/bed.glb', function (gltf) {
gltf.scene.scale.set(100,100,100);
gltf.scene.rotation.set(0,0,0);
gltf.scene.position.set(50,-10,50)
gltf.scene.castShadow=true;
console.log(gltf.scene)
gltf.scene.traverse( function ( child ) {
if ( child.isMesh ) {
child.frustumCulled = false;
//模型陰影
child.castShadow = true;
//模型自發(fā)光
child.material.emissive = child.material.color;
child.material.emissiveMap = child.material.map ;
}})
scene.add(gltf.scene);
});
只需設(shè)置模型自發(fā)光即可
child.material.emissive = child.material.color;
child.material.emissiveMap = child.material.map ;