dolly
dolly copied to clipboard
Sequentially evaluating and replacing drivers
Hey! We're using dolly
and wanting to swap out camera drivers at runtime (specifically Rotation
and YawPitch
). There are no helpers to expose this in the public API, but since the drivers
Vec
is (perhaps unintentionally) pub
we can patch those in. Is that an intended use-case?
As an alternative approach we also looked into having both drivers on the stack so that we could set one of the two to IDENTITY
, but as it turns out dolly
doesn't really stack the drivers sequentially, instead the Position
/Rotation
/YawPitch
(and maybe all the other) drivers replace a translation or rotation on update()
, meaning only the last rotation
or position
sticks. This is also visible in the README
example, where a camera has a Rotation
(that is updated) but useless because the subsequent LookAt
overwrites the rotation.
Something I just had in mind (for my specific use-case) is a function that takes a generic A
and B
: it tries to find A
in the driver stack and if it finds it, it replaces it with a (default initialized or passed?) instance of B
and returns a (mutable) reference. If it finds B
instead, it immediately returns a reference to it.
Though that seems weirdly add-hoc and ugly, and it is perhaps cleaner to just have my A/B on the stack sequentially, while the rotations are multiplied in update()
, so that I can zero out one or the other.
Swapping of drivers at runtime is not something I've given any thought. When changing cameras in my apps, I'm just replacing the entire rig, and so far that has worked fine. That might not be sufficient for your use case, but in practical terms I won't have the resources to look into this myself :eyes: :sweat_smile: