我很确定这在Aframe的早期版本中有效,但不能确定。但是,当我尝试使用:
为组件上的位置设置动画时,我收到一个奇怪的错误const positionAnimation = {
property: 'position',
from: this._threeElement.position,
to: (reversed) ? this._initialPosition : this._targetPosition,
dur: 2000,
round: false,
easing: 'easeInOutCubic',
startEvents: ['---non-existent-event---'], //Avoid auto-play of the animation
}
//Set the animation on the element
this.el.setAttribute('animation__position', positionAnimation)
它似乎与position属性有关(如果我删除了这个没有错误,但它没有动画)
Uncaught TypeError: Cannot read property 'x' of undefined
at round (aframe-master.js:8445)
at I (anime.min.js:13)
at ba (anime.min.js:18)
at anime.min.js:19
at Array.map (<anonymous>)
at da (anime.min.js:19)
at anime.min.js:20
at Array.map (<anonymous>)
at anime.min.js:20
at Array.map (<anonymous>)
at ea (anime.min.js:20)
at fa (anime.min.js:21)
at q (anime.min.js:24)
at NewComponent.createAndStartAnimation (index.js:164)
at NewComponent.update (index.js:122)
at NewComponent.updateProperties (aframe-master.js:72452)
at NewComponent.module.exports.Component (aframe-master.js:72222)
at new NewComponent (aframe-master.js:72646)
at HTMLElement.value (aframe-master.js:71059)
at HTMLElement.value (aframe-master.js:71215)
at HTMLElement.value (aframe-master.js:71386)
at NewComponent.tweenHotspotToCamera (zoom-front-camera.js:127)
编辑问题是在'to'属性中(如果删除它我没有错误但没有动画)
那里有数据
from:Vector3
x:8.743012486033315
y:1.7184335476624883
z:-5.017845407952605
__proto__
:
Object
property
:
"position"
startEvents
:
["---non-existent-event---"]
to
:
Vector3
x:8.26445236188911
y:0.33004119004908694
z:-11.007824476509064
这是动画组件v 4.2.0和Aframe 0.8.2
编辑 - 这在Aframe 0.5中起作用
看看这个小提琴 https://jsfiddle.net/qzox15w5/1/
这是按预期工作的,但是如果我升级AFRAME,我会收到之前提到的错误。
https://jsfiddle.net/jpvsrnq1/1/
我尝试过使用AFRAME.utils.clone Vector,但这会产生不良后果。