Skip to content

Significantly optimized 3D Renderer performance, shadow update suppression, instancing optimizations#482

Open
Mond-Mann wants to merge 1 commit intoMechanical-Advantage:mainfrom
Mond-Mann:main
Open

Significantly optimized 3D Renderer performance, shadow update suppression, instancing optimizations#482
Mond-Mann wants to merge 1 commit intoMechanical-Advantage:mainfrom
Mond-Mann:main

Conversation

@Mond-Mann
Copy link

This PR focuses on reducing the previously ridiculous per-frame allocations, avoiding redundant computations, and improving rendering performance across 3D+XR renderers while not cutting any existing features or visualization behavior. These changes mark a significant step towards making the 3D Field view practical for lower-end devices.
I will be responding to questions to this PR, but I likely won't make other contributions to this repo.

Rendering+Frame Loops:
Added overlay toggled by backtick displaying FPS and frame-time over a 60-frame window.
Cinematic mode shadow maps now only update when the scene is dirty/after an idle interval, reducing shadow pass cost.
Camera movement properly triggers shadow refreshes, delta time clamped to prevent camera jumps after tab backgrounding.
Camera movement input combined into one update call.

Change Detection+Caching:
Replaced JSON.stringify comparisons with reference equality fast paths!
Cached coordinate transforms, field bounds, and expensive function results, background colors, light temperature conversions, redundant asset+alliance-state change detection, field configs, etc.
Deduplicated renderer.setPixelRatio calls and capped XR pixel ratio at 2 times.

Object+Memory Optimizations:
Removed superfluous per-frame allocations such as scratch vectors/quaternions, stationary objects, etc.
Replaced O(n²) object-manager scans with O(n) inactive pool map to improve scaling.
Replaced filter cleanup with one pass in-place compaction.

Instancing Improvements:
ResizableInstancedMesh now uses Matrix4.compose() and preassigned scratch objects.
Instanced meshes use DynamicDrawUsage and render only active instances.
Removed unused bounding-box calculations.

Misc Improvements:
ConeManager: preallocated pose buffers+immutable geometry.
HeatmapManager: full dirty tracking skips GPU updates when unchanged.
TrajectoryManager: preallocated Float32Array, fewer allocations, early returns.
XR: RAF scheduling now combines render requests into one frame.

@Mond-Mann Mond-Mann changed the title Significantly optimizing 3D Field performance Significantly optimizing 3D Renderer performance, shadow update suppression, instancing optimizations Mar 8, 2026
@Mond-Mann Mond-Mann changed the title Significantly optimizing 3D Renderer performance, shadow update suppression, instancing optimizations Significantly optimized 3D Renderer performance, shadow update suppression, instancing optimizations Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant