@ignifx/physics-2d 0.2.0 → 0.2.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/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -14
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/skills/physics-2d/SKILL.md +21 -2
package/dist/index.d.ts
CHANGED
|
@@ -779,6 +779,10 @@ export declare class CharacterController2D extends Component implements Componen
|
|
|
779
779
|
/**
|
|
780
780
|
* Emitted once per obstacle the character hit during a step.
|
|
781
781
|
*
|
|
782
|
+
* @remarks
|
|
783
|
+
* Trigger colliders are not obstacles — the character walks straight through them — so a sensor
|
|
784
|
+
* never appears here. Listen for `onTriggerEnter`/`onTriggerExit` on the entity's scripts instead.
|
|
785
|
+
*
|
|
782
786
|
* @returns The signal, created on first access.
|
|
783
787
|
*/
|
|
784
788
|
get onCollided(): Signal<CharacterCollision2D>;
|
|
@@ -1446,7 +1450,7 @@ declare class Physics2DRuntime {
|
|
|
1446
1450
|
teleportController(component: CharacterController2D, position: Vec2Like): void;
|
|
1447
1451
|
/**
|
|
1448
1452
|
* Restores the authoritative pose of every interpolated body, undoing the display pose the
|
|
1449
|
-
* `
|
|
1453
|
+
* `Update` system wrote at the top of the previous frame's `Update` (`09-physics.md` §1).
|
|
1450
1454
|
*/
|
|
1451
1455
|
restorePoses(): void;
|
|
1452
1456
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/settings.ts","../src/material.ts","../src/lite/rapier/world.ts","../src/components/collider.ts","../src/events.ts","../src/components/rigidbody.ts","../src/components/character-controller.ts","../src/components/colliders.ts","../src/components/tilemap-collider.ts","../src/errors.ts","../src/queries.ts","../src/runtime/body-record.ts","../src/runtime/runtime.ts","../src/runtime/host.ts","../src/service.ts","../src/extension.ts","../src/schemas.ts"],"mappings":";;;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;;;;;;MASA,gBAAgB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/settings.ts","../src/material.ts","../src/lite/rapier/world.ts","../src/components/collider.ts","../src/events.ts","../src/components/rigidbody.ts","../src/components/character-controller.ts","../src/components/colliders.ts","../src/components/tilemap-collider.ts","../src/errors.ts","../src/queries.ts","../src/runtime/body-record.ts","../src/runtime/runtime.ts","../src/runtime/host.ts","../src/service.ts","../src/extension.ts","../src/schemas.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAiBa;;;;;;UAOI;;WAEN;;WAEA;;;;;;;;;;;;;;;;;;;UAoBM;;WAEN,SAAS;;;;;WAKT,iBAAiB,SAAS;;WAE1B,iBAAiB;;WAEjB;;WAEA;;;;;;;;;;;;;wBAuBK,2BAA2B;;;;;;;;wBAoB3B,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;qBC9E/B;;;;;;qBAOA;;;;;;qBAOA;;;;;;qBAOA;;;;;;;;;;;;qBAaA,6BAA6B;;SAEjC;;WAGE;;WAGA;;WAGA;;;;;;;EAQT,YAAY,cAAc,QAAQ;;;;;;;;;;;;;SAkB3B,WAAW,cAAc,QAAQ,QAAQ,2BAA2B;;;;;;;;;wBAe7D,iCAAiC,YAAY;;;;;;;;;;;wBAqB7C,uBAAuB,iBAAiB,UAAU,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;KCzFlE,cAAc;;;;;;KAOd,aAAa;;;;;;KAOb,iBAAiB;;;;;;cAchB;;WAEX;;WAEA;;WAEA;;;;;;;KAQU,uBAAuB,2BAA2B;;;;;;KA+BlD;WACG;WAAsB;WAA4B;;WAClD;WAAyB;;WACzB;WAA0B;WAA6B;;WACvD;WAA0B,QAAQ;;WAClC;WAA2B,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCnFrC;;;;;;KAOD,sBAAsB;;;;;;UAOjB;;WAEN,OAAO;;WAEP,QAAQ;;WAER;;WAEA;;;;;;;;;wBAUK,oBAAo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e"}
|
package/dist/index.js
CHANGED
|
@@ -349,6 +349,10 @@ var CharacterController2D = class CharacterController2D extends Component {
|
|
|
349
349
|
/**
|
|
350
350
|
* Emitted once per obstacle the character hit during a step.
|
|
351
351
|
*
|
|
352
|
+
* @remarks
|
|
353
|
+
* Trigger colliders are not obstacles — the character walks straight through them — so a sensor
|
|
354
|
+
* never appears here. Listen for `onTriggerEnter`/`onTriggerExit` on the entity's scripts instead.
|
|
355
|
+
*
|
|
352
356
|
* @returns The signal, created on first access.
|
|
353
357
|
*/
|
|
354
358
|
get onCollided() {
|
|
@@ -2024,6 +2028,12 @@ var Physics2DHost = class {
|
|
|
2024
2028
|
//#endregion
|
|
2025
2029
|
//#region src/lite/rapier/character.ts
|
|
2026
2030
|
/**
|
|
2031
|
+
* The obstacle filter every controller move uses. Sensors describe regions, not geometry, so they
|
|
2032
|
+
* are excluded from collide-and-slide; the pair is still reported by the world step, which is where
|
|
2033
|
+
* `onTriggerEnter`/`onTriggerExit` come from.
|
|
2034
|
+
*/
|
|
2035
|
+
const OBSTACLE_FLAGS = QueryFilterFlags.EXCLUDE_SENSORS;
|
|
2036
|
+
/**
|
|
2027
2037
|
* Creates a character controller.
|
|
2028
2038
|
*
|
|
2029
2039
|
* @param world - The world.
|
|
@@ -2071,6 +2081,10 @@ function tuneController(controller, tuning) {
|
|
|
2071
2081
|
/**
|
|
2072
2082
|
* Runs one collide-and-slide move.
|
|
2073
2083
|
*
|
|
2084
|
+
* @remarks
|
|
2085
|
+
* Sensors are excluded from the obstacle set ({@link OBSTACLE_FLAGS}), so a character walks into and
|
|
2086
|
+
* out of a trigger volume at full speed and the world step raises the intersection events.
|
|
2087
|
+
*
|
|
2074
2088
|
* @param controller - The controller.
|
|
2075
2089
|
* @param collider - The character's own collider.
|
|
2076
2090
|
* @param desired - The displacement to attempt, in metres.
|
|
@@ -2085,11 +2099,11 @@ function computeControllerMovement(controller, collider, desired, groups, filter
|
|
|
2085
2099
|
if (filter === null) controller.computeColliderMovement(collider, {
|
|
2086
2100
|
x: desired.x,
|
|
2087
2101
|
y: desired.y
|
|
2088
|
-
},
|
|
2102
|
+
}, OBSTACLE_FLAGS, groups);
|
|
2089
2103
|
else controller.computeColliderMovement(collider, {
|
|
2090
2104
|
x: desired.x,
|
|
2091
2105
|
y: desired.y
|
|
2092
|
-
},
|
|
2106
|
+
}, OBSTACLE_FLAGS, groups, filter);
|
|
2093
2107
|
controller.computedMovement(out);
|
|
2094
2108
|
return controller.computedGrounded();
|
|
2095
2109
|
}
|
|
@@ -2430,7 +2444,7 @@ var Physics2DRuntime = class {
|
|
|
2430
2444
|
}
|
|
2431
2445
|
/**
|
|
2432
2446
|
* Restores the authoritative pose of every interpolated body, undoing the display pose the
|
|
2433
|
-
* `
|
|
2447
|
+
* `Update` system wrote at the top of the previous frame's `Update` (`09-physics.md` §1).
|
|
2434
2448
|
*/
|
|
2435
2449
|
restorePoses() {
|
|
2436
2450
|
for (let index = 0; index < this.#records.length; index += 1) {
|
|
@@ -2497,8 +2511,9 @@ var Physics2DRuntime = class {
|
|
|
2497
2511
|
destroyWorld(this.#world);
|
|
2498
2512
|
}
|
|
2499
2513
|
/**
|
|
2500
|
-
* Publishes the frame's counters and zeroes the accumulators.
|
|
2501
|
-
*
|
|
2514
|
+
* Publishes the frame's counters and zeroes the accumulators. The top of `Update`, where the
|
|
2515
|
+
* display pose is written, is the first point in a frame at which every fixed step of that frame
|
|
2516
|
+
* is done.
|
|
2502
2517
|
*/
|
|
2503
2518
|
#publishCounters() {
|
|
2504
2519
|
this.#counters.set(this.#counters.index("bodies"), this.#records.length);
|
|
@@ -2951,6 +2966,10 @@ var Physics2DRuntime = class {
|
|
|
2951
2966
|
/**
|
|
2952
2967
|
* Reports every obstacle a controller hit and returns the most upward-facing normal.
|
|
2953
2968
|
*
|
|
2969
|
+
* @remarks
|
|
2970
|
+
* Sensors are filtered out of the move (`lite/rapier/character.ts`), so a trigger volume never
|
|
2971
|
+
* shows up here and never contributes a ground normal.
|
|
2972
|
+
*
|
|
2954
2973
|
* @param rapierController - Rapier's controller.
|
|
2955
2974
|
* @param component - The component.
|
|
2956
2975
|
* @returns The ground normal, or `null` when nothing was hit.
|
|
@@ -3250,26 +3269,43 @@ function now() {
|
|
|
3250
3269
|
//#endregion
|
|
3251
3270
|
//#region src/runtime/systems.ts
|
|
3252
3271
|
/**
|
|
3253
|
-
* The three systems `docs/architecture/01-lifecycle-and-time.md` §3
|
|
3254
|
-
*
|
|
3255
|
-
*
|
|
3272
|
+
* The three systems `docs/architecture/01-lifecycle-and-time.md` §3 and `09-physics.md` §1 put
|
|
3273
|
+
* physics in the frame with — identical in 2D, except that Rapier is stepped directly and there is
|
|
3274
|
+
* no Babylon Lite simulation scene:
|
|
3256
3275
|
*
|
|
3257
3276
|
* ```
|
|
3258
3277
|
* Systems(FixedUpdate, -100) restore the authoritative pose of interpolated bodies
|
|
3259
3278
|
* scripts.fixedUpdate(dt) forces, velocities, CharacterController2D.move()
|
|
3260
3279
|
* Systems(FixedUpdate, 100) step Rapier, snapshot poses, dispatch collision and trigger events
|
|
3261
|
-
*
|
|
3280
|
+
* ── the fixed loop ends; time.fixedStepAlpha is final ──
|
|
3281
|
+
* Systems(Update, -900) write lerp(prev, cur, time.fixedStepAlpha)
|
|
3282
|
+
* scripts.update / lateUpdate, animation, rendering — all read the display pose
|
|
3262
3283
|
* ```
|
|
3263
3284
|
*
|
|
3285
|
+
* **Why the display pose is written at the top of `Update` and not in `PreRender`** (2026-09-08).
|
|
3286
|
+
* It used to be written in `PreRender`, after `lateUpdate`. `Camera2DFollow` and every hand-written
|
|
3287
|
+
* follow camera run in `update`/`lateUpdate`, so they framed the character where the last fixed step
|
|
3288
|
+
* left it while the renderer drew it at `lerp(prev, cur, alpha)`: up to one fixed step of relative
|
|
3289
|
+
* judder every frame, which a pixel-perfect camera turns into a visibly shaking sprite because the
|
|
3290
|
+
* two poses are quantised independently. Writing the pose before `scripts.update` means scripts,
|
|
3291
|
+
* animation, camera rigs and the render sync all see the pose the frame presents, which is Unity's
|
|
3292
|
+
* model. The simulation is unaffected: the restore system at `FixedUpdate −100` runs before
|
|
3293
|
+
* `scripts.fixedUpdate`, so `fixedUpdate` and Rapier still see the authoritative pose.
|
|
3294
|
+
*
|
|
3264
3295
|
* Everything here is `@internal`.
|
|
3265
3296
|
*/
|
|
3266
3297
|
/** The `FixedUpdate` order the restore system runs at. */
|
|
3267
3298
|
const PHYSICS_2D_RESTORE_ORDER = -100;
|
|
3268
|
-
/** The `PreRender` order the interpolation system runs at. */
|
|
3269
|
-
const PHYSICS_2D_INTERPOLATE_ORDER = -500;
|
|
3270
3299
|
/**
|
|
3271
|
-
*
|
|
3272
|
-
*
|
|
3300
|
+
* The `Update` order the interpolation system runs at. Negative, so it lands in
|
|
3301
|
+
* `Systems(Update, order < 0)` — after the fixed loop and lifecycle flush B, before
|
|
3302
|
+
* `scripts.update` — and low enough that a game's own `Update` systems can still be ordered in
|
|
3303
|
+
* front of it if they must see the authoritative pose.
|
|
3304
|
+
*/
|
|
3305
|
+
const PHYSICS_2D_INTERPOLATE_ORDER = -900;
|
|
3306
|
+
/**
|
|
3307
|
+
* Undoes the display pose the interpolation system wrote at the top of the previous `Update`, so
|
|
3308
|
+
* `fixedUpdate` and Rapier both see the authoritative pose.
|
|
3273
3309
|
*
|
|
3274
3310
|
* @internal
|
|
3275
3311
|
*/
|
|
@@ -3745,7 +3781,7 @@ const physics2d = defineExtension((options = {}) => {
|
|
|
3745
3781
|
order: 100
|
|
3746
3782
|
});
|
|
3747
3783
|
ctx.registerSystem(new Physics2DInterpolationSystem(host), {
|
|
3748
|
-
phase: Phase.
|
|
3784
|
+
phase: Phase.Update,
|
|
3749
3785
|
order: PHYSICS_2D_INTERPOLATE_ORDER
|
|
3750
3786
|
});
|
|
3751
3787
|
},
|