Loading…
Creator · Aceternity UI
View original source ↗
Prompt
// components/ui/parallax-hero-images.tsx
"use client";
import React, { useEffect, useState, useMemo, useCallback, memo } from "react";
import {
motion,
useMotionValue,
useSpring,
useTransform,
MotionValue,
} from "motion/react";
import { cn } from "@/lib/utils";
type ImagePosition = {
src: string;
position:
| "top-left"
| "top-right"
| "mid-left"
| "mid-right"
| "bottom-left"
| "bottom-right"
| "far-left"
| "far-right";
depth: number;
delay: number;
};
const positionStyles: Record<
ImagePosition["position"],
{ top: string; left?: string; right?: string }
> = {
"top-left": { top: "8%", left: "4%" },
"top-right": { top: "8%", right: "4%" },
"mid-left": { top: "38%", left: "6%" },
"mid-right": { top: "38%", right: "6%" },
"bottom-left": { top: "68%", left: "4%" },
"bottom-right": { top: "68%", right: "4%" },
"far-left": { top: "52%", left: "2%" },
"far-right": { top: "52%", right: "2%" },
};
const positionOrder: ImagePosition["position"][] = [
"top-left",
"top-right",
"mid-left",
"mid-right",
"bottom-left",
"bottom-right",
"far-left",
"far-right",
];
type DepthVariant = "default" | "edge-focus";
const depthValuesByVariant: Record<DepthVariant, number[]> = {
default: [0.3, 0.35, 0.9, 0.85, 0.4, 0.45, 0.25, 0.2],
"edge-focus": [0.85, 0.9, 0.3, 0.35, 0.8, 0.85, 0.4, 0.45],
};
const SPRING_CONFIG = { damping: 25, stiffness: 120 };
export interface ParallaxHeroImagesProps {
images: string[];
className?: string;
imageClassName?: string;
variant?: DepthVariant;
}
export const ParallaxHeroImages = ({
images,
className,
imageClassName,
variant = "default",
}: ParallaxHeroImagesProps) => {
const mouseX = useMotionValue(0);
const mouseY = useMotionValue(0);
const smoothMouseX = useSpring(mouseX, SPRING_CONFIG);
const smoothMouseY = useSpring(mouseY, SPRING_CONFIG);
const positions = useMemo(() => {
const limitedImages = images.slice(0, 8);
const depthValues = depthValuesByVariant[variant];
return limitedImages.map((src, index) => ({
src,
position: positionOrder[index],
depth: depthValues[index],
delay: index * 0.12,
}));
}, [images, variant]);
useEffect(() => {
const handleMouseMove = (e: MouseEvent) => {
const x = (e.clientX / window.innerWidth) * 2 - 1;
const y = (e.clientY / window.innerHeight) * 2 - 1;
mouseX.set(x);
mouseY.set(y);
};
window.addEventListener("mousemove", handleMouseMove);
return () => window.removeEventListener("mousemove", handleMouseMove);
}, [mouseX, mouseY]);
return (
<div
className={cn(
"pointer-events-none absolute inset-0 overflow-hidden",
className,
)}
>
{positions.map((pos, index) => (
<ParallaxImage
key={`${pos.src}-${index}`}
src={pos.src}
position={pos.position}
depth={pos.depth}
delay={pos.delay}
imageClassName={imageClassName}
smoothMouseX={smoothMouseX}
smoothMouseY={smoothMouseY}
/>
))}
</div>
);
};
interface ParallaxImageProps extends ImagePosition {
imageClassName?: string;
smoothMouseX: MotionValue<number>;
smoothMouseY: MotionValue<number>;
}
const ParallaxImage = memo(function ParallaxImage({
src,
position,
depth,
delay,
imageClassName,
smoothMouseX,
smoothMouseY,
}: ParallaxImageProps) {
const maxOffset = 40;
const translateX = useTransform(
smoothMouseX,
[-1, 1],
[-maxOffset * depth, maxOffset * depth],
);
const translateY = useTransform(
smoothMouseY,
[-1, 1],
[-maxOffset * depth, maxOffset * depth],
);
const posStyle = positionStyles[position];
return (
<motion.div
className="absolute"
style={{
top: posStyle.top,
left: posStyle.left,
right: posStyle.right,
x: translateX,
y: translateY,
zIndex: Math.round(depth * 10),
}}
initial={{ opacity: 0, filter: "blur(20px)", scale: 0.9 }}
animate={{ opacity: 1, filter: "blur(0px)", scale: 1 }}
transition={{
duration: 0.8,
delay: delay,
ease: [0.25, 0.1, 0.25, 1],
}}
>
<img
src={src}
alt=""
loading="lazy"
decoding="async"
className={cn(
"aspect-4/3 h-20 w-32 rounded-lg object-cover shadow-sm ring-1 ring-black/10 sm:h-40 sm:w-56 md:h-52 md:w-80 dark:ring-white/10",
imageClassName,
)}
/>
</motion.div>
);
});Models & stability
Recommended models
Keep exploring
A webpage case by @Oluwaphilemon1 using Claude Fable 5 · Three.js · Blender · GSAP, including the public result, full prompt, and original source.
Prompt
Claude Fable 5 and GPT-5.6 are powerful🥵🥵🥵 Here Is How I built with Claude 👇 Prompt: "Design an agency site where services are presented as supermarket product packaging in 3D" Use Three.js with WebGL to render al
复制这段 TSX 组件源码,交给 Cursor、v0、Claude 等 AI 编程工具,说明这是「3D Animated Pin」的 Aceternity UI 组件实现,即可让它接入你的 React 项目,再按需替换文案、配色与触发参数复用。
Prompt
// components/ui/3d-pin.tsx "use client"; import React, { useState } from "react"; import { motion } from "motion/react"; import { cn } from "@/lib/utils"; export const PinContainer = ({ children, title, href, className, containerClassName…

一个复杂的提示词,用于利用 Three.js 风格优化和逼真光照,在浏览器中生成精细的实时 3D 森林环境。
Prompt
First search for the "/unlazy" skill, read it fully, and use it throughout the entire task. Treat this as a major visual build lasting at least {argument name="minimum duration" d