|
@@ -1,6 +1,6 @@
|
|
|
import { IEasingFunction, EasingFunction } from "./easing";
|
|
|
import { Vector3, Quaternion, Vector2, Matrix } from "../Maths/math.vector";
|
|
|
-import { Color3 } from '../Maths/math.color';
|
|
|
+import { Color3, Color4 } from '../Maths/math.color';
|
|
|
import { Scalar } from "../Maths/math.scalar";
|
|
|
|
|
|
import { Nullable } from "../types";
|
|
@@ -95,6 +95,8 @@ export class Animation {
|
|
|
dataType = Animation.ANIMATIONTYPE_VECTOR2;
|
|
|
} else if (from instanceof Color3) {
|
|
|
dataType = Animation.ANIMATIONTYPE_COLOR3;
|
|
|
+ } else if (from instanceof Color4) {
|
|
|
+ dataType = Animation.ANIMATIONTYPE_COLOR4;
|
|
|
} else if (from instanceof Size) {
|
|
|
dataType = Animation.ANIMATIONTYPE_SIZE;
|
|
|
}
|
|
@@ -572,6 +574,17 @@ export class Animation {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Interpolates a Color4 linearly
|
|
|
+ * @param startValue Start value of the animation curve
|
|
|
+ * @param endValue End value of the animation curve
|
|
|
+ * @param gradient Scalar amount to interpolate
|
|
|
+ * @returns Interpolated Color3 value
|
|
|
+ */
|
|
|
+ public color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4 {
|
|
|
+ return Color4.Lerp(startValue, endValue, gradient);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @hidden Internal use only
|
|
|
*/
|
|
|
public _getKeyValue(value: any): any {
|
|
@@ -690,6 +703,15 @@ export class Animation {
|
|
|
case Animation.ANIMATIONLOOPMODE_RELATIVE:
|
|
|
return this.color3InterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
|
|
|
}
|
|
|
+ // Color4
|
|
|
+ case Animation.ANIMATIONTYPE_COLOR4:
|
|
|
+ switch (state.loopMode) {
|
|
|
+ case Animation.ANIMATIONLOOPMODE_CYCLE:
|
|
|
+ case Animation.ANIMATIONLOOPMODE_CONSTANT:
|
|
|
+ return this.color4InterpolateFunction(startValue, endValue, gradient);
|
|
|
+ case Animation.ANIMATIONLOOPMODE_RELATIVE:
|
|
|
+ return this.color4InterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
|
|
|
+ }
|
|
|
// Matrix
|
|
|
case Animation.ANIMATIONTYPE_MATRIX:
|
|
|
switch (state.loopMode) {
|
|
@@ -803,6 +825,7 @@ export class Animation {
|
|
|
case Animation.ANIMATIONTYPE_MATRIX:
|
|
|
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
|
case Animation.ANIMATIONTYPE_COLOR3:
|
|
|
+ case Animation.ANIMATIONTYPE_COLOR4:
|
|
|
key.values = animationKey.value.asArray();
|
|
|
break;
|
|
|
}
|
|
@@ -831,113 +854,47 @@ export class Animation {
|
|
|
/**
|
|
|
* Float animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_FLOAT = 0;
|
|
|
+ public static readonly ANIMATIONTYPE_FLOAT = 0;
|
|
|
/**
|
|
|
* Vector3 animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_VECTOR3 = 1;
|
|
|
+ public static readonly ANIMATIONTYPE_VECTOR3 = 1;
|
|
|
/**
|
|
|
* Quaternion animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_QUATERNION = 2;
|
|
|
+ public static readonly ANIMATIONTYPE_QUATERNION = 2;
|
|
|
/**
|
|
|
* Matrix animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_MATRIX = 3;
|
|
|
+ public static readonly ANIMATIONTYPE_MATRIX = 3;
|
|
|
+ /**
|
|
|
+ * Color3 animation type
|
|
|
+ */
|
|
|
+ public static readonly ANIMATIONTYPE_COLOR3 = 4;
|
|
|
/**
|
|
|
* Color3 animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_COLOR3 = 4;
|
|
|
+ public static readonly ANIMATIONTYPE_COLOR4 = 7;
|
|
|
/**
|
|
|
* Vector2 animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_VECTOR2 = 5;
|
|
|
+ public static readonly ANIMATIONTYPE_VECTOR2 = 5;
|
|
|
/**
|
|
|
* Size animation type
|
|
|
*/
|
|
|
- private static _ANIMATIONTYPE_SIZE = 6;
|
|
|
+ public static readonly ANIMATIONTYPE_SIZE = 6;
|
|
|
/**
|
|
|
* Relative Loop Mode
|
|
|
*/
|
|
|
- private static _ANIMATIONLOOPMODE_RELATIVE = 0;
|
|
|
+ public static readonly ANIMATIONLOOPMODE_RELATIVE = 0;
|
|
|
/**
|
|
|
* Cycle Loop Mode
|
|
|
*/
|
|
|
- private static _ANIMATIONLOOPMODE_CYCLE = 1;
|
|
|
+ public static readonly ANIMATIONLOOPMODE_CYCLE = 1;
|
|
|
/**
|
|
|
* Constant Loop Mode
|
|
|
*/
|
|
|
- private static _ANIMATIONLOOPMODE_CONSTANT = 2;
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the float animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_FLOAT(): number {
|
|
|
- return Animation._ANIMATIONTYPE_FLOAT;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Vector3 animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_VECTOR3(): number {
|
|
|
- return Animation._ANIMATIONTYPE_VECTOR3;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Vector2 animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_VECTOR2(): number {
|
|
|
- return Animation._ANIMATIONTYPE_VECTOR2;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Size animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_SIZE(): number {
|
|
|
- return Animation._ANIMATIONTYPE_SIZE;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Quaternion animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_QUATERNION(): number {
|
|
|
- return Animation._ANIMATIONTYPE_QUATERNION;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Matrix animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_MATRIX(): number {
|
|
|
- return Animation._ANIMATIONTYPE_MATRIX;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Color3 animation type
|
|
|
- */
|
|
|
- public static get ANIMATIONTYPE_COLOR3(): number {
|
|
|
- return Animation._ANIMATIONTYPE_COLOR3;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Relative Loop Mode
|
|
|
- */
|
|
|
- public static get ANIMATIONLOOPMODE_RELATIVE(): number {
|
|
|
- return Animation._ANIMATIONLOOPMODE_RELATIVE;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Cycle Loop Mode
|
|
|
- */
|
|
|
- public static get ANIMATIONLOOPMODE_CYCLE(): number {
|
|
|
- return Animation._ANIMATIONLOOPMODE_CYCLE;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the Constant Loop Mode
|
|
|
- */
|
|
|
- public static get ANIMATIONLOOPMODE_CONSTANT(): number {
|
|
|
- return Animation._ANIMATIONLOOPMODE_CONSTANT;
|
|
|
- }
|
|
|
+ public static readonly ANIMATIONLOOPMODE_CONSTANT = 2;
|
|
|
|
|
|
/** @hidden */
|
|
|
public static _UniversalLerp(left: any, right: any, amount: number): any {
|
|
@@ -1010,6 +967,9 @@ export class Animation {
|
|
|
case Animation.ANIMATIONTYPE_COLOR3:
|
|
|
data = Color3.FromArray(key.values);
|
|
|
break;
|
|
|
+ case Animation.ANIMATIONTYPE_COLOR4:
|
|
|
+ data = Color4.FromArray(key.values);
|
|
|
+ break;
|
|
|
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
|
default:
|
|
|
data = Vector3.FromArray(key.values);
|