<!-- /* * 3dhtml Example :: Cube3D * Version 1.0, 20/11/2001 * * Copyright (c) 2001 by Netzministerium.de * Written by Till Nagel and René Sander. * Distributed under the terms of the GNU Lesser General Public. (See licence.txt for details) */ --> <html> <head> <title>3dhtml Example :: Cube3D</title> <!-- helper libs --> <script language="JavaScript" src="../js/LyrObj.js"></script> <!-- core 3dhtml lib --> <script language="JavaScript" src="../js/3dhtml.js"></script> <script language="JavaScript" src="../js/ColorUtil.js"></script> <script language="JavaScript" src="../js/materials.js"></script> <script language="javascript"> <!-- // (c) 2001 Till Nagel, till@netzministerium.de & Rene Sander, rene@netzministerium.de // --------------------------------------------------------------------------- // creates cube model with name and (a simple) material var cubeModel = new Model("cube", new Material("°")); // defines model points. // The model's points have to be defined before the respective code is written into the document. cubeModel.setPoints(createCubeModelPoints()); // --------------------------------------------------------------------------- // the matrix to transform the model with var staticRotationMatrix = new Matrix(); staticRotationMatrix.rotateX(0.05); staticRotationMatrix.rotateY(0.1); // --------------------------------------------------------------------------- function initOnLoad() { fixNetscape(); cubeModel.assignLayers(); // creates and inits matrix to initialize the model var initMatrix = new Matrix(); initMatrix.scale(50, 50, 50); // >> begin to work with the model etc. // initializes model cubeModel.transform(initMatrix); // >> first draw of the model (recommended) cubeModel.draw(); // starts animation animate(); } /* * The main animate method. Calls itself repeatedly. */ function animate() { var delay = 10; // animates cube model ---------------------------------------- // rotates the cube cubeModel.transform(staticRotationMatrix); // updates display cubeModel.draw(); // calls itself with an delay to decouple client computer speed from the animation speed. // result: the animation is as fast as possible. setTimeout("animate()", delay); } // --------------------------------------------------------------------------- function createCubeModelPoints() { // the cube model return new Array( // Point3D( x, y, z, m) new Point3D( 1, 1, 1, 0), new Point3D( 1, 1, -1, 0), new Point3D( 1, -1, 1, 0), new Point3D( 1, -1, -1, 0), new Point3D(-1, 1, 1, 0), new Point3D(-1, 1, -1, 0), new Point3D(-1, -1, 1, 0), new Point3D(-1, -1, -1, 0) ); } // --> </script> </head> <body onload="initOnLoad()" bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0" style="height:100%"> <!-- layer to bugfix netscape --> <div id="fixnetscape" style="position:absolute;visibility:hidden"></div> <script language="JavaScript" type="text/javascript"> <!-- // (c) 2001 Till Nagel, till@netzministerium.de & Rene Sander, rene@netzministerium.de // MANDATORY: INSERTION OF HTML PART INTO PAGE // creates the HTML code representing the model's points // NB: This is written directly into the page from within the method cubeModel.createPointCode(); // --> </script> </body> </html>