Installation
Choose your framework. The registry installs one component file and its PixiJS dependency.
Installation unavailable
The preview is public, but its installable release is still being prepared.
The registry command writes the component to src/lib/components/ui/GlassLens.svelte and installs its dependencies.
The registry command writes the component to src/components/ui/GlassLens.tsx and installs its dependencies.
The registry command writes the component to src/components/ui/GlassLens.vue and installs its dependencies.
Overview
Glass Lens places an image over a configurable surface and moves a plano-convex glass volume toward the pointer with frame-rate-independent smoothing.
The lens traces refraction through curved and planar interfaces, separates wavelengths, adds Fresnel reflections, and casts a soft offset shadow onto the image plane.
Basic usage
The shader fills its parent. Your layout decides whether that parent is a card, hero, or viewport.
- Give the component a definite parent size; the image scale and lens diameter are relative to that surface.
- Pointer tracking is enabled by default. Reduced-motion mode keeps the lens interactive but applies pointer positions without interpolation.
- Keep the image source CORS-accessible when it is hosted on another origin.
Component API
Types below match the selected Svelte component.
Additional classes for the parent-sized root element.
- Type
string
URL or data URL displayed beneath the physical glass lens.
- Type
string- Range / values
Image URL or data URL
Controls how the source image is placed inside the canvas.
- Type
"cover" | "fit" | "stretch"- Default
"cover"- Range / values
cover, fit, stretch
Size of the centered image relative to the canvas.
- Type
number- Default
1- Range / values
0.2–1
Color revealed around the image when its scale is reduced.
- Type
string- Default
"#FFFFFF"
Diameter of the circular lens relative to canvas height.
- Type
number- Default
0.4- Range / values
0.15–0.8
Depth of the plano-convex glass volume in lens-radius units.
- Type
number- Default
0.42- Range / values
0.05–0.9
Refractive index used at the air, glass, and exit interfaces.
- Type
number- Default
1.5- Range / values
1–2.2
Spectral separation produced by wavelength-dependent refraction.
- Type
number- Default
0.65- Range / values
0–2
Distance from the rear glass surface to the image plane.
- Type
number- Default
0.65- Range / values
0–2
Strength of Fresnel reflections and the spectral rim.
- Type
number- Default
0.8- Range / values
0–2
Density of the soft shadow cast onto the background plane.
- Type
number- Default
0.16- Range / values
0–0.6
Spread of the cast shadow across the background surface.
- Type
number- Default
0.7- Range / values
0.1–1.5
Offset of the shadow from the lens center.
- Type
number- Default
0.72- Range / values
0–2
Direction of the cast shadow in screen space.
- Type
number- Default
52- Range / values
-180–180
Response rate of the lens as it eases toward the pointer.
- Type
number- Default
9- Range / values
1–30
Stops the render loop while keeping the current frame visible.
- Type
boolean- Default
false
Enables pointer-driven effects when the shader supports them.
- Type
boolean- Default
true
Caps render resolution independently from the element size.
- Type
number- Default
2- Range / values
1–3
Scales GPU resolution without changing layout dimensions.
- Type
number- Default
1- Range / values
0.25–1
Runs after the shader is mounted successfully, including a WebGL fallback.
- Type
(backend: ShaderBackend) => void- Range / values
webgpu, webgl
Runs when automatic initialization changes the requested WebGPU backend to WebGL.
- Type
(backend: ShaderBackend, reason: string) => void- Range / values
webgl
Reports source-loading or renderer failures so the host application can decide how to recover.
- Type
(error: Error) => void
Exposes the imperative component lifecycle methods.
- Type
Component public instance- Range / values
pause, resume, reset, resize, destroy
Types below match the selected React component.
Additional classes for the parent-sized root element.
- Type
string
URL or data URL displayed beneath the physical glass lens.
- Type
string- Range / values
Image URL or data URL
Controls how the source image is placed inside the canvas.
- Type
"cover" | "fit" | "stretch"- Default
"cover"- Range / values
cover, fit, stretch
Size of the centered image relative to the canvas.
- Type
number- Default
1- Range / values
0.2–1
Color revealed around the image when its scale is reduced.
- Type
string- Default
"#FFFFFF"
Diameter of the circular lens relative to canvas height.
- Type
number- Default
0.4- Range / values
0.15–0.8
Depth of the plano-convex glass volume in lens-radius units.
- Type
number- Default
0.42- Range / values
0.05–0.9
Refractive index used at the air, glass, and exit interfaces.
- Type
number- Default
1.5- Range / values
1–2.2
Spectral separation produced by wavelength-dependent refraction.
- Type
number- Default
0.65- Range / values
0–2
Distance from the rear glass surface to the image plane.
- Type
number- Default
0.65- Range / values
0–2
Strength of Fresnel reflections and the spectral rim.
- Type
number- Default
0.8- Range / values
0–2
Density of the soft shadow cast onto the background plane.
- Type
number- Default
0.16- Range / values
0–0.6
Spread of the cast shadow across the background surface.
- Type
number- Default
0.7- Range / values
0.1–1.5
Offset of the shadow from the lens center.
- Type
number- Default
0.72- Range / values
0–2
Direction of the cast shadow in screen space.
- Type
number- Default
52- Range / values
-180–180
Response rate of the lens as it eases toward the pointer.
- Type
number- Default
9- Range / values
1–30
Stops the render loop while keeping the current frame visible.
- Type
boolean- Default
false
Enables pointer-driven effects when the shader supports them.
- Type
boolean- Default
true
Caps render resolution independently from the element size.
- Type
number- Default
2- Range / values
1–3
Scales GPU resolution without changing layout dimensions.
- Type
number- Default
1- Range / values
0.25–1
Runs after the shader is mounted successfully, including a WebGL fallback.
- Type
(backend: ShaderBackend) => void- Range / values
webgpu, webgl
Runs when automatic initialization changes the requested WebGPU backend to WebGL.
- Type
(backend: ShaderBackend, reason: string) => void- Range / values
webgl
Reports source-loading or renderer failures so the host application can decide how to recover.
- Type
(error: Error) => void
Exposes the imperative component lifecycle methods.
- Type
GlassLensHandle- Range / values
pause, resume, reset, resize, destroy
Types below match the selected Vue component.
Additional classes for the parent-sized root element.
- Type
string
URL or data URL displayed beneath the physical glass lens.
- Type
string- Range / values
Image URL or data URL
Controls how the source image is placed inside the canvas.
- Type
"cover" | "fit" | "stretch"- Default
"cover"- Range / values
cover, fit, stretch
Size of the centered image relative to the canvas.
- Type
number- Default
1- Range / values
0.2–1
Color revealed around the image when its scale is reduced.
- Type
string- Default
"#FFFFFF"
Diameter of the circular lens relative to canvas height.
- Type
number- Default
0.4- Range / values
0.15–0.8
Depth of the plano-convex glass volume in lens-radius units.
- Type
number- Default
0.42- Range / values
0.05–0.9
Refractive index used at the air, glass, and exit interfaces.
- Type
number- Default
1.5- Range / values
1–2.2
Spectral separation produced by wavelength-dependent refraction.
- Type
number- Default
0.65- Range / values
0–2
Distance from the rear glass surface to the image plane.
- Type
number- Default
0.65- Range / values
0–2
Strength of Fresnel reflections and the spectral rim.
- Type
number- Default
0.8- Range / values
0–2
Density of the soft shadow cast onto the background plane.
- Type
number- Default
0.16- Range / values
0–0.6
Spread of the cast shadow across the background surface.
- Type
number- Default
0.7- Range / values
0.1–1.5
Offset of the shadow from the lens center.
- Type
number- Default
0.72- Range / values
0–2
Direction of the cast shadow in screen space.
- Type
number- Default
52- Range / values
-180–180
Response rate of the lens as it eases toward the pointer.
- Type
number- Default
9- Range / values
1–30
Stops the render loop while keeping the current frame visible.
- Type
boolean- Default
false
Enables pointer-driven effects when the shader supports them.
- Type
boolean- Default
true
Caps render resolution independently from the element size.
- Type
number- Default
2- Range / values
1–3
Scales GPU resolution without changing layout dimensions.
- Type
number- Default
1- Range / values
0.25–1
Runs after the shader is mounted successfully, including a WebGL fallback.
- Type
(backend: ShaderBackend) => void- Range / values
webgpu, webgl
Runs when automatic initialization changes the requested WebGPU backend to WebGL.
- Type
(backend: ShaderBackend, reason: string) => void- Range / values
webgl
Reports source-loading or renderer failures so the host application can decide how to recover.
- Type
(error: Error) => void
Exposes the imperative component lifecycle methods.
- Type
Component public instance- Range / values
pause, resume, reset, resize, destroy