-
Notifications
You must be signed in to change notification settings - Fork 272
/
x3dom_simpleManip.xhtml
67 lines (51 loc) · 1.68 KB
/
x3dom_simpleManip.xhtml
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Simple attribute update</title>
<style>
p.case { clear: both; border-top: 1px solid #888; }
</style>
<link rel="stylesheet" type="text/css" href="x3dom.css" />
</head>
<body>
<h1>Simple attribute update</h1>
<p class="case">
<X3D xmlns="http://www.web3d.org/specifications/x3d-namespace" showStat="false" showLog="false" x="0px" y="0px" width="400px" height="400px" altImg="helloX3D-alt.png">
<Scene>
<Viewpoint position='0 0 10' />
<Shape>
<Appearance>
<Material diffuseColor='1 0 0.5' />
</Appearance>
<Box DEF='box'/>
</Shape>
</Scene>
</X3D>
</p>
<script type="text/javascript"><![CDATA[
var solid = true;
function toggleRendering()
{
var button = document.getElementById("color");
solid = !solid;
if (solid)
button.value = "Blue";
else
button.value = "Red";
var mat = document.getElementsByTagName("Material");
var i = 0, n = mat.length;
var aMat = mat[0];
aMat.setAttribute("diffuseColor", (!solid ? "0 0 1" : "1 0 0"));
return false;
}
]]></script>
<p class="case">
Dynamic material update
<input type="button" id="color" value="Change Color" onclick="toggleRendering();" />
</p>
<script type="text/javascript" src="x3dom.js"></script>
</body>
</html>