瀏覽代碼

Adding animatable.goToFrame

David catuhe 9 年之前
父節點
當前提交
3ac6803510

File diff suppressed because it is too large
+ 5 - 5
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 1166 - 1163
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 12 - 12
dist/preview release/babylon.js


+ 33 - 13
dist/preview release/babylon.max.js

@@ -22013,6 +22013,32 @@ var BABYLON;
             }
             return this._getKeyValue(this._keys[this._keys.length - 1].value);
         };
+        Animation.prototype.setValue = function (currentValue) {
+            // Set value
+            if (this.targetPropertyPath.length > 1) {
+                var property = this._target[this.targetPropertyPath[0]];
+                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
+                    property = property[this.targetPropertyPath[index]];
+                }
+                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
+            }
+            else {
+                this._target[this.targetPropertyPath[0]] = currentValue;
+            }
+            if (this._target.markAsDirty) {
+                this._target.markAsDirty(this.targetProperty);
+            }
+        };
+        Animation.prototype.goToFrame = function (frame) {
+            if (frame < this._keys[0].frame) {
+                frame = this._keys[0].frame;
+            }
+            else if (frame > this._keys[this._keys.length - 1].frame) {
+                frame = this._keys[this._keys.length - 1].frame;
+            }
+            var currentValue = this._interpolate(frame, 0, this.loopMode);
+            this.setValue(currentValue);
+        };
         Animation.prototype.animate = function (delay, from, to, loop, speedRatio) {
             if (!this.targetPropertyPath || this.targetPropertyPath.length < 1) {
                 this._stopped = true;
@@ -22103,19 +22129,7 @@ var BABYLON;
             var currentFrame = returnValue ? from + ratio % range : to;
             var currentValue = this._interpolate(currentFrame, repeatCount, this.loopMode, offsetValue, highLimitValue);
             // Set value
-            if (this.targetPropertyPath.length > 1) {
-                var property = this._target[this.targetPropertyPath[0]];
-                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
-                    property = property[this.targetPropertyPath[index]];
-                }
-                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
-            }
-            else {
-                this._target[this.targetPropertyPath[0]] = currentValue;
-            }
-            if (this._target.markAsDirty) {
-                this._target.markAsDirty(this.targetProperty);
-            }
+            this.setValue(currentValue);
             if (!returnValue) {
                 this._stopped = true;
             }
@@ -22250,6 +22264,12 @@ var BABYLON;
             this._localDelayOffset = null;
             this._pausedDelay = null;
         };
+        Animatable.prototype.goToFrame = function (frame) {
+            var animations = this._animations;
+            for (var index = 0; index < animations.length; index++) {
+                animations[index].goToFrame(frame);
+            }
+        };
         Animatable.prototype.pause = function () {
             if (this._paused) {
                 return;

File diff suppressed because it is too large
+ 12 - 12
dist/preview release/babylon.noworker.js


+ 6 - 0
src/Animations/babylon.animatable.js

@@ -49,6 +49,12 @@ var BABYLON;
             this._localDelayOffset = null;
             this._pausedDelay = null;
         };
+        Animatable.prototype.goToFrame = function (frame) {
+            var animations = this._animations;
+            for (var index = 0; index < animations.length; index++) {
+                animations[index].goToFrame(frame);
+            }
+        };
         Animatable.prototype.pause = function () {
             if (this._paused) {
                 return;

+ 8 - 0
src/Animations/babylon.animatable.ts

@@ -55,6 +55,14 @@
 
         }
 
+        public goToFrame(frame: number): void {
+            var animations = this._animations;
+
+            for (var index = 0; index < animations.length; index++) {
+                animations[index].goToFrame(frame);
+            }
+        }
+
         public pause(): void {
             if (this._paused) {
                 return;

+ 27 - 13
src/Animations/babylon.animation.js

@@ -241,6 +241,32 @@ var BABYLON;
             }
             return this._getKeyValue(this._keys[this._keys.length - 1].value);
         };
+        Animation.prototype.setValue = function (currentValue) {
+            // Set value
+            if (this.targetPropertyPath.length > 1) {
+                var property = this._target[this.targetPropertyPath[0]];
+                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
+                    property = property[this.targetPropertyPath[index]];
+                }
+                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
+            }
+            else {
+                this._target[this.targetPropertyPath[0]] = currentValue;
+            }
+            if (this._target.markAsDirty) {
+                this._target.markAsDirty(this.targetProperty);
+            }
+        };
+        Animation.prototype.goToFrame = function (frame) {
+            if (frame < this._keys[0].frame) {
+                frame = this._keys[0].frame;
+            }
+            else if (frame > this._keys[this._keys.length - 1].frame) {
+                frame = this._keys[this._keys.length - 1].frame;
+            }
+            var currentValue = this._interpolate(frame, 0, this.loopMode);
+            this.setValue(currentValue);
+        };
         Animation.prototype.animate = function (delay, from, to, loop, speedRatio) {
             if (!this.targetPropertyPath || this.targetPropertyPath.length < 1) {
                 this._stopped = true;
@@ -331,19 +357,7 @@ var BABYLON;
             var currentFrame = returnValue ? from + ratio % range : to;
             var currentValue = this._interpolate(currentFrame, repeatCount, this.loopMode, offsetValue, highLimitValue);
             // Set value
-            if (this.targetPropertyPath.length > 1) {
-                var property = this._target[this.targetPropertyPath[0]];
-                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
-                    property = property[this.targetPropertyPath[index]];
-                }
-                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
-            }
-            else {
-                this._target[this.targetPropertyPath[0]] = currentValue;
-            }
-            if (this._target.markAsDirty) {
-                this._target.markAsDirty(this.targetProperty);
-            }
+            this.setValue(currentValue);
             if (!returnValue) {
                 this._stopped = true;
             }

+ 31 - 15
src/Animations/babylon.animation.ts

@@ -291,6 +291,36 @@
             return this._getKeyValue(this._keys[this._keys.length - 1].value);
         }
 
+        public setValue(currentValue: any): void {
+            // Set value
+            if (this.targetPropertyPath.length > 1) {
+                var property = this._target[this.targetPropertyPath[0]];
+
+                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
+                    property = property[this.targetPropertyPath[index]];
+                }
+
+                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
+            } else {
+                this._target[this.targetPropertyPath[0]] = currentValue;
+            }
+
+            if (this._target.markAsDirty) {
+                this._target.markAsDirty(this.targetProperty);
+            }
+        }
+
+        public goToFrame(frame: number): void {
+            if (frame < this._keys[0].frame) {
+                frame = this._keys[0].frame
+            } else if (frame > this._keys[this._keys.length - 1].frame) {
+                frame = this._keys[this._keys.length - 1].frame;
+            }
+
+            var currentValue = this._interpolate(frame, 0, this.loopMode);
+
+            this.setValue(currentValue);
+        }
 
         public animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number): boolean {
             if (!this.targetPropertyPath || this.targetPropertyPath.length < 1) {
@@ -392,21 +422,7 @@
             var currentValue = this._interpolate(currentFrame, repeatCount, this.loopMode, offsetValue, highLimitValue);
 
             // Set value
-            if (this.targetPropertyPath.length > 1) {
-                var property = this._target[this.targetPropertyPath[0]];
-
-                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
-                    property = property[this.targetPropertyPath[index]];
-                }
-
-                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
-            } else {
-                this._target[this.targetPropertyPath[0]] = currentValue;
-            }
-
-            if (this._target.markAsDirty) {
-                this._target.markAsDirty(this.targetProperty);
-            }
+            this.setValue(currentValue);
 
             if (!returnValue) {
                 this._stopped = true;