簡體   English   中英

A幀相機旋轉和移動動畫不考慮新數據

[英]A-Frame Camera rotation and movement animation not taking into account new data

我正在嘗試使相機移動並旋轉到js中動態指定的特定位置和旋轉。

但是,攝像機將從起始值旋轉到0 00。當數據顯示為其他值時。 旋轉立即完成,沒有動畫。 即使數據成功更改,位置也不會更改。

我正在使用aframe-animation-component。

// JS
var camera = document.getElementById('camera');

camera.components.animation__movecamera.data.from = camera.components.position.data;
camera.components.animation__rotatecamera.data.from = camera.components.rotation.data;

camera.components.animation__movecamera.data.to = (positions.x - positionX)+ ' ' + positions.y + ' ' + (positions.z + 10);
camera.components.animation__rotatecamera.data.to = rotations.x + ' ' + rotations.y + ' ' + rotations.z;

camera.emit('rotateCamera');
camera.emit('moveCamera');


// HTML
<a-camera id="camera"
    look-controls
    wasd-controls="acceleration:200"
    animation__rotateCamera="property: rotation; startEvents: rotateCamera;"
    animation__moveCamera="property: position; startEvents: moveCamera;"
>

謝謝您的幫助。

數據屬性不應直接訪問,它是組件的內部變量。 必須使用公共API:

el.setAttribute('animation__rotateCamera', { to: foo });

在文檔中有更多詳細信息:

https://aframe.io/docs/0.7.0/introduction/javascript-events-dom-apis.html#updating-a-component-with-setattribute

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM