/** * `BodyMaterial` — wrapper around a `THREE.ShaderMaterial` for procedural planets. * * Available types: `'rocky' | 'gaseous' | 'metallic' | 'star'`. * Zero Vue dependency — usable in any Three.js project. */ import * as THREE from 'three'; import { type LibBodyType } from './params'; import type { TerrainLevel } from '../render/types/terrain.types'; /** * Maximum number of palette entries passed to the rocky shader. Matches * `PALETTE_MAX` in `shaders/glsl/bodies/rocky.frag` — entries beyond this are * silently dropped. Sized generously so the derived band count * (`resolveTerrainLevelCount` — ≈ `shell / DEFAULT_TERRAIN_STEP`) always fits * for any playable body radius / core ratio combination. */ export declare const BODY_SHADER_PALETTE_MAX = 128; /** * Liquid-mask configuration (rocky bodies with a surface liquid shell). * * When provided, the fragment shader excludes submerged regions from * per-fragment effects (cracks, lava) by replicating the CPU simplex3D * elevation field through `uLiquidPerm` and comparing against * `seaLevel`. Substance-agnostic — the same mask drives water, methane, * nitrogen or any other caller-defined liquid. */ export interface LiquidMaskOptions { /** 512×1 `UNSIGNED_BYTE` permutation texture (see `shaders/simplexPerm.ts`). */ permTexture: THREE.DataTexture; /** Elevation threshold from `BodySimulation.seaLevelElevation`. */ seaLevel: number; /** `config.noiseScale` — must match the CPU sampling frequency. */ noiseScale: number; /** Body radius used to normalise object-space positions to the unit sphere. */ radius: number; } /** * Constructor options for {@link BodyMaterial}. Configures the primary * light (kelvin + intensity + direction), ambient tint, vertex-color * support and an optional liquid-mask texture bundle. */ export interface BodyMaterialOptions { lightKelvin?: number; lightIntensity?: number; lightDir?: number[] | THREE.Vector3; ambientColor?: string | THREE.Color; vertexColors?: boolean; liquid?: LiquidMaskOptions; /** * Optional terrain palette — when set, the rocky fragment shader samples its * base colour from the palette (same thresholds & colours as the hex tile * bands) instead of the two-tone `uColorA/uColorB` gradient. Non-rocky * shaders ignore the palette uniforms. */ palette?: TerrainLevel[]; } /** * Mutable subset of the light state accepted by `BodyMaterial.updateLight`. * Any field omitted leaves the current value untouched. */ export interface BodyLightUpdate { kelvin?: number; intensity?: number; direction?: number[] | THREE.Vector3; ambientColor?: string | THREE.Color; } /** * Shader parameter value — broad enough to cover all presets across * rocky / gas / metallic / star bodies (scalar floats, hex colours, * `noiseSeed` arrays, feature toggles). */ export type ParamValue = number | string | number[] | boolean; /** Flat bag of shader parameters keyed by uniform name. */ export type ParamMap = Record; /** * @example * ```ts * const planet = new BodyMaterial('rocky', { roughness: 0.8, colorA: '#c87941' }) * sphere.material = planet.material * * // Render loop * planet.tick(elapsed) * * // Live-update params without rebuilding * planet.setParams({ lavaAmount: 0.5 }) * * // Switch type (rebuilds the material, keeps common params) * planet.setType('gaseous') * * // Light configuration * planet.setLight({ kelvin: 3500, intensity: 1.8, direction: [0, 1, 0.5] }) * * planet.dispose() * ``` */ export declare class BodyMaterial { #private; constructor(type: LibBodyType, params?: ParamMap, options?: BodyMaterialOptions); /** `THREE.ShaderMaterial` ready to assign to a `THREE.Mesh`. */ get material(): THREE.ShaderMaterial; /** Snapshot of the current scalar/string params (excludes light config). */ get params(): ParamMap; /** Updates time (call every frame in the render loop). */ tick(elapsed: number): void; /** Updates one or more params **without rebuilding** the material. */ setParams(partial: ParamMap): void; /** * Switches the shader type. **The material is rebuilt.** * Params that exist in the new type are preserved; the others are reset to defaults. */ setType(type: LibBodyType): void; /** Toggles vertex-colour support. **The material is rebuilt.** */ setVertexColors(enabled: boolean): void; /** Updates the light config. Only provided fields are changed. */ setLight({ kelvin, intensity, direction, ambientColor }?: BodyLightUpdate): void; /** * Enables / disables flat lighting (top-down view). * When enabled, `diff = 1` over the whole surface — removes directional gradients * and dark areas caused by the surface normal when seen from above. */ setFlatLighting(enabled: boolean): void; /** * Moves the liquid-mask waterline in simplex-noise space. Silently * ignored when the material was built without a liquid mask (non-rocky * or no surface liquid). Drives the `uSeaLevel` uniform consumed by * `liquidMask.glsl` — cracks/lava/craters flip their submerged gating * as the threshold slides. */ setSeaLevel(simplexThreshold: number): void; /** * Backdrop attenuation in `[0, 1]` driving `uViewDim` on `gas.frag`. * `1.0` = full-intensity (Shader view); lower values fade the disc * into the background (Sol view). No-op on shaders that don't consume * the uniform. */ setViewDim(value: number): void; /** * Replaces the terrain palette uniforms at runtime (no material rebuild). * Pass `null`/`undefined` to clear the palette and fall back to the legacy * two-tone gradient. */ setPalette(palette: TerrainLevel[] | null | undefined): void; /** Releases the material's GPU memory. */ dispose(): void; } //# sourceMappingURL=BodyMaterial.d.ts.map