@newkrok/nape-js 3.5.3 → 3.6.2

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/README.md CHANGED
@@ -10,11 +10,11 @@
10
10
  [![bundle size](https://img.shields.io/badge/gzip-414%20KB-blue.svg)](https://github.com/NewKrok/nape-js)
11
11
  [![license](https://img.shields.io/npm/l/@newkrok/nape-js.svg)](https://github.com/NewKrok/nape-js/blob/master/LICENSE)
12
12
 
13
- Modern TypeScript wrapper for the [Nape](https://github.com/deltaluca/nape) 2D physics engine.
13
+ Fully typed, tree-shakeable 2D physics engine a complete TypeScript port of the
14
+ [Nape](https://github.com/deltaluca/nape) Haxe physics engine.
14
15
 
15
- - Original Haxe engine by Luca Deltodesco
16
- - JS compiler by Andrew Bradley ([nape-to-js](https://github.com/cspotcode/nape-to-js))
17
- - TypeScript wrapper by Istvan Krisztian Somoracz
16
+ - Originally created in Haxe by Luca Deltodesco
17
+ - Ported to TypeScript by Istvan Krisztian Somoracz
18
18
 
19
19
  ## Installation
20
20
 
@@ -55,29 +55,6 @@ function update() {
55
55
  }
56
56
  ```
57
57
 
58
- ### Before (v1) vs After (v2)
59
-
60
- ```javascript
61
- // v1 — raw Haxe API
62
- import initNape from "./js/libs/nape-js.module.js";
63
- initNape();
64
- const body = new nape.phys.Body(nape.phys.BodyType.get_DYNAMIC());
65
- body.get_shapes().add(new nape.shape.Polygon(nape.shape.Polygon.box(100, 100)));
66
- body.get_position().set_x(200);
67
- body.set_rotation(Math.PI / 2);
68
- body.set_space(space);
69
- ```
70
-
71
- ```typescript
72
- // v2 — TypeScript wrapper
73
- import { Body, BodyType, Polygon } from "@newkrok/nape-js";
74
- const body = new Body(BodyType.DYNAMIC);
75
- body.shapes.add(new Polygon(Polygon.box(100, 100)));
76
- body.position.x = 200;
77
- body.rotation = Math.PI / 2;
78
- body.space = space;
79
- ```
80
-
81
58
  ## API Reference
82
59
 
83
60
  ### Core Classes
@@ -86,8 +63,11 @@ body.space = space;
86
63
  |-------|-------------|
87
64
  | `Space` | Physics world — add bodies, step simulation |
88
65
  | `Body` | Rigid body with position, velocity, mass |
89
- | `Vec2` | 2D vector for positions, velocities, forces |
90
- | `AABB` | Axis-aligned bounding box |
66
+ | `Vec2` | 2D vector pooling, `clone()`, `equals()`, `lerp()`, `fromAngle()` |
67
+ | `Vec3` | 3D vector for constraint impulses — `clone()`, `equals()` |
68
+ | `AABB` | Axis-aligned bounding box — `clone()`, `equals()`, `fromPoints()` |
69
+ | `Mat23` | 2×3 affine matrix — `clone()`, `equals()`, transform, inverse |
70
+ | `Ray` | Raycasting — `clone()`, `fromSegment()`, spatial queries |
91
71
 
92
72
  ### Shapes
93
73
 
@@ -134,14 +114,15 @@ body.space = space;
134
114
  | Class | Description |
135
115
  |-------|-------------|
136
116
  | `NapeList<T>` | Iterable list with `for...of` support |
117
+ | `MatMN` | Variable-sized M×N matrix — `clone()`, `equals()`, multiply, transpose |
137
118
 
138
119
  ## Development
139
120
 
140
121
  ```bash
141
122
  npm install
142
- npm run build # Compile TypeScript + bundle
143
- npm test # Run tests (779 tests)
144
- npm run benchmark # Performance benchmarks
123
+ npm run build # tsup dist/ (ESM + CJS + DTS)
124
+ npm test # vitest — 2736 tests across 139 files
125
+ npm run benchmark # Performance benchmarks
145
126
  ```
146
127
 
147
128
  ## License