How to move, rotate & zoom trackball control in three js using keyboard or button click

687 Views Asked by At

Is it possible to use keyboard to control the trackball actions such as zoom , rotate. There are various SO question & answers are there by most are based on orbital control, but not for track ball.

example provided here having some keyboard events but these are not working trackball control threejs

1

There are 1 best solutions below

0
Alex Melluzzo On

If you're using threejs, I think you might be able to set up an eventListener on the keyboard, and basically say "when shift and UP are pressed, increment the camera.position.z+10".

Here's a little code to get you started. It listens to the keyboard, console logs what key it was, and moves the camera along the Z access by 10:

    function setupKeyLogger() {
        document.onkeydown = function (e) {
            console.log(e);
            camera.position.z+10
        }
    }