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