examples/3d/js/controls.js
function(event) {
    var touches = event.touches[0];

    // Reset the states.
    this.touchEnd(event);

    // Determine which key to simulate.
    if (touches.pageY < window.innerHeight * 0.3) {
      this.key(true, {keyCode: 38});
    } else if (touches.pageY > window.innerHeight * 0.7) {
      this.key(true, {keyCode: 40});
    } else if (touches.pageX < window.innerWidth * 0.5) {
      this.key(true, {keyCode: 37});
    } else if (touches.pageX > window.innerWidth * 0.5) {
      this.key(true, {keyCode: 39});
    }
  }
function(event) {
    var touches = event.touches[0];

    // Reset the states.
    this.touchEnd(event);

    // Determine which key to simulate.
    if (touches.pageY < window.innerHeight * 0.3) {
      this.key(true, {keyCode: 38});
    } else if (touches.pageY > window.innerHeight * 0.7) {
      this.key(true, {keyCode: 40});
    } else if (touches.pageX < window.innerWidth * 0.5) {
      this.key(true, {keyCode: 37});
    } else if (touches.pageX > window.innerWidth * 0.5) {
      this.key(true, {keyCode: 39});
    }
  }
function ( event ) { var touches = event . touches [ 0 ] ; // Reset the states. this . touchEnd ( event ) ; // Determine which key to simulate. if ( touches . pageY < window . innerHeight * 0.3 ) { this . key ( true , { keyCode : 38 } ) ; } else if ( touches . pageY > window . innerHeight * 0.7 ) { this . key ( true , { keyCode : 40 } ) ; } else if ( touches . pageX < window . innerWidth * 0.5 ) { this . key ( true , { keyCode : 37 } ) ; } else if ( touches . pageX > window . innerWidth * 0.5 ) { this . key ( true , { keyCode : 39 } ) ; } }
Listen for touch events and determine which key to simulate.
@param  {Object} event DOM event data including the position touched.
Listen for touch events and determine which key to simulate .