浏览代码

can now set pivot point in world space

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

+ 14 - 2
src/Mesh/babylon.abstractMesh.ts

@@ -1219,9 +1219,21 @@
             Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
         }
 
-        public setPivotPoint(point:Vector3): void{
+        public setPivotPoint(point:Vector3, space:Space = Space.LOCAL): void{
 
-            Vector3.TransformCoordinatesToRef(point, this.getWorldMatrix(), this.position);
+            if(this.getScene().getRenderId() == 0){
+                this.computeWorldMatrix(true);
+            }
+
+            var wm = this.getWorldMatrix();
+            
+            if (space == Space.WORLD) {
+                var tmat = Tmp.Matrix[0];
+                wm.invertToRef(tmat);
+                point = Vector3.TransformCoordinates(point, tmat);
+            }
+
+            Vector3.TransformCoordinatesToRef(point, wm, this.position);
 
             this._pivotMatrix.m[12] = -point.x;
             this._pivotMatrix.m[13] = -point.y;