mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(globe): Navara's shadowed sun leaked a light per frame
Navara 0.2.1's transparent pass refreshes its copy of every scene light each frame with copy(light, true). For the sun's cascaded shadow lights (three-csm CascadedDirectionalLights) that copy clones every cascade, so each frame brought new DirectionalLights with new ids and three's WebGLLights uniforms cache (keyed by id) grew by about 1.2 KB a frame in the looks whose sun casts shadows (minimal, photoreal). src/globe/navara/cascadedLightCopy.js patches the copy to update the cascades it has in place (pose, colour, intensity, target, shadow settings and camera) when the counts match, and keeps the rebuild otherwise; internals.js finds the class among the view's scene lights (private view._scenes.light) and applies it when the globe is built. Tests on three-csm's own class: the original copy changes the light ids, the patched one keeps the lights and takes the values. Post-GC JS heap (CDP HeapProfiler.collectGarbage every 10 s, the app on ?engine=navara rendering continuously at 60 fps): minimal 4.33 → 0.20 MB/min over 70 s and 0.06 MB/min over 180 s; photoreal 4.34 → 0.19 MB/min; cinematic (no shadow) 0.34. Added to the upstream asks.
This commit is contained in:
1 parent
c327a25744
commit
8812117013
5 files changed
+185
-2
No files matched your search
@@ -5,6 +5,7 @@
|
||||
// found it and the public API that would replace it upstream.
|
||||
|
||||
import { ModelMesh } from '@navaramap/three';
|
||||
import { patchCascadedLightCopy } from './cascadedLightCopy.js';
|
||||
|
||||
export const NAVARA_INTERNALS_VERSION = '0.2.1';
|
||||
|
||||
@@ -130,6 +131,23 @@ export function forEachLuminanceUniform(handles, visit) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Phase 3 review (leak): the sun's cascaded shadow lights are re-cloned by
|
||||
* the transparent pass every frame (cascadedLightCopy.js). Finds the
|
||||
* CascadedDirectionalLights class among the view's scene lights (private:
|
||||
* view._scenes.light) and patches its copy to update in place. Returns the
|
||||
* restore function, or null when the look has no cascaded light (the
|
||||
* cinematic sun casts no shadow). Upstream ask: copy cascaded lights in
|
||||
* place.
|
||||
*/
|
||||
export function keepCascadedLightIds(view) {
|
||||
const lights = view._scenes?.light?.children ?? [];
|
||||
const cascaded = lights.find((light) => Array.isArray(light?.cascadedLights));
|
||||
return cascaded
|
||||
? patchCascadedLightCopy(Object.getPrototypeOf(cascaded))
|
||||
: null;
|
||||
}
|
||||
|
||||
/** The hooks createNavaraEngine takes. */
|
||||
export const navaraHooks = (view) => ({
|
||||
retainTileGeometry,
|
||||
|
||||
Reference in new issue
Block a user