Your system asks for reduced motion, so VFX-JS draws nothing. Demos on this site show plain HTML.

Class

SwirlParticleEffect

effects/src/swirl-particle.ts:1557 ↗
import { SwirlParticleEffect } from "@vfx-js/effects";

Particles that flow over the surface of the element's silhouette, extruded into 3D, and peel off it in curling wisps. Fibres are shaded from the shape's SDF, coloured by a gradient SwirlParticleParams.palette (or the source colours, with sourceColor), with HDR sparkles and bloom.

vfx.add(img, { effect: new SwirlParticleEffect({ palette: "ember" }) });

The silhouette is the element's alpha (or the channel sourceChannel picks), read back when the effect starts and again when the element's aspect ratio changes. Call refresh() after its content changes. An opaque photo becomes an extruded slab. The particles are born over the first intro seconds (1.5 by default). The output is premultiplied over transparency, so set the page background yourself. The camera (OrbitCameraParams) is the one GlassEffect has, with angles in degrees; pointer: "tilt" turns it towards the pointer. With cameraOrigin: "viewport", the default pad of 200 can clip an element near the edge of the viewport.

All params, count and fireflyRatio included, are read every frame, so you can mutate params live. Numbers that are not finite fall back to their defaults. Set drag: true to orbit the camera by dragging the element, shadow: true to cast a drop shadow onto the page behind, and antialias: true to smooth the fibres' edges.

Implements
Effect
Interface members
disposeinitoutputRectrender

Constructors

new SwirlParticleEffect()

new SwirlParticleEffect(
    initial?: Partial<SwirlParticleParams> = {},
    opts?: SwirlParticleEffectOptions = {},
): SwirlParticleEffect

Properties

params

params: SwirlParticleParams

Methods

refresh

refresh(): void

Capture the element's silhouette again, for when its content changed: an image's src swapped, a text edit. For an <img>, call it after vfx.update(img) has reloaded the image.

The particles keep flowing over the current shape until the new one has been read back (a few frames later), then flow onto it, and respawn on it. A change of the element's aspect ratio is recaptured automatically once its size settles; a change of size alone needs none.

Safe to call at any time and any number of times; a call while a capture is pending restarts it, so the latest content wins.

setParams

setParams(updates: Partial<SwirlParticleParams>): void