topical media & game development

talk show tell print

mobile-query-three-plugins-ogsworkshop-examples-game030.htm / htm



  <!--
          Lets put some shaddow
  -->
  
  <!doctype html><title>Minimal tQuery Page</title>
  <script src="../../../build/tquery-bundle-require.js"></script>
  <body><script>
  require(['tquery.minecraft', 'tquery.skymap', 'tquery.grassground'
          , 'tquery.keyboard'
          , 'tquery.shadowmap'], function(){
          // create world
          var world        = tQuery.createWorld().boilerplate().start();
  
          // add a skybox
          tQuery.createSkymap('skybox').addTo(world);
  
          // add a ground        
          var ground  = tQuery.createGrassGround({
                  textureRepeatX  : 20,
                  textureRepeatY  : 20,
          }).addTo(world)
          .scale(80);
          ground.get(0).material.map.anisotropy = 16;
  
          // add minecraft char
          var character        = tQuery.createMinecraftChar().addTo(world);        
          // ad a keyboard control
          tQuery.createMinecraftCharKeyboard2({
                  object3D        : character.object3D('root'),
                  lateralMove        : 'rotationY'
          });        
  
          // make it run only if it move
          var bodyAnims        = new tQuery.MinecraftCharAnimations(character);        
          var mesh        = character.object3D('root')
          var prevPosition= tQuery.createVector3()
          world.loop().hook(function(){
                  // compute velocity
                  var velocity        = mesh.position().clone().subSelf(prevPosition);
                  // pick animation based
                  if( velocity.length() ){
                          bodyAnims.start('run')
                  }else{
                          bodyAnims.start('stand')
                  }
                  // update player.prevPosition/player.prevRotation
                  prevPosition.copy( mesh.position() )                
          })
  
  

/////////////////////////////////////////////////////////////////

// lights //

/////////////////////////////////////////////////////////////////

// enable shaddow in the renderer world.tRenderer().shadowMapEnabled = true; world.tRenderer().shadowMapSoft = true; tQuery.createDirectionalLight().addTo(world) .position(-1, 2, 3) .color(0xff00ff).intensity(4) .castShadow(true) .shadowDarkness(1) .shadowMap(256,256) //.shadowCamera(8, -8, 8, -8, 0.1, 10) .shadowCamera(2, -2, 8, -8, 0.1, 10) .shadowCameraVisible(true) tQuery('mesh', character.object3D('root')).castShadow(true); ground.receiveShadow(true); }) </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.