viewer: fit shadow frustum to building geometry instead of camera#348
Merged
Conversation
Following the camera look-at broke when zoomed out (fixed ±50 frustum too small to cover the scene) and when zoomed into an empty corner (frustum centred on nothing). Instead, fit the directional light's ortho shadow camera to the building: union the registered scene-node bounds (excluding the site/ground plane), fit a sphere, and size + place the shadow camera to cover that sphere plus a margin. Bounds are refreshed on a short interval since they only change while editing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
What does this PR do?
Reworks how the directional-light shadow frustum is framed. It previously followed the camera look-at, which fell apart in practice:
Now the frustum is fit to the building geometry, independent of the camera:
sceneRegistry.nodes), excludingsitenodes so the large ground/site plane doesn't inflate the frustum.radius * 1.15 + 3(the building "and a bit nearby"), park the light just outside the sphere along its theme direction, and bracketnear/fararound the sphere.The light direction still comes entirely from the scene theme — only the light's distance and the frustum extents change.
Follow-up to #347.
How to test
bun devand open a project with a building.Screenshots / screen recording
N/A — shadow-camera framing change; verified locally with a temporary
CameraHelper(removed before this PR) confirming the frustum hugs the building bounds across zoom levels.Checklist
bun devbun checkto verify)mainbranch