| 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" data-dojo-config="isDebug: true"></script> |
| 11 | <script type="text/javascript"> |
| 12 | |
| 13 | dojo.require("dojox.gfx3d"); |
| 14 | |
| 15 | var angles = {x: 0, y: 0, z: 0}; |
| 16 | var view = null; |
| 17 | var cube = null; |
| 18 | |
| 19 | function moveMe(){ |
| 20 | var p = dojo.byId("action"); |
| 21 | var m = dojox.gfx3d.matrix; |
| 22 | if(p.value == "Move to Back!"){ |
| 23 | console.debug(p.value); |
| 24 | p.value = "Move to Front!"; |
| 25 | cube.setTransform(m.translate(20, 0, -120)) |
| 26 | }else{ |
| 27 | p.value = "Move to Back!"; |
| 28 | cube.setTransform(m.translate(50, 0, 150)) |
| 29 | } |
| 30 | cube.invalidate(); |
| 31 | view.render(); |
| 32 | }; |
| 33 | |
| 34 | makeObjects = function(){ |
| 35 | var surface = dojox.gfx.createSurface("test", 500, 500); |
| 36 | view = surface.createViewport(); |
| 37 | var c = { bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100} }; |
| 38 | var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}]; |
| 39 | var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}]; |
| 40 | var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}]; |
| 41 | |
| 42 | var m = dojox.gfx3d.matrix; |
| 43 | |
| 44 | view.createEdges(xaxis).setStroke({color: "red", width: 1}); |
| 45 | view.createEdges(yaxis).setStroke({color: "green", width: 1}); |
| 46 | view.createEdges(zaxis).setStroke({color: "blue", width: 1}); |
| 47 | |
| 48 | view.createCube(c) |
| 49 | .setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "blue"}) |
| 50 | .setStroke({color: "black", width: 1}); |
| 51 | |
| 52 | cube = view.createCube(c) |
| 53 | .setTransform(m.translate(50, 50, 150)) |
| 54 | .setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "lime"}) |
| 55 | .setStroke({color: "black", width: 1}); |
| 56 | |
| 57 | var camera = dojox.gfx3d.matrix.normalize([ |
| 58 | m.cameraRotateXg(60), |
| 59 | m.cameraRotateYg(30), |
| 60 | m.cameraTranslate(-200, -300, 0) |
| 61 | ]); |
| 62 | |
| 63 | view.applyCameraTransform(camera); |
| 64 | view.setLights([{direction: {x: 10, y: 7, z: 5}, color: "white"}], |
| 65 | {color:"white", intensity: 2}, "white"); |
| 66 | view.render(); |
| 67 | |
| 68 | // add the click event handler |
| 69 | dojo.connect(dojo.byId("action"), "onclick", moveMe); |
| 70 | }; |
| 71 | |
| 72 | mdebug = function(matrix){ |
| 73 | var m = dojox.gfx3d.matrix.normalize(matrix); |
| 74 | console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx); |
| 75 | console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy); |
| 76 | console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz); |
| 77 | }; |
| 78 | |
| 79 | dojo.addOnLoad(makeObjects); |
| 80 | |
| 81 | </script> |
| 82 | </head> |
| 83 | <body class="tundra"> |
| 84 | <h1>Pilot Test</h1> |
| 85 | <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 |
| 86 | and forth, using this to test <em>dojox.gfx3d.drawer.conservative</em></p> |
| 87 | <input id="action" type="button" value="Move to Back!"/> |
| 88 | |
| 89 | <div id="test" style="width: 500px; height: 500px;"></div> |
| 90 | <p>That's all Folks!</p> |
| 91 | </body> |
| 92 | </html> |