examples/3d/js/controls.js
function() {
  // Define our control key codes and states.
  this.codes = {
    // Arrows
    37: 'left', 39: 'right', 38: 'front', 40: 'back',
    // WASD
    65: 'left', 68: 'right', 87: 'front', 83: 'back',
  };
  this.states = {left: false, right: false, front: false, back: false};

  // Setup the DOM listeners.
  document.addEventListener('keydown', this.key.bind(this, true), false);
  document.addEventListener('keyup', this.key.bind(this, false), false);
  document.addEventListener('touchstart', this.touch.bind(this), false);
  document.addEventListener('touchmove', this.touch.bind(this), false);
  document.addEventListener('touchend', this.touchEnd.bind(this), false);
}
function() {
  // Define our control key codes and states.
  this.codes = {
    // Arrows
    37: 'left', 39: 'right', 38: 'front', 40: 'back',
    // WASD
    65: 'left', 68: 'right', 87: 'front', 83: 'back',
  };
  this.states = {left: false, right: false, front: false, back: false};

  // Setup the DOM listeners.
  document.addEventListener('keydown', this.key.bind(this, true), false);
  document.addEventListener('keyup', this.key.bind(this, false), false);
  document.addEventListener('touchstart', this.touch.bind(this), false);
  document.addEventListener('touchmove', this.touch.bind(this), false);
  document.addEventListener('touchend', this.touchEnd.bind(this), false);
}
function ( ) { // Define our control key codes and states. this . codes = { // Arrows 37 : 'left' , 39 : 'right' , 38 : 'front' , 40 : 'back' , // WASD 65 : 'left' , 68 : 'right' , 87 : 'front' , 83 : 'back' , } ; this . states = { left : false , right : false , front : false , back : false } ; // Setup the DOM listeners. document . addEventListener ( 'keydown' , this . key . bind ( this , true ) , false ) ; document . addEventListener ( 'keyup' , this . key . bind ( this , false ) , false ) ; document . addEventListener ( 'touchstart' , this . touch . bind ( this ) , false ) ; document . addEventListener ( 'touchmove' , this . touch . bind ( this ) , false ) ; document . addEventListener ( 'touchend' , this . touchEnd . bind ( this ) , false ) ; }
Defines and handles the various controls.
Defines and handles the various controls .