@codexo/exojs-tilemap 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/ImageLayerNode.d.ts +1 -3
- package/dist/esm/ImageLayerNode.d.ts.map +1 -1
- package/dist/esm/MapSpawnSession.d.ts +0 -7
- package/dist/esm/MapSpawnSession.d.ts.map +1 -1
- package/dist/esm/MapWorldRuntime.d.ts +0 -2
- package/dist/esm/MapWorldRuntime.d.ts.map +1 -1
- package/dist/esm/TileChunk.d.ts +0 -58
- package/dist/esm/TileChunk.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.d.ts +1 -73
- package/dist/esm/TileChunkNode.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.js +1 -1
- package/dist/esm/TileChunkNode.js.map +1 -1
- package/dist/esm/TileLayer.d.ts +0 -63
- package/dist/esm/TileLayer.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.d.ts +2 -7
- package/dist/esm/TileLayerNode.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.js +1 -1
- package/dist/esm/TileLayerNode.js.map +1 -1
- package/dist/esm/TileMapBand.d.ts +0 -33
- package/dist/esm/TileMapBand.d.ts.map +1 -1
- package/dist/esm/TileMapNode.d.ts +1 -1
- package/dist/esm/TileMapNode.js +1 -1
- package/dist/esm/TileMapNode.js.map +1 -1
- package/dist/esm/TileSet.d.ts +3 -9
- package/dist/esm/TileSet.d.ts.map +1 -1
- package/dist/esm/TileSet.js +3 -3
- package/dist/esm/TileSet.js.map +1 -1
- package/dist/esm/chunkGeometry.d.ts +1 -71
- package/dist/esm/chunkGeometry.d.ts.map +1 -1
- package/dist/esm/nodeBounds.d.ts +1 -19
- package/dist/esm/nodeBounds.d.ts.map +1 -1
- package/dist/esm/pixelSnap.d.ts +1 -12
- package/dist/esm/pixelSnap.d.ts.map +1 -1
- package/dist/esm/tileWord.d.ts +1 -11
- package/dist/esm/tileWord.d.ts.map +1 -1
- package/dist/esm/tilemapExtension.d.ts.map +1 -1
- package/dist/esm/tilemapExtension.js +5 -8
- package/dist/esm/tilemapExtension.js.map +1 -1
- package/dist/esm/tilemapSerializers.d.ts +1 -19
- package/dist/esm/tilemapSerializers.d.ts.map +1 -1
- package/dist/esm/types.d.ts +0 -6
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +1 -92
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +9 -9
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +1 -107
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +9 -9
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/TileSet.d.ts
CHANGED
|
@@ -78,19 +78,13 @@ export declare class TileSet {
|
|
|
78
78
|
*/
|
|
79
79
|
constructor(options: TileSetOptions);
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
_setDefinition(localTileId: number, definition: Partial<TileDefinition>): void;
|
|
86
|
-
/**
|
|
87
|
-
* Build definitions from an array, replacing the internal definitions map.
|
|
88
|
-
* Each entry's properties are copied and frozen.
|
|
81
|
+
* Replace all tile definitions with the given array. Each entry's
|
|
82
|
+
* properties are copied and frozen.
|
|
89
83
|
*
|
|
90
84
|
* Part of the tilemap SDK contract for extension packages that build
|
|
91
85
|
* tilesets programmatically.
|
|
92
86
|
*/
|
|
93
|
-
|
|
87
|
+
setDefinitions(definitions: readonly TileDefinition[]): void;
|
|
94
88
|
/**
|
|
95
89
|
* Retrieve per-tile metadata, or undefined if none defined.
|
|
96
90
|
* @advanced
|
|
@@ -1 +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,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAchG;;;OAGG;IACI,YAAY,IAAI,gBAAgB,CAAC,cAAc,CAAC;IAIvD;;;;OAIG;IACH,IAAW,cAAc,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC,CAMhF;CACF"}
|
package/dist/esm/TileSet.js
CHANGED
|
@@ -100,13 +100,13 @@ var TileSet = class {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
103
|
+
* Replace all tile definitions with the given array. Each entry's
|
|
104
|
+
* properties are copied and frozen.
|
|
105
105
|
*
|
|
106
106
|
* Part of the tilemap SDK contract for extension packages that build
|
|
107
107
|
* tilesets programmatically.
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
setDefinitions(definitions) {
|
|
110
110
|
const map = this._definitions;
|
|
111
111
|
map.clear();
|
|
112
112
|
for (const def of definitions) {
|
package/dist/esm/TileSet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileSet.js","names":[],"sources":["../../src/TileSet.ts"],"sourcesContent":["import type { TextureRegion } from '@codexo/exojs';\n\nimport type { TileDefinition, TileProperties } from './types';\nimport { validateNonNegativeInteger, validatePositiveInteger } from './types';\n\n/**\n * Options for constructing a {@link TileSet}.\n * @advanced\n */\nexport interface TileSetOptions {\n /** Stable runtime name (unique within a {@link TileMap}). */\n readonly name: string;\n /** Texture atlas for this tileset. Textures are Loader-owned. */\n readonly texture: TextureRegion;\n /** Width of each tile in pixels. */\n readonly tileWidth: number;\n /** Height of each tile in pixels. */\n readonly tileHeight: number;\n /** Total number of tiles in this tileset. */\n readonly tileCount: number;\n /** Number of tile columns in the atlas grid. Computed from texture width / tileWidth if omitted. */\n readonly columns?: number;\n /** Pixel spacing between tiles in the atlas. Defaults to 0. */\n readonly spacing?: number;\n /** Pixel margin around the atlas. Defaults to 0. */\n readonly margin?: number;\n /** Tileset class/type string (Tiled `class`). Defaults to `''`. */\n readonly class?: string;\n /** Visual drawing offset in pixels applied to every tile of this set drawn by a tile layer. Defaults to 0. */\n readonly offsetX?: number;\n /** Visual drawing offset in pixels applied to every tile of this set drawn by a tile layer. Defaults to 0. */\n readonly offsetY?: number;\n}\n\n/**\n * A resolved tileset: a uniform grid of tiles within a texture atlas.\n *\n * Does **not** own its texture - the Loader or application code retains\n * texture ownership. Tileset dimensions are validated at construction and\n * frozen thereafter.\n *\n * Multiple tilesets are supported per {@link TileMap}; each carries its own\n * tile dimensions, spacing, and optional per-tile metadata.\n * @advanced\n */\nexport class TileSet {\n /** Stable runtime name. */\n public readonly name: string;\n\n /** Atlas texture region - Loader-owned, never destroyed by the tileset. */\n public readonly texture: TextureRegion;\n\n /** Tile width in pixels. */\n public readonly tileWidth: number;\n /** Tile height in pixels. */\n public readonly tileHeight: number;\n\n /** Total number of tiles in the tileset. */\n public readonly tileCount: number;\n\n /** Number of columns in the atlas grid. */\n public readonly columns: number;\n /** Number of rows implied by tileCount and columns. */\n public readonly rows: number;\n\n /** Pixel spacing between tiles in the atlas. */\n public readonly spacing: number;\n /** Pixel margin around the atlas. */\n public readonly margin: number;\n\n /** Tileset class/type string (Tiled `class`; may be empty). */\n public readonly class: string;\n /**\n * Visual drawing offset X in pixels (Tiled `tileoffset`).\n *\n * Applied by the tile-layer geometry builder and by the tile-collision\n * helpers - i.e. wherever this package places a tile on a grid. It is **not**\n * folded into a {@link TileObject}'s `x`/`y`: object layers are data-only, so\n * code that draws a tile object itself has to add this offset the way a tile\n * layer would.\n */\n public readonly offsetX: number;\n /** Visual drawing offset Y in pixels (Tiled `tileoffset`) - see {@link offsetX} for where it applies. */\n public readonly offsetY: number;\n\n private readonly _definitions: ReadonlyMap<number, TileDefinition>;\n\n /**\n * @throws When dimensions, counts, or spacing values are invalid.\n */\n public constructor(options: TileSetOptions) {\n if (!options.name || typeof options.name !== 'string') {\n throw new Error('TileSet name must be a non-empty string.');\n }\n\n if (!options.texture) {\n throw new Error('TileSet requires a valid TextureRegion.');\n }\n\n validatePositiveInteger(options.tileWidth, 'tileWidth');\n validatePositiveInteger(options.tileHeight, 'tileHeight');\n validatePositiveInteger(options.tileCount, 'tileCount');\n\n const spacing = options.spacing ?? 0;\n const margin = options.margin ?? 0;\n validateNonNegativeInteger(spacing, 'spacing');\n validateNonNegativeInteger(margin, 'margin');\n\n // A tile grid is derived from the atlas dimensions and then fixed, so it\n // cannot be built against a texture that has not loaded yet - and the\n // dimension checks below would otherwise report the resulting zeros as a\n // bad tile size rather than as the real cause.\n if (options.texture.width <= 0 || options.texture.height <= 0) {\n throw new Error(\n `TileSet needs a loaded texture to derive its grid, but \"${options.name}\" was given one measuring ` +\n `${options.texture.width}x${options.texture.height}. Await it (loader.load(...) or texture.loaded) before constructing the tile set.`,\n );\n }\n\n const atlasWidth = options.texture.width - margin * 2;\n const atlasHeight = options.texture.height - margin * 2;\n\n const columns = options.columns ?? Math.floor(atlasWidth / options.tileWidth);\n\n validatePositiveInteger(columns, 'columns');\n if (columns <= 0) {\n throw new Error(`TileSet columns must be positive (got ${columns}).`);\n }\n\n if (options.tileWidth * columns + spacing * (columns - 1) > atlasWidth) {\n throw new Error(`TileSet grid width exceeds atlas: ${options.tileWidth}*${columns}` + ` + ${spacing}*${columns - 1} > ${atlasWidth}.`);\n }\n\n const rows = Math.ceil(options.tileCount / columns);\n if (rows > 0 && options.tileHeight * rows + spacing * (rows - 1) > atlasHeight) {\n throw new Error(`TileSet grid height exceeds atlas: ${options.tileHeight}*${rows}` + ` + ${spacing}*${rows - 1} > ${atlasHeight}.`);\n }\n\n this.name = options.name;\n this.texture = options.texture;\n this.tileWidth = options.tileWidth;\n this.tileHeight = options.tileHeight;\n this.tileCount = options.tileCount;\n this.columns = columns;\n this.rows = rows;\n this.spacing = spacing;\n this.margin = margin;\n this.class = options.class ?? '';\n this.offsetX = options.offsetX ?? 0;\n this.offsetY = options.offsetY ?? 0;\n\n this._definitions = new Map();\n\n if (__DEV__) {\n Object.freeze(this);\n }\n }\n\n /**\n * Set per-tile metadata for a local tile ID.\n * Copies input to prevent caller-owned mutation leaking into the tileset.\n * @internal\n */\n public _setDefinition(localTileId: number, definition: Partial<TileDefinition>): void {\n if (localTileId < 0 || localTileId >= this.tileCount) {\n throw new Error(`Tile definition localTileId ${localTileId} out of range [0, ${this.tileCount - 1}].`);\n }\n const props = definition.properties ? Object.freeze({ ...definition.properties }) : undefined;\n const animation = definition.animation ? Object.freeze(definition.animation.map(frame => Object.freeze({ ...frame }))) : undefined;\n const collision = definition.collision ? Object.freeze([...definition.collision]) : undefined;\n (this._definitions as Map<number, TileDefinition>).set(localTileId, {\n localTileId,\n ...(props !== undefined && { properties: props }),\n ...(animation !== undefined && { animation }),\n ...(collision !== undefined && { collision }),\n });\n }\n\n /**\n * Build definitions from an array, replacing the internal definitions map.\n * Each entry's properties are copied and frozen.\n *\n * Part of the tilemap SDK contract for extension packages that build\n * tilesets programmatically.\n */\n public _setDefinitions(definitions: readonly TileDefinition[]): void {\n const map = this._definitions as Map<number, TileDefinition>;\n map.clear();\n for (const def of definitions) {\n const props = def.properties ? Object.freeze({ ...def.properties }) : undefined;\n const animation = def.animation ? Object.freeze(def.animation.map(frame => Object.freeze({ ...frame }))) : undefined;\n const collision = def.collision ? Object.freeze([...def.collision]) : undefined;\n map.set(def.localTileId, {\n localTileId: def.localTileId,\n ...(props !== undefined && { properties: props }),\n ...(animation !== undefined && { animation }),\n ...(collision !== undefined && { collision }),\n });\n }\n }\n\n /**\n * Retrieve per-tile metadata, or undefined if none defined.\n * @advanced\n */\n public getTileDefinition(localTileId: number): TileDefinition | undefined {\n return this._definitions.get(localTileId);\n }\n\n /**\n * Compute the pixel-space source rectangle for a local tile ID\n * within the atlas, accounting for columns, spacing, and margin.\n * @advanced\n */\n public getTileRect(localTileId: number): { x: number; y: number; width: number; height: number } {\n if (localTileId < 0 || localTileId >= this.tileCount) {\n throw new Error(`getTileRect: localTileId ${localTileId} out of range [0, ${this.tileCount - 1}].`);\n }\n const col = localTileId % this.columns;\n const row = Math.floor(localTileId / this.columns);\n return {\n x: this.margin + col * (this.tileWidth + this.spacing),\n y: this.margin + row * (this.tileHeight + this.spacing),\n width: this.tileWidth,\n height: this.tileHeight,\n };\n }\n\n /**\n * Iterate over all defined tiles (sparse).\n * @advanced\n */\n public definedTiles(): IterableIterator<TileDefinition> {\n return this._definitions.values();\n }\n\n /**\n * Read-only snapshot of all per-tile definitions.\n * The returned record is a caller-owned copy.\n * @advanced\n */\n public get allDefinitions(): Readonly<Record<number, TileProperties | undefined>> {\n const result: Record<number, TileProperties | undefined> = {};\n for (const [id, def] of this._definitions) {\n result[id] = def.properties;\n }\n return Object.freeze(result);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA,IAAa,UAAb,MAAqB;;CAEnB,AAAgB;;CAGhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;;;;;;;;;CAUhB,AAAgB;;CAEhB,AAAgB;CAEhB,AAAiB;;;;CAKjB,AAAO,YAAY,SAAyB;EAC1C,IAAI,CAAC,QAAQ,QAAQ,OAAO,QAAQ,SAAS,UAC3C,MAAM,IAAI,MAAM,0CAA0C;EAG5D,IAAI,CAAC,QAAQ,SACX,MAAM,IAAI,MAAM,yCAAyC;EAG3D,wBAAwB,QAAQ,WAAW,WAAW;EACtD,wBAAwB,QAAQ,YAAY,YAAY;EACxD,wBAAwB,QAAQ,WAAW,WAAW;EAEtD,MAAM,UAAU,QAAQ,WAAW;EACnC,MAAM,SAAS,QAAQ,UAAU;EACjC,2BAA2B,SAAS,SAAS;EAC7C,2BAA2B,QAAQ,QAAQ;EAM3C,IAAI,QAAQ,QAAQ,SAAS,KAAK,QAAQ,QAAQ,UAAU,GAC1D,MAAM,IAAI,M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M,MAAM,KAAK,MAAM,cAAc,KAAK,OAAO;EACjD,OAAO;GACL,GAAG,KAAK,SAAS,OAAO,KAAK,YAAY,KAAK;GAC9C,GAAG,KAAK,SAAS,OAAO,KAAK,aAAa,KAAK;GAC/C,OAAO,KAAK;GACZ,QAAQ,KAAK;EACf;CACF;;;;;CAMA,AAAO,eAAiD;EACtD,OAAO,KAAK,aAAa,OAAO;CAClC;;;;;;CAOA,IAAW,iBAAuE;EAChF,MAAM,SAAqD,CAAC;EAC5D,KAAK,MAAM,CAAC,IAAI,QAAQ,KAAK,cAC3B,OAAO,MAAM,IAAI;EAEnB,OAAO,OAAO,OAAO,MAAM;CAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"TileSet.js","names":[],"sources":["../../src/TileSet.ts"],"sourcesContent":["import type { TextureRegion } from '@codexo/exojs';\n\nimport type { TileDefinition, TileProperties } from './types';\nimport { validateNonNegativeInteger, validatePositiveInteger } from './types';\n\n/**\n * Options for constructing a {@link TileSet}.\n * @advanced\n */\nexport interface TileSetOptions {\n /** Stable runtime name (unique within a {@link TileMap}). */\n readonly name: string;\n /** Texture atlas for this tileset. Textures are Loader-owned. */\n readonly texture: TextureRegion;\n /** Width of each tile in pixels. */\n readonly tileWidth: number;\n /** Height of each tile in pixels. */\n readonly tileHeight: number;\n /** Total number of tiles in this tileset. */\n readonly tileCount: number;\n /** Number of tile columns in the atlas grid. Computed from texture width / tileWidth if omitted. */\n readonly columns?: number;\n /** Pixel spacing between tiles in the atlas. Defaults to 0. */\n readonly spacing?: number;\n /** Pixel margin around the atlas. Defaults to 0. */\n readonly margin?: number;\n /** Tileset class/type string (Tiled `class`). Defaults to `''`. */\n readonly class?: string;\n /** Visual drawing offset in pixels applied to every tile of this set drawn by a tile layer. Defaults to 0. */\n readonly offsetX?: number;\n /** Visual drawing offset in pixels applied to every tile of this set drawn by a tile layer. Defaults to 0. */\n readonly offsetY?: number;\n}\n\n/**\n * A resolved tileset: a uniform grid of tiles within a texture atlas.\n *\n * Does **not** own its texture - the Loader or application code retains\n * texture ownership. Tileset dimensions are validated at construction and\n * frozen thereafter.\n *\n * Multiple tilesets are supported per {@link TileMap}; each carries its own\n * tile dimensions, spacing, and optional per-tile metadata.\n * @advanced\n */\nexport class TileSet {\n /** Stable runtime name. */\n public readonly name: string;\n\n /** Atlas texture region - Loader-owned, never destroyed by the tileset. */\n public readonly texture: TextureRegion;\n\n /** Tile width in pixels. */\n public readonly tileWidth: number;\n /** Tile height in pixels. */\n public readonly tileHeight: number;\n\n /** Total number of tiles in the tileset. */\n public readonly tileCount: number;\n\n /** Number of columns in the atlas grid. */\n public readonly columns: number;\n /** Number of rows implied by tileCount and columns. */\n public readonly rows: number;\n\n /** Pixel spacing between tiles in the atlas. */\n public readonly spacing: number;\n /** Pixel margin around the atlas. */\n public readonly margin: number;\n\n /** Tileset class/type string (Tiled `class`; may be empty). */\n public readonly class: string;\n /**\n * Visual drawing offset X in pixels (Tiled `tileoffset`).\n *\n * Applied by the tile-layer geometry builder and by the tile-collision\n * helpers - i.e. wherever this package places a tile on a grid. It is **not**\n * folded into a {@link TileObject}'s `x`/`y`: object layers are data-only, so\n * code that draws a tile object itself has to add this offset the way a tile\n * layer would.\n */\n public readonly offsetX: number;\n /** Visual drawing offset Y in pixels (Tiled `tileoffset`) - see {@link offsetX} for where it applies. */\n public readonly offsetY: number;\n\n private readonly _definitions: ReadonlyMap<number, TileDefinition>;\n\n /**\n * @throws When dimensions, counts, or spacing values are invalid.\n */\n public constructor(options: TileSetOptions) {\n if (!options.name || typeof options.name !== 'string') {\n throw new Error('TileSet name must be a non-empty string.');\n }\n\n if (!options.texture) {\n throw new Error('TileSet requires a valid TextureRegion.');\n }\n\n validatePositiveInteger(options.tileWidth, 'tileWidth');\n validatePositiveInteger(options.tileHeight, 'tileHeight');\n validatePositiveInteger(options.tileCount, 'tileCount');\n\n const spacing = options.spacing ?? 0;\n const margin = options.margin ?? 0;\n validateNonNegativeInteger(spacing, 'spacing');\n validateNonNegativeInteger(margin, 'margin');\n\n // A tile grid is derived from the atlas dimensions and then fixed, so it\n // cannot be built against a texture that has not loaded yet - and the\n // dimension checks below would otherwise report the resulting zeros as a\n // bad tile size rather than as the real cause.\n if (options.texture.width <= 0 || options.texture.height <= 0) {\n throw new Error(\n `TileSet needs a loaded texture to derive its grid, but \"${options.name}\" was given one measuring ` +\n `${options.texture.width}x${options.texture.height}. Await it (loader.load(...) or texture.loaded) before constructing the tile set.`,\n );\n }\n\n const atlasWidth = options.texture.width - margin * 2;\n const atlasHeight = options.texture.height - margin * 2;\n\n const columns = options.columns ?? Math.floor(atlasWidth / options.tileWidth);\n\n validatePositiveInteger(columns, 'columns');\n if (columns <= 0) {\n throw new Error(`TileSet columns must be positive (got ${columns}).`);\n }\n\n if (options.tileWidth * columns + spacing * (columns - 1) > atlasWidth) {\n throw new Error(`TileSet grid width exceeds atlas: ${options.tileWidth}*${columns}` + ` + ${spacing}*${columns - 1} > ${atlasWidth}.`);\n }\n\n const rows = Math.ceil(options.tileCount / columns);\n if (rows > 0 && options.tileHeight * rows + spacing * (rows - 1) > atlasHeight) {\n throw new Error(`TileSet grid height exceeds atlas: ${options.tileHeight}*${rows}` + ` + ${spacing}*${rows - 1} > ${atlasHeight}.`);\n }\n\n this.name = options.name;\n this.texture = options.texture;\n this.tileWidth = options.tileWidth;\n this.tileHeight = options.tileHeight;\n this.tileCount = options.tileCount;\n this.columns = columns;\n this.rows = rows;\n this.spacing = spacing;\n this.margin = margin;\n this.class = options.class ?? '';\n this.offsetX = options.offsetX ?? 0;\n this.offsetY = options.offsetY ?? 0;\n\n this._definitions = new Map();\n\n if (__DEV__) {\n Object.freeze(this);\n }\n }\n\n /**\n * Set per-tile metadata for a local tile ID.\n * Copies input to prevent caller-owned mutation leaking into the tileset.\n * @internal\n */\n public _setDefinition(localTileId: number, definition: Partial<TileDefinition>): void {\n if (localTileId < 0 || localTileId >= this.tileCount) {\n throw new Error(`Tile definition localTileId ${localTileId} out of range [0, ${this.tileCount - 1}].`);\n }\n const props = definition.properties ? Object.freeze({ ...definition.properties }) : undefined;\n const animation = definition.animation ? Object.freeze(definition.animation.map(frame => Object.freeze({ ...frame }))) : undefined;\n const collision = definition.collision ? Object.freeze([...definition.collision]) : undefined;\n (this._definitions as Map<number, TileDefinition>).set(localTileId, {\n localTileId,\n ...(props !== undefined && { properties: props }),\n ...(animation !== undefined && { animation }),\n ...(collision !== undefined && { collision }),\n });\n }\n\n /**\n * Replace all tile definitions with the given array. Each entry's\n * properties are copied and frozen.\n *\n * Part of the tilemap SDK contract for extension packages that build\n * tilesets programmatically.\n */\n public setDefinitions(definitions: readonly TileDefinition[]): void {\n const map = this._definitions as Map<number, TileDefinition>;\n map.clear();\n for (const def of definitions) {\n const props = def.properties ? Object.freeze({ ...def.properties }) : undefined;\n const animation = def.animation ? Object.freeze(def.animation.map(frame => Object.freeze({ ...frame }))) : undefined;\n const collision = def.collision ? Object.freeze([...def.collision]) : undefined;\n map.set(def.localTileId, {\n localTileId: def.localTileId,\n ...(props !== undefined && { properties: props }),\n ...(animation !== undefined && { animation }),\n ...(collision !== undefined && { collision }),\n });\n }\n }\n\n /**\n * Retrieve per-tile metadata, or undefined if none defined.\n * @advanced\n */\n public getTileDefinition(localTileId: number): TileDefinition | undefined {\n return this._definitions.get(localTileId);\n }\n\n /**\n * Compute the pixel-space source rectangle for a local tile ID\n * within the atlas, accounting for columns, spacing, and margin.\n * @advanced\n */\n public getTileRect(localTileId: number): { x: number; y: number; width: number; height: number } {\n if (localTileId < 0 || localTileId >= this.tileCount) {\n throw new Error(`getTileRect: localTileId ${localTileId} out of range [0, ${this.tileCount - 1}].`);\n }\n const col = localTileId % this.columns;\n const row = Math.floor(localTileId / this.columns);\n return {\n x: this.margin + col * (this.tileWidth + this.spacing),\n y: this.margin + row * (this.tileHeight + this.spacing),\n width: this.tileWidth,\n height: this.tileHeight,\n };\n }\n\n /**\n * Iterate over all defined tiles (sparse).\n * @advanced\n */\n public definedTiles(): IterableIterator<TileDefinition> {\n return this._definitions.values();\n }\n\n /**\n * Read-only snapshot of all per-tile definitions.\n * The returned record is a caller-owned copy.\n * @advanced\n */\n public get allDefinitions(): Readonly<Record<number, TileProperties | undefined>> {\n const result: Record<number, TileProperties | undefined> = {};\n for (const [id, def] of this._definitions) {\n result[id] = def.properties;\n }\n return Object.freeze(result);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA,IAAa,UAAb,MAAqB;;CAEnB,AAAgB;;CAGhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;;;;;;;;;CAUhB,AAAgB;;CAEhB,AAAgB;CAEhB,AAAiB;;;;CAKjB,AAAO,YAAY,SAAyB;EAC1C,IAAI,CAAC,QAAQ,QAAQ,OAAO,QAAQ,SAAS,UAC3C,MAAM,IAAI,MAAM,0CAA0C;EAG5D,IAAI,CAAC,QAAQ,SACX,MAAM,IAAI,MAAM,yCAAyC;EAG3D,wBAAwB,QAAQ,WAAW,WAAW;EACtD,wBAAwB,QAAQ,YAAY,YAAY;EACxD,wBAAwB,QAAQ,WAAW,WAAW;EAEtD,MAAM,UAAU,QAAQ,WAAW;EACnC,MAAM,SAAS,QAAQ,UAAU;EACjC,2BAA2B,SAAS,SAAS;EAC7C,2BAA2B,QAAQ,QAAQ;EAM3C,IAAI,QAAQ,QAAQ,SAAS,KAAK,QAAQ,QAAQ,UAAU,GAC1D,MAAM,IAAI,MACR,2DAA2D,QAAQ,KAAK,4BACnE,QAAQ,QAAQ,MAAM,GAAG,QAAQ,QAAQ,OAAO,kFACvD;EAGF,MAAM,aAAa,QAAQ,QAAQ,QAAQ,SAAS;EACpD,MAAM,cAAc,QAAQ,QAAQ,SAAS,SAAS;EAEtD,MAAM,UAAU,QAAQ,WAAW,KAAK,MAAM,aAAa,QAAQ,SAAS;EAE5E,wBAAwB,SAAS,SAAS;EAC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BAAuE;EAChF,MAAM,SAAqD,CAAC;EAC5D,KAAK,MAAM,CAAC,IAAI,QAAQ,KAAK,cAC3B,OAAO,MAAM,IAAI;EAEnB,OAAO,OAAO,OAAO,MAAM;CAC7B;AACF"}
|
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ReadonlyTileChunk } from './TileChunk';
|
|
3
|
-
import type { TileSet } from './TileSet';
|
|
4
|
-
import type { TileTransform } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* One textured tile quad in chunk-local pixel space.
|
|
7
|
-
*
|
|
8
|
-
* `u0/v0/u1/v1` are the raw (min/max) source UV bounds of the tile within its
|
|
9
|
-
* tileset texture - flip/orientation is **not** baked here; it travels in
|
|
10
|
-
* {@link TileQuad.orient} and is applied by the per-backend renderer (flipX/Y
|
|
11
|
-
* via UV-corner swap, diagonal via an axis swap in the shader). Keeping the
|
|
12
|
-
* geometry orientation-neutral lets both backends share one CPU builder.
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export interface TileQuad {
|
|
16
|
-
/** Local destination rect, left/top (chunk-local pixels). */
|
|
17
|
-
readonly x0: number;
|
|
18
|
-
readonly y0: number;
|
|
19
|
-
/** Local destination rect, right/bottom (chunk-local pixels). */
|
|
20
|
-
readonly x1: number;
|
|
21
|
-
readonly y1: number;
|
|
22
|
-
/** Normalised source UV bounds (always min ≤ max). */
|
|
23
|
-
readonly u0: number;
|
|
24
|
-
readonly v0: number;
|
|
25
|
-
readonly u1: number;
|
|
26
|
-
readonly v1: number;
|
|
27
|
-
/** Orientation code: bit0 = flipX, bit1 = flipY, bit2 = diagonal. */
|
|
28
|
-
readonly orient: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Geometry for one tileset "page" within a chunk: every tile in the chunk that
|
|
32
|
-
* draws from a single tileset texture, grouped so the renderer can batch by
|
|
33
|
-
* `(shader, texture)`.
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export interface ChunkPage {
|
|
37
|
-
/** The tileset all quads in this page draw from. */
|
|
38
|
-
readonly tileset: TileSet;
|
|
39
|
-
/** The underlying GPU texture (the tileset's atlas), bound once per page. */
|
|
40
|
-
readonly texture: Texture;
|
|
41
|
-
/** The tile quads for this page, in deterministic row-major order. */
|
|
42
|
-
readonly quads: readonly TileQuad[];
|
|
43
|
-
}
|
|
44
|
-
/** Pack a {@link TileTransform} into a 3-bit orientation code. @internal */
|
|
45
|
-
export declare const orientCode: (transform: TileTransform) => number;
|
|
46
|
-
/** Read the cumulative chunk-geometry rebuild count. @internal */
|
|
47
|
-
export declare const getTileGeometryRebuildCount: () => number;
|
|
48
|
-
/** Reset the chunk-geometry rebuild counter (call before a measured frame). @internal */
|
|
49
|
-
export declare const resetTileGeometryRebuildCount: () => void;
|
|
50
|
-
/**
|
|
51
|
-
* Build per-tileset page geometry for a single chunk.
|
|
52
|
-
*
|
|
53
|
-
* Iterates the chunk's packed cells in deterministic row-major order, skipping
|
|
54
|
-
* empties, out-of-range tilesets, and out-of-range local tile ids (all treated
|
|
55
|
-
* as empty - this is the renderer's half of the G-GID contract). Each surviving
|
|
56
|
-
* cell is resolved to its source UV rect (from `tileset.getTileRect` + the
|
|
57
|
-
* tileset `TextureRegion`) and a chunk-local destination rect (bottom-left
|
|
58
|
-
* aligned per Tiled orthogonal semantics, so tilesets whose tiles are taller
|
|
59
|
-
* than the map grid extend upward).
|
|
60
|
-
*
|
|
61
|
-
* Allocation happens here only - the result is cached on the owning
|
|
62
|
-
* {@link import('./TileChunkNode').TileChunkNode} keyed by `chunk.revision`, so
|
|
63
|
-
* unchanged chunks never rebuild and the per-frame path stays allocation-free.
|
|
64
|
-
*
|
|
65
|
-
* @param chunk The readonly chunk view to build from.
|
|
66
|
-
* @param tilesets The layer's tileset array (packed `tilesetIndex` selects one).
|
|
67
|
-
* @param tileWidth Map/layer tile cell width in pixels.
|
|
68
|
-
* @param tileHeight Map/layer tile cell height in pixels.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export declare const buildChunkPages: (chunk: ReadonlyTileChunk, tilesets: readonly TileSet[], tileWidth: number, tileHeight: number) => ChunkPage[];
|
|
1
|
+
export {};
|
|
72
2
|
//# sourceMappingURL=chunkGeometry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkGeometry.d.ts","sourceRoot":"","sources":["../../src/chunkGeometry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunkGeometry.d.ts","sourceRoot":"","sources":["../../src/chunkGeometry.ts"],"names":[],"mappings":""}
|
package/dist/esm/nodeBounds.d.ts
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Rectangle } from '@codexo/exojs';
|
|
3
|
-
/**
|
|
4
|
-
* Grow `out` to the union of `children`'s local bounds, each transformed by
|
|
5
|
-
* the child's own (translation-only, in practice) local transform - i.e. the
|
|
6
|
-
* children's combined extent expressed in the *parent's* local coordinate
|
|
7
|
-
* space, not the parent's own position/scale/rotation.
|
|
8
|
-
*
|
|
9
|
-
* Used as the unbounded-layer/-map fallback for `getLocalBounds()`: `Container`
|
|
10
|
-
* does not aggregate children into its own local bounds automatically (only
|
|
11
|
-
* `getBounds()` - global - does that), so nodes that want a children-derived
|
|
12
|
-
* local rect must compute it explicitly. Mirrors `Container.updateBounds()`'s
|
|
13
|
-
* own aggregation semantics, including skipping invisible children. Callers
|
|
14
|
-
* are expected to only invoke this when `children.length > 0`; `out` is left
|
|
15
|
-
* untouched otherwise (also guarded internally in case a future call site
|
|
16
|
-
* forgets to check).
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare const aggregateChildLocalBounds: (children: readonly SceneNode[], out: Rectangle) => void;
|
|
1
|
+
export {};
|
|
20
2
|
//# sourceMappingURL=nodeBounds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeBounds.d.ts","sourceRoot":"","sources":["../../src/nodeBounds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodeBounds.d.ts","sourceRoot":"","sources":["../../src/nodeBounds.ts"],"names":[],"mappings":""}
|
package/dist/esm/pixelSnap.d.ts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Throw a deterministic error when `mode` is not a valid {@link PixelSnapMode}.
|
|
4
|
-
*
|
|
5
|
-
* Mirrors the core `Drawable` setter's guard so the tilemap node passthroughs
|
|
6
|
-
* (`TileMapView` / `TileMapNode` / `TileLayerNode`) reject JavaScript-invalid
|
|
7
|
-
* values atomically - even for an empty layer that has no chunk drawable to
|
|
8
|
-
* delegate the validation to. Kept local because the core guard is not part of
|
|
9
|
-
* the public API surface.
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare const assertPixelSnapMode: (mode: PixelSnapMode) => void;
|
|
1
|
+
export {};
|
|
13
2
|
//# sourceMappingURL=pixelSnap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixelSnap.d.ts","sourceRoot":"","sources":["../../src/pixelSnap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pixelSnap.d.ts","sourceRoot":"","sources":["../../src/pixelSnap.ts"],"names":[],"mappings":""}
|
package/dist/esm/tileWord.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Tile word packing, shared by both backends and by the shader sources they
|
|
3
|
-
* fill: transform-buffer row in the low 29 bits, diagonal flip in bit 29.
|
|
4
|
-
* flipX/flipY are baked into the UV bounds at write time, so the shader only
|
|
5
|
-
* needs the diagonal axis swap.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare const TILE_ROW_MASK = 536870911;
|
|
10
|
-
/** @internal */
|
|
11
|
-
export declare const TILE_DIAGONAL_BIT = 536870912;
|
|
1
|
+
export {};
|
|
12
2
|
//# sourceMappingURL=tileWord.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileWord.d.ts","sourceRoot":"","sources":["../../src/tileWord.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tileWord.d.ts","sourceRoot":"","sources":["../../src/tileWord.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tilemapExtension.d.ts","sourceRoot":"","sources":["../../src/tilemapExtension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"tilemapExtension.d.ts","sourceRoot":"","sources":["../../src/tilemapExtension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AAiC3E;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAI7B,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { TileMapNode } from "./TileMapNode.js";
|
|
|
3
3
|
import { tileMapNodeSerializer } from "./tilemapSerializers.js";
|
|
4
4
|
import { WebGl2TileChunkRenderer } from "./webgl2/WebGl2TileChunkRenderer.js";
|
|
5
5
|
import { WebGpuTileChunkRenderer } from "./webgpu/WebGpuTileChunkRenderer.js";
|
|
6
|
-
import { RenderBackendType } from "@codexo/exojs/renderer-sdk";
|
|
6
|
+
import { RenderBackendType, defineRendererBinding } from "@codexo/exojs/renderer-sdk";
|
|
7
7
|
|
|
8
8
|
//#region src/tilemapExtension.ts
|
|
9
9
|
/** Per-tile instance batch size for the WebGL2 tile chunk renderer. */
|
|
@@ -16,13 +16,10 @@ const tileRendererBatchSize = 4096;
|
|
|
16
16
|
* {@link import('./TileLayerNode').TileLayerNode}, whose chunk children resolve
|
|
17
17
|
* to this renderer through the registry prototype walk.
|
|
18
18
|
*/
|
|
19
|
-
const buildTileChunkRendererBinding = (batchSize) => ({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (backend.backendType === RenderBackendType.WebGpu) return new WebGpuTileChunkRenderer();
|
|
24
|
-
throw new Error(`Unsupported render backend: ${String(backend.backendType)}`);
|
|
25
|
-
}
|
|
19
|
+
const buildTileChunkRendererBinding = (batchSize) => defineRendererBinding([TileChunkNode], (backend) => {
|
|
20
|
+
if (backend.backendType === RenderBackendType.WebGl2) return new WebGl2TileChunkRenderer(batchSize);
|
|
21
|
+
if (backend.backendType === RenderBackendType.WebGpu) return new WebGpuTileChunkRenderer();
|
|
22
|
+
throw new Error(`Unsupported render backend: ${String(backend.backendType)}`);
|
|
26
23
|
});
|
|
27
24
|
/**
|
|
28
25
|
* Default immutable tilemap extension descriptor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tilemapExtension.js","names":[],"sources":["../../src/tilemapExtension.ts"],"sourcesContent":["import type { Extension, RendererBinding } from '@codexo/exojs/extensions';\nimport
|
|
1
|
+
{"version":3,"file":"tilemapExtension.js","names":[],"sources":["../../src/tilemapExtension.ts"],"sourcesContent":["import type { Extension, RendererBinding } from '@codexo/exojs/extensions';\nimport { defineRendererBinding, RenderBackendType } from '@codexo/exojs/renderer-sdk';\n\nimport { TileChunkNode } from './TileChunkNode';\nimport { TileMapNode } from './TileMapNode';\nimport { tileMapNodeSerializer } from './tilemapSerializers';\nimport { WebGl2TileChunkRenderer } from './webgl2/WebGl2TileChunkRenderer';\nimport { WebGpuTileChunkRenderer } from './webgpu/WebGpuTileChunkRenderer';\n\n/** Per-tile instance batch size for the WebGL2 tile chunk renderer. */\nconst tileRendererBatchSize = 4096;\n\n/**\n * Build the renderer binding that wires the per-backend\n * {@link import('./TileChunkNode').TileChunkNode} renderers. The binding targets\n * the internal chunk drawable; applications never construct it directly - they\n * build {@link import('./TileMapNode').TileMapNode} /\n * {@link import('./TileLayerNode').TileLayerNode}, whose chunk children resolve\n * to this renderer through the registry prototype walk.\n */\nconst buildTileChunkRendererBinding = (batchSize: number): RendererBinding =>\n defineRendererBinding([TileChunkNode], backend => {\n if (backend.backendType === RenderBackendType.WebGl2) {\n return new WebGl2TileChunkRenderer(batchSize);\n }\n\n if (backend.backendType === RenderBackendType.WebGpu) {\n return new WebGpuTileChunkRenderer();\n }\n\n throw new Error(`Unsupported render backend: ${String(backend.backendType satisfies never)}`);\n });\n\n/**\n * Default immutable tilemap extension descriptor.\n *\n * Registers the WebGL2/WebGPU tile chunk renderers (`renderers`) and the\n * {@link TileMapNode} scene serializer (`serializers`); it carries no asset\n * bindings - there is no generic on-disk tilemap format in this slice, so format\n * adapters (e.g. `@codexo/exojs-tiled`) own loading and depend on this\n * descriptor to pull in rendering.\n *\n * Install + register directly for procedural / hand-built maps\n * (`extensions: [tilemapExtension]` plus a `TileMap` built via the runtime), or\n * receive it transitively through a format adapter's `dependencies`.\n *\n * Pass it to the application that should have it via\n * `ApplicationOptions.extensions`.\n * @advanced\n */\nexport const tilemapExtension: Extension = Object.freeze({\n id: '@codexo/exojs-tilemap',\n renderers: [buildTileChunkRendererBinding(tileRendererBatchSize)],\n serializers: [{ typeName: 'TileMapNode', target: TileMapNode, serializer: tileMapNodeSerializer }],\n});\n"],"mappings":";;;;;;;;;AAUA,MAAM,wBAAwB;;;;;;;;;AAU9B,MAAM,iCAAiC,cACrC,sBAAsB,CAAC,aAAa,IAAG,YAAW;CAChD,IAAI,QAAQ,gBAAgB,kBAAkB,QAC5C,OAAO,IAAI,wBAAwB,SAAS;CAG9C,IAAI,QAAQ,gBAAgB,kBAAkB,QAC5C,OAAO,IAAI,wBAAwB;CAGrC,MAAM,IAAI,MAAM,+BAA+B,OAAO,QAAQ,WAA2B,GAAG;AAC9F,CAAC;;;;;;;;;;;;;;;;;;AAmBH,MAAa,mBAA8B,OAAO,OAAO;CACvD,IAAI;CACJ,WAAW,CAAC,8BAA8B,qBAAqB,CAAC;CAChE,aAAa,CAAC;EAAE,UAAU;EAAe,QAAQ;EAAa,YAAY;CAAsB,CAAC;AACnG,CAAC"}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { TileMapNode } from './TileMapNode';
|
|
3
|
-
/**
|
|
4
|
-
* Scene serializer for {@link TileMapNode} - the convenience node that renders a
|
|
5
|
-
* whole {@link TileMap}.
|
|
6
|
-
*
|
|
7
|
-
* Captures the **map reference** (its Loader source key) plus the render-only
|
|
8
|
-
* `pixelSnapMode`; the per-layer / per-chunk nodes are derived from the map and
|
|
9
|
-
* rebuilt on construction, so they are never written. The referenced `TileMap`
|
|
10
|
-
* must be pre-loaded into the target Loader (e.g. `loader.load(Asset.type('tileMap', 'world.tmj'))`)
|
|
11
|
-
* before deserialize - procedurally-built maps have no source key and cannot be
|
|
12
|
-
* referenced.
|
|
13
|
-
*
|
|
14
|
-
* Standalone `TileLayerNode` / `TileMapBand` placement (the actor-interleaving
|
|
15
|
-
* cases) is not yet covered.
|
|
16
|
-
*
|
|
17
|
-
* @internal - registered via {@link tilemapExtension}'s `serializers` binding.
|
|
18
|
-
*/
|
|
19
|
-
export declare const tileMapNodeSerializer: NodeSerializer<TileMapNode>;
|
|
1
|
+
export {};
|
|
20
2
|
//# sourceMappingURL=tilemapSerializers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tilemapSerializers.d.ts","sourceRoot":"","sources":["../../src/tilemapSerializers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tilemapSerializers.d.ts","sourceRoot":"","sources":["../../src/tilemapSerializers.ts"],"names":[],"mappings":""}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -90,12 +90,6 @@ export interface TileTransform {
|
|
|
90
90
|
}
|
|
91
91
|
/** The identity transform: no flip, no diagonal. */
|
|
92
92
|
export declare const TILE_TRANSFORM_IDENTITY: Readonly<TileTransform>;
|
|
93
|
-
/**
|
|
94
|
-
* Short string label for a {@link TileTransform} (debug / serialisation).
|
|
95
|
-
* Returns one of the eight deterministic names, e.g. `"flipX"` or `"diag+flipX+flipY"`.
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
export declare const tileTransformLabel: (t: TileTransform) => string;
|
|
99
93
|
/**
|
|
100
94
|
* Opaque packed tile data stored in a {@link TileChunk}'s compact array.
|
|
101
95
|
* 0 means "empty cell". Any non-zero value encodes localTileId, tilesetIndex,
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAExF,oEAAoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;IAC7C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,gBAAgB,CAAC,SAAS,CAAC;IACjD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,OAAO,g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E,OAAO,MAAM,KAAG,IAI9D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,MAAM,GAAG,SAAS,EAAE,QAAQ,MAAM,GAAG,SAAS,EAAE,YAAY,MAAM,EAAE,aAAa,MAAM,KAAG,IAQzI,CAAC"}
|
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { AbstractWebGl2Renderer } from '@codexo/exojs/renderer-sdk';
|
|
3
|
-
import type { TileChunkNode } from '../TileChunkNode';
|
|
4
|
-
/**
|
|
5
|
-
* Instanced WebGL2 renderer for {@link TileChunkNode}. Each tile is one
|
|
6
|
-
* instanced quad; tiles are batched by `(shader, tileset texture)` and one
|
|
7
|
-
* `drawArraysInstanced` is issued per batch. Per-chunk transforms ride on the
|
|
8
|
-
* shared transform buffer (one row per chunk node), so the chunk geometry is
|
|
9
|
-
* orientation-neutral and never re-uploaded for a camera pan.
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare class WebGl2TileChunkRenderer extends AbstractWebGl2Renderer<TileChunkNode> implements WebGl2RetainedBatchReplayer {
|
|
13
|
-
/**
|
|
14
|
-
* Retained-batch capability opt-in: a tile chunk's per-flush
|
|
15
|
-
* instanced batches (fixed 32-byte layout, tile word at word 7) can be
|
|
16
|
-
* recorded into a group's instruction set and replayed from group-owned
|
|
17
|
-
* resources. Pixel-snapped draws are excluded by the collect-time
|
|
18
|
-
* recordability predicate (and belt-and-braces poisoning in {@link render});
|
|
19
|
-
* tile chunks have no custom-material path to exclude.
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
readonly _supportsRetainedBatches = true;
|
|
23
|
-
private readonly _shader;
|
|
24
|
-
private readonly _batchSize;
|
|
25
|
-
private readonly _instanceData;
|
|
26
|
-
private readonly _instanceFloat32;
|
|
27
|
-
private readonly _instanceUint32;
|
|
28
|
-
private readonly _transformUnitScratch;
|
|
29
|
-
private readonly _baseTextureUnitScratch;
|
|
30
|
-
private readonly _recordTextures;
|
|
31
|
-
private _quadIndex;
|
|
32
|
-
private _maxNodeIndex;
|
|
33
|
-
private _batchNodeCount;
|
|
34
|
-
private _nodeBooked;
|
|
35
|
-
private _currentBlendMode;
|
|
36
|
-
private _currentTexture;
|
|
37
|
-
private _currentView;
|
|
38
|
-
private _currentViewId;
|
|
39
|
-
private _hasWrittenGroup;
|
|
40
|
-
private readonly _writtenGroupData;
|
|
41
|
-
private _instanceBuffer;
|
|
42
|
-
private _vao;
|
|
43
|
-
private _connection;
|
|
44
|
-
constructor(batchSize: number);
|
|
45
|
-
render(node: TileChunkNode): void;
|
|
46
|
-
private _renderPage;
|
|
47
|
-
private _writeRun;
|
|
48
|
-
flush(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Scope the batch memos to one batch: they describe what is accumulating, not
|
|
51
|
-
* what GL holds, so a memo that outlived its flush would let the next batch
|
|
52
|
-
* skip establishing state another renderer has since changed.
|
|
53
|
-
*/
|
|
54
|
-
private _resetBatchState;
|
|
55
|
-
/**
|
|
56
|
-
* Stage `u_projection` (live view) and `u_group` (live composed group
|
|
57
|
-
* matrix) on the shader, guarded by cached view/group stamps. Shared by the
|
|
58
|
-
* live flush path and retained-batch replay - replay resolves exactly the
|
|
59
|
-
* same live state a slow-path flush would.
|
|
60
|
-
*/
|
|
61
|
-
private _stageViewUniforms;
|
|
62
|
-
/** @internal See {@link WebGl2RetainedBatchReplayer._scanRetainedNodeIndexRange}. */
|
|
63
|
-
_scanRetainedNodeIndexRange(payload: WebGl2RetainedBatchPayload, range: WebGl2RetainedNodeIndexRange): void;
|
|
64
|
-
/** @internal See {@link WebGl2RetainedBatchReplayer._rebaseRetainedNodeIndices} (group-local indices). */
|
|
65
|
-
_rebaseRetainedNodeIndices(payload: WebGl2RetainedBatchPayload, base: number): void;
|
|
66
|
-
/**
|
|
67
|
-
* Point the batch VAO's per-instance attributes at the bundle's persistent
|
|
68
|
-
* instance buffer, based at the batch's byte offset (WebGL2 has no
|
|
69
|
-
* baseInstance, hence one small VAO per recorded batch). Same attribute
|
|
70
|
-
* set/locations as the live VAO in {@link onConnect}.
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
_configureRetainedVao(payload: WebGl2RetainedBatchPayload): void;
|
|
74
|
-
/**
|
|
75
|
-
* Replay one recorded batch: all STATE is resolved live - blend mode via
|
|
76
|
-
* the backend's dedup, `u_projection`/`u_group` from the live view + live
|
|
77
|
-
* composed group matrix (the camera-pan / group-move win), the single
|
|
78
|
-
* tileset texture bound to unit 0 by recorded slot order - and only the
|
|
79
|
-
* DATA is cached: the instance bytes in the bundle buffer (bound through
|
|
80
|
-
* the per-batch VAO) and the group-owned transform texture on the shared
|
|
81
|
-
* transform unit. The backend hook flushed any pending live batch before
|
|
82
|
-
* dispatching here and bumps the stats from the instruction descriptor.
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
_replayRetainedBatch(payload: WebGl2RetainedBatchPayload): void;
|
|
86
|
-
protected onConnect(backend: WebGl2Backend): void;
|
|
87
|
-
protected onDisconnect(): void;
|
|
88
|
-
destroy(): void;
|
|
89
|
-
private _createConnection;
|
|
90
|
-
private _createBufferRuntime;
|
|
91
|
-
private _createVaoRuntime;
|
|
92
|
-
}
|
|
1
|
+
export {};
|
|
93
2
|
//# sourceMappingURL=WebGl2TileChunkRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGl2TileChunkRenderer.d.ts","sourceRoot":"","sources":["../../../src/webgl2/WebGl2TileChunkRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebGl2TileChunkRenderer.d.ts","sourceRoot":"","sources":["../../../src/webgl2/WebGl2TileChunkRenderer.ts"],"names":[],"mappings":""}
|
|
@@ -78,7 +78,7 @@ var WebGl2TileChunkRenderer = class extends AbstractWebGl2Renderer {
|
|
|
78
78
|
const blendMode = node.blendMode;
|
|
79
79
|
const tintRgba = node.tint.toRgba8();
|
|
80
80
|
const command = backend.activeDrawCommand;
|
|
81
|
-
const nodeIndex = command !== null ? command.nodeIndex : backend.
|
|
81
|
+
const nodeIndex = command !== null ? command.nodeIndex : backend.pushTransform(node);
|
|
82
82
|
for (const page of pages) this._renderPage(page.texture, page.quads, blendMode, tintRgba, nodeIndex);
|
|
83
83
|
}
|
|
84
84
|
_renderPage(texture, quads, blendMode, tintRgba, nodeIndex) {
|
|
@@ -165,7 +165,7 @@ var WebGl2TileChunkRenderer = class extends AbstractWebGl2Renderer {
|
|
|
165
165
|
backend.stats.drawCalls++;
|
|
166
166
|
if (backend._isRetainedCapturing && this._currentTexture !== null) {
|
|
167
167
|
this._recordTextures[0] = this._currentTexture;
|
|
168
|
-
backend.
|
|
168
|
+
backend.recordRetainedBatch(this, this._instanceUint32.subarray(0, this._quadIndex * wordsPerInstance), this._quadIndex, this._currentBlendMode ?? BlendModes.Normal, this._recordTextures, 1, null, null, this._batchNodeCount);
|
|
169
169
|
}
|
|
170
170
|
this._resetBatchState();
|
|
171
171
|
}
|
|
@@ -201,10 +201,10 @@ var WebGl2TileChunkRenderer = class extends AbstractWebGl2Renderer {
|
|
|
201
201
|
this._writtenGroupData.set(groupData);
|
|
202
202
|
this._hasWrittenGroup = true;
|
|
203
203
|
}
|
|
204
|
-
backend.
|
|
204
|
+
backend.stageViewportUniform(this._shader);
|
|
205
205
|
}
|
|
206
|
-
/** @internal See {@link WebGl2RetainedBatchReplayer.
|
|
207
|
-
|
|
206
|
+
/** @internal See {@link WebGl2RetainedBatchReplayer.scanRetainedNodeIndexRange}. */
|
|
207
|
+
scanRetainedNodeIndexRange(payload, range) {
|
|
208
208
|
const words = payload.bundle.instanceWords;
|
|
209
209
|
const start = payload.byteOffset / Uint32Array.BYTES_PER_ELEMENT;
|
|
210
210
|
for (let i = 0; i < payload.instanceCount; i++) {
|
|
@@ -213,8 +213,8 @@ var WebGl2TileChunkRenderer = class extends AbstractWebGl2Renderer {
|
|
|
213
213
|
if (row > range.max) range.max = row;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
/** @internal See {@link WebGl2RetainedBatchReplayer.
|
|
217
|
-
|
|
216
|
+
/** @internal See {@link WebGl2RetainedBatchReplayer.rebaseRetainedNodeIndices} (group-local indices). */
|
|
217
|
+
rebaseRetainedNodeIndices(payload, base) {
|
|
218
218
|
const words = payload.bundle.instanceWords;
|
|
219
219
|
const start = payload.byteOffset / Uint32Array.BYTES_PER_ELEMENT;
|
|
220
220
|
for (let i = 0; i < payload.instanceCount; i++) {
|
|
@@ -230,7 +230,7 @@ var WebGl2TileChunkRenderer = class extends AbstractWebGl2Renderer {
|
|
|
230
230
|
* set/locations as the live VAO in {@link onConnect}.
|
|
231
231
|
* @internal
|
|
232
232
|
*/
|
|
233
|
-
|
|
233
|
+
configureRetainedVao(payload) {
|
|
234
234
|
const gl = this.getBackend().context;
|
|
235
235
|
const buffer = payload.bundle.instanceBuffer;
|
|
236
236
|
const vao = payload.vao;
|
|
@@ -249,7 +249,7 @@ var WebGl2TileChunkRenderer = class extends AbstractWebGl2Renderer {
|
|
|
249
249
|
* dispatching here and bumps the stats from the instruction descriptor.
|
|
250
250
|
* @internal
|
|
251
251
|
*/
|
|
252
|
-
|
|
252
|
+
replayRetainedBatch(payload) {
|
|
253
253
|
const backend = this.getBackendOrNull();
|
|
254
254
|
const vao = payload.vao;
|
|
255
255
|
const transformTexture = payload.bundle.transformTexture;
|