浏览代码

added raw parameter to Path3D constructor : returns unnormalized Path3D

jbousquie 10 年之前
父节点
当前提交
0de72c0eeb
共有 1 个文件被更改,包括 21 次插入7 次删除
  1. 21 7
      src/Math/babylon.math.ts

+ 21 - 7
src/Math/babylon.math.ts

@@ -3513,11 +3513,13 @@
         private _tangents = new Array<Vector3>();
         private _normals = new Array<Vector3>();
         private _binormals = new Array<Vector3>();
+        private _raw: boolean;
 
-        constructor(public path: Vector3[], firstNormal?: Vector3) {
+        constructor(public path: Vector3[], firstNormal?: Vector3, raw?: boolean) {
             for (var p = 0; p < path.length; p++) {
                 this._curve[p] = path[p].clone(); // hard copy
             }
+            this._raw = raw || false;
             this._compute(firstNormal);
         }
 
@@ -3557,17 +3559,25 @@
 
             // first and last tangents
             this._tangents[0] = this._getFirstNonNullVector(0);
-            this._tangents[0].normalize();
+            if (!this._raw) {
+                this._tangents[0].normalize();
+            }
             this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
-            this._tangents[l - 1].normalize();
+            if (!this._raw) {
+                this._tangents[l - 1].normalize();
+            }
             
             // normals and binormals at first point : arbitrary vector with _normalVector()
             var tg0 = this._tangents[0];
             var pp0 = this._normalVector(this._curve[0], tg0, firstNormal);
             this._normals[0] = pp0;
-            this._normals[0].normalize();
+            if (!this._raw) {
+                this._normals[0].normalize();
+            }
             this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
-            this._binormals[0].normalize();
+            if (!this._raw) {
+                this._binormals[0].normalize();
+            }
             this._distances[0] = 0;
 
             // normals and binormals : next points
@@ -3592,9 +3602,13 @@
                 curTang = this._tangents[i];
                 prevBinor = this._binormals[i - 1];
                 this._normals[i] = Vector3.Cross(prevBinor, curTang);
-                this._normals[i].normalize();
+                if (!this._raw) {
+                    this._normals[i].normalize();
+                }
                 this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
-                this._binormals[i].normalize();
+                if (!this._raw) {
+                    this._binormals[i].normalize();
+                }
             }
         }