@codexo/exojs-tilemap-physics 0.18.0 → 0.19.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 CHANGED
@@ -68,6 +68,14 @@ for (const { object, body } of built) {
68
68
  }
69
69
  ```
70
70
 
71
+ ## Isometric presentation
72
+
73
+ Tile and object colliders use logical coordinates. Isometric logical cells are squares of side `tileHeight`; image-space tile collision shapes are inverse-projected before collider generation. Display layer offsets become logical translation vectors, and streamed collider bodies retain the same cell/chunk ownership rules. Orthogonal behavior is unchanged.
74
+
75
+ Create a `TilePhysicsBinding(body, node, map.projection)` explicitly and call `sync()` after physics updates, or `syncInterpolated(alpha)` with the fixed-step interpolation fraction. The node's parent must use map display coordinates. The binding only writes node position, owns nothing, and leaves sprite rotation/scale to the application; a projected logical rotation is not a rigid sprite rotation. Do not attach the same node through `PhysicsWorld.attach()`, which binds directly to unprojected world coordinates.
76
+
77
+ Object-layer `objects` remain logical geometry; `getDisplayObject()` is for rendering and must not be fed back into the collider builder. The Isometric Landscape example shows both representations.
78
+
71
79
  ## Geometry mapping
72
80
 
73
81
  | Source | Collider |
@@ -1 +1 @@
1
- {"version":3,"file":"TileColliderStreamer.d.ts","sourceRoot":"","sources":["../../src/TileColliderStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAqB,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKzG,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhE,gEAAgE;AAChE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,uEAAuE;IACvE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+DAA+D;IAC/D,MAAM,CAAC,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;OAOG;IACI,IAAI,IAAI,IAAI,CAgDlB;IAED;;;OAGG;IACI,OAAO,IAAI,IAAI,CAIrB;IAED,OAAO,CAAC,MAAM;IASd;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,WAAW;CAuCpB"}
@@ -171,15 +171,16 @@ var TileColliderStreamer = class {
171
171
  ...options.cells !== void 0 && { cells: options.cells }
172
172
  });
173
173
  if (geometry.rects.length === 0 && geometry.shapes.length === 0) return null;
174
- const x = startTx * layer.tileWidth + layer.offsetX;
175
- const y = startTy * layer.tileHeight + layer.offsetY;
174
+ const offset = layer.logicalOffset;
175
+ const x = startTx * layer.projection.logicalTileWidth + offset.x;
176
+ const y = startTy * layer.projection.logicalTileHeight + offset.y;
176
177
  const colliders = buildTileColliders(geometry, {
177
178
  x,
178
179
  y,
179
- tileWidth: layer.tileWidth,
180
- tileHeight: layer.tileHeight,
181
- layerOffsetX: layer.offsetX,
182
- layerOffsetY: layer.offsetY,
180
+ tileWidth: layer.projection.logicalTileWidth,
181
+ tileHeight: layer.projection.logicalTileHeight,
182
+ layerOffsetX: offset.x,
183
+ layerOffsetY: offset.y,
183
184
  regionMode: this._regionMode,
184
185
  defaults: this._defaults,
185
186
  material: options.material
@@ -1 +1 @@
1
- {"version":3,"file":"TileColliderStreamer.js","names":[],"sources":["../../src/TileColliderStreamer.ts"],"sourcesContent":["import { PhysicsBody, type PhysicsWorld } from '@codexo/exojs-physics';\nimport type { ReadonlyTileChunk, TileCellSource, TileLayer, TileMapObject } from '@codexo/exojs-tilemap';\nimport { buildTileCollisionGeometry } from '@codexo/exojs-tilemap';\n\nimport { buildTileColliders } from './buildColliders';\nimport { resolveDefaults, type ResolvedMaterial } from './material';\nimport type { ColliderDefaults, TileRegionMode } from './types';\n\n/** Options for a {@link TileColliderStreamer}. All optional. */\nexport interface TileColliderOptions extends ColliderDefaults {\n /** How solid whole-cell regions are represented. Default `'boxes'`. */\n regionMode?: TileRegionMode;\n /**\n * Merge adjacent whole-cell boxes sharing a `type` into larger rectangles.\n * Default `true`. Merging never crosses a chunk boundary.\n */\n merge?: boolean;\n /** Drop a source shape before any collider is built for it. */\n accept?: (object: TileMapObject, tx: number, ty: number) => boolean;\n /**\n * Per-cell collision classification, for layers whose collision is authored\n * per cell rather than per tile. On a bounded layer this makes the bridge\n * cover the whole layer, including partitions that hold no tiles at all.\n *\n * Sampled while a partition is built and expected to answer identically for\n * the lifetime of this bridge: changing what it returns does not invalidate\n * colliders that already exist. Rebuild by recreating the bridge.\n */\n cells?: TileCellSource | undefined;\n}\n\n/**\n * One collision build block: the deterministic spatial partition this bridge\n * may own a body for. A partition is not the same thing as tile residency - a\n * cell source covers partitions that hold no {@link ReadonlyTileChunk} at all,\n * and nothing here makes a non-resident chunk look resident.\n *\n * An entry with `body === null` is a cached empty result, not an absence: it\n * is what keeps an unrelated layer revision from re-walking every cell of\n * every empty partition.\n */\ninterface BlockEntry {\n readonly cx: number;\n readonly cy: number;\n /** The chunk the body was built from; `null` for a cell-only partition. A re-adopted chunk is a new one. */\n readonly chunk: ReadonlyTileChunk | null;\n readonly revision: number;\n /** `null` when the partition holds no collision geometry at all. */\n readonly body: PhysicsBody | null;\n}\n\nconst chunkKey = (cx: number, cy: number): string => `${cx},${cy}`;\n\n/**\n * Tile extent of a build block along one axis. Edge blocks of a bounded layer\n * are clipped, matching the dimensions the layer gives an edge chunk, so a\n * cell-only block never walks cells outside the layer.\n */\nconst blockExtent = (chunkExtent: number, layerExtent: number | undefined, start: number): number =>\n layerExtent === undefined ? chunkExtent : Math.min(chunkExtent, layerExtent - start);\n\n/**\n * Keeps a physics world's static tile colliders in sync with a\n * {@link TileLayer}: one static body per chunk-sized partition of the layer,\n * rebuilt when that partition changes, destroyed when it is evicted.\n *\n * The bridge owns every body it creates and nothing else. It observes the layer\n * through its public revision counters, so it works with any chunk source -\n * {@link import('@codexo/exojs-tilemap').ChunkStreamer}, a hand-rolled loader,\n * or a fully resident bounded layer.\n *\n * Tick it from `preFrame`, before the frame's fixed steps run - not from\n * `update`, which runs after them:\n *\n * ```ts\n * const colliders = new TileColliderStreamer(world, layer);\n * scene.systems.add({ preFrame: () => colliders.sync() });\n * ```\n *\n * `SceneScope` runs `preFrame` once per frame, before any of that frame's\n * fixed steps, and `update` after all of them. A chunk that becomes resident\n * this frame needs its collider body built before the world steps over the\n * hole, and a chunk evicted this frame must not keep its body for a whole\n * extra frame of stepping - `update` gets both of those one step too late.\n * Wiring `sync()` into `fixedUpdate` instead (ordered before\n * {@link SystemOrder.Physics}) also works, and additionally re-syncs on\n * every fixed step within a frame rather than once per frame.\n *\n * Two consequences worth knowing before shipping a level:\n *\n * - Whole-cell merging never crosses a partition boundary, so a solid run\n * spanning two of them is at least two rectangles. This is what makes the\n * result independent of the order chunks were loaded in.\n * - A dynamic body resting on a chunk that gets evicted falls. Eviction is the\n * chunk source's decision; widen its unload radius if that matters.\n * - With {@link TileColliderOptions.cells}, a bounded layer's partitions are\n * all covered, resident or not - collision authored per cell does not depend\n * on tiles being placed.\n */\nexport class TileColliderStreamer {\n private readonly _world: PhysicsWorld;\n private readonly _layer: TileLayer;\n private readonly _options: TileColliderOptions;\n private readonly _defaults: ResolvedMaterial;\n private readonly _regionMode: TileRegionMode;\n\n private readonly _built = new Map<string, BlockEntry>();\n private readonly _seen = new Set<string>();\n\n private _layerRevision = -1;\n private _offsetX: number;\n private _offsetY: number;\n private _destroyed = false;\n\n public constructor(world: PhysicsWorld, layer: TileLayer, options: TileColliderOptions = {}) {\n this._world = world;\n this._layer = layer;\n this._options = options;\n this._defaults = resolveDefaults(options);\n this._regionMode = options.regionMode ?? 'boxes';\n this._offsetX = layer.offsetX;\n this._offsetY = layer.offsetY;\n }\n\n /** Number of bodies currently owned by this bridge. */\n public get bodyCount(): number {\n let count = 0;\n\n for (const entry of this._built.values()) {\n if (entry.body !== null) count++;\n }\n\n return count;\n }\n\n /**\n * The bodies this bridge owns, in `(cy, cx)` partition order - independent of\n * the order the chunks became resident in.\n */\n public *bodies(): IterableIterator<PhysicsBody> {\n const ordered = [...this._built.values()].sort((a, b) => a.cy - b.cy || a.cx - b.cx);\n\n for (const entry of ordered) {\n if (entry.body !== null) yield entry.body;\n }\n }\n\n /**\n * Bring the world's tile colliders up to date with the layer: build bodies\n * for newly resident chunks, rebuild edited ones, destroy evicted ones.\n *\n * Cheap to call every frame. With no change since the last call it performs\n * no work and allocates nothing. No-op once {@link destroy}ed or once the\n * layer is destroyed.\n */\n public sync(): void {\n if (this._destroyed || this._layer.destroyed) return;\n\n const layer = this._layer;\n const offsetChanged = layer.offsetX !== this._offsetX || layer.offsetY !== this._offsetY;\n\n if (!offsetChanged && layer.revision === this._layerRevision) return;\n\n if (offsetChanged) {\n // Geometry is emitted in layer pixel space, so a moved layer invalidates\n // every collider - and moving a layer does not bump its revision.\n this._clear();\n this._offsetX = layer.offsetX;\n this._offsetY = layer.offsetY;\n }\n\n const seen = this._seen;\n\n seen.clear();\n\n for (const chunk of layer.loadedChunks()) {\n this._syncBlock(chunk.cx, chunk.cy, chunk);\n }\n\n // A cell source covers the layer, not its residency: every partition of a\n // bounded layer is a build block, whether or not tiles were ever placed in\n // it. Without this the canonical case - collision authored per cell on a\n // layer that renders nothing - would produce no bodies at all.\n if (this._options.cells !== undefined) {\n const range = layer.chunkRange();\n\n if (range !== null) {\n for (let cy = range.minCy; cy <= range.maxCy; cy++) {\n for (let cx = range.minCx; cx <= range.maxCx; cx++) {\n this._syncBlock(cx, cy, layer.getChunk(cx, cy) ?? null);\n }\n }\n }\n }\n\n for (const [key, entry] of this._built) {\n if (seen.has(key)) continue;\n\n if (entry.body !== null) this._world.destroyBody(entry.body);\n this._built.delete(key);\n }\n\n this._layerRevision = layer.revision;\n }\n\n /**\n * Destroy every body this bridge created and stop responding to\n * {@link sync}. Bodies it did not create are untouched. Idempotent.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n this._clear();\n }\n\n private _clear(): void {\n for (const entry of this._built.values()) {\n if (entry.body !== null) this._world.destroyBody(entry.body);\n }\n\n this._built.clear();\n this._layerRevision = -1;\n }\n\n /**\n * Reconcile one build block against what was built for it before. Skips\n * without sampling anything when neither the backing chunk nor its revision\n * moved - which is what keeps an empty cell-only block from re-walking its\n * cells on every unrelated layer change.\n */\n private _syncBlock(cx: number, cy: number, chunk: ReadonlyTileChunk | null): void {\n const key = chunkKey(cx, cy);\n\n if (this._seen.has(key)) return;\n\n this._seen.add(key);\n\n const entry = this._built.get(key);\n const revision = chunk?.revision ?? -1;\n\n if (entry?.chunk === chunk && entry.revision === revision) {\n return;\n }\n\n if (entry?.body != null) {\n this._world.destroyBody(entry.body);\n }\n\n this._built.set(key, { cx, cy, chunk, revision, body: this._buildBlock(cx, cy, chunk) });\n }\n\n private _buildBlock(cx: number, cy: number, chunk: ReadonlyTileChunk | null): PhysicsBody | null {\n const layer = this._layer;\n const options = this._options;\n const startTx = cx * layer.chunkWidth;\n const startTy = cy * layer.chunkHeight;\n const width = chunk?.width ?? blockExtent(layer.chunkWidth, layer.width, startTx);\n const height = chunk?.height ?? blockExtent(layer.chunkHeight, layer.height, startTy);\n const geometry = buildTileCollisionGeometry(layer, {\n region: { x: startTx, y: startTy, width, height },\n ...(options.merge !== undefined && { merge: options.merge }),\n ...(options.accept !== undefined && { accept: options.accept }),\n ...(options.cells !== undefined && { cells: options.cells }),\n });\n\n if (geometry.rects.length === 0 && geometry.shapes.length === 0) {\n return null;\n }\n\n const x = startTx * layer.tileWidth + layer.offsetX;\n const y = startTy * layer.tileHeight + layer.offsetY;\n const colliders = buildTileColliders(geometry, {\n x,\n y,\n tileWidth: layer.tileWidth,\n tileHeight: layer.tileHeight,\n layerOffsetX: layer.offsetX,\n layerOffsetY: layer.offsetY,\n regionMode: this._regionMode,\n defaults: this._defaults,\n material: options.material,\n });\n\n if (colliders.length === 0) {\n return null;\n }\n\n return this._world.add(new PhysicsBody({ type: 'static', position: { x, y }, colliders }));\n }\n}\n"],"mappings":";;;;;;AAmDA,MAAM,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{"version":3,"file":"TileColliderStreamer.js","names":[],"sources":["../../src/TileColliderStreamer.ts"],"sourcesContent":["import { PhysicsBody, type PhysicsWorld } from '@codexo/exojs-physics';\nimport type { ReadonlyTileChunk, TileCellSource, TileLayer, TileMapObject } from '@codexo/exojs-tilemap';\nimport { buildTileCollisionGeometry } from '@codexo/exojs-tilemap';\n\nimport { buildTileColliders } from './buildColliders';\nimport { resolveDefaults, type ResolvedMaterial } from './material';\nimport type { ColliderDefaults, TileRegionMode } from './types';\n\n/** Options for a {@link TileColliderStreamer}. All optional. */\nexport interface TileColliderOptions extends ColliderDefaults {\n /** How solid whole-cell regions are represented. Default `'boxes'`. */\n regionMode?: TileRegionMode;\n /**\n * Merge adjacent whole-cell boxes sharing a `type` into larger rectangles.\n * Default `true`. Merging never crosses a chunk boundary.\n */\n merge?: boolean;\n /** Drop a source shape before any collider is built for it. */\n accept?: (object: TileMapObject, tx: number, ty: number) => boolean;\n /**\n * Per-cell collision classification, for layers whose collision is authored\n * per cell rather than per tile. On a bounded layer this makes the bridge\n * cover the whole layer, including partitions that hold no tiles at all.\n *\n * Sampled while a partition is built and expected to answer identically for\n * the lifetime of this bridge: changing what it returns does not invalidate\n * colliders that already exist. Rebuild by recreating the bridge.\n */\n cells?: TileCellSource | undefined;\n}\n\n/**\n * One collision build block: the deterministic spatial partition this bridge\n * may own a body for. A partition is not the same thing as tile residency - a\n * cell source covers partitions that hold no {@link ReadonlyTileChunk} at all,\n * and nothing here makes a non-resident chunk look resident.\n *\n * An entry with `body === null` is a cached empty result, not an absence: it\n * is what keeps an unrelated layer revision from re-walking every cell of\n * every empty partition.\n */\ninterface BlockEntry {\n readonly cx: number;\n readonly cy: number;\n /** The chunk the body was built from; `null` for a cell-only partition. A re-adopted chunk is a new one. */\n readonly chunk: ReadonlyTileChunk | null;\n readonly revision: number;\n /** `null` when the partition holds no collision geometry at all. */\n readonly body: PhysicsBody | null;\n}\n\nconst chunkKey = (cx: number, cy: number): string => `${cx},${cy}`;\n\n/**\n * Tile extent of a build block along one axis. Edge blocks of a bounded layer\n * are clipped, matching the dimensions the layer gives an edge chunk, so a\n * cell-only block never walks cells outside the layer.\n */\nconst blockExtent = (chunkExtent: number, layerExtent: number | undefined, start: number): number =>\n layerExtent === undefined ? chunkExtent : Math.min(chunkExtent, layerExtent - start);\n\n/**\n * Keeps a physics world's static tile colliders in sync with a\n * {@link TileLayer}: one static body per chunk-sized partition of the layer,\n * rebuilt when that partition changes, destroyed when it is evicted.\n *\n * The bridge owns every body it creates and nothing else. It observes the layer\n * through its public revision counters, so it works with any chunk source -\n * {@link import('@codexo/exojs-tilemap').ChunkStreamer}, a hand-rolled loader,\n * or a fully resident bounded layer.\n *\n * Tick it from `preFrame`, before the frame's fixed steps run - not from\n * `update`, which runs after them:\n *\n * ```ts\n * const colliders = new TileColliderStreamer(world, layer);\n * scene.systems.add({ preFrame: () => colliders.sync() });\n * ```\n *\n * `SceneScope` runs `preFrame` once per frame, before any of that frame's\n * fixed steps, and `update` after all of them. A chunk that becomes resident\n * this frame needs its collider body built before the world steps over the\n * hole, and a chunk evicted this frame must not keep its body for a whole\n * extra frame of stepping - `update` gets both of those one step too late.\n * Wiring `sync()` into `fixedUpdate` instead (ordered before\n * {@link SystemOrder.Physics}) also works, and additionally re-syncs on\n * every fixed step within a frame rather than once per frame.\n *\n * Two consequences worth knowing before shipping a level:\n *\n * - Whole-cell merging never crosses a partition boundary, so a solid run\n * spanning two of them is at least two rectangles. This is what makes the\n * result independent of the order chunks were loaded in.\n * - A dynamic body resting on a chunk that gets evicted falls. Eviction is the\n * chunk source's decision; widen its unload radius if that matters.\n * - With {@link TileColliderOptions.cells}, a bounded layer's partitions are\n * all covered, resident or not - collision authored per cell does not depend\n * on tiles being placed.\n */\nexport class TileColliderStreamer {\n private readonly _world: PhysicsWorld;\n private readonly _layer: TileLayer;\n private readonly _options: TileColliderOptions;\n private readonly _defaults: ResolvedMaterial;\n private readonly _regionMode: TileRegionMode;\n\n private readonly _built = new Map<string, BlockEntry>();\n private readonly _seen = new Set<string>();\n\n private _layerRevision = -1;\n private _offsetX: number;\n private _offsetY: number;\n private _destroyed = false;\n\n public constructor(world: PhysicsWorld, layer: TileLayer, options: TileColliderOptions = {}) {\n this._world = world;\n this._layer = layer;\n this._options = options;\n this._defaults = resolveDefaults(options);\n this._regionMode = options.regionMode ?? 'boxes';\n this._offsetX = layer.offsetX;\n this._offsetY = layer.offsetY;\n }\n\n /** Number of bodies currently owned by this bridge. */\n public get bodyCount(): number {\n let count = 0;\n\n for (const entry of this._built.values()) {\n if (entry.body !== null) count++;\n }\n\n return count;\n }\n\n /**\n * The bodies this bridge owns, in `(cy, cx)` partition order - independent of\n * the order the chunks became resident in.\n */\n public *bodies(): IterableIterator<PhysicsBody> {\n const ordered = [...this._built.values()].sort((a, b) => a.cy - b.cy || a.cx - b.cx);\n\n for (const entry of ordered) {\n if (entry.body !== null) yield entry.body;\n }\n }\n\n /**\n * Bring the world's tile colliders up to date with the layer: build bodies\n * for newly resident chunks, rebuild edited ones, destroy evicted ones.\n *\n * Cheap to call every frame. With no change since the last call it performs\n * no work and allocates nothing. No-op once {@link destroy}ed or once the\n * layer is destroyed.\n */\n public sync(): void {\n if (this._destroyed || this._layer.destroyed) return;\n\n const layer = this._layer;\n const offsetChanged = layer.offsetX !== this._offsetX || layer.offsetY !== this._offsetY;\n\n if (!offsetChanged && layer.revision === this._layerRevision) return;\n\n if (offsetChanged) {\n // Geometry is emitted in layer pixel space, so a moved layer invalidates\n // every collider - and moving a layer does not bump its revision.\n this._clear();\n this._offsetX = layer.offsetX;\n this._offsetY = layer.offsetY;\n }\n\n const seen = this._seen;\n\n seen.clear();\n\n for (const chunk of layer.loadedChunks()) {\n this._syncBlock(chunk.cx, chunk.cy, chunk);\n }\n\n // A cell source covers the layer, not its residency: every partition of a\n // bounded layer is a build block, whether or not tiles were ever placed in\n // it. Without this the canonical case - collision authored per cell on a\n // layer that renders nothing - would produce no bodies at all.\n if (this._options.cells !== undefined) {\n const range = layer.chunkRange();\n\n if (range !== null) {\n for (let cy = range.minCy; cy <= range.maxCy; cy++) {\n for (let cx = range.minCx; cx <= range.maxCx; cx++) {\n this._syncBlock(cx, cy, layer.getChunk(cx, cy) ?? null);\n }\n }\n }\n }\n\n for (const [key, entry] of this._built) {\n if (seen.has(key)) continue;\n\n if (entry.body !== null) this._world.destroyBody(entry.body);\n this._built.delete(key);\n }\n\n this._layerRevision = layer.revision;\n }\n\n /**\n * Destroy every body this bridge created and stop responding to\n * {@link sync}. Bodies it did not create are untouched. Idempotent.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n this._clear();\n }\n\n private _clear(): void {\n for (const entry of this._built.values()) {\n if (entry.body !== null) this._world.destroyBody(entry.body);\n }\n\n this._built.clear();\n this._layerRevision = -1;\n }\n\n /**\n * Reconcile one build block against what was built for it before. Skips\n * without sampling anything when neither the backing chunk nor its revision\n * moved - which is what keeps an empty cell-only block from re-walking its\n * cells on every unrelated layer change.\n */\n private _syncBlock(cx: number, cy: number, chunk: ReadonlyTileChunk | null): void {\n const key = chunkKey(cx, cy);\n\n if (this._seen.has(key)) return;\n\n this._seen.add(key);\n\n const entry = this._built.get(key);\n const revision = chunk?.revision ?? -1;\n\n if (entry?.chunk === chunk && entry.revision === revision) {\n return;\n }\n\n if (entry?.body != null) {\n this._world.destroyBody(entry.body);\n }\n\n this._built.set(key, { cx, cy, chunk, revision, body: this._buildBlock(cx, cy, chunk) });\n }\n\n private _buildBlock(cx: number, cy: number, chunk: ReadonlyTileChunk | null): PhysicsBody | null {\n const layer = this._layer;\n const options = this._options;\n const startTx = cx * layer.chunkWidth;\n const startTy = cy * layer.chunkHeight;\n const width = chunk?.width ?? blockExtent(layer.chunkWidth, layer.width, startTx);\n const height = chunk?.height ?? blockExtent(layer.chunkHeight, layer.height, startTy);\n const geometry = buildTileCollisionGeometry(layer, {\n region: { x: startTx, y: startTy, width, height },\n ...(options.merge !== undefined && { merge: options.merge }),\n ...(options.accept !== undefined && { accept: options.accept }),\n ...(options.cells !== undefined && { cells: options.cells }),\n });\n\n if (geometry.rects.length === 0 && geometry.shapes.length === 0) {\n return null;\n }\n\n const offset = layer.logicalOffset;\n const x = startTx * layer.projection.logicalTileWidth + offset.x;\n const y = startTy * layer.projection.logicalTileHeight + offset.y;\n const colliders = buildTileColliders(geometry, {\n x,\n y,\n tileWidth: layer.projection.logicalTileWidth,\n tileHeight: layer.projection.logicalTileHeight,\n layerOffsetX: offset.x,\n layerOffsetY: offset.y,\n regionMode: this._regionMode,\n defaults: this._defaults,\n material: options.material,\n });\n\n if (colliders.length === 0) {\n return null;\n }\n\n return this._world.add(new PhysicsBody({ type: 'static', position: { x, y }, colliders }));\n }\n}\n"],"mappings":";;;;;;AAmDA,MAAM,YAAY,IAAY,OAAuB,GAAG,GAAG,GAAG;;;;;;AAO9D,MAAM,eAAe,aAAqB,aAAiC,UACzE,gBAAgB,SAAY,cAAc,KAAK,IAAI,aAAa,cAAc,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCrF,IAAa,uBAAb,MAAkC;CAChC,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAiB,yBAAS,IAAI,IAAwB;CACtD,AAAiB,wBAAQ,IAAI,IAAY;CAEzC,AAAQ,iBAAiB;CACzB,AAAQ;CACR,AAAQ;CACR,AAAQ,aAAa;CAErB,AAAO,YAAY,OAAqB,OAAkB,UAA+B,CAAC,GAAG;EAC3F,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,YAAY,gBAAgB,OAAO;EACxC,KAAK,cAAc,QAAQ,cAAc;EACzC,KAAK,WAAW,MAAM;EACtB,KAAK,WAAW,MAAM;CACxB;;CAGA,IAAW,YAAoB;EAC7B,IAAI,QAAQ;EAEZ,KAAK,MAAM,SAAS,KAAK,OAAO,OAAO,GACrC,IAAI,MAAM,SAAS,MAAM;EAG3B,OAA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,WAAW,KAAK,SAAS,OAAO,WAAW,GAC5D,OAAO;EAGT,MAAM,SAAS,MAAM;EACrB,MAAM,IAAI,UAAU,MAAM,WAAW,mBAAmB,OAAO;EAC/D,MAAM,IAAI,UAAU,MAAM,WAAW,oBAAoB,OAAO;EAChE,MAAM,YAAY,mBAAmB,UAAU;GAC7C;GACA;GACA,WAAW,MAAM,WAAW;GAC5B,YAAY,MAAM,WAAW;GAC7B,cAAc,OAAO;GACrB,cAAc,OAAO;GACrB,YAAY,KAAK;GACjB,UAAU,KAAK;GACf,UAAU,QAAQ;EACpB,CAAC;EAED,IAAI,UAAU,WAAW,GACvB,OAAO;EAGT,OAAO,KAAK,OAAO,IAAI,IAAI,YAAY;GAAE,MAAM;GAAU,UAAU;IAAE;IAAG;GAAE;GAAG;EAAU,CAAC,CAAC;CAC3F;AACF"}
@@ -0,0 +1,21 @@
1
+ import type { SceneNode } from '@codexo/exojs';
2
+ import type { PhysicsBody } from '@codexo/exojs-physics';
3
+ import type { TileProjection } from '@codexo/exojs-tilemap';
4
+ /**
5
+ * Explicit presentation of a logical physics body through a tile projection.
6
+ * Call after stepping the world, or use syncInterpolated with the fixed-step
7
+ * interpolation fraction. The node's parent must use map display coordinates.
8
+ * Owns neither body nor node; does not register with the world. Sprite rotation
9
+ * and scale remain application-owned because projection is not a rigid rotation.
10
+ */
11
+ export declare class TilePhysicsBinding {
12
+ readonly body: PhysicsBody;
13
+ readonly node: SceneNode;
14
+ readonly projection: TileProjection;
15
+ constructor(body: PhysicsBody, node: SceneNode, projection: TileProjection);
16
+ sync(): void;
17
+ /** Interpolates logical positions before projection; teleport semantics follow PhysicsBody. */
18
+ syncInterpolated(alpha: number): void;
19
+ private _sync;
20
+ }
21
+ //# sourceMappingURL=TilePhysicsBinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TilePhysicsBinding.d.ts","sourceRoot":"","sources":["../../src/TilePhysicsBinding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;GAMG;AACH,qBAAa,kBAAkB;aAEX,IAAI,EAAE,WAAW;aACjB,IAAI,EAAE,SAAS;aACf,UAAU,EAAE,cAAc;IAH5C,YACkB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,cAAc,EACxC;IAEG,IAAI,IAAI,IAAI,CAElB;IAED,+FAA+F;IACxF,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAG3C;IAED,OAAO,CAAC,KAAK;CAQd"}
@@ -0,0 +1,35 @@
1
+ //#region src/TilePhysicsBinding.ts
2
+ /**
3
+ * Explicit presentation of a logical physics body through a tile projection.
4
+ * Call after stepping the world, or use syncInterpolated with the fixed-step
5
+ * interpolation fraction. The node's parent must use map display coordinates.
6
+ * Owns neither body nor node; does not register with the world. Sprite rotation
7
+ * and scale remain application-owned because projection is not a rigid rotation.
8
+ */
9
+ var TilePhysicsBinding = class {
10
+ body;
11
+ node;
12
+ projection;
13
+ constructor(body, node, projection) {
14
+ this.body = body;
15
+ this.node = node;
16
+ this.projection = projection;
17
+ }
18
+ sync() {
19
+ this._sync(this.body.x, this.body.y);
20
+ }
21
+ /** Interpolates logical positions before projection; teleport semantics follow PhysicsBody. */
22
+ syncInterpolated(alpha) {
23
+ const body = this.body;
24
+ this._sync(body.previousX + (body.x - body.previousX) * alpha, body.previousY + (body.y - body.previousY) * alpha);
25
+ }
26
+ _sync(x, y) {
27
+ const p = this.projection;
28
+ if (p.orientation === "isometric") this.node.setPosition(p.originX + (x - y) * p.tileWidth / (2 * p.tileHeight), p.originY + (x + y) / 2);
29
+ else this.node.setPosition(p.originX + x, p.originY + y);
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ export { TilePhysicsBinding };
35
+ //# sourceMappingURL=TilePhysicsBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TilePhysicsBinding.js","names":[],"sources":["../../src/TilePhysicsBinding.ts"],"sourcesContent":["import type { SceneNode } from '@codexo/exojs';\nimport type { PhysicsBody } from '@codexo/exojs-physics';\nimport type { TileProjection } from '@codexo/exojs-tilemap';\n\n/**\n * Explicit presentation of a logical physics body through a tile projection.\n * Call after stepping the world, or use syncInterpolated with the fixed-step\n * interpolation fraction. The node's parent must use map display coordinates.\n * Owns neither body nor node; does not register with the world. Sprite rotation\n * and scale remain application-owned because projection is not a rigid rotation.\n */\nexport class TilePhysicsBinding {\n public constructor(\n public readonly body: PhysicsBody,\n public readonly node: SceneNode,\n public readonly projection: TileProjection,\n ) {}\n\n public sync(): void {\n this._sync(this.body.x, this.body.y);\n }\n\n /** Interpolates logical positions before projection; teleport semantics follow PhysicsBody. */\n public syncInterpolated(alpha: number): void {\n const body = this.body;\n this._sync(body.previousX + (body.x - body.previousX) * alpha, body.previousY + (body.y - body.previousY) * alpha);\n }\n\n private _sync(x: number, y: number): void {\n const p = this.projection;\n if (p.orientation === 'isometric') {\n this.node.setPosition(p.originX + ((x - y) * p.tileWidth) / (2 * p.tileHeight), p.originY + (x + y) / 2);\n } else {\n this.node.setPosition(p.originX + x, p.originY + y);\n }\n }\n}\n"],"mappings":";;;;;;;;AAWA,IAAa,qBAAb,MAAgC;CAEZ;CACA;CACA;CAHlB,AAAO,YACL,AAAgB,MAChB,AAAgB,MAChB,AAAgB,YAChB;EAHgB;EACA;EACA;CACf;CAEH,AAAO,OAAa;EAClB,KAAK,MAAM,KAAK,KAAK,GAAG,KAAK,KAAK,CAAC;CACrC;;CAGA,AAAO,iBAAiB,OAAqB;EAC3C,MAAM,OAAO,KAAK;EAClB,KAAK,MAAM,KAAK,aAAa,KAAK,IAAI,KAAK,aAAa,OAAO,KAAK,aAAa,KAAK,IAAI,KAAK,aAAa,KAAK;CACnH;CAEA,AAAQ,MAA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reamer.js";
3
+ import { TilePhysicsBinding } from "./TilePhysicsBinding.js";
3
4
 
4
- export { TileColliderStreamer, buildObjectLayerColliders };
5
+ export { TileColliderStreamer, TilePhysicsBinding, buildObjectLayerColliders };
@@ -11,7 +11,7 @@ export interface ResolvedMaterial {
11
11
  /** Resolve the call-level defaults once, before any geometry is walked. */
12
12
  export declare const resolveDefaults: (options: ColliderDefaults) => ResolvedMaterial;
13
13
  /** Apply a resolver's overrides over already-resolved defaults. */
14
- export declare const resolveMaterial: (defaults: ResolvedMaterial, resolver: ColliderDefaults["material"], context: TileColliderContext) => ResolvedMaterial;
14
+ export declare const resolveMaterial: (defaults: ResolvedMaterial, resolver: ColliderDefaults['material'], context: TileColliderContext) => ResolvedMaterial;
15
15
  /**
16
16
  * Identity of everything a chain collider can carry, used to decide which solid
17
17
  * cells may be traced into a common outline.
@@ -1 +1 @@
1
- {"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../src/material.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMrE,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,gBAU1D,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,eAAe,GAAI,UAAU,gBAAgB,EAAE,UAAU,gBAAgB,CAAC,UAAU,CAAC,EAAE,SAAS,mBAAmB,KAAG,gBAkBlI,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,gBAAgB,KAAG,MACiG,CAAC"}
1
+ {"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../src/material.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMrE,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,YAAa,gBAAgB,KAAG,gBAU1D,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,eAAe,aAAc,gBAAgB,YAAY,gBAAgB,CAAC,UAAU,CAAC,WAAW,mBAAmB,KAAG,gBAkBlI,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,aAAc,gBAAgB,KAAG,MACiG,CAAC"}
@@ -20,8 +20,8 @@ export interface ObjectCollider {
20
20
  * them through the world. Use {@link import('./TileColliderStreamer').TileColliderStreamer}
21
21
  * for tile layers, whose chunks come and go.
22
22
  *
23
- * The layer's pixel offset is applied, so the colliders land where the layer is
24
- * drawn. Objects with no collision geometry (points, tile and text objects) are
23
+ * The layer's display offset is converted to a logical translation. Isometric
24
+ * geometry remains in logical space; use TilePhysicsBinding for presentation. Objects with no collision geometry (points, tile and text objects) are
25
25
  * skipped, as is any object the decomposition rejects - with a warning, not an
26
26
  * exception.
27
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"objectLayer.d.ts","sourceRoot":"","sources":["../../src/objectL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AyB,UAAW,YAAY,SAAS,WAAW,YAAW,qBAAqB,KAAQ,cAAc,EA4BtI,CAAC"}
@@ -12,8 +12,8 @@ import { PhysicsBody } from "@codexo/exojs-physics";
12
12
  * them through the world. Use {@link import('./TileColliderStreamer').TileColliderStreamer}
13
13
  * for tile layers, whose chunks come and go.
14
14
  *
15
- * The layer's pixel offset is applied, so the colliders land where the layer is
16
- * drawn. Objects with no collision geometry (points, tile and text objects) are
15
+ * The layer's display offset is converted to a logical translation. Isometric
16
+ * geometry remains in logical space; use TilePhysicsBinding for presentation. Objects with no collision geometry (points, tile and text objects) are
17
17
  * skipped, as is any object the decomposition rejects - with a warning, not an
18
18
  * exception.
19
19
  */
@@ -23,8 +23,13 @@ const buildObjectLayerColliders = (world, layer, options = {}) => {
23
23
  const built = [];
24
24
  for (const object of layer.objects) {
25
25
  if (accept !== void 0 && !accept(object)) continue;
26
- const x = object.x + layer.offsetX;
27
- const y = object.y + layer.offsetY;
26
+ const p = layer.projection;
27
+ const offset = p === void 0 ? {
28
+ x: layer.offsetX,
29
+ y: layer.offsetY
30
+ } : p.pixelToLogical(p.originX + layer.offsetX, p.originY + layer.offsetY);
31
+ const x = object.x + offset.x;
32
+ const y = object.y + offset.y;
28
33
  const material = resolveMaterial(defaults, options.material, {
29
34
  type: object.type,
30
35
  object
@@ -1 +1 @@
1
- {"version":3,"file":"objectLayer.js","names":[],"sources":["../../src/objectLayer.ts"],"sourcesContent":["import { PhysicsBody, type PhysicsWorld } from '@codexo/exojs-physics';\nimport type { ObjectLayer, TileMapObject } from '@codexo/exojs-tilemap';\n\nimport { collidersForGeometry, objectLabel } from './buildColliders';\nimport { resolveDefaults, resolveMaterial } from './material';\nimport type { ColliderDefaults } from './types';\n\n/** Options for {@link buildObjectLayerColliders}. */\nexport interface ObjectColliderOptions extends ColliderDefaults {\n /** Drop an object before a body is built for it. Return `true` to keep it. */\n accept?: (object: TileMapObject) => boolean;\n}\n\n/** One static body built from one object, paired with its source. */\nexport interface ObjectCollider {\n readonly object: TileMapObject;\n readonly body: PhysicsBody;\n}\n\n/**\n * Build one static body per collision object in an object layer and add them to\n * `world`.\n *\n * An object layer is static data with no residency, so this is a one-shot\n * build with no lifecycle: the caller owns the returned bodies and destroys\n * them through the world. Use {@link import('./TileColliderStreamer').TileColliderStreamer}\n * for tile layers, whose chunks come and go.\n *\n * The layer's pixel offset is applied, so the colliders land where the layer is\n * drawn. Objects with no collision geometry (points, tile and text objects) are\n * skipped, as is any object the decomposition rejects - with a warning, not an\n * exception.\n */\nexport const buildObjectLayerColliders = (world: PhysicsWorld, layer: ObjectLayer, options: ObjectColliderOptions = {}): ObjectCollider[] => {\n const defaults = resolveDefaults(options);\n const accept = options.accept;\n const built: ObjectCollider[] = [];\n\n for (const object of layer.objects) {\n if (accept !== undefined && !accept(object)) {\n continue;\n }\n\n const x = object.x + layer.offsetX;\n const y = object.y + layer.offsetY;\n const material = resolveMaterial(defaults, options.material, { type: object.type, object });\n const colliders = collidersForGeometry({ ...object, x, y }, material, x, y, objectLabel(object));\n\n if (colliders.length === 0) {\n continue;\n }\n\n built.push({\n object,\n body: world.add(new PhysicsBody({ type: 'static', position: { x, y }, colliders })),\n });\n }\n\n return built;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,MAAa,6BAA6B,OAAqB,OAAoB,UAAiC,CAAC,MAAwB;CAC3I,MAAM,WAAW,gBAAgB,OAAO;CACxC,MAAM,SAAS,QAAQ;CACvB,MAAM,QAA0B,CAAC;CAEjC,KAAK,MAAM,UAAU,MAAM,SAAS;EAClC,IAAI,WAAW,UAAa,CAAC,OAAO,MAAM,GACxC;EAGF,MAAM,IAAI,OAAO,IAAI,MAAM;EAC3B,MAAM,IAAI,OAAO,IAAI,MAAM;EAC3B,MAAM,WAAW,gBAAgB,UAAU,QAAQ,UAAU;GAAE,MAAM,OAAO;GAAM;EAAO,CAAC;EAC1F,MAAM,YAAY,qBAAqB;GAAE,GAAG;GAAQ;GAAG;EAAE,GAAG,UAAU,GAAG,GAAG,YAAY,MAAM,CAAC;EAE/F,IAAI,UAAU,WAAW,GACvB;EAGF,MAAM,KAAK;GACT;GACA,MAAM,MAAM,IAAI,IAAI,YAAY;IAAE,MAAM;IAAU,UAAU;KAAE;KAAG;IAAE;IAAG;GAAU,CAAC,CAAC;EACpF,CAAC;CACH;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"objectLayer.js","names":[],"sources":["../../src/objectLayer.ts"],"sourcesContent":["import { PhysicsBody, type PhysicsWorld } from '@codexo/exojs-physics';\nimport type { ObjectLayer, TileMapObject } from '@codexo/exojs-tilemap';\n\nimport { collidersForGeometry, objectLabel } from './buildColliders';\nimport { resolveDefaults, resolveMaterial } from './material';\nimport type { ColliderDefaults } from './types';\n\n/** Options for {@link buildObjectLayerColliders}. */\nexport interface ObjectColliderOptions extends ColliderDefaults {\n /** Drop an object before a body is built for it. Return `true` to keep it. */\n accept?: (object: TileMapObject) => boolean;\n}\n\n/** One static body built from one object, paired with its source. */\nexport interface ObjectCollider {\n readonly object: TileMapObject;\n readonly body: PhysicsBody;\n}\n\n/**\n * Build one static body per collision object in an object layer and add them to\n * `world`.\n *\n * An object layer is static data with no residency, so this is a one-shot\n * build with no lifecycle: the caller owns the returned bodies and destroys\n * them through the world. Use {@link import('./TileColliderStreamer').TileColliderStreamer}\n * for tile layers, whose chunks come and go.\n *\n * The layer's display offset is converted to a logical translation. Isometric\n * geometry remains in logical space; use TilePhysicsBinding for presentation. Objects with no collision geometry (points, tile and text objects) are\n * skipped, as is any object the decomposition rejects - with a warning, not an\n * exception.\n */\nexport const buildObjectLayerColliders = (world: PhysicsWorld, layer: ObjectLayer, options: ObjectColliderOptions = {}): ObjectCollider[] => {\n const defaults = resolveDefaults(options);\n const accept = options.accept;\n const built: ObjectCollider[] = [];\n\n for (const object of layer.objects) {\n if (accept !== undefined && !accept(object)) {\n continue;\n }\n\n const p = layer.projection;\n const offset = p === undefined ? { x: layer.offsetX, y: layer.offsetY } : p.pixelToLogical(p.originX + layer.offsetX, p.originY + layer.offsetY);\n const x = object.x + offset.x;\n const y = object.y + offset.y;\n const material = resolveMaterial(defaults, options.material, { type: object.type, object });\n const colliders = collidersForGeometry({ ...object, x, y }, material, x, y, objectLabel(object));\n\n if (colliders.length === 0) {\n continue;\n }\n\n built.push({\n object,\n body: world.add(new PhysicsBody({ type: 'static', position: { x, y }, colliders })),\n });\n }\n\n return built;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,MAAa,6BAA6B,OAAqB,OAAoB,UAAiC,CAAC,MAAwB;CAC3I,MAAM,WAAW,gBAAgB,OAAO;CACxC,MAAM,SAAS,QAAQ;CACvB,MAAM,QAA0B,CAAC;CAEjC,KAAK,MAAM,UAAU,MAAM,SAAS;EAClC,IAAI,WAAW,UAAa,CAAC,OAAO,MAAM,GACxC;EAGF,MAAM,IAAI,MAAM;EAChB,MAAM,SAAS,MAAM,SAAY;GAAE,GAAG,MAAM;GAAS,GAAG,MAAM;EAAQ,IAAI,EAAE,eAAe,EAAE,UAAU,MAAM,SAAS,EAAE,UAAU,MAAM,OAAO;EAC/I,MAAM,IAAI,OAAO,IAAI,OAAO;EAC5B,MAAM,IAAI,OAAO,IAAI,OAAO;EAC5B,MAAM,WAAW,gBAAgB,UAAU,QAAQ,UAAU;GAAE,MAAM,OAAO;GAAM;EAAO,CAAC;EAC1F,MAAM,YAAY,qBAAqB;GAAE,GAAG;GAAQ;GAAG;EAAE,GAAG,UAAU,GAAG,GAAG,YAAY,MAAM,CAAC;EAE/F,IAAI,UAAU,WAAW,GACvB;EAGF,MAAM,KAAK;GACT;GACA,MAAM,MAAM,IAAI,IAAI,YAAY;IAAE,MAAM;IAAU,UAAU;KAAE;KAAG;IAAE;IAAG;GAAU,CAAC,CAAC;EACpF,CAAC;CACH;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/outline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAgK/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,SAAS,MAAM,EAAE,KAAG,SAAS,EAAE,EA0D7E,CAAC"}
1
+ {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/outline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAgK/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,gBAAiB,SAAS,MAAM,EAAE,KAAG,SAAS,EAAE,EA0D7E,CAAC"}
@@ -2,5 +2,6 @@ export type { ObjectCollider, ObjectColliderOptions } from './objectLayer';
2
2
  export { buildObjectLayerColliders } from './objectLayer';
3
3
  export type { TileColliderOptions } from './TileColliderStreamer';
4
4
  export { TileColliderStreamer } from './TileColliderStreamer';
5
+ export { TilePhysicsBinding } from './TilePhysicsBinding';
5
6
  export type { ColliderDefaults, TileColliderContext, TileColliderMaterial, TileColliderMaterialResolver, TileRegionMode } from './types';
6
7
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAIA,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAIA,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexo/exojs-tilemap-physics",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
4
4
  "description": "Static physics colliders from ExoJS tilemap collision geometry.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,17 +26,17 @@
26
26
  "LICENSE"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@codexo/exojs": "0.18.x",
30
- "@codexo/exojs-physics": "0.18.x",
31
- "@codexo/exojs-tilemap": "0.18.x"
29
+ "@codexo/exojs": "0.19.x",
30
+ "@codexo/exojs-physics": "0.19.x",
31
+ "@codexo/exojs-tilemap": "0.19.x"
32
32
  },
33
33
  "devDependencies": {
34
- "@codexo/exojs": "0.18.0",
34
+ "@codexo/exojs": "0.19.1",
35
+ "@codexo/exojs-physics": "0.19.1",
36
+ "@codexo/exojs-ldtk": "0.19.1",
37
+ "@codexo/exojs-tiled": "0.19.1",
35
38
  "@codexo/exojs-config": "0.0.0",
36
- "@codexo/exojs-ldtk": "0.18.0",
37
- "@codexo/exojs-tiled": "0.18.0",
38
- "@codexo/exojs-tilemap": "0.18.0",
39
- "@codexo/exojs-physics": "0.18.0"
39
+ "@codexo/exojs-tilemap": "0.19.1"
40
40
  },
41
41
  "license": "MIT",
42
42
  "publishConfig": {
@@ -45,7 +45,7 @@
45
45
  "scripts": {
46
46
  "build": "tsx ../../scripts/build-extension.ts",
47
47
  "build:dev": "tsx ../../scripts/build-extension.ts --dev",
48
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
48
+ "typecheck": "exo-tsc --noEmit && exo-tsc --noEmit -p tsconfig.test.json",
49
49
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
50
50
  "test": "vitest run --root ../.. --project=exojs-tilemap-physics"
51
51
  }