import { TextureOptions, TexturePreset } from "./texturePresets.js"; import { TileMapData } from "../tilemap/types.js"; import { Loader } from "three"; import { NormalSourceDescriptor } from "@three-flatland/normals"; import { BakedAssetLoaderOptions } from "@three-flatland/bake"; //#region src/loaders/TiledLoader.d.ts /** * Shape accepted by `TiledLoaderOptions.normals`. Same semantics as * the LDtk loader's option — see {@link TiledLoaderOptions.normals}. */ type TiledNormalsOption = false | true | NormalSourceDescriptor; /** * Options for loading a Tiled map. */ interface TiledLoaderOptions extends BakedAssetLoaderOptions { /** Texture preset or custom options. Overrides loader and global defaults. */ texture?: TexturePreset | TextureOptions; /** * Normal-map generation. Same semantics as * `LDtkLoaderOptions.normals`. Reads `tileDir` / `tileCap*` from * each tile's properties. Each baked normal map is attached to its * `TilesetData.normalMap`. */ normals?: TiledNormalsOption; } /** * Loader for Tiled JSON format (.tmj/.json). * * Extends Three.js's Loader class for compatibility with R3F's useLoader. * Supports: * - Standard JSON map format * - Embedded and external tilesets * - Tile layers with data arrays * - Infinite maps with chunks * - Object layers * - Tile animations * - Tile collision data * * @example * ```typescript * // Three.js usage - static API * const mapData = await TiledLoader.load('/maps/level1.json') * * // Override for this load * const mapData = await TiledLoader.load('/maps/hd-level.json', { texture: 'smooth' }) * * // R3F usage - works with useLoader * import { TiledLoader } from 'three-flatland/react'; * const mapData = useLoader(TiledLoader, '/maps/level1.json'); * * // Override preset via extension * const mapData = useLoader(TiledLoader, '/maps/hd-level.json', (loader) => { * loader.preset = 'smooth'; * }); * * // Set loader-level default * TiledLoader.options = 'pixel-art' * ``` */ declare class TiledLoader extends Loader { private static cache; /** * Texture options for this loader class. * When undefined, falls through to TextureConfig.options. */ static options: TexturePreset | TextureOptions | undefined; /** * Instance-level preset override. * Set via R3F's useLoader extension callback. * * @example * ```tsx * const mapData = useLoader(TiledLoader, '/maps/level.json', (loader) => { * loader.preset = 'smooth'; * }); * ``` */ preset: TexturePreset | TextureOptions | undefined; /** * Normal-map generation. See {@link TiledLoaderOptions.normals}. */ normals: TiledNormalsOption; /** * Generate this tilemap's tileset normal maps in the browser on * every load instead of loading pre-baked sidecars. The in-memory * bake runs on every load; sidecar probes and "no baked sibling" * warns are skipped. Not a dev-iteration knob. * See {@link BakedAssetLoaderOptions.forceRuntime}. */ forceRuntime: boolean; /** * Load a Tiled map asynchronously (for R3F useLoader compatibility). * Presets are automatically applied. */ loadAsync(url: string): Promise; /** * Load a Tiled JSON map (static method for Three.js usage). * Results are cached by URL and resolved options. */ static load(url: string, options?: TiledLoaderOptions): Promise; /** * Get cache key including resolved options. */ private static getCacheKey; /** * Load without caching. */ private static loadUncached; /** * Parse Tiled JSON map. */ private static parseMap; /** * Parse tileset (embedded or external). */ private static parseTileset; /** * Build a normal-source descriptor for a Tiled tileset from per-tile * properties and hand it to `resolveNormalMap`. Mirrors the LDtk * loader's synthesis path — `tilesetToRegions` carves cap/face * regions for tagged cells, untagged cells emit a single flat * region. */ private static resolveTilesetNormals; /** * Calculate UV coordinates for a tile. */ private static calculateUV; /** * Parse a collision object from tile. */ private static parseCollisionObject; /** * Parse a tile layer. */ private static parseTileLayer; /** * Parse infinite layer chunks into a contiguous array. */ private static parseInfiniteLayer; /** * Parse an object layer. */ private static parseObjectLayer; /** * Parse Tiled properties array to object. */ private static parseProperties; /** * Parse Tiled color string to number. */ private static parseColor; /** * Load a texture with the specified options. */ private static loadTexture; /** * Clear the cache. */ static clearCache(): void; /** * Preload multiple maps. */ static preload(urls: string[], options?: TiledLoaderOptions): Promise; } //#endregion export { TiledLoader, TiledLoaderOptions, TiledNormalsOption }; //# sourceMappingURL=TiledLoader.d.ts.map