$ show GordenSun/LearningCell
This repository is an interactive 3D biology teaching application built with React, TypeScript, Vite, and three.js. It allows users to explore detailed models of biological structures (plant cell, animal cell, white blood cell, neuron, DNA) with rotation, zoom, and informational overlays. The application features a custom model loading system that prioritizes the initially displayed model and preloads others in the background to optimize bandwidth usage. The UI consists of a sidebar for model selection, a central 3D viewing area, and an information panel detailing each model's characteristics. The code demonstrates thoughtful engineering in resource loading, state management, and responsive design, making it suitable for educational contexts.
The LLM identified 3 files worth highlighting for reuse:
Implements a robust caching and loading system for Three.js GLTF models with Draco compression. Provides real-time download progress tracking using the Fetch API and ReadableStream, prioritizes initial model loading, and preloads additional models in the background to avoid bandwidth contention. Includes error handling and a mechanism to clone GLTF scenes for safe reuse in multiple Three.js instances. The core logic is framework-agnostic and could be adapted for other resource types with minimal changes.
A React hook that subscribes to the loading state of a model from the modelLoader system. Tracks status (idle, downloading, parsing, done, error) and progress (0-1) with automatic updates when state changes. Handles auto-starting loads based on configuration and cleanly manages subscriptions to prevent memory leaks. Decouples loading logic from UI components, making it reusable for any resource loading scenario in React applications.
A self-contained, accessible loading overlay component that displays a spinner, progress bar, and status text during resource loading. Uses SVG for an animated circular progress indicator (resembling a cell) and CSS for the progress bar. Accepts props for progress percentage, status text, model name, and optional error message. Designed for reuse in any loading scenario with minimal dependenciesβonly requires the progress and status values to function. The component is responsive and includes ARIA attributes for screen reader accessibility.