Update src/app/gym-3d/page.tsx

This commit is contained in:
2026-03-04 18:55:29 +00:00
parent 7e3f6595c7
commit d16d1f0b26

View File

@@ -1,181 +1,254 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef, useState } from 'react';
import * as THREE from 'three';
import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import { Mail, Send } from 'lucide-react';
import * as THREE from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import { ChevronDown, Mail, Phone, MapPin } from 'lucide-react';
export default function Gym3D() {
const canvasRef = useRef<HTMLCanvasElement>(null);
const [formData, setFormData] = useState({ name: "", email: "", message: "" });
interface FormData {
name: string;
email: string;
phone: string;
message: string;
}
export default function Gym3DPage() {
const mountRef = useRef<HTMLDivElement>(null);
const sceneRef = useRef<THREE.Scene | null>(null);
const rendererRef = useRef<THREE.WebGLRenderer | null>(null);
const [formData, setFormData] = useState<FormData>({
name: '',
email: '',
phone: '',
message: ''
});
const [submitted, setSubmitted] = useState(false);
useEffect(() => {
const loadThree = async () => {
if (!canvasRef.current) return;
if (!mountRef.current) return;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a0a0a);
scene.fog = new THREE.Fog(0x0a0a0a, 50, 200);
// Scene setup
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a0a0a);
sceneRef.current = scene;
const camera = new THREE.PerspectiveCamera(
75,
canvasRef.current.clientWidth / canvasRef.current.clientHeight,
0.1,
1000
// Camera
const camera = new THREE.PerspectiveCamera(
75,
mountRef.current.clientWidth / mountRef.current.clientHeight,
0.1,
1000
);
camera.position.set(0, 5, 15);
camera.lookAt(0, 5, 0);
// Renderer
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(mountRef.current.clientWidth, mountRef.current.clientHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowShadowMap;
mountRef.current.appendChild(renderer.domElement);
rendererRef.current = renderer;
// Lighting
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(10, 20, 10);
directionalLight.castShadow = true;
directionalLight.shadow.mapSize.width = 2048;
directionalLight.shadow.mapSize.height = 2048;
scene.add(directionalLight);
const pointLight = new THREE.PointLight(0xffff00, 0.5);
pointLight.position.set(0, 10, 0);
scene.add(pointLight);
// Floor
const floorGeometry = new THREE.PlaneGeometry(50, 50);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x1a1a1a,
roughness: 0.8,
metalness: 0.1
});
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = true;
floor.receiveShadow = true;
scene.add(floor);
// Walls
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0x2a2a2a,
roughness: 0.7,
metalness: 0.05
});
// Back wall
const backWallGeometry = new THREE.BoxGeometry(50, 15, 1);
const backWall = new THREE.Mesh(backWallGeometry, wallMaterial);
backWall.position.set(0, 7.5, -25);
backWall.castShadow = true;
backWall.receiveShadow = true;
scene.add(backWall);
// Side walls
const sideWallGeometry = new THREE.BoxGeometry(1, 15, 50);
const leftWall = new THREE.Mesh(sideWallGeometry, wallMaterial);
leftWall.position.set(-25, 7.5, 0);
leftWall.castShadow = true;
leftWall.receiveShadow = true;
scene.add(leftWall);
const rightWall = new THREE.Mesh(sideWallGeometry, wallMaterial);
rightWall.position.set(25, 7.5, 0);
rightWall.castShadow = true;
rightWall.receiveShadow = true;
scene.add(rightWall);
// Equipment - Barbells/Rack
const rackGeometry = new THREE.BoxGeometry(8, 2, 0.5);
const rackMaterial = new THREE.MeshStandardMaterial({
color: 0x333333,
roughness: 0.3,
metalness: 0.8
});
const rack = new THREE.Mesh(rackGeometry, rackMaterial);
rack.position.set(-10, 1, 0);
rack.castShadow = true;
rack.receiveShadow = true;
scene.add(rack);
// Dumbbells
for (let i = 0; i < 5; i++) {
const dumbbell = new THREE.Mesh(
new THREE.CylinderGeometry(0.3, 0.3, 0.8, 16),
new THREE.MeshStandardMaterial({
color: 0xff6600,
roughness: 0.2,
metalness: 0.9
})
);
camera.position.set(20, 15, 20);
dumbbell.position.set(-15 + i * 2, 0.5, -5);
dumbbell.castShadow = true;
dumbbell.receiveShadow = true;
scene.add(dumbbell);
}
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(canvasRef.current.clientWidth, canvasRef.current.clientHeight);
renderer.shadowMap.enabled = true;
canvasRef.current.appendChild(renderer.domElement);
// Rings (suspension trainer)
const ringGeometry = new THREE.TorusGeometry(0.3, 0.05, 16, 16);
const ringMaterial = new THREE.MeshStandardMaterial({
color: 0xffff00,
roughness: 0.3,
metalness: 0.8
});
for (let i = 0; i < 2; i++) {
const ring = new THREE.Mesh(ringGeometry, ringMaterial);
ring.position.set(-5 + i * 10, 8, -10);
ring.castShadow = true;
ring.receiveShadow = true;
scene.add(ring);
}
// Lighting
const ambientLight = new THREE.AmbientLight(0xffff00, 0.6);
scene.add(ambientLight);
// Climbing wall
const climbingWallGeometry = new THREE.BoxGeometry(8, 10, 0.3);
const climbingWallMaterial = new THREE.MeshStandardMaterial({
color: 0x444444,
roughness: 0.8,
metalness: 0.1
});
const climbingWall = new THREE.Mesh(climbingWallGeometry, climbingWallMaterial);
climbingWall.position.set(10, 5, -22);
climbingWall.castShadow = true;
climbingWall.receiveShadow = true;
scene.add(climbingWall);
const directionalLight = new THREE.DirectionalLight(0xffff00, 0.8);
directionalLight.position.set(30, 30, 20);
directionalLight.castShadow = true;
directionalLight.shadow.mapSize.width = 2048;
directionalLight.shadow.mapSize.height = 2048;
scene.add(directionalLight);
// Floor
const floorGeometry = new THREE.PlaneGeometry(50, 50);
const floorMaterial = new THREE.MeshStandardMaterial({ color: 0x1a1a1a });
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
// Gym Equipment - Barbells
const barlbellGeometry = new THREE.CylinderGeometry(0.2, 0.2, 2, 16);
const barMaterial = new THREE.MeshStandardMaterial({ color: 0xffff00, metalness: 0.8, roughness: 0.2 });
const barbell1 = new THREE.Mesh(barlbellGeometry, barMaterial);
barbell1.position.set(-10, 1, 0);
barbell1.rotation.z = Math.PI / 2;
barbell1.castShadow = true;
scene.add(barbell1);
const barbell2 = new THREE.Mesh(barlbellGeometry, barMaterial);
barbell2.position.set(-5, 1, 0);
barbell2.rotation.z = Math.PI / 2;
barbell2.castShadow = true;
scene.add(barbell2);
const barbell3 = new THREE.Mesh(barlbellGeometry, barMaterial);
barbell3.position.set(0, 1, 0);
barbell3.rotation.z = Math.PI / 2;
barbell3.castShadow = true;
scene.add(barbell3);
// Dumbbells
const dumbellBallGeometry = new THREE.SphereGeometry(0.3, 16, 16);
const dumbellMaterial = new THREE.MeshStandardMaterial({ color: 0x1a1a1a, metalness: 0.6 });
for (let i = 0; i < 6; i++) {
const dumbbell1 = new THREE.Mesh(dumbellBallGeometry, dumbellMaterial);
dumbbell1.position.set(-15 + i * 3, 0.5, -5);
dumbbell1.castShadow = true;
scene.add(dumbbell1);
const dumbbell2 = new THREE.Mesh(dumbellBallGeometry, dumbellMaterial);
dumbbell2.position.set(-15 + i * 3, 0.5, 5);
dumbbell2.castShadow = true;
scene.add(dumbbell2);
}
// Pull-up Bar / Rig
const rigFrameGeometry = new THREE.BoxGeometry(15, 0.3, 0.3);
const rigMaterial = new THREE.MeshStandardMaterial({ color: 0xffff00, metalness: 0.7 });
const rigBar = new THREE.Mesh(rigFrameGeometry, rigMaterial);
rigBar.position.set(0, 10, -8);
rigBar.castShadow = true;
scene.add(rigBar);
// Supports for rig
const supportGeometry = new THREE.CylinderGeometry(0.2, 0.2, 10, 16);
const support1 = new THREE.Mesh(supportGeometry, rigMaterial);
support1.position.set(-7, 5, -8);
support1.castShadow = true;
scene.add(support1);
const support2 = new THREE.Mesh(supportGeometry, rigMaterial);
support2.position.set(7, 5, -8);
support2.castShadow = true;
scene.add(support2);
// Rowing Machine
const rowingBaseGeometry = new THREE.BoxGeometry(2, 0.5, 1);
const rowingMaterial = new THREE.MeshStandardMaterial({ color: 0x333333 });
const rowingBase = new THREE.Mesh(rowingBaseGeometry, rowingMaterial);
rowingBase.position.set(10, 0.25, 0);
rowingBase.castShadow = true;
scene.add(rowingBase);
const rowingSeatGeometry = new THREE.BoxGeometry(0.5, 1, 0.8);
const rowingSeat = new THREE.Mesh(rowingSeatGeometry, rowingMaterial);
rowingSeat.position.set(10, 1.3, 0);
rowingSeat.castShadow = true;
scene.add(rowingSeat);
// Gym Walls
const wallGeometry = new THREE.BoxGeometry(50, 15, 0.5);
const wallMaterial = new THREE.MeshStandardMaterial({ color: 0x2a2a2a });
const backWall = new THREE.Mesh(wallGeometry, wallMaterial);
backWall.position.set(0, 7.5, -25);
scene.add(backWall);
const sideWall = new THREE.Mesh(
new THREE.BoxGeometry(0.5, 15, 50),
wallMaterial
// Hold indicators on climbing wall
for (let i = 0; i < 6; i++) {
const hold = new THREE.Mesh(
new THREE.SphereGeometry(0.3, 16, 16),
new THREE.MeshStandardMaterial({
color: 0xff3333,
roughness: 0.4,
metalness: 0.6
})
);
sideWall.position.set(-25, 7.5, 0);
scene.add(sideWall);
hold.position.set(
10 - 2 + (i % 3) * 2,
5 + Math.floor(i / 3) * 3,
-21.5
);
hold.castShadow = true;
hold.receiveShadow = true;
scene.add(hold);
}
// Controls
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.autoRotate = true;
controls.autoRotateSpeed = 2;
// Treadmill/Cardio station
const treadmillGeometry = new THREE.BoxGeometry(1.5, 1, 2);
const treadmillMaterial = new THREE.MeshStandardMaterial({
color: 0x1a1a1a,
roughness: 0.6,
metalness: 0.4
});
const treadmill = new THREE.Mesh(treadmillGeometry, treadmillMaterial);
treadmill.position.set(15, 0.5, 0);
treadmill.castShadow = true;
treadmill.receiveShadow = true;
scene.add(treadmill);
const animate = () => {
requestAnimationFrame(animate);
controls.update();
renderer.render(scene, camera);
};
animate();
// Animation
let animationId: number;
const animate = () => {
animationId = requestAnimationFrame(animate);
// Handle resize
const handleResize = () => {
if (!canvasRef.current) return;
const width = canvasRef.current.clientWidth;
const height = canvasRef.current.clientHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
};
window.addEventListener("resize", handleResize);
// Rotate the camera around the scene
const angle = Date.now() * 0.0001;
camera.position.x = Math.sin(angle) * 20;
camera.position.z = Math.cos(angle) * 20;
camera.lookAt(0, 5, 0);
return () => {
window.removeEventListener("resize", handleResize);
canvasRef.current?.removeChild(renderer.domElement);
};
renderer.render(scene, camera);
};
animate();
// Handle resize
const handleResize = () => {
if (!mountRef.current) return;
const width = mountRef.current.clientWidth;
const height = mountRef.current.clientHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
};
loadThree();
window.addEventListener('resize', handleResize);
return () => {
window.removeEventListener('resize', handleResize);
cancelAnimationFrame(animationId);
mountRef.current?.removeChild(renderer.domElement);
};
}, []);
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = e.target;
setFormData(prev => ({
...prev,
[name]: value
}));
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
// Handle form submission
console.log('Form submitted:', formData);
setSubmitted(true);
setFormData({ name: "", email: "", message: "" });
setTimeout(() => setSubmitted(false), 3000);
setTimeout(() => {
setSubmitted(false);
setFormData({ name: '', email: '', phone: '', message: '' });
}, 3000);
};
return (
@@ -195,112 +268,117 @@ export default function Gym3D() {
<NavbarLayoutFloatingOverlay
brandName="Iron Pulse"
navItems={[
{ name: "Home", id: "/" },
{ name: "WOD", id: "wod" },
{ name: "Pricing", id: "pricing" },
{ name: "Gallery", id: "gallery" },
{ name: "Testimonials", id: "testimonials" }
{ name: "Testimonials", id: "testimonials" },
{ name: "Home", id: "/" }
]}
button={{ text: "Start Your Trial", href: "contact" }}
/>
</div>
<div className="min-h-screen bg-black py-12 px-4">
<div className="max-w-7xl mx-auto">
<div className="text-center mb-12">
<h1 className="text-5xl md:text-6xl font-bold text-yellow-400 mb-4">Tour Our 3D Gym</h1>
<p className="text-xl text-gray-300">Explore Iron Pulse's state-of-the-art facility from every angle</p>
</div>
<div className="min-h-screen bg-black pt-32">
{/* 3D Gym Visualization */}
<div
ref={mountRef}
className="w-full h-96 md:h-screen mb-12 rounded-lg overflow-hidden border border-yellow-400/20"
style={{
background: 'linear-gradient(to bottom, #0a0a0a, #1a1a1a)'
}}
/>
<div className="bg-gradient-to-br from-gray-900 to-black rounded-xl overflow-hidden shadow-2xl mb-12">
<canvas
ref={canvasRef}
className="w-full"
style={{ height: "600px" }}
aria-label="3D Gym Tour"
/>
</div>
{/* Contact Form */}
<div className="max-w-2xl mx-auto px-6 py-12 mb-12">
<div className="bg-gray-900/50 backdrop-blur-sm border border-yellow-400/20 rounded-lg p-8 md:p-12">
<h2 className="text-4xl md:text-5xl font-bold text-white mb-4">Contact Us</h2>
<p className="text-gray-300 mb-8 text-lg">Interested in our 3D gym experience or want to learn more? Get in touch!</p>
<div className="grid md:grid-cols-2 gap-8 items-start">
<div className="bg-gradient-to-br from-yellow-400/10 to-yellow-400/5 border border-yellow-400/30 rounded-xl p-8">
<h2 className="text-3xl font-bold text-yellow-400 mb-6">Gym Features</h2>
<ul className="space-y-4 text-gray-300">
<li className="flex items-start gap-3">
<span className="text-yellow-400 font-bold">✓</span>
<span>Olympic Barbells & Competition Platforms</span>
</li>
<li className="flex items-start gap-3">
<span className="text-yellow-400 font-bold">✓</span>
<span>Complete Gymnastics Rig with Rings & Pull-up Bars</span>
</li>
<li className="flex items-start gap-3">
<span className="text-yellow-400 font-bold">✓</span>
<span>Full Set of Competition Dumbbells (5 lbs to 150 lbs)</span>
</li>
<li className="flex items-start gap-3">
<span className="text-yellow-400 font-bold">✓</span>
<span>Cardio Equipment: Rowing Machines & Bikes</span>
</li>
<li className="flex items-start gap-3">
<span className="text-yellow-400 font-bold">✓</span>
<span>Strength Training: Power Racks & Benches</span>
</li>
<li className="flex items-start gap-3">
<span className="text-yellow-400 font-bold">✓</span>
<span>Climate Controlled & Fully Equipped Locker Rooms</span>
</li>
</ul>
</div>
{submitted ? (
<div className="bg-green-900/30 border border-green-400 rounded-lg p-6 text-green-300 text-center">
<p className="text-xl font-semibold"> Thank you for reaching out!</p>
<p>We'll get back to you soon.</p>
</div>
) : (
<form onSubmit={handleSubmit} className="space-y-6">
<div className="grid md:grid-cols-2 gap-6">
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">Name</label>
<input
type="text"
name="name"
value={formData.name}
onChange={handleInputChange}
required
className="w-full bg-gray-800 border border-yellow-400/20 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-yellow-400 transition"
placeholder="Your name"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">Email</label>
<input
type="email"
name="email"
value={formData.email}
onChange={handleInputChange}
required
className="w-full bg-gray-800 border border-yellow-400/20 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-yellow-400 transition"
placeholder="your@email.com"
/>
</div>
</div>
<div className="bg-gradient-to-br from-yellow-400/10 to-yellow-400/5 border border-yellow-400/30 rounded-xl p-8">
<h2 className="text-3xl font-bold text-yellow-400 mb-6 flex items-center gap-2">
<Mail className="w-8 h-8" />
Contact Us
</h2>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">Name</label>
<label className="block text-sm font-medium text-gray-300 mb-2">Phone</label>
<input
type="text"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
className="w-full bg-black/50 border border-yellow-400/30 rounded px-4 py-2 text-white placeholder-gray-500 focus:outline-none focus:border-yellow-400 transition"
placeholder="Your name"
required
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">Email</label>
<input
type="email"
value={formData.email}
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
className="w-full bg-black/50 border border-yellow-400/30 rounded px-4 py-2 text-white placeholder-gray-500 focus:outline-none focus:border-yellow-400 transition"
placeholder="your@email.com"
required
type="tel"
name="phone"
value={formData.phone}
onChange={handleInputChange}
className="w-full bg-gray-800 border border-yellow-400/20 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-yellow-400 transition"
placeholder="+1 (555) 000-0000"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">Message</label>
<textarea
name="message"
value={formData.message}
onChange={(e) => setFormData({ ...formData, message: e.target.value })}
className="w-full bg-black/50 border border-yellow-400/30 rounded px-4 py-2 text-white placeholder-gray-500 focus:outline-none focus:border-yellow-400 transition resize-none h-24"
placeholder="Tell us how we can help you..."
onChange={handleInputChange}
required
rows={5}
className="w-full bg-gray-800 border border-yellow-400/20 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-yellow-400 transition resize-none"
placeholder="Tell us about your interest..."
/>
</div>
<button
type="submit"
className="w-full bg-yellow-400 hover:bg-yellow-500 text-black font-bold py-3 px-4 rounded transition flex items-center justify-center gap-2"
className="w-full bg-yellow-400 hover:bg-yellow-500 text-black font-bold py-3 rounded-lg transition transform hover:scale-105 active:scale-95"
>
<Send className="w-5 h-5" />
Send Message
</button>
{submitted && (
<p className="text-center text-green-400 font-semibold">Message sent successfully! We'll be in touch soon.</p>
)}
</form>
)}
</div>
{/* Contact Info */}
<div className="grid md:grid-cols-3 gap-6 mt-12">
<div className="text-center">
<Phone className="w-8 h-8 text-yellow-400 mx-auto mb-3" />
<p className="text-gray-300 font-semibold mb-1">Phone</p>
<p className="text-gray-400">+1 (555) 123-4567</p>
</div>
<div className="text-center">
<Mail className="w-8 h-8 text-yellow-400 mx-auto mb-3" />
<p className="text-gray-300 font-semibold mb-1">Email</p>
<p className="text-gray-400">contact@ironpulse.com</p>
</div>
<div className="text-center">
<MapPin className="w-8 h-8 text-yellow-400 mx-auto mb-3" />
<p className="text-gray-300 font-semibold mb-1">Location</p>
<p className="text-gray-400">123 Power Ave, Fitness City</p>
</div>
</div>
</div>