2026-11-03 13:36:36 +05:30
|
|
|
'use client';
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
import React, { useState, useEffect, useRef } from 'react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import Link from 'next/link';
|
2026-11-04 18:22:18 +05:30
|
|
|
import * as THREE from 'three';
|
2026-11-04 12:06:23 +05:30
|
|
|
import {
|
|
|
|
|
Sparkles,
|
|
|
|
|
ArrowRight,
|
|
|
|
|
Smartphone,
|
2026-11-04 18:22:18 +05:30
|
|
|
ArrowDown,
|
2026-11-04 18:28:04 +05:30
|
|
|
ShieldCheck,
|
|
|
|
|
LockKeyhole,
|
|
|
|
|
Check,
|
|
|
|
|
Zap
|
2026-11-04 12:06:23 +05:30
|
|
|
} from 'lucide-react';
|
2026-11-04 18:22:18 +05:30
|
|
|
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
|
2026-11-04 17:55:18 +05:30
|
|
|
import { TextAnimate } from '@/components/magicui/text-animate';
|
2026-11-04 18:22:18 +05:30
|
|
|
import { Particles } from '@/components/magicui/particles';
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
interface HeroSectionProps {
|
2026-11-04 18:22:18 +05:30
|
|
|
title?: Record<string, string> | string;
|
|
|
|
|
badge?: Record<string, string> | string;
|
|
|
|
|
subtitle?: Record<string, string> | string;
|
|
|
|
|
primaryCta?: { label?: Record<string, string> | string; href?: string };
|
|
|
|
|
secondaryCta?: { label?: Record<string, string> | string; href?: string };
|
2026-11-03 12:24:43 +05:30
|
|
|
variant?: string;
|
2026-11-04 18:22:18 +05:30
|
|
|
tool?: ToolItem;
|
|
|
|
|
homeApp?: any;
|
2026-11-03 12:24:43 +05:30
|
|
|
variants?: VariantSpec[];
|
|
|
|
|
locale?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function HeroSection({
|
|
|
|
|
title,
|
|
|
|
|
badge,
|
2026-11-04 18:22:18 +05:30
|
|
|
subtitle,
|
2026-11-04 15:36:30 +05:30
|
|
|
primaryCta,
|
|
|
|
|
secondaryCta,
|
2026-11-03 12:24:43 +05:30
|
|
|
tool,
|
|
|
|
|
variants = [],
|
|
|
|
|
locale = 'en',
|
|
|
|
|
}: HeroSectionProps) {
|
2026-11-04 18:28:04 +05:30
|
|
|
const resolvedBadge = resolveLocalised(badge, locale) || 'Next-Gen Creative Vision AI';
|
|
|
|
|
const primaryCtaLabel = resolveLocalised(primaryCta?.label, locale, 'Explore the Magic');
|
2026-11-04 17:55:18 +05:30
|
|
|
const primaryCtaHref = primaryCta?.href || '#our-tools';
|
2026-11-04 18:22:18 +05:30
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
const secondaryCtaLabel = resolveLocalised(secondaryCta?.label, locale, 'Mobile App Studio');
|
2026-11-04 17:55:18 +05:30
|
|
|
const secondaryCtaHref = secondaryCta?.href || '#recommended-apps';
|
2026-11-04 15:36:30 +05:30
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
// Dedicated Tool Detail Page Hero (when viewing a specific tool page like /tools/[slug])
|
2026-11-04 18:22:18 +05:30
|
|
|
if (tool) {
|
2026-11-04 11:35:51 +05:30
|
|
|
return (
|
2026-11-04 18:22:18 +05:30
|
|
|
<section className="relative overflow-hidden bg-white border-b border-slate-900/[0.08] pt-24 sm:pt-28 pb-12 sm:pb-16 px-4 sm:px-6 lg:px-10">
|
|
|
|
|
<div className="max-w-[1640px] mx-auto">
|
|
|
|
|
<nav className="flex items-center gap-2 text-xs font-mono text-slate-500 mb-8">
|
2026-11-04 11:35:51 +05:30
|
|
|
<Link href="/" className="hover:text-blue-700 transition-colors">Home</Link>
|
|
|
|
|
<span>/</span>
|
|
|
|
|
<Link href="/tools" className="hover:text-blue-700 transition-colors">Tools</Link>
|
|
|
|
|
<span>/</span>
|
2026-11-04 17:55:18 +05:30
|
|
|
<span className="text-slate-900 font-semibold">{resolveLocalised(tool.name, locale)}</span>
|
2026-11-04 11:35:51 +05:30
|
|
|
</nav>
|
|
|
|
|
|
2026-11-04 12:28:32 +05:30
|
|
|
<div className="text-center max-w-4xl mx-auto mb-10 sm:mb-12">
|
2026-11-04 18:22:18 +05:30
|
|
|
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-mono font-semibold tracking-wider uppercase text-blue-700 bg-blue-50 border border-blue-200">
|
2026-11-04 12:00:17 +05:30
|
|
|
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
|
2026-11-04 18:22:18 +05:30
|
|
|
<span>Studio Neural Tool</span>
|
2026-11-04 11:35:51 +05:30
|
|
|
</div>
|
|
|
|
|
|
2026-11-04 12:28:32 +05:30
|
|
|
<h1 className="mt-4 text-3xl sm:text-5xl lg:text-6xl font-display font-black tracking-tight text-slate-900 leading-[1.08]">
|
2026-11-04 17:55:18 +05:30
|
|
|
<TextAnimate animation="slideLeft" by="word">{resolveLocalised(tool.name, locale)}</TextAnimate>
|
2026-11-04 12:00:17 +05:30
|
|
|
</h1>
|
|
|
|
|
|
2026-11-04 17:55:18 +05:30
|
|
|
<p className="mt-4 text-base sm:text-lg leading-relaxed text-slate-600 max-w-2xl mx-auto font-sans">
|
|
|
|
|
<TextAnimate animation="fadeIn" by="word" delay={0.15}>{resolveLocalised(tool.summary, locale)}</TextAnimate>
|
2026-11-04 12:00:17 +05:30
|
|
|
</p>
|
2026-11-04 12:28:32 +05:30
|
|
|
|
|
|
|
|
<div className="mt-6 flex flex-wrap items-center justify-center gap-2 sm:gap-3 text-xs font-medium text-slate-600">
|
2026-11-04 18:22:18 +05:30
|
|
|
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
|
|
|
|
|
<ShieldCheck className="h-3.5 w-3.5 text-emerald-600" />
|
|
|
|
|
<span>Zero Storage</span>
|
2026-11-04 12:28:32 +05:30
|
|
|
</span>
|
2026-11-04 18:22:18 +05:30
|
|
|
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
|
|
|
|
|
<LockKeyhole className="h-3.5 w-3.5 text-blue-600" />
|
|
|
|
|
<span>Client-Side Processing</span>
|
2026-11-04 12:28:32 +05:30
|
|
|
</span>
|
2026-11-04 18:22:18 +05:30
|
|
|
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
|
|
|
|
|
<Check className="h-3.5 w-3.5 text-indigo-600" />
|
|
|
|
|
<span>Lossless Quality</span>
|
2026-11-04 12:28:32 +05:30
|
|
|
</span>
|
|
|
|
|
</div>
|
2026-11-04 12:00:17 +05:30
|
|
|
</div>
|
2026-11-04 11:35:51 +05:30
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
// -------------------------------------------------------------
|
2026-11-04 18:28:04 +05:30
|
|
|
// Pure Front Page Hero View:
|
|
|
|
|
// ONLY Animated Text, 3D WebGL Prism, Particles, Radiant Colors & Effects
|
|
|
|
|
// Zero tool names, zero tool selection, zero feature lists
|
2026-11-04 18:22:18 +05:30
|
|
|
// -------------------------------------------------------------
|
2026-11-03 12:24:43 +05:30
|
|
|
return (
|
2026-11-04 18:22:18 +05:30
|
|
|
<section className="relative isolate min-h-[96vh] flex flex-col justify-center items-center text-center overflow-hidden bg-[#FAF8F5] pt-24 pb-20 px-4 sm:px-6 md:px-8 lg:px-10">
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* 1. MagicUI Ambient Floating Particles */}
|
2026-11-04 18:22:18 +05:30
|
|
|
<Particles
|
2026-11-04 18:28:04 +05:30
|
|
|
className="absolute inset-0 -z-20 opacity-50"
|
|
|
|
|
quantity={70}
|
2026-11-04 18:22:18 +05:30
|
|
|
color="#3b82f6"
|
2026-11-04 18:28:04 +05:30
|
|
|
size={0.8}
|
2026-11-04 18:22:18 +05:30
|
|
|
/>
|
|
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* 2. Interactive 3D WebGL Crystal Prism Canvas Rotating Behind the Text */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<div className="absolute inset-0 -z-10 flex items-center justify-center pointer-events-none select-none overflow-hidden">
|
2026-11-04 18:28:04 +05:30
|
|
|
<div className="w-[650px] h-[650px] sm:w-[950px] sm:h-[950px] lg:w-[1250px] lg:h-[1250px] opacity-75 transform-gpu transition-opacity duration-1000">
|
2026-11-04 17:55:18 +05:30
|
|
|
<Hero3DCanvas className="w-full h-full" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* 3. Radiant Multidimensional Chromatic Glow Mesh */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<div
|
2026-11-04 18:22:18 +05:30
|
|
|
className="absolute inset-0 -z-30 pointer-events-none"
|
2026-11-04 17:55:18 +05:30
|
|
|
style={{
|
2026-11-04 18:28:04 +05:30
|
|
|
background: 'radial-gradient(circle at 50% 38%, rgba(59,130,246,0.16) 0%, rgba(99,102,241,0.12) 30%, rgba(6,182,212,0.08) 50%, transparent 75%)',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 -z-30 pointer-events-none opacity-60"
|
|
|
|
|
style={{
|
|
|
|
|
background: 'radial-gradient(ellipse at 80% 20%, rgba(236,72,153,0.08) 0%, transparent 50%), radial-gradient(ellipse at 20% 70%, rgba(16,185,129,0.07) 0%, transparent 50%)',
|
2026-11-04 17:55:18 +05:30
|
|
|
}}
|
|
|
|
|
/>
|
2026-11-04 18:22:18 +05:30
|
|
|
<div className="absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-[#FAF8F5] to-transparent -z-10 pointer-events-none" />
|
2026-11-03 12:24:43 +05:30
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* 4. Center Hero Typography & Visual Atmosphere */}
|
2026-11-04 18:22:18 +05:30
|
|
|
<div className="relative z-10 max-w-[1640px] mx-auto flex flex-col items-center justify-center w-full">
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* Glowing Pill Badge */}
|
|
|
|
|
<div className="inline-flex items-center gap-2 rounded-full border border-blue-500/25 bg-white/90 backdrop-blur-md px-5 py-2 text-xs font-mono font-semibold tracking-wider uppercase text-blue-800 shadow-md mb-8">
|
2026-11-04 17:55:18 +05:30
|
|
|
<span className="flex h-2 w-2 relative">
|
|
|
|
|
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"></span>
|
|
|
|
|
<span className="relative inline-flex rounded-full h-2 w-2 bg-blue-600"></span>
|
|
|
|
|
</span>
|
|
|
|
|
<span>{resolvedBadge}</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* Grand Headline with Character-Level MagicUI Animation */}
|
|
|
|
|
<h1 className="text-5xl sm:text-7xl md:text-8xl lg:text-[6.5rem] font-display font-black tracking-[-0.045em] text-slate-900 leading-[1.02] max-w-5xl mx-auto text-balance">
|
2026-11-04 17:55:18 +05:30
|
|
|
<span className="block text-slate-900">
|
|
|
|
|
<TextAnimate animation="slideLeft" by="character">
|
2026-11-04 18:28:04 +05:30
|
|
|
Imagine. Transform.
|
2026-11-04 17:55:18 +05:30
|
|
|
</TextAnimate>
|
|
|
|
|
</span>
|
2026-11-04 18:28:04 +05:30
|
|
|
<span className="block mt-2 sm:mt-3 text-blue-600 font-extrabold pb-2">
|
2026-11-04 18:05:26 +05:30
|
|
|
<TextAnimate animation="slideLeft" by="character" delay={0.2}>
|
2026-11-04 18:28:04 +05:30
|
|
|
Create the Impossible.
|
2026-11-04 17:55:18 +05:30
|
|
|
</TextAnimate>
|
|
|
|
|
</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</h1>
|
|
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* Inspiring, Universal Subtitle (No features, no tool lists) */}
|
|
|
|
|
<p className="mt-8 text-lg sm:text-xl lg:text-2xl text-slate-600 max-w-3xl mx-auto font-sans leading-relaxed text-pretty">
|
2026-11-04 17:55:18 +05:30
|
|
|
<TextAnimate animation="fadeIn" by="word" delay={0.25}>
|
2026-11-04 18:28:04 +05:30
|
|
|
Turn ordinary moments into extraordinary visual art. Instant, effortless, and private photo magic right in your browser.
|
2026-11-04 17:55:18 +05:30
|
|
|
</TextAnimate>
|
2026-11-03 12:24:43 +05:30
|
|
|
</p>
|
|
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* Elegant Action Buttons */}
|
|
|
|
|
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
|
2026-11-04 17:55:18 +05:30
|
|
|
<a
|
|
|
|
|
href={primaryCtaHref}
|
2026-11-04 18:28:04 +05:30
|
|
|
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-9 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-all duration-300 hover:scale-105 hover:from-blue-600 hover:to-indigo-600 active:scale-95"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-04 17:55:18 +05:30
|
|
|
<span>{primaryCtaLabel}</span>
|
|
|
|
|
<ArrowDown className="w-4 h-4 transition-transform group-hover:translate-y-0.5" />
|
|
|
|
|
</a>
|
|
|
|
|
<a
|
|
|
|
|
href={secondaryCtaHref}
|
2026-11-04 18:28:04 +05:30
|
|
|
className="inline-flex items-center gap-2.5 rounded-full border border-slate-300/80 bg-white/90 backdrop-blur-md px-8 py-4 text-xs sm:text-sm font-semibold text-slate-800 shadow-sm transition-all duration-300 hover:scale-105 hover:border-blue-400 hover:text-blue-600 hover:bg-white active:scale-95"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-03 13:16:16 +05:30
|
|
|
<Smartphone className="w-4 h-4 text-blue-600" />
|
2026-11-04 17:55:18 +05:30
|
|
|
<span>{secondaryCtaLabel}</span>
|
|
|
|
|
</a>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
2026-11-04 17:55:18 +05:30
|
|
|
|
2026-11-04 18:28:04 +05:30
|
|
|
{/* Floating 3D Prismatic Light Halo */}
|
|
|
|
|
<div className="mt-14 relative w-full max-w-4xl h-24 flex items-center justify-center pointer-events-none">
|
|
|
|
|
<div className="w-3/4 h-8 bg-gradient-to-r from-transparent via-blue-500/20 to-transparent blur-2xl" />
|
|
|
|
|
<div className="w-1/2 h-1 bg-gradient-to-r from-transparent via-cyan-400 to-transparent shadow-[0_0_20px_rgba(6,182,212,0.8)]" />
|
2026-11-04 17:55:18 +05:30
|
|
|
</div>
|
2026-11-04 18:28:04 +05:30
|
|
|
|
|
|
|
|
{/* Gentle Scroll Cue */}
|
|
|
|
|
<a
|
|
|
|
|
href="#our-tools"
|
|
|
|
|
aria-label="Scroll to our tools"
|
|
|
|
|
className="mt-6 inline-flex flex-col items-center gap-2 text-[11px] font-mono uppercase tracking-widest text-slate-500 hover:text-blue-600 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<span>Scroll to Explore</span>
|
|
|
|
|
<span className="w-4 h-7 rounded-full border border-slate-300 flex justify-center p-1">
|
|
|
|
|
<span className="w-1 h-1.5 rounded-full bg-blue-600 animate-bounce" />
|
|
|
|
|
</span>
|
|
|
|
|
</a>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-11-04 18:22:18 +05:30
|
|
|
|
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
// Interactive 3D WebGL Crystal Prism Background Canvas
|
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
function Hero3DCanvas({ className }: { className?: string }) {
|
|
|
|
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const container = containerRef.current;
|
|
|
|
|
if (!container) return;
|
|
|
|
|
|
|
|
|
|
let width = container.clientWidth || 600;
|
|
|
|
|
let height = container.clientHeight || 600;
|
|
|
|
|
|
|
|
|
|
const scene = new THREE.Scene();
|
|
|
|
|
const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
|
|
|
|
|
camera.position.z = 4.2;
|
|
|
|
|
|
|
|
|
|
let renderer: THREE.WebGLRenderer | null = null;
|
|
|
|
|
try {
|
|
|
|
|
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
|
|
|
|
|
renderer.setSize(width, height);
|
|
|
|
|
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
|
|
|
|
container.appendChild(renderer.domElement);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Geometry: Floating Octahedron Crystal Prism
|
|
|
|
|
const geometry = new THREE.OctahedronGeometry(1.65, 0);
|
|
|
|
|
const material = new THREE.MeshPhysicalMaterial({
|
|
|
|
|
color: 0x2563eb,
|
|
|
|
|
emissive: 0x1d4ed8,
|
|
|
|
|
emissiveIntensity: 0.15,
|
|
|
|
|
roughness: 0.25,
|
|
|
|
|
metalness: 0.1,
|
|
|
|
|
transmission: 0.85,
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.75,
|
|
|
|
|
ior: 1.5,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const crystal = new THREE.Mesh(geometry, material);
|
|
|
|
|
scene.add(crystal);
|
|
|
|
|
|
|
|
|
|
// Wireframe Cage
|
|
|
|
|
const wireGeo = new THREE.WireframeGeometry(geometry);
|
|
|
|
|
const wireMat = new THREE.LineBasicMaterial({
|
|
|
|
|
color: 0x93c5fd,
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.35,
|
|
|
|
|
});
|
|
|
|
|
const wireframe = new THREE.LineSegments(wireGeo, wireMat);
|
|
|
|
|
crystal.add(wireframe);
|
|
|
|
|
|
|
|
|
|
// Subtle Particle Constellation
|
2026-11-04 18:28:04 +05:30
|
|
|
const particleCount = 45;
|
2026-11-04 18:22:18 +05:30
|
|
|
const particleGeo = new THREE.BufferGeometry();
|
|
|
|
|
const posArray = new Float32Array(particleCount * 3);
|
|
|
|
|
for (let i = 0; i < particleCount * 3; i++) {
|
|
|
|
|
posArray[i] = (Math.random() - 0.5) * 6;
|
|
|
|
|
}
|
|
|
|
|
particleGeo.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
|
|
|
|
|
const particleMat = new THREE.PointsMaterial({
|
|
|
|
|
size: 0.04,
|
|
|
|
|
color: 0x60a5fa,
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.5,
|
|
|
|
|
});
|
|
|
|
|
const particles = new THREE.Points(particleGeo, particleMat);
|
|
|
|
|
scene.add(particles);
|
|
|
|
|
|
|
|
|
|
// Studio Lights
|
|
|
|
|
const ambientLight = new THREE.AmbientLight(0xffffff, 0.85);
|
|
|
|
|
scene.add(ambientLight);
|
|
|
|
|
|
|
|
|
|
const pointLight = new THREE.PointLight(0x06b6d4, 3, 10);
|
|
|
|
|
pointLight.position.set(3, 3, 3);
|
|
|
|
|
scene.add(pointLight);
|
|
|
|
|
|
|
|
|
|
const pointLight2 = new THREE.PointLight(0x4f46e5, 2.5, 10);
|
|
|
|
|
pointLight2.position.set(-3, -2, 2);
|
|
|
|
|
scene.add(pointLight2);
|
|
|
|
|
|
|
|
|
|
let animId = 0;
|
|
|
|
|
let clock = new THREE.Clock();
|
|
|
|
|
|
|
|
|
|
const animate = () => {
|
|
|
|
|
animId = requestAnimationFrame(animate);
|
|
|
|
|
const elapsed = clock.getElapsedTime();
|
|
|
|
|
|
|
|
|
|
crystal.rotation.x = elapsed * 0.18;
|
|
|
|
|
crystal.rotation.y = elapsed * 0.25;
|
|
|
|
|
|
|
|
|
|
particles.rotation.y = elapsed * 0.05;
|
|
|
|
|
particles.rotation.x = elapsed * 0.03;
|
|
|
|
|
|
|
|
|
|
if (renderer) renderer.render(scene, camera);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
animate();
|
|
|
|
|
|
|
|
|
|
const handleResize = () => {
|
|
|
|
|
if (!container || !renderer) return;
|
|
|
|
|
const w = container.clientWidth;
|
|
|
|
|
const h = container.clientHeight;
|
|
|
|
|
camera.aspect = w / h;
|
|
|
|
|
camera.updateProjectionMatrix();
|
|
|
|
|
renderer.setSize(w, h);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
cancelAnimationFrame(animId);
|
|
|
|
|
window.removeEventListener('resize', handleResize);
|
|
|
|
|
if (renderer && renderer.domElement && container.contains(renderer.domElement)) {
|
|
|
|
|
container.removeChild(renderer.domElement);
|
|
|
|
|
}
|
|
|
|
|
geometry.dispose();
|
|
|
|
|
material.dispose();
|
|
|
|
|
renderer?.dispose();
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return <div ref={containerRef} className={className} />;
|
|
|
|
|
}
|