build app .fbx .glb viewvwer with animations too
- User
build app .fbx .glb viewvwer with animations too
Assistant
I'll build a 3D model viewer app that supports both
.fbxand.glbfile formats with animation playback. Let me start by planning the structure and setting up the project.Now let me install the required Three.js packages and the FBX loader:
Good. Now let me update the index.html title and create all the necessary source files. I'll build a complete 3D model viewer with:
- Drag-and-drop file loading for
.fbxand.glb - Three.js scene with lighting, grid, and orbit controls
- Animation playback controls (play/pause, speed, scrub)
- Model info panel
Let me update the title and create all files:
Now let me create the core files:
Let me fix those lint errors:
These state variables are used in the animation loop and elsewhere. The issue is the TS linter not detecting the usage via refs. Let me prefix them with underscore or actually use them in the JSX. Let me restructure slightly - I'll make the component export the state for the parent to use, and fix the unused import.
Actually, the simplest fix is to just reference them somewhere visible to TS. Let me use them in a way that's picked up:
The variables are used later in the file. Let me fix the references:
These are referenced in the
setCurrentTime,setActiveAnimation,setAnimationssetters used in callbacks. The TS linter is complaining about the getters not being read. Let me replace them with a simpler approach - just use useRef for these values that don't need re-renders:OK, let me just take a different approach - I'll fully rewrite the ModelViewer component to be cleaner and fix all the lint issues at once. I'll also create the App component with the full UI.
Now let me create the main App component with the full UI - drag/drop, animation controls, and model info:
Now let me update the index.css to add some global styles:
Now let's build and check for any errors:
The build succeeds. The output is larger because Three.js is bundled inline. Let me verify the project structure is clean:
The build is successful and everything is in order. Let me provide a summary of what was built:
3D Model Viewer — Complete
I've built a full-featured 3D model viewer that supports FBX, GLB, and GLTF files with animation playback. Here's what's included:
Features
- Drag & Drop / File Picker — Drop any
.fbx,.glb, or.gltffile onto the viewport or click "Open Model" to browse - Real-time 3D Rendering — Three.js-powered scene with:
- Orbit controls (drag to rotate, scroll to zoom, right-drag to pan)
- Three-point lighting (key, fill, rim) with shadows
- Ground plane shadow catcher
- Grid floor for spatial reference
- Atmospheric fog for depth
- ACES filmic tone mapping
- Animation System:
- Play/Pause button
- Speed control (0.25x, 0.5x, 1x, 1.5x, 2x)
- Timeline scrubber with real-time time display
- Per-clip animation selection or "Play All"
- Smooth seeking
- Model Info Sidebar — Shows mesh count, animation count, total duration
- FBX Support via
FBXLoaderwith animation extraction - GLB/GLTF Support via
GLTFLoaderwith Draco decompression for compressed meshes - Automatic model normalization — Models are auto-scaled and centered
- Responsive layout — Works at any viewport size
File Structure
src/App.tsx— Main UI with drag/drop, sidebar controls, and state managementsrc/components/ModelViewer.tsx— Three.js 3D scene, model loading, animation enginesrc/index.css— Tailwind imports and custom scrollbar/range styles
Files built:
index.html,src/utils/cn.ts,src/components/ModelViewer.tsx,src/App.tsx,src/index.css- Drag-and-drop file loading for