【发布时间】:2018-06-10 07:38:18
【问题描述】:
我正在使用 aframe 0.8.2,并且正在尝试添加相机空闲动画(仅适用于旋转组件)。到目前为止我已经做到了:
HTML:
<!-- Camera-->
<a-entity id = "my_c" position="8.435 0 -3.579" > <a-camera></a-camera></a-entity>
Javascript:
var scene = document.getElementById("my_s");
var camera = document.getElementById("my_c");
var anime_1 = document.createElement("a-animation");
/* Add a time of "not moving" */
var t;
window.onload = resetTimer;
// DOM Events
document.onkeypress = resetTimer;
document.onmousedown = resetTimer;
function standby() {
console.log("Start standby.");
anime_1.setAttribute("attribute","rotation");
console.log(camera.getAttribute("rotation"));
anime_1.setAttribute("dur", "80000");
anime_1.setAttribute("to", "0 360 0");
anime_1.setAttribute("easing", "linear");
anime_1.setAttribute("repeat", "indefinite");
camera.appendChild(anime_1);
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(standby, 3000);
camera.removeChild(anime_1);
// 1000 milisec = 1 sec
}
问题是,我认为我的相机没有上传它的位置和旋转:当我旋转我的相机时,相机空闲动画不会在同一位置开始。
感谢您的支持:)
【问题讨论】:
标签: javascript html aframe