UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

255 lines (254 loc) 7.81 kB
/** * Lighting effect preset types. * These simulate light hitting a surface to add depth. */ export type LightingPreset = "inset" | "outset" | "pillow" | "ambient_occlusion"; /** * Configuration for lighting effects. * Adds pseudo-3D depth to flat textures by simulating light direction. */ export interface ILightingEffect { /** * The lighting preset to apply: * - 'inset': Darken top/left, lighten bottom/right (recessed panels, buttons) * - 'outset': Lighten top/left, darken bottom/right (raised blocks, bricks) * - 'pillow': Darken all edges toward center (rounded/soft look) * - 'ambient_occlusion': Darken only corners/edges (realistic depth) */ preset: LightingPreset; /** * Intensity of the effect (0.0 to 1.0). Default: 0.3 * - 0.0: No effect * - 0.5: Medium effect * - 1.0: Maximum effect */ intensity?: number; /** * Light source angle in degrees (0-360). Default: 315 (top-left) * - 0: Right * - 90: Bottom * - 180: Left * - 270: Top * - 315: Top-left (most common for pseudo-3D) */ angle?: number; } /** * Border style types. */ export type BorderStyle = "solid" | "dashed" | "worn" | "highlight"; /** * Configuration for a single border side (CSS-like). */ export interface IBorderSide { /** * Style of the border: * - 'solid': Continuous line * - 'dashed': Alternating on/off segments * - 'worn': Irregular/weathered edge * - 'highlight': Bright line (auto-lightened from base) */ style: BorderStyle; /** * Width in pixels (1-8). Default: 1 */ width?: number; /** * Border color (hex string). If not specified: * - For 'solid'/'dashed': Auto-darkens from texture * - For 'highlight': Auto-lightens from texture * - For 'worn': Uses texture color with variations */ color?: string; } /** * Configuration for border effects (CSS-like syntax). * Supports individual side configuration or shorthand for all sides. */ export interface IBorderEffect { /** * Shorthand: Apply to all sides. Individual side properties override this. */ all?: IBorderSide; /** * Top border configuration. */ top?: IBorderSide; /** * Right border configuration. */ right?: IBorderSide; /** * Bottom border configuration. */ bottom?: IBorderSide; /** * Left border configuration. */ left?: IBorderSide; /** * Random seed for 'worn' style. Enables deterministic weathering. */ seed?: number; } /** * Overlay pattern types for weathering and detail. */ export type OverlayPattern = "cracks" | "scratches" | "moss" | "rust" | "sparkle" | "veins"; /** * Configuration for overlay effects. * Adds surface detail without modifying the base texture structure. */ export interface IOverlayEffect { /** * The overlay pattern to apply: * - 'cracks': Dark lines suggesting cracks/fractures * - 'scratches': Light linear marks * - 'moss': Green/organic patches * - 'rust': Orange/brown oxidation spots * - 'sparkle': Bright highlight dots * - 'veins': Dark branching lines (for stone/marble) */ pattern: OverlayPattern; /** * Coverage density (0.0 to 1.0). Default: 0.3 * - 0.0: Almost no overlay * - 0.5: Medium coverage * - 1.0: Heavy coverage */ density?: number; /** * Override color for the overlay pattern (hex string). * If not specified, uses pattern-appropriate defaults. */ color?: string; /** * Random seed for deterministic pattern placement. */ seed?: number; } /** * Color variation mode types. */ export type ColorVariationMode = "hue_shift" | "saturation_jitter" | "value_jitter" | "palette_snap"; /** * Configuration for color variation effects. * Modifies the color distribution to reduce flatness. */ export interface IColorVariationEffect { /** * The color variation mode: * - 'hue_shift': Randomly shift hue within range * - 'saturation_jitter': Randomly vary saturation * - 'value_jitter': Randomly vary brightness/value * - 'palette_snap': Snap colors to nearest palette entry */ mode: ColorVariationMode; /** * Amount of variation (0.0 to 1.0). Default: 0.1 * - 0.0: No change * - 0.5: Medium variation * - 1.0: Maximum variation */ amount?: number; /** * For 'palette_snap': Array of colors to snap to (hex strings). */ palette?: string[]; /** * Random seed for deterministic variation. */ seed?: number; } /** * Tiling pattern types for seamless/patterned textures. */ export type TilingPattern = "brick" | "herringbone" | "basketweave" | "random"; /** * Configuration for tiling effects. * Helps create seamless textures or specific tiling patterns. */ export interface ITilingEffect { /** * Make edges seamless for repeating textures. */ seamless?: boolean; /** * Tiling pattern for block arrangement: * - 'brick': Offset rows by half * - 'herringbone': Diagonal zigzag pattern * - 'basketweave': Alternating horizontal/vertical groups * - 'random': Randomized positions */ pattern?: TilingPattern; /** * Offset amount for brick pattern (0.0 to 1.0). Default: 0.5 */ offset?: number; } /** * Combined effects configuration for a texture. * Multiple effects can be applied in a defined order. */ export interface ITextureEffects { /** * Lighting effect for pseudo-3D depth. */ lighting?: ILightingEffect; /** * Border effect for edges/outlines (CSS-like syntax). */ border?: IBorderEffect; /** * Overlay effects for surface detail. Applied in array order. */ overlay?: IOverlayEffect | IOverlayEffect[]; /** * Color variation effect. */ colorVariation?: IColorVariationEffect; /** * Tiling effect for seamless/patterned textures. */ tiling?: ITilingEffect; } /** * Apply lighting effect to pixel buffer. * Creates pseudo-3D depth by simulating light hitting a surface. */ export declare function applyLightingEffect(pixels: Uint8Array, width: number, height: number, effect: ILightingEffect): void; /** * Apply border effect to pixel buffer. * Uses CSS-like syntax for specifying individual or all sides. */ export declare function applyBorderEffect(pixels: Uint8Array, width: number, height: number, effect: IBorderEffect): void; /** * Apply overlay effect to pixel buffer. * Adds surface detail without modifying base structure. */ export declare function applyOverlayEffect(pixels: Uint8Array, width: number, height: number, effect: IOverlayEffect): void; /** * Apply color variation effect to pixel buffer. */ export declare function applyColorVariationEffect(pixels: Uint8Array, width: number, height: number, effect: IColorVariationEffect): void; /** * Apply tiling effect to pixel buffer. * Makes textures seamless or applies tiling patterns. */ export declare function applyTilingEffect(pixels: Uint8Array, width: number, height: number, effect: ITilingEffect): void; /** * Apply all texture effects to a pixel buffer in the correct order. * * Order of application: * 1. Color variation (modifies base colors) * 2. Lighting (adds depth based on position) * 3. Overlays (adds surface detail) * 4. Borders (adds edge definition) * 5. Tiling (makes seamless) * * @param pixels RGBA pixel buffer to modify in-place * @param width Buffer width * @param height Buffer height * @param effects Effects configuration */ export declare function applyTextureEffects(pixels: Uint8Array, width: number, height: number, effects: ITextureEffects): void;