davidfig / pixi-cull

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

Culling seems not working #8

Closed zhouccccc closed 4 years ago

zhouccccc commented 4 years ago

Hi, I created a map with pixi.js and this plugin. As the picture shown I create lots of points, each point is PIXI.Container (some sprites inside it ) image

According to the document, the less points shown, the higher the map rendering performance. but when I zoomed the map and let less points shown, I found that rendering performance has not improved (the FPS is low). I also log the culling image

I believe this is a problem with my usage. The following is my code:

  const cull = new Simple({ calculatePIXI: true });
  cull.addList(viewport.children);
  cull.cull(viewport.getVisibleBounds());

  const callRender = () => {
    if (viewport.dirty) {
      cull.cull(viewport.getVisibleBounds());
      viewport.dirty = false;
      console.log(cull.stats());
    }
    renderer.render(viewport);
  };
  viewport.on('moved', callRender);

the function callRender is used for re-render map manually.

Could you please help me resolve this?

davidfig commented 4 years ago

The code looks right. The culling results also look okay (although I guess you can count to find out for sure). Have you tried turning off culling and render 1300 objects? The performance problem may be with how you set up your objects instead of the culling. Culling doesn't guarantee good performance.

zhouccccc commented 4 years ago

I tried turning off culling and render 1300 object just now, it seems okay. Maybe you are right, I will do some research on how to properly set up an object. Thank you