d838484f7516f582cc0e76f67e11017865b84a48.svn-base 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
  2. <head>
  3. <title>Camera rotate 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: false"></script>
  11. <script type="text/javascript" src="../object.js"></script>
  12. <script type="text/javascript" src="../scheduler.js"></script>
  13. <script type="text/javascript">
  14. dojo.require("dojox.gfx3d");
  15. var angles = {x: 30, y: 30, z: 0};
  16. var cube = null;
  17. var view = null;
  18. rotate = function() {
  19. var m = dojox.gfx3d.matrix;
  20. if(dojo.byId('rx').checked){
  21. angles.x += 1;
  22. }
  23. if(dojo.byId('ry').checked){
  24. angles.y += 1;
  25. }
  26. if(dojo.byId('rz').checked){
  27. angles.z += 1;
  28. }
  29. var t = m.normalize([
  30. m.cameraTranslate(-300, -200, 0),
  31. m.cameraRotateXg(angles.x),
  32. m.cameraRotateYg(angles.y),
  33. m.cameraRotateZg(angles.z)
  34. ]);
  35. console.debug(t);
  36. view.setCameraTransform(t);
  37. view.render();
  38. }
  39. makeObjects = function(){
  40. var surface = dojox.gfx.createSurface("test", 500, 500);
  41. view = surface.createViewport();
  42. view.setLights([{direction: {x: -10, y: -5, z: 5}, color: "white"}],
  43. {color:"white", intensity: 2}, "white");
  44. var c = {bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100}};
  45. var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}];
  46. var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}];
  47. var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}];
  48. var m = dojox.gfx3d.matrix;
  49. view.createEdges(xaxis).setStroke({color: "red", width: 1});
  50. view.createEdges(yaxis).setStroke({color: "green", width: 1});
  51. view.createEdges(zaxis).setStroke({color: "blue", width: 1});
  52. // setStroke({color: "lime", width: 1}).
  53. cube = view.createCube(c).setFill({ type: "plastic", finish: "dull", color: "lime" });
  54. var camera = dojox.gfx3d.matrix.normalize([
  55. m.cameraTranslate(-300, -200, 0),
  56. m.cameraRotateXg(angles.x),
  57. m.cameraRotateYg(angles.y),
  58. m.cameraRotateZg(angles.z),
  59. ]);
  60. view.applyCameraTransform(camera);
  61. view.render();
  62. window.setInterval(rotate, 50);
  63. };
  64. dojo.addOnLoad(makeObjects);
  65. </script>
  66. </head>
  67. <body class="tundra">
  68. <h1>Camera rotate</h1>
  69. <p>The cube is in the center (0, 0, 0): The color of X, Y, Z axes are red, green, blue. The view renders all the objects
  70. in each frame, the <em>conservative</em> drawer is used.</p>
  71. <form>
  72. <input id="rx" type="checkbox" name="rotateX" checked="true" value="on"/>
  73. <label for="rx"> Rotate around X-axis</label> <br/>
  74. <input id="ry" type="checkbox" name="rotateY" checked="false" value="off"/>
  75. <label for="ry"> Rotate around Y-axis</label> <br/>
  76. <input id="rz" type="checkbox" name="rotateZ" checked="false" value="off"/>
  77. <label for="rz"> Rotate around Z-axis</label> <br/>
  78. </form>
  79. <div id="test" style="width: 500px; height: 500px;"></div>
  80. <p>That's all Folks!</p>
  81. </body>
  82. </html>