This file provides guidance to WARP (warp.dev) when working with code in this repository.
Galvanorm Next.js - A corporate website for Galvanorm, featuring an interactive 3D catalog viewer. Built with Next.js 14 (App Router), React 18, TypeScript, and Three.js/React Three Fiber for 3D rendering.
npm run dev # Start development server on http://localhost:3000
npm run build # Build production bundle
npm run start # Start production server
npm run lint # Run ESLintnpm install # Install all dependencies (required after cloning)- Framework: Next.js 14 with App Router
- Language: TypeScript (strict mode enabled)
- 3D Graphics: Three.js via @react-three/fiber and @react-three/drei
- State Management: Jotai (atomic state management)
- Animations: GSAP, Swiper
- Styling: CSS Modules + Global CSS
App Router Layout (app/)
layout.tsx- Root layout with metadata, CSS/JS includes, Turkish localepage.tsx- Main page composing all sections- Uses Next.js Script component for legacy JS files loaded in specific order
Component Architecture (components/)
Single-page application with section-based components:
Header.tsx- Navigation headerHeroSection.tsx- Hero/landing sectionAboutSection.tsx- Company overviewServicesSection.tsx- Services offeredProjectsSection.tsx- Project showcaseStatsSection.tsx- Statistics/metricsTestimonialsSection.tsx- Customer testimonialsCatalogSection.tsx- 3D interactive catalog viewer (see below)GlobalMapSection.tsx- Geographic presenceClientsSection.tsx- Client logosFooterSection.tsx- Footer with contact infoPreloader.tsx,MobileMenu.tsx,OffcanvasMenu.tsx- UI utilities
The interactive 3D book/catalog is the core feature of this project. It allows users to view a PDF catalog as a 3D flippable book.
Key Files:
-
index.tsx- Main component with:- Lazy loading via Intersection Observer
- Dual rendering modes (embedded view + fullscreen modal)
- Keyboard shortcuts (Arrow keys for navigation, Escape to close)
- Sound effects support (optional
/audios/page-flip.mp3) - Portal-based fullscreen overlay using
createPortal
-
UI.tsx- State management and configuration:PICTURES_COUNTconstant - SET THIS to match your PDF page count- Jotai atoms:
pageAtom,zoomedAtom,fullscreenAtom - Page array generation (front/back pairs)
- Navigation controls (only shown in fullscreen mode)
-
Experience.tsx- Three.js scene setup:- Lighting configuration (directional + ambient + environment)
- OrbitControls with zoom/pan/rotate
- Float animation wrapper
- Shadow mapping (2048x2048 resolution)
-
Book.tsx- 3D book mesh implementation:- Skinned mesh with bone-based page curling animation
- Dynamic texture loading with format fallback (jpg/png/webp)
- Page interaction detection
- Emissive hover effects
- PBR materials with optional roughness maps
3D Catalog Workflow:
- PDF pages must be converted to images (JPG recommended)
- Place in
public/textures/:book-cover.jpg- Front coverbook-back.jpg- Back cover1.jpg,2.jpg,3.jpg, ... - Interior pages
- Update
PICTURES_COUNTincomponents/Book3D/UI.tsx - Optional: Add
book-cover-roughness.jpgfor realistic cover material
Texture Loading Logic:
- Attempts multiple image formats automatically (png, jpg, jpeg, webp)
- Special handling for cover/back vs interior pages
- Anisotropic filtering (16x) for high-quality rendering
- sRGB color space for accurate color reproduction
The 3D Book component uses dynamic import with ssr: false to prevent server-side rendering issues with Three.js:
const Book3D = dynamic(() => import('./Book3D').then(mod => ({ default: mod.Book3D })), {
ssr: false,
loading: () => <LoadingComponent />
});Why: Three.js and WebGL require browser APIs not available during SSR. This pattern is critical for all Three.js components.
TypeScript configured with @/* mapping to project root:
import Component from '@/components/Component'/public/textures/- 3D book page images/public/images/- General website images/public/css/- Legacy CSS files (loaded in specific order via layout.tsx)/public/js/- Legacy JavaScript files (loaded via Next.js Script component)/public/audios/- Optional sound effects
Before running the project, you MUST:
- Add PDF page images to
public/textures/ - Set
PICTURES_COUNTincomponents/Book3D/UI.tsxto match your actual page count
Default is 10 pages. If you have 20 pages, change:
const PICTURES_COUNT = 20; // Your actual page countWhen adding any Three.js/React Three Fiber components:
- Use
'use client'directive at the top of the file - Import dynamically with
ssr: falsewhen used in pages - Wrap in
<Suspense>with appropriate fallback - Consider Intersection Observer for lazy loading
The project loads many legacy JS files in a specific order (see app/layout.tsx). Do NOT reorder these scripts without testing thoroughly, as they may have dependencies on each other.
- Strict mode enabled - All code must pass strict TypeScript checks
- Path aliases: Use
@/for imports from project root - Module resolution:
bundler(for Next.js App Router compatibility)
The project uses a hybrid CSS approach:
- Legacy global CSS files (loaded in specific order)
- CSS Modules for component-specific styles
- Inline styles for dynamic 3D UI elements
Do not convert legacy CSS to CSS Modules without careful testing.
- Jotai is used for 3D book state (page number, zoom state, fullscreen mode)
- Each atom is exported from
components/Book3D/UI.tsx - Use
useAtomhook to read/write atom values
For optimal 3D catalog performance:
- Format: JPG (PNG for transparency needs)
- Resolution: 2048x2732px (4:3 aspect ratio)
- File Size: Max 500KB per image
- DPI: 150-300
- Color Profile: sRGB
- Compression: 80-90% quality
Tools: iLovePDF, TinyPNG, Squoosh.app
3D-BOOK-INTEGRATION.md- Detailed 3D catalog implementation guide with troubleshootingQUICK-START.md- Quick setup guide (Turkish)README.md- Standard Next.js boilerplate
Standard Next.js deployment:
npm run build- Creates optimized production buildnpm run start- Runs production server- Or deploy to Vercel/similar platforms
Important: Ensure public/textures/ is included in deployment and contains all required book page images.
- Modern browsers with WebGL 2.0 support required for 3D features
- Responsive design supports mobile and desktop
- Touch gestures supported for mobile 3D interaction (rotate, zoom, pan)
Components using browser APIs (window, document) should:
- Use
'use client'directive - Check
typeof window !== "undefined"before accessing window - Use
useEffectfor initialization that requires browser APIs - Use
suppressHydrationWarningon body tag (already configured)
The 3D catalog uses React portals to render fullscreen overlays outside the normal component tree. This pattern allows the book to escape any parent container constraints.
The 3D book uses Intersection Observer to delay 3D rendering until the user scrolls to the catalog section, improving initial page load performance.
Run npm install - dependencies may not be installed
- Verify files exist in
public/textures/ - Check file names match exactly (case-sensitive)
- Check file extensions are lowercase
- View browser console for 404 errors
- Check browser has WebGL support
- Verify dynamic import with
ssr: falseis used - Check console for Three.js errors
- Ensure textures are present before rendering
Update PICTURES_COUNT in components/Book3D/UI.tsx to match actual number of PDF pages
- Optimize texture file sizes (use TinyPNG/Squoosh)
- Reduce texture resolution if needed
- Use JPG instead of PNG where possible
- Check that lazy loading via Intersection Observer is working