Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
2
<head>
3
<title>Rotate 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
 
13
dojo.require("dojox.gfx3d");
14
 
15
var angles = {x: 0, y: 0, 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 += 10;
24
	}
25
	if(dojo.byId('ry').checked){
26
		angles.y += 10;
27
	}
28
	if(dojo.byId('rz').checked){
29
		angles.z += 10;
30
	}
31
	var t = m.normalize([
32
		m.cameraRotateXg(angles.x),
33
		m.cameraRotateYg(angles.y),
34
		m.cameraRotateZg(angles.z),
35
	]);
36
	cube.setTransform(t);
37
	cube.invalidate();
38
	view.render();
39
}
40
 
41
makeObjects = function(){
42
	var surface = dojox.gfx.createSurface("test", 500, 500);
43
	view = surface.createViewport();
44
	var c = {bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}};
45
	var xaxis = [
46
		{x: 0, y: 0, z: 0},
47
		{x: 200, y: 0, z: 0}
48
	];
49
 
50
	var yaxis = [
51
		{x: 0, y: 0, z: 0},
52
		{x: 0, y: 200, z: 0}
53
	];
54
 
55
	var zaxis = [
56
		{x: 0, y: 0, z: 0},
57
		{x: 0, y: 0, z: 200}
58
	];
59
 
60
	var m = dojox.gfx3d.matrix;
61
 
62
	view.createEdges(xaxis).setStroke({color: "red",   width: 1});
63
	view.createEdges(yaxis).setStroke({color: "green", width: 1});
64
	view.createEdges(zaxis).setStroke({color: "blue",  width: 1});
65
 
66
	cube = view.createCube(c).setStroke({color: "lime", width: 1});
67
 
68
	var camera = dojox.gfx3d.matrix.normalize([
69
		m.cameraRotateXg(20),
70
		m.cameraRotateYg(30),
71
		m.cameraTranslate(-100, -100, 0)
72
	]);
73
 
74
	view.applyCameraTransform(camera);
75
	view.render();
76
	window.setInterval(rotate, 200);
77
 
78
	// add the click event handler
79
	dojo.connect(dojo.byId("conservative"), "onclick", drawWithConservative);
80
	dojo.connect(dojo.byId("chart"), "onclick", drawWithChart);
81
};
82
 
83
draw = function(title, drawer){
84
	dojo.byId("drawer").innerHTML = title;
85
	view.setDrawer(drawer);
86
};
87
 
88
drawWithConservative = function(){
89
	draw("Conservative", dojox.gfx3d.drawer.conservative);
90
};
91
 
92
drawWithChart = function(){
93
	draw("Chart", dojox.gfx3d.drawer.chart);
94
};
95
 
96
dojo.addOnLoad(makeObjects);
97
 
98
</script>
99
</head>
100
<body class="tundra">
101
	<h1>Pilot Test</h1>
102
	<p>There are two drawers(well, the name is quite misleading, it means draw-er) in dojox.gfx3d, conservative and chart:</p>
103
	<ul>
104
		<li><em>conservative</em> drawer is a pessimist, it assumes that the movement, transformation of objects would take a big fat impact to the viewport, so it not only render the modified objects, but also reorder all the underlying 2D shapes and redraw them.</li>
105
		<li> <em>chart</em> drawer is an optimist, it assumes the change of the objects does not take effect on the z-order, this is most likely true in chart application. It only render and then draw the modified objects.</li>
106
	</ul>
107
	<p>The cube is in the center (0, 0, 0): The color of X, Y, Z axes are red, green, blue as the reference. The cube would rotate around X, Y, Z or their combination, it is up to you.</p>
108
	<p>Current Drawer: <strong id="drawer">Conservative</strong></p>
109
<form>
110
	<input id="conservative" type="button" value="Draw with conservative"/>
111
	<input id="chart" type="button" value="Draw with chart"/><br />
112
	<input id="rx" type="checkbox" name="rotateX" checked="true" value="on"/>
113
	<label for="rx"> Rotate around X-axis</label> <br/>
114
	<input id="ry" type="checkbox" name="rotateY" checked="false" value="off"/>
115
	<label for="ry"> Rotate around Y-axis</label> <br/>
116
	<input id="rz" type="checkbox" name="rotateZ" checked="false" value="off"/>
117
	<label for="rz"> Rotate around Z-axis</label> <br/>
118
</form>
119
 
120
<div id="test" style="width: 500px; height: 500px;"></div>
121
<p>That's all Folks!</p>
122
</body>
123
</html>