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
@@ -6,7 +6,11 @@ import ThreeView from '@navaramap/three';
|
||||
import * as geo from '../../geo/index.js';
|
||||
import { DefaultPlugin } from '@navaramap/three-default-plugin';
|
||||
import { createNavaraEngine } from './createNavaraEngine.js';
|
||||
import { forEachLuminanceUniform, navaraHooks } from './internals.js';
|
||||
import {
|
||||
forEachLuminanceUniform,
|
||||
keepCascadedLightIds,
|
||||
navaraHooks,
|
||||
} from './internals.js';
|
||||
import { buildNavaraLook } from './look.js';
|
||||
import { createNavaraSharpen } from './sharpen.js';
|
||||
import { createNavaraMovers } from './movers/index.js';
|
||||
@@ -112,6 +116,8 @@ export async function createNavaraGlobe({
|
||||
() => engine.clock.frameTime(),
|
||||
{ forEachLuminanceUniform },
|
||||
);
|
||||
// The look's shadowed sun leaked a light per frame (internals.js).
|
||||
keepCascadedLightIds(view);
|
||||
engine = createNavaraEngine(view, {
|
||||
hooks: navaraHooks(view),
|
||||
container,
|
||||
|
||||
Reference in new issue
Block a user