All Projects → AdaRoseCannon → immersive-ar-emulation

AdaRoseCannon / immersive-ar-emulation

Licence: MIT license
A sort-of polyfill to emulate a fake AR environment which can be hit-tested against.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to immersive-ar-emulation

Webxr Emulator Extension
WebXR emulator extension
Stars: ✭ 231 (+788.46%)
Mutual labels:  threejs, ar, webxr
Egjs View3d
Fast & customizable 3D model viewer for everyone
Stars: ✭ 34 (+30.77%)
Mutual labels:  threejs, ar, webxr
Threear
A marker based Augmented Reality library for Three.js
Stars: ✭ 124 (+376.92%)
Mutual labels:  threejs, webxr
Remixvr
RemixVR is a tool for collaboratively building customisable VR experiences.
Stars: ✭ 129 (+396.15%)
Mutual labels:  threejs, webxr
Three.vrcontroller
Support hand controllers for Oculus, Vive, Windows Mixed Reality, Daydream, GearVR, and more by adding VRController to your existing Three.js-based WebVR project.
Stars: ✭ 213 (+719.23%)
Mutual labels:  threejs, webxr
Handy.js
Handy makes defining and recognizing custom hand shapes in WebXR a snap!
Stars: ✭ 76 (+192.31%)
Mutual labels:  threejs, webxr
Wechat Miniprogram Ar 3d
A WeChat MiniProgram 3D that includes a Panorama Viewer and a 3D Viewer using the device orientation control.
Stars: ✭ 80 (+207.69%)
Mutual labels:  threejs, ar
Ar.js
Image tracking, Location Based AR, Marker tracking. All on the Web.
Stars: ✭ 3,048 (+11623.08%)
Mutual labels:  threejs, ar
Webxr Physics
Adds physics to WebXR
Stars: ✭ 18 (-30.77%)
Mutual labels:  threejs, webxr
lvr
👓 Augmented Reality for everyone - Out of the world experiences
Stars: ✭ 92 (+253.85%)
Mutual labels:  threejs, ar
awesome-webxr
All things WebXR.
Stars: ✭ 117 (+350%)
Mutual labels:  ar, webxr
emscripten-webxr
WebXR library for use with Emscripten.
Stars: ✭ 21 (-19.23%)
Mutual labels:  ar, webxr
3dstreet
🚲🚶🚌 Web-based 3D visualization of streets using A-Frame
Stars: ✭ 74 (+184.62%)
Mutual labels:  threejs, webxr
Webxr Handtracking
👐 WebXR hand tracking examples
Stars: ✭ 116 (+346.15%)
Mutual labels:  threejs, webxr
Expo Chroma Key Camera
Live green-screen effect with Expo and THREE.js
Stars: ✭ 28 (+7.69%)
Mutual labels:  threejs, ar
Studio
An authoring platform to build Web Augmented Reality experiences, without coding knowledge
Stars: ✭ 135 (+419.23%)
Mutual labels:  threejs, ar
Ideaspace
😎 Create interactive 3D and VR web experiences for desktop, mobile & VR devices
Stars: ✭ 344 (+1223.08%)
Mutual labels:  threejs, webxr
Troika
A JavaScript framework for interactive 3D and 2D visualizations
Stars: ✭ 342 (+1215.38%)
Mutual labels:  threejs, webxr
spacesvr
A standardized reality for the future of the 3D Web.
Stars: ✭ 135 (+419.23%)
Mutual labels:  threejs, webxr
threelet
Portable 3D/WebXR component based on three.js
Stars: ✭ 38 (+46.15%)
Mutual labels:  threejs, webxr

Immersive AR Emulation for AFRAME & THREE.js

This project is still pretty new and will have lots of issues, it has not been widely tested, pull requests and contributions are very welcome.

ezgif-1-c9a7ac33a76d

WebXR gives you the ability to build Augmented Reality experiences in the Web, both for handsets like phones and headsets. It's very possible to build a single code-path which works well for headsets and handsets without needing to detect which kind of hardware you are using.

Unforunately AR headsets are expensive and hard to access to so many AR experiences only work with handsets either through design or accident.

The other type of head mounted WebXR experience is immersive Virtual Reality. Virtual Reality headsets are cheaper and more widely avaialble than VR headsets so what if you could test Headset Augmented Reality on a VR Headset?

"What if you could test Headset AR on a VR Headset?"

NB: This is not designed for use in production code, this method of modifying the XRFrame is inefficient, and will give you poor performance. This is only for testing the AR path of your WebXR app. If you want to provide users a VR fallback for your XR experience you should have a seperate code path which uses THREE.js' Raycaster when the user is in a VR session.

This is a project designed to allow you to test your immersive-ar session in a VR headset it acts kind of like a polyfill, if immersive-ar is already supported then it does nothing. But if immersive-vr is supported and immersive-ar it will let it work by:

  • In emulated immersive-ar draw a background scene behind your scene
  • Modifying navigator.xr.isSessionSupported to override requests for immersive-ar to let it be allowed.
  • Modifying navigator.xr.requestSession to return an immersive-vr session if an immersive-ar session is requested which has been modified such that:
    • It supports requestHitTestSource by testing against the rendered background scene
    • It modifies requestAnimationFrame so that each XRFrame returned has a replacement getHitTestResults

Installation

There are two methods of installation one, for if you have THREE.JS as a script and one for if you are building with Webpack or Rollup

ThreeJS as a script

<script src="js/three.js"></script>
<script type="module">
import {
	init as initEmulateAR,
	requestSession,
	isSessionSupported,
	renderEnvironment,
	applyImmersiveARProxy,
	sceneModelURL
} from "https://adarosecannon.github.io/immersive-ar-emulation/src/EmulateAR.js";
</script>

With WebPack or Rollup

npm install --save immersive-ar-emulation
import {
	init as initEmulateAR,
	requestSession,
	isSessionSupported,
	renderEnvironment,
	applyImmersiveARProxy,
	sceneModelURL
} from "immersive-ar-emulation";

Usage A-Frame

Demo: A-Frame Demo for this Emulator

Add the EmulateAR.aframe.js BEFORE the AFrame the script.

<script src="../../build/EmulateAR.aframe.js"></script>
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@6e3b6c84391d50b45a1a3e801b74ca9d03ac8c09/dist/aframe-master.min.js"></script>

Then set up AR in A-Frame as usual.

Usage THREE.JS

Unfortunately it does require some integrating into your code, for an example app checkout the demo/ folder of this repo.

Step 1

Import the code as shown above.

Step 2 - Get the environment GLB

You can find the URL of the scene in .glb format to download in sceneModelURL,

Download the model using the ThreeJS GLTF Loader.

Step 3 - Initialise the emulator

Use this model and your scene and renderer to setup the emulator.

const environment = (await loadModel(sceneModelURL)).scene;
initEmulateAR({ renderer, environment });

You can then either apply the immersive-ar proxy to modify to navigator.xr

applyImmersiveARProxy();

but if you prefer to leave it unmodified you can use immersiveARProxyRequired to see if you need to add a button which can call requestSession and isSessionSupported from the emulator yourself.

Step 4 - Add the render hook

It must go before the your render function. It ignores depth and turns off autoclear so it needs to first so that it clears the buffer and renders underneath the rest of your scene.

renderer.setAnimationLoop(function (timestamp, frame) {
	renderEnvironment(camera);
	renderer.render(scene, camera);
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].