Your system asks for reduced motion, so VFX-JS draws nothing. Demos on this site show plain HTML.
Class
BubbleEffect
effects/src/bubble.ts:1585 ↗import { BubbleEffect } from "@vfx-js/effects";Fills the element's silhouette, extruded into 3D, with a foam of transparent soap bubbles in thin-film colours.
vfx.add(img, { effect: new BubbleEffect({ roundness: 0.7 }) });
The volume is filled with big spheres spread at random but evenly
(cellSize), and the gaps they leave, between them and along the
outline, with smaller ones down to minSize. Where spheres overlap,
they are cut by a flat wall they share (a power diagram); where they
are exposed, they keep their round outside. roundness goes from a
flat-walled foam to nearly separate spheres. The films are found
exactly along each ray.
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. Films do not bend
light, so the page shows through the foam, dimmed by what the films
reflect; the output is premultiplied over it. With backdropVisible,
a backdrop is drawn behind the foam instead.
The camera (OrbitCameraParams: yaw, pitch,
orbitAnimation, fov, …) works as in GlassEffect, with
angles in degrees. Set drag: true to orbit it with pointer drags that
start on the element, and pointer: "tilt" to turn it towards the
pointer.
All params are read every frame, so you can mutate params live. The
bubbles are placed on the CPU, again whenever a placement param
changes (see BubbleParams).
- Implements
-
Effect - Interface members
-
disposeinitoutputRectrender
Constructors
new BubbleEffect()
new BubbleEffect(
initial?: Partial<BubbleParams> = {},
opts?: BubbleEffectOptions = {},
): BubbleEffect
Properties
params
params: BubbleParams
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 foam keeps the current shape until the new one has been read back (a few frames later), then switches to it and places its bubbles again. 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<BubbleParams>): void