浏览代码

added setPivotPoint, getPivotPoint to AbstractMesh

Adam Bowman 8 年之前
父节点
当前提交
0cd46c9878
共有 1 个文件被更改,包括 52 次插入0 次删除
  1. 52 0
      src/Mesh/babylon.abstractMesh.ts

+ 52 - 0
src/Mesh/babylon.abstractMesh.ts

@@ -1219,5 +1219,57 @@
             Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
         }
 
+        public setPivotPoint(point:Vector3): void{
+
+            Vector3.TransformCoordinatesToRef(point, this.getWorldMatrix(), this.position);
+
+            this._pivotMatrix.m[12] = -point.x;
+            this._pivotMatrix.m[13] = -point.y;
+            this._pivotMatrix.m[14] = -point.z;
+
+            this._cache.pivotMatrixUpdated = true;
+
+        }
+
+        public getPivotPoint(): Vector3 {
+
+            var point = Vector3.Zero();
+
+            this.getPivotPointToRef(point);
+
+            return point;
+
+        }
+
+        public getPivotPointToRef(result:Vector3): void{
+
+            result.x = -this._pivotMatrix.m[12];
+            result.y = -this._pivotMatrix.m[13];
+            result.z = -this._pivotMatrix.m[14];
+
+        }
+
+        public getAbsolutePivotPoint(): Vector3 {
+
+            var point = Vector3.Zero();
+
+            this.getAbsolutePivotPointToRef(point);
+
+            return point;
+
+        }
+
+        public getAbsolutePivotPointToRef(result:Vector3): void{
+
+            result.x = this._pivotMatrix.m[12];
+            result.y = this._pivotMatrix.m[13];
+            result.z = this._pivotMatrix.m[14];
+
+            this.getPivotPointToRef(result);
+
+            Vector3.TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
+
+        }
+
     }
 }