I baked the texture in Blender and imported it along with the model, but the texture is brighter than the Blender render screen and the baked image. How can I solve this? Here is my code and image.
const canvas = document.querySelector('canvas.webgl')
const scene = new THREE.Scene()
const textureLoader = new THREE.TextureLoader()
const dracoLoader = new DRACOLoader()
dracoLoader.setDecoderPath('draco/')
const gltfLoader = new GLTFLoader()
gltfLoader.setDRACOLoader(dracoLoader)
const bakedTexture = textureLoader.load('baked.jpg')
THREE.ColorManagement.legacyMode = false
bakedTexture.flipY = false
bakedTexture.encoding = THREE.SRGBColorSpace
const bakedMaterial = new THREE.MeshBasicMaterial({ map: bakedTexture })
gltfLoader.load(
'camera.glb',
(gltf) =>
{
gltf.scene.traverse((child) =>
{
child.material = bakedMaterial
})
scene.add(gltf.scene)
}
)
const sizes = {
width: window.innerWidth,
height: window.innerHeight
}
window.addEventListener('resize', () =>
{
sizes.width = window.innerWidth
sizes.height = window.innerHeight
camera.aspect = sizes.width / sizes.height
camera.updateProjectionMatrix()
renderer.setSize(sizes.width, sizes.height)
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
})
const camera = new THREE.PerspectiveCamera(25, sizes.width / sizes.height, 0.1, 1000)
camera.position.x = 5
camera.position.y = 5
camera.position.z = 10
scene.add(camera)
const controls = new OrbitControls(camera, canvas)
controls.enableDamping = true
const renderer = new THREE.WebGLRenderer({
canvas: canvas,
antialias: true
})
renderer.setSize(sizes.width, sizes.height)
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
const tick = () =>
{
controls.update()
renderer.render(scene, camera)
window.requestAnimationFrame(tick)
}
tick()