f799bbbedc4419ac9ab02a9746cb53215657ec15.svn-base 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
  2. <head>
  3. <title>Rotate test of dojox.gfx3d.</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <style type="text/css">
  6. @import "../../../dojo/resources/dojo.css";
  7. @import "../../../dijit/tests/css/dijitTests.css";
  8. @import "../../../dijit/themes/tundra/tundra.css";
  9. </style>
  10. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
  11. <script type="text/javascript">
  12. dojo.require("dojox.gfx3d");
  13. var angles = {x: 0, y: 0, z: 0};
  14. var cube = null;
  15. var view = null;
  16. rotate = function(){
  17. var m = dojox.gfx3d.matrix;
  18. if(dojo.byId('rx').checked){
  19. angles.x += 10;
  20. }
  21. if(dojo.byId('ry').checked){
  22. angles.y += 10;
  23. }
  24. if(dojo.byId('rz').checked){
  25. angles.z += 10;
  26. }
  27. var t = m.normalize([
  28. m.cameraRotateXg(angles.x),
  29. m.cameraRotateYg(angles.y),
  30. m.cameraRotateZg(angles.z),
  31. ]);
  32. cube.setTransform(t);
  33. cube.invalidate();
  34. view.render();
  35. }
  36. makeObjects = function(){
  37. var surface = dojox.gfx.createSurface("test", 500, 500);
  38. view = surface.createViewport();
  39. var c = {bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}};
  40. var xaxis = [
  41. {x: 0, y: 0, z: 0},
  42. {x: 200, y: 0, z: 0}
  43. ];
  44. var yaxis = [
  45. {x: 0, y: 0, z: 0},
  46. {x: 0, y: 200, z: 0}
  47. ];
  48. var zaxis = [
  49. {x: 0, y: 0, z: 0},
  50. {x: 0, y: 0, z: 200}
  51. ];
  52. var m = dojox.gfx3d.matrix;
  53. view.createEdges(xaxis).setStroke({color: "red", width: 1});
  54. view.createEdges(yaxis).setStroke({color: "green", width: 1});
  55. view.createEdges(zaxis).setStroke({color: "blue", width: 1});
  56. cube = view.createCube(c).setStroke({color: "lime", width: 1});
  57. var camera = dojox.gfx3d.matrix.normalize([
  58. m.cameraRotateXg(20),
  59. m.cameraRotateYg(30),
  60. m.cameraTranslate(-100, -100, 0)
  61. ]);
  62. view.applyCameraTransform(camera);
  63. view.render();
  64. window.setInterval(rotate, 200);
  65. // add the click event handler
  66. dojo.connect(dojo.byId("conservative"), "onclick", drawWithConservative);
  67. dojo.connect(dojo.byId("chart"), "onclick", drawWithChart);
  68. };
  69. draw = function(title, drawer){
  70. dojo.byId("drawer").innerHTML = title;
  71. view.setDrawer(drawer);
  72. };
  73. drawWithConservative = function(){
  74. draw("Conservative", dojox.gfx3d.drawer.conservative);
  75. };
  76. drawWithChart = function(){
  77. draw("Chart", dojox.gfx3d.drawer.chart);
  78. };
  79. dojo.addOnLoad(makeObjects);
  80. </script>
  81. </head>
  82. <body class="tundra">
  83. <h1>Pilot Test</h1>
  84. <p>There are two drawers(well, the name is quite misleading, it means draw-er) in dojox.gfx3d, conservative and chart:</p>
  85. <ul>
  86. <li><em>conservative</em> drawer is a pessimist, it assumes that the movement, transformation of objects would take a big fat impact to the viewport, so it not only render the modified objects, but also reorder all the underlying 2D shapes and redraw them.</li>
  87. <li> <em>chart</em> drawer is an optimist, it assumes the change of the objects does not take effect on the z-order, this is most likely true in chart application. It only render and then draw the modified objects.</li>
  88. </ul>
  89. <p>The cube is in the center (0, 0, 0): The color of X, Y, Z axes are red, green, blue as the reference. The cube would rotate around X, Y, Z or their combination, it is up to you.</p>
  90. <p>Current Drawer: <strong id="drawer">Conservative</strong></p>
  91. <form>
  92. <input id="conservative" type="button" value="Draw with conservative"/>
  93. <input id="chart" type="button" value="Draw with chart"/><br />
  94. <input id="rx" type="checkbox" name="rotateX" checked="true" value="on"/>
  95. <label for="rx"> Rotate around X-axis</label> <br/>
  96. <input id="ry" type="checkbox" name="rotateY" checked="false" value="off"/>
  97. <label for="ry"> Rotate around Y-axis</label> <br/>
  98. <input id="rz" type="checkbox" name="rotateZ" checked="false" value="off"/>
  99. <label for="rz"> Rotate around Z-axis</label> <br/>
  100. </form>
  101. <div id="test" style="width: 500px; height: 500px;"></div>
  102. <p>That's all Folks!</p>
  103. </body>
  104. </html>