SlideShare uma empresa Scribd logo
1 de 41
Créez les interfaces du futur avec les APIs d’aujourd’hui
Je suis web opener chez
Deux interfaces futuristes utilisant des APIs web
+ web sockets + device orientation =




                    + du WebGL!!
server.js
       α, β, ɣ               α, β, ɣ

remote.js                         teapot.js
web sockets
remote.js:
      var websocketServerUrl = 'ws://10.112.0.139:8080/';

      window.addEventListener('DOMContentLoaded', function init() {
        //init websocket connections
        //device orientation sync socket
        var ws = new WebSocket(websocketServerUrl);
        ws.onopen = function() {
          ws.opened = true;
        };

        //listen to device orientation
        window.addEventListener('deviceorientation', function(e) {
          if (ws.opened) {
            ws.send(JSON.stringify({
              alpha: e.alpha,
              beta: e.beta,
              gamma: e.gamma
            }));
          }
        });
      });
server.js:

             // ws server
             var ws = require('websocket-server');
             var wsServer = ws.createServer();

             wsServer.addListener('connection',
             function(connection){
               connection.addListener('message',
             function(msg) {
                 wsServer.broadcast(msg);
               });
             });

             wsServer.listen(8080);
teapot.js:

  window.addEventListener('DOMContentLoaded', function init() {
    //connect to server using websockets
    var ws = new WebSocket('ws://10.112.0.139:8080/');
    ws.onopen = function() {
      ws.onmessage = function(e) {
        var data = JSON.parse(e.data),
            avalue = data.alpha / 180 * Math.PI,
            bvalue = data.beta / 180 * Math.PI,
            gvalue = data.gamma / 180 * Math.PI;
          
          teapot.rotation.set(gvalue, avalue, -bvalue);
       };
     };
  });
socket.io
device orientation
remote.js:

      //listen to device orientation
      window.addEventListener('deviceorientation', function(e) {
        angles.innerHTML = 'alpha: ' + e.alpha + ', beta: ' +
    e.beta + ', gamma: ' + e.gamma;
        if (ws.opened) {
          ws.send(JSON.stringify({
            alpha: e.alpha,
            beta: e.beta,
            gamma: e.gamma
          }));
        }
      });
source: http://lists.w3.org/Archives/Public/
public-geolocation/2012Jun/0000.html                  ↑N                  ↑up                  ↑up
All Android-based test results shown below
were obtained from a
HTC One X running Android 4.0. All iOS-
                                               α                      β                  ɣ
based test results were obtained
from an Apple iPad running iOS 5.1.


                                                          270                   0                      0
       Chrome beta for                             360/0___|___180        -90___|___90       -90/270___|___90
          Android                                           |                   |                       |
                                                           90                   0                     180
                                                        360/0                    0                   0
                                                    270___|___90          -90___|___90         -90___|___90
  FF mobile for Android
                                                          |                      |                   |
                                                         180                 -180/180                0
                                                        0/360                    0                   0
      Opera Mobile for                               90___|___270         -90___|___90         -90___|___90
         Android                                          |                      |                   |
                                                         180                 -180/180                0
                                                          90                    0                    0
                                                    180___|___0/360       -90___|___90         -90___|___90
          Safari for iOS
                                                           |                    |                     |
                                                         270                    0                 -180/180
                                                        0/360                    0                   0
           Specification                              90___|___270         -90___|___90         -90___|___90
                                                          |                      |                   |
                                                         180                 -180/180                0
et tout ça n’est que pour un dispositif!
1. shim: gist.github.com/2966043 (crée par richtr)

2. étalonnage fait à travers d’une UI
WebGL
three.js
// scene size
var WIDTH = 724, HEIGHT = 512;

// get the DOM element to attach to
var container = $('container');

// create a WebGL renderer, set its size and append it to the DOM
var renderer = new THREE.WebGLRenderer();

renderer.setSize(WIDTH, HEIGHT);

renderer.setClearColorHex(0x111111, 1);
renderer.clear();

container.appendChild(renderer.domElement);

// create a scene
var scene = new THREE.Scene();
// camera settings: fov, aspect ratio, near, far
var FOV = 45, ASPECT = WIDTH / HEIGHT, NEAR = 0.1, FAR = 10000;

// create a camera and position camera on z axis (starts at 0,0,0)
var camera = new THREE.PerspectiveCamera( FOV, ASPECT, NEAR, FAR);
camera.position.z = 100;

// add the camera to the scene
scene.add(camera);

// create some lights, position them and add it to the scene
var spotlight = new THREE.SpotLight();
spotlight.position.set( 170, 330, -160 );
scene.add(spotlight);

ambilight = new THREE.AmbientLight(0x333333);
scene.add(ambilight);

//enable shadows on the renderer
renderer.shadowMapEnabled = true;
// add an object (teapot) to the scene
var teapot;

var loader = new THREE.JSONLoader(),
  createScene = function createScene( geometry ) {
      var material = new THREE.MeshFaceMaterial();
      teapot = new THREE.Mesh( geometry, material ); 
      teapot.scale.set(8, 8, 8);   
      teapot.position.set( 0, -10, 0 );
      scene.add( teapot );
      
    console.log('matrix ' + teapot.matrix);
    console.log('rotation ' + teapot.rotation.x);
  };

loader.load('teapot-model.js', createScene );

// draw
renderer.render(scene, camera);
animate();

//animate
function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
}
canvas 2D?
+ getUserMedia =




           + du WebGL!!
getUserMedia
<video id="camera" autoplay></video>


var video = document.getElementById("camera");

navigator.getUserMedia({ video: true }, function(stream) {
    video.src = window.URL.createObjectURL(stream) || stream;
}, function() {
    //error...
});




                ** vous devez ajouter ces deux lignes pour que vôtre code marche dans tous les navigateurs

                navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
                navigator.mozGetUserMedia || navigator.msGetUserMedia;

                window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
headtrackr.js
<canvas id="inputCanvas" width="320" height="240"
style="display:none"></canvas>
<video id="inputVideo" autoplay loop></video>

<script>
  var videoInput = document.getElementById('inputVideo');
  var canvasInput = document.getElementById('inputCanvas');

  var htracker = new headtrackr.Tracker();
  htracker.init(videoInput, canvasInput);
  htracker.start();
</script>
// set up camera controller for head-coupled perspective
headtrackr.controllers.three.realisticAbsoluteCameraControl(
camera, 27, [0,0,50], new THREE.Vector3(0,0,0), {damping : 0.5});

 * @param {THREE.PerspectiveCamera} camera
 * @param {number} scaling size of screen in 3d-model relative to
vertical size of computer screen in real life
 * @param {array} fixedPosition array (x,y,z) w/ the position of
the real life screen in the 3d-model space coordinates
 * @param {THREE.Vector3} lookAt the object/position the camera
should be pointed towards
 * @param {object} params optional object with optional parameters
document.addEventListener('headtrackingEvent', function(event) {
     scene.fog = new THREE.Fog(0x000000,
        1+(event.z*27), 3000+(event.z*27));
}, false);

* x :   position   of head in cm's right of camera as seen from
users   point of   view (see figure)
* y :   position   of head in cm's above camera (see figure)
* z :   position   of head in cm's distance from camera (see figure)
WebGL
three.js
//top wall
plane1 = new THREE.Mesh(new THREE.PlaneGeometry(500, 3000, 5, 15),
   new THREE.MeshBasicMaterial({color: 0xcccccc, wireframe : true }));
plane1.rotation.x = Math.PI/2;
plane1.position.y = 250;
plane1.position.z = 50-1500;
scene.add(plane1);
 var geometry = new THREE.Geometry();
      geometry.vertices.push(
        new THREE.Vertex(new THREE.Vector3(0, 0, -80000)));
      geometry.vertices.push(new THREE.Vertex(
        new THREE.Vector3(0, 0, z)));
      var line = new THREE.Line(geometry,
        new THREE.LineBasicMaterial({color: 0xeeeeee }));
      line.position.x = x;
      line.position.y = y;
      scene.add(line);
github.com/luzc/wiimote



auduno.github.com/
headtrackr/examples/targets.html

github.com/auduno/headtrackr
shinydemos.com/touch-tracker


github.com/operasoftware
@gerbille



github.com/luzc



dev.opera.com

Mais conteúdo relacionado

Semelhante a Des interfaces futuristes utilisant des APIs web

Device dis(orientation)?
Device dis(orientation)?Device dis(orientation)?
Device dis(orientation)?gerbille
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介Justin Lee
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0Takuya Tejima
 
Responsive layouts by Maqbool
Responsive layouts by MaqboolResponsive layouts by Maqbool
Responsive layouts by MaqboolNavin Agarwal
 
2011 05-23 metrics-agilasverige-english
2011 05-23 metrics-agilasverige-english2011 05-23 metrics-agilasverige-english
2011 05-23 metrics-agilasverige-englishMårten Gustafson
 
Android RotateAnimation 簡介
Android RotateAnimation 簡介Android RotateAnimation 簡介
Android RotateAnimation 簡介Chun-Chia Chen
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksCobus Bernard
 
Crush Candy with DukeScript
Crush Candy with DukeScriptCrush Candy with DukeScript
Crush Candy with DukeScriptAnton Epple
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Spike Brehm
 
Svg, canvas e animations in angular (3 maggio 2019)
Svg, canvas e animations in angular (3 maggio 2019)Svg, canvas e animations in angular (3 maggio 2019)
Svg, canvas e animations in angular (3 maggio 2019)Leonardo Buscemi
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMichael Dawson
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsSven Wolfermann
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Matt Raible
 
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Yuji Hato
 
Beauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationBeauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationCodemotion
 

Semelhante a Des interfaces futuristes utilisant des APIs web (20)

Device dis(orientation)?
Device dis(orientation)?Device dis(orientation)?
Device dis(orientation)?
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 
Responsive layouts by Maqbool
Responsive layouts by MaqboolResponsive layouts by Maqbool
Responsive layouts by Maqbool
 
2011 05-23 metrics-agilasverige-english
2011 05-23 metrics-agilasverige-english2011 05-23 metrics-agilasverige-english
2011 05-23 metrics-agilasverige-english
 
Android RotateAnimation 簡介
Android RotateAnimation 簡介Android RotateAnimation 簡介
Android RotateAnimation 簡介
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocks
 
Crush Candy with DukeScript
Crush Candy with DukeScriptCrush Candy with DukeScript
Crush Candy with DukeScript
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
 
Svg, canvas e animations in angular (3 maggio 2019)
Svg, canvas e animations in angular (3 maggio 2019)Svg, canvas e animations in angular (3 maggio 2019)
Svg, canvas e animations in angular (3 maggio 2019)
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive Boston
 
Micro app-framework
Micro app-frameworkMicro app-framework
Micro app-framework
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
 
Beauty Treatment for your Android Application
Beauty Treatment for your Android ApplicationBeauty Treatment for your Android Application
Beauty Treatment for your Android Application
 

Último

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Último (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Des interfaces futuristes utilisant des APIs web

  • 1. Créez les interfaces du futur avec les APIs d’aujourd’hui
  • 2. Je suis web opener chez
  • 3. Deux interfaces futuristes utilisant des APIs web
  • 4. + web sockets + device orientation = + du WebGL!!
  • 5. server.js α, β, ɣ α, β, ɣ remote.js teapot.js
  • 7. remote.js: var websocketServerUrl = 'ws://10.112.0.139:8080/'; window.addEventListener('DOMContentLoaded', function init() {   //init websocket connections   //device orientation sync socket   var ws = new WebSocket(websocketServerUrl);   ws.onopen = function() {     ws.opened = true;   };   //listen to device orientation   window.addEventListener('deviceorientation', function(e) {     if (ws.opened) {       ws.send(JSON.stringify({         alpha: e.alpha,         beta: e.beta,         gamma: e.gamma       }));     }   }); });
  • 8. server.js: // ws server var ws = require('websocket-server'); var wsServer = ws.createServer(); wsServer.addListener('connection', function(connection){   connection.addListener('message', function(msg) {     wsServer.broadcast(msg);   }); }); wsServer.listen(8080);
  • 9. teapot.js: window.addEventListener('DOMContentLoaded', function init() {   //connect to server using websockets   var ws = new WebSocket('ws://10.112.0.139:8080/');   ws.onopen = function() {     ws.onmessage = function(e) {       var data = JSON.parse(e.data),           avalue = data.alpha / 180 * Math.PI,           bvalue = data.beta / 180 * Math.PI,           gvalue = data.gamma / 180 * Math.PI;                  teapot.rotation.set(gvalue, avalue, -bvalue);      };    }; });
  • 10.
  • 13. remote.js:   //listen to device orientation   window.addEventListener('deviceorientation', function(e) {     angles.innerHTML = 'alpha: ' + e.alpha + ', beta: ' + e.beta + ', gamma: ' + e.gamma;     if (ws.opened) {       ws.send(JSON.stringify({         alpha: e.alpha,         beta: e.beta,         gamma: e.gamma       }));     }   });
  • 14.
  • 15. source: http://lists.w3.org/Archives/Public/ public-geolocation/2012Jun/0000.html ↑N ↑up ↑up All Android-based test results shown below were obtained from a HTC One X running Android 4.0. All iOS- α β ɣ based test results were obtained from an Apple iPad running iOS 5.1. 270 0 0 Chrome beta for 360/0___|___180 -90___|___90 -90/270___|___90 Android | | | 90 0 180 360/0 0 0 270___|___90 -90___|___90 -90___|___90 FF mobile for Android | | | 180 -180/180 0 0/360 0 0 Opera Mobile for 90___|___270 -90___|___90 -90___|___90 Android | | | 180 -180/180 0 90 0 0 180___|___0/360 -90___|___90 -90___|___90 Safari for iOS | | | 270 0 -180/180 0/360 0 0 Specification 90___|___270 -90___|___90 -90___|___90 | | | 180 -180/180 0
  • 16. et tout ça n’est que pour un dispositif!
  • 17. 1. shim: gist.github.com/2966043 (crée par richtr) 2. étalonnage fait à travers d’une UI
  • 18. WebGL
  • 20.
  • 21. // scene size var WIDTH = 724, HEIGHT = 512; // get the DOM element to attach to var container = $('container'); // create a WebGL renderer, set its size and append it to the DOM var renderer = new THREE.WebGLRenderer(); renderer.setSize(WIDTH, HEIGHT); renderer.setClearColorHex(0x111111, 1); renderer.clear(); container.appendChild(renderer.domElement); // create a scene var scene = new THREE.Scene();
  • 22. // camera settings: fov, aspect ratio, near, far var FOV = 45, ASPECT = WIDTH / HEIGHT, NEAR = 0.1, FAR = 10000; // create a camera and position camera on z axis (starts at 0,0,0) var camera = new THREE.PerspectiveCamera( FOV, ASPECT, NEAR, FAR); camera.position.z = 100; // add the camera to the scene scene.add(camera); // create some lights, position them and add it to the scene var spotlight = new THREE.SpotLight(); spotlight.position.set( 170, 330, -160 ); scene.add(spotlight); ambilight = new THREE.AmbientLight(0x333333); scene.add(ambilight); //enable shadows on the renderer renderer.shadowMapEnabled = true;
  • 23. // add an object (teapot) to the scene var teapot; var loader = new THREE.JSONLoader(),   createScene = function createScene( geometry ) {       var material = new THREE.MeshFaceMaterial();       teapot = new THREE.Mesh( geometry, material );        teapot.scale.set(8, 8, 8);          teapot.position.set( 0, -10, 0 );       scene.add( teapot );            console.log('matrix ' + teapot.matrix);     console.log('rotation ' + teapot.rotation.x);   }; loader.load('teapot-model.js', createScene ); // draw renderer.render(scene, camera); animate(); //animate function animate() {     requestAnimationFrame(animate);     renderer.render(scene, camera); }
  • 24.
  • 26. + getUserMedia = + du WebGL!!
  • 28. <video id="camera" autoplay></video> var video = document.getElementById("camera"); navigator.getUserMedia({ video: true }, function(stream) {     video.src = window.URL.createObjectURL(stream) || stream; }, function() {     //error... }); ** vous devez ajouter ces deux lignes pour que vôtre code marche dans tous les navigateurs navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  • 29.
  • 31. <canvas id="inputCanvas" width="320" height="240" style="display:none"></canvas> <video id="inputVideo" autoplay loop></video> <script>   var videoInput = document.getElementById('inputVideo');   var canvasInput = document.getElementById('inputCanvas');   var htracker = new headtrackr.Tracker();   htracker.init(videoInput, canvasInput);   htracker.start(); </script>
  • 32. // set up camera controller for head-coupled perspective headtrackr.controllers.three.realisticAbsoluteCameraControl( camera, 27, [0,0,50], new THREE.Vector3(0,0,0), {damping : 0.5}); * @param {THREE.PerspectiveCamera} camera * @param {number} scaling size of screen in 3d-model relative to vertical size of computer screen in real life * @param {array} fixedPosition array (x,y,z) w/ the position of the real life screen in the 3d-model space coordinates * @param {THREE.Vector3} lookAt the object/position the camera should be pointed towards * @param {object} params optional object with optional parameters
  • 33. document.addEventListener('headtrackingEvent', function(event) { scene.fog = new THREE.Fog(0x000000, 1+(event.z*27), 3000+(event.z*27)); }, false); * x : position of head in cm's right of camera as seen from users point of view (see figure) * y : position of head in cm's above camera (see figure) * z : position of head in cm's distance from camera (see figure)
  • 34. WebGL
  • 36. //top wall plane1 = new THREE.Mesh(new THREE.PlaneGeometry(500, 3000, 5, 15), new THREE.MeshBasicMaterial({color: 0xcccccc, wireframe : true })); plane1.rotation.x = Math.PI/2; plane1.position.y = 250; plane1.position.z = 50-1500; scene.add(plane1);
  • 37.  var geometry = new THREE.Geometry();     geometry.vertices.push( new THREE.Vertex(new THREE.Vector3(0, 0, -80000)));     geometry.vertices.push(new THREE.Vertex( new THREE.Vector3(0, 0, z)));     var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0xeeeeee }));     line.position.x = x;     line.position.y = y;     scene.add(line);
  • 38.

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n