Browse Source

Canvas2D rendering issue on Sprite2D and Text2d

Fixing a bug then the rendering was incorrectly considered as successfully done but in fact not due to Shader Effect not yet loaded.
nockawa 9 năm trước cách đây
mục cha
commit
510b56f313

+ 1 - 1
src/Canvas2d/babylon.sprite2d.ts

@@ -11,7 +11,7 @@
         render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean {
         render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean {
             // Do nothing if the shader is still loading/preparing 
             // Do nothing if the shader is still loading/preparing 
             if (!this.effectsReady) {
             if (!this.effectsReady) {
-                if ((!this.effect.isReady() || (this.effectInstanced && !this.effectInstanced.isReady()))) {
+                if ((this.effect && (!this.effect.isReady() || (this.effectInstanced && !this.effectInstanced.isReady())))) {
                     return false;
                     return false;
                 }
                 }
                 this.effectsReady = true;
                 this.effectsReady = true;

+ 1 - 1
src/Canvas2d/babylon.text2d.ts

@@ -11,7 +11,7 @@
         render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean {
         render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean {
             // Do nothing if the shader is still loading/preparing 
             // Do nothing if the shader is still loading/preparing 
             if (!this.effectsReady) {
             if (!this.effectsReady) {
-                if ((!this.effect.isReady() || (this.effectInstanced && !this.effectInstanced.isReady()))) {
+                if ((this.effect && (!this.effect.isReady() || (this.effectInstanced && !this.effectInstanced.isReady())))) {
                     return false;
                     return false;
                 }
                 }
                 this.effectsReady = true;
                 this.effectsReady = true;