Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: camera aspect #531

Closed
wants to merge 6 commits into from
Closed

fix: camera aspect #531

wants to merge 6 commits into from

Conversation

andretchen0
Copy link
Contributor

@andretchen0 andretchen0 commented Feb 1, 2024

Warning

For current users of <TresOrthographicCamera /> this is a breaking change. A solution is provided but requires intervention. See "Problem 2".

Problem 1

Screen.Recording.2024-02-01.at.20.35.09.mov

Unlike <TresPerspectiveCamera />, <TresOrthographicCamera /> does not update automatically after screen ratio changes.

StackBlitz

Solution

R3F uses the Three.OrthographicCamera's default left, right, top, bottom to maintain the frustum cuboid. This PR follows that example.


Problem 2

Tres currently overwrites aspect on <TresPerspectiveCamera />. In rare cases, the user may wish to control aspect.

Similarly, with this PR, left, right, top, bottom on <TresOrthographicCamera /> are controlled by Tres. Users who set those attributes manually need a way to keep Tres from overwriting them.

Solution

R3F lets users set a manual flag on the cameras to opt out of automatic aspect changes. This PR follows that example.

To set a camera as "manual" in TypeScript:

const myCamera = new PerspectiveCamera(); // or OrthographicCamera
(myCamera as any).manual = true

Playground

Playground updated at /cameras/camera . manual cameras have been added.

Copy link

netlify bot commented Feb 1, 2024

Deploy Preview for tresjs-docs ready!

Name Link
🔨 Latest commit 722e1ca
🔍 Latest deploy log https://app.netlify.com/sites/tresjs-docs/deploys/65bc1dc9f7c4f80008cce984
😎 Deploy Preview https://deploy-preview-531--tresjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@andretchen0 andretchen0 changed the title Fix/camera aspect fix: camera aspect Feb 1, 2024
@andretchen0 andretchen0 marked this pull request as ready for review February 1, 2024 22:41
@alvarosabu
Copy link
Member

Hey @andretchen0 great work here, thanks for the fix, if it's a breaking change, should we include it better on the v4 then?

@andretchen0
Copy link
Contributor Author

Hey @andretchen0 great work here, thanks for the fix, if it's a breaking change, should we include it better on the v4 then?

Thanks! v4 is fine with me.

@alvarosabu
Copy link
Member

@andretchen0 Ok awesome, just change the base of the PR to the branch v4

@andretchen0 andretchen0 added the v4 label Feb 2, 2024
@andretchen0 andretchen0 changed the base branch from main to v4 February 2, 2024 13:06
@alvarosabu
Copy link
Member

@andretchen0 something is off, there are too many changes that weren't related to your initial PR into v4

@andretchen0
Copy link
Contributor Author

@alvarosabu

Thanks for flagging that.

Merging in v4 seems to have added a lot of files to the PR. I'll close open a new PR that's based on v4 from the start.

@andretchen0 andretchen0 closed this Feb 5, 2024
@andretchen0 andretchen0 deleted the fix/camera-aspect branch February 5, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants