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
|
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
<head>
<title>Scene 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";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
dojo.require("dojox.gfx3d");
var view = null;
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 m = dojox.gfx3d.matrix;
var sc1 = view.createScene();
sc1.createCube(c).setStroke({color: "blue", width: 1});
var sc2 = view.createScene();
sc2.createCube(c).setStroke({color: "red", width: 1}).setFill("lime");
var poly = [{x: 0, y: 0, z: 0}, {x: 0, y: 100, z: 0}, {x: 100, y: 100, z: 0}, {x: 100, y: 0, z: 0}];
sc2.createPolygon(poly)
.setStroke({color: "blue", width: 1})
.setTransform(dojox.gfx3d.matrix.translate(50, 20, 30))
.setFill("yellow");
sc2.setTransform(dojox.gfx3d.matrix.translate(100, 200, 30))
var camera = dojox.gfx3d.matrix.normalize([
m.cameraRotateXg(30),
m.cameraRotateYg(60),
m.cameraTranslate(0, 0, 0)
]);
view.applyCameraTransform(camera);
view.render();
// set up the click handlers.
dojo.connect(dojo.byId("rotate"), "onclick", rotate);
};
rotate = function() {
view.applyCameraTransform(dojox.gfx3d.matrix.rotateXg(10));
view.invalidate();
view.render();
};
dojo.addOnLoad(makeObjects);
</script>
</head>
<body>
<h1>Scene Test</h1>
<p>Test the setTransform of the Scene. the lime cube and yellow polygon are grouped in one Scene, and they are moved in one shot.</p>
<p>Test Viewport.invalidate with Scene. <input id="rotate" type="button" value="Rotate around Z-Axis"/></p>
<div id="test" style="width: 500px; height: 500px;"></div>
<p>That's all Folks!</p>
</body>
</html>
|