A sophisticated interactive 3D mathematical function visualizer built with Three.js, featuring real-time rendering, intuitive controls, and comprehensive mathematical plotting capabilities.
- Features
- Quick Start
- User Guide
- Technical Documentation
- API Reference
- Development
- Deployment
- Troubleshooting
- Contributing
- License
- Real-time 3D Visualization: Plot mathematical functions in 3D space with smooth wireframe rendering
- Interactive Controls: Orbit controls for camera manipulation (rotate, zoom, pan)
- Customizable Functions: Input any JavaScript mathematical expression for the Z-axis
- Dynamic Range Settings: Adjust X and Y axis ranges to focus on specific domains
- Modern Design: Glassmorphism UI with backdrop blur effects
- Burger Menu: Collapsible controls panel for clean interface
- Color-coded Popups: Success (green), error (red), warning (orange), info (blue) messages
- Responsive Design: Optimized for desktop, tablet, and mobile devices
- Touch-friendly: Enhanced mobile interactions with larger touch targets
- Coordinate System: Labeled axes with numerical markers
- Grid Overlay: Customizable reference grid
- Wireframe Rendering: Clean mathematical surface visualization
- Smooth Animations: CSS transitions and Three.js animations
- Function Library: Save and manage frequently used functions
- Error Handling: Intelligent validation with contextual error messages
- Performance Optimized: Efficient rendering for complex functions
- Keyboard Shortcuts: Quick access to common actions
- Browser: Modern browser with WebGL support (Chrome 80+, Firefox 75+, Safari 13+, Edge 80+)
- Python: Version 3.x for local development server
- WebGL: Enabled in browser settings
# Clone the repository
git clone https://github.com/mrodriguex/xgraphx.git
cd xgraphx
# Start development server
python3 -m http.server 8000
# Open in browser
# Navigate to: http://localhost:8000- Open
http://localhost:8000in your browser - Enter
x*x + y*yin the function input - Click the Plot button
- Use mouse to rotate the 3D view
The application features a clean, modern interface with three main components:
- 3D Canvas: Main visualization area (center)
- Burger Menu: Controls toggle (top-left corner)
- Action Buttons: Help (?) and Reset (⟲) buttons (top-right corner)
- Variables:
xandy(case-sensitive) - Operators:
+,-,*,/,**(power),%(modulo) - Parentheses: Use
()for grouping expressions
// Trigonometric
Math.sin(x), Math.cos(x), Math.tan(x)
Math.asin(x), Math.acos(x), Math.atan(x)
// Exponential & Logarithmic
Math.exp(x), Math.log(x), Math.log10(x)
// Power & Root
Math.pow(x, y), Math.sqrt(x), x**(1/3)
// Rounding
Math.floor(x), Math.ceil(x), Math.round(x)
// Absolute & Sign
Math.abs(x), Math.sign(x)
// Constants
Math.PI, Math.E// Saddle surface
x*x - y*y
// Ripple effect with distance
Math.sin(Math.sqrt(x*x + y*y) * 2)
// Gaussian bell curve
Math.exp(-(x*x + y*y) / 2)
// Torus approximation
Math.sin(x) * Math.cos(y) * 2
// Möbius strip approximation
Math.sin(x) * Math.sin(y/2)Control the plotting domain by adjusting X and Y ranges:
- Default Range: -2 to +2 for both axes
- Recommended: Keep ranges symmetric for best visualization
- Performance: Smaller ranges = faster rendering
- Precision: Larger ranges may need more grid points
- Show Grid: Reference grid for spatial orientation
- Performance: Disable for complex functions
- Show Numbers: Axis coordinate labels
- Clarity: Enable for educational use, disable for clean visualization
| Action | Input | Description |
|---|---|---|
| Rotate | Left-click + drag | Orbit around center point |
| Zoom | Mouse wheel | Zoom in/out |
| Pan | Middle-click + drag | Move camera position |
| Reset View | Right-click menu | Return to default position |
| Action | Gesture | Description |
|---|---|---|
| Rotate | 1 finger drag | Orbit around visualization |
| Zoom | Pinch | Zoom in/out |
| Pan | 2 finger drag | Move camera position |
- Enter your function in the input field
- Click the Save button
- Provide a descriptive name
- Function appears in the dropdown list
- Load: Select from dropdown to load saved function
- Delete: Remove unwanted saved functions
- New: Clear current function for fresh input
| Shortcut | Action | Description |
|---|---|---|
Enter |
Plot Function | Execute current function |
Ctrl+S |
Save Function | Open save dialog |
Ctrl+R |
Reset View | Return camera to default |
F1 |
Help | Show help modal |
Esc |
Close Modals | Close any open dialogs |
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ index.html │ │ controls.js │ │ plotter.js │
│ │ │ │ │ │
│ • DOM Structure │ │ • UI Management │ │ • Three.js │
│ • Event Binding │ │ • State Control │ │ • Scene Mgmt │
│ • Canvas Setup │ │ • Validation │ │ • Rendering │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────┐
│ style.css │
│ │
│ • Layout │
│ • Animations │
│ • Responsive │
└─────────────────┘
- Renderer: WebGL context with antialiasing
- Camera: Perspective camera with orbit controls
- Scene: 3D object container with lighting
- Geometry: Parametric surface generation
- Materials: Wireframe and solid surface materials
- Parser: JavaScript
Functionconstructor for dynamic evaluation - Validation: Syntax checking and error handling
- Sampling: Grid-based point evaluation
- Performance: Optimized computation with caching
- Controls Panel: Collapsible settings interface
- Popup System: Color-coded user feedback
- Responsive Design: Mobile-first approach
- Accessibility: ARIA labels and keyboard navigation
- LOD (Level of Detail): Adaptive mesh resolution
- Frustum Culling: Hide objects outside camera view
- Object Pooling: Reuse geometry and materials
- Efficient Updates: Minimal scene graph modifications
- Garbage Collection: Proper cleanup of Three.js objects
- Texture Compression: Optimized image loading
- Lazy Loading: On-demand resource loading
- WebGL Detection: Fallback for unsupported browsers
- Feature Detection: Progressive enhancement
- Polyfills: ES6+ compatibility for older browsers
xgraphx/
├── index.html # Main application shell
│ ├── Canvas setup # WebGL context initialization
│ ├── UI components # HTML structure for controls
│ └── Event bindings # User interaction handlers
│
├── assets/
│ ├── css/
│ │ └── style.css # Complete styling system
│ │ ├── Layout # Grid and flexbox layouts
│ │ ├── Components # Button, input, modal styles
│ │ ├── Animations # Transitions and keyframes
│ │ └── Responsive # Mobile-first breakpoints
│ │
│ └── js/
│ ├── main.js # Application entry point
│ │ ├── Module imports
│ │ ├── DOM ready handler
│ │ └── Component initialization
│ │
│ ├── controls.js # UI control logic
│ │ ├── Event handlers
│ │ ├── State management
│ │ ├── Validation
│ │ └── User feedback
│ │
│ └── plotter.js # Three.js visualization
│ ├── Scene setup
│ ├── Geometry generation
│ ├── Camera controls
│ └── Rendering loop
│
├── .vscode/
│ └── launch.json # Development configurations
│
├── .gitignore # Version control exclusions
├── LICENSE # MIT license terms
└── README.md # This documentation
Renders a 3D surface from a mathematical expression.
Parameters:
expression(string): Mathematical function as JavaScript codeoptions(object): Rendering configurationxMin,xMax(number): X-axis rangeyMin,yMax(number): Y-axis rangegridSize(number): Resolution of the meshwireframe(boolean): Wireframe vs solid rendering
Returns: Promise that resolves when rendering completes
Example:
plotFunction("Math.sin(x) * Math.cos(y)", {
xMin: -Math.PI,
xMax: Math.PI,
yMin: -Math.PI,
yMax: Math.PI,
gridSize: 50,
wireframe: true
});Resets camera to default position and orientation.
Sets camera position in 3D space.
Parameters:
x,y,z(number): World coordinates
Sets camera look-at target.
Displays a user notification.
Parameters:
message(string): Notification texttype(string): "success", "error", "warning", "info"duration(number): Auto-hide delay in milliseconds
Shows/hides the controls panel.
Updates plotting range for specified axis.
-
Install recommended extensions:
- Live Server
- Three.js Snippets
- JavaScript (ES6) code snippets
-
Launch configurations available:
- Launch 3D Plotter: Opens in default browser
- Debug Mode: Enables browser developer tools
# Install dependencies (none required for basic development)
# Start development server
python3 -m http.server 8000
# Open browser to http://localhost:8000# Install ESLint globally
npm install -g eslint
# Run linting
eslint assets/js/*.js# Manual testing checklist:
# - Function plotting accuracy
# - UI responsiveness
# - Mobile compatibility
# - Error handling
# - Performance benchmarks- Extend the function parser in
plotter.js - Add validation rules in
controls.js - Update documentation
- Modify
style.cssfor styling changes - Update
index.htmlfor structure changes - Test across all breakpoints
- Profile rendering performance
- Optimize geometry generation
- Implement caching strategies
main: Production-ready codedevelop: Integration branchfeature/*: New featuresbugfix/*: Bug fixeshotfix/*: Critical fixes
feat: add new plotting function
fix: resolve mobile layout issue
docs: update API documentation
style: format code with Prettier
refactor: optimize rendering performance
test: add unit tests for validation
The application is static and can be deployed to any web server:
# Create gh-pages branch
git checkout -b gh-pages
# Build and deploy
npm run deploy # or manual upload- Connect repository
- Set build command:
echo "Static site - no build needed" - Set publish directory:
/ - Deploy
# Upload files via FTP
ftp example.com
cd public_html
put -r xgraphx/# Minify CSS
npx postcss assets/css/style.css -o assets/css/style.min.css --use cssnano
# Minify JavaScript
npx terser assets/js/*.js -o assets/js/bundle.min.jsConfigure server for:
- GZIP compression for HTML/CSS/JS
- WebP images (if applicable)
- Brotli compression for modern browsers
- LCP (Largest Contentful Paint): < 2.5s
- FID (First Input Delay): < 100ms
- CLS (Cumulative Layout Shift): < 0.1
- Google PageSpeed Insights
- WebPageTest
- Chrome DevTools Performance tab
Symptoms: Black screen, "WebGL context lost" error Solutions:
- Refresh the page
- Restart browser
- Update graphics drivers
- Disable hardware acceleration in browser settings
Symptoms: "Invalid function" popup messages Common Causes:
- Missing
Math.prefix: UseMath.sin(x), notsin(x) - Undefined variables: Only
xandyare available - Syntax errors: Check parentheses and operators
- Reserved words: Avoid using
function,var, etc.
Symptoms: Slow rendering, browser freezing Solutions:
- Reduce range values (smaller domains)
- Decrease grid resolution
- Close other browser tabs
- Update browser to latest version
- Enable hardware acceleration
Symptoms: Unresponsive touch controls Solutions:
- Ensure viewport meta tag is present
- Check for conflicting CSS touch events
- Test on actual mobile device (not just browser dev tools)
Symptoms: "Failed to load resource" errors Solutions:
- Check file paths and permissions
- Ensure development server is running
- Verify CORS settings for external resources
- Clear browser cache
Enable debug logging:
// In browser console
localStorage.setItem('debug', 'true');
location.reload();- Enable WebGL:
chrome://flags/#enable-webgl-draft-extensions - Hardware acceleration:
chrome://settings/?search=hardware+acceleration
- WebGL:
about:config→webgl.force-enabled→true - Performance:
about:config→dom.webgl.max_frames_per_second→60
- WebGL: Develop menu → Experimental Features → WebGL 2.0
- Performance: Develop menu → Experimental Features → GPU Process: WebGL
- Check Documentation: Review this comprehensive README
- Browser Console: Check for JavaScript errors
- Network Tab: Verify all resources load correctly
- Performance Tab: Identify bottlenecks
- Create Issue: Use GitHub issues for bugs/features
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/xgraphx.git - Create feature branch:
git checkout -b feature/amazing-feature - Make changes and test thoroughly
- Commit with clear messages:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Create Pull Request with detailed description
- Use ES6+ features (const/let, arrow functions, template literals)
- Consistent naming: camelCase for variables/functions
- JSDoc comments for functions
- Error handling with try/catch
- Modular code organization
- BEM methodology for class naming
- CSS custom properties for theming
- Mobile-first responsive design
- Optimized animations and transitions
- Semantic HTML5 elements
- Accessibility attributes (ARIA labels)
- Clean, minimal markup
- Progressive enhancement
- Function plotting works correctly
- Camera controls respond properly
- UI elements are interactive
- Error handling provides helpful messages
- Desktop browsers (Chrome, Firefox, Safari, Edge)
- Mobile browsers (iOS Safari, Chrome Mobile)
- Different screen sizes and orientations
- Touch and mouse interactions
- Initial load time < 3 seconds
- Smooth 60fps rendering
- Memory usage remains stable
- No console errors or warnings
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] All tests pass
- [ ] Manual testing completed
- [ ] Cross-browser testing done
## Screenshots
Add screenshots if UI changes
## Additional Notes
Any additional information or contextThis project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- ✅ Commercial use
- ✅ Modification
- ✅ Distribution
- ✅ Private use
- ✅ Patent use
- ❌ Liability
- ❌ Warranty
⚠️ Copyleft: Derivative works must also be GPL v3 licensed
- Three.js: Powerful 3D graphics library
- OrbitControls: Intuitive camera controls
- WebGL: Hardware-accelerated 3D graphics
- VS Code: Primary development environment
- Git: Version control system
- Python HTTP Server: Local development server
- Browser DevTools: Debugging and profiling
- Three.js Community: Excellent documentation and examples
- Stack Overflow: Invaluable problem-solving resource
- GitHub Community: Open source collaboration
- Mathematical visualization tools
- Modern web application design patterns
- Educational software for STEM learning
- Documentation: This comprehensive README
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Maintainer: mrodriguex
- Email: manuel.r.camacho@outlook.com
- GitHub: @mrodriguex
- Repository: GitHub Repository
Built using Three.js and modern web technologies