闲置动画相机Aframe

时间:2018-06-07 08:24:37

标签: javascript html aframe

我正在使用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
    }

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

感谢您的支持:)

2 个答案:

答案 0 :(得分:0)

您可以区别对待class RepairForm(forms.ModelForm): class Meta: model = Repair exclude = ( "repair_cost_estimate","repair_status","submitted_by","repair_request_date",) from属性:

to

<小时/> 有点offtop,但... let initCamRotation = camera.getAttribute("rotation") let endCamRotation = initCameraRotation endCamRotation.y += 360 anime_1.setAttribute("from", initCamRotation); anime_1.setAttribute("to", endCamRotation); .... 动画可以在给定pauseEvents时暂停,我尝试使用它而不是a-animation实体。在这里我不确定你是否可以在动画开始时中断动画。

答案 1 :(得分:0)

更新了问题:

 var scene = document.getElementById("my_s");
 var camera = document.getElementById("my_c"); 
 var pause = false;
    /* Add a time of "not moving" */

        var t;
        window.onload = resetTimer;
        // DOM Events
        document.onkeypress = resetTimer;
        document.onmousedown = resetTimer;
       // var currentEvent= 'rotation-begin' ;
        function standby() {
            camera.setAttribute("animation","property : rotation");
            camera.setAttribute("animation","loop: true");
            camera.setAttribute("animation","dur : 30000");
            camera.setAttribute("animation","easing:linear");
            camera.setAttribute("animation","pauseEvents: rotation-pause");
            camera.setAttribute("animation","resumeEvents: rotation-resume");

            camera.setAttribute("animation","to: 0 540 0");
           // currentEvent = 'rotation-resume';

        }

        function resetTimer() {
        clearTimeout(t);           
        if (pause == false){
            t = setTimeout(standby, 3000);
            console.log(pause);
        }
        if (pause == true){
            t = setTimeout(camera.emit("rotation-resume"), 3000);
            console.log(pause);
    }


        camera.emit("rotation-pause");
        pause = true;

动画开始,pauseEvents正常工作但是,我无法恢复动画。