|
@@ -32678,9 +32678,15 @@ var BABYLON;
|
|
Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
|
|
Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
|
|
return BABYLON.Vector3.Lerp(startValue, endValue, gradient);
|
|
return BABYLON.Vector3.Lerp(startValue, endValue, gradient);
|
|
};
|
|
};
|
|
|
|
+ Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, endValue, outTangent, inTangent, gradient) {
|
|
|
|
+ return BABYLON.Vector3.Hermite(startValue, outTangent, endValue, inTangent, gradient);
|
|
|
|
+ };
|
|
Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
|
|
Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
|
|
return BABYLON.Vector2.Lerp(startValue, endValue, gradient);
|
|
return BABYLON.Vector2.Lerp(startValue, endValue, gradient);
|
|
};
|
|
};
|
|
|
|
+ Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, endValue, outTangent, inTangent, gradient) {
|
|
|
|
+ return BABYLON.Vector2.Hermite(startValue, outTangent, endValue, inTangent, gradient);
|
|
|
|
+ };
|
|
Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
|
|
Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
|
|
return BABYLON.Size.Lerp(startValue, endValue, gradient);
|
|
return BABYLON.Size.Lerp(startValue, endValue, gradient);
|
|
};
|
|
};
|
|
@@ -32722,18 +32728,21 @@ var BABYLON;
|
|
}
|
|
}
|
|
this.currentFrame = currentFrame;
|
|
this.currentFrame = currentFrame;
|
|
// Try to get a hash to find the right key
|
|
// Try to get a hash to find the right key
|
|
- var startKey = Math.max(0, Math.min(this._keys.length - 1, Math.floor(this._keys.length * (currentFrame - this._keys[0].frame) / (this._keys[this._keys.length - 1].frame - this._keys[0].frame)) - 1));
|
|
|
|
- if (this._keys[startKey].frame >= currentFrame) {
|
|
|
|
- while (startKey - 1 >= 0 && this._keys[startKey].frame >= currentFrame) {
|
|
|
|
- startKey--;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (var key = startKey; key < this._keys.length; key++) {
|
|
|
|
- if (this._keys[key + 1].frame >= currentFrame) {
|
|
|
|
- var startValue = this._getKeyValue(this._keys[key].value);
|
|
|
|
- var endValue = this._getKeyValue(this._keys[key + 1].value);
|
|
|
|
|
|
+ var startKeyIndex = Math.max(0, Math.min(this._keys.length - 1, Math.floor(this._keys.length * (currentFrame - this._keys[0].frame) / (this._keys[this._keys.length - 1].frame - this._keys[0].frame)) - 1));
|
|
|
|
+ if (this._keys[startKeyIndex].frame >= currentFrame) {
|
|
|
|
+ while (startKeyIndex - 1 >= 0 && this._keys[startKeyIndex].frame >= currentFrame) {
|
|
|
|
+ startKeyIndex--;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (var key = startKeyIndex; key < this._keys.length; key++) {
|
|
|
|
+ var endKey = this._keys[key + 1];
|
|
|
|
+ if (endKey.frame >= currentFrame) {
|
|
|
|
+ var startKey = this._keys[key];
|
|
|
|
+ var startValue = this._getKeyValue(startKey.value);
|
|
|
|
+ var endValue = this._getKeyValue(endKey.value);
|
|
|
|
+ var useTangent = startKey.outTangent && endKey.inTangent;
|
|
// gradient : percent of currentFrame between the frame inf and the frame sup
|
|
// gradient : percent of currentFrame between the frame inf and the frame sup
|
|
- var gradient = (currentFrame - this._keys[key].frame) / (this._keys[key + 1].frame - this._keys[key].frame);
|
|
|
|
|
|
+ var gradient = (currentFrame - startKey.frame) / (endKey.frame - startKey.frame);
|
|
// check for easingFunction and correction of gradient
|
|
// check for easingFunction and correction of gradient
|
|
if (this._easingFunction != null) {
|
|
if (this._easingFunction != null) {
|
|
gradient = this._easingFunction.ease(gradient);
|
|
gradient = this._easingFunction.ease(gradient);
|
|
@@ -32764,21 +32773,23 @@ var BABYLON;
|
|
return quaternion;
|
|
return quaternion;
|
|
// Vector3
|
|
// Vector3
|
|
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
|
|
+ var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent, endValue, endKey.inTangent, gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
|
|
switch (loopMode) {
|
|
switch (loopMode) {
|
|
case Animation.ANIMATIONLOOPMODE_CYCLE:
|
|
case Animation.ANIMATIONLOOPMODE_CYCLE:
|
|
case Animation.ANIMATIONLOOPMODE_CONSTANT:
|
|
case Animation.ANIMATIONLOOPMODE_CONSTANT:
|
|
- return this.vector3InterpolateFunction(startValue, endValue, gradient);
|
|
|
|
|
|
+ return vec3Value;
|
|
case Animation.ANIMATIONLOOPMODE_RELATIVE:
|
|
case Animation.ANIMATIONLOOPMODE_RELATIVE:
|
|
- return this.vector3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
|
|
|
|
|
|
+ return vec3Value.add(offsetValue.scale(repeatCount));
|
|
}
|
|
}
|
|
// Vector2
|
|
// Vector2
|
|
case Animation.ANIMATIONTYPE_VECTOR2:
|
|
case Animation.ANIMATIONTYPE_VECTOR2:
|
|
|
|
+ var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent, endValue, endKey.inTangent, gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
|
|
switch (loopMode) {
|
|
switch (loopMode) {
|
|
case Animation.ANIMATIONLOOPMODE_CYCLE:
|
|
case Animation.ANIMATIONLOOPMODE_CYCLE:
|
|
case Animation.ANIMATIONLOOPMODE_CONSTANT:
|
|
case Animation.ANIMATIONLOOPMODE_CONSTANT:
|
|
- return this.vector2InterpolateFunction(startValue, endValue, gradient);
|
|
|
|
|
|
+ return vec2Value;
|
|
case Animation.ANIMATIONLOOPMODE_RELATIVE:
|
|
case Animation.ANIMATIONLOOPMODE_RELATIVE:
|
|
- return this.vector2InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
|
|
|
|
|
|
+ return vec2Value.add(offsetValue.scale(repeatCount));
|
|
}
|
|
}
|
|
// Size
|
|
// Size
|
|
case Animation.ANIMATIONTYPE_SIZE:
|
|
case Animation.ANIMATIONTYPE_SIZE:
|