Releases: Prozi/detect-collisions
v9.24.0
added another simpler live online js edit https://code.pietal.dev/#/boilerplate/detect-collisions?pans=html,console to links in readme
added Usage in Browsers readme section
added explanation of third parameter in https://github.com/Prozi/detect-collisions?tab=readme-ov-file#raycasting System.raycast
v9.20.0
You can provide custom class to body create functions:
import { System, Polygon } from "detect-collisions";
const physics = new System();
class MyPolygon extends Polygon {
constructor(position, points, options) {
super(position, points, options);
this.foo = "bar";
}
}
// create minimal MyPolygon and insert to system
const myPolygon = physics.createPolygon({}, [{}], {}, MyPolygon);
// true
console.log(myPolygon.foo === "bar");
});
this may be useful for any customizations
last optional parameter of system.create*
is a class that extends the base class (extends Box for createBox, extends Circle for createCircle, etc.)
v9.18.1
You can now add body.userData
of any
type during creation or runtime.
You can type it throught body generic if you need to. UserDataType
in each body is
Body<UserDataType = any> { userData?: UserDataType }
- merged #84
- added tests
- more strict lint code rules
- removed prettier
- added short readme note about userData
next I will work on
in the next days - to use this
v9.17.0
v9.16.0
v9.11.1
we got faster! 🔥
added a few magical improvements, and improved naming of params in docs
this is a benchmark from few commits before:
https://app.circleci.com/pipelines/github/Prozi/detect-collisions/415/workflows/e6f86657-f364-4ce8-b983-f4f0864fe8cb/jobs/360
> detect-collisions@9.9.4 benchmark-stress
> node -r pixi-shim -e 'import("./dist/benchmarks/index.js").then(({ stressBenchmark }) => stressBenchmark());'
┌─────────┬────────────────────────────┬─────────┬────────────────────┬───────────┬─────────┐
│ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├─────────┼────────────────────────────┼─────────┼────────────────────┼───────────┼─────────┤
│ 0 │ 'stress test, items=1000' │ '126' │ 7923593.826771655 │ '±10.14%' │ 127 │
│ 1 │ 'stress test, items=2000' │ '51' │ 19304634.250000007 │ '±6.36%' │ 52 │
│ 2 │ 'stress test, items=3000' │ '31' │ 32114035.15624994 │ '±5.62%' │ 32 │
│ 3 │ 'stress test, items=4000' │ '19' │ 52447966.149999954 │ '±5.82%' │ 20 │
│ 4 │ 'stress test, items=5000' │ '11' │ 84901515.83333318 │ '±4.76%' │ 12 │
│ 5 │ 'stress test, items=6000' │ '9' │ 109472182.69999993 │ '±2.74%' │ 10 │
│ 6 │ 'stress test, items=7000' │ '7' │ 135961302.60000008 │ '±2.22%' │ 10 │
│ 7 │ 'stress test, items=8000' │ '6' │ 159949840.89999998 │ '±3.67%' │ 10 │
│ 8 │ 'stress test, items=9000' │ '4' │ 200536707.80000103 │ '±1.54%' │ 10 │
│ 9 │ 'stress test, items=10000' │ '4' │ 221228030.29999924 │ '±6.09%' │ 10 │
└─────────┴────────────────────────────┴─────────┴────────────────────┴───────────┴─────────┘
Done in 72.83s.
this is after changes:
https://app.circleci.com/pipelines/github/Prozi/detect-collisions/421/workflows/6e76f81f-fee6-4d6c-87e0-923e2880fbdc/jobs/367
> detect-collisions@9.11.1 benchmark-stress
> node -r pixi-shim -e 'import("./dist/benchmarks/index.js").then(({ stressBenchmark }) => stressBenchmark());'
┌─────────┬────────────────────────────┬─────────┬────────────────────┬──────────┬─────────┐
│ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├─────────┼────────────────────────────┼─────────┼────────────────────┼──────────┼─────────┤
│ 0 │ 'stress test, items=1000' │ '149' │ 6681088.626666648 │ '±4.34%' │ 150 │
│ 1 │ 'stress test, items=2000' │ '59' │ 16753291.399999958 │ '±3.63%' │ 60 │
│ 2 │ 'stress test, items=3000' │ '28' │ 35010410.27586203 │ '±7.12%' │ 29 │
│ 3 │ 'stress test, items=4000' │ '19' │ 51137117.60000001 │ '±4.03%' │ 20 │
│ 4 │ 'stress test, items=5000' │ '11' │ 86016739.83333315 │ '±5.20%' │ 12 │
│ 5 │ 'stress test, items=6000' │ '8' │ 111907240.60000011 │ '±2.89%' │ 10 │
│ 6 │ 'stress test, items=7000' │ '7' │ 138337668.09999943 │ '±3.13%' │ 10 │
│ 7 │ 'stress test, items=8000' │ '6' │ 149393420.39999992 │ '±2.25%' │ 10 │
│ 8 │ 'stress test, items=9000' │ '4' │ 205487630.59999982 │ '±4.38%' │ 10 │
│ 9 │ 'stress test, items=10000' │ '4' │ 208027424.3000007 │ '±2.54%' │ 10 │
└─────────┴────────────────────────────┴─────────┴────────────────────┴──────────┴─────────┘
Done in 76.81s.
values of course fluctuate but believe me we should be more performant by like 4%