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