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

add camera.set_position to TrackballCamera #166

Merged

Conversation

chrishavlin
Copy link
Contributor

This adds a camera.set_position function so that the view_matrix will get updated when setting a position.

here's the result of the additional image i added to examples/amr_osmesa.py

step3_set_position

@chrishavlin chrishavlin linked an issue Dec 11, 2024 that may be closed by this pull request
@chrishavlin chrishavlin marked this pull request as draft December 11, 2024 16:15
@chrishavlin
Copy link
Contributor Author

drafting because looking at the base camera, looks like there was already some architecture for this, just not implemented fully?

@traitlets.observe(
"position",
"focus",
"up",
"fov",
"near_plane",
"far_plane",
"aspect_ratio",
"orientation",
)
def compute_matrices(self, change=None):
"""Regenerate all position, view and projection matrices of the camera."""
with self.hold_traits(self._compute_matrices):
pass

will see if it's a quick thing, cause i'd prefer to do thsi with traitlets.

@chrishavlin chrishavlin force-pushed the add_set_position_camera_func branch from 2b5be54 to 7371831 Compare December 11, 2024 19:22
@chrishavlin chrishavlin marked this pull request as ready for review December 11, 2024 19:22
@chrishavlin
Copy link
Contributor Author

chrishavlin commented Dec 11, 2024

well getting this to work with traitlets has proven more confusing that I thought it would be... I think maybe the camera objects could use a bit of refactoring? so I'm undrafting this with the new function rather than getting traitlets to work, but @matthewturk if you have any ideas, definitely let me know.

@matthewturk
Copy link
Member

I think it absolutely could use some refactoring. I think that we probably want to get to a point where the state is stored in one place (like the view matrix) and then the others are backed out of it or something. But I'm not 100% sure.

@chrishavlin
Copy link
Contributor Author

ya, that makes sense. i was getting confused about the possible dependencies and order of operations -- e.g., if you update the orientation in the trackball you need to re-calculate the position, but if you set the position you would need to update the orientation (and other matrices). so having a single state object of some kind would make a lot of sense.

you think it's OK to merge this one in the meantime though? It'd help with the tests I'm adding in #159

@matthewturk
Copy link
Member

I trust your judgment, yup!

@chrishavlin chrishavlin merged commit 709b216 into yt-project:main Dec 13, 2024
6 checks passed
@chrishavlin chrishavlin deleted the add_set_position_camera_func branch December 13, 2024 18:00
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.

updating camera position in osmesa?
2 participants