🚀 Try this Example
View the complete source code on GitHub. Live Demo: manifold-jet.vercel.app Steps to run:- Install fal:
- Authenticate:
- Clone the repository with submodules:
- Set up the frontend:
- Configure environment variables in
frontend/.env.local:
- Run the development server:
How it Works
- Prompt Enhancement — Groq LLM (
llama-3.3-70b) rewrites your text into an optimized image prompt + segmentation label - Image Generation —
fal-ai/z-image/turbogenerates a 3D-ready image in ~1s - 3D Reconstruction — SAM-3D runs geometry and appearance diffusion on H100, streaming voxel data via SSE callbacks at each denoising step
- Live Visualization — React Three Fiber renders voxels/mesh/GLB in real-time as data streams in
Deploy Your Own Endpoint
To customize the SAM-3D backend, deploy your own:FAL_ENDPOINT_ID in .env.local with your new endpoint ID.
Key Features
- Progressive Rendering: See voxels appear during both geometry and appearance diffusion stages
- Binary Streaming Protocol: Efficient base64-encoded voxel data (xyz + rgb per voxel)
- Multiple Output Formats: Voxels, vertex-colored mesh preview, and final GLB model
- Custom Container: Complex CUDA dependencies handled via Dockerfile
- H100 GPU: High-performance inference for fast reconstruction
Backend Architecture
The serverless endpoint uses Server-Sent Events (SSE) for streaming progressive updates:SSE Event Types
The streaming endpoint emits these event types:Binary Voxel Encoding
Voxels are packed as uint8 arrays for efficient streaming:Frontend Integration
The React frontend uses a custom hook to consume the SSE stream:Voxel Rendering with Three.js
Use React Three Fiber to render the streaming voxels:Custom Container Image
The backend requires complex CUDA dependencies. Use a Dockerfile for full control:Input Parameters
Project Structure
Performance Considerations
Streaming Frequency
Control the streaming frequency to balance smoothness vs. performance:Binary Encoding
The binary encoding reduces payload size significantly compared to JSON:- 6 bytes per voxel (xyz + rgb as uint8)
- ~10,000 voxels = ~60KB per frame
- Base64 encoding adds ~33% overhead
Key Takeaways
- SSE streaming enables real-time visualization of long-running 3D reconstruction
- Binary encoding makes voxel streaming efficient over HTTP
- Custom containers handle complex GPU dependencies (CUDA, PyTorch3D, kaolin)
- Progressive rendering gives users immediate visual feedback during generation
- H100 GPUs provide the compute power needed for fast 3D diffusion