2150 |
mathias |
1 |
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" >
|
|
|
2 |
<head>
|
|
|
3 |
<title>Scene 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 |
</style>
|
|
|
9 |
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
|
|
|
10 |
<script type="text/javascript">
|
|
|
11 |
|
|
|
12 |
dojo.require("dojox.gfx3d");
|
|
|
13 |
|
|
|
14 |
var view = null;
|
|
|
15 |
|
|
|
16 |
makeObjects = function(){
|
|
|
17 |
var surface = dojox.gfx.createSurface("test", 500, 500);
|
|
|
18 |
view = surface.createViewport();
|
|
|
19 |
var c = {bottom: {x: 0, y: 0, z: 0}, top: {x: 100, y: 100, z: 100}};
|
|
|
20 |
var m = dojox.gfx3d.matrix;
|
|
|
21 |
|
|
|
22 |
var sc1 = view.createScene();
|
|
|
23 |
sc1.createCube(c).setStroke({color: "blue", width: 1});
|
|
|
24 |
|
|
|
25 |
var sc2 = view.createScene();
|
|
|
26 |
sc2.createCube(c).setStroke({color: "red", width: 1}).setFill("lime");
|
|
|
27 |
|
|
|
28 |
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}];
|
|
|
29 |
sc2.createPolygon(poly)
|
|
|
30 |
.setStroke({color: "blue", width: 1})
|
|
|
31 |
.setTransform(dojox.gfx3d.matrix.translate(50, 20, 30))
|
|
|
32 |
.setFill("yellow");
|
|
|
33 |
|
|
|
34 |
sc2.setTransform(dojox.gfx3d.matrix.translate(100, 200, 30))
|
|
|
35 |
|
|
|
36 |
var camera = dojox.gfx3d.matrix.normalize([
|
|
|
37 |
m.cameraRotateXg(30),
|
|
|
38 |
m.cameraRotateYg(60),
|
|
|
39 |
m.cameraTranslate(0, 0, 0)
|
|
|
40 |
]);
|
|
|
41 |
|
|
|
42 |
view.applyCameraTransform(camera);
|
|
|
43 |
view.render();
|
|
|
44 |
|
|
|
45 |
// set up the click handlers.
|
|
|
46 |
dojo.connect(dojo.byId("rotate"), "onclick", rotate);
|
|
|
47 |
};
|
|
|
48 |
|
|
|
49 |
rotate = function() {
|
|
|
50 |
view.applyCameraTransform(dojox.gfx3d.matrix.rotateXg(10));
|
|
|
51 |
view.invalidate();
|
|
|
52 |
view.render();
|
|
|
53 |
};
|
|
|
54 |
|
|
|
55 |
dojo.addOnLoad(makeObjects);
|
|
|
56 |
|
|
|
57 |
</script>
|
|
|
58 |
</head>
|
|
|
59 |
<body>
|
|
|
60 |
<h1>Scene Test</h1>
|
|
|
61 |
<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>
|
|
|
62 |
<p>Test Viewport.invalidate with Scene. <input id="rotate" type="button" value="Rotate around Z-Axis"/></p>
|
|
|
63 |
<div id="test" style="width: 500px; height: 500px;"></div>
|
|
|
64 |
<p>That's all Folks!</p>
|
|
|
65 |
</body>
|
|
|
66 |
</html>
|