Significantly optimized 3D Renderer performance, shadow update suppression, instancing optimizations#482
Open
Mond-Mann wants to merge 1 commit intoMechanical-Advantage:mainfrom
Open
Significantly optimized 3D Renderer performance, shadow update suppression, instancing optimizations#482Mond-Mann wants to merge 1 commit intoMechanical-Advantage:mainfrom
Mond-Mann wants to merge 1 commit intoMechanical-Advantage:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.