This article says that shadows only work with the Orthographic
camera, not Perspective
, is that true?
Link removed by moderation as it leads to a malicious site
I followed the article’s code with my scene that is based on a Perspective
camera and It’s true, I don’t see any shadows. But I’m hoping there’s still a way to get shadows because to redo my scene with an Orthographic
camera would take a lot of work I don’t have time for.
Here’s my current code:
console.warn(`${errPrefix}Initializing Galaxy Pay.`);
assignThreeJsCamera(new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000));
// Set the camera position.
g_ThreeJsCamera.position.y = 10;
// -------------------- BEGIN: SOLAR SYSTEM LIGHTS ------------
// >>>>> BELOW
const lightBelowSS = new THREE.HemisphereLight(0xeeeeff, 0x777788, 1, ); // 0.75);
lightBelowSS.position.set(SOLAR_SYSTEM_X_POS, SOLAR_SYSTEM_Y_POS - 3, SOLAR_SYSTEM_Z_POS);
lightBelowSS.lookAt(g_TheEarth.position);
g_ThreeJsScene.add(lightBelowSS);
// >>>>> ABOVE
// const lightAboveSS = new THREE.DirectionalLight(0xeeeeff, 0x777788, 1, ); // 0.75);
const lightAboveSS = new THREE.DirectionalLight(0xeeeeff);
lightAboveSS.position.set(SOLAR_SYSTEM_X_POS, SOLAR_SYSTEM_Y_POS + 3, SOLAR_SYSTEM_Z_POS);
// Cast shadow.
lightAboveSS.castShadow = true;
// Shadow intensity.
lightAboveSS.shadowDarkness = 0.5;
// Debugging tool.
lightAboveSS.shadowCameraVisible = true;
// Look at the arth.
lightAboveSS.lookAt(g_TheEarth.position);
g_ThreeJsScene.add(lightAboveSS);
// -------------------- END : SOLAR SYSTEM LIGHTS ------------
Screenshot, no shadows.