@gitborlando/geo 5.1.0 → 5.2.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.
package/dist/index.d.ts CHANGED
@@ -46,7 +46,16 @@ declare class OBB {
46
46
  x: number;
47
47
  y: number;
48
48
  }];
49
+ plain: () => {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ rotation: number;
55
+ center: IXY;
56
+ };
49
57
  clone: () => OBB;
58
+ shift: (delta: IXY) => this;
50
59
  projectAt: (anotherAxis: IXY) => number;
51
60
  collide: (another: OBB) => boolean;
52
61
  static identityOBB(): OBB;
package/dist/index.js CHANGED
@@ -279,7 +279,7 @@ var OBB = class _OBB {
279
279
  return XY.$(this.x, this.y);
280
280
  }
281
281
  #calcCenter = () => {
282
- const center = XY.center(this);
282
+ const center = XY.center(this).plus(this.xy);
283
283
  return center.rotate(this.xy, this.rotation);
284
284
  };
285
285
  #calcAxis = () => {
@@ -301,9 +301,31 @@ var OBB = class _OBB {
301
301
  const BL = XY.$(this.x - sinHeight, this.y + cosHeight);
302
302
  return this.vertexes = [TL, TR, BR, BL];
303
303
  };
304
+ plain = () => {
305
+ return {
306
+ x: this.x,
307
+ y: this.y,
308
+ width: this.width,
309
+ height: this.height,
310
+ rotation: this.rotation,
311
+ center: this.center
312
+ };
313
+ };
304
314
  clone = () => {
305
315
  return new _OBB(this.x, this.y, this.width, this.height, this.rotation);
306
316
  };
317
+ shift = (delta) => {
318
+ this.x += delta.x;
319
+ this.y += delta.y;
320
+ this.center.x += delta.x;
321
+ this.center.y += delta.y;
322
+ this.vertexes.forEach((vertex) => {
323
+ vertex.x += delta.x;
324
+ vertex.y += delta.y;
325
+ });
326
+ AABB.updateFromOBB(this.aabb, this);
327
+ return this;
328
+ };
307
329
  projectAt = (anotherAxis) => {
308
330
  const { widthAxis, heightAxis } = this.axis;
309
331
  return Math.abs(XY.dot(widthAxis, anotherAxis)) * this.width + Math.abs(XY.dot(heightAxis, anotherAxis)) * this.height;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitborlando/geo",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,15 +21,15 @@
21
21
  "author": "",
22
22
  "license": "ISC",
23
23
  "devDependencies": {
24
- "@vitest/ui": "^3.2.4",
25
- "vitest": "^3.2.4",
26
24
  "@changesets/cli": "^2.29.5",
27
25
  "@types/node": "^24.0.15",
28
- "husky": "^9.1.7",
26
+ "@vitest/ui": "^3.2.4",
29
27
  "pretty-quick": "^4.2.2",
30
28
  "tsup": "^8.5.0",
31
29
  "tsx": "^4.20.3",
32
- "typescript": "^5.8.3"
30
+ "typescript": "^5.8.3",
31
+ "vitest": "^3.2.4",
32
+ "simple-git-hooks": "^2.13.1"
33
33
  },
34
34
  "prettier": {
35
35
  "printWidth": 85,
@@ -40,10 +40,13 @@
40
40
  "singleQuote": true,
41
41
  "jsxSingleQuote": true
42
42
  },
43
+ "simple-git-hooks": {
44
+ "pre-commit": "npx pretty-quick --staged"
45
+ },
43
46
  "scripts": {
44
47
  "dev": "tsup --watch",
45
48
  "build": "tsup",
46
- "clean": "rm -rf node_modules pnpm-lock.yaml",
49
+ "re-i": "rm -rf node_modules pnpm-lock.yaml",
47
50
  "test": "vitest",
48
51
  "test:run": "vitest run",
49
52
  "test:ui": "vitest --ui"
package/src/obb.ts CHANGED
@@ -29,7 +29,7 @@ export class OBB {
29
29
  }
30
30
 
31
31
  #calcCenter = () => {
32
- const center = XY.center(this)
32
+ const center = XY.center(this).plus(this.xy)
33
33
  return center.rotate(this.xy, this.rotation)
34
34
  }
35
35
 
@@ -54,10 +54,34 @@ export class OBB {
54
54
  return (this.vertexes = [TL, TR, BR, BL])
55
55
  }
56
56
 
57
+ plain = () => {
58
+ return {
59
+ x: this.x,
60
+ y: this.y,
61
+ width: this.width,
62
+ height: this.height,
63
+ rotation: this.rotation,
64
+ center: this.center,
65
+ }
66
+ }
67
+
57
68
  clone = () => {
58
69
  return new OBB(this.x, this.y, this.width, this.height, this.rotation)
59
70
  }
60
71
 
72
+ shift = (delta: IXY) => {
73
+ this.x += delta.x
74
+ this.y += delta.y
75
+ this.center.x += delta.x
76
+ this.center.y += delta.y
77
+ this.vertexes.forEach((vertex) => {
78
+ vertex.x += delta.x
79
+ vertex.y += delta.y
80
+ })
81
+ AABB.updateFromOBB(this.aabb, this)
82
+ return this
83
+ }
84
+
61
85
  projectAt = (anotherAxis: IXY) => {
62
86
  const { widthAxis, heightAxis } = this.axis
63
87
  return (