-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
200 lines (184 loc) · 8.61 KB
/
example.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<html>
<!--
See http://realism.com/blog/tracking-device-motion for a description of this example.
You will also need to download
* x3dom.js
* x3dom.css
* jQuery.js (any recent version)
to the same directory as this file.
x3dom needs to be at least V1.5. You can get the library at http://x3dom.org/
LICENSE
The MIT License (MIT)
Copyright (c) 2016 DrX3D
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<head>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
<script type="text/javascript" src="x3dom.js"></script>
<link rel='stylesheet' type='text/css' href='x3dom.css'>
<script src="jQuery.js"></script>
<style type='text/css' media='all'>
#goFullScreen {font-size:200%; font-weight:bold; position:absolute; height30px; width:200px; border:1 solid black; background-color:white; border-radius:7px; z-index:2; top:20px; left:20px; text-align:center; padding:10px 0 10px 0; }
</style>
</head>
<body style='width:100%; height:100%; border:0; margin:0; padding:0;'>
<div id='goFullScreen'>Go Full Screen</div>
<x3d id='x3dElement' showStat='false' showLog='false' style='width:100%; height:100%; border:0; margin:0; padding:0;'>
<scene id='scene'>
<!-- set the value of headlight as needed -->
<navigationInfo headlight='TRUE' type='"EXAMINE" "WALK"'></navigationInfo>
<!-- set the value of position as needed to match the scale of the model -->
<viewpoint centerOfRotation='0 0 0' position='0 0 10'></viewpoint>
<background DEF='bgnd' skyColor="0.4 0.4 0.5"></background>
<group id='root' render='true'>
<group DEF='theScene'>
<Transform id='orient-spin' DEF='RotateObjectAlpha' rotation='0 1 0 0' translation='0 0 0'>
<Transform id='orient-tilt' DEF='RotateObjectGamma' rotation='0 1 0 0' translation='0 0 0'>
<Transform id='orient-compass' DEF='RotateObjectBeta' rotation='0 1 0 0' translation='0 0 0'>
<Transform DEF='Reposition' translation='0 0 0'>
<!-- Change the url to correspond to your model's X3D file or uncomment the simple model -->
<Inline url='YourModel.x3d'></Inline>
<!-- Simple model. If you are going to use this, make sure to comment or remove the above Inline node -->
<!--
<Group>
<Transform translation='-2 0 0'>
<Shape>
<Box size='2 2 2'></Box>
<Appearance>
<Material diffuseColor="1 0 0"></Material>
</Appearance>
</Shape>
<Transform translation='0 2 0'>
<Shape>
<Cone heigh='1' bottomRadius='1'></Cone>
<Appearance>
<Material diffuseColor="1 1 0"></Material>
</Appearance>
</Shape>
</Transform>
</Transform>
<Transform translation='2 0 0'>
<Shape>
<Sphere radius='1'></Sphere>
<Appearance>
<Material diffuseColor="0 0 1"></Material>
</Appearance>
</Shape>
</Transform>
<Transform translation='0 0 -3'>
<Shape>
<Cylinder height='2' radius='1'></Cylinder>
<Appearance>
<Material diffuseColor="0 1 0"></Material>
</Appearance>
</Shape>
</Transform>
</Group>
-->
</Transform>
</Transform>
</Transform>
</Transform>
</group>
</group>
<group DEF='left'>
<shape>
<appearance>
<renderedTexture interpupillaryDistance="0.03" id="rtLeft" stereoMode="LEFT_EYE" update='ALWAYS'
dimensions='480 320 4' repeatS='false' repeatT='false'>
<viewpoint USE='vp' containerField='viewpoint'></viewpoint>
<background USE='bgnd' containerField='background'></background>
<group USE='theScene' containerField="scene"></group>
</renderedTexture>
<composedShader>
<field name='tex' type='SFInt32' value='0'></field>
<field name='leftEye' type='SFFloat' value='1'></field>
<shaderPart type='VERTEX'>
attribute vec3 position;
attribute vec2 texcoord;
uniform mat4 modelViewProjectionMatrix;
varying vec2 fragTexCoord;
void main()
{
vec2 pos = sign(position.xy);
fragTexCoord = texcoord;
gl_Position = vec4((pos.x/2.0)-0.5, pos.y, 0.0, 1.0);
}
</shaderPart>
<shaderPart DEF="frag" type='FRAGMENT'>
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D tex;
uniform float leftEye;
varying vec2 fragTexCoord;
void main()
{
gl_FragColor = texture2D(tex, fragTexCoord);
}
</shaderPart>
</composedShader>
</appearance>
<plane solid="false"></plane>
</shape>
</group>
<group DEF='right'>
<shape>
<appearance>
<renderedTexture interpupillaryDistance="0.03" id="rtRight" stereoMode="RIGHT_EYE" update='ALWAYS'
dimensions='480 320 4' repeatS='false' repeatT='false'>
<viewpoint USE='vp' containerField='viewpoint'></viewpoint>
<background USE='bgnd' containerField='background'></background>
<group USE='theScene' containerField="scene"></group>
</renderedTexture>
<composedShader>
<field name='tex' type='SFInt32' value='0'></field>
<field name='leftEye' type='SFFloat' value='0'></field>
<shaderPart type='VERTEX'>
attribute vec3 position;
attribute vec2 texcoord;
uniform mat4 modelViewProjectionMatrix;
varying vec2 fragTexCoord;
void main()
{
vec2 pos = sign(position.xy);
fragTexCoord = texcoord;
gl_Position = vec4((pos.x + 1.0) / 2.0, pos.y, 0.0, 1.0);
}
</shaderPart>
<shaderPart USE="frag" type='FRAGMENT'>
</shaderPart>
</composedShader>
</appearance>
<plane solid="false"></plane>
</shape>
</group>
</scene>
</x3d>
<!--
Load the display.js library and activate the orientation manager (DeviceDisplay). See http://realism.com/blog/tracking-device-motion
for a description of the library interface.
-->
<script type="text/javascript" src="display.js"></script>
<script type="text/javascript">
cb = new DeviceDisplay ('x3dElement', 'orient-compass', 'orient-tilt', 'orient-spin', 'Shapes', true, 'rtLeft', 'rtRight');
document.onload = function() {loadStereographic(cb); fullscreen(cb);};
jQuery("#goFullScreen").click(function() {fullscreen(cb);});
</script>
</body>
</html>