Remember projection mode across app restarts - #19
Merged
Conversation
Studio defaulted to the orthogonal projection on every launch, so a perspective view had to be re-selected each time. The choice is now persisted as `orthogonal_view` in `~/.config/luacad/state.json`, next to `hide_editor` and `auto_reload`, and restored at startup. Switching the projection moves the camera so the scene keeps its apparent size. That conversion, previously inline in the bottom bar, moves into `AppState::set_orthogonal_view` so restoring the setting at startup goes through the same path, and the ratio it uses (the perspective/orthogonal distance factor for the 45° FOV) is shared with the raytrace framing instead of being spelled out twice. `reset_camera` now uses the default distance that matches the current projection as well, rather than always the orthogonal one — resetting the camera in a perspective view no longer jumps the zoom. Closes #18 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MB6F4dt6mJBviL7su3RKYz
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.
Summary
This PR adds persistence for the 3D view projection mode (orthogonal vs perspective) across application restarts, and improves camera distance handling to maintain consistent apparent scene size when switching projections.
Key Changes
set_orthogonal_view()method: Centralizes projection switching logic with automatic camera distance adjustment to keep the scene at the same apparent sizeprojection_distance_ratio()function: Eliminates magic number duplication and documents the mathematical relationship (tan(22.5°)) between orthogonal and perspective camera distancesreset_camera(): Now respects the current projection mode when setting the default camera distance, instead of always using the orthogonal distanceset_orthogonal_view()method instead of duplicating the distance calculation logicImplementation Details
1.0 / tan(22.5°)where 22.5° is half the perspective FOVhide_editor,auto_reload) in the state fileprojection_distance_ratio()function for consistencyhttps://claude.ai/code/session_01MB6F4dt6mJBviL7su3RKYz