ProductShowcase
threecn/product-showcaseFreeComponent
A product on a circular pedestal with soft contact shadows, studio lighting and slow auto-rotate.
Install it
npx shadcn@latest add https://threecn.dev/r/product-showcase.jsonSource
1"use client"23import * as React from "react"4import { useFrame } from "@react-three/fiber"5import { ContactShadows, Float, OrbitControls } from "@react-three/drei"6import * as THREE from "three"78import { SceneContainer } from "@/components/threecn/scene-container"9import {10 useShadcnTheme,11 type ThemeMode,12} from "@/components/hooks/use-shadcn-theme"1314type ShowcaseProps = {15 color?: string16 metalness: number17 roughness: number18 theme: ThemeMode19}2021function Showcase({ color, metalness, roughness, theme }: ShowcaseProps) {22 const groupRef = React.useRef<THREE.Group>(null)23 const { primaryColor, accentColor, mutedColor, foregroundColor } =24 useShadcnTheme(theme)2526 const productColor = React.useMemo(27 () => (color ? new THREE.Color(color) : primaryColor),28 [color, primaryColor]29 )3031 useFrame((_, delta) => {32 if (groupRef.current) groupRef.current.rotation.y += delta * 0.2533 })3435 return (36 <group position={[0, -0.6, 0]}>37 {/* circular pedestal */}38 <mesh position={[0, -0.15, 0]} receiveShadow>39 <cylinderGeometry args={[1.7, 1.85, 0.3, 64]} />40 <meshStandardMaterial color={accentColor} metalness={0.4} roughness={0.6} />41 </mesh>42 <mesh position={[0, 0.01, 0]} receiveShadow>43 <cylinderGeometry args={[1.55, 1.55, 0.04, 64]} />44 <meshStandardMaterial color={mutedColor} metalness={0.2} roughness={0.8} />45 </mesh>4647 {/* the "product": a small composed object */}48 <Float speed={2} rotationIntensity={0.2} floatIntensity={0.4}>49 <group ref={groupRef} position={[0, 1.05, 0]}>50 <mesh castShadow>51 <torusKnotGeometry args={[0.55, 0.19, 160, 24]} />52 <meshStandardMaterial53 color={productColor}54 emissive={productColor}55 emissiveIntensity={0.22}56 metalness={metalness}57 roughness={roughness}58 />59 </mesh>60 <mesh castShadow position={[0, 0, 0]}>61 <icosahedronGeometry args={[0.34, 0]} />62 <meshStandardMaterial63 color={foregroundColor}64 metalness={0.9}65 roughness={0.1}66 />67 </mesh>68 </group>69 </Float>7071 <ContactShadows72 position={[0, -0.28, 0]}73 opacity={0.45}74 scale={7}75 blur={2.6}76 far={4}77 resolution={512}78 color="#000000"79 />80 </group>81 )82}8384export type ProductShowcaseProps = {85// … truncated
What it pulls in
npm packages
Files it writes
More from threecn
All 28 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AuroraRibbonsaurora-ribbons | threecn | Components | Free | 3 deps · 3 files | |
| Boidsboids | threecn | Components | Free | 3 deps · 3 files | |
| Clothcloth | threecn | Components | Free | 3 deps · 3 files | |
| Crystalcrystal | threecn | Components | Free | 3 deps · 3 files | |
| CubeWavecube-wave | threecn | Components | Free | 3 deps · 3 files | |
| CurlFlowcurl-flow | threecn | Components | Free | 3 deps · 3 files | |
| DnaHelixdna-helix | threecn | Components | Free | 3 deps · 3 files | |
| FloatingCard3Dfloating-card-3d | threecn | Components | Free | 3 deps · 3 files |
