Capítulo 847 de 859
Three.js's default shadow maps work by re-rendering all shadow-casting objects from each shadow-casting light's point of view, which gets expensive fast (a point light alone costs 6 extra scene renders) — cheap "fake" gradient-texture shadows are a common lighter-weight alternative, and real shadow maps need their light's shadow camera frustum sized correctly or shadows get clipped.
PointLight alone costs 6 renders (once per cube-map direction).DirectionalLight) even if the scene has several lights, or fake shadows with a soft gradient-blob texture on a plane beneath each object, fading its opacity as the object rises — cheap and used in real shipped games for exactly this reason.renderer.shadowMap.enabled = true, light.castShadow = true on the light, and explicit mesh.castShadow/mesh.receiveShadow flags per object (e.g. a ground plane typically only needs receiveShadow).OrthographicCamera for DirectionalLight, matching how directional light rays are parallel) whose frustum bounds where shadows are computed at all — content outside that box casts or receives no shadow; visualize it with a CameraHelper on light.shadow.camera.left/right/top/bottom (and near/far) to fit the scene's actual shadow-relevant area is necessary — the default box is often too small.renderer.shadowMap.enabled = true;
const light = new THREE.DirectionalLight(0xffffff, 1);
light.castShadow = true;
scene.add(light);
scene.add(light.target);
groundMesh.receiveShadow = true;
cubeMesh.castShadow = true;
cubeMesh.receiveShadow = true;
const cameraHelper = new THREE.CameraHelper(light.shadow.camera);
scene.add(cameraHelper); // visualize the shadow camera's frustum
PointLight costs 6x on its own.renderer.shadowMap.enabled, light.castShadow, and per-mesh castShadow/receiveShadow flags — all four pieces are needed.CameraHelper) that must be sized to cover the actual shadow-relevant scene area, or parts of shadows will be silently clipped.