This document discusses using sensors and device capabilities with JavaScript. It begins by describing the various sensors available on mobile devices like accelerometers and gyroscopes. It then provides examples of projects that utilize these sensors, such as using the light sensor to control an on-screen music player or tracking device movement to render a 3D model. The document also introduces JanOS, a fork of Firefox OS intended for phones and Raspberry Pi devices that provides access to phone APIs in JavaScript. It encourages attendees to experiment with sensors and think creatively about new uses.
25. Track real life movement
Draw 3D model of phones
Measure gyroscope data
Show real life state on screen
26.
27. Track real life movement
1 var front = new THREE.MeshBasicMaterial({ map: loadTexture('front.jpg') });
2 var back = new THREE.MeshBasicMaterial({ map: loadTexture('back.jpg') });
3 var border = new THREE.MeshBasicMaterial({ color: 0xffe04526 });
4
5 var materials = [ border, border, border,
6 border, front, back ];
7
8 var geometry = new THREE.BoxGeometry(2, 4, 0.3);
9 var cube = new THREE.Mesh(geometry,
10 new THREE.MeshFaceMaterial(materials));
11 scene.add(cube);
28. Track real life movement
1 window.addEventListener('deviceorientation', function(e) {
2 cube.rotation.x = e.beta / 60;
3 cube.rotation.y = e.gamma / 60;
4 cube.rotation.z = e.alpha / 60;
5 });