import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode, CSSProperties } from 'react'; /** * Coordinate-conversion helpers for `` consumers. * * The shader plane spans normalized device coordinates (NDC): `x, y ∈ [-1, 1]`, * with `(0, 0)` at the canvas center and `+y` pointing up. DOM event handlers * deliver `clientX`/`clientY` in viewport-relative pixels, so anything that * wants to drive the shader from a click or an element's position needs to * map between the two spaces. Doing this manually requires the canvas's * `getBoundingClientRect()` — the helpers here centralize that math so callers * never have to reach for `window.innerWidth` (which is only correct when the * shader is fullscreen) or walk the DOM to find the canvas. */ type ElementAnchor = "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right"; /** Convert viewport-relative pixels to the canvas's NDC space. */ declare function screenToNDC(canvas: HTMLCanvasElement, clientX: number, clientY: number): [number, number]; /** * Resolve an `ElementAnchor` against a `DOMRect` to viewport pixels. Exposed * so consumers can mirror the same anchor semantics outside of shader-dom. */ declare function rectAnchorPoint(rect: DOMRect | { left: number; top: number; width: number; height: number; }, anchor?: ElementAnchor): [number, number]; /** Convert an element's anchor point to the canvas's NDC space. */ declare function elementToNDC(canvas: HTMLCanvasElement, element: Element, anchor?: ElementAnchor): [number, number]; interface ShaderSceneLifecycle { /** * Called once when a child HtmlTexture's snapshot canvas first has * non-zero size (first successful snapshot). Called again if the * HtmlTexture unmounts and a new one mounts. * * The canvas reference is stable; its contents update in place. * three.js consumers wrap it in CanvasTexture and set needsUpdate. * Scenes consuming a data URL (e.g. liquid1.loadImage) call * snapshot.toDataURL() on demand. */ onSnapshot?: (snapshot: HTMLCanvasElement) => void; /** Called on resize (ResizeObserver on the ). */ onResize?: (width: number, height: number) => void; /** Called on unmount or `scene` prop change. */ dispose: () => void; } type ShaderScene = (canvas: HTMLCanvasElement) => ShaderSceneLifecycle; type ShaderCommonProps = { children: ReactNode; className?: string; style?: CSSProperties; }; type ShaderProps = ShaderCommonProps & ({ fragment: string; uniforms?: Record; scene?: never; } | { scene: ShaderScene; fragment?: never; uniforms?: never; } | { fragment?: never; scene?: never; uniforms?: never; }); declare function Shader(props: ShaderProps): react_jsx_runtime.JSX.Element; export { type ElementAnchor as E, Shader as S, type ShaderProps as a, type ShaderScene as b, type ShaderSceneLifecycle as c, elementToNDC as e, rectAnchorPoint as r, screenToNDC as s };