An interactive 3D educational platform for exploring biological entities, chemical molecules, and physical structures. Built with Next.js, Three.js, and React Three Fiber.
- Real-time 3D Rendering: Explore scientific models with full rotation, zoom, and pan controls
- Optimized Model Loading: Intelligent caching and preloading system for instant access
- DRACO Compression: Supports compressed GLB models for faster loading
- Responsive Design: Adapts seamlessly from desktop to mobile devices
- Rich Metadata: Each entity includes detailed descriptions, fun facts, and teaching focus points
- Key Structures: Highlight important anatomical or molecular features with test point markers
- Microscope Visibility: Information about visibility under light and electron microscopes
- Size Ranges: Interactive sliders showing realistic scale with units
- Extensible Data Model: Generic entity system supports biology, chemistry, physics, and more
- Project-based Organization: Group related models into educational projects
- Categorization System: Main categories and sub-categories for easy navigation
- Attribute System: Flexible key-value attributes for domain-specific data
- Resizable Panels: Desktop layout with adjustable sidebar, viewer, and info panel
- Mobile-First Design: Touch-optimized controls with slide-out drawers
- Academic Theme: Clean, modern laboratory-inspired design system
- Accessibility: Proper ARIA labels and keyboard navigation support
Core Framework:
- Next.js 16 - React framework with App Router and static export
- React 19 - Latest React with concurrent features
- TypeScript - Full type safety across the codebase
3D Rendering:
- Three.js - Core 3D graphics library
- React Three Fiber - React renderer for Three.js
- Drei - Useful helpers for React Three Fiber (Environment, OrbitControls, etc.)
- DRACO - 3D model compression for optimized loading
Styling & UI:
- Tailwind CSS v4 - Utility-first CSS framework
- Radix UI - Accessible component primitives
- Lucide React - Modern icon library
- CSS Variables - Theme system with custom properties
Development Tools:
- Sharp - Image processing for WebP conversion
- glTF Transform - 3D model optimization
- ESLint - Code quality and consistency
ai-3d-learning/
βββ app/ # Next.js App Router
β βββ page.tsx # Homepage with project overview
β βββ layout.tsx # Root layout with metadata
β βββ globals.css # Global styles and CSS variables
β βββ project/[slug]/ # Dynamic route for each project
β βββ page.tsx # Server component with static params
β βββ ProjectClient.tsx # Client component with interactive UI
βββ components/ # React components
β βββ EntityViewer.tsx # 3D canvas viewer with controls
β βββ EntityInfoPanel.tsx # Entity details and attributes
β βββ EntitySidebar.tsx # Model selection sidebar
β βββ ModelScene.tsx # Three.js scene wrapper
β βββ Layout.tsx # Header and Footer
β βββ ui/ # Reusable UI primitives
βββ data/ # Content and data models
β βββ types.ts # TypeScript interfaces
β βββ index.ts # Data utilities and exports
β βββ projects/ # Project-specific data
β βββ bio.ts # Biology project entities
βββ hooks/ # Custom React hooks
β βββ useModel.ts # Model loading state management
βββ lib/ # Core utilities
β βββ modelLoader.ts # Advanced model loading system
β βββ utils.ts # Helper functions
βββ public/ # Static assets
β βββ models/ # 3D GLB model files
β βββ images/ # Entity preview images (WebP)
β βββ draco/ # DRACO decoder files
βββ scripts/ # Build and optimization scripts
βββ optimize-glb.ts # GLB model optimization
βββ convert-images-to-webp.ts # Image conversion to WebP
βββ update-model-sizes.ts # Sync model file sizes
The platform uses a generic entity-based data model that can represent any 3D educational content:
interface Entity3D {
id: string; // Unique identifier
name: string; // Display name
mainCategory: string; // Primary classification
subCategory: string; // Secondary classification
description: string; // Detailed description
funFact: string; // Engaging trivia
teachingFocus: string; // Educational objectives
attributes: Attribute[]; // Flexible key-value data
features: Feature[]; // Key structures/test points
model3D: Model3DMetadata; // 3D model configuration
}This design allows:
- Extensibility: Add new disciplines without code changes
- Consistency: Uniform data structure across all entities
- Rich Metadata: Support for domain-specific attributes
The custom model loader implements an optimized loading strategy:
1. Request Initiation
β
2. Check Cache (in-memory Map)
β (cache miss)
3. Download with Progress Tracking
β
4. Parse GLB with DRACO Decoder
β
5. Store in Cache
β
6. Resolve Promise to Component
Key Features:
- State-driven: Tracks phases (idle β downloading β parsing β completed)
- Promise-based: Components await model readiness
- Intelligent Caching: Prevents redundant downloads
- Preloading: Anticipates next model user might view
EntityViewer (React Component)
βββ Canvas (React Three Fiber)
βββ Lighting Setup
β βββ Ambient Light
β βββ Directional Lights (with shadows)
βββ Environment (Studio preset)
βββ ModelScene (GLTF content)
βββ ContactShadows (Ground reflection)
βββ OrbitControls (User interaction)
Optimization Strategies:
- Adaptive DPR:
[1, 2]for retina displays - Shadow Maps: 1024x1024 for balance of quality/performance
- Environment Maps: Studio lighting for realistic materials
- Lazy Loading: Suspense boundaries for async content
Desktop (>640px):
βββββββββββββββββββββββββββββββββββββββββββ
β Header β
ββββββββββββ¬βββββββββββββββ¬ββββββββββββββββ€
β Sidebar β 3D Viewer β Info Panel β
β (20%) β (55%) β (25%) β
βResizable β Resizable β Resizable β
ββββββββββββ΄βββββββββββββββ΄ββββββββββββββββ€
β Footer β
βββββββββββββββββββββββββββββββββββββββββββ
Mobile (<640px):
ββββββββββββββββββββββββ
β Header β
ββββββββββββββββββββββββ€
β [Menu] [Info] β β Control buttons
ββββββββββββββββββββββββ€
β β
β 3D Viewer (Full) β
β β
ββββββββββββββββββββββββ€
β Footer β
ββββββββββββββββββββββββ
β Swipe/Tap
ββββββββββββββββ
β Sidebar β β Slide-out drawer
β (Overlay) β
ββββββββββββββββ
The platform uses Next.js static export for GitHub Pages deployment:
// Generate all project routes at build time
export function generateStaticParams() {
return projects.map((project) => ({
slug: project.slug,
}));
}Benefits:
- Zero Server Required: Pure static HTML/CSS/JS
- Fast Loading: Pre-rendered pages
- CDN Ready: Deploy anywhere (GitHub Pages, Vercel, Netlify)
- SEO Friendly: Server-rendered metadata
- Node.js 20+
- pnpm 10+ (or npm/yarn)
# Clone the repository
git clone <repository-url>
cd ai-3d-learning
# Install dependencies
pnpm install
# Start development server
pnpm devThe application will be available at http://localhost:3000
# Build static site
pnpm build
# Preview production build
pnpm startStatic files are generated in the out/ directory.
# Optimize all GLB models
pnpm optimize:glb ./public/models
# Optimize with custom output directory
pnpm optimize:glb ./public/models ./public/models-optimizedUses glTF Transform to:
- Compress textures to WebP
- Apply DRACO mesh compression
- Reduce file sizes by 50-80%
# Convert images to WebP
pnpm convert:webp ./public/imagesConverts PNG/JPG to optimized WebP format with:
- Max width: 400px
- Quality: 80%
- Maintains aspect ratio
# Sync file sizes in data models
pnpm update:model-sizesAutomatically updates fileSize fields in model definitions based on actual GLB file sizes.
Add new entities in data/projects/<project>.ts:
{
id: "my-entity",
name: "My Entity",
subtitle: "Description",
mainCategory: "Category",
subCategory: "Subcategory",
accent: "#hexcolor",
description: "Detailed explanation...",
funFact: "Interesting fact!",
teachingFocus: "Learning objective...",
attributes: [
{ name: "Size Range", value: "10-100", unit: "ΞΌm" },
// ... more attributes
],
features: [
{ name: "Feature 1", detail: "Description", isHighFreqTestPoint: true },
// ... more features
],
whereItOccurs: {
text: "Where to find it...",
habitat: "Habitat info..."
},
model3D: {
modelUrl: asset("models/my-entity.glb"),
imageUrl: asset("images/my-entity.webp"),
fileSize: 1234567,
defaultRotationY: -Math.PI / 4,
displayScale: 1.4,
}
}Place your GLB file in public/models/:
cp my-entity.glb public/models/Optimization recommended:
pnpm optimize:glb ./public/modelsPlace WebP image in public/images/:
cp my-entity.webp public/images/Or convert from PNG/JPG:
pnpm convert:webp ./public/imagespnpm update:model-sizespnpm devNavigate to http://localhost:3000/project/<project-slug> to see your new entity.
The project includes a complete GitHub Actions workflow:
# .github/workflows/deploy.yml
# Automatically deploys on push to main branchSetup:
- Push to
mainbranch - GitHub Actions builds and deploys
- Site available at
https://<username>.github.io/<repo>
Since it's a static site, you can deploy to:
- Vercel:
vercel --prod - Netlify: Drag & drop
out/folder - AWS S3: Upload
out/to S3 bucket - Any CDN: Serve static files
- Visual Demonstrations: Show complex 3D structures in class
- Self-Study Resource: Students can explore at their own pace
- Test Preparation: High-frequency test points highlighted
- Comparative Learning: Side-by-side model comparisons
- Interactive Exploration: Rotate, zoom, and examine every detail
- Contextual Learning: Fun facts and real-world applications
- Microscope Prep: Know what to expect before lab sessions
- Scale Understanding: Size ranges with visual sliders
- Extensible Platform: Add your own 3D models and data
- Multi-Discipline: Support any scientific field
- AI-Generated Models: Includes prompts for AI 3D generation
- Open Architecture: Modify and customize freely
Cells:
- Plant Cell (Eukaryotic, Autotrophic)
- Animal Cell (Eukaryotic, Heterotrophic)
- Bacterial Cell (Prokaryotic)
- White Blood Cell (Immune System)
- Neuron (Nervous System)
Organelles:
- Mitochondrion (Powerhouse)
- Chloroplast (Photosynthesis)
- Cell Membrane (Fluid Mosaic Model)
Biomolecules:
- DNA Double Helix (Genetic Code)
Viruses:
- T4 Bacteriophage (Bacterial Virus)
- Check GLB files exist in
public/models/ - Verify file sizes match in data definitions
- Run
pnpm update:model-sizesto sync
- Ensure all TypeScript types are correct
- Check that
generateStaticParamsreturns valid slugs - Clear
.next/cache:rm -rf .next
- Optimize GLB files:
pnpm optimize:glb - Convert images to WebP:
pnpm convert:webp - Check browser console for Three.js warnings
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- Three.js community for amazing 3D web tools
- React Three Fiber for seamless React integration
- Next.js team for the excellent framework
- Educators who inspired this platform
Built with β€οΈ for science education
Explore. Learn. Discover.