浏览代码

Canvas2D small API added to access global position of prim (#1200)

* Change text drawing starting location to the right place in case of multi-line

* Fix textSize null case

* Canvas2D: enhance text rendering quality

* Canvas2D: small api to access global position of prim
Loïc Baumann 9 年之前
父节点
当前提交
34f8e78d57
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      src/Canvas2d/babylon.prim2dBase.ts

+ 18 - 0
src/Canvas2d/babylon.prim2dBase.ts

@@ -1873,6 +1873,24 @@
         }
 
         /**
+         * return the global position of the primitive, relative to its canvas
+         */
+        public getGlobalPosition(): Vector2 {
+            let v = new Vector2(0, 0);
+            this.getGlobalPositionByRef(v);
+            return v;
+        }
+
+        /**
+         * return the global position of the primitive, relative to its canvas
+         * @param v the valid Vector2 object where the global position will be stored
+         */
+        public getGlobalPositionByRef(v: Vector2) {
+            v.x = this.globalTransform.m[12];
+            v.y = this.globalTransform.m[13];
+        }
+
+        /**
          * Get invert of the global transformation matrix of the primitive
          */
         public get invGlobalTransform(): Matrix {