0
votes

I am having problems regarding the switching of two viewpoints.

Whenever I move from viewpoint1 to viewpoint2 the rotation when I arrive at viewpoint2 seems off.

At first I wanted to switch viewpoints and this would involve setting the camera position. This doesn't seem possible so I had to wrap the camera with a container like so:

 <a-entity><a-camera></a-camera></a-entity>

And then use .setAttribute('position', xyz); on the a-entity tag (I know the object3d approach is favorable, I still need to refactor this).

Now when I look from viewpoint1 to viewpoint2 (we call this movement deltaRotation) and switch viewpoints I change the rotation of the entity to my preferred point of view, lets say 0, 45, 0.

What I expect is that I end up at viewpoint2 with the camera looking at 0, 45, 0. The camera however seems to be looking at 0, 45, 0 + deltaRotation.

Is this the way I am supposed to be switching viewpoints? If so is this "tank" model way of working intended? Or should I take another approach.

1

1 Answers

0
votes

What's happening is when you move the camera around with the default look-controls, it's changing the rotation attribute of the camera within the "camera rig" wrapper entity. So, when you change the rotation of the entity, the end result is the camera will be looking in a direction that is the sum of the rotations of the camera and the camera rig.

Unfortunately I'm not sure how to work around this because setting or animating the rotation of the main camera directly simply doesn't work. So, scripting the perspective of the first-person camera is something a-frame isn't equipped to handle in its current state. Reverting to an earlier version of a-frame may be your best option.