在 A-Frame 场景中调整灵敏度

Adjusting sensitivity in A-Frame scene

当我在场景上单击并拖动鼠标时,需要两个全屏宽度才能进行 360 度旋转。

是否可以调整A-Frame场景的灵敏度?

如果有人好奇,这是我正在使用的html:

<!DOCTYPE html>


<html>
<head>
    <title>test</title>
    <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
</head>


<body>
    <a-scene vr-mode-ui="enabled: false">
        <a-assets>
            <img id="image" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/sechelt.jpg">
        </a-assets>

        <a-sky id="image-360" radius="10" src="#image"></a-sky>
    </a-scene>
</body>
</html>
<script type="text/javascript">
    AFRAME.registerComponent('drag-rotate-component',{
      schema : { speed : {default:1}},
      init : function(){
        this.ifMouseDown = false;
        this.x_cord = 0;
        this.y_cord = 0;
        document.addEventListener('mousedown',this.OnDocumentMouseDown.bind(this));
        document.addEventListener('mouseup',this.OnDocumentMouseUp.bind(this));
        document.addEventListener('mousemove',this.OnDocumentMouseMove.bind(this));
      },
      OnDocumentMouseDown : function(event){
        this.ifMouseDown = true;
        this.x_cord = event.clientX;
        this.y_cord = event.clientY;
      },
      OnDocumentMouseUp : function(){
        this.ifMouseDown = false;
      },
      OnDocumentMouseMove : function(event)
      {
        if(this.ifMouseDown)
        {
          var temp_x = event.clientX-this.x_cord;
          var temp_y = event.clientY-this.y_cord;
          if(Math.abs(temp_y)<Math.abs(temp_x))
          {
            this.el.object3D.rotateY(temp_x*this.data.speed/100);
          }
          else
          {
            this.el.object3D.rotateX(temp_y*this.data.speed/100);
          }
          this.x_cord = event.clientX;
          this.y_cord = event.clientY;
        }
      }
    });
  </script>

可以调整速度,在天空正上方添加camera分量

<a-entity camera drag-rotate-component></a-entity>

Demo

您只需要Y定义的

我制作了一个 fork of aframe,其中包括 look-controls

的 X 和 Y 鼠标灵敏度