Skip to content
New issue

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

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

Already on GitHub? # to your account

Scale camera zoom based on distance to target #40

Merged
merged 5 commits into from
Nov 13, 2024

Conversation

thatcomputerguy0101
Copy link
Contributor

This causes the distance between the camera position and the camera target to affect the scale at which geometry is projected through the camera. Zooming was also changed to not affect the position of the view target, which in combination with the scaling removes the need to dynamically change the orthographic camera height.

For all cameras, this scales the effective far and near plane distances. Perspective cameras are otherwise unaffected visually. 2D cameras left at the default position are not affected at all. The default height of orthographic cameras will need to be divided by their initial distance to the target to maintain the same appearance.

This is motivated by a combination perspective/orthographic camera I am developing, which would otherwise require both a FOV and height parameter and be dynamically rescaled similar to what is done for the current orthographic camera.

@asny
Copy link
Owner

asny commented Nov 13, 2024

This looks really nice. I checked the three-d examples and it seems to work nicely if the zoom target is the same as the camera target, but didn't when the zoom target was different from the camera target (see the Mandelbrot example). I think I've fixed it, so I'm merging these changes.

@asny asny merged commit 2aa308f into asny:main Nov 13, 2024
4 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants