An open API service indexing awesome lists of open source software.

https://github.com/ehsanwwe/ios-webxr-slam

WebXR-grade AR for iOS Safari. SLAM-based surface detection, gyro tracking & 3D placement โ€” no app, no SDK, no compromise.
https://github.com/ehsanwwe/ios-webxr-slam

Last synced: 2 months ago
JSON representation

WebXR-grade AR for iOS Safari. SLAM-based surface detection, gyro tracking & 3D placement โ€” no app, no SDK, no compromise.

Awesome Lists containing this project

README

          

๐Ÿ”ญ WebARKit


WebXR-grade Augmented Reality for iOS Safari โ€” No App Required


The open-source AR engine that brings real-world surface tracking to iOS browsers.

The missing bridge between WebXR and iOS Safari.

---

![Version](https://img.shields.io/badge/version-0.9.0--beta-blue?style=flat-square)
![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)
![Platform](https://img.shields.io/badge/platform-iOS%20Safari%20%7C%20Android%20Chrome-lightgrey?style=flat-square)
![Three.js](https://img.shields.io/badge/Three.js-r165-black?style=flat-square&logo=three.js)
![WebGL](https://img.shields.io/badge/WebGL2-supported-orange?style=flat-square)
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen?style=flat-square)
![Stars](https://img.shields.io/github/stars/ehsanwwe/ios-webxr-slam?style=flat-square)
![Last Commit](https://img.shields.io/github/last-commit/ehsanwwe/ios-webxr-slam?style=flat-square)


**[๐Ÿš€ Live Demo](#demo) ยท [๐Ÿ“– Documentation](#getting-started) ยท [๐Ÿ—บ Roadmap](#roadmap) ยท [๐Ÿค Contributing](#contributing)**

---

## The Problem

```
iOS Safari has ~25% global mobile market share.
iOS Safari does NOT support WebXR immersive-ar sessions.
Every existing Web AR solution either requires a paid SDK (8th Wall),
a native app (ARKit), or degrades silently to nothing on iOS.
```

**WebARKit solves this.** It is a standalone AR engine that runs entirely in the browser โ€” using the device camera, gyroscope, and a WASM-powered visual tracking layer โ€” to deliver surface-aware AR on iOS Safari, with no app install, no proprietary SDK, and no compromise.

---

## โœจ Features

| Feature | iOS Safari | Android Chrome |
|---|---|---|
| Camera overlay | โœ… | โœ… |
| Gyroscope-based orientation | โœ… | โœ… |
| Visual feature tracking (SLAM) | โœ… ๐Ÿ†• | โœ… |
| Plane / floor detection | โœ… ๐Ÿ†• | โœ… via WebXR |
| 3D object placement on surface | โœ… ๐Ÿ†• | โœ… |
| Drag / rotate placed object | โœ… | โœ… |
| 3D avatar + animation (GLB/FBX) | โœ… | โœ… |
| Voice AI integration | โœ… | โœ… |
| Works without app install | โœ… | โœ… |
| Works without paid SDK | โœ… | โœ… |

---

## ๐Ÿ— Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ WebARKit Engine โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Sensor Layer โ”‚ โ”‚ Camera Layer โ”‚ โ”‚
โ”‚ โ”‚ DeviceOrientation โ”‚ โ”‚ getUserMedia (rear cam) โ”‚ โ”‚
โ”‚ โ”‚ alpha / beta / gammaโ”‚ โ”‚ OffscreenCanvas frames โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ–ผ โ–ผ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Orientation โ”‚ โ”‚ Visual Tracker (WASM) โ”‚ โ”‚
โ”‚ โ”‚ computeDeviceQuat()โ”‚ โ”‚ FAST corner detection โ”‚ โ”‚
โ”‚ โ”‚ screen-orient corr.โ”‚ โ”‚ Lucas-Kanade optical flow โ”‚ โ”‚
โ”‚ โ”‚ quaternion slerp โ”‚ โ”‚ Essential matrix / pose est.โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Sensor Fusion โ”‚ โ”‚
โ”‚ โ”‚ Gyro (rotation) + โ”‚ โ”‚
โ”‚ โ”‚ Optical flow (position) โ”‚ โ”‚
โ”‚ โ”‚ โ†’ Fused 6DOF camera pose โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Plane Detector โ”‚ โ”‚
โ”‚ โ”‚ RANSAC homography โ”‚ โ”‚
โ”‚ โ”‚ Floor / surface recognition โ”‚ โ”‚
โ”‚ โ”‚ โ†’ Reticle on real surface โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Three.js Renderer โ”‚ โ”‚
โ”‚ โ”‚ Fused pose โ†’ camera matrix โ”‚ โ”‚
โ”‚ โ”‚ GLB / FBX / animated avatar โ”‚ โ”‚
โ”‚ โ”‚ AR overlay on camera feed โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

**Dual-mode runtime โ€” automatic, zero config:**

```
navigator.xr?.isSessionSupported('immersive-ar')
โ”œโ”€โ”€ true โ†’ XR Mode (Android Chrome, full WebXR)
โ””โ”€โ”€ false โ†’ WebARKit Mode (iOS Safari, this engine)
```

---

## ๐ŸŽฌ Demo

> ๐Ÿ“ฑ Point your iPhone camera at a flat surface. Tap to place. Drag to move. Pinch-rotate with two fingers.

| AR Avatar Placement | Surface Detection | Voice AI |
|---|---|---|
| *(GIF coming soon)* | *(GIF coming soon)* | *(GIF coming soon)* |

**[โ†’ Try the live demo](https://your-demo-url.com)** *(iOS Safari recommended)*

---

## ๐Ÿš€ Getting Started

### Requirements

- Modern iOS device (iOS 13+) with Safari
- HTTPS (required for camera + sensor permissions)
- Three.js r140+

### Installation

```bash
npm install webarkit
# or use via CDN
```

```html

import { WebARKit } from './webarkit.js';

```

### Minimal Setup

```javascript
import { WebARKit } from './webarkit.js';
import * as THREE from 'three';

const scene = new THREE.Scene();
const engine = new WebARKit({ scene });

// Load your 3D model
engine.onReady(() => {
engine.loadModel('/my-model.glb').then(model => {
engine.placeOnSurface(model);
});
});

engine.start(); // auto-detects iOS vs WebXR, handles permissions
```

### How It Works on iOS

1. **Camera feed** is captured via `getUserMedia` and composited behind the Three.js canvas.
2. **Gyroscope** (`DeviceOrientationEvent`) drives camera rotation โ€” calibrated at session start.
3. **Visual tracker** (WASM Worker) extracts FAST corners each frame and tracks them across frames using Lucas-Kanade optical flow to estimate camera translation.
4. **Sensor fusion** merges gyro orientation with visual translation into a stable 6DOF pose.
5. **Plane detector** runs RANSAC over tracked point clouds to identify horizontal surfaces and outputs a hit-test equivalent for object placement.
6. **Three.js** renders the 3D scene using the fused camera matrix, pixel-perfectly over the camera feed.

---

## ๐Ÿ“ Project Structure

```
webarkit/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ core/
โ”‚ โ”‚ โ”œโ”€โ”€ WebARKit.js # Main engine class
โ”‚ โ”‚ โ”œโ”€โ”€ ModeRouter.js # XR vs Gyro auto-detection
โ”‚ โ”‚ โ””โ”€โ”€ SessionManager.js # Permission flow
โ”‚ โ”œโ”€โ”€ tracking/
โ”‚ โ”‚ โ”œโ”€โ”€ GyroTracker.js # DeviceOrientation โ†’ quaternion
โ”‚ โ”‚ โ”œโ”€โ”€ VisualTracker.js # WASM optical flow bridge
โ”‚ โ”‚ โ”œโ”€โ”€ SensorFusion.js # Gyro + visual โ†’ 6DOF pose
โ”‚ โ”‚ โ””โ”€โ”€ PlaneDetector.js # RANSAC surface detection
โ”‚ โ”œโ”€โ”€ wasm/
โ”‚ โ”‚ โ”œโ”€โ”€ fast_corners.cpp # FAST feature detector (C++)
โ”‚ โ”‚ โ”œโ”€โ”€ lk_tracker.cpp # Lucas-Kanade tracker (C++)
โ”‚ โ”‚ โ””โ”€โ”€ build.sh # Emscripten build script
โ”‚ โ”œโ”€โ”€ rendering/
โ”‚ โ”‚ โ”œโ”€โ”€ CameraOverlay.js # Camera feed compositor
โ”‚ โ”‚ โ”œโ”€โ”€ Reticle.js # Surface indicator
โ”‚ โ”‚ โ””โ”€โ”€ AvatarLoader.js # GLB/FBX + animation
โ”‚ โ””โ”€โ”€ ui/
โ”‚ โ”œโ”€โ”€ LoadingUI.js
โ”‚ โ”œโ”€โ”€ StatusUI.js
โ”‚ โ””โ”€โ”€ VoiceChat.js
โ”œโ”€โ”€ demo/
โ”‚ โ”œโ”€โ”€ index.html
โ”‚ โ””โ”€โ”€ avatar-demo.js
โ”œโ”€โ”€ tests/
โ””โ”€โ”€ docs/
```

---

## ๐Ÿ—บ Roadmap

### โœ… Phase 1 โ€” Gyro AR (Complete)
- [x] iOS camera feed via `getUserMedia`
- [x] `DeviceOrientationEvent` permission flow (iOS 13+)
- [x] `computeDeviceQuat()` โ€” screen-orientation-corrected quaternion
- [x] Gyro calibration & reset on session start
- [x] SLERP-smoothed camera rotation
- [x] Three.js scene over camera feed
- [x] GLB + FBX avatar loading with animation mixer
- [x] Two-finger rotate gesture
- [x] Single-finger drag (world XZ plane)
- [x] Dual-mode auto-routing (XR / Gyro)
- [x] WebXR hit-test drag (Android Chrome)
- [x] Voice-to-voice AI assistant integration
- [x] Timeline-based animation playback system
- [x] In-scene GLB UI button interaction

---

### ๐Ÿ”„ Phase 2 โ€” Visual Tracking (In Progress)
- [x] Camera frame capture via OffscreenCanvas
- [ ] Web Worker pipeline for off-main-thread processing
- [ ] FAST corner detector (WASM, compiled from C++)
- [ ] Lucas-Kanade optical flow tracker (WASM)
- [ ] Camera translation estimation from tracked points
- [ ] Sensor fusion: gyro orientation + visual translation
- [ ] Drift correction using feature re-detection
- [ ] Pose smoothing & outlier rejection

---

### ๐Ÿ”œ Phase 3 โ€” Plane Detection & True SLAM
- [ ] Point cloud accumulation over time
- [ ] RANSAC-based planar surface fitting
- [ ] Floor / table / wall classification
- [ ] Reticle snapping to detected surface (WebXR hit-test parity)
- [ ] Object placement on real surface (not fixed Z)
- [ ] Surface mesh visualization (optional debug overlay)
- [ ] Multi-plane tracking

---

### ๐Ÿ”ฎ Phase 4 โ€” Advanced Features
- [ ] Monocular depth estimation (TensorFlow.js / ONNX)
- [ ] Occlusion: real objects hiding virtual ones
- [ ] Light estimation from camera feed
- [ ] Image target / marker tracking
- [ ] Persistent world anchors (IndexedDB)
- [ ] Multi-object scene management
- [ ] iOS 18 WebXR support monitoring & auto-migration

---

### ๐Ÿ“ฆ Phase 5 โ€” SDK & Ecosystem
- [ ] Clean public API with TypeScript types
- [ ] npm package `webarkit`
- [ ] React wrapper (`@webarkit/react`)
- [ ] Webpack / Vite plugin
- [ ] Example templates (avatar, furniture, product viewer)
- [ ] Interactive documentation site
- [ ] Performance benchmarks vs 8th Wall / AR.js / Mind-AR

---

## ๐Ÿ“Š Comparison

| | **WebARKit** | 8th Wall | AR.js | Mind-AR |
|---|---|---|---|---|
| iOS Safari | โœ… | โœ… | โš ๏ธ limited | โš ๏ธ limited |
| Surface tracking | โœ… (Phase 3) | โœ… | โŒ | โŒ |
| Open source | โœ… | โŒ | โœ… | โœ… |
| Free | โœ… | โŒ ($) | โœ… | โœ… |
| Three.js native | โœ… | โš ๏ธ wrapper | โš ๏ธ wrapper | โš ๏ธ wrapper |
| No app required | โœ… | โœ… | โœ… | โœ… |
| Voice AI ready | โœ… | โŒ | โŒ | โŒ |

---

## ๐Ÿง  Technical Notes

### Why not just use a WebXR polyfill?

Existing polyfills (Google's `webxr-polyfill`) handle controller input and basic session management, but **do not implement** `immersive-ar` hit-test or image tracking on iOS โ€” the hard parts. WebARKit implements exactly those missing pieces from scratch.

### Why sensor fusion instead of pure visual SLAM?

Pure visual SLAM is computationally expensive on mobile browsers. Pure gyro drifts. Fusing both gives stable orientation (gyro) with position correction (visual) โ€” the same strategy used in ARCore and ARKit under the hood, adapted for the browser sandbox.

### WASM for performance

Feature detection and optical flow run in a Web Worker using WebAssembly compiled from C++ via Emscripten. This keeps the main thread free for Three.js rendering and maintains 60fps on mid-range iOS hardware.

---

## ๐Ÿค Contributing

Contributions are welcome โ€” especially on the WASM tracker and plane detection modules.

```bash
git clone https://github.com/ehsanwwe/ios-webxr-slam
cd ios-webxr-slam
npm install
npm run dev
```

To build the WASM module:
```bash
cd src/wasm
./build.sh # requires Emscripten SDK
```

Please open an issue before submitting large PRs. See [CONTRIBUTING.md](./CONTRIBUTING.md).

---

## ๐Ÿ‘ค Author

**Ehsan Moradi** โ€” Senior Full-Stack & AI Engineer ยท CTO ยท 20+ years in production software

Specialized in: Real-time graphics ยท AR / SLAM systems ยท AI agents ยท WebGL renderers

- ๐Ÿ”— [LinkedIn](https://www.linkedin.com/in/ehsan-hightech/)
- ๐Ÿ™ [GitHub](https://github.com/ehsanwwe)
- ๐Ÿ“ง ehsan.hightech@gmail.com

> This project grew out of production work building [Mediuty](https://mediuty.com) โ€” an AR virtual makeup platform with a custom real-time rendering engine โ€” where iOS support was a hard requirement with no acceptable commercial solution.

---

## ๐Ÿ“„ License

MIT ยฉ [Ehsan Moradi](https://github.com/ehsanwwe)

---

## ๐Ÿท GitHub Topics

> Add these to your repository Settings โ†’ Topics for maximum discoverability:

`ios` ยท `webxr` ยท `ios-ar` ยท `web-ar` ยท `slam` ยท `augmented-reality` ยท `three-js` ยท `ios-safari` ยท `webxr-ios` ยท `mobile-ar` ยท `gyroscope` ยท `computer-vision` ยท `optical-flow` ยท `wasm` ยท `arkit-web` ยท `webarkit`

---


If this saved you from buying an SDK license, consider giving it a โญ