I want to continuously move the view of my Aframe scene in the current viewing direction.
There seem to be two components to do this, (1) getting current viewing direction in correct format, (2) defining and updating a continuous animation with the current viewing direction of the camera.
I managed to get the camera's viewing direction using the following code:
<script>
AFRAME.registerComponent('listener', {
tick: function () {
var position = this.el.getAttribute('position');
var rotation = this.el.getAttribute('rotation');
}
});
</script>
How can I create an animation that moves in the camera's viewing direction, here for example with the current tilt?
I tried this for motion:
AFRAME.registerComponent('listener', {
tick: function () {
var camp = document.querySelector("#cameraWrapper");
camp.setAttribute('position', camp.getAttribute('position').add(0.1)););
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…