summaryrefslogtreecommitdiffstatshomepage
path: root/includes/js/dojox/gfx3d/tests/test_drawer.html
blob: 3a9af1f30954a2aa27ad7d72933ecac8c49b5d21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Pilot test of dojox.gfx3d.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
	@import "../../../dojo/resources/dojo.css";
	@import "../../../dijit/tests/css/dijitTests.css";
	@import "../../../dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">

dojo.require("dojox.gfx3d");

var angles = {x: 0, y: 0, z: 0};
var view = null;
var cube = null;

function moveMe(){
	var p = dojo.byId("action");
	var m = dojox.gfx3d.matrix;
	if(p.value == "Move to Back!"){
		console.debug(p.value);
		p.value = "Move to Front!";
		cube.setTransform(m.translate(20, 0, -120))
	}else{
		p.value = "Move to Back!";
		cube.setTransform(m.translate(50, 0, 150))
	}
	cube.invalidate();
	view.render();
};

makeObjects = function(){
	var surface = dojox.gfx.createSurface("test", 500, 500);
	view = surface.createViewport();
	var c = { bottom: {x: 0, y: 0, z: 0}, top :{x: 100, y: 100, z: 100} };
	var xaxis = [{x: 0, y: 0, z: 0}, {x: 200, y: 0, z: 0}];
	var yaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 200, z: 0}];
	var zaxis = [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 200}];

	var m = dojox.gfx3d.matrix;

	view.createEdges(xaxis).setStroke({color: "red", width: 1});
	view.createEdges(yaxis).setStroke({color: "green", width: 1});
	view.createEdges(zaxis).setStroke({color: "blue", width: 1});

	view.createCube(c)
		.setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "blue"})
		.setStroke({color: "black", width: 1});

	cube = view.createCube(c)
		.setTransform(m.translate(50, 50, 150))
		.setFill({type: "plastic", finish: dojox.gfx3d.lighting.finish.dull, color: "lime"})
		.setStroke({color: "black", width: 1});

	var camera = dojox.gfx3d.matrix.normalize([
		m.cameraRotateXg(60), 
		m.cameraRotateYg(30),
		m.cameraTranslate(-200, -300, 0)
	]);

	view.applyCameraTransform(camera);
	view.setLights([{direction: {x: 10, y: 7, z: 5}, color: "white"}], 
			{color:"white", intensity: 2}, "white");
	view.render();

	// add the click event handler
	dojo.connect(dojo.byId("action"), "onclick", moveMe);
};

mdebug = function(matrix){
	var m = dojox.gfx3d.matrix.normalize(matrix);
	console.debug("xx: " + m.xx + ", xy: " + m.xy + " | xz:" + m.xz + " | dx:" + m.dx);
	console.debug("yx: " + m.yx + ", yy: " + m.yy + " | yz:" + m.yz + " | dy:" + m.dy);
	console.debug("zx: " + m.zx + ", zy: " + m.zy + " | zz:" + m.zz + " | dz:" + m.dz);
};

dojo.addOnLoad(makeObjects);

</script>
</head>
<body class="tundra">
	<h1>Pilot Test</h1>
	<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
	and forth, using this to test <em>dojox.gfx3d.drawer.conservative</em></p>
	<input id="action" type="button" value="Move to Back!"/>

<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>