Fivos Doganis | fivos.doganis@gmail.com
Marker Based GPS based Works on desktop with webcams Works on old smartphones
<script src='vendor/three.js/build/three.min.js'></script> <script src="vendor/three.js/examples/js/libs/stats.min.js"></script> <script src="../build/ar.js"></script> <script>THREEx.ArToolkitContext.baseURL = '../'</script>
Many (old) examples using AR.js + THREE.js + THREEx
Web development
Technologies: HTML, JS, CSS, WebGL, THREE.js, WebXR
Optional:
sudo apt-get install chromium-browser
sudo apt-get install git git config --global user.name "myusername" git config --global user.email myname@mymailprovider.com
sudo apt update sudo apt install software-properties-common apt-transport-https wget wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" sudo apt install code
Remove GPG warnings
sudo gpgconf --kill dirmngr sudo chown -R $USER:$USER ~/.gnupg
set window.titleBarStyle to custom
need to run a server, like Live Server, or using Python:
$ cd /home/somedir $ python -m SimpleHTTPServer $ python3 -m http.server
Then open http://localhost:8000 in your browser
http://localhost:8000
Alternatives:
<html> <head> <script src="https://aframe.io/releases/1.0.3/aframe.min.js"></script> </head> <body> <a-scene> <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box> <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere> <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane> <a-sky color="#ECECEC"></a-sky> </a-scene> </body> </html>
<html> <head> <title>A-Frame + AR.js</title> <script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script> <script src="https://jeromeetienne.github.io/AR.js/aframe/build/aframe-ar.js"></script> </head> <body> <a-scene embedded arjs="debugUIEnabled:false;"> <a-marker preset="hiro"> <a-box position="0 0.5 0" color="yellow"></a-box> </a-marker> <a-entity camera></a-entity> </a-scene> </body> </html>
<html> <head> <script src='https://cdn.jsdelivr.net/gh/aframevr/aframe@1c2407b26c61958baa93967b5412487cd94b290b/dist/aframe-master.min.js'></script> <script src='../../build/aframe-ar.min.js'></script> </head> <link rel="stylesheet" href="../../src/location-based/stylesheets/index.css"> <!-- Dynamically add places from Javascript --> <script src="./places.js"></script> <body style='margin: 0; overflow: hidden;'> <a-scene cursor='rayOrigin: mouse; fuse: true; fuseTimeout: 0;' raycaster="objects: [gps-entity-place];" vr-mode-ui="enabled: false" embedded arjs='sourceType: webcam; sourceWidth:1280; sourceHeight:960; displayWidth: 1280; displayHeight: 960; debugUIEnabled: false;'> <a-camera gps-camera rotation-reader> </a-camera> </a-scene> </body>
Official A-Frame examples
Lee Stemkoski
FrameVR
related to geolocation and maps
Native AR: ARKit / ARCore WebXR HoloLens
chrome://flags
"caniuse"
WebXR Report
source code
Android
https://aframe.io/blog/webxr-ar-module/ https://glitch.com/edit/#!/xr-spinosaurus
<a-scene> <a-assets timeout="30000"> <a-asset-item id="spinosaurus" src="dino-model.glb"></a-asset-item> </a-assets> <a-camera position="0 1.2 0"></a-camera> <a-entity id="dino" position="-1 0 -3" scale="0.5 0.5 0.5"> <a-entity position="0 2.15 0" rotation="0 55 0" gltf-model="#spinosaurus" animation-mixer shadow="cast: true; receive: false"></a-entity> </a-entity> </a-scene>
iOS
VR only on iOS?
https://webxr-ios.webxrexperiments.com/ https://blog.mozvr.com/responsive-webxr-a-painter-xr/
Native + Web
API overview using pseudo-code
isSessionSupported(‘immersive-ar’); // RequestSession on Button press navigator.xr.requestSession // Add listener for ARButton Press // Request reference spaces localReferenceSpace = await session.requestReferenceSpace(‘local'); viewerReferenceSpace = await session.requestReferenceSpace(‘viewer'); // Request hitTest session.requestHitTestSource // RequestAnimationFrame // NOTE: THREE.js must use renderer.setAnimationLoop // instead of window.requestAnimationFrame // Or else use session.requestAnimationFrame(render)
// On each Draw // Callback on every draw, with an XRFrame const render = (t, frame) => { const pose = frame.getViewerPose(localReferenceSpace); frame.getPose(localReferenceSpace, viewerReferenceSpace).transform.matrix const hitTestResults = frame.getHitTestResults( hitTestSource ); const hit = hitTestResults[ 0 ]; reticle.matrix.fromArray( hit.getPose(viewerReferenceSpace ).transform.matrix ); }
Example: https://github.com/mrdoob/three.js/blob/master/examples/webxr_ar_cones.html
// Get hand, controller, or phone controller = renderer.xr.getController( 0 ); // See also selectstart, selectend, squeeze etc. controller.addEventListener( 'select', onSelect ); scene.add( controller ); // Before rendering, update the controller, and apply position to mesh (in meters) mesh.position.set( 0, 0, - 0.3 ).applyMatrix4( controller.matrixWorld );
npm install
npm run build
Port your THREE.js project to use the real world!
http://webglworkshop.com/presentations/Workshop31-ar-vr.html#/21
https://webxr.io/webar-playground/
http://learningthreejs.com/blog/2015/07/16/hatsune-miku-dancing-in-augmented-reality/
http://studioknol.com/phase-two-building-with-virtuality/
https://github.com/rodrigocam/ar-gif https://github.com/XingMeansOK/slamjs_samples (RGBD)
https://medium.com/arjs/webar-playground-ar-in-a-few-clicks-67a08cfb1534
https://blog.halolabs.io/building-ar-vr-with-javascript-and-html-97af4434bcf6
https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/augmented-reality/
**************************
See Readme / TODO