Hello,
im sory for stupid question, but i would like to setup whole light system like in this case:
https://vanruesc.github.io/postprocessing/public/demo/#antialiasing
i have copied light, but my project looks strange:
the objects have enable receiveShadow, and castShadow, and the light has enabled castShadow - so why i don’t see the shadows on map?
this is my code (i have changed the API, so don’t worry about names):
export default class MainScene extends Scene3D {
constructor() {
super('SpaceScene');
}
create() {
this.third.warpSpeed('sky', '-ground')
this.cameras.main.setViewport(0, 0, GAME_CONFIG.scale.width, GAME_CONFIG.scale.height);
this.third.renderer.setSize(GAME_CONFIG.scale.width, GAME_CONFIG.scale.height)
this.third.renderer.shadowMap.enabled= true;
this.third.camera.aspect = GAME_CONFIG.scale.width / GAME_CONFIG.scale.height
this.third.camera.updateProjectionMatrix()
this.third.camera.position.set(...this.SCENE_CONFIG.CAMERA_POSITION)
this.third.camera.lookAt(...this.SCENE_CONFIG.CAMERA_LOOK_AT)
this.createLight();
let loader = new THREE.GLTFLoader();
loader.load("/assets/sponza/Sponza.gltf", (model)=> {
let mesh = model.scene.children[0]
mesh.scale.set(1, 1, 1)
mesh.traverse(child => {
if (child.isMesh)
child.castShadow = child.receiveShadow = true
})
this.third.add.existing(mesh)
})
}
createLight(){
var ambientLight = new THREE.AmbientLight(0x111111);
ambientLight.castShadow = true;
this.third.add.existing(ambientLight)
var directionalLight = new THREE.DirectionalLight(0xffffff, 3);
directionalLight.position.set(4, 18, 3);
directionalLight.target.position.set(0, 7, 0);
directionalLight.castShadow = true;
directionalLight.shadow.mapSize.width = 2048;
directionalLight.shadow.mapSize.height = 2048;
directionalLight.shadow.camera.top = 20;
directionalLight.shadow.camera.right = 20;
directionalLight.shadow.camera.bottom = -20;
directionalLight.shadow.camera.left = -20;
directionalLight.shadow.camera.far = 32;
this.third.add.existing(directionalLight)
}
}