Motion Kit

Canvas

Fake 3D Image

OGL depth-map parallax effect — move the cursor to shift the image by a grayscale depth map.

  • lit
  • ogl

Preview

Depth-map parallax effect. Move the cursor to shift the image against a grayscale depth map.
Attributes

Installation

pnpm dlx shadcn@latest add https://motion-kit-astro.vercel.app/r/fake-3d-image.json

Usage

---
import "@/components/motion-kit/fake-3d-image-element.ts";
---

<motion-fake-3d-image
  color-src="/path/to/image.jpg"
  depth-src="/path/to/depth-map.jpg"
  x-threshold="8"
  y-threshold="8"
  sensitivity="0.25"
  class="w-full h-[400px]"
/>

API Reference

Attribute Type Default
color-src URL of the color image to display. string ""
depth-src URL of the grayscale depth map (white = near, black = far). string ""
x-threshold Parallax strength threshold on X axis. number 8
y-threshold Parallax strength threshold on Y axis. number 8
sensitivity Mouse movement sensitivity (0 to 1). number 0.25