738028bed2baf262f375f4de253e86b73b697549.svn-base 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
  2. <head>
  3. <title>Scene 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. </style>
  9. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
  10. <script type="text/javascript">
  11. dojo.require("dojox.gfx3d");
  12. var view = null;
  13. makeObjects = function(){
  14. var surface = dojox.gfx.createSurface("test", 500, 500);
  15. view = surface.createViewport();
  16. var c = {bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}};
  17. var m = dojox.gfx3d.matrix;
  18. var sc1 = view.createScene();
  19. sc1.createCube(c).setStroke({color: "blue", width: 1});
  20. var sc2 = view.createScene();
  21. sc2.createCube(c).setStroke({color: "red", width: 1}).setFill("lime");
  22. var poly = [{x: 0, y: 0, z: 0}, {x: 0, y: 100, z: 0}, {x: 100, y: 100, z: 0}, {x: 100, y: 0, z: 0}];
  23. sc2.createPolygon(poly)
  24. .setStroke({color: "blue", width: 1})
  25. .setTransform(dojox.gfx3d.matrix.translate(50, 20, 30))
  26. .setFill("yellow");
  27. sc2.setTransform(dojox.gfx3d.matrix.translate(100, 200, 30))
  28. var camera = dojox.gfx3d.matrix.normalize([
  29. m.cameraRotateXg(30),
  30. m.cameraRotateYg(60),
  31. m.cameraTranslate(0, 0, 0)
  32. ]);
  33. view.applyCameraTransform(camera);
  34. view.render();
  35. // set up the click handlers.
  36. dojo.connect(dojo.byId("rotate"), "onclick", rotate);
  37. };
  38. rotate = function() {
  39. view.applyCameraTransform(dojox.gfx3d.matrix.rotateXg(10));
  40. view.invalidate();
  41. view.render();
  42. };
  43. dojo.addOnLoad(makeObjects);
  44. </script>
  45. </head>
  46. <body>
  47. <h1>Scene Test</h1>
  48. <p>Test the setTransform of the Scene. the lime cube and yellow polygon are grouped in one Scene, and they are moved in one shot.</p>
  49. <p>Test Viewport.invalidate with Scene. <input id="rotate" type="button" value="Rotate around Z-Axis"/></p>
  50. <div id="test" style="width: 500px; height: 500px;"></div>
  51. <p>That's all Folks!</p>
  52. </body>
  53. </html>