Skip to content

Commit

Permalink
feat: system create generic type
Browse files Browse the repository at this point in the history
  • Loading branch information
Prozi committed Nov 1, 2024
1 parent 6cff6b1 commit ee73508
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 51 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Detect-Collisions 💫 is a lightning-fast ⚡️ TypeScript library built to de
## Installation

```bash
$ npm i detect-collisions --save
npm i detect-collisions --save
```

## API Documentation
Expand Down Expand Up @@ -48,7 +48,7 @@ Bodies possess various properties:
- **AABB Bounding Box**: Use `aabb: BBox` for inserted or `getAABBAsBBox(): BBox` for non inserted bodies to get the bounding box.
- **Padding**: Use `padding: number` and set to nonzero value to reduce costly reinserts on attributes' change.
- **Collision Filtering**: Use `group: number` for collision filtering, with a range within 0x0 ~ 0x7fffffff.
- **Body Options**: Use `isStatic: boolean` to mark body as non movable and `isTrigger: boolean` to set body as ghost. Use `userData` option to pass any custom data to your body.
- **Body Options**: [Read more in BodyOptions documentation](https://prozi.github.io/detect-collisions/interfaces/BodyOptions.html)

### Step 3: Create and Manage Bodies

Expand Down Expand Up @@ -190,9 +190,9 @@ While physics engines like [Matter-js](https://github.com/liabru/matter-js) or [
This will provide you with the results of both the insertion test benchmark and a headless [Stress Demo](https://prozi.github.io/detect-collisions/demo/?stress) benchmark, featuring moving bodies, with increasing amounts in each step.

```bash
$ git clone https://github.com/Prozi/detect-collisions.git
$ cd detect-collisions
$ npm i && npm run build # will build & run tests & run benchmarks
git clone https://github.com/Prozi/detect-collisions.git
cd detect-collisions
npm i && npm run build # will build & run tests & run benchmarks
```

## License
Expand All @@ -201,4 +201,4 @@ MIT

## You can buy me a coffee

https://paypal.me/jacekpietal
<https://paypal.me/jacekpietal>
12 changes: 6 additions & 6 deletions dist/base-system.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ export declare class BaseSystem<TBody extends Body = Body> extends RBush impleme
/**
* create point at position with options and add to system
*/
createPoint(position: PotentialVector, options?: BodyOptions): Point;
createPoint<TPoint extends Point>(position: PotentialVector, options?: BodyOptions): TPoint;
/**
* create line at position with options and add to system
*/
createLine(start: Vector, end: Vector, options?: BodyOptions): Line;
createLine<TLine extends Line>(start: Vector, end: Vector, options?: BodyOptions): TLine;
/**
* create circle at position with options and add to system
*/
createCircle(position: PotentialVector, radius: number, options?: BodyOptions): Circle;
createCircle<TCircle extends Circle>(position: PotentialVector, radius: number, options?: BodyOptions): TCircle;
/**
* create box at position with options and add to system
*/
createBox(position: PotentialVector, width: number, height: number, options?: BodyOptions): Box;
createBox<TBox extends Box>(position: PotentialVector, width: number, height: number, options?: BodyOptions): TBox;
/**
* create ellipse at position with options and add to system
*/
createEllipse(position: PotentialVector, radiusX: number, radiusY?: number, step?: number, options?: BodyOptions): Ellipse;
createEllipse<TEllipse extends Ellipse>(position: PotentialVector, radiusX: number, radiusY?: number, step?: number, options?: BodyOptions): TEllipse;
/**
* create polygon at position with options and add to system
*/
createPolygon(position: PotentialVector, points: PotentialVector[], options?: BodyOptions): Polygon;
createPolygon<TPolygon extends Polygon>(position: PotentialVector, points: PotentialVector[], options?: BodyOptions): TPolygon;
/**
* re-insert body into collision tree and update its bbox
* every body can be part of only one system
Expand Down
Loading

0 comments on commit ee73508

Please sign in to comment.