Skip to content

fix: preserve shared session aspect ratio#15

Merged
cazala merged 2 commits into
mainfrom
preserve-shared-session-aspect-ratio
Jan 15, 2026
Merged

fix: preserve shared session aspect ratio#15
cazala merged 2 commits into
mainfrom
preserve-shared-session-aspect-ratio

Conversation

@cazala
Copy link
Copy Markdown
Owner

@cazala cazala commented Jan 15, 2026

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 InitControls UI allowing users to toggle "Preserve shared aspect ratio" when a shared session with aspect ratio data is loaded.

  • Implemented state and effect hooks in InitControls to manage aspect ratio preservation, handle user zoom adjustments, and recalculate zoom on viewport resize or option toggle. [1] [2]

Engine Integration:

  • Extended the useEngine hook usage to include size, zoom, setZoom, and engine for proper zoom and sizing calculations in InitControls.
    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:

  • Added a new optional sceneAspectRatio field to the SessionDataV1 interface to record the aspect ratio when generating a shareable session URL.
  • Updated buildShareableSessionData to compute and include the current scene aspect ratio in shared session data, if available. [1] [2]

InitControls logic enhancements:

  • Refactored InitControls to extract and use sceneAspectRatio and base zoom from shared session URLs, computing a contained zoom to preserve scene framing on different device viewports. [1] [2]
  • Introduced state and logic to track and apply the shared session's aspect ratio and zoom dynamically when the viewport size changes. [1] [2]
  • Updated imports and hooks in InitControls to support the new logic and state management. [1] [2]

@github-actions
Copy link
Copy Markdown

Preview deployment ready

@cazala cazala merged commit 347f59f into main Jan 15, 2026
1 check passed
@cazala cazala deleted the preserve-shared-session-aspect-ratio branch January 15, 2026 12:48
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