@ignifx/physics-2d 0.9.0 → 0.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignifx/physics-2d",
3
- "version": "0.9.0",
3
+ "version": "0.11.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.9.0",
49
- "@ignifx/core": "0.9.0"
48
+ "@ignifx/2d": "0.11.0",
49
+ "@ignifx/core": "0.11.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@ignifx/2d": "0.9.0",
53
- "@ignifx/core": "0.9.0"
52
+ "@ignifx/2d": "0.11.0",
53
+ "@ignifx/core": "0.11.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.9.0"
6
+ ignifx-version: "0.11.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.9.0`; this package targets `@ignifx/core` `>=0.0.0 <1.0.0`.
27
+ - Engine: ignifx `0.11.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 data type, so a
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` | `collisionData` from a `Tilemap` |
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`,
@@ -132,7 +132,8 @@ Colliders share `offset`, `isTrigger`, `material` (a `.physicsmaterial.json` ass
132
132
  `groundNormal`, and `onCollided`.
133
133
 
134
134
  `app.physics2d` — `gravity`, `raycast`, `raycastAll`, `overlapCircle`, `overlapBox`, `shapeCast`,
135
- and `rapier` (the unstable escape hatch). Full signatures:
135
+ `colliderOutlines(entity)` (Rapier's drawing of each collider as world-space XY segments, for an
136
+ editor's gizmos), and `rapier` (the unstable escape hatch). Full signatures:
136
137
  `skills/ignifx/references/api/physics-2d.md`.
137
138
 
138
139
  ## Recipes
@@ -218,6 +219,27 @@ if (hit !== null) {
218
219
 
219
220
  ### Tilemap collision
220
221
 
222
+ Put `TilemapCollider2D` on the entity that holds the `Tilemap`, in a scene file or in code. It reads
223
+ that tilemap's `collisionData`, so a level loaded from a scene file collides with no code after
224
+ `loadScene`, and a tile edit (`tilemap.setTile`) reaches physics at the next fixed step.
225
+
226
+ ```ts
227
+ import { Tilemap } from "@ignifx/2d";
228
+ import { TilemapCollider2D } from "@ignifx/physics-2d";
229
+ import type { TilemapAsset } from "@ignifx/2d";
230
+ import type { App } from "@ignifx/core";
231
+
232
+ export function addLevel(app: App): void {
233
+ const level = app.world.createEntity("Level");
234
+ level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("level.tilemap.json");
235
+ level.addComponent(TilemapCollider2D);
236
+ }
237
+ ```
238
+
239
+ To use other geometry, such as data built in code or a tilemap on another entity, assign
240
+ `collisionData`. Assigning `null` goes back to the tilemap. The runtime rebuilds the shapes whenever
241
+ the data or its `version` changes.
242
+
221
243
  ```ts run
222
244
  import { createApp } from "@ignifx/core";
223
245
  import { physics2d, TilemapCollider2D } from "@ignifx/physics-2d";
@@ -249,10 +271,6 @@ collider.collisionData = {
249
271
  app.step(1 / 60);
250
272
  ```
251
273
 
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
274
  ## File formats
257
275
 
258
276
  `ignifx.physicsmaterial` — the **same** `.physicsmaterial.json` document 3D physics reads
@@ -295,6 +313,11 @@ Component field tables: `skills/ignifx/references/formats/components.md`.
295
313
  the authoritative pose. Everything outside the fixed loop — `update`, `lateUpdate`, animation,
296
314
  `Camera2DFollow`, rendering — sees the interpolated one, because the display pose is written at the
297
315
  top of `Update`. That is what keeps a follow camera locked to the sprite the frame actually draws.
316
+ - **In an edit-mode app (`createApp({ editMode: true })`) bodies exist but nothing simulates.**
317
+ Bodies are built, rebuilt, and removed as components and tiles change and follow every transform
318
+ the editor moves, so queries answer from the first frame. No fixed step runs: nothing falls, no
319
+ collision or trigger callback fires, and no simulated pose is written to a transform.
320
+ `colliderOutlines(entity)` gives an editor its collider gizmos, tile collision included.
298
321
 
299
322
  ## Deprecated (current window)
300
323