import React, { useRef, useState, Suspense } from "react";
import { Canvas, useFrame } from "@react-three/fiber";
import { OrbitControls, Html, useGLTF } from "@react-three/drei";
// NOTE: This is a single-file React component ready to drop into a React + Vite/Next project.
// Tailwind CSS is used for styling (no imports here).
// Dependencies (install):
// react, react-dom, @react-three/fiber, @react-three/drei, three, tailwindcss
// Optional UI libs: shadcn/ui (used conceptually), but this file uses basic HTML + Tailwind.
// --- Mock product data ---
const PRODUCTS = [
{
id: 1,
title: "Aurora Jacket",
price: 89,
color: "#1f2937",
size: ["S", "M", "L", "XL"],
},
{
id: 2,
title: "Nimbus Hoodie",
price: 59,
color: "#111827",
size: ["S", "M", "L"],
},
{
id: 3,
title: "Breeze Tee",
price: 25,
color: "#ef4444",
size: ["S", "M", "L", "XL"],
},
];
// --- Simple rotating 3D product using primitives ---
function RotatingCloth({ color = "#888", product = {} }) {
const ref = useRef();
useFrame((state, delta) => (ref.current.rotation.y += delta * 0.6));
return (
{/* torso-like shape */}
{/* sleeves */}
{/* neckline highlight */}
);
}
// --- 3D Viewer wrapper ---
function ProductViewer({ product }) {
return (