Why are some cubes in my loop not casting shadows?
Despite using a directional light that should cast shadows on all cubes, the shadowing stops after around 5 columns.
let dirLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
dirLight.position.set(300, -300, 400);
dirLight.castShadow = true;
scene.add(dirLight);
dirLight.shadow.mapSize.width = 512;
dirLight.shadow.mapSize.height = 512;
dirLight.shadow.camera.near = 0.5;
dirLight.shadow.camera.far = 1000;
let cubeGeometry = new THREE.BoxGeometry(1, 3, 1);
let cubeMaterial = new THREE.MeshLambertMaterial({
color: 0xf54242
});
function drawCubes() {
for (let c = 0; c < 25; c++) {
for (let r = 0; r < 10; r++) {
for (let t = 0; t < 2; t++) {
let cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
cube.position.x = c * 1.3;
cube.position.y = r * 3.02;
cube.position.z = t * 1.01;
cube.castShadow = true;
cube.receiveShadow = true;
scene.add(cube);
}
}
}
}
drawCubes();