ソースを参照

Fix rotation to quaternion

Sebastien Vandenberghe 7 年 前
コミット
ab22765a15

ファイルの差分が大きいため隠しています
+ 14804 - 14804
Playground/babylon.d.txt


ファイルの差分が大きいため隠しています
+ 11414 - 11414
dist/preview release/babylon.d.ts


ファイルの差分が大きいため隠しています
+ 28 - 28
dist/preview release/babylon.js


+ 1 - 12
dist/preview release/babylon.max.js

@@ -2852,18 +2852,7 @@ var BABYLON;
          * @returns a new Quaternion object, computed from the Vector3 coordinates
          */
         Vector3.prototype.toQuaternion = function () {
-            var result = new Quaternion(0.0, 0.0, 0.0, 1.0);
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny;
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-            return result;
+            return BABYLON.Quaternion.RotationYawPitchRoll(this.x, this.y, this.z);
         };
         /**
          * Adds the given vector to the current Vector3

+ 1 - 12
dist/preview release/babylon.no-module.max.js

@@ -2819,18 +2819,7 @@ var BABYLON;
          * @returns a new Quaternion object, computed from the Vector3 coordinates
          */
         Vector3.prototype.toQuaternion = function () {
-            var result = new Quaternion(0.0, 0.0, 0.0, 1.0);
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny;
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-            return result;
+            return BABYLON.Quaternion.RotationYawPitchRoll(this.x, this.y, this.z);
         };
         /**
          * Adds the given vector to the current Vector3

ファイルの差分が大きいため隠しています
+ 29 - 29
dist/preview release/babylon.worker.js


+ 1 - 12
dist/preview release/es6.js

@@ -2819,18 +2819,7 @@ var BABYLON;
          * @returns a new Quaternion object, computed from the Vector3 coordinates
          */
         Vector3.prototype.toQuaternion = function () {
-            var result = new Quaternion(0.0, 0.0, 0.0, 1.0);
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny;
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-            return result;
+            return BABYLON.Quaternion.RotationYawPitchRoll(this.x, this.y, this.z);
         };
         /**
          * Adds the given vector to the current Vector3

ファイルの差分が大きいため隠しています
+ 17 - 17
dist/preview release/viewer/babylon.viewer.js


+ 2 - 13
dist/preview release/viewer/babylon.viewer.max.js

@@ -2940,18 +2940,7 @@ var BABYLON;
          * @returns a new Quaternion object, computed from the Vector3 coordinates
          */
         Vector3.prototype.toQuaternion = function () {
-            var result = new Quaternion(0.0, 0.0, 0.0, 1.0);
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny;
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-            return result;
+            return BABYLON.Quaternion.RotationYawPitchRoll(this.x, this.y, this.z);
         };
         /**
          * Adds the given vector to the current Vector3
@@ -104843,7 +104832,7 @@ var BABYLON;
                 });
                 loadAttribute("TANGENT", BABYLON.VertexBuffer.TangentKind, function (babylonVertexBuffer, data) {
                     var dataIndex = 0;
-                    babylonVertexBuffer.forEach(data.length, function (value, index) {
+                    babylonVertexBuffer.forEach(data.length / 3 * 4, function (value, index) {
                         // Tangent data for morph targets is stored as xyz delta.
                         // The vertexData.tangent is stored as xyzw.
                         // So we need to skip every fourth vertexData.tangent.

+ 1 - 14
src/Math/babylon.math.ts

@@ -1565,20 +1565,7 @@
          * @returns a new Quaternion object, computed from the Vector3 coordinates
          */
         public toQuaternion(): Quaternion {
-            var result = new Quaternion(0.0, 0.0, 0.0, 1.0);
-
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny;
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-            return result;
+            return BABYLON.Quaternion.RotationYawPitchRoll(this.x, this.y, this.z);
         }
 
         /**