Closed AdrienLemaire closed 3 years ago
Adding the stats will result in additional looping to find the number of culled objects. Since that's mostly used for debug purposes, I'm going to leave it as is. I will add an optional callback for non-culled objects to the cull function.
Published as v1.1.0.
@davidfig I'm having issues installing that latest version
$ npm install pixi-cull@1.1.0 -E
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: pixi.js@6.0.0
npm ERR! node_modules/pixi.js
npm ERR! peer pixi.js@">=4.6.0" from pixi-viewport@4.22.0
npm ERR! node_modules/pixi-viewport
npm ERR! pixi-viewport@"4.22.0" from the root project
npm ERR! pixi.js@"6.0.0" from pixi.js-legacy@6.0.0
npm ERR! node_modules/pixi.js-legacy
npm ERR! pixi.js-legacy@"6.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! pixi-cull@"1.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: pixi.js@5.3.9
npm ERR! node_modules/pixi.js
npm ERR! peer pixi.js@"^5.0.0-rc.2" from pixi-cull@1.1.0
npm ERR! node_modules/pixi-cull
npm ERR! pixi-cull@"1.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Since you didn't create a git tag for v1.0.1, it's difficult to debug what has changed between the versions. Could you also add the callback param to the cull() type ? https://github.com/davidfig/pixi-cull/blob/master/%40types/index.d.ts#L93
Hmm..I updated the types in v1.1.1.
I'm not sure what's going on with your npm install. I just installed piix.js pixi-viewport and pixi-cull to a clean project and I didn't get any errors. You might want to delete your lock file and node_modules directory and reinstall everything. That sometimes cleans stuff out.
closing since this was completed. I ended up not using it because this function is called before setting object.visible=true
, and I need to know this value in my callback.
After culling non-visible sprites, I do other operations like calling
stats()
andqueryCallback()
.When reading the code, I realize that the O(n^2) double-for loop operation is repeated 3 times (in cull(), queryCallback() and stats()).
Could we have a
callback
option tocull()
, and maybe return stats including lastBuckets ? The children would be looped only once in that case, and my code would look like: