davidfig / pixi-cull

a library to visibly cull objects designed to work with pixi.js
MIT License
112 stars 15 forks source link

Some Sprites could disappeared when init out of screen in the beginning #21

Closed zhouccccc closed 3 years ago

zhouccccc commented 3 years ago

As stated in the title, If I put some sprites out of the viewport screen in the beginning of rendering, these sprites could disappeared when wheel the viewport for view them. But not all sprites disappear, it seems to be random

Case 1 image

Case 2 image

The complete map looks like this image

Even though update the cull to the latest version

version

image

The following is my code: image

davidfig commented 3 years ago

It's difficult to figure out what's going on. The sample code seems straightforward and similar to the demo in pixi-cull. Do you know what's different from the demo project?

zhouccccc commented 3 years ago

there are no lots of differences. I think the only difference between them is that the demo show all sprites in the beginning, but my case is not. that's weird! Also If I remove the cull function, it works well. now I'm debugging the cull source code in my project

davidfig commented 3 years ago

What version of pixi-cull? If it's an older version, you could try: new Simple({ dirtyTest: false }) and see if that helps.

zhouccccc commented 3 years ago

So sorry I forgot it because we download the source code and use it as the local static js module before. But the latest version can also reproduce

davidfig commented 3 years ago

Hmm...try to call addList after you added your elements to the children (it shouldn't need this but worth a try).

zhouccccc commented 3 years ago

I didn't add all children to the viewport or cull at one time. The following is the rendering logic: image So how ( or where )do I do this action addList ?

davidfig commented 3 years ago

Maybe something like this (I'm guessing this is for a one-time render; you wouldn't want to recreate your scene on every frame like this for perf reasons):

  1. create and add all sprites to the viewport
  2. create a new cull (or remove old elements from cull)
  3. call addList to cull
  4. cull
  5. render
zhouccccc commented 3 years ago

Thanks for your tips, I have resolved this issue because I found my weird operation on creating some specific sprites . But my doubt is why I removed this module and then it can also works well. I will keep researching. (>‿◠)