[英]A-frame fadeOut primitives
I've got a trouble with a-frame. 我遇到了镜架问题。 Is here way to remove a component or primitive from scene with delay?
这里是延迟删除场景中的组件或图元的方法吗? Like fadeOut in jQuery?
像jQuery中的fadeOut一样?
should I check every tick for opacity
CSS property or special className or smth like that? 我应该检查每个刻度以了解
opacity
CSS属性或特殊的className或类似的东西吗?
If I want to fadeOut a primitive from ng-repeat
, should I use ng-animate and check for .ng-leave
class? 如果我想从
ng-repeat
淡出基元,是否应该使用ng-animate并检查.ng-leave
类?
Ideally, I want to declare algorythm in remove()
function of my component or primitive. 理想情况下,我想在组件或基元的
remove()
函数中声明算法。 For example, if I return a Promise in remove() function, then remove Object3D
on promise resolve. 例如,如果我在remove()函数中返回一个Promise,则在promise resolve上删除
Object3D
。 But that's implemented not in this way, and I've got stuck :( 但这不是以这种方式实现的,我被卡住了:(
look example: http://codepen.io/Disorrder/pen/BWBKpb 看例子: http : //codepen.io/Disorrder/pen/BWBKpb
I may be confused, are you trying to remove it or just fade it out from view? 我可能会感到困惑,您是要删除它还是将其从视图中淡出? You may consider using the built-in
Animations
with A-Frame. 您可以考虑使用带有A帧的内置
Animations
。 Examples here: https://aframe.io/docs/0.5.0/core/animations.html#begin 此处的示例: https : //aframe.io/docs/0.5.0/core/animations.html#begin
This wouldn't remove it, but jQuery (per your second question) does not remove the element on fadeOut() . 这不会删除它,但是jQuery(第二个问题)不会删除fadeOut()上的元素。
http://codepen.io/jdoyle/pen/aJoVJj http://codepen.io/jdoyle/pen/aJoVJj
As far as I can tell, the opacity CSS property will have no effect on objects in the scene. 据我所知,opacity CSS属性不会对场景中的对象产生任何影响。 Because of this, I don't think you will be able to use
.ng-leave
. 因此,我认为您将无法使用
.ng-leave
。 The only way to animate the opacity is through the animation component, or programmatically. 动画不透明度的唯一方法是通过动画组件或以编程方式。
Using the $timeout
provider, and knowing the animation duration, you could set something up like this: 使用
$timeout
提供程序,并了解动画持续时间,您可以进行如下设置:
<a-box ng-repeat="box in page.getActiveBoxes() track by box.id"
ng-class="{animated: page.animate}"
position="{{box.position}}"
rotation="0 45 0"
width="0.6" height="1" depth="0.6"
color="{{box.color}}"
>
<a-animation attribute="opacity" begin="fadeOut" duration="5000" to="0"></a-animation>
</a-box>
fadeOut() {
var id = this.getRandomInt(0, this.boxes.length-1);
document.querySelector('#box-' + id).emit('fadeOut');
this.$timeout(function() {
// you can now delete the primitive
}, 5000 + 50); // added 50ms for good measure
}
getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
It is not the most elegant solution, but I can't really think of another way. 这不是最优雅的解决方案,但我真的想不出另一种方法。
Another disappointment, angular interpolation does not work for duration property of animation. 另一个令人失望的是,角度插值不适用于动画的持续时间属性。 Duration once set, cannot be changed.
持续时间一旦设置,就无法更改。 This will not work:
这将不起作用:
<a-animation attribute="opacity" duration="{{page.animationDuration}}" begin="fadeOut" to="0"></a-animation>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.