首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >空闲动画摄影机Aframe

空闲动画摄影机Aframe
EN

Stack Overflow用户
提问于 2018-06-07 16:24:37
回答 1查看 202关注 0票数 0

我使用的是aframe 0.8.2,并且我正在尝试添加一个相机空闲动画(仅用于旋转组件)。到目前为止,我已经这样做了:

HTML:

代码语言:javascript
复制
<!-- Camera-->
<a-entity id = "my_c" position="8.435 0 -3.579" > <a-camera></a-camera></a-entity>

Javascript:

代码语言: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
    }

问题是,我认为我的相机没有上传它的位置和旋转:当我旋转相机时,相机空闲动画不是从相同的位置开始的。

感谢您的支持:)

EN

回答 1

Stack Overflow用户

发布于 2018-06-07 18:35:04

您可以以不同的方式处理fromto属性:

代码语言:javascript
复制
...
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实体。在这里,我不确定您是否可以在动画开始时中断它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50736337

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档