-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgllimpx.html
132 lines (117 loc) · 2.9 KB
/
gllimpx.html
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<title>gllimpx</title>
<script type="text/javascript" src="gllimpx.js"></script>
<script type="text/javascript">
var gll = new gllimpx();
var outputCanvas, dragAction;
function initScene(text) {
outputCanvas = document.getElementById("outputCanvas");
dragAction = document.getElementById("dragAction");
gll.parseX3d(text);
gll.setCanvas(outputCanvas);
gll.redrawCanvas();
}
function canvasOnMouseMove(event) {
switch (dragAction.selectedIndex) {
case 0:
gll.rotateOnMouseMove(event);
break;
case 1:
gll.translateOnMouseMove(event);
break;
case 2:
gll.zoomOnMouseMove(event);
break;
}
}
</script>
</head>
<body onload="initScene(controlForm.modelText.value)">
<center><h1>gllimpx</h1></center>
<hr/>
<center>
<canvas id="outputCanvas" style="width:640px;height:480px;border-style:solid;border-width:1px"
onmousedown="gll.onMouseDown(event)"
onmousemove="canvasOnMouseMove(event)"
onmouseup="gll.onMouseUp(event)"
onmouseout="gll.onMouseUp(event)"
>
</canvas>
</center>
<hr/>
<form name="controlForm">
<select id="dragAction">
<option>
Rotate
</option>
<option>
Translate
</option>
<option>
Zoom
</option>
</select>
<input type="button" value="Load" onClick="initScene(modelText.value)"/>
<textarea name="modelText" rows="40" cols="120">
<X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<Scene>
<Transform scale="4 4 4">
<Transform>
<Transform>
<Shape>
<Appearance DEF="Gris">
<Material diffuseColor="0.7 0.7 0.7"/>
</Appearance>
<Cylinder radius="0.1" height="1.0"/>
</Shape>
</Transform>
<Transform translation="0.0 0.6 0.0">
<Shape>
<Appearance DEF="Vert">
<Material diffuseColor="0.6 1.0 0.6"/>
</Appearance>
<Cone height="0.2" bottomRadius="0.2"/>
</Shape>
</Transform>
</Transform>
<Transform rotation="0.0 0.0 1.0 -1.57">
<Transform>
<Shape>
<Appearance USE="Gris"/>
<Cylinder radius="0.1" height="1.0"/>
</Shape>
</Transform>
<Transform translation="0.0 0.6 0.0">
<Shape>
<Appearance DEF="Rouge">
<Material diffuseColor="1.0 0.6 0.6"/>
</Appearance>
<Cone height="0.2" bottomRadius="0.2"/>
</Shape>
</Transform>
</Transform>
<Transform rotation="1.0 0.0 0.0 1.57">
<Transform>
<Shape>
<Appearance USE="Gris"/>
<Cylinder radius="0.1" height="1.0"/>
</Shape>
</Transform>
<Transform translation="0.0 0.6 0.0">
<Shape>
<Appearance DEF="Bleu">
<Material diffuseColor="0.6 0.6 1.0"/>
</Appearance>
<Cone height="0.2" bottomRadius="0.2"/>
</Shape>
</Transform>
</Transform>
</Transform>
</Scene>
</X3D>
</textarea>
</form>
</body>
</html>