0

I was puzzled with resetting camera rotation, I wrote a simple component to reset camera rotation, the code is published at aframe demo

I add 'click' event listener to the blue box, if the box was clicked. then, i would reset camera rotation to {x:0,y:0,z:0}. but, as you see, there is no effects. I step in to my component and i found my code did work, but something set the rotation back after my function.

I have tried:

  1. use look-controls instead of universal-control. in this way, it works on the PC browser but my mobile phone.
  2. use a newer aframe-extras lib, v3.1.0. and I got an error 'Cannot read property x of undefined' at aframe-extras.js:5265.

Anyone hints?

Craig.Li
  • 1,336
  • 10
  • 17

1 Answers1

0

You could try using a wrapper entity around the camera and modifying that. Or if that doesn't work...

Since the controls continually update the camera rotation on each frame, any rotations you set may be overwritten by the camera controls. You could perhaps try pausing the camera (el.pause()), setting the rotation (el.setAttribute), and resuming the camera (el.play()), but no guarantees that will work.

If it doesn't, you could maybe fork any control implementations and add some sort of logic to allow you to manually update the rotation.

ngokevin
  • 12,980
  • 2
  • 38
  • 84