UNPKG

@wolffo/three-fire

Version:

Modern TypeScript volumetric fire effect for Three.js and React Three Fiber

101 lines 2.84 kB
import React from 'react'; import { ReactThreeFiber } from '@react-three/fiber'; import { Fire as FireMesh, FireProps as FireMeshProps } from './Fire'; import { Texture } from 'three'; declare module '@react-three/fiber' { interface ThreeElements { fire: ReactThreeFiber.Object3DNode<FireMesh, typeof FireMesh>; } } /** * Props for the Fire React component */ export interface FireProps extends Omit<FireMeshProps, 'fireTex'> { /** Fire texture URL or Three.js Texture object */ texture: string | Texture; /** Auto-update time from useFrame (default: true) */ autoUpdate?: boolean; /** Custom update function called each frame */ onUpdate?: (fire: FireMesh, time: number) => void; /** Child components */ children?: React.ReactNode; /** Position in 3D space */ position?: [number, number, number]; /** Rotation in radians */ rotation?: [number, number, number]; /** Scale factor (uniform or per-axis) */ scale?: [number, number, number] | number; } /** * Ref interface for imperative fire control */ export interface FireRef { /** Fire mesh instance */ fire: FireMesh | null; /** Update fire animation manually */ update: (time?: number) => void; } /** * React Three Fiber component for volumetric fire effect * * Creates a procedural fire effect that can be easily integrated into R3F scenes. * The component automatically handles texture loading, animation updates, and * provides props for all fire parameters. * * @example * ```tsx * <Canvas> * <Fire * texture="/fire.png" * color="orange" * magnitude={1.5} * scale={[2, 3, 2]} * position={[0, 0, 0]} * /> * </Canvas> * ``` * * @example With custom animation * ```tsx * <Fire * texture="/fire.png" * onUpdate={(fire, time) => { * fire.fireColor.setHSL((time * 0.1) % 1, 1, 0.5) * }} * /> * ``` */ export declare const FireComponent: React.ForwardRefExoticComponent<FireProps & React.RefAttributes<FireRef>>; /** * Hook for easier access to fire instance and controls * * Provides a ref and helper methods for controlling fire imperatively. * * @returns Object with ref, fire instance, and update method * * @example * ```tsx * function MyComponent() { * const fireRef = useFire() * * const handleClick = () => { * if (fireRef.fire) { * fireRef.fire.magnitude = 2.0 * } * } * * return ( * <Fire ref={fireRef.ref} texture="/fire.png" /> * ) * } * ``` */ export declare const useFire: () => { /** Ref to pass to Fire component */ ref: React.RefObject<FireRef>; /** Fire mesh instance (null until mounted) */ fire: FireMesh | null; /** Update fire animation manually */ update: (time?: number) => void | undefined; }; //# sourceMappingURL=FireComponent.d.ts.map