LibraryEffects

ParticleMorph

A WebGL particle field that morphs through a queue of shapes.

ParticleMorph

Status: internal
Package path: packages/effects/src/particle-morph/
Import: @ziteox/effects/particle-morph

A particle field that gathers into a shape, holds it, scatters back into a loose field, then gathers into the next shape in the queue, on a loop. It fills the box you give it, so it works as a background behind content or inline at a fixed height. The field leans gently toward the pointer.

Preview

ParticleMorph · defaults

Usage

As a background, positioned behind your content:

import { ParticleMorph } from "@ziteox/effects/particle-morph";

export function Banner() {
  return (
    <section style={{ position: "relative", minHeight: 480 }}>
      <ParticleMorph style={{ position: "absolute", inset: 0 }} />
      {/* content */}
    </section>
  );
}

Inline, with your own shapes, colours and timing:

<ParticleMorph
  height={320}
  shapes={["torus", "box"]}
  color="#7C9CFF"
  colorAlt="#4B6BDB"
  holdSeconds={4}
/>

Text and images can be stages too:

<ParticleMorph
  stages={[
    { type: "text", text: "Hello" },
    { type: "shape", shape: "sphere" },
    { type: "image", src: "/mark.svg", size: 5 },
  ]}
/>

Install peer dependencies in your app:

pnpm add three @react-three/fiber

Example preset: ziteox.com

The slower four-shape queue behind the ziteox.com home hero. It is an example, not the default.

ParticleMorph · ziteox.com preset
<ParticleMorph
  stages={[
    { type: "shape", shape: "sphere" },
    { type: "shape", shape: "cloud" },
    { type: "shape", shape: "servers" },
    { type: "shape", shape: "torus", offset: [0, 0.6, 0] },
  ]}
  gatherSeconds={11}
  holdSeconds={3.5}
  scatterSeconds={6}
  opacity={0.9}
/>

Props

PropTypeDefaultDescription
shapesParticleShape[]["sphere", "torus", "box"]Shapes to morph through, looped. ParticleShape is "sphere" | "torus" | "box" | "cloud" | "servers"
stagesParticleMorphStage[]Full stage list (shape, text or image, each with an optional [x, y, z] offset); overrides shapes
colorstring--zx-particle-color, then #3BEA9CMain particle colour
colorAltstring--zx-particle-color-alt, then #21AB70Second particle colour
particleCountnumber3000Particles in the shapes (a small roaming pool is added)
gatherSecondsnumber4.2Time to gather into a shape
holdSecondsnumber2.8Time a finished shape is held
scatterSecondsnumber2.5Time to scatter back into the field
fadebooleantrueFade the field out towards its edges
opacitynumber1Opacity of the whole field
compactBelownumber640Container width (px) below which the lighter small-size tuning is used
width / heightCSS length"100%"Size; by default it fills its container
reducedMotionFallbackReactNodenullRendered instead of the animation for prefers-reduced-motion
tuningParticleMorphTuningAdvanced engine values (point sizes, intensity, roaming pool, stagger)
className / styleOn the wrapper

Behaviour

  • Client-only. three and @react-three/fiber load lazily the first time a ParticleMorph mounts in the browser, so pages that don't use it never download them.
  • The render loop pauses while the field is out of view.
  • Tuning follows the container width, not the viewport, so it looks the same wherever it is placed.
  • prefers-reduced-motion: reduce renders reducedMotionFallback (nothing by default).
  • Decorative: aria-hidden with pointer-events: none.