|
@@ -52572,6 +52572,10 @@ var BABYLON;
|
|
|
this._speedRatio = 1;
|
|
|
this._weight = -1.0;
|
|
|
this.animationStarted = false;
|
|
|
+ /**
|
|
|
+ * Observer raised when the animation ends
|
|
|
+ */
|
|
|
+ this.onAnimationEndObservable = new BABYLON.Observable();
|
|
|
this._scene = scene;
|
|
|
if (animations) {
|
|
|
this.appendAnimations(target, animations);
|
|
@@ -52730,6 +52734,12 @@ var BABYLON;
|
|
|
Animatable.prototype.restart = function () {
|
|
|
this._paused = false;
|
|
|
};
|
|
|
+ Animatable.prototype._raiseOnAnimationEnd = function () {
|
|
|
+ if (this.onAnimationEnd) {
|
|
|
+ this.onAnimationEnd();
|
|
|
+ }
|
|
|
+ this.onAnimationEndObservable.notifyObservers(this);
|
|
|
+ };
|
|
|
Animatable.prototype.stop = function (animationName) {
|
|
|
if (animationName) {
|
|
|
var idx = this._scene._activeAnimatables.indexOf(this);
|
|
@@ -52744,9 +52754,7 @@ var BABYLON;
|
|
|
}
|
|
|
if (runtimeAnimations.length == 0) {
|
|
|
this._scene._activeAnimatables.splice(idx, 1);
|
|
|
- if (this.onAnimationEnd) {
|
|
|
- this.onAnimationEnd();
|
|
|
- }
|
|
|
+ this._raiseOnAnimationEnd();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -52758,12 +52766,19 @@ var BABYLON;
|
|
|
for (var index = 0; index < runtimeAnimations.length; index++) {
|
|
|
runtimeAnimations[index].dispose();
|
|
|
}
|
|
|
- if (this.onAnimationEnd) {
|
|
|
- this.onAnimationEnd();
|
|
|
- }
|
|
|
+ this._raiseOnAnimationEnd();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ Animatable.prototype.waitAsync = function () {
|
|
|
+ var _this = this;
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ _this.onAnimationEndObservable.add(function () {
|
|
|
+ resolve(_this);
|
|
|
+ }, undefined, undefined, _this, true);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /** @hidden */
|
|
|
Animatable.prototype._animate = function (delay) {
|
|
|
if (this._paused) {
|
|
|
this.animationStarted = false;
|
|
@@ -52802,8 +52817,8 @@ var BABYLON;
|
|
|
runtimeAnimations[index].dispose();
|
|
|
}
|
|
|
}
|
|
|
- if (!running && this.onAnimationEnd) {
|
|
|
- this.onAnimationEnd();
|
|
|
+ if (!running) {
|
|
|
+ this._raiseOnAnimationEnd();
|
|
|
this.onAnimationEnd = null;
|
|
|
}
|
|
|
return running;
|