Due to the fact that look-controls overrides the rotation component on the camera, direct setting or animating of rotation is not possible.
An alternative solution would involve disabling look controls (or removing it), then executing the animation on rotation. Once the animation is complete, re-enable (or add back) the look-controls component.
Another approach is to utilize THREEjs camera control for setting and animating the camera's rotation. The Animation component solely functions with other component properties. Hence, you'll need to create a custom component, animate a schema property within that component, and in the update() method inside the component, adjust the threejs rotation of the camera based on the schema property.
AFRAME.registerComponent('camcontrol',{
schema: {
rot: { type: 'vec3'} ,
animactive: { type: 'boolean', default: false } },
init: function(){
// Initialize component here
},
update: function(){
// Update component logic here
},
lookAnimation: function(pos){
// Method for handling camera look animation
}
});
<a-scene>
<a-entity id="button1" geometry="primitive: box" position="1 0 -5" class="clickable" material="color: tomato" button3d></a-entity>
<a-entity id="button2" geometry="primitive: octahedron; radius: 0.2" position="-4 0 -3" class="clickable" material="color: #4466BB" button3d></a-entity>
<a-entity id="button3" geometry="primitive: sphere; radius: 0.2" position="2 0 -2" class="clickable" material="color: green" button3d></a-entity>
<a-entity id="button4" geometry="primitive: cone; radius: 0.2" position="-3 0 -8" class="clickable" material="color: purple" button3d></a-entity>
<a-entity id="button5" geometry="primitive: icosahedron; radius: 0.2" position="0 0 0" class="clickable" material="color: blue" button3d></a-entity>
<a-sky color="#bbddff"></a-sky>
<a-entity id="camrig" position="0 0 0" ></a-entity>
<a-entity id="camera" position="0 0 0" fov="100" camera look-controls camcontrol
animation__look="property: camcontrol.rot; startEvents: camlook; dur:500"></a-entity>
</a-entity>
<a-entity id="mouseCursor" cursor="rayOrigin: mouse" raycaster="objects: .clickable"></a-entity>
</a-scene>
Explore the glitch here