freshfork / p5.EasyCam

A p5.js library for easy 3D camera control.
https://freshfork.github.io/p5.EasyCam
MIT License
138 stars 33 forks source link

Option to rotating camera around a global axis #7

Open BartaG512 opened 4 years ago

BartaG512 commented 4 years ago

I am trying to modify the camera behavior when i drag on the screen. Basically this is the same as my problem: https://gamedev.stackexchange.com/questions/136174/im-rotating-an-object-on-two-axes-so-why-does-it-keep-twisting-around-the-thir?noredirect=1&lq=1

Now the default behavior that is the rotations are applied relative to the camera coordinate system. I would like to apply yaw rotation around the global Y axis.

How this can be achieved? Animation

jwdunn1 commented 4 years ago

This type of global yaw rotation does not presently exist in EasyCam (or its predecessor) and would be considered a feature request. I'll leave this issue open if someone wishes to contribute this enhancement. For an existing solution, see SimpleCam.

jwdunn1 commented 1 year ago

Turns out there is a global yaw rotation constraint in EasyCam. This sketch demonstrates its use by calling setRotationConstraint(true,false,false) and rendering on the XY plane. CONTROLS: Left-click/touch rotates the scene. Mouse wheel, right-click, pinch/spread for zoom. Middle-click/two-touch drag to move the lookat point. Shift-middle-click and drag upward to move the lookat point along the Z-axis. Double-click or double-tap to reset the camera. Another option to constrain the yaw without using the method call, is simply pressing shift, then left-click mouse and drag left/right.