import * as THREE from "three"; import type { TileRef, TilesetDefinition } from "./types.ts"; import type { BlockDefinition } from "../blocks/BlockDefinition.ts"; export type { TileRef, TilesetDefinition }; export interface TilesetDefaultBlockOptions { /** * Maximum block ID to generate (inclusive). * @default 255. **/ limit?: number; /** * Function to map block IDs to custom block definitions. */ map?: (blockId: number, col: number, row: number) => Omit; } /** Precomputed UV region for a specific tile in the atlas. */ export interface TilesetUVRegion { offsetU: number; offsetV: number; scaleU: number; scaleV: number; } /** TilesetDefinition with cols and rows guaranteed (resolved from image dimensions when omitted). */ export type ResolvedTilesetDefinition = TilesetDefinition & { cols: number; rows: number; }; export interface TilesetEntry { def: ResolvedTilesetDefinition; texture: THREE.Texture; material: THREE.MeshLambertMaterial | null; } /** * Manages tileset textures and computes UV regions for each tile. * * UV formula (Y-flipped for WebGL origin, half-texel inset to prevent bleeding): * offsetU = col * tileW / imgW + 0.5 / imgW * offsetV = 1 - (row + 1) * tileH / imgH + 0.5 / imgH * scaleU = (tileW - 1) / imgW * scaleV = (tileH - 1) / imgH * * A single shared THREE.Texture is kept per tileset — no per-tile cloning. * NearestFilter is used to preserve pixel-art crispness. */ export declare class TilesetManager { #private; /** * Loads a tileset image and registers it under the given definition ID. * The loader parameter is optional; a new TextureLoader is created if absent. */ loadTileset(def: TilesetDefinition, loader?: THREE.TextureLoader): Promise; /** * Registers a tileset from an already-loaded THREE.Texture. * Useful in tests or when the texture is loaded externally. */ registerTexture(def: TilesetDefinition, texture: THREE.Texture): void; /** * Computes the atlas UV region for the tile at (col, row) in a given tileset. * If tilesetId is omitted, the first registered tileset is used. */ getTileUV(ref: TileRef): TilesetUVRegion; /** * Returns the shared THREE.Texture for a tileset. **/ getTexture(tilesetId?: string): THREE.Texture | undefined; getDefinitions(): ResolvedTilesetDefinition[]; getDefaultBlocks(tilesetId?: string | null, options?: TilesetDefaultBlockOptions): BlockDefinition[]; get defaultTilesetId(): string | null; dispose(): void; } //# sourceMappingURL=TilesetManager.d.ts.map