bevy_pancam
bevy_pancam copied to clipboard
Projection scale formula is incorrect
For scaling there is formula, which is incorrect:
proj.scale = (proj.scale * (1. + -scroll * 0.001)).max(cam.min_scale);
Lets zoom out and zoom in:
# scale = 1
# will make scale = 1.1
scale = 1 * (1 + 100 * 0.001)
# zoom in will make scale = 0.99
scale = 1.1 * (1 + -100 * 0.001)
Value drifts on zoom out, zoom in.
Lets look at scaling formula: new_scale = old_scale * scale_factor
In order to reverse zoom action you need to get old_scale
, which we can derive like:
old_scale = new_scale * 1/scale_factor
So scale factors should be scale_factor
and 1/scale_factor