3
votes

Prior to Aframe 0.8, you could give a camera an initial rotation. Now you can't, and instead you are encouraged to set up a camera rig (outer a-entity) and give that the position and rotation. The problem with this is now your movement and rotation orientation is the wrong plane. You no longer move along the scene's floor, but a floor based on the camera's new rotation. In Aframe 0.7, your camera's initial rotation didn't affect your movement plane.

Link to more info of the decision: https://github.com/aframevr/aframe/issues/3462

Working: https://glitch.com/~aframe-0-7-camera-rotation

  <a-camera position="3 -2 0" rotation="30 45 0"></a-camera>

Not working: https://glitch.com/~aframe-0-8-camera-rotation

  <a-entity position="3 -2 0" rotation="30 45 0">
    <a-camera></a-camera>
  </a-entity>

(press forward in both and see the different movement plane)

What is the appropriate way to get the same behavior as before?

1

1 Answers

2
votes

This may be hacky, but it seems to be working:

When on PC - the look controls (build into the camera primitive) rotate the camera based on two objects: yawObject and pitchObject. Source code fragment here.

If you try to set the rotation values for those objects - it seems to be working without any harm (restraining the camera in any way).

var el = document.querySelector("a-camera")
el.components["look-controls"].pitchObject.rotation.x = 0.7
el.components["look-controls"].yawObject.rotation.y = 0.8

Check it out in my fiddle