Skip to content

Example with WEB-XR and interfacing with VR Headsets. Tested on a Varjo Aero with 4 base stations and Valve Index Knuckle controllers. (https://immersiveweb.dev/) and sinking my teeth into babylonjs (https://www.babylonjs.com/) for some technical experimentation and exploration. Built with react.

Notifications You must be signed in to change notification settings

webdevbrian/vr_webxr

Repository files navigation

VR WebXR Experimental Project

A comprehensive WebXR experience built with Babylon.js, showcasing advanced VR development techniques and real-time audio visualization. This project serves as a technical exploration of modern WebXR standards and Babylon.js capabilities.

๐Ÿš€ Live Demo

Experience it here: https://vr-webxr.vercel.app/

๐ŸŽฏ Project Overview

This project was developed as a technical exploration of WebXR standards and Babylon.js capabilities, focusing on creating an immersive cyberpunk environment with real-time audio visualization and advanced VR interactions.

Key Experiments & Features

๐ŸŽต Real-Time Audio Visualization

  • Microphone Input Processing: Real-time audio spectrum analysis using Web Audio API
  • Dynamic Visual Response: 3D cylindrical bars that respond to frequency bands
  • Particle System: Animated particles that emit from audio-reactive cylinders
  • Cyberpunk Color Gradients: Dynamic color transitions based on audio intensity
  • Smooth Interpolation: Advanced smoothing algorithms for fluid visual responses

๐ŸŽฎ Advanced VR Interactions

  • Multi-Controller Support: Full support for Valve Index Knuckles and other VR controllers
  • Head Tracking: Real-time head position and rotation tracking
  • Teleportation System: Smooth VR locomotion with visual indicators
  • Physics Integration: Cannon.js physics for realistic object interactions
  • FOV Adjustment: Dynamic field-of-view controls for comfort optimization

๐ŸŒ† Immersive Cyberpunk Environment

  • PBR Materials: Physically-based rendering for realistic lighting and reflections
  • Dynamic Lighting: Multiple light sources with volumetric effects
  • Reflection Probes: Real-time reflections on wet asphalt surfaces
  • Atmospheric Effects: Post-processing pipeline with SSAO and bloom effects
  • 3D Model Integration: GLTF/GLB model loading with texture support

๐Ÿ“Š Performance & Monitoring

  • Real-time Statistics: FPS, draw calls, and vertex count monitoring
  • VR Session Data: Comprehensive tracking of VR state and controller data
  • Responsive Design: Adaptive UI that works across desktop and VR modes
  • Memory Management: Efficient resource disposal and cleanup

๐Ÿ› ๏ธ Technology Stack

Core Technologies

  • Babylon.js 8.15.1: Advanced 3D engine with WebXR support
  • React 18.3.1: Modern UI framework with TypeScript
  • Vite 5.4.2: Fast build tool and development server
  • TypeScript 5.5.3: Type-safe development environment

VR & 3D Libraries

  • @babylonjs/core: Core 3D engine functionality
  • @babylonjs/gui: VR-compatible UI components
  • @babylonjs/loaders: GLTF/GLB model loading
  • @babylonjs/materials: PBR material system
  • @babylonjs/serializers: Scene serialization
  • cannon-es 0.20.0: Physics engine for realistic interactions

Development Tools

  • Tailwind CSS 3.4.1: Utility-first CSS framework
  • ESLint 9.9.1: Code quality and consistency
  • PostCSS 8.4.35: CSS processing and optimization
  • Lucide React 0.344.0: Modern icon library

๐ŸŽฎ VR Hardware Support

Tested Hardware

  • Varjo Aero: High-resolution VR headset with 4 base stations
  • Valve Index Knuckles: Advanced hand tracking controllers
  • Steam Base Stations: Precise positional tracking

WebXR Features Implemented

  • Session Management: Enter/exit VR with proper state handling
  • Controller Tracking: Full 6DOF controller support
  • Head Tracking: Real-time head position and orientation
  • Haptic Feedback: Controller vibration support (framework ready)
  • Room-Scale VR: Full room-scale movement support

๐Ÿ”ฌ Technical Experiments

Audio Visualization System

// Real-time frequency analysis with Web Audio API
const analyser = audioContext.createAnalyser();
analyser.fftSize = 256;
const frequencyData = new Uint8Array(analyser.frequencyBinCount);

Advanced Physics Integration

// Cannon.js physics with custom materials
scene.enablePhysics(new Vector3(0, -9.81, 0), new CannonJSPlugin());
ground.physicsImpostor = new PhysicsImpostor(ground, PhysicsImpostor.BoxImpostor, {
  mass: 0,
  restitution: 0.2,
  friction: 0.9
});

PBR Material System

// Physically-based rendering for realistic surfaces
const material = new PBRMaterial("groundMaterial", scene);
material.albedoTexture = asphaltTexture;
material.roughness = 0.2;
material.metallicFactor = 0.7;

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • Modern browser with WebXR support
  • VR headset (optional for full experience)

Installation

# Clone the repository
git clone https://github.com/webdevbrian/vr-webxr.git
cd vr-webxr

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

Development Commands

npm run dev          # Start development server
npm run build        # Build for production
npm run preview      # Preview production build
npm run lint         # Run ESLint

๐ŸŽจ Project Structure

src/
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ AudioSpectrum.ts      # Real-time audio visualization
โ”‚   โ”œโ”€โ”€ SceneStats.tsx        # Performance monitoring
โ”‚   โ”œโ”€โ”€ VRInterface.tsx       # VR controls and UI
โ”‚   โ””โ”€โ”€ VRScene.ts           # Main 3D scene management
โ”œโ”€โ”€ types/
โ”‚   โ””โ”€โ”€ VRTypes.ts           # TypeScript interfaces
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ ModelLoader.ts        # 3D model loading utilities
โ”‚   โ””โ”€โ”€ VRUtils.ts           # VR helper functions
โ””โ”€โ”€ App.tsx                  # Main application component

๐Ÿ”ฎ Future Features

Planned Enhancements

  • HTC Vive Tracker Support: Full body tracking integration
  • Steam Base Station Integration: Enhanced positional tracking
  • Hand Gesture Recognition: Advanced hand tracking and gestures
  • Multiplayer Support: Collaborative VR experiences
  • Advanced Audio Effects: 3D spatial audio and reverb
  • Custom Shaders: GLSL shader development for visual effects

Technical Roadmap

  • WebGPU Integration: Next-generation graphics API
  • WebAssembly Physics: High-performance physics simulation
  • Procedural Generation: Dynamic environment creation
  • AI Integration: Intelligent NPCs and interactions

๐Ÿค Contributing

This project is open for contributions! Areas of interest:

  • Audio visualization improvements
  • VR interaction enhancements
  • Performance optimizations
  • New visual effects
  • Documentation improvements

๐Ÿ“„ License

This project is developed for educational and experimental purposes. Feel free to use and modify for your own projects.

๐Ÿ‘จโ€๐Ÿ’ป Author

Brian Kinney - GitHub

Built with โค๏ธ using modern web technologies and a passion for immersive experiences.


This project showcases the power of WebXR standards and Babylon.js for creating next-generation virtual reality experiences on the web.

About

Example with WEB-XR and interfacing with VR Headsets. Tested on a Varjo Aero with 4 base stations and Valve Index Knuckle controllers. (https://immersiveweb.dev/) and sinking my teeth into babylonjs (https://www.babylonjs.com/) for some technical experimentation and exploration. Built with react.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published