https://github.com/schteppe/sweep-and-prune
2D collision detection for AABBs
https://github.com/schteppe/sweep-and-prune
collision-detection
Last synced: 20 days ago
JSON representation
2D collision detection for AABBs
- Host: GitHub
- URL: https://github.com/schteppe/sweep-and-prune
- Owner: schteppe
- License: mit
- Created: 2018-08-01T09:00:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-01T09:55:18.000Z (over 6 years ago)
- Last Synced: 2025-02-09T22:41:18.578Z (2 months ago)
- Topics: collision-detection
- Language: HTML
- Homepage: https://schteppe.github.io/sweep-and-prune/
- Size: 9.77 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sweep-and-prune
Incremental 2D sweep and prune collision detection for JavaScript.
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=Z2G8VHLDJ9N3L&lc=GB&item_name=Stefan%20Hedman&item_number=schteppe¤cy_code=USD&bn=PP%2dDonationsBF%3aDonate%2dPayPal%2dgreen%2esvg%3aNonHosted)
## Installation
(TODO)
## Documentation
### Constructor
```js
var sap = new SweepAndPrune();
```### .addObject
```js
var data = { foo: "bar" };
var x0 = 0;
var y0 = 1;
var x1 = 2;
var y1 = 3;
var box = sap.addObject(x0,y0,x1,y1,data);
```### .updateObject
```js
var x0 = 0;
var y0 = 1;
var x1 = 2;
var y1 = 3;
sap.updateObject(box,x0,y0,x1,y1);
```### .removeObject
```js
sap.removeObject(box);
```### .onadd
```js
sap.onadd = function(boxA, boxB){
// Do something with boxA.userData or boxB.userData
};
```### .onremove
```js
sap.onremove = function(boxA, boxB){
// Do something with boxA.userData or boxB.userData
};
```