فهرست منبع

Added easingFunction param in Animation.CreateAndStartAnimation (quick animation method)

Vousk-prod 10 سال پیش
والد
کامیت
ad3928f47e
2فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 4 1
      src/Animations/babylon.animation.js
  2. 5 1
      src/Animations/babylon.animation.ts

+ 4 - 1
src/Animations/babylon.animation.js

@@ -14,7 +14,7 @@ var BABYLON;
             this.dataType = dataType;
             this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
         }
-        Animation.CreateAndStartAnimation = function (name, mesh, targetProperty, framePerSecond, totalFrame, from, to, loopMode) {
+        Animation.CreateAndStartAnimation = function (name, mesh, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
             var dataType = undefined;
             if (!isNaN(parseFloat(from)) && isFinite(from)) {
                 dataType = Animation.ANIMATIONTYPE_FLOAT;
@@ -39,6 +39,9 @@ var BABYLON;
             keys.push({ frame: 0, value: from });
             keys.push({ frame: totalFrame, value: to });
             animation.setKeys(keys);
+            if (easingFunction !== undefined) {
+                animation.setEasingFunction(easingFunction);
+            }
             mesh.animations.push(animation);
             return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1));
         };

+ 5 - 1
src/Animations/babylon.animation.ts

@@ -12,7 +12,7 @@
 
         public static CreateAndStartAnimation(name: string, mesh: AbstractMesh, targetProperty: string,
             framePerSecond: number, totalFrame: number,
-            from: any, to: any, loopMode?: number) {
+            from: any, to: any, loopMode?: number, easingFunction?: EasingFunction) {
 
             var dataType = undefined;
 
@@ -39,6 +39,10 @@
             keys.push({ frame: totalFrame, value: to });
             animation.setKeys(keys);
 
+            if (easingFunction !== undefined) {
+                animation.setEasingFunction(easingFunction);
+            }
+            
             mesh.animations.push(animation);
 
             return mesh.getScene().beginAnimation(mesh, 0, totalFrame,(animation.loopMode === 1));