This document outlines the implementation of lighting and shadows in our voxel world project. We've focused on creating a visually appealing environment with soft, realistic shadows and a color scheme inspired by a provided example.
We've implemented a lighting system that combines ambient light with directional lights to create depth and atmosphere in the scene.
#454e61
function setupLighting() {
scene.background = new THREE.Color('#454e61');
const ambientLight = new THREE.AmbientLight(0xffffff, 1.5);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 1.5);
directionalLight.position.set(-1, -1, -1).normalize().multiplyScalar(200);
directionalLight.castShadow = true;
// Shadow configuration (see Shadow Configuration section)
scene.add(directionalLight);
const additionalDirectionalLight = new THREE.DirectionalLight(0x000020, 1.5);
additionalDirectionalLight.position.set(-1, -1, -1).normalize().multiplyScalar(-200);
scene.add(additionalDirectionalLight);
}
We've optimized shadow settings for the main directional light to achieve soft, realistic shadows.