|
@@ -27854,12 +27854,13 @@ var BABYLON;
|
|
* @param onAnimationEnd defines the function to be executed when the animation ends
|
|
* @param onAnimationEnd defines the function to be executed when the animation ends
|
|
* @param animatable defines an animatable object. If not provided a new one will be created from the given params
|
|
* @param animatable defines an animatable object. If not provided a new one will be created from the given params
|
|
* @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
|
|
* @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
|
|
|
|
+ * @param onAnimationLoop defines the callback to call when an animation loops
|
|
* @returns the animatable object created for this animation
|
|
* @returns the animatable object created for this animation
|
|
*/
|
|
*/
|
|
- Scene.prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask) {
|
|
|
|
|
|
+ Scene.prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
|
|
if (weight === void 0) { weight = 1.0; }
|
|
if (weight === void 0) { weight = 1.0; }
|
|
if (speedRatio === void 0) { speedRatio = 1.0; }
|
|
if (speedRatio === void 0) { speedRatio = 1.0; }
|
|
- var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask);
|
|
|
|
|
|
+ var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
|
|
returnedAnimatable.weight = weight;
|
|
returnedAnimatable.weight = weight;
|
|
return returnedAnimatable;
|
|
return returnedAnimatable;
|
|
};
|
|
};
|
|
@@ -27873,10 +27874,11 @@ var BABYLON;
|
|
* @param onAnimationEnd defines the function to be executed when the animation ends
|
|
* @param onAnimationEnd defines the function to be executed when the animation ends
|
|
* @param animatable defines an animatable object. If not provided a new one will be created from the given params
|
|
* @param animatable defines an animatable object. If not provided a new one will be created from the given params
|
|
* @param stopCurrent defines if the current animations must be stopped first (true by default)
|
|
* @param stopCurrent defines if the current animations must be stopped first (true by default)
|
|
- * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
|
|
|
|
|
|
+ * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
|
|
|
|
+ * @param onAnimationLoop defines the callback to call when an animation loops
|
|
* @returns the animatable object created for this animation
|
|
* @returns the animatable object created for this animation
|
|
*/
|
|
*/
|
|
- Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask) {
|
|
|
|
|
|
+ Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
|
|
if (speedRatio === void 0) { speedRatio = 1.0; }
|
|
if (speedRatio === void 0) { speedRatio = 1.0; }
|
|
if (stopCurrent === void 0) { stopCurrent = true; }
|
|
if (stopCurrent === void 0) { stopCurrent = true; }
|
|
if (from > to && speedRatio > 0) {
|
|
if (from > to && speedRatio > 0) {
|
|
@@ -27886,7 +27888,7 @@ var BABYLON;
|
|
this.stopAnimation(target, undefined, targetMask);
|
|
this.stopAnimation(target, undefined, targetMask);
|
|
}
|
|
}
|
|
if (!animatable) {
|
|
if (!animatable) {
|
|
- animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd);
|
|
|
|
|
|
+ animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
|
|
}
|
|
}
|
|
var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
|
|
var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
|
|
// Local animations
|
|
// Local animations
|
|
@@ -27897,7 +27899,7 @@ var BABYLON;
|
|
if (target.getAnimatables) {
|
|
if (target.getAnimatables) {
|
|
var animatables = target.getAnimatables();
|
|
var animatables = target.getAnimatables();
|
|
for (var index = 0; index < animatables.length; index++) {
|
|
for (var index = 0; index < animatables.length; index++) {
|
|
- this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask);
|
|
|
|
|
|
+ this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
animatable.reset();
|
|
animatable.reset();
|
|
@@ -27915,9 +27917,10 @@ var BABYLON;
|
|
* @param animatable defines an animatable object. If not provided a new one will be created from the given params
|
|
* @param animatable defines an animatable object. If not provided a new one will be created from the given params
|
|
* @param stopCurrent defines if the current animations must be stopped first (true by default)
|
|
* @param stopCurrent defines if the current animations must be stopped first (true by default)
|
|
* @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
|
|
* @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
|
|
|
|
+ * @param onAnimationLoop defines the callback to call when an animation loops
|
|
* @returns the list of created animatables
|
|
* @returns the list of created animatables
|
|
*/
|
|
*/
|
|
- Scene.prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask) {
|
|
|
|
|
|
+ Scene.prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
|
|
if (speedRatio === void 0) { speedRatio = 1.0; }
|
|
if (speedRatio === void 0) { speedRatio = 1.0; }
|
|
if (stopCurrent === void 0) { stopCurrent = true; }
|
|
if (stopCurrent === void 0) { stopCurrent = true; }
|
|
var children = target.getDescendants(directDescendantsOnly);
|
|
var children = target.getDescendants(directDescendantsOnly);
|
|
@@ -27938,13 +27941,14 @@ var BABYLON;
|
|
* @param loop defines if you want animation to loop (off by default)
|
|
* @param loop defines if you want animation to loop (off by default)
|
|
* @param speedRatio defines the speed ratio to apply to all animations
|
|
* @param speedRatio defines the speed ratio to apply to all animations
|
|
* @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
|
|
* @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
|
|
|
|
+ * @param onAnimationLoop defines the callback to call when an animation loops
|
|
* @returns the list of created animatables
|
|
* @returns the list of created animatables
|
|
*/
|
|
*/
|
|
- Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd) {
|
|
|
|
|
|
+ Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
|
|
if (speedRatio === undefined) {
|
|
if (speedRatio === undefined) {
|
|
speedRatio = 1.0;
|
|
speedRatio = 1.0;
|
|
}
|
|
}
|
|
- var animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations);
|
|
|
|
|
|
+ var animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
|
|
return animatable;
|
|
return animatable;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -27957,15 +27961,16 @@ var BABYLON;
|
|
* @param loop defines if you want animation to loop (off by default)
|
|
* @param loop defines if you want animation to loop (off by default)
|
|
* @param speedRatio defines the speed ratio to apply to all animations
|
|
* @param speedRatio defines the speed ratio to apply to all animations
|
|
* @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
|
|
* @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
|
|
|
|
+ * @param onAnimationLoop defines the callback to call when an animation loops
|
|
* @returns the list of animatables created for all nodes
|
|
* @returns the list of animatables created for all nodes
|
|
*/
|
|
*/
|
|
- Scene.prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd) {
|
|
|
|
|
|
+ Scene.prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
|
|
var children = target.getDescendants(directDescendantsOnly);
|
|
var children = target.getDescendants(directDescendantsOnly);
|
|
var result = [];
|
|
var result = [];
|
|
- result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd));
|
|
|
|
|
|
+ result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
|
|
for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
|
|
for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
|
|
var child = children_2[_i];
|
|
var child = children_2[_i];
|
|
- result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd));
|
|
|
|
|
|
+ result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
};
|
|
};
|
|
@@ -55208,10 +55213,14 @@ var BABYLON;
|
|
this._to = -Number.MAX_VALUE;
|
|
this._to = -Number.MAX_VALUE;
|
|
this._speedRatio = 1;
|
|
this._speedRatio = 1;
|
|
/**
|
|
/**
|
|
- * This observable will notify when one animation have ended.
|
|
|
|
|
|
+ * This observable will notify when one animation have ended
|
|
*/
|
|
*/
|
|
this.onAnimationEndObservable = new BABYLON.Observable();
|
|
this.onAnimationEndObservable = new BABYLON.Observable();
|
|
/**
|
|
/**
|
|
|
|
+ * Observer raised when one animation loops
|
|
|
|
+ */
|
|
|
|
+ this.onAnimationLoopObservable = new BABYLON.Observable();
|
|
|
|
+ /**
|
|
* This observable will notify when all animations have ended.
|
|
* This observable will notify when all animations have ended.
|
|
*/
|
|
*/
|
|
this.onAnimationGroupEndObservable = new BABYLON.Observable();
|
|
this.onAnimationGroupEndObservable = new BABYLON.Observable();
|
|
@@ -55398,6 +55407,9 @@ var BABYLON;
|
|
_this.onAnimationEndObservable.notifyObservers(targetedAnimation);
|
|
_this.onAnimationEndObservable.notifyObservers(targetedAnimation);
|
|
_this._checkAnimationGroupEnded(animatable);
|
|
_this._checkAnimationGroupEnded(animatable);
|
|
};
|
|
};
|
|
|
|
+ animatable.onAnimationLoop = function () {
|
|
|
|
+ _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
|
|
|
|
+ };
|
|
this_1._animatables.push(animatable);
|
|
this_1._animatables.push(animatable);
|
|
};
|
|
};
|
|
var this_1 = this;
|
|
var this_1 = this;
|
|
@@ -55549,6 +55561,11 @@ var BABYLON;
|
|
if (index > -1) {
|
|
if (index > -1) {
|
|
this._scene.animationGroups.splice(index, 1);
|
|
this._scene.animationGroups.splice(index, 1);
|
|
}
|
|
}
|
|
|
|
+ this.onAnimationEndObservable.clear();
|
|
|
|
+ this.onAnimationGroupEndObservable.clear();
|
|
|
|
+ this.onAnimationGroupPauseObservable.clear();
|
|
|
|
+ this.onAnimationGroupPlayObservable.clear();
|
|
|
|
+ this.onAnimationLoopObservable.clear();
|
|
};
|
|
};
|
|
AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
|
|
AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
|
|
// animatable should be taken out of the array
|
|
// animatable should be taken out of the array
|
|
@@ -55978,9 +55995,10 @@ var BABYLON;
|
|
* @param loop defines if the current animation must loop
|
|
* @param loop defines if the current animation must loop
|
|
* @param speedRatio defines the current speed ratio
|
|
* @param speedRatio defines the current speed ratio
|
|
* @param weight defines the weight of the animation (default is -1 so no weight)
|
|
* @param weight defines the weight of the animation (default is -1 so no weight)
|
|
|
|
+ * @param onLoop optional callback called when animation loops
|
|
* @returns a boolean indicating if the animation is running
|
|
* @returns a boolean indicating if the animation is running
|
|
*/
|
|
*/
|
|
- RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight) {
|
|
|
|
|
|
+ RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
|
|
if (weight === void 0) { weight = -1.0; }
|
|
if (weight === void 0) { weight = -1.0; }
|
|
var targetPropertyPath = this._animation.targetPropertyPath;
|
|
var targetPropertyPath = this._animation.targetPropertyPath;
|
|
if (!targetPropertyPath || targetPropertyPath.length < 1) {
|
|
if (!targetPropertyPath || targetPropertyPath.length < 1) {
|
|
@@ -56104,6 +56122,9 @@ var BABYLON;
|
|
var events = this._events;
|
|
var events = this._events;
|
|
if (range > 0 && this.currentFrame > currentFrame ||
|
|
if (range > 0 && this.currentFrame > currentFrame ||
|
|
range < 0 && this.currentFrame < currentFrame) {
|
|
range < 0 && this.currentFrame < currentFrame) {
|
|
|
|
+ if (onLoop) {
|
|
|
|
+ onLoop();
|
|
|
|
+ }
|
|
// Need to reset animation events
|
|
// Need to reset animation events
|
|
for (var index = 0; index < events.length; index++) {
|
|
for (var index = 0; index < events.length; index++) {
|
|
if (!events[index].onlyOnce) {
|
|
if (!events[index].onlyOnce) {
|
|
@@ -56161,6 +56182,7 @@ var BABYLON;
|
|
* @param speedRatio defines the factor to apply to animation speed (default is 1)
|
|
* @param speedRatio defines the factor to apply to animation speed (default is 1)
|
|
* @param onAnimationEnd defines a callback to call when animation ends if it is not looping
|
|
* @param onAnimationEnd defines a callback to call when animation ends if it is not looping
|
|
* @param animations defines a group of animation to add to the new Animatable
|
|
* @param animations defines a group of animation to add to the new Animatable
|
|
|
|
+ * @param onAnimationLoop defines a callback to call when animation loops
|
|
*/
|
|
*/
|
|
function Animatable(scene,
|
|
function Animatable(scene,
|
|
/** defines the target object */
|
|
/** defines the target object */
|
|
@@ -56172,7 +56194,9 @@ var BABYLON;
|
|
/** defines if the animation must loop (default is false) */
|
|
/** defines if the animation must loop (default is false) */
|
|
loopAnimation, speedRatio,
|
|
loopAnimation, speedRatio,
|
|
/** defines a callback to call when animation ends if it is not looping */
|
|
/** defines a callback to call when animation ends if it is not looping */
|
|
- onAnimationEnd, animations) {
|
|
|
|
|
|
+ onAnimationEnd, animations,
|
|
|
|
+ /** defines a callback to call when animation loops */
|
|
|
|
+ onAnimationLoop) {
|
|
if (fromFrame === void 0) { fromFrame = 0; }
|
|
if (fromFrame === void 0) { fromFrame = 0; }
|
|
if (toFrame === void 0) { toFrame = 100; }
|
|
if (toFrame === void 0) { toFrame = 100; }
|
|
if (loopAnimation === void 0) { loopAnimation = false; }
|
|
if (loopAnimation === void 0) { loopAnimation = false; }
|
|
@@ -56182,6 +56206,7 @@ var BABYLON;
|
|
this.toFrame = toFrame;
|
|
this.toFrame = toFrame;
|
|
this.loopAnimation = loopAnimation;
|
|
this.loopAnimation = loopAnimation;
|
|
this.onAnimationEnd = onAnimationEnd;
|
|
this.onAnimationEnd = onAnimationEnd;
|
|
|
|
+ this.onAnimationLoop = onAnimationLoop;
|
|
this._localDelayOffset = null;
|
|
this._localDelayOffset = null;
|
|
this._pausedDelay = null;
|
|
this._pausedDelay = null;
|
|
this._runtimeAnimations = new Array();
|
|
this._runtimeAnimations = new Array();
|
|
@@ -56201,6 +56226,10 @@ var BABYLON;
|
|
* Observer raised when the animation ends
|
|
* Observer raised when the animation ends
|
|
*/
|
|
*/
|
|
this.onAnimationEndObservable = new BABYLON.Observable();
|
|
this.onAnimationEndObservable = new BABYLON.Observable();
|
|
|
|
+ /**
|
|
|
|
+ * Observer raised when the animation loops
|
|
|
|
+ */
|
|
|
|
+ this.onAnimationLoopObservable = new BABYLON.Observable();
|
|
this._scene = scene;
|
|
this._scene = scene;
|
|
if (animations) {
|
|
if (animations) {
|
|
this.appendAnimations(target, animations);
|
|
this.appendAnimations(target, animations);
|
|
@@ -56459,6 +56488,7 @@ var BABYLON;
|
|
};
|
|
};
|
|
/** @hidden */
|
|
/** @hidden */
|
|
Animatable.prototype._animate = function (delay) {
|
|
Animatable.prototype._animate = function (delay) {
|
|
|
|
+ var _this = this;
|
|
if (this._paused) {
|
|
if (this._paused) {
|
|
this.animationStarted = false;
|
|
this.animationStarted = false;
|
|
if (this._pausedDelay === null) {
|
|
if (this._pausedDelay === null) {
|
|
@@ -56483,7 +56513,12 @@ var BABYLON;
|
|
var index;
|
|
var index;
|
|
for (index = 0; index < runtimeAnimations.length; index++) {
|
|
for (index = 0; index < runtimeAnimations.length; index++) {
|
|
var animation = runtimeAnimations[index];
|
|
var animation = runtimeAnimations[index];
|
|
- var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
|
|
|
|
|
|
+ var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
|
|
|
|
+ _this.onAnimationLoopObservable.notifyObservers(_this);
|
|
|
|
+ if (_this.onAnimationLoop) {
|
|
|
|
+ _this.onAnimationLoop();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
running = running || isRunning;
|
|
running = running || isRunning;
|
|
}
|
|
}
|
|
this.animationStarted = running;
|
|
this.animationStarted = running;
|
|
@@ -56500,6 +56535,8 @@ var BABYLON;
|
|
this._raiseOnAnimationEnd();
|
|
this._raiseOnAnimationEnd();
|
|
if (this.disposeOnEnd) {
|
|
if (this.disposeOnEnd) {
|
|
this.onAnimationEnd = null;
|
|
this.onAnimationEnd = null;
|
|
|
|
+ this.onAnimationLoop = null;
|
|
|
|
+ this.onAnimationLoopObservable.clear();
|
|
this.onAnimationEndObservable.clear();
|
|
this.onAnimationEndObservable.clear();
|
|
}
|
|
}
|
|
}
|
|
}
|