Aroxis Posted December 17, 2018 Share Posted December 17, 2018 Hello! I was wondering if `PIXI.Containers` have any associated performance overhead. Take the following examples: Example #1: Extending Container: class SpriteTile extends PIXI.Container { constructor(resource) { super(); // Create a sprite and add it to children const sprite = new PIXI.Sprite.fromImage(resource); this.addChild(sprite); } } Example #2: Extending Sprite directly: class SpriteTile extends PIXI.Sprite { constructor(resource) { super(resource); } } Both examples achieve the same thing. Example #1, while seemingly more obscure, keeps a certain level of extensibility by having the freedom of a Container. Example #2 is much more direct but is now also limited to the functionality of a simple Sprite. My question being; is there any (notable?) performance benefit over choosing example #2 over #1 in the use cases as shown above? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 17, 2018 Share Posted December 17, 2018 So, 5000 tiles of #2 will eat same amount of CPU as 10000 of #1 in updateTransform() loop. Its not important, because 1. There's a simple way to use only few hundreds or a thousand tiles. 2. There's a way to remove sprites and put stuff directly in buffer. Quote Link to comment Share on other sites More sharing options...
Aroxis Posted December 17, 2018 Author Share Posted December 17, 2018 28 minutes ago, ivan.popelyshev said: So, 5000 tiles of #2 will eat same amount of CPU as 10000 of #1 in updateTransform() loop. #2 renders just the Sprite while #1 renders both the Container and the Sprite, so it's the other way around, right? But what I gather is that both ways are fine because they can handle much more than the usual use case. Thanks! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 17, 2018 Share Posted December 17, 2018 Containers are not rendered. extra updateTransform() on camera move is the only problem. Quote Link to comment Share on other sites More sharing options...
Sein Posted October 8, 2022 Share Posted October 8, 2022 Thanks%[email protected].%20could%20you%20please%20give%20me%20an%20example%20of%20how%20to%20directly%20put%20stuff%20in%20the%20buffer%20instead%20of%20adding%20more%20sprites? Thanks @ivan.popelyshev. could you please give me an example of how to directly put stuff in the buffer instead of adding more sprites. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 9, 2022 Share Posted October 9, 2022 Nope, I cant find the article for it. Maybe somewhere at https://medium.com/@sukantk3.4 . Just directly pass object to the batcher, requirements are somethign like "needs vertexData and other stuff" Sein 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.