S
S
Sergei Zhilinski2017-12-11 16:58:04
JavaScript
Sergei Zhilinski, 2017-12-11 16:58:04

How to control the view by moving the mouse cursor?

Good afternoon, a question arose about changing the coordinates of the camera position in space.
So, what is there: there is a simple demo scene in the browser, where I can change the position of the camera and its angle.
I change the position by translating the camera matrix (a classic wasd-scheme taken from games), and I change the tilt angle by tilting to the x or y axis. I calculate the angle of inclination through the coordinates of the cursor on the screen.
This method is good if everything was not in the browser, because. problems arise in it:
1) Zero is considered to be the point where the cursor was at the time the page was loaded. This is the smallest problem that I can even imagine how to fix.
2) The rotation angle is limited by the screen border. Those. I bring the cursor to the border - and that's it, I can't turn any further.
Tell me, what else can I use to change the camera coordinate matrix so that the screen borders do not limit the rotation angle? It comes to my mind, I don’t know how to properly call this thing, but something like “increment of values ​​​​to the cursor coordinates that are sent by the mouse to the system”, but I have no idea how this is implemented and what I basically need to look for.
I implement on web-gl and java script.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Egor Padalka, 2017-12-11
@ehs

I think it is necessary to describe the "acceleration" of the mouse - if you move slowly - you will hit the edge, and if you pull quickly - you will scroll 360

A
Alexander Skusnov, 2017-12-11
@AlexSku

Often used:
left book. mouse - rotate along y (vertical axis),
right - rotate along x (tilts),
wheel - zoom (camera viewing angle. Usually 90 degrees)
keyboard: W - move forward, X - backward;
A - to the left, D - to the right (movements perpendicular to the gaze)
(wrote from memory)

S
shushpanio, 2017-12-12
@shushpanio

And what prevents you from changing the angle while holding the LMB?
For example, we hold LMB and move the cursor to the left, and the camera rotates with inversion (to the right).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question