Explorar o código

Canvas2D: Attempt #1 to fix Delayed FontTexture in Text2D

[Trello Card](https://trello.com/c/rhriSGcf)
nockawa %!s(int64=8) %!d(string=hai) anos
pai
achega
b6676856f5
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      canvas2D/src/Engine/babylon.text2d.ts

+ 9 - 0
canvas2D/src/Engine/babylon.text2d.ts

@@ -462,6 +462,15 @@
                 this._fontName        = null;
                 this._fontSuperSample = false;
                 this._fontSDF         = false;
+
+                let ft = this._fontTexture;
+                if (ft != null && !ft.isReady()) {
+                    ft.onLoadObservable.add(() => {
+                        this._positioningDirty();
+                        this._setLayoutDirty();
+                        this._instanceDirtyFlags |= Prim2DBase.originProperty.flagId;  // To make sure the Text2D is issued again for render
+                    });                    
+                }
             } else {
                 this._fontName       = (settings.fontName==null) ? "12pt Arial" : settings.fontName;
                 this._fontSuperSample= (settings.fontSuperSample!=null && settings.fontSuperSample);