Skip to content

Commit

Permalink
fix: missing sat reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Jan Pietal committed Aug 7, 2022
1 parent 6b3a418 commit 3d50495
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction

**Detect-Collisions** is <s>JavaScript</s> TypeScript library for quickly and accurately detecting collisions between Points, Lines, Boxes, Polygons, Ellipses and Circles, also with rotation. It combines the efficiency of a [Bounding Volume Hierarchy](https://en.wikipedia.org/wiki/Bounding_volume_hierarchy) (BVH) for broad-phase searching and the accuracy of the [Separating Axis Theorem](https://en.wikipedia.org/wiki/Separating_axis_theorem) (SAT) for narrow-phase collision testing.
**Detect-Collisions** is TypeScript (compiled to JavaScript, fully typed) library for quickly and accurately detecting collisions between Points, Lines, Boxes, Polygons, Ellipses and Circles, also with rotation. It combines the efficiency of a [Bounding Volume Hierarchy](https://en.wikipedia.org/wiki/Bounding_volume_hierarchy) (BVH) for broad-phase searching and the accuracy of the [Separating Axis Theorem](https://en.wikipedia.org/wiki/Separating_axis_theorem) (SAT) for narrow-phase collision testing.

[<img src="https://img.shields.io/npm/v/detect-collisions?style=for-the-badge&color=success" alt="npm version" />](https://www.npmjs.com/package/detect-collisions?activeTab=versions)
[<img src="https://img.shields.io/npm/dw/detect-collisions.svg?style=for-the-badge&color=success" alt="npm downloads per week" />](https://www.npmjs.com/package/detect-collisions)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "detect-collisions",
"version": "6.3.3",
"version": "6.3.4",
"description": "2d collision detection for Points, Lines, Boxes, Polygons, Ellipses and Circles (with SAT and BVH)",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist && tsc",
"dev:demo": "webpack serve --port 4200",
"build:demo": "yarn build && webpack",
"build:demo": "webpack",
"build:docs": "rm -rf docs && yarn typedoc && yarn docs:postbuild",
"docs:postbuild": "cp dist/demo -r docs",
"docs": "yarn build:docs && chef-express docs --debug",
Expand Down
15 changes: 0 additions & 15 deletions src/system.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,4 @@ describe("GIVEN System", () => {
expectToBeNear(hit.point.y, 70, 10);
});
});

it("THEN getBounceDirection works correctly", () => {
const { System, getBounceDirection } = require("../dist/");

const physics = new System();
const circle = physics.createCircle({ x: 100, y: 100 }, 30);

physics.createCircle({ x: 120, y: 100 }, 30);
physics.checkOne(circle, ({ a, b }) => {
const bounce = getBounceDirection(a, b);

expect(bounce.x).toBe(-1);
expect(bounce.y).toBe(0);
});
});
});
1 change: 0 additions & 1 deletion src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
testCirclePolygon,
testPolygonCircle,
testPolygonPolygon,
Vector as SATVector,
} from "sat";

import { BaseSystem } from "./base-system";
Expand Down
18 changes: 16 additions & 2 deletions src/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const { Circle } = require("sat");
const { Line, intersectLineLine, intersectLineCircle } = require("../dist");
const {
Line,
Circle,
intersectLineLine,
intersectLineCircle,
getBounceDirection,
} = require("../dist");

describe("GIVEN Utils", () => {
it("THEN intersectLineLine should work", () => {
Expand All @@ -15,4 +20,13 @@ describe("GIVEN Utils", () => {

expect(intersectLineCircle(line1, circle1).length).toBe(2);
});

it("THEN getBounceDirection works correctly", () => {
const a = new Circle({ x: 100, y: 100 }, 30);
const b = new Circle({ x: 120, y: 100 }, 30);
const bounce = getBounceDirection(a, b);

expect(bounce.x).toBe(-1);
expect(bounce.y).toBe(0);
});
});
9 changes: 3 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
"moduleResolution": "node",
"target": "es2015",
"module": "none",
"outDir": "dist"
"outDir": "dist",
"types": []
},
"files": ["src/index.ts"],
"include": [
"src/**/*.ts",
"node_modules/sat/**/*.ts",
"node_modules/rbush/**/*.ts"
],
"include": ["src/**/*.ts"],
"exclude": ["**/*.spec.ts", "*.js"]
}

0 comments on commit 3d50495

Please sign in to comment.