Jump to content

Render warning when adding new text after Text2D.dispose()


Joakim
 Share

Recommended Posts

Hi

I just started using the Text2D class - and I find it very useful!

But I found a little problem. If I dispose of a text element and then add another one to the same canvas, the new text is nothing but a black rectangle and I get the following warning in the console:

[.CommandBufferContext.Offscreen-MainThread-0493EE88]RENDER WARNING: there is no texture bound to the unit 0

Here is a small example where the phenomenon occurs: http://www.babylonjs-playground.com/#1WJHS0#0

This is a bug right? Or am I just doing something wrong? Is there a workaround?

Thank you!

Link to comment
Share on other sites

19 hours ago, Joakim said:

Hi

I just started using the Text2D class - and I find it very useful!

But I found a little problem. If I dispose of a text element and then add another one to the same canvas, the new text is nothing but a black rectangle and I get the following warning in the console:


[.CommandBufferContext.Offscreen-MainThread-0493EE88]RENDER WARNING: there is no texture bound to the unit 0

Here is a small example where the phenomenon occurs: http://www.babylonjs-playground.com/#1WJHS0#0

This is a bug right? Or am I just doing something wrong? Is there a workaround?

Thank you!

Hello, yes, unfortunately it's a known bug which happens for any kinds of Primitives. If you dispose the last primitive of a given type, I release everything but looks like I can't recreate the instances.

I don't have time to code right now because I'm moving back in my old house after 2 years of being abroad and I have lots of things to do, but I'll work on it in few days.

There's a Trello Card for this bug.

Link to comment
Share on other sites

Ah, okay.

Well, thanks to the information you gave me, the workaround seems to be that if I add a text element off screen (say at (-50,-50)), which I never remove, the problem is solved!

But please, if and when you come up with a solution, post here, so I can mark this topic as solved.

Thanks!

Link to comment
Share on other sites

9 hours ago, Joakim said:

Ah, okay.

Well, thanks to the information you gave me, the workaround seems to be that if I add a text element off screen (say at (-50,-50)), which I never remove, the problem is solved!

But please, if and when you come up with a solution, post here, so I can mark this topic as solved.

Thanks!

Will do it. best.

Link to comment
Share on other sites

Hello
why not dealing with opacity?
 
much faster, then - if you want to destroy an element, you also have to write, you own redraw function, its kind of 2d and fun, but slow things down.
I would recommend to deprecated the .dispose(), what i most of the time want is just changing text. Not destroying elements.

http://www.babylonjs-playground.com/#1WJHS0#2

Edited by Nabroski
easy peasy
Link to comment
Share on other sites

Thank you, i spend hours exploring this, kind of game for me:

Glad if someone find my experience helpful, here is a workaround for dispose()

http://www.babylonjs-playground.com/#1WJHS0#3

You can also write your own Primitive Type, that fits exactly with challenges of your project 
http://doc.babylonjs.com/tutorials/How_to_create_your_own_Canvas2D_primitive

Best

Link to comment
Share on other sites

14 hours ago, Nabroski said:

Thank you, i spend hours exploring this, kind of game for me:

Glad if someone find my experience helpful, here is a workaround for dispose()

http://www.babylonjs-playground.com/#1WJHS0#3

You can also write your own Primitive Type, that fits exactly with challenges of your project 
http://doc.babylonjs.com/tutorials/How_to_create_your_own_Canvas2D_primitive

Best

@Nabroski and @Joakim don't forget about the doc ! The visibility feature is listed in second place of the General Concept Overview section ;)

 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...