Motion Blocks

Canvas

Fake 3D Image

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

  • lit Preview of https://lit.devLitSimple. Fast. Web Components.
  • ogl Preview of https://github.com/oframe/oglOGLMinimal WebGL framework.

Preview

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

Installation

pnpm dlx motion-blocks add fake-3d-image

Usage

---import "@/components/motion-blocks/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