@ignifx/physics-2d 0.8.0 → 0.10.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 +25 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -20
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/skills/physics-2d/SKILL.md +36 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignifx/physics-2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "ignifx 2D physics: Rigidbody2D, 2D colliders, CharacterController2D, queries.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ignifx",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"typedoc-plugin-markdown": "^4.13.0",
|
|
46
46
|
"typescript-native": "npm:typescript@7.0.2",
|
|
47
47
|
"vitest": "^5.0.0",
|
|
48
|
-
"@ignifx/2d": "0.
|
|
49
|
-
"@ignifx/core": "0.
|
|
48
|
+
"@ignifx/2d": "0.10.0",
|
|
49
|
+
"@ignifx/core": "0.10.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@ignifx/2d": "0.
|
|
53
|
-
"@ignifx/core": "0.
|
|
52
|
+
"@ignifx/2d": "0.10.0",
|
|
53
|
+
"@ignifx/core": "0.10.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@ignifx/2d": {
|
|
@@ -3,7 +3,7 @@ name: physics-2d
|
|
|
3
3
|
description: Adds 2D physics to an ignifx game with @ignifx/physics-2d: Rapier 2D simulation on the fixed loop, Rigidbody2D, box/circle/capsule/polygon/edge/tilemap colliders, physics materials, 2D triggers, CharacterController2D with slopes, autostep, snap-to-ground and one-way platforms, 2D raycasts and shape queries, the collision layer matrix, and render interpolation. Use when adding or editing 2D physics bodies, 2D colliders, platformer movement, 2D triggers, or 2D queries in an ignifx project, or when the user mentions @ignifx/physics-2d, Rigidbody2D, Rapier, or CharacterController2D.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
|
-
ignifx-version: "0.
|
|
6
|
+
ignifx-version: "0.10.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# @ignifx/physics-2d
|
|
@@ -24,10 +24,10 @@ A world uses **either** `physics()` **or** `physics2d()`. Registering both throw
|
|
|
24
24
|
|
|
25
25
|
## Environment
|
|
26
26
|
|
|
27
|
-
- Engine: ignifx `0.
|
|
27
|
+
- Engine: ignifx `0.10.0`; this package targets `@ignifx/core` `>=0.0.0 <1.0.0`.
|
|
28
28
|
- Dependency: `@dimforge/rapier2d-compat` `^0.20.0`. The `-compat` build **inlines** its WebAssembly
|
|
29
29
|
as base64, so nothing has to be served and Node, the browser, and Electron all take the same path.
|
|
30
|
-
- `@ignifx/2d` is an **optional** peer: you need it only for `TilemapCollider2D`'s
|
|
30
|
+
- `@ignifx/2d` is an **optional** peer: you need it only for `TilemapCollider2D`'s tilemap, so a
|
|
31
31
|
game that draws its own graphics can use 2D physics on its own.
|
|
32
32
|
- Register it like any extension; nothing happens at import time.
|
|
33
33
|
|
|
@@ -117,14 +117,14 @@ means "weigh the colliders at 1 kg/m²"), `gravityScale`, `linearDamping`, `angu
|
|
|
117
117
|
Colliders share `offset`, `isTrigger`, `material` (a `.physicsmaterial.json` asset), the
|
|
118
118
|
`inlineMaterial` fallback, `frictionCombine` / `restitutionCombine`, `oneWay`, and `layerOverride`:
|
|
119
119
|
|
|
120
|
-
| Collider | Geometry
|
|
121
|
-
| ------------------- |
|
|
122
|
-
| `BoxCollider2D` | `size` — an axis-aligned rectangle
|
|
123
|
-
| `CircleCollider2D` | `radius`; the larger scale axis wins
|
|
124
|
-
| `CapsuleCollider2D` | `radius`, `height` (tip to tip), `direction` (`"x" \| "y"`)
|
|
125
|
-
| `PolygonCollider2D` | `points` → the **convex hull** of the list
|
|
126
|
-
| `EdgeCollider2D` | `points` → an open chain; infinitely thin
|
|
127
|
-
| `TilemapCollider2D` | `
|
|
120
|
+
| Collider | Geometry |
|
|
121
|
+
| ------------------- | ------------------------------------------------------------- |
|
|
122
|
+
| `BoxCollider2D` | `size` — an axis-aligned rectangle |
|
|
123
|
+
| `CircleCollider2D` | `radius`; the larger scale axis wins |
|
|
124
|
+
| `CapsuleCollider2D` | `radius`, `height` (tip to tip), `direction` (`"x" \| "y"`) |
|
|
125
|
+
| `PolygonCollider2D` | `points` → the **convex hull** of the list |
|
|
126
|
+
| `EdgeCollider2D` | `points` → an open chain; infinitely thin |
|
|
127
|
+
| `TilemapCollider2D` | the `Tilemap` on the same entity, or assigned `collisionData` |
|
|
128
128
|
|
|
129
129
|
`CharacterController2D` — `shape` (`"capsule" | "box"`), `radius`, `height`, `offset`, `slopeLimit`
|
|
130
130
|
(degrees), `stepOffset`, `snapToGround`, `skinWidth`, `onOneWayPlatforms`, `pushBodies`,
|
|
@@ -218,6 +218,27 @@ if (hit !== null) {
|
|
|
218
218
|
|
|
219
219
|
### Tilemap collision
|
|
220
220
|
|
|
221
|
+
Put `TilemapCollider2D` on the entity that holds the `Tilemap`, in a scene file or in code. It reads
|
|
222
|
+
that tilemap's `collisionData`, so a level loaded from a scene file collides with no code after
|
|
223
|
+
`loadScene`, and a tile edit (`tilemap.setTile`) reaches physics at the next fixed step.
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
import { Tilemap } from "@ignifx/2d";
|
|
227
|
+
import { TilemapCollider2D } from "@ignifx/physics-2d";
|
|
228
|
+
import type { TilemapAsset } from "@ignifx/2d";
|
|
229
|
+
import type { App } from "@ignifx/core";
|
|
230
|
+
|
|
231
|
+
export function addLevel(app: App): void {
|
|
232
|
+
const level = app.world.createEntity("Level");
|
|
233
|
+
level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("level.tilemap.json");
|
|
234
|
+
level.addComponent(TilemapCollider2D);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
To use other geometry, such as data built in code or a tilemap on another entity, assign
|
|
239
|
+
`collisionData`. Assigning `null` goes back to the tilemap. The runtime rebuilds the shapes whenever
|
|
240
|
+
the data or its `version` changes.
|
|
241
|
+
|
|
221
242
|
```ts run
|
|
222
243
|
import { createApp } from "@ignifx/core";
|
|
223
244
|
import { physics2d, TilemapCollider2D } from "@ignifx/physics-2d";
|
|
@@ -249,10 +270,6 @@ collider.collisionData = {
|
|
|
249
270
|
app.step(1 / 60);
|
|
250
271
|
```
|
|
251
272
|
|
|
252
|
-
Assign `tilemap.collisionData` from `@ignifx/2d` instead of building it by hand. The runtime watches
|
|
253
|
-
the data's `version` every fixed step and rebuilds the shapes when it changes, so a tile edit reaches
|
|
254
|
-
physics with no subscription of your own.
|
|
255
|
-
|
|
256
273
|
## File formats
|
|
257
274
|
|
|
258
275
|
`ignifx.physicsmaterial` — the **same** `.physicsmaterial.json` document 3D physics reads
|
|
@@ -295,6 +312,10 @@ Component field tables: `skills/ignifx/references/formats/components.md`.
|
|
|
295
312
|
the authoritative pose. Everything outside the fixed loop — `update`, `lateUpdate`, animation,
|
|
296
313
|
`Camera2DFollow`, rendering — sees the interpolated one, because the display pose is written at the
|
|
297
314
|
top of `Update`. That is what keeps a follow camera locked to the sprite the frame actually draws.
|
|
315
|
+
- **In an edit-mode app (`createApp({ editMode: true })`) nothing simulates.** No fixed step runs, so
|
|
316
|
+
no body is built, nothing falls, interpolation never touches a transform, and a query throws
|
|
317
|
+
`IGX-1153` as it does before a game's first step. Draw collider gizmos from the component fields;
|
|
318
|
+
`TilemapCollider2D.collisionData` still reads the tilemap, so tile outlines can be drawn too.
|
|
298
319
|
|
|
299
320
|
## Deprecated (current window)
|
|
300
321
|
|