Jump to content

How to remove the Canvas2D element?


Kent
 Share

Recommended Posts

Hi Kent, welcome to the forum... good to have you with us.

   Canvas2d is new, and I'm newbie... but I don't see any .removePrimitive() func on Canvas2d.  That is what you are trying to do.  You are attempting to remove only the "lines2d primitive" and not the entire canvas2D screenSpace, right?  Maybe not possible at this time.  But you can easily remove the entire canvas2d.

http://babylonjs-playground.com/#15C96V#3

In lines 21-23, I renamed 'canvas' to 'screenSpace'.  Less confusing.

And in line 43... there it is, the screenSpace.dispose()... seems to work ok.  Might work for your needs.  Our 2D hero @Nockawa might come visit this thread and leave us with his wisdom.  Hope this helps.  Again, welcome, keep us posted.  thx.

Link to comment
Share on other sites

7 hours ago, Kent said:

I try to use dispose function to remove the 2d line when click the canvas, but seems not work.

http://babylonjs-playground.com/#15C96V#2

Hi @Kent thank you for your question, I've played with your PG and indeed, things should work and it's not.

But, it's working on my machine, so I guess I've fixed the issue locally and it's not merged yet in the PG.

I'm working hard to finish supporting the opaque/alphaTest/transparency and I'll commit things asap. In the time being, sorry for the inconvenience.

A big thank to @Wingnut for dispatching!

Link to comment
Share on other sites

Hey, that's great customer service from @Nockawa... yay!

http://babylonjs-playground.com/#272WI1#3

See the console and code line 45.  var Canvas2D = function r() ?  Weird.

Cast-off your castings, Canvas2D.  Come run with us... as an [object]  :)

Just talkin' crap, here,  but I think that function r() is reasonably unhealthy.  :)  Thanks for your work, N!  The demos from the docs are SWEEEET.  I like 'em!

http://babylonjs-playground.com/#15C96V

(Off-topic, but, are we seeing some failed/intermittent clicks on the right two shape prims?  I am.  Just passing it along.  Be well, guys.)

Link to comment
Share on other sites

2 minutes ago, Wingnut said:

Hey, that's great customer service from @Nockawa... yay!

http://babylonjs-playground.com/#272WI1#3

See the console and code line 45.  var Canvas2D = function r() ?  Weird.

Cast-off your castings, Canvas2D.  Come run with us... as an [object]  :)

Just talkin' crap, here,  but I think that function r() is reasonably unhealthy.  :)  Thanks for your work, N!  The demos from the docs are SWEEEET.  I like 'em!

http://babylonjs-playground.com/#15C96V

(Off-topic, but, are we seeing some failed/intermittent clicks on the right two shape prims?  I am.  Just passing it along.  Be well, guys.)

I admit my JS skills are too limited to debug this PG if it's a JS issue, I'm a spoiled child doing TypeScript only! :)

Concerning your off topic, no,you're right, intersection is supported actually only on the lines' element itself, not the cap (the square, round, arrow stuffs). I didn't have the time to do it yet! on more thing left to do!

Link to comment
Share on other sites

ohhhhhh... ok.  (duh, Wingy)   Ok, cool, lines only, not fill-area, yet.  Understood.  Thanks!  

Hey, there's one way to get good at JS.  Get in there and hack chow, baby.  :)  That's what the playground is for, right?  SourceCode + rototiller = fun!  Jump-in and hack away with the machete, hit RUN over and over.  Why do it precise and tight... when you can do it with a chainsaw, right?  heh

Just havin' fun, as always.  You see line 45 console.log(Canvas2D) report:  function r()     Right?  Sure ya do.  Canvas2d has a mis-casted type-mold.  (huh?)   (Like I know anything about TS)

But... you know...  Canvas2D was type-casted incorrectly for some reason.  Should be an [object] (just like what line 46 reports) *shrug*

 

Link to comment
Share on other sites

7 hours ago, Wingnut said:

Hi Kent, welcome to the forum... good to have you with us.

   Canvas2d is new, and I'm newbie... but I don't see any .removePrimitive() func on Canvas2d.  That is what you are trying to do.  You are attempting to remove only the "lines2d primitive" and not the entire canvas2D screenSpace, right?  Maybe not possible at this time.  But you can easily remove the entire canvas2d.

http://babylonjs-playground.com/#15C96V#3

In lines 21-23, I renamed 'canvas' to 'screenSpace'.  Less confusing.

And in line 43... there it is, the screenSpace.dispose()... seems to work ok.  Might work for your needs.  Our 2D hero @Nockawa might come visit this thread and leave us with his wisdom.  Hope this helps.  Again, welcome, keep us posted.  thx.

Thank you Wingnut. Yes, I want remove only the "lines2d primitive". I want create some dynamic 2d primitives on the screen, and remove one of them when some events happened, like the click event in the demo.

Link to comment
Share on other sites

8 hours ago, Nockawa said:

Hi @Kent thank you for your question, I've played with your PG and indeed, things should work and it's not.

But, it's working on my machine, so I guess I've fixed the issue locally and it's not merged yet in the PG.

I'm working hard to finish supporting the opaque/alphaTest/transparency and I'll commit things asap. In the time being, sorry for the inconvenience.

A big thank to @Wingnut for dispatching!

Hi Nockawa, thank you for all your hard work. Looking forward to your updates:)

Link to comment
Share on other sites

9 hours ago, Nockawa said:

Ok, weird thing...your playground is actually working on Internet Explorer, but not on FF or Chrome...

But my local code is on both three webnav...

Yes, I just tested, the IE worked fine, but the Chrome did not, maybe this is a browser compatibility issue.

Because the http://babylonjs-playground.com/ website hard to open with IE in my country, so I always use the Chrome browser to test Babylonjs code. Sorry for missing the browser description in my question.

Link to comment
Share on other sites

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...