Camera Scripts project

Hi everyone,

I did a little study of the playcanvas editor camera code, and derived my own camera handling scripts.

I have prepared 5 scripts that can be applied to a camera type object: flyCamera (allows you to move around the scene using the WASD keys or the arrow keys + RF or page up / down to move up and down); lookCamera (allows you to look around by clicking with the left mouse button); orbitCamera (allows you to rotate the view around the center of the scene by clicking with the left mouse button together with the Shift key); panCamera (allows you to move the view up / down / left / right by clicking with the left mouse button together with the Control key); zoomCamera (allows you to zoom in / out to the position of the mouse pointer by rotating the mouse wheel).

While these scripts largely cover my needs, I’d like to finish the job to make them available to everyone … but unfortunately I don’t have the math skills to finish.

To be complete, the handling of the camera roll (which I thought of inserting in the lookCamera script, by pressing the E and Q keys to roll clockwise and counterclockwise) and all the analogous part relating to the handling of the orthographic perspective would be missing.

If someone wanted to try their hand at completing what is missing it would be fantastic and I think it is also useful to many.

The project can be found here: PlayCanvas 3D HTML5 Game Engine

Thank you all for your attention and for any help

1 Like

We have similar camera scripts here that may help: https://github.com/playcanvas/engine/tree/dev/scripts/camera

Not sure how roll would work or be useful except for flyCamera in a Descent game style?

1 Like

Yes, I had already seen the scripts in the engine … but for me they were too complex … the ones in the project are a simplification of the ones in the editor …

At the moment the scripts in the project move the camera forward, backward, up, down, left and right, approach and move away, steer left and right … but they always remain parallel to the floor (or in any case with a pitch angle) … . it would also be useful to have a roll movement (yes, as in descent), to have more freedom of movement … but I don’t know how to add the roll management … unfortunately I have no mathematical basis :weary:

1 Like

You can’t achieve this by just rotating one of the three axes?

1 Like

no, because the rotation would take place around the real axis, while instead it must take place in the current view (which can be oriented in any direction and in any angle) … it is the same that applies to the pitch and the yaw

1 Like

If you rotate the y-axis of the camera entity itself?

1 Like