1
votes

When I click and drag my mouse across a scene, it takes two full screen widths to make a 360 degree turn.

Is it possible to adjust the sensitivity of an A-Frame scene?

In case anyone was curious, this is the html I am using:

<!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>
2
the sensitivity is set to the head rotation. You don't click and drag inside VR in regards to the backgroundGrasper
A-Frame allows for click and drag rotation with the mouse, I understand it is meant for VR, but if the user does not have a device capable of detecting movement, such as a pc, I would still like them to be able to move around quicklyGabe Willson

2 Answers

1
votes
<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>

Source you can adjust the speed, and add the camera component right above the sky

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

Demo

You will only need the Y defined

0
votes

I made a fork of aframe that includes X and Y mouse sensitivity for look-controls