fix: preserve shared session aspect ratio#15
Merged
Conversation
|
Preview deployment ready
|
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 pull request introduces support for preserving the aspect ratio of a shared session scene across different device viewports in the Playground app. It adds logic to capture the aspect ratio when generating a shareable session, and provides UI and state management to optionally maintain the original framing when loading a shared session. The changes ensure that users can toggle this aspect ratio preservation and that zoom is correctly adjusted to fit the target viewport.
Aspect Ratio Preservation for Shared Sessions:
Added logic to capture and store the scene's aspect ratio (
sceneAspectRatio) when generating a shareable session, and included it in the session data format (SessionDataV1) and shareable session builder (buildShareableSessionData). [1] [2] [3]When loading a shared session, detects and parses the stored aspect ratio, and calculates an appropriate zoom level to preserve the original framing. This includes updating the session loading logic and managing new state variables for aspect ratio and zoom.
UI/UX Improvements:
Added a checkbox to the
InitControlsUI allowing users to toggle "Preserve shared aspect ratio" when a shared session with aspect ratio data is loaded.Implemented state and effect hooks in
InitControlsto manage aspect ratio preservation, handle user zoom adjustments, and recalculate zoom on viewport resize or option toggle. [1] [2]Engine Integration:
useEnginehook usage to includesize,zoom,setZoom, andenginefor proper zoom and sizing calculations inInitControls.This pull request enhances the handling of viewport aspect ratios and zoom levels when sharing and restoring sessions in the playground app. The main goal is to ensure that scenes maintain consistent framing across devices with different screen sizes by capturing and applying the scene's aspect ratio and zoom during session sharing and loading.
Session sharing and restoration improvements:
sceneAspectRatiofield to theSessionDataV1interface to record the aspect ratio when generating a shareable session URL.buildShareableSessionDatato compute and include the current scene aspect ratio in shared session data, if available. [1] [2]InitControls logic enhancements:
InitControlsto extract and usesceneAspectRatioand base zoom from shared session URLs, computing a contained zoom to preserve scene framing on different device viewports. [1] [2]InitControlsto support the new logic and state management. [1] [2]