Browse Source

can now set pivot point in world space

Adam Bowman 8 năm trước cách đây
mục cha
commit
68cb658166
1 tập tin đã thay đổi với 14 bổ sung2 xóa
  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;