Jump to content

Replace geometry in graphics object


Saeki Amae
 Share

Recommended Posts

Hello, I'd like to ask if there is any way to replace geometry in already created graphics?
The documentation says that geometry attribute in graphics object is read-only.

I know I can clear and redraw but then i make new geometry instance instead of using shared one (I want to have many graphics items of same geometry).

I can remove graphics object and make new object applying shared geometry to new object but then I have to mess with zIndexes and other stuff as rendering queue changes
(not to mention resetting all current graphics settings like scale, tint and so on).

In Sprites i can easily replace texture by modifying texture attribute.

Is there some easy method of resolving this issue in Pixi v5?

Edited by Saeki Amae
Link to comment
Share on other sites

Its possible with modifying "graphics.geometry.graphicsData" and calling "graphics.geometry.invalidate()" after that. Or you can do something like "drawPolygon(myPolygon)", then modify polygon, then call "graphics.geometry.invalidate()". It triggers triangulation and full rebuild of vertex buffer.

Edited by ivan.popelyshev
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...