소스 검색

Merge pull request #1852 from aWeirdo/patch-9

Allows y === null in drawText.
David Catuhe 8 년 전
부모
커밋
d0c6914c24
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      src/Materials/Textures/babylon.dynamicTexture.ts

+ 7 - 3
src/Materials/Textures/babylon.dynamicTexture.ts

@@ -75,11 +75,15 @@ module BABYLON {
             }
 
             this._context.font = font;
-            if (x === null) {
+            if (x === null  || x === undefined) {
                 var textSize = this._context.measureText(text);
                 x = (size.width - textSize.width) / 2;
             }
-
+            if (y === null || y === undefined) {
+                var fontSize = parseInt((font.replace(/\D/g,'')));;
+                y = (size.height /2) + (fontSize/3.65);
+            }
+            
             this._context.fillStyle = color;
             this._context.fillText(text, x, y);
 
@@ -103,4 +107,4 @@ module BABYLON {
             return newTexture;
         }
     }
-} 
+}