Your GLB file has been successfully integrated into the simulation! The system now supports:
- ✅ Your CAD Model:
bridge.glb(1.5MB) - ✅ Automatic Fallback: If model fails to load
- ✅ Real-time Animation: Based on sensor data
- ✅ Material Color Changes: Visual status indicators
- URL:
http://localhost:8081/cad-simulation - Navigation: Click "CAD Model" in the top menu
- Loads your
bridge.glbfile from/public/bridge.glb - Automatic preloading for faster initial display
- Error handling with fallback to geometric bridge
- Memory-efficient cloning to avoid conflicts
- Vibration Effects: Model moves based on vibration sensor data
- Strain Visualization: Color changes from green → yellow → red
- Material Updates: Both emissive and diffuse color changes
- Subtle Movements: Appropriate for CAD models
- 🖱️ Mouse Controls: Orbit, zoom, pan
- ⏸️ Pause/Resume: Control simulation
- 🔄 Reset: Return to normal values
- 🔄 Reload Model: Force model refresh
- Professional Lighting: Multiple light sources
- Ground Plane: Realistic foundation
- Grid Reference: For scale understanding
- Shadows: Depth perception (if supported)
// Model positioning and scaling
<primitive
object={clonedScene}
scale={0.1} // 10% of original size
position={[0, -2, 0]} // Slightly below center
/>
// Camera position
camera={{ position: [10, 6, 10], fov: 50 }}If your model appears too large/small, modify the scale:
scale={0.05} // Smaller (5% of original)
scale={0.2} // Larger (20% of original)To reposition your model:
position={[x, y, z]}
// x: left(-)/right(+)
// y: down(-)/up(+)
// z: back(-)/forward(+)If your model needs rotation:
<primitive
object={clonedScene}
scale={0.1}
position={[0, -2, 0]}
rotation={[0, Math.PI/4, 0]} // Rotate 45° around Y-axis
/>Adjust how much the color changes based on strain:
// Current: 20% blend with status color
material.color.copy(originalColor).lerp(color, 0.2);
// More dramatic: 50% blend
material.color.copy(originalColor).lerp(color, 0.5);Adjust vibration and movement:
// Vibration (current: 0.02)
groupRef.current.position.y = Math.sin(time * 2) * vibration * 0.02;
// More subtle: 0.01
// More dramatic: 0.05- File Size: 1.56 MB (Good for web)
- Format: GLB (Optimized)
- Loading: ~1-3 seconds on average connection
- Reduce Texture Size: Use 1024x1024 instead of 2048x2048
- Simplify Geometry: Reduce polygon count if very detailed
- Compress Textures: Use WebP format in Blender
- Remove Unused Materials: Clean up before export
To add additional GLB files:
- Place them in
/public/folder - Update the component:
const modelPath = "/your-model.glb";
gltf = useGLTF(modelPath);Create buttons to switch between models:
const [currentModel, setCurrentModel] = useState("bridge.glb");
const models = {
bridge: "/bridge.glb",
building: "/building.glb",
tower: "/tower.glb"
};Show different damage states:
const getModelPath = (strain: number) => {
if (strain < 1000) return "/bridge-normal.glb";
if (strain < 2000) return "/bridge-stressed.glb";
return "/bridge-damaged.glb";
};- Check File Path: Ensure
/public/bridge.glbexists - Check Console: Look for loading errors
- File Corruption: Re-export from your CAD software
- Size Limit: Some servers have upload limits
- Scale Issues: Adjust
scaleproperty - Orientation: Add
rotationproperty - Position: Modify
positionproperty - Materials: Check if materials are embedded
- Reduce Model Complexity: Simplify geometry
- Optimize Textures: Reduce texture resolution
- Disable Shadows: Comment out shadow settings
- Lower Update Rate: Increase interval time
- Units: Use consistent units (preferably meters)
- Origin: Place model at origin (0,0,0)
- Materials: Ensure materials are properly applied
- Textures: Embed textures in GLB file
- Optimization: Use Blender's GLB export settings
public/
├── bridge.glb // Your main model
├── bridge-damaged.glb // Damaged state (optional)
├── building.glb // Additional models
└── textures/ // External textures (if any)
- Test Your Model: Visit
/cad-simulation - Adjust Settings: Modify scale/position as needed
- Add More Models: Include different infrastructure types
- Enhance Animations: Add more sophisticated effects
- Integrate Sensors: Connect real sensor data
If your model doesn't display correctly:
- Check the browser console for errors
- Verify the file path is correct
- Ensure the GLB file is valid
- Try the fallback geometric bridge first
Your CAD model integration is now ready for real-time infrastructure monitoring! 🎉