Closed ExpertOfNil closed 2 months ago
Hi there. This is expected behaviour. bevy_panorbit_camera has its own state that describes the camera transform (focus, radius, yaw, and pitch). If you change the camera transform directly, then those changes will be overridden the next time bevy_panorbit_camera updates it.
In other words, this plugin 'takes over' the camera transform. If you want to programmatically alter it, you have to modify the plugin state, rather than the transform itself.
That said, there might be a solution. If you set PanOrbitCamera.initialized
to false
whenever you update the transform directly, then the plugin should recalculate its state based on the new transform. Give that a try and let me know if it works.
@Plonq I tried setting PanOrbitCamera.initialized = false
directly before and/or directly after changing the camera transform, but this resulted in my bevy_egui
interface being unresponsive.
After some trial and error, it seems like I may have to store and augment the PanOrbitCamera
transform, as you said previously.
I'll keep working at this and see if I can come up with a solution. Thank you for your help!
Hmm, PanOrbitCamera probably interferes with the egui stuff on initialisation.
Another idea is to modify focus, radius, yaw, and pitch directly, but calculate them based on a transform. For example, this function calculates radius, yaw, and pitch based on a given translation and focus. It's not public but you could copy paste it.
Hmm, PanOrbitCamera probably interferes with the egui stuff on initialisation.
Another idea is to modify focus, radius, yaw, and pitch directly, but calculate them based on a transform. For example, this function calculates radius, yaw, and pitch based on a given translation and focus. It's not public but you could copy paste it.
This is fantastic. I was just headed down that road, so thank you for saving me the effort! I'll report back after I integrate this and do some testing.
@Plonq modifying the focus, radius, yaw and pitch directly worked well with the aid of the linked function. Thank you for your help!
Glad you found a solution
I am attempting to use a
bevy_egui
window to explicitly set my camera position. The camera positions update with changes made within thebevy_egui
window, but once thePanOrbitCamera
makes a change, the camera transform reverts back to the position and rotation it had whenbevy_egui
got focus.https://github.com/user-attachments/assets/839480be-ac7b-40d8-8809-0a561cca2362