18f69299a5c88fcf03c01a97c80ee389ff3beee4.svn-base 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
  2. <head>
  3. <title>Pilot 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 view = null;
  15. var cube = null;
  16. function moveMe(){
  17. var p = dojo.byId("action");
  18. var m = dojox.gfx3d.matrix;
  19. if(p.value == "Move to Back!"){
  20. console.debug(p.value);
  21. p.value = "Move to Front!";
  22. cube.setTransform(m.translate(20, 0, -120))
  23. }else{
  24. p.value = "Move to Back!";
  25. cube.setTransform(m.translate(50, 0, 150))
  26. }
  27. cube.invalidate();
  28. view.render();
  29. };
  30. makeObjects = function(){
  31. var surface = dojox.gfx.createSurface("test", 500, 500);
  32. view = surface.createViewport();
  33. var c = { bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100} };
  34. var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}];
  35. var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}];
  36. var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}];
  37. var m = dojox.gfx3d.matrix;
  38. view.createEdges(xaxis).setStroke({color: "red", width: 1});
  39. view.createEdges(yaxis).setStroke({color: "green", width: 1});
  40. view.createEdges(zaxis).setStroke({color: "blue", width: 1});
  41. view.createCube(c)
  42. .setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "blue"})
  43. .setStroke({color: "black", width: 1});
  44. cube = view.createCube(c)
  45. .setTransform(m.translate(50, 50, 150))
  46. .setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "lime"})
  47. .setStroke({color: "black", width: 1});
  48. var camera = dojox.gfx3d.matrix.normalize([
  49. m.cameraRotateXg(60),
  50. m.cameraRotateYg(30),
  51. m.cameraTranslate(-200, -300, 0)
  52. ]);
  53. view.applyCameraTransform(camera);
  54. view.setLights([{direction: {x: 10, y: 7, z: 5}, color: "white"}],
  55. {color:"white", intensity: 2}, "white");
  56. view.render();
  57. // add the click event handler
  58. dojo.connect(dojo.byId("action"), "onclick", moveMe);
  59. };
  60. mdebug = function(matrix){
  61. var m = dojox.gfx3d.matrix.normalize(matrix);
  62. console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
  63. console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
  64. console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
  65. };
  66. dojo.addOnLoad(makeObjects);
  67. </script>
  68. </head>
  69. <body class="tundra">
  70. <h1>Pilot Test</h1>
  71. <p> The color of X, Y, Z axes are red, green, blue. One cube is in the center (0, 0, 0), click the button to move the other one back
  72. and forth, using this to test <em>dojox.gfx3d.drawer.conservative</em></p>
  73. <input id="action" type="button" value="Move to Back!"/>
  74. <div id="test" style="width: 500px; height: 500px;"></div>
  75. <p>That's all Folks!</p>
  76. </body>
  77. </html>