How to create an in-browser AR web app with floor detection that works on iOS and Android
Building a Cross-Platform WebAR Demo
I was recently tasked to build a simple web AR prototype. The idea was straightforward: users scan their surroundings, detect a flat surface, and tap to spawn a tree that animates into place. Once placed, they could walk around and view the tree from any angle.
The requirements were clear:
- Plane detection so the tree could be placed naturally in the real world.
- World anchoring so the tree stays fixed in place as you move around it.
- Runs in the browser with no downloads or native apps.
- Cross-platform support for both Android and iOS.
Exploring the Options
Before diving into implementation, I researched the main tools available for WebAR development. Each came with its own tradeoffs.
| AR.js | Description: A veteran of browser-based AR, but focused primarily on marker-based tracking. Pros:
Cons:
Verdict: Good for QR-style projects, but not suitable for my “scan and place” tree demo. |
|---|---|
| Zappar | Description: A commercial WebAR platform with its own SDK and ecosystem. Pros:
Cons:
Verdict: Powerful and reliable, but too heavy and costly for a small demo. |
| 8th Wall | Description: Another commercial WebAR SDK, widely used for branded AR campaigns. Pros:
Cons:
Verdict: Good for commercial projects, but overkill for my lightweight use case and costs a lot. |
| Model Viewer | Description: Google’s <model-viewer> web component for quickly embedding 3D models on the web. Pros:
Cons:
Verdict: Perfect for quick prototypes, but harder to expand for a more complex project. |
| Three.js + WebXR | Description: The most popular WebGL library for rendering 3D in the browser, with WebXR integration for AR features like plane detection and hit testing. Pros:
Cons:
Verdict: Perfect for Android, but left me stranded on iOS. |
The Approach I Took
In the end, I built the demo with Three.js + WebXR. It gave me the flexibility I wanted, let me animate the tree the way I wanted, and ran great on Android. But that left the elephant in the room: iOS does not support WebXR. That meant my demo, built entirely with free tools, was essentially Android-only.
The Workaround: Variant Launch
To solve the iOS problem, I used Variant Launch, which effectively runs the Android version on the Variant Launch viewer through an app clip.
- On Android, the app runs with Three.js + WebXR, with full plane detection and animated placement.
- On iOS, users are redirected to Variant Launch, which handles AR placement reliably within Safari.
This hybrid approach let me keep the flexibility of Three.js on Android while ensuring iOS users weren’t left out and kept the code base the same.
- Reliable across both platforms.
- Still browser-based, no app downloads required.
- Slightly different experiences between Android and iOS.
Final Thoughts
This project was a great reminder of the current state of WebAR:
- Free and open tools are powerful but not cross-platform.
- WebXR works beautifully on Android but is not available on iOS.
- To deliver a working experience everywhere, you need a fallback.
For me, that fallback was Variant Launch. It let me meet all the requirements—plane detection, world anchoring, browser-based access, and cross-platform support—without paying for a commercial SDK. Until Apple supports WebXR in Safari, building cross-platform WebAR means piecing together hybrid solutions like this.
You can try out the demo here: https://artest.codeandvisual.com.au/
(You’ll need to open it up on a mobile device)
Note: This article was written by Darcy, one of our super versatile developers at Code and Visual. He usually specialises in game development but bravely took on the challenge given to him.
Creative Digital Agency
Code and Visual works with clients around Australia to create and build outstanding and accessible digital services. If you want to discus a project contact us now for an initial consultation.
Leave a Reply
You must be logged in to post a comment.