pixijs / layers

Separate the z-hierarchy of your scene tree from its canonical structure.
https://pixijs.io/layers/docs/
MIT License
220 stars 57 forks source link

How the get only the actual rendered sprites #63

Open Anckermann opened 3 years ago

Anckermann commented 3 years ago

I have already searched on the Pixi.js forums and guidelines, but found nothing. Is there a way to get the only displayed sprites? I have to load a lot of sprites on the map (8000+) and then populate an html list for them that is contestual to what is seen on the map. Yes, I could scroll the entire array of sprites in the container and check if every sprite is in the map bounds, but this operation takes way too much effort and is taking a lot of perfomance away. When the sprites will be in great number, I'm planning on using an infinite procedural list, but getting what is displayed will help me a lot and avoid useless computation.

Is it possible to get just what is seen on the screen by the pixi renderer for example?

Alexbay218 commented 3 years ago

https://github.com/davidfig/pixi-cull might fit your needs, especially if you use pixi-viewport library (by the same author). The simple version looks to be the same approach (looping through all sprites), but the spatial hash might give you the performance you need.