I’m trying to find a solution to both move and zoom an orthographic camera.
A solution in Zoom where move cursor is in orthographic mode suggests using orthoLeft
, orthoRight
, orthoTop
and orthoBottom
to achieve both zooming and camera movement while zooming.
However that solution still relies on the builtin behavior of the camera to achieve panning, which changes the target
of a camera. That results in a strange situation where camera location is defined by a combination of ortho*
properties and target
. For example, you can end up in a situation where camera target is at 5,0,0
and orthoLeft = 10
, orthoRight = 20
, which means:
- the camera is actually centered at
20,0,0
, - not at
5,0,0
where it would be if you would look attarget
alone, and - not at
15,0,0
where it would be if you only looked at theortho*
properties alone.
The software engineer in me says that continuing with this approach will cause even more mess and confusion in the future, so I think I should find a better approach.
To eliminate this mismatch I tried to implement camera panning using the just the ortho*
properties:
This almost works, but some sort of shaking occurs, which gets worse and worse as you keep panning for longer and longer.
Alternatively I’m open to moving the camera by changing its target
(which might be the more correct approach), but then I’d need a different implementation of the zooming functionality. I’ve tried to implement it as a combination of ortho*
and target
, but didn’t manage to make it work.