»
AnglaisFran�aisVietnamien

Imprimer - 3D auto-renouvelable cube - JavaScriptBank.com

Version compl�te: jsB@nk » 3D » 3D auto-renouvelable cube
URL: https://www.javascriptbank.com/3d-self-revolving-cube.html

3D auto-renouvelable cube © JavaScriptBank.comIl s'agit d'un cube en trois dimensions la filature. Huit points tourner par lui-même pour créer un cube dynamiques.

Version compl�te: jsB@nk » 3D » 3D auto-renouvelable cube
URL: https://www.javascriptbank.com/3d-self-revolving-cube.html



JavaScript
<SCRIPT language=javascript>/*     This script downloaded from www.JavaScriptBank.com     Come to view and download over 2000+ free javascript at www.JavaScriptBank.com*/<!-- // (c) 2001 Till Nagel, [email protected] & Rene Sander, [email protected]// ---------------------------------------------------------------------------// creates cube model with name and (a simple) materialvar cubeModel = new Model("cube", new Material("&deg;"));// 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 withvar staticRotationMatrix = new Matrix();staticRotationMatrix.rotateX(0.05);staticRotationMatrix.rotateY(0.1);// ---------------------------------------------------------------------------function initOnLoad() {fixNetscape();// assign layer (only for Netscape 4.x, for all other browsers// this is done automatically when writing the point code)cubeModel.assignLayers();// creates and inits matrix to initialize the modelvar initMatrix = new Matrix();initMatrix.scale(50, 50, 50);// >> begin to work with the model etc.// initializes modelcubeModel.transform(initMatrix);// >> first draw of the model (recommended)cubeModel.draw();// starts animationanimate();}/* * The main animate method. Calls itself repeatedly. */function animate() {var delay = 10;// animates cube model ----------------------------------------// rotates the cubecubeModel.transform(staticRotationMatrix);// updates displaycubeModel.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 modelreturn 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>


HTML
<DIV id=fixnetscape style="POSITION: absolute; VISIBILITY: hidden"></DIV><SCRIPT language=JavaScript type=text/javascript><!-- // (c) 2001 Till Nagel, [email protected] & Rene Sander, [email protected]// 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 methodcubeModel.createPointCode();// --></SCRIPT>


Files
/javascript/3d/js/LyrObj.js/javascript/3d/js/3dhtml.js/javascript/3d/js/ColorUtil.js/javascript/3d/js/materials.js