Workspace / effect / three

Dither Object

Any GLB/glTF model, SVG, or image floating in a studio scene, rendered through a 1-bit dither.

Workspaceeffectthree

npx shadcn@latest add @pax-sh/dither-object-reactlocal only

Tier: high. Reduced motion: static dither render

DitherObject.tsx
"use client";

import { useEffect, useRef } from "react";
import { ditherObjectEffect } from "@pax-sh/effects";

export interface DitherObjectProps {
  className?: string;
  reducedMotion?: boolean;
  tier?: "low" | "medium" | "high";
  children?: React.ReactNode;
}

export function DitherObject(props: DitherObjectProps) {
  const rootRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const target = rootRef.current;
    if (!target) return;
    const instance = ditherObjectEffect.mount(target, {
      className: props.className,
      reducedMotion: props.reducedMotion,
      tier: props.tier,
    });
    return () => instance.dispose();
  }, [props.className, props.reducedMotion, props.tier]);

  return (
    <div ref={rootRef} className={props.className} data-pax-effect="dither-object">
      {props.children}
    </div>
  );
}