xr-developer
WebXR Development Guide
Build immersive, performant AR/VR/XR applications with spatial interfaces, multi-input support, and cross-device compatibility using WebXR, A-Frame, Three.js, and Babylon.js.
Session Lifecycle
navigator.xr.requestSession('immersive-vr')
-> session.requestReferenceSpace('local-floor')
-> session.requestAnimationFrame(onXRFrame)
-> session.end() // cleanup on onend event
Always handle onend for cleanup. Follow WebXR spec for immersive-vr and immersive-ar session types.
Cross-Device Compatibility
| Device | Session Type | Primary Input | Notes |
|---|---|---|---|
| Meta Quest 2/3/Pro | immersive-vr |
Controllers + hand tracking | Test both input modes |
| Apple Vision Pro | immersive-vr |
Hand tracking + eye tracking | Hand tracking primary |
| HoloLens 2 | immersive-ar |
Hand tracking + gaze | AR session type |
| Mobile AR | immersive-ar |
Touch + device motion | Fallback to inline if needed |
Handle capability differences via feature detection (not user-agent sniffing). Adapt interaction models per device.
Performance
Frame Budget
- Target 72fps on Quest 3, 90fps on Quest Pro.
- Keep frame budget under 11ms for 90fps targets.
- Optimize rendering: occlusion culling, LOD, shader tuning, draw call batching.
- Handle graceful fallback for non-XR browsers with progressive enhancement.
Optimization Checklist
- Profile GPU and CPU on-device (not just desktop).
- Reduce draw calls via instancing and mesh merging.
- Implement LOD (level of detail) for distant objects.
- Use texture atlases to reduce material switches.
- Test with WebXR emulators and real devices (at least 2 runtimes before shipping).
Code Examples
See WebXR with Three.js Guide for full session setup, controller models, hand tracking pinch detection, controller input handling, and the input fallback chain.
See Spatial UI with A-Frame Guide for the spatial-panel component, follow-camera HUD component, and spatial UX guidelines.
Workflow
- Define scope: Target devices, interaction model, session type (VR/AR/inline).
- Scaffold: Set up renderer, XR session management, input handling.
- Build interactions: Implement spatial UI, input methods, physics/raycasting.
- Optimize: Profile GPU/CPU, reduce draw calls, implement LOD, test on-device.
- Ship: Test across target devices, implement fallbacks, document known limitations.
Scripts
scripts/scaffold_webxr.sh
Create a minimal WebXR project structure with Three.js and a working VR hello-world that renders a rotating cube. Generates index.html (with Three.js CDN + WebXR boilerplate), main.js (XR session setup + render loop), styles.css, and package.json (with a dev server).
scripts/scaffold_webxr.sh --name my-vr-app
scripts/scaffold_webxr.sh --name vr-demo
scripts/check_webxr_compat.py
Check JavaScript/HTML files for common WebXR compatibility issues: deprecated WebVR APIs (navigator.getVRDisplays), missing feature detection, missing session support checks, and vendor-prefixed extensions. Outputs a structured markdown compatibility report with line numbers and suggestions.
scripts/check_webxr_compat.py main.js
scripts/check_webxr_compat.py src/
scripts/check_webxr_compat.py --output report.md src/xr-scene.js
Key Specifications
More from peterhdd/agent-skills
engineering-senior-developer
Lead complex software implementation, architecture decisions, and reliable delivery across any modern technology stack. Use when you need pragmatic architecture tradeoffs, technical plan creation from ambiguous requirements, code quality improvements, production-safe rollout strategies, observability setup, or senior engineering judgment on maintainability, testing, and operational reliability.
63engineering-frontend-developer
Build modern web applications with React, Vue, Angular, or Svelte, focusing on performance and accessibility. Use when you need component library development, TypeScript UI implementation, responsive layouts with CSS Grid and Flexbox, Core Web Vitals optimization, service worker offline support, code splitting, ARIA accessibility, Storybook integration, or frontend API client architecture.
40engineering-backend-architect
Architect scalable backend systems, database schemas, APIs, and cloud infrastructure for robust server-side applications. Use when you need microservice vs monolith decisions, database indexing strategies, API versioning, event-driven architecture, ETL pipelines, WebSocket streaming, data modeling, query optimization, or cloud-native service design with high reliability and sub-20ms query performance.
40engineering-mobile-app-builder
Build native and cross-platform mobile applications for iOS and Android with optimized performance and platform integration. Use when you need SwiftUI or Jetpack Compose development, React Native or Flutter cross-platform apps, offline-first architecture, biometric authentication, push notifications, deep linking, app startup optimization, or mobile-specific UX patterns and gesture handling.
38engineering-system-designer
Design distributed systems, define architecture for scalability and reliability, or create system design documents. Use when you need component diagrams, data flow analysis, capacity planning, database sharding strategies, API contract design, failure mode analysis, CAP theorem tradeoffs, monolith-to-microservice migration, or architecture decision records for new or existing systems.
34engineering-rapid-prototyper
Build functional prototypes and MVPs at maximum speed to validate ideas through working software. Use when you need proof-of-concept development, rapid iteration on user feedback, no-code or low-code solutions, backend-as-a-service integration, A/B testing scaffolding, quick feature validation, or modular architectures designed for fast experimentation and learning.
33