@ue-too/dynamics 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/package.json +9 -10
  2. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/collision.js +0 -330
  3. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/collision.js.map +0 -1
  4. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/constraint.js +0 -166
  5. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/constraint.js.map +0 -1
  6. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/index.js +0 -4
  7. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/index.js.map +0 -1
  8. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/quadtree.js +0 -124
  9. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/quadtree.js.map +0 -1
  10. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/rigidbody.js +0 -476
  11. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/rigidbody.js.map +0 -1
  12. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/world.js +0 -90
  13. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/world.js.map +0 -1
  14. package/dist/collision.d.ts +0 -36
  15. package/dist/constraint.d.ts +0 -35
  16. package/dist/dynamics.tsbuildinfo +0 -1
  17. package/dist/index.d.ts +0 -3
  18. package/dist/package.json +0 -22
  19. package/dist/quadtree.d.ts +0 -26
  20. package/dist/rigidbody.d.ts +0 -252
  21. package/dist/world.d.ts +0 -29
  22. package/jest.config.js +0 -18
  23. package/project.json +0 -33
  24. package/rollup.config.js +0 -20
  25. package/src/collision.ts +0 -359
  26. package/src/constraint.ts +0 -245
  27. package/src/index.ts +0 -3
  28. package/src/quadtree.ts +0 -145
  29. package/src/rigidbody.ts +0 -640
  30. package/src/world.ts +0 -116
  31. package/test/rigidbody.test.ts +0 -10
  32. package/tsconfig.json +0 -21
  33. package/tsconfig.spec.json +0 -12
  34. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/collision.d.ts → collision.d.ts} +0 -0
  35. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/constraint.d.ts → constraint.d.ts} +0 -0
  36. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/dynamics.tsbuildinfo → dynamics.tsbuildinfo} +0 -0
  37. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/index.d.ts → index.d.ts} +0 -0
  38. /package/{dist/index.js → index.js} +0 -0
  39. /package/{dist/index.js.map → index.js.map} +0 -0
  40. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/quadtree.d.ts → quadtree.d.ts} +0 -0
  41. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/rigidbody.d.ts → rigidbody.d.ts} +0 -0
  42. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/dynamics/dist/world.d.ts → world.d.ts} +0 -0
package/src/world.ts DELETED
@@ -1,116 +0,0 @@
1
- import { BaseRigidBody, RigidBody } from "./rigidbody";
2
- import * as Collision from "./collision";
3
- import { RectangleBound, QuadTree} from "./quadtree"
4
- import { Point } from "@ue-too/math";
5
- import { Constraint } from "./constraint";
6
- import { PinJointConstraint, solvePinJointConstraint } from "./constraint";
7
-
8
- export class World {
9
- private rigidBodyList: RigidBody[];
10
- private rigidBodyMap: Map<string, RigidBody>;
11
- private _resolveCollision: boolean;
12
- private maxTransWidth: number;
13
- private maxTransHeight: number;
14
- private bound: RectangleBound;
15
- private quadTree: QuadTree;
16
- private constraints: Constraint[];
17
- private pinJoints: PinJointConstraint[] = [];
18
- _context: CanvasRenderingContext2D | null = null;
19
-
20
- constructor(maxTransWidth: number, maxTransHeight: number){
21
- this.maxTransHeight = maxTransHeight;
22
- this.maxTransWidth = maxTransWidth;
23
- this.bound = new RectangleBound({x: -this.maxTransWidth, y: -this.maxTransHeight}, 2 * this.maxTransWidth, 2 * this.maxTransHeight);
24
- this.quadTree = new QuadTree(0, this.bound);
25
- this.rigidBodyList = [];
26
- this.rigidBodyMap = new Map<string, RigidBody>();
27
- this._resolveCollision = true;
28
- this.constraints = [];
29
- }
30
-
31
- addRigidBody(ident: string, body: RigidBody): void{
32
- this.rigidBodyList.push(body);
33
- this.rigidBodyMap.set(ident, body);
34
- }
35
-
36
- removeRigidBody(ident: string): void{
37
- if (this.rigidBodyMap.has(ident)) {
38
- this.rigidBodyMap.delete(ident);
39
- }
40
- }
41
-
42
- step(deltaTime: number): void{
43
- if(this._resolveCollision){
44
- const contactPoints = this.resolveCollisionPhase();
45
- }
46
- // if(this._context != null){
47
- // this.quadTree.draw(this._context);
48
- // contactPoints.forEach((contactPoint) => {
49
- // if(this._context != null){
50
- // this._context.lineWidth = 1;
51
- // this._context.strokeStyle = "red";
52
- // }
53
- // this._context?.beginPath();
54
- // this._context?.arc(contactPoint.x, contactPoint.y, 3, 0, 2 * Math.PI);
55
- // this._context?.stroke();
56
- // });
57
- // }
58
- this.constraints.forEach(constraint => constraint.enforce(deltaTime));
59
- this.getRigidBodyList().forEach(rigidBody => {
60
- rigidBody.step(deltaTime);
61
- });
62
- }
63
-
64
- resolveCollisionPhase(): Point[]{
65
- let rigidBodyList: RigidBody[] = [];
66
- this.quadTree.clear();
67
- this.rigidBodyMap.forEach((body) => {
68
- rigidBodyList.push(body);
69
- this.quadTree.insert(body);
70
- });
71
- // console.log("quadtree size: ", this.quadTree);
72
- let possibleCombinations = Collision.broadPhaseWithRigidBodyReturned(this.quadTree, rigidBodyList);
73
- let contactPoints = Collision.narrowPhaseWithRigidBody(rigidBodyList, possibleCombinations, this._resolveCollision);
74
- return contactPoints;
75
- }
76
-
77
- get resolveCollision(): boolean{
78
- return this._resolveCollision;
79
- }
80
-
81
- set resolveCollision(resolveCollision: boolean){
82
- this._resolveCollision = resolveCollision;
83
- }
84
-
85
- getRigidBodyList(){
86
- let rigidBodyList:RigidBody[] = [];
87
- this.rigidBodyMap.forEach((body) => {
88
- rigidBodyList.push(body);
89
- })
90
- return rigidBodyList;
91
- }
92
-
93
- getRigidBodyMap(): Map<string, RigidBody>{
94
- return this.rigidBodyMap;
95
- }
96
-
97
- setMaxTransHeight(height: number){
98
- this.maxTransHeight = height;
99
- }
100
-
101
- setMaxTransWidth(width: number){
102
- this.maxTransWidth = width;
103
- }
104
-
105
- addConstraint(constraint: Constraint): void{
106
- this.constraints.push(constraint);
107
- }
108
-
109
- getConstraints(): Constraint[]{
110
- return this.constraints;
111
- }
112
-
113
- addPinJoint(bodyA: RigidBody, bodyB: RigidBody, anchorA: Point, anchorB: Point) {
114
- this.pinJoints.push({ bodyA, bodyB, anchorA, anchorB });
115
- }
116
- }
@@ -1,10 +0,0 @@
1
- import { Polygon } from "../src/rigidbody";
2
-
3
- describe("Polygon Rigidbody", ()=>{
4
-
5
-
6
- test("Initializing a polygon rigidbody", ()=>{
7
- const testPolygon = new Polygon({x: 0, y: 0}, [{x: 10, y: 10}, {x: -10, y: 10}, {x: -10, y: -10}, {x: 10, y: -10}]);
8
-
9
- })
10
- });
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "baseUrl": ".",
6
- "outDir": "dist",
7
- "tsBuildInfoFile": "dist/dynamics.tsbuildinfo",
8
- "declaration": true,
9
- "module": "ESNext",
10
- "moduleResolution": "node"
11
- },
12
- "include": [
13
- "src/**/*"
14
- ],
15
- "references": [
16
- {
17
- "path": "../math"
18
- }
19
- ]
20
- }
21
-
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "baseUrl": ".",
6
- "outDir": "dist",
7
- "tsBuildInfoFile": "dist/dynamics.tsbuildinfo",
8
- "declaration": true
9
- },
10
- "include": ["test/**/*"]
11
- }
12
-
File without changes
File without changes