superframe
superframe copied to clipboard
Can not set camera position with disabled look-controls
Hello!
We want to animate a camera entity around a target position, but it only works when we enable the look-control component which resullts in a weird camera behaviour. So we need to disable them in non-VR mode.
Our camera looks like:
<a-camera zoom="1" target="#camera-target" id="cam" look-controls="enabled:false;" orbit-controls="initialPosition:0 4 0; enabled: true; enablePan: true; enableDamping: true; minDistance: 0.5; maxDistance: 15.5; rotateSpeed: 0.25; zoomSpeed:1.5;" animation="property: position; dur: 1500; easing: easeInOutQuad; startEvents: returnhome; pauseEvents: stop"></a-camera>
And we try to animate it with:
var cameraInstance = document.querySelector("a-camera").getObject3D('camera');
let cam = document.getElementById('cam');
let cameraInstancePosition = new THREE.Vector3();
cameraInstancePosition.copy(cameraInstance.position);
cam.setAttribute('animation', 'from', cameraInstancePosition.x + ' ' + cameraInstancePosition.y + ' ' + cameraInstancePosition.z);
cam.setAttribute('animation', 'to', relativeCameraPosition.x + ' ' + relativeCameraPosition.y + ' ' + relativeCameraPosition.z);
cam.emit('returnhome');
The animation gets triggered but the camera position does not update. We tried different combinations : using camera component instead of <a-camera>
, setting the target attribute in orbit controls, calling updateMatrixWorld()
and getWorldPosition()
disable the orbit-controls while moving the camera, none of them worked.
BUT it works when we enable the "look-controls" component before the animation and disable it again when the animation finished which results in a weird camera behaviour afterwards.
We are using A-Frame 0.9.0 and your orbit-controls of https://unpkg.com/[email protected]/dist/aframe-orbit-controls.min.js
Do you have some suggestions what we can do? Thanks in advance!
following i need that too