我使用的是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
}
问题是,我认为我的相机没有上传它的位置和旋转:当我旋转相机时,相机空闲动画不是从相同的位置开始的。
感谢您的支持:)
发布于 2018-06-07 18:35:04
您可以以不同的方式处理from
和to
属性:
...
let initCamRotation = camera.getAttribute("rotation")
let endCamRotation = initCameraRotation
endCamRotation.y += 360
anime_1.setAttribute("from", initCamRotation);
anime_1.setAttribute("to", endCamRotation);
....
有点偏离顶部,但当给定pauseEvents
时,animation component的动画可能会暂停,我会尝试使用它而不是a-animation
实体。在这里,我不确定您是否可以在动画开始时中断它。
https://stackoverflow.com/questions/50736337
复制相似问题