topical media & game development

talk show tell print

mobile-query-three-plugins-keyboard-examples-index.htm / htm



  <!doctype html><title>Minimal tQuery Page</title>
  <script src="../../../build/tquery-bundle.js"></script>
  
  <script src="../../../vendor/threex/THREEx.KeyboardState.js"></script>
  <script src="../tquery.keyboard.js"></script>
  <body><script>
          var world        = tQuery.createWorld().boilerplate().start();
          var object3d        = tQuery.createTorus().addTo(world);
          
          // at every frame
          world.loop().hook(function(){
                  if( tQuery.keyboard().pressed('a') ){
                          object3d.scale(2);
                  }else{
                          object3d.scale(1);
                  }
          })
          
          // only on keydown
          var keyboard        = tQuery.keyboard();
          keyboard.domElement().addEventListener('keydown', function(){
                  if( keyboard.pressed('left') )        object3d.rotateX( Math.PI/6)
                  if( keyboard.pressed('right') )        object3d.rotateX(-Math.PI/6)
          });
          
  </script></body>


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.