/** * UV Unwrapping System * * Fast, rule-based UV unwrapping optimized for low-poly, game-ready workflows * * This system uses face-based projection rather than global unwrapping algorithms. * It's designed to be fast, predictable, and pixel-art-friendly. */ import { Mesh } from '../geometry/mesh'; import { MeshFace } from '../geometry/mesh_face'; import { Cube } from '../geometry/cube'; import { Texture } from './texture'; /** * UV unwrapping options */ export interface UVUnwrapOptions { /** * Angle threshold for grouping faces into islands (degrees) * Faces with angle < threshold are grouped together */ angleThreshold?: number; /** * Projection method * - 'planar': Planar projection using dominant axis * - 'per_face': Each face projected individually * - 'auto': Automatically choose based on geometry */ projection?: 'planar' | 'per_face' | 'auto'; /** * Material-based grouping * If true, faces with different materials are in separate islands */ groupByMaterial?: boolean; /** * Pixel snapping * If true, snap UVs to pixel boundaries */ pixelSnap?: boolean; /** * Texture for pixel snapping and scaling */ texture?: Texture; /** * Padding between UV islands (in UV units) */ padding?: number; /** * Scale factor for UV coordinates */ scale?: number; /** * Minimum face area for island grouping * Faces smaller than this are isolated */ minFaceArea?: number; } /** * UV island (group of connected faces) */ export interface UVIsland { faces: Array<{ key: string; face: MeshFace; }>; material?: string | null; bounds?: { minU: number; minV: number; maxU: number; maxV: number; }; } /** * Identify UV islands (groups of connected faces) * * Implements Blockbench's exact island detection algorithm: * 1. Build face adjacency graph * 2. Check material compatibility * 3. Check angle threshold * 4. Check for existing UV seams * 5. BFS/DFS to build islands * 6. Handle special cases (border edges, non-manifold, tiny faces) */ export declare function identifyUVIslands(mesh: Mesh, faceKeys?: string[], options?: UVUnwrapOptions): UVIsland[]; /** * Merge multiple UV islands into one * * Used when islands should be stitched together */ export declare function mergeUVIslands(islands: UVIsland[], mesh: Mesh, options?: { angleThreshold?: number; pixelSnap?: boolean; texture?: Texture; }): UVIsland[]; /** * Unwrap mesh UVs * * Complete UV unwrapping pipeline: * 1. Identify UV islands * 2. Choose projection method * 3. Generate UV coordinates * 4. Stitch adjacent faces * 5. Pack UV islands * 6. Pixel snapping (optional) * 7. Update mesh UV data */ export declare function unwrapMeshUVs(mesh: Mesh, options?: UVUnwrapOptions): { unwrappedFaces: number; islands: number; }; /** * Unwrap cube UVs (parametric) * * Cubes use simple parametric UV mapping - no real unwrapping needed */ export declare function unwrapCubeUVs(cube: Cube, texture: Texture): void; /** * Relax UV coordinates * * Smooths out UV layout by averaging adjacent UVs * Framework adapters can implement more sophisticated relaxation */ export declare function relaxUVs(mesh: Mesh, faceKeys?: string[], iterations?: number): void; /** * Weld UV vertices * * Implements Blockbench's exact UV welding behavior: * 1. Same 3D vertex required * 2. Same material required * 3. Angle threshold check (smooth angles only) * 4. No manual seam * 5. UV proximity check * * Merges UV vertices that belong to the same 3D vertex and are close in UV space. */ export declare function weldUVs(mesh: Mesh, options?: { faceKeys?: string[]; tolerance?: number; angleThreshold?: number; force?: boolean; }): number; /** * Split UV vertices * * Implements Blockbench's exact UV splitting behavior: * 1. Creates separate UV vertices for each face using a vertex * 2. Duplicates the vertex in UV space (same 3D position, different UVs) * 3. Faces reference the appropriate UV copy * * This creates a seam by duplicating vertices. */ export declare function splitUVs(mesh: Mesh, vertexKeys: string[], options?: { byMaterial?: boolean; byAngle?: boolean; angleThreshold?: number; }): number; //# sourceMappingURL=uv_unwrapping.d.ts.map