Vickey
Vickey

Reputation: 373

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

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

Upvotes: -1

Views: 734

Answers (1)

Alex Melluzzo
Alex Melluzzo

Reputation: 73

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
        }
    }

Upvotes: 0

Related Questions