@ignifx/physics-2d 0.9.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 CHANGED
@@ -878,19 +878,21 @@ export declare class EdgeCollider2D extends Collider2D {
878
878
  }
879
879
  //#endregion
880
880
  //#region src/components/tilemap-collider.d.ts
881
- /**
882
- * Read tile collision data through the optional 2D toolkit's type and rebuild when its version changes.
883
- * Closed polylines preserve concave tile outlines that convex hulls would fill in. They are thin
884
- * surfaces, so a body starting inside the map is not pushed out.
885
- */
886
881
  /**
887
882
  * The collision surface of a tilemap, as one static body's worth of Rapier shapes.
888
883
  *
884
+ * @remarks
885
+ * The collider reads the `Tilemap` on its own entity, so a scene file that holds both components
886
+ * has tile collision as soon as it loads. It follows that tilemap: a tile edit, a new map, or a
887
+ * tilemap added later all reach physics at the next fixed step. Assign
888
+ * {@link TilemapCollider2D.collisionData} only to use other geometry, such as data you built in
889
+ * code or a tilemap on another entity.
890
+ *
889
891
  * @example
890
892
  * ```ts
891
- * const map = world.createEntity("Map");
892
- * const collider = map.addComponent(TilemapCollider2D);
893
- * collider.collisionData = tilemap.collisionData;
893
+ * const level = world.createEntity("Level");
894
+ * level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("level.tilemap.json");
895
+ * level.addComponent(TilemapCollider2D); // reads the Tilemap beside it
894
896
  * ```
895
897
  *
896
898
  * @public
@@ -904,21 +906,32 @@ export declare class TilemapCollider2D extends Collider2D {
904
906
  /** Applies the shared defaults. */
905
907
  constructor();
906
908
  /**
907
- * The merged chunk geometry this collider builds shapes from.
909
+ * The merged chunk geometry this collider builds shapes from: the assigned data, or else the
910
+ * `Tilemap` on the same entity.
908
911
  *
909
- * @returns The data, or `null` when none has been supplied.
912
+ * @remarks
913
+ * Reading it works in an edit-mode app too, where no body is built (ADR-0028), so an editor can
914
+ * draw the outlines.
915
+ *
916
+ * @returns The data, or `null` when nothing was assigned and the entity has no `Tilemap`.
910
917
  */
911
918
  get collisionData(): TilemapCollisionData | null;
912
919
  /**
913
- * Replaces the tilemap geometry and schedules a rebuild.
920
+ * Uses other geometry instead of the sibling tilemap's, and schedules a rebuild.
914
921
  *
915
- * @param value - The merged chunk geometry, or `null` to drop the shapes.
922
+ * @param value - The merged chunk geometry, or `null` to go back to the `Tilemap` on the same
923
+ * entity (no shapes when there is none).
916
924
  */
917
925
  set collisionData(value: TilemapCollisionData | null);
918
926
  /**
919
927
  * Whether the supplied data has changed since the shapes were built. The runtime polls this once
920
928
  * per fixed step, which is how a tile edit reaches physics without a cross-package subscription.
921
929
  *
930
+ * @remarks
931
+ * A disabled collider, or one on an inactive entity, builds no shapes, so it answers `false`
932
+ * rather than asking for the same empty rebuild every step. Enabling it again finds the data
933
+ * changed and rebuilds.
934
+ *
922
935
  * @returns `true` when a rebuild is due.
923
936
  *
924
937
  * @internal
@@ -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":";;;;;;;;;;;;;;;;;qBAiBa;;;;;;UAOI;;WAEN;;WAEA;;;;;;;;;;;;;;;;;;;UAoBM;;WAEN,SAAS;;;;;WAKT,iBAAiB,SAAS;;WAE1B,iBAAiB;;WAEjB;;WAEA;;;;;;;;;;;;;wBAuBK,2BAA2B;;;;;;;;wBAoB3B,4BAA4B;;;;;;;;;;;;;qBCzF/B;;;;;;qBAOA;;;;;;qBAOA;;;;;;qBAOA;;;;;;;;;;;;qBAaA,6BAA6B;;SAEjC;;WAGE;;WAGA;;WAGA;;;;;;;EAQT,YAAY,cAAc,QAAQ;;;;;;;;;;;;;SAkB3B,WA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;;;;;;;;EA0CZ,cAAc,QAAQ,UAAU,gBAAgB,UAAU,0BAA0B;;;;;;;;;;;EAcpF,WAAW,QAAQ,UAAU,MAAM,UAAU,mBAAsB,UAAU,0BAA0B;;;;;;;;;;;;EAqBvG,UACE,QAAQ,UACR,gBACA,WAAW,UACX,qBACA,UAAU,iBACT;;;;;;;;;;;;;;UCrMY;;;;;;;WAON,mBAAmB;;;YAIlB;;aAEC,WAAW;;;;;;;;;;;;;;;;qBAiBX,YAAY,UAAU,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;wBCrCxC,mBAAmB,SAAS,eAAe"}
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;;;;;;;;;;;;;qBCzF/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;;;;;;;;;;;;;;KC3FlE,cAAc;;;;;;KAOd,aAAa;;;;;;KAOb,iBAAiB;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AQ,UACR,gBACA,WAAW,UACX,qBACA,UAAU,iBACT;;;;;;;;;;;;;;UCrMY;;;;;;;WAON,mBAAmB;;;YAIlB;;aAEC,WAAW;;;;;;;;;;;;;;;;qBAiBX,YAAY,UAAU,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;wBCrCxC,mBAAmB,SAAS,eAAe"}
package/dist/index.js CHANGED
@@ -1054,18 +1054,29 @@ function degenerate(entity, component, requirement) {
1054
1054
  //#endregion
1055
1055
  //#region src/components/tilemap-collider.ts
1056
1056
  /**
1057
- * Read tile collision data through the optional 2D toolkit's type and rebuild when its version changes.
1058
- * Closed polylines preserve concave tile outlines that convex hulls would fill in. They are thin
1059
- * surfaces, so a body starting inside the map is not pushed out.
1057
+ * Read tile collision data through the optional 2D toolkit's type and rebuild when it changes.
1058
+ * The sibling `Tilemap` is found by its registered type id, because `@ignifx/2d` is an optional
1059
+ * peer and must not be imported as a value. Closed polylines preserve concave tile outlines that
1060
+ * convex hulls would fill in. They are thin surfaces, so a body starting inside the map is not
1061
+ * pushed out.
1060
1062
  */
1063
+ /** The type id `@ignifx/2d` registers `Tilemap` under. */
1064
+ const TILEMAP_TYPE_ID = "ignifx/Tilemap";
1061
1065
  /**
1062
1066
  * The collision surface of a tilemap, as one static body's worth of Rapier shapes.
1063
1067
  *
1068
+ * @remarks
1069
+ * The collider reads the `Tilemap` on its own entity, so a scene file that holds both components
1070
+ * has tile collision as soon as it loads. It follows that tilemap: a tile edit, a new map, or a
1071
+ * tilemap added later all reach physics at the next fixed step. Assign
1072
+ * {@link TilemapCollider2D.collisionData} only to use other geometry, such as data you built in
1073
+ * code or a tilemap on another entity.
1074
+ *
1064
1075
  * @example
1065
1076
  * ```ts
1066
- * const map = world.createEntity("Map");
1067
- * const collider = map.addComponent(TilemapCollider2D);
1068
- * collider.collisionData = tilemap.collisionData;
1077
+ * const level = world.createEntity("Level");
1078
+ * level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("level.tilemap.json");
1079
+ * level.addComponent(TilemapCollider2D); // reads the Tilemap beside it
1069
1080
  * ```
1070
1081
  *
1071
1082
  * @public
@@ -1075,9 +1086,11 @@ var TilemapCollider2D = class TilemapCollider2D extends Collider2D {
1075
1086
  static typeId = "ignifx/TilemapCollider2D";
1076
1087
  /** The serialized field declarations; the geometry itself comes from the tilemap asset. */
1077
1088
  static schema = tilemapSchema();
1078
- /** The merged chunk geometry, or `null` until a tilemap supplies it. */
1079
- #data = null;
1080
- /** The `version` of the data the current shapes were built from. */
1089
+ /** Geometry that code assigned, which takes the place of the sibling tilemap's. */
1090
+ #override = null;
1091
+ /** The data the current shapes were built from. */
1092
+ #builtData = null;
1093
+ /** The `version` of that data when the shapes were built. */
1081
1094
  #builtVersion = -1;
1082
1095
  /** Applies the shared defaults. */
1083
1096
  constructor() {
@@ -1085,20 +1098,27 @@ var TilemapCollider2D = class TilemapCollider2D extends Collider2D {
1085
1098
  Object.assign(this, createDefaults(TilemapCollider2D.schema));
1086
1099
  }
1087
1100
  /**
1088
- * The merged chunk geometry this collider builds shapes from.
1101
+ * The merged chunk geometry this collider builds shapes from: the assigned data, or else the
1102
+ * `Tilemap` on the same entity.
1103
+ *
1104
+ * @remarks
1105
+ * Reading it works in an edit-mode app too, where no body is built (ADR-0028), so an editor can
1106
+ * draw the outlines.
1089
1107
  *
1090
- * @returns The data, or `null` when none has been supplied.
1108
+ * @returns The data, or `null` when nothing was assigned and the entity has no `Tilemap`.
1091
1109
  */
1092
1110
  get collisionData() {
1093
- return this.#data;
1111
+ return this.#override ?? siblingCollisionData(this);
1094
1112
  }
1095
1113
  /**
1096
- * Replaces the tilemap geometry and schedules a rebuild.
1114
+ * Uses other geometry instead of the sibling tilemap's, and schedules a rebuild.
1097
1115
  *
1098
- * @param value - The merged chunk geometry, or `null` to drop the shapes.
1116
+ * @param value - The merged chunk geometry, or `null` to go back to the `Tilemap` on the same
1117
+ * entity (no shapes when there is none).
1099
1118
  */
1100
1119
  set collisionData(value) {
1101
- this.#data = value;
1120
+ this.#override = value;
1121
+ this.#builtData = null;
1102
1122
  this.#builtVersion = -1;
1103
1123
  this.rebuild();
1104
1124
  }
@@ -1106,12 +1126,19 @@ var TilemapCollider2D = class TilemapCollider2D extends Collider2D {
1106
1126
  * Whether the supplied data has changed since the shapes were built. The runtime polls this once
1107
1127
  * per fixed step, which is how a tile edit reaches physics without a cross-package subscription.
1108
1128
  *
1129
+ * @remarks
1130
+ * A disabled collider, or one on an inactive entity, builds no shapes, so it answers `false`
1131
+ * rather than asking for the same empty rebuild every step. Enabling it again finds the data
1132
+ * changed and rebuilds.
1133
+ *
1109
1134
  * @returns `true` when a rebuild is due.
1110
1135
  *
1111
1136
  * @internal
1112
1137
  */
1113
1138
  needsRebuild() {
1114
- return (this.#data?.version ?? -1) !== this.#builtVersion;
1139
+ if (!this.isEnabledInHierarchy) return false;
1140
+ const data = this.collisionData;
1141
+ return data !== this.#builtData || (data?.version ?? -1) !== this.#builtVersion;
1115
1142
  }
1116
1143
  /**
1117
1144
  * Appends one shape per merged outline and one per one-way edge.
@@ -1122,7 +1149,8 @@ var TilemapCollider2D = class TilemapCollider2D extends Collider2D {
1122
1149
  * @internal
1123
1150
  */
1124
1151
  collectShapes(scale, out) {
1125
- const data = this.#data;
1152
+ const data = this.collisionData;
1153
+ this.#builtData = data;
1126
1154
  this.#builtVersion = data?.version ?? -1;
1127
1155
  if (data === null) return;
1128
1156
  const offset = {
@@ -1155,6 +1183,27 @@ var TilemapCollider2D = class TilemapCollider2D extends Collider2D {
1155
1183
  }
1156
1184
  };
1157
1185
  /**
1186
+ * Reads the collision data of the `Tilemap` on a collider's entity.
1187
+ *
1188
+ * @param collider - The collider.
1189
+ * @returns The tilemap's merged geometry, or `null` when the entity has no `Tilemap` or the 2D
1190
+ * toolkit is not registered.
1191
+ */
1192
+ function siblingCollisionData(collider) {
1193
+ const type = collider.world.registry.get(TILEMAP_TYPE_ID);
1194
+ const tilemap = type === null ? null : collider.entity.getComponent(type);
1195
+ return tilemap !== null && isTilemap(tilemap) ? tilemap.collisionData : null;
1196
+ }
1197
+ /**
1198
+ * Whether a component registered as `ignifx/Tilemap` has the shape this package reads.
1199
+ *
1200
+ * @param component - The component.
1201
+ * @returns `true` when it carries `collisionData`.
1202
+ */
1203
+ function isTilemap(component) {
1204
+ return "collisionData" in component;
1205
+ }
1206
+ /**
1158
1207
  * Builds the `TilemapCollider2D` schema.
1159
1208
  *
1160
1209
  * @returns The schema.
@@ -3672,15 +3721,18 @@ const physics2d = defineExtension((options = {}) => {
3672
3721
  ctx.defineAppProperty("physics2d", () => service);
3673
3722
  ctx.registerSystem(new Physics2DRestoreSystem(host), {
3674
3723
  phase: Phase.FixedUpdate,
3675
- order: PHYSICS_2D_RESTORE_ORDER
3724
+ order: PHYSICS_2D_RESTORE_ORDER,
3725
+ editMode: "skip"
3676
3726
  });
3677
3727
  ctx.registerSystem(new Physics2DStepSystem(host), {
3678
3728
  phase: Phase.FixedUpdate,
3679
- order: 100
3729
+ order: 100,
3730
+ editMode: "skip"
3680
3731
  });
3681
3732
  ctx.registerSystem(new Physics2DInterpolationSystem(host), {
3682
3733
  phase: Phase.Update,
3683
- order: PHYSICS_2D_INTERPOLATE_ORDER
3734
+ order: PHYSICS_2D_INTERPOLATE_ORDER,
3735
+ editMode: "skip"
3684
3736
  });
3685
3737
  },
3686
3738
  async onStart(app) {