@newkrok/nape-js 3.7.6 → 3.8.1
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 +24 -1
- package/dist/ConvexResult-CYFNMlT2.d.cts +2690 -0
- package/dist/ConvexResult-CYFNMlT2.d.ts +2690 -0
- package/dist/chunk-3TXNIYBK.js +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +120 -2670
- package/dist/index.d.ts +120 -2670
- package/dist/index.js +1 -1
- package/dist/serialization/index.cjs +2 -0
- package/dist/serialization/index.d.cts +230 -0
- package/dist/serialization/index.d.ts +230 -0
- package/dist/serialization/index.js +2 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -116,12 +116,35 @@ function update() {
|
|
|
116
116
|
| `NapeList<T>` | Iterable list with `for...of` support |
|
|
117
117
|
| `MatMN` | Variable-sized M×N matrix — `clone()`, `equals()`, multiply, transpose |
|
|
118
118
|
|
|
119
|
+
### Serialization
|
|
120
|
+
|
|
121
|
+
Full physics state snapshot/restore — suitable for save/load, replay, and multiplayer
|
|
122
|
+
server↔client synchronization.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import "@newkrok/nape-js";
|
|
126
|
+
import { spaceToJSON, spaceFromJSON } from "@newkrok/nape-js/serialization";
|
|
127
|
+
|
|
128
|
+
// Serialize
|
|
129
|
+
const snapshot = spaceToJSON(space);
|
|
130
|
+
const json = JSON.stringify(snapshot);
|
|
131
|
+
|
|
132
|
+
// Restore (e.g. on another machine / after network transfer)
|
|
133
|
+
const restored = spaceFromJSON(JSON.parse(json));
|
|
134
|
+
restored.step(1 / 60);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The `/serialization` entry point is tree-shakeable — it does not pull in the engine
|
|
138
|
+
bootstrap when unused. The snapshot captures bodies, shapes, materials, interaction
|
|
139
|
+
filters, fluid properties, all constraint types (except `UserConstraint`), and compounds.
|
|
140
|
+
Arbiters and broadphase tree state are reconstructed automatically on the first step.
|
|
141
|
+
|
|
119
142
|
## Development
|
|
120
143
|
|
|
121
144
|
```bash
|
|
122
145
|
npm install
|
|
123
146
|
npm run build # tsup → dist/ (ESM + CJS + DTS)
|
|
124
|
-
npm test # vitest —
|
|
147
|
+
npm test # vitest — 3276 tests across 149 files
|
|
125
148
|
npm run benchmark # Performance benchmarks
|
|
126
149
|
```
|
|
127
150
|
|