瀏覽代碼

added Path3D update() method

jbousquie 10 年之前
父節點
當前提交
65e89b95a6
共有 1 個文件被更改,包括 34 次插入21 次删除
  1. 34 21
      Babylon/Math/babylon.math.ts

+ 34 - 21
Babylon/Math/babylon.math.ts

@@ -3294,7 +3294,40 @@
         private _binormals = new Array<Vector3>();
 
         constructor(public path: Vector3[]) {
-            this._curve = path.slice();   // copy array         
+            this._curve = path.slice();   // copy array  
+            this._compute();       
+        }
+
+        public getCurve(): Vector3[] {
+            return this._curve;
+        }
+
+        public getTangents(): Vector3[] {
+            return this._tangents;
+        }
+
+        public getNormals(): Vector3[] {
+            return this._normals;
+        }
+
+        public getBinormals(): Vector3[] {
+            return this._binormals;
+        }
+
+        public getDistances(): number[] {
+            return this._distances;
+        }
+
+        public update(path: Vector3[]): Path3D {
+            for(var i = 0; i < path.length; i++) {
+                this._curve[i] = path[i];
+            }
+            this._compute();
+            return this;
+        }
+
+        // private function compute() : computes tangents, normals and binormals
+        private _compute() {
             var l = this._curve.length;
 
             // first and last tangents
@@ -3341,26 +3374,6 @@
             }
         }
 
-        public getCurve(): Vector3[] {
-            return this._curve;
-        }
-
-        public getTangents(): Vector3[] {
-            return this._tangents;
-        }
-
-        public getNormals(): Vector3[] {
-            return this._normals;
-        }
-
-        public getBinormals(): Vector3[] {
-            return this._binormals;
-        }
-
-        public getDistances(): number[] {
-            return this._distances;
-        }
-
         // private function normalVector(v0, vt) :
         // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
         private _normalVector(v0: Vector3, vt: Vector3): Vector3 {