topical media & game development

talk show tell print

mobile-query-three-plugins-cannonjs-examples-buble.htm / htm



  <!doctype html><title>Minimal tQuery Page</title>
  <script src="../../../build/tquery-bundle-require.js"></script>
  <script src="../vendor/cannon.js/build/cannon.js"></script>
  <body><script>
  require(['tquery.poolball'], function(){
          var world        = tQuery.createWorld().boilerplate().start();
          
          // put some lights
          tQuery.createAmbientLight().addTo(world).color(0x444444);
          tQuery.createDirectionalLight().addTo(world).position(1,1,1);
  
          // physics world init
          var physWorld        = new CANNON.World();
          physWorld.gravity.set(0,0,0);
          physWorld.broadphase = new CANNON.NaiveBroadphase();
          physWorld.solver.iterations = 25;
  
          // init physics body
          var shape        = new CANNON.Sphere(1);
          var mass        = 1;
          
          var body        = new CANNON.RigidBody(mass,shape);
          physWorld.add(body);
  
          // make body move        
          body.angularVelocity.set(0,0,10);
  
          // create 3d object
          var object	= tQuery.createPoolBall().addTo(world)
          object.get(0).useQuaternion        = true;
  
          //object.addCannonjsPhysics(bodyCannonjs)
          //object.removeCannonjsPhysics()
  
          world.loop().hook(function(delta, now){
                  // Step the physics physWorld
                  physWorld.step(delta);
                  // update 3d object with physics data
                  body.position.copy(object.get(0).position);
                  body.quaternion.copy(object.get(0).quaternion);
          })
  });
  </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.