Closed greenbech closed 11 months ago
I agree that this would be helpful. I could imagine methods to update/remove single shapes, and/or a static
flag on shapes (so they would not be affected by clear).
Due to the recursive nature, skipping the rebuild could result in nodes without objects, but the benefits should outweight that.
I forked and added the remove behavior
I refactored your code a bit and added tests and docs. In the simple example there are now "remove" buttons: https://timohausmann.github.io/quadtree-ts/examples/simple/
I also added a helper function "join" that can safely cleanup the vacant subnodes. This can be skipped with a "fast" flag.
Docs: https://timohausmann.github.io/quadtree-ts/documentation/classes/Quadtree.html#remove
If you have the time I'd be happy to hear your feedback.
npm install -S @timohausmann/quadtree-ts@latest
Alright fine, I will slap on an update method and example aswell:
https://timohausmann.github.io/quadtree-ts/examples/update/
https://timohausmann.github.io/quadtree-ts/documentation/classes/Quadtree.html#update
Please let me know if your issue isn't resolved.
Thanks for a great package - good documentation and a clean implementation!
I wonder if a remove/delete API for shapes is on the roadmap? In my intended usecase the world is mostly static, but sometimes a line it split in two. It seems like a waiste of resources to rebuild the entire datastructure when just one node is changed/deleted. What's your thoughts on that?