about me:
Front End & JavaScript Specialist
Co-founder & CTO Nau Studio
Lecturer at NordicCoder.com
Website: int3ractive.com
Github, Twitter, Facebook: @trongthanh
HTML5 and Canvas 2D
first iPhone and
smartphone revolution
Three.js
WebGL and Canvas 3D
DeviceOrientation Event and other device API
Google cardboard and VR on the phone
WebVR API
ARKit on iOS 11+ and ARCore on Android 7+
Next generation augmented reality
How AR.js work?
Marker detection by emscripten ARtoolkit. 3D rendering by three.js
Sample code: detect and init
class App {
...
async init() {
if (navigator.xr && XRSession.prototype.requestHitTest) {
try {
this.device = await navigator.xr.requestDevice();
} catch (e) {
this.onNoXRDevice();
return;
}
} else {
this.onNoXRDevice();
return;
}
...
}
}
Sample code: start XRSession
class App {
...
async onEnterAR() {
const outputCanvas = document.createElement('canvas');
const ctx = outputCanvas.getContext('xrpresent');
const session = await this.device.requestSession({
outputContext: ctx,
environmentIntegration: true,
});
document.body.appendChild(outputCanvas);
this.onSessionStarted(session);
}
}
Placing object in real world: WebXR Hit Test
"Always bet on the Web"
- Thanh Tran
Learn more: