Ghost Ether

WebGL-powered interactive fluid background simulation.

The Ghost Ether component creates an interactive, high-performance fluid simulation using WebGL and Three.js. It responds dynamically to user mouse pointer movements and touch gestures, injecting forces into the fluid grid.

Preview

Usage

Installation

$ npx shadcn@latest add https://spark-ui-olive.vercel.app/r/ghost-ether.json

Basic Example

import GhostEther from "@/registry/spark-ui/ghost-ether";

export default function App() {
  return (
    <div className="relative w-full h-[600px] bg-black">
      <GhostEther
        colors={["#7b2cbf", "#3f37c9", "#00f5d4"]}
        mouseForce={20}
        cursorSize={100}
      />
    </div>
  );
}

Properties

PropTypeDefaultDescription
colorsstring[]["#7B2CBF", "#3F37C9", "#00F5D4"]Array of hex color stops used to build the velocity-to-color mapping palette.
mouseForcenumber20Strength multiplier applied to user pointer movement when injecting fluid velocity.
cursorSizenumber100Radius (in pixels at base resolution) of the user pointer force brush.
resolutionnumber0.5Simulation texture scale relative to canvas size. Lower yields higher performance.
isViscousbooleanfalseEnables the iterative Gauss-Seidel viscosity solve for smoother, thicker flow.
viscousnumber30Viscosity coefficient applied when isViscous is active.
iterationsViscousnumber32Number of Jacobi iterations for the viscosity solve step.
iterationsPoissonnumber32Number of pressure Poisson iterations to enforce fluid incompressibility.
dtnumber0.014Constant time step size used for fluid simulation updates.
BFECCbooleantrueEnables Back and Forth Error Compensation and Correction for sharper advection textures.
isBouncebooleanfalseIf active, clamps velocity boundaries at the edges instead of soft wrapping.
autoDemobooleantrueEnables idle driving of the user cursor position when no interaction occurs.
autoSpeednumber0.5Wandering speed multiplier used when auto-demo is active.
autoIntensitynumber2.2Force scaling applied to the auto-demo wandering trail.
takeoverDurationnumber0.25Transition time (in seconds) when taking control over the auto-driver on interaction.
autoResumeDelaynumber1000Delay time (in milliseconds) before the auto-demo resumes after user interaction stops.
autoRampDurationnumber0.6Duration (in seconds) to fade in auto-demo movement once it resumes.