@codexo/exojs-tilemap 0.19.0 → 0.20.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.
Files changed (157) hide show
  1. package/README.md +7 -163
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +12 -20
  5. package/dist/esm/ChunkSource.d.ts +0 -33
  6. package/dist/esm/ChunkSource.d.ts.map +0 -1
  7. package/dist/esm/ChunkStreamer.d.ts +0 -104
  8. package/dist/esm/ChunkStreamer.d.ts.map +0 -1
  9. package/dist/esm/ChunkStreamer.js +0 -229
  10. package/dist/esm/ChunkStreamer.js.map +0 -1
  11. package/dist/esm/ImageLayer.d.ts +0 -89
  12. package/dist/esm/ImageLayer.d.ts.map +0 -1
  13. package/dist/esm/ImageLayer.js +0 -74
  14. package/dist/esm/ImageLayer.js.map +0 -1
  15. package/dist/esm/ImageLayerNode.d.ts +0 -91
  16. package/dist/esm/ImageLayerNode.d.ts.map +0 -1
  17. package/dist/esm/ImageLayerNode.js +0 -210
  18. package/dist/esm/ImageLayerNode.js.map +0 -1
  19. package/dist/esm/MapObject.d.ts +0 -70
  20. package/dist/esm/MapObject.d.ts.map +0 -1
  21. package/dist/esm/MapObject.js +0 -34
  22. package/dist/esm/MapObject.js.map +0 -1
  23. package/dist/esm/MapObjectSpawner.d.ts +0 -133
  24. package/dist/esm/MapObjectSpawner.d.ts.map +0 -1
  25. package/dist/esm/MapObjectSpawner.js +0 -147
  26. package/dist/esm/MapObjectSpawner.js.map +0 -1
  27. package/dist/esm/MapSpawnSession.d.ts +0 -46
  28. package/dist/esm/MapSpawnSession.d.ts.map +0 -1
  29. package/dist/esm/MapSpawnSession.js +0 -88
  30. package/dist/esm/MapSpawnSession.js.map +0 -1
  31. package/dist/esm/MapWorld.d.ts +0 -134
  32. package/dist/esm/MapWorld.d.ts.map +0 -1
  33. package/dist/esm/MapWorld.js +0 -150
  34. package/dist/esm/MapWorld.js.map +0 -1
  35. package/dist/esm/MapWorldRuntime.d.ts +0 -180
  36. package/dist/esm/MapWorldRuntime.d.ts.map +0 -1
  37. package/dist/esm/MapWorldRuntime.js +0 -261
  38. package/dist/esm/MapWorldRuntime.js.map +0 -1
  39. package/dist/esm/ObjectLayer.d.ts +0 -379
  40. package/dist/esm/ObjectLayer.d.ts.map +0 -1
  41. package/dist/esm/ObjectLayer.js +0 -221
  42. package/dist/esm/ObjectLayer.js.map +0 -1
  43. package/dist/esm/SampledChunkSource.d.ts +0 -43
  44. package/dist/esm/SampledChunkSource.d.ts.map +0 -1
  45. package/dist/esm/SampledChunkSource.js +0 -48
  46. package/dist/esm/SampledChunkSource.js.map +0 -1
  47. package/dist/esm/TileAnimator.d.ts +0 -72
  48. package/dist/esm/TileAnimator.d.ts.map +0 -1
  49. package/dist/esm/TileAnimator.js +0 -158
  50. package/dist/esm/TileAnimator.js.map +0 -1
  51. package/dist/esm/TileChunk.d.ts +0 -103
  52. package/dist/esm/TileChunk.d.ts.map +0 -1
  53. package/dist/esm/TileChunk.js +0 -194
  54. package/dist/esm/TileChunk.js.map +0 -1
  55. package/dist/esm/TileChunkNode.d.ts +0 -2
  56. package/dist/esm/TileChunkNode.d.ts.map +0 -1
  57. package/dist/esm/TileChunkNode.js +0 -145
  58. package/dist/esm/TileChunkNode.js.map +0 -1
  59. package/dist/esm/TileLayer.d.ts +0 -286
  60. package/dist/esm/TileLayer.d.ts.map +0 -1
  61. package/dist/esm/TileLayer.js +0 -526
  62. package/dist/esm/TileLayer.js.map +0 -1
  63. package/dist/esm/TileLayerNode.d.ts +0 -129
  64. package/dist/esm/TileLayerNode.d.ts.map +0 -1
  65. package/dist/esm/TileLayerNode.js +0 -245
  66. package/dist/esm/TileLayerNode.js.map +0 -1
  67. package/dist/esm/TileMap.d.ts +0 -317
  68. package/dist/esm/TileMap.d.ts.map +0 -1
  69. package/dist/esm/TileMap.js +0 -406
  70. package/dist/esm/TileMap.js.map +0 -1
  71. package/dist/esm/TileMapBand.d.ts +0 -80
  72. package/dist/esm/TileMapBand.d.ts.map +0 -1
  73. package/dist/esm/TileMapBand.js +0 -155
  74. package/dist/esm/TileMapBand.js.map +0 -1
  75. package/dist/esm/TileMapNode.d.ts +0 -92
  76. package/dist/esm/TileMapNode.d.ts.map +0 -1
  77. package/dist/esm/TileMapNode.js +0 -134
  78. package/dist/esm/TileMapNode.js.map +0 -1
  79. package/dist/esm/TileMapView.d.ts +0 -248
  80. package/dist/esm/TileMapView.d.ts.map +0 -1
  81. package/dist/esm/TileMapView.js +0 -394
  82. package/dist/esm/TileMapView.js.map +0 -1
  83. package/dist/esm/TileProjection.d.ts +0 -59
  84. package/dist/esm/TileProjection.d.ts.map +0 -1
  85. package/dist/esm/TileProjection.js +0 -106
  86. package/dist/esm/TileProjection.js.map +0 -1
  87. package/dist/esm/TileSet.d.ts +0 -116
  88. package/dist/esm/TileSet.d.ts.map +0 -1
  89. package/dist/esm/TileSet.js +0 -168
  90. package/dist/esm/TileSet.js.map +0 -1
  91. package/dist/esm/WangSet.d.ts +0 -80
  92. package/dist/esm/WangSet.d.ts.map +0 -1
  93. package/dist/esm/WangSet.js +0 -73
  94. package/dist/esm/WangSet.js.map +0 -1
  95. package/dist/esm/WorkerSampledChunkSource.d.ts +0 -94
  96. package/dist/esm/WorkerSampledChunkSource.d.ts.map +0 -1
  97. package/dist/esm/WorkerSampledChunkSource.js +0 -113
  98. package/dist/esm/WorkerSampledChunkSource.js.map +0 -1
  99. package/dist/esm/autoTile.d.ts +0 -88
  100. package/dist/esm/autoTile.d.ts.map +0 -1
  101. package/dist/esm/autoTile.js +0 -173
  102. package/dist/esm/autoTile.js.map +0 -1
  103. package/dist/esm/chunkGeometry.d.ts +0 -2
  104. package/dist/esm/chunkGeometry.d.ts.map +0 -1
  105. package/dist/esm/chunkGeometry.js +0 -116
  106. package/dist/esm/chunkGeometry.js.map +0 -1
  107. package/dist/esm/index.d.ts +0 -2
  108. package/dist/esm/index.d.ts.map +0 -1
  109. package/dist/esm/index.js +0 -27
  110. package/dist/esm/nodeBounds.d.ts +0 -2
  111. package/dist/esm/nodeBounds.d.ts.map +0 -1
  112. package/dist/esm/nodeBounds.js +0 -40
  113. package/dist/esm/nodeBounds.js.map +0 -1
  114. package/dist/esm/pixelSnap.d.ts +0 -2
  115. package/dist/esm/pixelSnap.d.ts.map +0 -1
  116. package/dist/esm/pixelSnap.js +0 -21
  117. package/dist/esm/pixelSnap.js.map +0 -1
  118. package/dist/esm/projectObject.d.ts +0 -4
  119. package/dist/esm/projectObject.d.ts.map +0 -1
  120. package/dist/esm/projectObject.js +0 -87
  121. package/dist/esm/projectObject.js.map +0 -1
  122. package/dist/esm/public.d.ts +0 -48
  123. package/dist/esm/public.d.ts.map +0 -1
  124. package/dist/esm/tileCollision.d.ts +0 -190
  125. package/dist/esm/tileCollision.d.ts.map +0 -1
  126. package/dist/esm/tileCollision.js +0 -399
  127. package/dist/esm/tileCollision.js.map +0 -1
  128. package/dist/esm/tileWord.d.ts +0 -2
  129. package/dist/esm/tileWord.d.ts.map +0 -1
  130. package/dist/esm/tileWord.js +0 -16
  131. package/dist/esm/tileWord.js.map +0 -1
  132. package/dist/esm/tilemapExtension.d.ts +0 -20
  133. package/dist/esm/tilemapExtension.d.ts.map +0 -1
  134. package/dist/esm/tilemapExtension.js +0 -53
  135. package/dist/esm/tilemapExtension.js.map +0 -1
  136. package/dist/esm/tilemapSerializers.d.ts +0 -2
  137. package/dist/esm/tilemapSerializers.d.ts.map +0 -1
  138. package/dist/esm/tilemapSerializers.js +0 -54
  139. package/dist/esm/tilemapSerializers.js.map +0 -1
  140. package/dist/esm/types.d.ts +0 -231
  141. package/dist/esm/types.d.ts.map +0 -1
  142. package/dist/esm/types.js +0 -129
  143. package/dist/esm/types.js.map +0 -1
  144. package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +0 -2
  145. package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +0 -1
  146. package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +0 -376
  147. package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +0 -1
  148. package/dist/esm/webgl2/shaders/tile-chunk.frag.js +0 -6
  149. package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +0 -1
  150. package/dist/esm/webgl2/shaders/tile-chunk.vert.js +0 -6
  151. package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +0 -1
  152. package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +0 -2
  153. package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +0 -1
  154. package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +0 -539
  155. package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +0 -1
  156. package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +0 -6
  157. package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ObjectLayer.js","names":[],"sources":["../../src/ObjectLayer.ts"],"sourcesContent":["import type { TileProjection } from './TileProjection';\nimport type { ResolvedTile, TileProperties, TilePropertyObjectRef, TilePropertyValue } from './types';\nimport { TilePropertyKind } from './types';\n\n/**\n * Geometry kinds for a {@link TileMapObject}, as an `as const` value object.\n *\n * Modelled as a frozen string map (not a TS `enum`) so the values stay\n * wire-compatible with the Tiled string serialisation, survive\n * `verbatimModuleSyntax` (no emitted runtime helper), and follow the package\n * convention for enum-like constants. Use the members for ergonomic, typo-safe\n * call sites: `layer.byKind(ObjectKind.Polygon)`.\n * @stable\n */\nexport const ObjectKind = {\n Rectangle: 'rectangle',\n Ellipse: 'ellipse',\n Polygon: 'polygon',\n Polyline: 'polyline',\n Point: 'point',\n Tile: 'tile',\n Text: 'text',\n} as const;\n\n/** Geometry discriminant for a {@link TileMapObject}. */\nexport type ObjectKind = (typeof ObjectKind)[keyof typeof ObjectKind];\n\n/**\n * Geometry discriminant for a {@link TileMapObject}.\n * Structural alias of {@link ObjectKind}; retained so existing code keeps\n * compiling. New code may prefer {@link ObjectKind}.\n */\nexport type TileMapObjectKind = ObjectKind;\n\n/** A point in object-layer space (pixels, relative to the object). */\nexport interface ObjectPoint {\n readonly x: number;\n readonly y: number;\n}\n\n/** Fields shared by every {@link TileMapObject} kind. */\ninterface TileMapObjectBase<P extends TileProperties = TileProperties> {\n /** Source-unique object id. */\n readonly id: number;\n /**\n * Stable string identity assigned by the authoring format, when it has one.\n *\n * LDtk sets it to the entity `iid`, which is globally unique and survives\n * re-ordering, re-export and level moves - the identity to persist in a\n * savegame. Tiled has no such field and leaves this unset; there, {@link id}\n * is the identity and it is unique only within its map.\n */\n readonly sourceId?: string;\n /** Object name (may be empty; not unique). */\n readonly name: string;\n /** Object class/type string (Tiled `type`/`class`; may be empty). */\n readonly type: string;\n /** X of the object origin in layer coordinates; logical pixels when the layer has a projection. */\n readonly x: number;\n /** Y of the object origin in layer coordinates; logical pixels when the layer has a projection. */\n readonly y: number;\n /** Bounding width in px (0 for points). */\n readonly width: number;\n /** Bounding height in px (0 for points). */\n readonly height: number;\n /**\n * Rotation in degrees, clockwise, about `(x, y)` - except on a\n * {@link TileObject}, whose pivot stays at the source format's own anchor and\n * is generally not `(x, y)`. See {@link TileObject} for why.\n */\n readonly rotation: number;\n /** Whether the object is marked visible. */\n readonly visible: boolean;\n /** Immutable custom properties. */\n readonly properties: P;\n /**\n * The raw source-format record this object was parsed from, for the rare\n * case that needs a field this model does not carry. Adapters that keep\n * their parsed document alive set it (`LdtkEntityInstance` for LDtk,\n * `TiledObject` for Tiled); a procedurally built object has none.\n *\n * Reading it ties the code to one source format - prefer the typed fields.\n */\n readonly source?: unknown;\n}\n\n/** An axis-aligned rectangle object spanning `[x, y, width, height]`. */\nexport interface RectangleObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Rectangle;\n}\n\n/** An ellipse inscribed in `[x, y, width, height]`. */\nexport interface EllipseObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Ellipse;\n}\n\n/** A single point at `(x, y)`. */\nexport interface PointObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Point;\n}\n\n/** A closed polygon; `points` are relative to the object origin. */\nexport interface PolygonObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Polygon;\n readonly points: readonly ObjectPoint[];\n}\n\n/** An open polyline; `points` are relative to the object origin. */\nexport interface PolylineObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Polyline;\n readonly points: readonly ObjectPoint[];\n}\n\n/**\n * A tile (GID) object carrying a resolved tile reference.\n *\n * `x`/`y` are the top-left corner of the bounding box, the same convention as\n * every other object kind. Source formats that anchor a tile object elsewhere\n * normalise to the corner on import: Tiled stores the position at the\n * tileset's `objectalignment` point (bottom-left by default on an orthogonal\n * map, bottom-centre on an isometric one) and rotates the tile image about\n * that point, so a non-zero {@link TileMapObjectBase.rotation} on a tile\n * object still pivots about the source anchor rather than about `(x, y)`.\n * Isometric Tiled objects expose this anchor as `rotationOrigin`;\n * `getDisplayObject` projects both the unrotated corner and this pivot.\n *\n * The owning tileset's drawing offset (Tiled `tileoffset`, reachable as\n * `tile.tileset.offsetX`/`offsetY`) is likewise **not** folded into `x`/`y`.\n * Object layers are data-only, so nothing in this package draws a tile object;\n * code that does has to add that offset itself to match how a tile layer\n * places the same tile.\n */\nexport interface TileObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Tile;\n readonly tile: ResolvedTile;\n /** Image rotation pivot in layer coordinates, logical when projected. Adapters may omit it when unavailable. */\n readonly rotationOrigin?: ObjectPoint;\n}\n\n/** Text styling options carried by a {@link TextObject}. */\nexport interface TextStyle {\n /** The text content. */\n readonly text: string;\n /** Text colour as 0xRRGGBB, or `null` if default. */\n readonly color?: number | null;\n /** Font family name. */\n readonly fontFamily?: string;\n /** Font size in pixels. */\n readonly pixelSize?: number;\n /** Bold text. */\n readonly bold?: boolean;\n /** Italic text. */\n readonly italic?: boolean;\n /** Underline text. */\n readonly underline?: boolean;\n /** Strikeout text. */\n readonly strikeout?: boolean;\n /** Wrap text within the object bounds. */\n readonly wrap?: boolean;\n /** Horizontal alignment. */\n readonly halign?: 'left' | 'center' | 'right' | 'justify';\n /** Vertical alignment. */\n readonly valign?: 'top' | 'center' | 'bottom';\n}\n\n/** A text object carrying styled text content within `[x, y, width, height]`. */\nexport interface TextObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {\n readonly kind: typeof ObjectKind.Text;\n readonly text: TextStyle;\n}\n\n/**\n * A format-independent map object. The geometry kind is the discriminant;\n * narrow on `kind` to read shape-specific fields. Template objects are not\n * yet represented.\n *\n * The optional property-shape parameter `P` lets typed accessors\n * (see {@link ObjectLayer.byType}) narrow `properties` to a developer-declared\n * schema. It defaults to the generic {@link TileProperties} bag, so the plain\n * `TileMapObject` form is unchanged.\n * @advanced\n */\nexport type TileMapObject<P extends TileProperties = TileProperties> =\n RectangleObject<P> | EllipseObject<P> | PointObject<P> | PolygonObject<P> | PolylineObject<P> | TileObject<P> | TextObject<P>;\n\n/**\n * A developer-declared mapping from object `type`/class strings to the property\n * shape an object of that type is expected to carry. Supplied as the type\n * parameter to {@link ObjectLayer} to unlock the typed accessors\n * ({@link ObjectLayer.byType}, {@link ObjectLayer.where}).\n *\n * @remarks\n * A schema is a **developer promise, not a runtime guarantee.** Tiled data is\n * untyped at runtime and ExoJS performs no validation against the schema -\n * the property objects are returned exactly as parsed. The schema only refines\n * the static type of `properties` for ergonomic, typo-safe field access. If the\n * source data does not match the declared shape, reads still succeed but the\n * static type is a fiction. Validate at the boundary if you need certainty.\n *\n * @example\n * ```ts\n * const EntityType = { Spawn: 'spawn', Pickup: 'pickup' } as const;\n * interface LevelObjects {\n * [EntityType.Spawn]: { team: 'red' | 'blue' };\n * [EntityType.Pickup]: { item: 'coin' | 'gem'; amount: number };\n * }\n * const entities = map.getObjectLayer<LevelObjects>('Entities');\n * entities.byType(EntityType.Spawn)[0].properties.team; // 'red' | 'blue'\n * ```\n * @stable\n */\nexport type ObjectSchema = Record<string, TileProperties>;\n\n/**\n * A {@link TileMapObject} whose `properties` are narrowed to the schema shape\n * declared for the object `type` `T` in schema `S`.\n * @advanced\n */\nexport type TypedObject<S extends ObjectSchema, T extends keyof S & string> = TileMapObject<S[T]>;\n\n/** Filter for {@link ObjectLayer.query}. Unspecified fields match everything. */\nexport interface ObjectQuery {\n /** Match objects whose `name` equals this. */\n readonly name?: string;\n /** Match objects whose `type`/class equals this. */\n readonly type?: string;\n /** Match objects of this geometry kind. */\n readonly kind?: TileMapObjectKind;\n /** Match objects that carry this property key. */\n readonly property?: string;\n /** When combined with `property`, also require the property value to equal this. */\n readonly value?: TilePropertyValue;\n}\n\n/**\n * Type guard for the {@link TilePropertyObjectRef} variant of\n * {@link TilePropertyValue}.\n * @internal\n */\nconst isTilePropertyObjectRef = (value: TilePropertyValue): value is TilePropertyObjectRef =>\n typeof value === 'object' && value !== null && !Array.isArray(value) && (value as { kind?: unknown }).kind === TilePropertyKind.ObjectRef;\n\n/**\n * Equality used by {@link ObjectLayer.query}'s `value` filter.\n *\n * Scalars and `null` compare with `===`. `objectRef` values compare by `id`\n * alone - the one genuinely common \"find all objects referencing X\" query\n * need - regardless of differing LDtk navigation fields. Every other\n * structured shape (`point`, `tileRef`, arrays, nested property bags) has no\n * obvious value-equality semantics (exact float coordinates? array order?)\n * and only matches when reference-identical; use `query({ property })`\n * (presence-only) for those.\n * @internal\n */\nconst tilePropertyValueEquals = (a: TilePropertyValue, b: TilePropertyValue): boolean => {\n if (a === b) return true;\n if (isTilePropertyObjectRef(a) && isTilePropertyObjectRef(b)) return a.id === b.id;\n return false;\n};\n\n/** Construction options for an {@link ObjectLayer}. */\nexport interface ObjectLayerOptions {\n /** Object geometry uses logical pixels when supplied; display placement is available through getDisplayObject. */\n readonly projection?: TileProjection;\n /** Layer id (unique within the map). */\n readonly id: number;\n /** Layer name. */\n readonly name?: string;\n /** Layer class string. */\n readonly class?: string;\n /** Whether the layer is visible. Default `true`. */\n readonly visible?: boolean;\n /** Layer opacity in `[0, 1]`. Default `1`. */\n readonly opacity?: number;\n /** Layer pixel offset X. Default `0`. */\n readonly offsetX?: number;\n /** Layer pixel offset Y. Default `0`. */\n readonly offsetY?: number;\n /**\n * Parallax scroll factor on the X axis. `1` = full camera speed (normal),\n * `0.5` = half speed (farther away), `0` = stationary. Default `1`.\n */\n readonly parallaxX?: number;\n /**\n * Parallax scroll factor on the Y axis. `1` = full camera speed (normal),\n * `0.5` = half speed (farther away), `0` = stationary. Default `1`.\n */\n readonly parallaxY?: number;\n /** Uniform parallax scale around the layer origin. Default `1`. */\n readonly parallaxScale?: number;\n /**\n * Multiplicative layer tint as a `0xRRGGBB` integer, or `null` for no tint\n * (Tiled `tintcolor`). Default `null`.\n */\n readonly tintColor?: number | null;\n /**\n * Draw order for the objects (Tiled `draworder`): `'topdown'` (sorted by `y`)\n * or `'index'` (source order). Informational; objects are stored as given.\n * Default `'topdown'`.\n */\n readonly drawOrder?: 'topdown' | 'index';\n /** The objects in this layer. */\n readonly objects?: readonly TileMapObject[];\n /** Layer-level properties (copied and frozen). */\n readonly properties?: TileProperties;\n}\n\n/**\n * A data-only layer of {@link TileMapObject}s - spawn points, trigger zones,\n * collision regions, markers. Object layers are not rendered by the tile\n * renderer; they are parsed and exposed for gameplay use (e.g. building physics\n * colliders, placing entities).\n *\n * The presentation fields the source format attaches to a layer -\n * {@link visible}, {@link opacity}, {@link offsetX}/{@link offsetY},\n * {@link parallaxX}/{@link parallaxY}, {@link parallaxScale}, and\n * {@link tintColor} - are carried\n * through in full, with any enclosing group layers' contribution already\n * folded in, so an object layer describes the same placement and shading its\n * neighbouring tile and image layers do. Nothing here acts on them: code that\n * draws these objects itself is what applies them.\n *\n * Query with {@link query} (untyped, fully back-compatible) or, when an\n * {@link ObjectSchema} type argument `S` is supplied, with the typed accessors\n * {@link byType}, {@link byKind}, and {@link where} - these narrow `properties`\n * to the developer-declared shape. The schema is **opt-in**: the default type\n * parameter reproduces the original untyped behaviour, so\n * `new ObjectLayer(options)` and `map.getObjectLayer('x')` are unchanged.\n *\n * @remarks\n * A schema is a developer promise, not a runtime guarantee - Tiled data is\n * untyped at runtime and ExoJS performs no validation. See {@link ObjectSchema}.\n *\n * @typeParam S - Optional {@link ObjectSchema} mapping object `type` strings to\n * their property shapes. Defaults to a generic schema (every type maps to the\n * loose {@link TileProperties} bag).\n *\n * @advanced\n */\nexport class ObjectLayer<S extends ObjectSchema = ObjectSchema> {\n /** Projection of the logical object geometry, or undefined for ordinary display-space objects. */\n public readonly projection: TileProjection | undefined;\n /** Layer-kind discriminant (distinguishes object layers from tile layers). */\n public readonly kind = 'object' as const;\n\n /** Layer id (unique within the map). */\n public readonly id: number;\n /** Layer name. */\n public readonly name: string;\n /** Layer class string. */\n public readonly class: string;\n /** Whether the layer is visible. */\n public readonly visible: boolean;\n /** Layer opacity in `[0, 1]`. */\n public readonly opacity: number;\n /** Layer pixel offset X. */\n public readonly offsetX: number;\n /** Layer pixel offset Y. */\n public readonly offsetY: number;\n /**\n * Parallax scroll factor on the X axis - the same quantity\n * {@link import('./TileLayer').TileLayer.parallaxX} carries, so an object\n * layer authored beside a tile layer in the same parallax group reports the\n * same factor. `1` = full camera speed, `0.5` = half speed, `0` =\n * stationary. Nothing in this package applies it: object layers are\n * data-only, so placing an object relative to the camera is the consumer's\n * job (see {@link ObjectLayer}).\n */\n public readonly parallaxX: number;\n /** Parallax scroll factor on the Y axis. See {@link ObjectLayer.parallaxX}. */\n public readonly parallaxY: number;\n /** Uniform scale applied around the layer origin by consumers that render this data-only layer. */\n public readonly parallaxScale: number;\n /**\n * Multiplicative layer tint as `0xRRGGBB`, or `null` for no tint. Carried\n * from the source map (including the accumulated tint of any enclosing group\n * layers) for code that draws these objects itself; like\n * {@link ObjectLayer.parallaxX}, nothing in this package applies it.\n */\n public readonly tintColor: number | null;\n /** Draw order for the objects (Tiled `draworder`). Informational. */\n public readonly drawOrder: 'topdown' | 'index';\n /** Immutable layer-level properties. */\n public readonly properties: TileProperties;\n /** The objects in this layer (insertion order). */\n public readonly objects: readonly TileMapObject[];\n\n public constructor(options: ObjectLayerOptions) {\n this.id = options.id;\n this.projection = options.projection;\n this.name = options.name ?? '';\n this.class = options.class ?? '';\n this.visible = options.visible ?? true;\n this.opacity = options.opacity ?? 1;\n this.offsetX = options.offsetX ?? 0;\n this.offsetY = options.offsetY ?? 0;\n this.parallaxX = options.parallaxX ?? 1;\n this.parallaxY = options.parallaxY ?? 1;\n this.parallaxScale = options.parallaxScale ?? 1;\n if (!Number.isFinite(this.parallaxScale) || this.parallaxScale <= 0) {\n throw new Error('ObjectLayer parallaxScale must be a positive finite number.');\n }\n this.tintColor = options.tintColor ?? null;\n this.drawOrder = options.drawOrder ?? 'topdown';\n this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});\n this.objects = options.objects ? Object.freeze([...options.objects]) : Object.freeze([]);\n }\n\n /**\n * Returns display-space geometry including the layer offset. Isometric\n * rectangles become polygons; ellipses retain their exact affine shape.\n * Tile/text dimensions remain display pixels. Parallax and scene transforms\n * are applied by the consumer, after this conversion.\n */\n public getDisplayObject(object: TileMapObject): TileMapObject {\n const projected = this.projection?.projectObject(object) ?? object;\n const position = { x: projected.x + this.offsetX, y: projected.y + this.offsetY };\n if (projected.kind === 'tile' && projected.rotationOrigin) {\n return { ...projected, ...position, rotationOrigin: { x: projected.rotationOrigin.x + this.offsetX, y: projected.rotationOrigin.y + this.offsetY } };\n }\n return { ...projected, ...position };\n }\n\n /** Objects matching every specified criterion of `filter`. Returns a fresh array. */\n public query(filter: ObjectQuery = {}): TileMapObject[] {\n return this.objects.filter(object => {\n if (filter.name !== undefined && object.name !== filter.name) {\n return false;\n }\n\n if (filter.type !== undefined && object.type !== filter.type) {\n return false;\n }\n\n if (filter.kind !== undefined && object.kind !== filter.kind) {\n return false;\n }\n\n if (filter.property !== undefined) {\n // TilePropertyValue never includes `undefined`, so an `undefined`\n // read is a reliable \"key absent\" signal (equivalent to, but avoids\n // re-indexing after, an `in` check).\n const value = object.properties[filter.property];\n if (value === undefined) {\n return false;\n }\n\n if (filter.value !== undefined && !tilePropertyValueEquals(value, filter.value)) {\n return false;\n }\n }\n\n return true;\n });\n }\n\n /**\n * Objects whose `type` equals `type`, with `properties` narrowed to the\n * schema shape `S[T]`. Returns a fresh array (insertion order).\n *\n * The narrowing is a static convenience only - no runtime validation is\n * performed (see {@link ObjectSchema}). On an unschematised layer this\n * behaves like `query({ type })` with `TileProperties` properties.\n */\n public byType<T extends keyof S & string>(type: T): Array<TypedObject<S, T>> {\n return this.objects.filter(object => object.type === type) as unknown as Array<TypedObject<S, T>>;\n }\n\n /**\n * Objects of the given geometry {@link ObjectKind}, narrowed to that\n * geometry's member type (e.g. `byKind(ObjectKind.Polygon)` yields\n * {@link PolygonObject}s with their `points`). Returns a fresh array.\n */\n public byKind<K extends ObjectKind>(kind: K): Array<Extract<TileMapObject, { kind: K }>> {\n return this.objects.filter(object => object.kind === kind) as Array<Extract<TileMapObject, { kind: K }>>;\n }\n\n /**\n * Objects of `type` (typed as in {@link byType}) that also satisfy\n * `predicate`. A convenience combination of {@link byType} and `Array.filter`\n * that keeps the narrowed `properties` type inside the predicate. Returns a\n * fresh array.\n */\n public where<T extends keyof S & string>(type: T, predicate: (object: TypedObject<S, T>) => boolean): Array<TypedObject<S, T>> {\n return this.byType(type).filter(object => predicate(object));\n }\n\n /** First object with the given id, or undefined. */\n public getObjectById(id: number): TileMapObject | undefined {\n return this.objects.find(object => object.id === id);\n }\n\n /** First object with the given name, or undefined. */\n public getObjectByName(name: string): TileMapObject | undefined {\n return this.objects.find(object => object.name === name);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,aAAa;CACxB,WAAW;CACX,SAAS;CACT,SAAS;CACT,UAAU;CACV,OAAO;CACP,MAAM;CACN,MAAM;A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,WAA6E;EAC7H,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC,QAAO,WAAU,UAAU,MAAM,CAAC;CAC7D;;CAGA,AAAO,cAAc,IAAuC;EAC1D,OAAO,KAAK,QAAQ,MAAK,WAAU,OAAO,OAAO,EAAE;CACrD;;CAGA,AAAO,gBAAgB,MAAyC;EAC9D,OAAO,KAAK,QAAQ,MAAK,WAAU,OAAO,SAAS,IAAI;CACzD;AACF"}
@@ -1,43 +0,0 @@
1
- import type { ChunkSource } from './ChunkSource';
2
- import type { TileLayer } from './TileLayer';
3
- import type { ResolvedTile } from './types';
4
- /**
5
- * Options for {@link createSampledChunkSource}.
6
- * @advanced
7
- */
8
- export interface SampledChunkSourceOptions {
9
- /**
10
- * Sample a scalar value at a tile coordinate. Called once per tile within
11
- * each requested chunk. Must be a pure, deterministic function of
12
- * `(tx, ty)` - {@link import('./ChunkStreamer').ChunkStreamer} regenerates
13
- * a chunk from scratch via this source whenever it's revisited after
14
- * eviction, so a non-deterministic sampler would make previously-visited
15
- * terrain silently change underneath the player.
16
- */
17
- sample(tx: number, ty: number): number;
18
- /**
19
- * Convert a sampled value (and its tile coordinate, for position-dependent
20
- * logic such as river carving or map edges) into a resolved tile, or
21
- * `null` for an empty cell. Must be pure and deterministic, same
22
- * requirement as {@link sample}.
23
- */
24
- mapValueToTile(value: number, tx: number, ty: number): ResolvedTile | null;
25
- }
26
- /**
27
- * Build a {@link import('./ChunkStreamer').ChunkStreamer}-ready
28
- * {@link ChunkSource} from a caller-supplied sampling function - the
29
- * generic mechanism behind procedurally generated tile content (noise,
30
- * a heightmap, or any other per-tile-coordinate scalar function). This
31
- * module intentionally has no opinion on the sampling algorithm itself
32
- * ({@link SampledChunkSourceOptions.sample}/`mapValueToTile` are both
33
- * required, not defaulted) - pick or write whatever generation function
34
- * fits your game.
35
- *
36
- * `layer` supplies the target chunk grid ({@link TileLayer.chunkWidth}/
37
- * `chunkHeight`) and the tileset list tiles are packed against
38
- * ({@link TileLayer.tilesets}) - the same `TileLayer` you'll construct the
39
- * `ChunkStreamer` with.
40
- * @advanced
41
- */
42
- export declare const createSampledChunkSource: (layer: TileLayer, options: SampledChunkSourceOptions) => ChunkSource;
43
- //# sourceMappingURL=SampledChunkSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SampledChunkSource.d.ts","sourceRoot":"","sources":["../../src/SampledChunkSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;CAC5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,UAAW,SAAS,WAAW,yBAAyB,KAAG,WAiC/F,CAAC"}
@@ -1,48 +0,0 @@
1
- import { packTile } from "./types.js";
2
-
3
- //#region src/SampledChunkSource.ts
4
- /**
5
- * Build a {@link import('./ChunkStreamer').ChunkStreamer}-ready
6
- * {@link ChunkSource} from a caller-supplied sampling function - the
7
- * generic mechanism behind procedurally generated tile content (noise,
8
- * a heightmap, or any other per-tile-coordinate scalar function). This
9
- * module intentionally has no opinion on the sampling algorithm itself
10
- * ({@link SampledChunkSourceOptions.sample}/`mapValueToTile` are both
11
- * required, not defaulted) - pick or write whatever generation function
12
- * fits your game.
13
- *
14
- * `layer` supplies the target chunk grid ({@link TileLayer.chunkWidth}/
15
- * `chunkHeight`) and the tileset list tiles are packed against
16
- * ({@link TileLayer.tilesets}) - the same `TileLayer` you'll construct the
17
- * `ChunkStreamer` with.
18
- * @advanced
19
- */
20
- const createSampledChunkSource = (layer, options) => {
21
- const sample = options.sample.bind(options);
22
- const mapValueToTile = options.mapValueToTile.bind(options);
23
- return { getChunk(cx, cy) {
24
- const chunkWidth = layer.chunkWidth;
25
- const chunkHeight = layer.chunkHeight;
26
- const startTx = cx * chunkWidth;
27
- const startTy = cy * chunkHeight;
28
- let out = null;
29
- for (let ty = startTy; ty < startTy + chunkHeight; ty++) for (let tx = startTx; tx < startTx + chunkWidth; tx++) {
30
- if (layer.width !== void 0 && layer.height !== void 0 && (tx >= layer.width || ty >= layer.height)) continue;
31
- const value = sample(tx, ty);
32
- const resolved = mapValueToTile(value, tx, ty);
33
- if (!resolved) continue;
34
- out ??= new Uint32Array(chunkWidth * chunkHeight);
35
- const tilesetIndex = layer.tilesets.indexOf(resolved.tileset);
36
- out[(ty - startTy) * chunkWidth + (tx - startTx)] = packTile(tilesetIndex, resolved.localTileId, resolved.transform);
37
- }
38
- return out === null ? null : {
39
- width: chunkWidth,
40
- height: chunkHeight,
41
- tiles: out
42
- };
43
- } };
44
- };
45
-
46
- //#endregion
47
- export { createSampledChunkSource };
48
- //# sourceMappingURL=SampledChunkSource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SampledChunkSource.js","names":[],"sources":["../../src/SampledChunkSource.ts"],"sourcesContent":["import type { ChunkPayload, ChunkSource } from './ChunkSource';\nimport type { TileLayer } from './TileLayer';\nimport type { ResolvedTile } from './types';\nimport { packTile } from './types';\n\n/**\n * Options for {@link createSampledChunkSource}.\n * @advanced\n */\nexport interface SampledChunkSourceOptions {\n /**\n * Sample a scalar value at a tile coordinate. Called once per tile within\n * each requested chunk. Must be a pure, deterministic function of\n * `(tx, ty)` - {@link import('./ChunkStreamer').ChunkStreamer} regenerates\n * a chunk from scratch via this source whenever it's revisited after\n * eviction, so a non-deterministic sampler would make previously-visited\n * terrain silently change underneath the player.\n */\n sample(tx: number, ty: number): number;\n /**\n * Convert a sampled value (and its tile coordinate, for position-dependent\n * logic such as river carving or map edges) into a resolved tile, or\n * `null` for an empty cell. Must be pure and deterministic, same\n * requirement as {@link sample}.\n */\n mapValueToTile(value: number, tx: number, ty: number): ResolvedTile | null;\n}\n\n/**\n * Build a {@link import('./ChunkStreamer').ChunkStreamer}-ready\n * {@link ChunkSource} from a caller-supplied sampling function - the\n * generic mechanism behind procedurally generated tile content (noise,\n * a heightmap, or any other per-tile-coordinate scalar function). This\n * module intentionally has no opinion on the sampling algorithm itself\n * ({@link SampledChunkSourceOptions.sample}/`mapValueToTile` are both\n * required, not defaulted) - pick or write whatever generation function\n * fits your game.\n *\n * `layer` supplies the target chunk grid ({@link TileLayer.chunkWidth}/\n * `chunkHeight`) and the tileset list tiles are packed against\n * ({@link TileLayer.tilesets}) - the same `TileLayer` you'll construct the\n * `ChunkStreamer` with.\n * @advanced\n */\nexport const createSampledChunkSource = (layer: TileLayer, options: SampledChunkSourceOptions): ChunkSource => {\n const sample = options.sample.bind(options);\n const mapValueToTile = options.mapValueToTile.bind(options);\n\n return {\n getChunk(cx: number, cy: number): ChunkPayload | null {\n const chunkWidth = layer.chunkWidth;\n const chunkHeight = layer.chunkHeight;\n const startTx = cx * chunkWidth;\n const startTy = cy * chunkHeight;\n\n let out: Uint32Array | null = null;\n for (let ty = startTy; ty < startTy + chunkHeight; ty++) {\n for (let tx = startTx; tx < startTx + chunkWidth; tx++) {\n // Bounded-layer edge chunks may be smaller than a full chunk\n // (TileLayer._ensureChunk clamps them); this provider always\n // samples a full chunk rect, so clamp here instead of letting\n // _adoptChunk over-report tiles past the layer's declared bounds.\n if (layer.width !== undefined && layer.height !== undefined && (tx >= layer.width || ty >= layer.height)) continue;\n\n const value = sample(tx, ty);\n const resolved = mapValueToTile(value, tx, ty);\n if (!resolved) continue;\n\n out ??= new Uint32Array(chunkWidth * chunkHeight);\n const tilesetIndex = layer.tilesets.indexOf(resolved.tileset);\n out[(ty - startTy) * chunkWidth + (tx - startTx)] = packTile(tilesetIndex, resolved.localTileId, resolved.transform);\n }\n }\n\n return out === null ? null : { width: chunkWidth, height: chunkHeight, tiles: out };\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CA,MAAa,4BAA4B,OAAkB,YAAoD;CAC7G,MAAM,SAAS,QAAQ,OAAO,KAAK,OAAO;CAC1C,MAAM,iBAAiB,QAAQ,eAAe,KAAK,OAAO;CAE1D,OAAO,EACL,SAAS,IAAY,IAAiC;EACpD,MAAM,aAAa,MAAM;EACzB,MAAM,cAAc,MAAM;EAC1B,MAAM,UAAU,KAAK;EACrB,MAAM,UAAU,KAAK;EAErB,IAAI,MAA0B;EAC9B,KAAK,IAAI,KAAK,SAAS,KAAK,UAAU,aAAa,MACjD,KAAK,IAAI,KAAK,SAAS,KAAK,UAAU,YAAY,MAAM;GAKtD,IAAI,MAAM,UAAU,UAAa,MAAM,WAAW,WAAc,MAAM,MAAM,SAAS,MAAM,MAAM,SAAS;GAE1G,MAAM,QAAQ,OAAO,IAAI,EAAE;GAC3B,MAAM,WAAW,eAAe,OAAO,IAAI,EAAE;GAC7C,IAAI,CAAC,UAAU;GAEf,QAAQ,IAAI,YAAY,aAAa,WAAW;GAChD,MAAM,eAAe,MAAM,SAAS,QAAQ,SAAS,OAAO;GAC5D,KAAK,KAAK,WAAW,cAAc,KAAK,YAAY,SAAS,cAAc,SAAS,aAAa,SAAS,SAAS;EACrH;EAGF,OAAO,QAAQ,OAAO,OAAO;GAAE,OAAO;GAAY,QAAQ;GAAa,OAAO;EAAI;CACpF,EACF;AACF"}
@@ -1,72 +0,0 @@
1
- import type { TileLayer } from './TileLayer';
2
- /**
3
- * Drives per-tile animations on one or more {@link TileLayer}s, RPG-Maker style.
4
- *
5
- * On construction it scans the given layer(s) once and registers every cell
6
- * whose tile carries an `animation` (see {@link import('./types').TileDefinition}).
7
- * Each {@link update} advances a shared clock and rewrites **only** the
8
- * registered animated cells, and **only** when a cell crosses a frame boundary -
9
- * static tiles are never touched. Because a tile rewrite goes through
10
- * `layer.setTileAt`, only the chunks that actually contain animated cells rebuild
11
- * their geometry, and only on the (infrequent) frames where a boundary is
12
- * crossed. The large static body of the map never rebuilds.
13
- *
14
- * An unbounded {@link import('./TileLayer').TileLayer} (see
15
- * {@link import('./TileLayer').TileLayer.bounded}) is skipped entirely by
16
- * the initial scan and reports zero animated cells for that layer, rather
17
- * than sweeping every ever-loaded chunk. Streaming/procedural chunk
18
- * providers that need animated tiles must drive per-chunk `TileAnimator`
19
- * instances themselves (scanning only the newly-adopted chunk's tile
20
- * range) - a whole-layer `TileAnimator` is not currently wired to react to
21
- * chunk load/unload.
22
- *
23
- * Tick it from your update loop, like `TweenSequencer`:
24
- *
25
- * ```ts
26
- * const animator = new TileAnimator(map.layers);
27
- * scene.systems.add({ update: (t) => animator.update(t.deltaSeconds) });
28
- * ```
29
- *
30
- * The animator references - but never owns - the layers and their tilesets;
31
- * {@link destroy} only drops its own cell registry.
32
- *
33
- * @advanced
34
- */
35
- export declare class TileAnimator {
36
- private readonly _layers;
37
- private _cells;
38
- private _elapsedMs;
39
- /**
40
- * @param layers One layer, or an array of layers (e.g. `map.layers`), to scan
41
- * for animated tiles.
42
- */
43
- constructor(layers: TileLayer | readonly TileLayer[]);
44
- /** Number of animated cells currently registered across all layers. */
45
- get animatedCellCount(): number;
46
- /** Total elapsed animation time in milliseconds since construction/reset. */
47
- get elapsedMs(): number;
48
- /**
49
- * Advance all registered animations by `deltaSeconds` and write the current
50
- * frame into any cell that crossed a frame boundary. Cells that did not change
51
- * frame are not touched, so their chunks do not rebuild.
52
- *
53
- * @param deltaSeconds Elapsed wall-clock time since the last call, in seconds.
54
- */
55
- update(deltaSeconds: number): void;
56
- /**
57
- * Restore every animated cell to its first frame and reset the clock.
58
- * Useful before serialising or pausing.
59
- */
60
- reset(): void;
61
- /**
62
- * Re-scan the layers for animated cells. Call after structural edits that add
63
- * or remove animated tiles. Resets all currently-tracked cells to frame 0
64
- * first so the rescan starts from a clean, deterministic state.
65
- */
66
- rescan(): void;
67
- /** Drop the cell registry. Does not modify the layers or tilesets. */
68
- destroy(): void;
69
- /** Scan all layers for cells whose tile carries a (multi-frame) animation. */
70
- private _scan;
71
- }
72
- //# sourceMappingURL=TileAnimator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TileAnimator.d.ts","sourceRoot":"","sources":["../../src/TileAnimator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAmB7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,UAAU,CAAK;IAEvB;;;OAGG;IACH,YAAmB,MAAM,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE,EAG1D;IAED,uEAAuE;IACvE,IAAW,iBAAiB,IAAI,MAAM,CAErC;IAED,6EAA6E;IAC7E,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;;;OAMG;IACI,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAwBxC;IAED;;;OAGG;IACI,KAAK,IAAI,IAAI,CAcnB;IAED;;;;OAIG;IACI,MAAM,IAAI,IAAI,CAGpB;IAED,sEAAsE;IAC/D,OAAO,IAAI,IAAI,CAGrB;IAED,8EAA8E;IAC9E,OAAO,CAAC,KAAK;CAqDd"}
@@ -1,158 +0,0 @@
1
- //#region src/TileAnimator.ts
2
- /**
3
- * Drives per-tile animations on one or more {@link TileLayer}s, RPG-Maker style.
4
- *
5
- * On construction it scans the given layer(s) once and registers every cell
6
- * whose tile carries an `animation` (see {@link import('./types').TileDefinition}).
7
- * Each {@link update} advances a shared clock and rewrites **only** the
8
- * registered animated cells, and **only** when a cell crosses a frame boundary -
9
- * static tiles are never touched. Because a tile rewrite goes through
10
- * `layer.setTileAt`, only the chunks that actually contain animated cells rebuild
11
- * their geometry, and only on the (infrequent) frames where a boundary is
12
- * crossed. The large static body of the map never rebuilds.
13
- *
14
- * An unbounded {@link import('./TileLayer').TileLayer} (see
15
- * {@link import('./TileLayer').TileLayer.bounded}) is skipped entirely by
16
- * the initial scan and reports zero animated cells for that layer, rather
17
- * than sweeping every ever-loaded chunk. Streaming/procedural chunk
18
- * providers that need animated tiles must drive per-chunk `TileAnimator`
19
- * instances themselves (scanning only the newly-adopted chunk's tile
20
- * range) - a whole-layer `TileAnimator` is not currently wired to react to
21
- * chunk load/unload.
22
- *
23
- * Tick it from your update loop, like `TweenSequencer`:
24
- *
25
- * ```ts
26
- * const animator = new TileAnimator(map.layers);
27
- * scene.systems.add({ update: (t) => animator.update(t.deltaSeconds) });
28
- * ```
29
- *
30
- * The animator references - but never owns - the layers and their tilesets;
31
- * {@link destroy} only drops its own cell registry.
32
- *
33
- * @advanced
34
- */
35
- var TileAnimator = class {
36
- _layers;
37
- _cells = [];
38
- _elapsedMs = 0;
39
- /**
40
- * @param layers One layer, or an array of layers (e.g. `map.layers`), to scan
41
- * for animated tiles.
42
- */
43
- constructor(layers) {
44
- this._layers = Array.isArray(layers) ? layers : [layers];
45
- this._scan();
46
- }
47
- /** Number of animated cells currently registered across all layers. */
48
- get animatedCellCount() {
49
- return this._cells.length;
50
- }
51
- /** Total elapsed animation time in milliseconds since construction/reset. */
52
- get elapsedMs() {
53
- return this._elapsedMs;
54
- }
55
- /**
56
- * Advance all registered animations by `deltaSeconds` and write the current
57
- * frame into any cell that crossed a frame boundary. Cells that did not change
58
- * frame are not touched, so their chunks do not rebuild.
59
- *
60
- * @param deltaSeconds Elapsed wall-clock time since the last call, in seconds.
61
- */
62
- update(deltaSeconds) {
63
- if (!Number.isFinite(deltaSeconds) || deltaSeconds <= 0 || this._cells.length === 0) return;
64
- this._elapsedMs += deltaSeconds * 1e3;
65
- for (const cell of this._cells) {
66
- const t = this._elapsedMs % cell.totalMs;
67
- const frameIndex = frameIndexAt(cell.cumulative, t);
68
- if (frameIndex === cell.currentFrame) continue;
69
- cell.currentFrame = frameIndex;
70
- const frame = cell.frames[frameIndex];
71
- if (frame === void 0) continue;
72
- cell.layer.setTileAt(cell.tx, cell.ty, {
73
- tileset: cell.tileset,
74
- localTileId: frame.localTileId,
75
- transform: cell.transform
76
- });
77
- }
78
- }
79
- /**
80
- * Restore every animated cell to its first frame and reset the clock.
81
- * Useful before serialising or pausing.
82
- */
83
- reset() {
84
- this._elapsedMs = 0;
85
- for (const cell of this._cells) {
86
- const frame = cell.frames[0];
87
- if (frame === void 0) continue;
88
- cell.currentFrame = 0;
89
- cell.layer.setTileAt(cell.tx, cell.ty, {
90
- tileset: cell.tileset,
91
- localTileId: frame.localTileId,
92
- transform: cell.transform
93
- });
94
- }
95
- }
96
- /**
97
- * Re-scan the layers for animated cells. Call after structural edits that add
98
- * or remove animated tiles. Resets all currently-tracked cells to frame 0
99
- * first so the rescan starts from a clean, deterministic state.
100
- */
101
- rescan() {
102
- this.reset();
103
- this._scan();
104
- }
105
- /** Drop the cell registry. Does not modify the layers or tilesets. */
106
- destroy() {
107
- this._cells = [];
108
- this._elapsedMs = 0;
109
- }
110
- /** Scan all layers for cells whose tile carries a (multi-frame) animation. */
111
- _scan() {
112
- const cells = [];
113
- for (const layer of this._layers) {
114
- if (layer.width === void 0 || layer.height === void 0) continue;
115
- for (let ty = 0; ty < layer.height; ty++) for (let tx = 0; tx < layer.width; tx++) {
116
- const tile = layer.getTileAt(tx, ty);
117
- if (!tile) continue;
118
- const frames = tile.tileset.getTileDefinition(tile.localTileId)?.animation;
119
- if (!frames || frames.length < 2) continue;
120
- if (frames.some((f) => f.localTileId < 0 || f.localTileId >= tile.tileset.tileCount)) continue;
121
- const cumulative = [];
122
- let total = 0;
123
- for (const frame of frames) {
124
- total += Math.max(0, frame.duration);
125
- cumulative.push(total);
126
- }
127
- if (total <= 0) continue;
128
- cells.push({
129
- layer,
130
- tx,
131
- ty,
132
- tileset: tile.tileset,
133
- transform: tile.transform,
134
- frames,
135
- cumulative,
136
- totalMs: total,
137
- currentFrame: -1
138
- });
139
- }
140
- }
141
- this._cells = cells;
142
- }
143
- };
144
- /**
145
- * Find the frame index whose cumulative window contains time `t` (0 ≤ t < total).
146
- * `cumulative[i]` is the end time of frame `i`; the last entry equals the total.
147
- */
148
- const frameIndexAt = (cumulative, t) => {
149
- for (let i = 0; i < cumulative.length; i++) {
150
- const end = cumulative[i];
151
- if (end !== void 0 && t < end) return i;
152
- }
153
- return cumulative.length - 1;
154
- };
155
-
156
- //#endregion
157
- export { TileAnimator };
158
- //# sourceMappingURL=TileAnimator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TileAnimator.js","names":[],"sources":["../../src/TileAnimator.ts"],"sourcesContent":["import type { TileLayer } from './TileLayer';\nimport type { TileSet } from './TileSet';\nimport type { TileAnimationFrame, TileTransform } from './types';\n\n/** Internal per-cell animation record. */\ninterface AnimatedCell {\n readonly layer: TileLayer;\n readonly tx: number;\n readonly ty: number;\n readonly tileset: TileSet;\n readonly transform: TileTransform;\n readonly frames: readonly TileAnimationFrame[];\n /** Cumulative end-time (ms) of each frame, so `cumulative.at(-1) === totalMs`. */\n readonly cumulative: readonly number[];\n readonly totalMs: number;\n /** Index of the frame currently written into the layer (-1 = none yet). */\n currentFrame: number;\n}\n\n/**\n * Drives per-tile animations on one or more {@link TileLayer}s, RPG-Maker style.\n *\n * On construction it scans the given layer(s) once and registers every cell\n * whose tile carries an `animation` (see {@link import('./types').TileDefinition}).\n * Each {@link update} advances a shared clock and rewrites **only** the\n * registered animated cells, and **only** when a cell crosses a frame boundary -\n * static tiles are never touched. Because a tile rewrite goes through\n * `layer.setTileAt`, only the chunks that actually contain animated cells rebuild\n * their geometry, and only on the (infrequent) frames where a boundary is\n * crossed. The large static body of the map never rebuilds.\n *\n * An unbounded {@link import('./TileLayer').TileLayer} (see\n * {@link import('./TileLayer').TileLayer.bounded}) is skipped entirely by\n * the initial scan and reports zero animated cells for that layer, rather\n * than sweeping every ever-loaded chunk. Streaming/procedural chunk\n * providers that need animated tiles must drive per-chunk `TileAnimator`\n * instances themselves (scanning only the newly-adopted chunk's tile\n * range) - a whole-layer `TileAnimator` is not currently wired to react to\n * chunk load/unload.\n *\n * Tick it from your update loop, like `TweenSequencer`:\n *\n * ```ts\n * const animator = new TileAnimator(map.layers);\n * scene.systems.add({ update: (t) => animator.update(t.deltaSeconds) });\n * ```\n *\n * The animator references - but never owns - the layers and their tilesets;\n * {@link destroy} only drops its own cell registry.\n *\n * @advanced\n */\nexport class TileAnimator {\n private readonly _layers: readonly TileLayer[];\n private _cells: AnimatedCell[] = [];\n private _elapsedMs = 0;\n\n /**\n * @param layers One layer, or an array of layers (e.g. `map.layers`), to scan\n * for animated tiles.\n */\n public constructor(layers: TileLayer | readonly TileLayer[]) {\n this._layers = Array.isArray(layers) ? layers : [layers as TileLayer];\n this._scan();\n }\n\n /** Number of animated cells currently registered across all layers. */\n public get animatedCellCount(): number {\n return this._cells.length;\n }\n\n /** Total elapsed animation time in milliseconds since construction/reset. */\n public get elapsedMs(): number {\n return this._elapsedMs;\n }\n\n /**\n * Advance all registered animations by `deltaSeconds` and write the current\n * frame into any cell that crossed a frame boundary. Cells that did not change\n * frame are not touched, so their chunks do not rebuild.\n *\n * @param deltaSeconds Elapsed wall-clock time since the last call, in seconds.\n */\n public update(deltaSeconds: number): void {\n if (!Number.isFinite(deltaSeconds) || deltaSeconds <= 0 || this._cells.length === 0) {\n return;\n }\n\n this._elapsedMs += deltaSeconds * 1000;\n\n for (const cell of this._cells) {\n const t = this._elapsedMs % cell.totalMs;\n const frameIndex = frameIndexAt(cell.cumulative, t);\n if (frameIndex === cell.currentFrame) {\n continue;\n }\n cell.currentFrame = frameIndex;\n const frame = cell.frames[frameIndex];\n if (frame === undefined) {\n continue;\n }\n cell.layer.setTileAt(cell.tx, cell.ty, {\n tileset: cell.tileset,\n localTileId: frame.localTileId,\n transform: cell.transform,\n });\n }\n }\n\n /**\n * Restore every animated cell to its first frame and reset the clock.\n * Useful before serialising or pausing.\n */\n public reset(): void {\n this._elapsedMs = 0;\n for (const cell of this._cells) {\n const frame = cell.frames[0];\n if (frame === undefined) {\n continue;\n }\n cell.currentFrame = 0;\n cell.layer.setTileAt(cell.tx, cell.ty, {\n tileset: cell.tileset,\n localTileId: frame.localTileId,\n transform: cell.transform,\n });\n }\n }\n\n /**\n * Re-scan the layers for animated cells. Call after structural edits that add\n * or remove animated tiles. Resets all currently-tracked cells to frame 0\n * first so the rescan starts from a clean, deterministic state.\n */\n public rescan(): void {\n this.reset();\n this._scan();\n }\n\n /** Drop the cell registry. Does not modify the layers or tilesets. */\n public destroy(): void {\n this._cells = [];\n this._elapsedMs = 0;\n }\n\n /** Scan all layers for cells whose tile carries a (multi-frame) animation. */\n private _scan(): void {\n const cells: AnimatedCell[] = [];\n\n for (const layer of this._layers) {\n if (layer.width === undefined || layer.height === undefined) {\n continue; // unbounded layers are not scanned in v1 — see class doc comment.\n }\n for (let ty = 0; ty < layer.height; ty++) {\n for (let tx = 0; tx < layer.width; tx++) {\n const tile = layer.getTileAt(tx, ty);\n if (!tile) {\n continue;\n }\n\n const def = tile.tileset.getTileDefinition(tile.localTileId);\n const frames = def?.animation;\n if (!frames || frames.length < 2) {\n continue;\n }\n\n // Skip animations referencing out-of-range frames so update() never\n // throws from setTileAt; such data is malformed and silently ignored.\n if (frames.some(f => f.localTileId < 0 || f.localTileId >= tile.tileset.tileCount)) {\n continue;\n }\n\n const cumulative: number[] = [];\n let total = 0;\n for (const frame of frames) {\n total += Math.max(0, frame.duration);\n cumulative.push(total);\n }\n if (total <= 0) {\n continue;\n }\n\n cells.push({\n layer,\n tx,\n ty,\n tileset: tile.tileset,\n transform: tile.transform,\n frames,\n cumulative,\n totalMs: total,\n currentFrame: -1,\n });\n }\n }\n }\n\n this._cells = cells;\n }\n}\n\n/**\n * Find the frame index whose cumulative window contains time `t` (0 ≤ t < total).\n * `cumulative[i]` is the end time of frame `i`; the last entry equals the total.\n */\nconst frameIndexAt = (cumulative: readonly number[], t: number): number => {\n for (let i = 0; i < cumulative.length; i++) {\n const end = cumulative[i];\n if (end !== undefined && t < end) {\n return i;\n }\n }\n return cumulative.length - 1;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,eAAb,MAA0B;CACxB,AAAiB;CACjB,AAAQ,SAAyB,CAAC;CAClC,AAAQ,aAAa;;;;;CAMrB,AAAO,YAAY,QAA0C;EAC3D,KAAK,UAAU,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAmB;EACpE,KAAK,MAAM;CACb;;CAGA,IAAW,oBAA4B;EACrC,OAAO,KAAK,OAAO;CACrB;;CAGA,IAAW,YAAoB;EAC7B,OAAO,KAAK;CACd;;;;;;;;CASA,AAAO,OAAO,cAA4B;EACxC,IAAI,CAAC,OAAO,SAAS,YAAY,KAAK,gBAAgB,KAAK,KAAK,OAAO,WAAW,GAChF;EAGF,KAAK,cAAc,eAAe;EAElC,KAAK,MAAM,QAAQ,KAAK,QAAQ;GAC9B,MAAM,IAAI,KAAK,aAAa,KAAK;GACjC,MAAM,aAAa,aAAa,KAAK,YAAY,CAAC;GAClD,IAAI,eAAe,KAAK,cACtB;GAEF,KAAK,eAAe;GACpB,MAAM,QAAQ,KAAK,OAAO;GAC1B,IAAI,UAAU,QACZ;GAEF,KAAK,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI;IACrC,SAAS,KAAK;IACd,aAAa,MAAM;IACnB,WAAW,KAAK;GAClB,CAAC;EACH;CACF;;;;;CAMA,AAAO,QAAc;EACnB,KAAK,aAAa;EAClB,KAAK,MAAM,QAAQ,KAAK,QAAQ;GAC9B,MAAM,QAAQ,KAAK,OAAO;GAC1B,IAAI,UAAU,QACZ;GAEF,KAAK,eAAe;GACpB,KAAK,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI;IACrC,SAAS,KAAK;IACd,aAAa,MAAM;IACn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/**
3
- * Public readonly view of a tile chunk.
4
- *
5
- * Provides read-only inspection access for iteration, queries, and the
6
- * future renderer. The underlying storage is never exposed directly.
7
- *
8
- * @advanced
9
- */
10
- export interface ReadonlyTileChunk {
11
- /** Signed chunk X coordinate. */
12
- readonly cx: number;
13
- /** Signed chunk Y coordinate. */
14
- readonly cy: number;
15
- /** Width of this chunk in tiles. */
16
- readonly width: number;
17
- /** Height of this chunk in tiles. */
18
- readonly height: number;
19
- /** Whether every cell is empty (all-zero). */
20
- readonly empty: boolean;
21
- /**
22
- * Monotonic revision counter. Increments on every cell mutation
23
- * within this chunk. No-ops (writing same value) do NOT increment.
24
- */
25
- readonly revision: number;
26
- /**
27
- * Read the raw packed tile word at local-in-chunk coordinates.
28
- * Returns 0 for empty.
29
- * @throws If coordinates are invalid.
30
- */
31
- getRawAt(lx: number, ly: number): PackedTile;
32
- /**
33
- * Create a defensive copy of the tile data. The caller owns the copy;
34
- * mutation of the returned array cannot affect the chunk.
35
- */
36
- cloneTiles(): Uint32Array;
37
- }
38
- /**
39
- * A compact, fixed-size chunk of tile data within a layer.
40
- *
41
- * Storage is a single {@link Uint32Array} of length `width * height`,
42
- * laid out row-major. Each cell is a packed tile word (0 = empty).
43
- * Chunk coordinates are signed to support future infinite maps.
44
- *
45
- * The backing array is **private** - external code cannot mutate storage
46
- * directly. All mutation must flow through {@link TileLayer} public APIs,
47
- * which call the package-internal `_setRawAt` method.
48
- *
49
- * The chunk tracks a revision counter that increments on every mutation
50
- * so the future renderer can detect which chunks need GPU rebuilds.
51
- *
52
- * @advanced
53
- */
54
- export declare class TileChunk implements ReadonlyTileChunk {
55
- /** Signed chunk X coordinate. */
56
- readonly cx: number;
57
- /** Signed chunk Y coordinate. */
58
- readonly cy: number;
59
- /** Width of this chunk in tiles. */
60
- readonly width: number;
61
- /** Height of this chunk in tiles. */
62
- readonly height: number;
63
- /** Packed tile storage (row-major). Private - never exposed directly. */
64
- private readonly _tiles;
65
- /** Whether every cell in this chunk is empty (0). Lazy-computed. */
66
- private _empty;
67
- /** Monotonic revision counter - incremented on every mutation. */
68
- private _revision;
69
- /**
70
- * Render-node-owned callbacks notified whenever `_revision` advances.
71
- * `TileChunkNode.pages` caches geometry against `revision`, but that cache
72
- * is only consulted from `render()` - a call the engine skips entirely for
73
- * a content-clean subtree under a `RetainedContainer`. Without
74
- * this push, an in-place tile edit after capture would replay stale cached
75
- * geometry forever. Package-internal; not part of {@link ReadonlyTileChunk}.
76
- */
77
- private _dirtyListeners;
78
- /**
79
- * @param cx Signed chunk X coordinate (must be finite safe integer).
80
- * @param cy Signed chunk Y coordinate (must be finite safe integer).
81
- * @param width Chunk width in tiles (positive safe integer).
82
- * @param height Chunk height in tiles (positive safe integer).
83
- * @param source Optional source data to copy (must match length).
84
- */
85
- constructor(cx: number, cy: number, width: number, height: number, source?: Uint32Array);
86
- /** Row-major index for cell (lx, ly) within this chunk. */
87
- private _index;
88
- /**
89
- * Validate local-in-chunk coordinates before access.
90
- * @throws If lx or ly is not a finite integer or out of [0, dimension).
91
- */
92
- private _validateLocalCoord;
93
- /** @inheritdoc */
94
- getRawAt(lx: number, ly: number): PackedTile;
95
- /** @inheritdoc */
96
- get empty(): boolean;
97
- /** @inheritdoc */
98
- get revision(): number;
99
- /** @inheritdoc */
100
- cloneTiles(): Uint32Array;
101
- private _notifyDirty;
102
- }
103
- //# sourceMappingURL=TileChunk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TileChunk.d.ts","sourceRoot":"","sources":["../../src/TileChunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC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