|
@@ -47993,9 +47993,10 @@ var BABYLON;
|
|
* @param target defines the target of the animation
|
|
* @param target defines the target of the animation
|
|
* @param animation defines the source {BABYLON.Animation} object
|
|
* @param animation defines the source {BABYLON.Animation} object
|
|
* @param scene defines the hosting scene
|
|
* @param scene defines the hosting scene
|
|
|
|
+ * @param host defines the initiating Animatable
|
|
*/
|
|
*/
|
|
- function RuntimeAnimation(target, animation, scene) {
|
|
|
|
- this.currentFrame = 0;
|
|
|
|
|
|
+ function RuntimeAnimation(target, animation, scene, host) {
|
|
|
|
+ this._currentFrame = 0;
|
|
this._offsetsCache = {};
|
|
this._offsetsCache = {};
|
|
this._highLimitsCache = {};
|
|
this._highLimitsCache = {};
|
|
this._stopped = false;
|
|
this._stopped = false;
|
|
@@ -48008,8 +48009,19 @@ var BABYLON;
|
|
this._animation = animation;
|
|
this._animation = animation;
|
|
this._target = target;
|
|
this._target = target;
|
|
this._scene = scene;
|
|
this._scene = scene;
|
|
|
|
+ this._host = host;
|
|
animation._runtimeAnimations.push(this);
|
|
animation._runtimeAnimations.push(this);
|
|
}
|
|
}
|
|
|
|
+ Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
|
|
|
|
+ /**
|
|
|
|
+ * Gets the current frame
|
|
|
|
+ */
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._currentFrame;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
Object.defineProperty(RuntimeAnimation.prototype, "weight", {
|
|
Object.defineProperty(RuntimeAnimation.prototype, "weight", {
|
|
/**
|
|
/**
|
|
* Gets the weight of the runtime animation
|
|
* Gets the weight of the runtime animation
|
|
@@ -48070,7 +48082,7 @@ var BABYLON;
|
|
RuntimeAnimation.prototype.reset = function () {
|
|
RuntimeAnimation.prototype.reset = function () {
|
|
this._offsetsCache = {};
|
|
this._offsetsCache = {};
|
|
this._highLimitsCache = {};
|
|
this._highLimitsCache = {};
|
|
- this.currentFrame = 0;
|
|
|
|
|
|
+ this._currentFrame = 0;
|
|
this._blendingFactor = 0;
|
|
this._blendingFactor = 0;
|
|
this._originalValue = null;
|
|
this._originalValue = null;
|
|
};
|
|
};
|
|
@@ -48093,7 +48105,7 @@ var BABYLON;
|
|
if (loopMode === BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
|
|
if (loopMode === BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
|
|
return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
|
|
return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
|
|
}
|
|
}
|
|
- this.currentFrame = currentFrame;
|
|
|
|
|
|
+ this._currentFrame = currentFrame;
|
|
var keys = this._animation.getKeys();
|
|
var keys = this._animation.getKeys();
|
|
// Try to get a hash to find the right key
|
|
// Try to get a hash to find the right key
|
|
var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
|
|
var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
|
|
@@ -48431,6 +48443,12 @@ var BABYLON;
|
|
// Compute value
|
|
// Compute value
|
|
var repeatCount = (ratio / range) >> 0;
|
|
var repeatCount = (ratio / range) >> 0;
|
|
var currentFrame = returnValue ? from + ratio % range : to;
|
|
var currentFrame = returnValue ? from + ratio % range : to;
|
|
|
|
+ // Need to normalize?
|
|
|
|
+ if (this._host && this._host.syncRoot) {
|
|
|
|
+ var syncRoot = this._host.syncRoot;
|
|
|
|
+ var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
|
|
|
|
+ currentFrame = from + (to - from) * hostNormalizedFrame;
|
|
|
|
+ }
|
|
var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
|
|
var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
|
|
// Set value
|
|
// Set value
|
|
this.setValue(currentValue, weight);
|
|
this.setValue(currentValue, weight);
|
|
@@ -48497,6 +48515,30 @@ var BABYLON;
|
|
this._scene = scene;
|
|
this._scene = scene;
|
|
scene._activeAnimatables.push(this);
|
|
scene._activeAnimatables.push(this);
|
|
}
|
|
}
|
|
|
|
+ Object.defineProperty(Animatable.prototype, "syncRoot", {
|
|
|
|
+ /**
|
|
|
|
+ * Gets the root Animatable used to synchronize and normalize animations
|
|
|
|
+ */
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._syncRoot;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Animatable.prototype, "masterFrame", {
|
|
|
|
+ /**
|
|
|
|
+ * Gets the current frame of the first RuntimeAnimation
|
|
|
|
+ * Used to synchronize Animatables
|
|
|
|
+ */
|
|
|
|
+ get: function () {
|
|
|
|
+ if (this._runtimeAnimations.length === 0) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return this._runtimeAnimations[0].currentFrame;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
Object.defineProperty(Animatable.prototype, "weight", {
|
|
Object.defineProperty(Animatable.prototype, "weight", {
|
|
/**
|
|
/**
|
|
* Gets or sets the animatable weight (-1.0 by default meaning not weighted)
|
|
* Gets or sets the animatable weight (-1.0 by default meaning not weighted)
|
|
@@ -48533,13 +48575,31 @@ var BABYLON;
|
|
configurable: true
|
|
configurable: true
|
|
});
|
|
});
|
|
// Methods
|
|
// Methods
|
|
|
|
+ /**
|
|
|
|
+ * Synchronize and normalize current Animatable with a source Animatable.
|
|
|
|
+ * This is useful when using animation weights and when animations are not of the same length
|
|
|
|
+ * @param root defines the root Animatable to synchronize with
|
|
|
|
+ * @returns the current Animatable
|
|
|
|
+ */
|
|
|
|
+ Animatable.prototype.syncWith = function (root) {
|
|
|
|
+ this._syncRoot = root;
|
|
|
|
+ if (root) {
|
|
|
|
+ // Make sure this animatable will animate after the root
|
|
|
|
+ var index = this._scene._activeAnimatables.indexOf(this);
|
|
|
|
+ if (index > -1) {
|
|
|
|
+ this._scene._activeAnimatables.splice(index, 1);
|
|
|
|
+ this._scene._activeAnimatables.push(this);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return this;
|
|
|
|
+ };
|
|
Animatable.prototype.getAnimations = function () {
|
|
Animatable.prototype.getAnimations = function () {
|
|
return this._runtimeAnimations;
|
|
return this._runtimeAnimations;
|
|
};
|
|
};
|
|
Animatable.prototype.appendAnimations = function (target, animations) {
|
|
Animatable.prototype.appendAnimations = function (target, animations) {
|
|
for (var index = 0; index < animations.length; index++) {
|
|
for (var index = 0; index < animations.length; index++) {
|
|
var animation = animations[index];
|
|
var animation = animations[index];
|
|
- this._runtimeAnimations.push(new BABYLON.RuntimeAnimation(target, animation, this._scene));
|
|
|
|
|
|
+ this._runtimeAnimations.push(new BABYLON.RuntimeAnimation(target, animation, this._scene, this));
|
|
}
|
|
}
|
|
};
|
|
};
|
|
Animatable.prototype.getAnimationByTargetProperty = function (property) {
|
|
Animatable.prototype.getAnimationByTargetProperty = function (property) {
|
|
@@ -92444,6 +92504,7 @@ var BABYLON;
|
|
loader.onTextureLoadedObservable.add(function (texture) { return _this.onTextureLoadedObservable.notifyObservers(texture); });
|
|
loader.onTextureLoadedObservable.add(function (texture) { return _this.onTextureLoadedObservable.notifyObservers(texture); });
|
|
loader.onMaterialLoadedObservable.add(function (material) { return _this.onMaterialLoadedObservable.notifyObservers(material); });
|
|
loader.onMaterialLoadedObservable.add(function (material) { return _this.onMaterialLoadedObservable.notifyObservers(material); });
|
|
loader.onExtensionLoadedObservable.add(function (extension) { return _this.onExtensionLoadedObservable.notifyObservers(extension); });
|
|
loader.onExtensionLoadedObservable.add(function (extension) { return _this.onExtensionLoadedObservable.notifyObservers(extension); });
|
|
|
|
+ loader.onAnimationGroupLoadedObservable.add(function (animationGroup) { return _this.onAnimationGroupLoadedObservable.notifyObservers(animationGroup); });
|
|
loader.onCompleteObservable.add(function () {
|
|
loader.onCompleteObservable.add(function () {
|
|
_this.onMeshLoadedObservable.clear();
|
|
_this.onMeshLoadedObservable.clear();
|
|
_this.onTextureLoadedObservable.clear();
|
|
_this.onTextureLoadedObservable.clear();
|