A sophisticated 3D terrain visualization engine built with WebGL, featuring advanced procedural generation, real-time controls, and interactive animation systems.
- Procedural Terrain Generation using Ken Perlin's improved noise algorithm
- Real-time Interactive Controls with comprehensive parameter adjustment
- Multiple Visualization Modes including wireframe, water simulation, and cross-section analysis
- Advanced Animation System with keyframe support and multiple easing functions
- Custom Color Palettes with interactive gradient editor
- Quality Presets from Low (20x20) to 4K Ultra (200x200)
- Responsive Camera System with orbital controls and auto-orbit mode
| Component | Technology | Details |
|---|---|---|
| Rendering | WebGL 1.0 | Custom vertex/fragment shaders, depth testing |
| Noise Algorithm | Ken Perlin's 2002 | 256-element permutation table, fractal noise |
| Terrain Resolution | 20x20 to 200x200 | Configurable grid with quality presets |
| Animation System | RequestAnimationFrame | 60fps smooth interpolation |
| Browser Support | Modern browsers | Chrome, Firefox, Safari, Edge |
| Memory Management | GPU Buffers | Efficient vertex/index buffer management |
| File Size | ~15KB | Minified JavaScript bundle |
- Modern web browser with WebGL support
- No additional dependencies required
- Clone the repository:
git clone https://github.com/arshlibruh-code/trnviz.git
cd trnviz- Open
index.htmlin your web browser:
# Using Python (if installed)
python -m http.server 8000
# Then visit http://localhost:8000/index.html
# Or simply double-click index.htmltrnviz/
├── index.html # Main application file
├── js/
│ ├── main.js # Core application logic (TerrainEngine)
│ ├── terrain.js # Terrain generation system
│ ├── noise.js # Perlin noise implementation
│ ├── controls.js # UI and interaction management
│ └── config.js # Configuration constants
└── media/ # Assets directory
├── gifs/
└── videos/
- Left Click + Drag: Orbit camera around terrain
- Mouse Wheel: Zoom in/out
- Right Click: Prevent context menu
- Shift + I: Toggle terrain animation
- Shift + O: Toggle auto-orbit camera
- Shift + P: Hide/show control panel
- Pattern Zoom: Adjust terrain detail scale (0.001-0.5)
- Height Multiplier: Control vertical scaling (1-50)
- Octaves: Number of noise layers (1-8)
- Lacunarity: Frequency multiplier between octaves (1.0-5.0)
- Persistence: Amplitude multiplier between octaves (0.01-1.0)
- Resolution: Grid size (20-200)
- Seed: Randomization seed (0-1000)
- Water Level: Sea level height (-20 to 20)
- Domain Warp: Terrain deformation strength (0-10)
- Viridis: Scientific color scheme (purple to yellow)
- Grayscale: Black to white gradient
- Heatmap: Red to yellow thermal mapping
- Custom: Interactive gradient editor with draggable color stops
- Random: Smooth cubic easing
- Sine/Cosine: Wave-based transitions
- Sawtooth: Linear progression
- Triangle: Triangular wave pattern
- Bounce: Elastic bounce effect
- Elastic: Spring-like motion
- Pulse: Rhythmic pulsing
| Preset | Resolution | Use Case |
|---|---|---|
| Low | 20x20 | Fast preview, mobile devices |
| Medium | 50x50 | Balanced performance/quality |
| High | 100x100 | Detailed visualization |
| 4K Ultra | 200x200 | Maximum detail, powerful hardware |
TerrainEngine (main.js)
├── NoiseGenerator (noise.js)
├── TerrainGenerator (terrain.js)
├── ControlManager (controls.js)
└── CameraController (main.js)
- TerrainEngine: Main application controller
- TerrainGenerator: Handles mesh generation and GPU uploads
- NoiseGenerator: Implements Perlin noise algorithms
- ControlManager: Manages UI interactions and animations
- CameraController: Handles 3D camera transformations
- New Noise Types: Extend
NoiseGeneratorclass - Custom Shaders: Modify shader source in
setupShaders() - UI Controls: Add to
controlsarray inControlManager - Animation Presets: Extend
getAnimationCurve()method
- Efficient GPU buffer management
- Optimized draw calls with element arrays
- RequestAnimationFrame-based rendering
- Memory-efficient noise calculations
- Mobile: Low quality (20x20), disable animations
- Desktop: Medium quality (50x50), enable animations
- High-end: High quality (100x100), all features enabled
- 4K Display: Ultra quality (200x200), maximum settings
- WebGL not supported: Update browser or enable hardware acceleration
- Poor performance: Reduce quality settings or disable animations
- Controls not responding: Check browser console for JavaScript errors
- Terrain not rendering: Verify all JS files are loaded correctly
- Chrome 56+
- Firefox 51+
- Safari 10+
- Edge 79+
MIT License - see LICENSE file for details
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Ken Perlin for the Perlin noise algorithm
- Adrian's Perlin Noise Tutorial for comprehensive noise implementation guidance
- WebGL Terrain Visualization Tutorial for 3D rendering techniques
- WebGL community for rendering techniques
- Contributors and testers
TRNVIZ - trnviz & arshlibruh

