소스 검색

Fixing a bug with quaternion animations

David Catuhe 11 년 전
부모
커밋
e5a4cad994

+ 20 - 2
Babylon/Animations/babylon.animation.js

@@ -153,15 +153,14 @@
 
             // Compute ratio
             var range = to - from;
+            var offsetValue;
             var ratio = delay * (this.framePerSecond * speedRatio) / 1000.0;
 
             if (ratio > range && !loop) {
-                offsetValue = 0;
                 returnValue = false;
                 highLimitValue = this._keys[this._keys.length - 1].value;
             } else {
                 // Get max value if required
-                var offsetValue = 0;
                 var highLimitValue = 0;
                 if (this.loopMode != Animation.ANIMATIONLOOPMODE_CYCLE) {
                     var keyOffset = to.toString() + from.toString();
@@ -194,6 +193,25 @@
                 }
             }
 
+            if (offsetValue === undefined) {
+                switch (this.dataType) {
+                    case Animation.ANIMATIONTYPE_FLOAT:
+                        offsetValue = 0;
+                        break;
+
+                    case Animation.ANIMATIONTYPE_QUATERNION:
+                        offsetValue = new BABYLON.Quaternion();
+                        break;
+
+                    case Animation.ANIMATIONTYPE_VECTOR3:
+                        offsetValue = BABYLON.Vector3.Zero();
+                        break;
+
+                    case Animation.ANIMATIONTYPE_COLOR3:
+                        offsetValue = BABYLON.Color3.Black();
+                }
+            }
+
             // Compute value
             var repeatCount = (ratio / range) >> 0;
             var currentFrame = returnValue ? from + ratio % range : to;

+ 21 - 2
Babylon/Animations/babylon.animation.ts

@@ -154,15 +154,14 @@
 
             // Compute ratio
             var range = to - from;
+            var offsetValue;
             var ratio = delay * (this.framePerSecond * speedRatio) / 1000.0;
 
             if (ratio > range && !loop) { // If we are out of range and not looping get back to caller
-                offsetValue = 0;
                 returnValue = false;
                 highLimitValue = this._keys[this._keys.length - 1].value;
             } else {
                 // Get max value if required
-                var offsetValue = 0;
                 var highLimitValue = 0;
                 if (this.loopMode != Animation.ANIMATIONLOOPMODE_CYCLE) {
                     var keyOffset = to.toString() + from.toString();
@@ -196,6 +195,26 @@
                 }
             }
 
+            if (offsetValue === undefined) {
+                switch (this.dataType) {
+                    // Float
+                    case Animation.ANIMATIONTYPE_FLOAT:
+                        offsetValue = 0;
+                        break;
+                    // Quaternion
+                    case Animation.ANIMATIONTYPE_QUATERNION:
+                        offsetValue = new Quaternion();
+                        break;
+                    // Vector3
+                    case Animation.ANIMATIONTYPE_VECTOR3:
+                        offsetValue = Vector3.Zero();
+                        break;
+                    // Color3
+                    case Animation.ANIMATIONTYPE_COLOR3:
+                        offsetValue = Color3.Black();
+                }
+            }
+
             // Compute value
             var repeatCount = (ratio / range) >> 0;
             var currentFrame = returnValue ? from + ratio % range : to;

+ 1 - 1
Babylon/Math/babylon.math.js

@@ -842,7 +842,7 @@
             if (typeof x === "undefined") { x = 0; }
             if (typeof y === "undefined") { y = 0; }
             if (typeof z === "undefined") { z = 0; }
-            if (typeof w === "undefined") { w = 0; }
+            if (typeof w === "undefined") { w = 1; }
             this.x = x;
             this.y = y;
             this.z = z;

+ 1 - 1
Babylon/Math/babylon.math.ts

@@ -810,7 +810,7 @@
     }
 
     export class Quaternion {
-        constructor(public x: number = 0, public y: number = 0, public z: number = 0, public w: number = 0) {
+        constructor(public x: number = 0, public y: number = 0, public z: number = 0, public w: number = 1) {
 
         }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2 - 2
babylon.1.14-beta-debug.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 4
babylon.1.14-beta.js