简体   繁体   English

如何使用键盘或按钮单击在三个js中移动,旋转和缩放轨迹球控件

[英]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. 有各种各样的SO问题和答案,大多数都是基于轨道控制的,而不是针对轨迹球的。

example provided here having some keyboard events but these are not working trackball control threejs 此处提供的示例具有一些键盘事件,但这些按钮无法正常工作轨迹球控件threejs

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". 如果您正在使用threejs,我认为您也许可以在键盘上设置一个eventListener,并且基本上说“当按下shift和UP时,增加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: 它监听键盘,控制台记录它是什么键,然后将摄像机沿Z通道移动10:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM