aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.67k stars 3.97k forks source link

Look controls only working horizontally on touchscreen #4957

Open a0m0rajab opened 2 years ago

a0m0rajab commented 2 years ago

Description:

The look controls only working horizontally on touch screen, is this a feature or a bug?

a0m0rajab commented 2 years ago

Here is the related code: https://github.com/aframevr/aframe/blob/dbe90665c8b5936818cc0157285217015f02009e/src/components/look-controls.js#L351

dmarcos commented 2 years ago

Thanks. this is a design decision https://github.com/aframevr/aframe/issues/4190

a0m0rajab commented 2 years ago

That's totally understandable,

What about putting a flag to activate the rotation? so that we can let the user decide if they would activate it or not! if you like that, I would edit the PR for this.

there is good example for this issue btw, which is used at 3Dvista https://www.kadirgasanat.com/sanaltur/ethem/

it's less sensitive to the gyroscope movements and always centralize the camera for the view.

Platform-Group commented 1 year ago

Stolen from stack overflow:

      AFRAME.components["look-controls"].Component.prototype.onTouchMove = function (t) {
        console.log('on touch move event!')
          if (this.touchStarted && this.data.touchEnabled) {
              this.pitchObject.rotation.x += .6 * Math.PI * (t.touches[0].pageY - this.touchStart.y) / this.el.sceneEl.canvas.clientHeight;
              this.yawObject.rotation.y += /*  */ Math.PI * (t.touches[0].pageX - this.touchStart.x) / this.el.sceneEl.canvas.clientWidth;
              this.pitchObject.rotation.x = Math.max(Math.PI / -2, Math.min(Math.PI / 2, this.pitchObject.rotation.x));
              this.touchStart = {
                  x: t.touches[0].pageX,
                  y: t.touches[0].pageY
              }
          }
      }