/** * UV Raycasting * * Converts 3D raycast hits to UV pixel coordinates for painting. * This is the core of painting directly on 3D models. * * Implements Blockbench's exact 3D-to-UV painting pipeline: * 1. Raycast from mouse into 3D scene * 2. Get barycentric coordinates from hit * 3. Interpolate UV from triangle vertices * 4. Convert UV → pixel coordinates * 5. Apply brush to texture * 6. Update viewport */ import { Texture } from './texture'; import { MeshFace } from '../geometry/mesh_face'; import { Vector3 } from '../modeling/transform'; export interface RaycastHit { element: any; face: string | number; uv?: [number, number]; point?: Vector3; barycentric?: [number, number, number]; distance?: number; } export interface UVPaintCoordinates { x: number; y: number; texture: Texture; element: any; face: string | number; uv: [number, number] | [number, number, number, number]; } /** * Convert raycast UV coordinates to pixel coordinates * * Implements Blockbench's exact UV → pixel conversion: * pixelX = floor(u * textureWidth) * pixelY = floor(v * textureHeight) * * This is used when painting directly on 3D models */ export declare function getCanvasToolPixelCoords(uv: [number, number], texture: Texture): [number, number]; /** * Convert raycast hit to UV paint coordinates * * Implements Blockbench's exact 3D-to-UV painting conversion: * 1. For cubes: Use parametric UV rectangle * 2. For meshes: Use barycentric interpolation * 3. Convert UV → pixel coordinates */ export declare function raycastHitToPaintCoords(hit: RaycastHit, texture: Texture): UVPaintCoordinates | null; /** * Get texture to edit from element face * Handles texture groups and material mode */ export declare function getTextureToEdit(texture: Texture | null | undefined, viewMode?: 'material' | 'texture'): Texture | null; /** * Get mesh UV island (connected faces sharing UV space) * Framework adapters should implement this based on their mesh structure */ export declare function getMeshUVIsland(faceKey: string | number, face: MeshFace, element: any): Array; /** * Check if two faces are in the same UV island */ export declare function areFacesInSameUVIsland(face1: string | number, face2: string | number, element: any): boolean; //# sourceMappingURL=uv_raycasting.d.ts.map