Quesionts about cameras

Hi,

I’d like to ask some questions on camera control/inputs.

FreeCamera position and direction
If I use following code on FreeCamera:
window.onkeydown = (e) => { if (e.key === "a") {freeCamera.position.x += 1}};
I see the view port “jumps” along x-axis by 1 unit when key “A” is pressed down;

If I change “position” to “cameraDirection”:
window.onkeydown = (e) => { if (e.key === "a") {freeCamera.cameraDirection.x += 1}};
Instead of “jump”, the view port moves smoothly along x-axis by roughly 10 units every time “A” is pressed.

(1) Why 10 units? I thought it was camera speed, but it actually makes no difference if I change the speed.
(2) How is that smooth transition achieved? How can I apply the smoothness when changing camera position (instead of “jumping”) ?

ArcRotateCamera
(1) The code above doesn’t work on ArctRotateCamera, neither camera.position nor camera.cameraDirection, why is that?
(2) ArcRotateCameraKeyboardMoveInput provides rotation control using keyUp, keyDown etc. and ArcRotateCameraPointersInput provides panning control using mouse buttons, what if I want to use keyboard for panning? I don’t see there is a way to assign keys to panning functionality through customizing inputs. If there is a way, could someone give a example please?

Many thanks!

Because of inertia. try to set camera.inertia to 0

(2) How is that smooth transition achieved? How can I apply the smoothness when changing camera position (instead of “jumping”) ?

Thanks to inertia :slight_smile: On every frame, the cameraDirection is multiplied by inertia so it does not “jump” from a value to 0

Because ArcRotateCamera is controlled through alpha, beta and radius properties.

There is a way but you will have to provide your own input controller: https://doc.babylonjs.com/how_to/customizing_camera_inputs

Thank you very much!