topical media & game development

talk show tell print

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



  <!doctype html><title>Minimal tQuery Page</title>
  <script src="../../../build/tquery-bundle.js"></script>
  
  <script src="../csg.js"></script>
  <script src="../ThreeCSG.js"></script>
  <script src="../tquery.geometry.csg.js"></script>
  <script src="../tquery.object3d.csg.js"></script>
  <body><script>
          var world        = tQuery.createWorld().boilerplate().start();
  
  // create cube
          var cube        = tQuery.createCube().geometry().translateX(0.6).back();
          var sphere        = tQuery.createSphere().geometry().translateX(1).back();        
          world.add(cube.subtract(sphere).id('origCube').geometry().center().back());
  
          // NOTE: the api is no good
          // * sphere.subtract(cube) -> tQuery.Object3D ? which material ?
          // * would be better API tho
          //   * in another plugins on top
          // * what about inplace replacement of sphere geometry ?
  
          // perform the operation
          var cube        = tQuery.createCube().geometry().translateX(-0.6).back();
          var geometry        = tQuery.createSphere().geometry().csg('intersect', cube.geometry());
          geometry.toMesh().id('origSphere').translateX(1).addTo(world);
  
          // animate the object
          world.loop().hook(function(delta, now){
                  var angle        = 0.5 * now * Math.PI * 2;
                  tQuery('#origSphere').positionX( 0.6 + (1-Math.sin(angle))/4 );
          });
  </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.