"use client"
import dynamic from "next/dynamic"
const MouseWaveScene = dynamic(
() => import("@/components/ui/mouse-wave-scene"),
{
ssr: false,
loading: () => (
<div className="h-full w-full bg-zinc-100 dark:bg-neutral-950">
{/* Skeleton loader */}
</div>
),
}
)
export function MouseWaveDemo() {
return (
<div className="h-auto max-h-[400px] w-full overflow-hidden rounded-lg">
<MouseWaveScene imageSrc="https://cdn.badtz-ui.com/images/shaders/forest-image.webp" />
</div>
)
}
pnpm dlx shadcn@latest add https://badtz-ui.com/r/mouse-wave.json
import dynamic from "next/dynamic";
const MouseWaveScene = dynamic(
() => import("@/components/ui/mouse-wave-scene"),
{
ssr: false,
loading: () => (
<div className="h-full w-full bg-zinc-100 dark:bg-neutral-950">
{/* Skeleton loader */}
</div>
),
},
);
<div className="w-full max-w-[620px] h-auto">
<MouseWaveScene imageSrc="/images/shaders/forest-image.webp" />
</div>
You can use a placeholder while loading, to avoid potential issues, consider using dynamic imports.
By default, the shader is automatically disabled on mobile and replaced with a static image.
mouse-wave-scene
props.
Prop | Type | Default |
---|---|---|
imageSrc | string | - |
alt? | string | undefined |
marginFactor? | number | 1.05 |
Here are some of the key resources that helped me learn about shaders. If you're interested in exploring shaders further, these are great places to start!
The GLSL shader used in this component was created by @stegu
If you are using Next.js 14 or earlier, install these packages instead:
@react-three/[email protected]
@react-three/[email protected] gsap
pnpm add @react-three/[email protected] @react-three/[email protected] gsap three
THREE.WebGLRenderer: Context Lost
error occurring on Next.js 15 projects.