cm107 commited on
Commit
57ac313
·
1 Parent(s): 28c86c4

Included explaination of controls in index.html.

Browse files

I also added a disclaimer in regards to performance issues.

Files changed (2) hide show
  1. index.html +192 -82
  2. main.css +45 -0
index.html CHANGED
@@ -1,92 +1,202 @@
1
  <!DOCTYPE html>
2
  <html lang="en-us">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
7
- <title>excav_simul_3d</title>
8
- <link rel="shortcut icon" href="TemplateData/favicon.ico">
9
- <link rel="stylesheet" href="TemplateData/style.css">
10
- </head>
11
- <body class="dark">
12
- <div id="unity-container" class="unity-desktop">
13
- <canvas id="unity-canvas"></canvas>
14
- </div>
15
- <div id="loading-cover" style="display:none;">
16
- <div id="unity-loading-bar">
17
- <div id="unity-logo"><img src="logo.png"></div>
18
- <div id="unity-progress-bar-empty" style="display: none;">
19
- <div id="unity-progress-bar-full"></div>
20
- </div>
21
- <div class="spinner"></div>
 
22
  </div>
 
23
  </div>
24
- <div id="unity-fullscreen-button" style="display: none;"></div>
25
- <script>
26
- const hideFullScreenButton = "";
27
- const buildUrl = "Build";
28
- const loaderUrl = buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.loader.js";
29
- const config = {
30
- dataUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.data",
31
- frameworkUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.framework.js",
32
- codeUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.wasm",
33
- streamingAssetsUrl: "StreamingAssets",
34
- companyName: "DefaultCompany",
35
- productName: "excav_simul_3d",
36
- productVersion: "0.1",
37
- };
 
38
 
39
- const container = document.querySelector("#unity-container");
40
- const canvas = document.querySelector("#unity-canvas");
41
- const loadingCover = document.querySelector("#loading-cover");
42
- const progressBarEmpty = document.querySelector("#unity-progress-bar-empty");
43
- const progressBarFull = document.querySelector("#unity-progress-bar-full");
44
- const fullscreenButton = document.querySelector("#unity-fullscreen-button");
45
- const spinner = document.querySelector('.spinner');
46
 
47
- const canFullscreen = (function() {
48
- for (const key of [
49
- 'exitFullscreen',
50
- 'webkitExitFullscreen',
51
- 'webkitCancelFullScreen',
52
- 'mozCancelFullScreen',
53
- 'msExitFullscreen',
54
- ]) {
55
- if (key in document) {
56
- return true;
57
- }
58
  }
59
- return false;
60
- }());
61
-
62
- if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
63
- container.className = "unity-mobile";
64
- config.devicePixelRatio = 1;
65
  }
66
- loadingCover.style.display = "";
 
67
 
68
- const script = document.createElement("script");
69
- script.src = loaderUrl;
70
- script.onload = () => {
71
- createUnityInstance(canvas, config, (progress) => {
72
- spinner.style.display = "none";
73
- progressBarEmpty.style.display = "";
74
- progressBarFull.style.width = `${100 * progress}%`;
75
- }).then((unityInstance) => {
76
- loadingCover.style.display = "none";
77
- if (canFullscreen) {
78
- if (!hideFullScreenButton) {
79
- fullscreenButton.style.display = "";
80
- }
81
- fullscreenButton.onclick = () => {
82
- unityInstance.SetFullscreen(1);
83
- };
 
 
84
  }
85
- }).catch((message) => {
86
- alert(message);
87
- });
88
- };
89
- document.body.appendChild(script);
90
- </script>
91
- </body>
92
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
  <html lang="en-us">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
8
+ <title>excav_simul_3d</title>
9
+ <link rel="shortcut icon" href="TemplateData/favicon.ico">
10
+ <link rel="stylesheet" href="TemplateData/style.css">
11
+ <link rel="stylesheet" href="main.css">
12
+ </head>
13
+
14
+ <body class="dark">
15
+ <div id="unity-container" class="unity-desktop">
16
+ <canvas id="unity-canvas"></canvas>
17
+ </div>
18
+ <div id="loading-cover" style="display:none;">
19
+ <div id="unity-loading-bar">
20
+ <div id="unity-logo"><img src="logo.png"></div>
21
+ <div id="unity-progress-bar-empty" style="display: none;">
22
+ <div id="unity-progress-bar-full"></div>
23
  </div>
24
+ <div class="spinner"></div>
25
  </div>
26
+ </div>
27
+ <div id="unity-fullscreen-button" style="display: none;"></div>
28
+ <script>
29
+ const hideFullScreenButton = "";
30
+ const buildUrl = "Build";
31
+ const loaderUrl = buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.loader.js";
32
+ const config = {
33
+ dataUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.data",
34
+ frameworkUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.framework.js",
35
+ codeUrl: buildUrl + "/SimplifiedTerrain-simpleMovement-demo-webgl-dev.wasm",
36
+ streamingAssetsUrl: "StreamingAssets",
37
+ companyName: "DefaultCompany",
38
+ productName: "excav_simul_3d",
39
+ productVersion: "0.1",
40
+ };
41
 
42
+ const container = document.querySelector("#unity-container");
43
+ const canvas = document.querySelector("#unity-canvas");
44
+ const loadingCover = document.querySelector("#loading-cover");
45
+ const progressBarEmpty = document.querySelector("#unity-progress-bar-empty");
46
+ const progressBarFull = document.querySelector("#unity-progress-bar-full");
47
+ const fullscreenButton = document.querySelector("#unity-fullscreen-button");
48
+ const spinner = document.querySelector('.spinner');
49
 
50
+ const canFullscreen = (function () {
51
+ for (const key of [
52
+ 'exitFullscreen',
53
+ 'webkitExitFullscreen',
54
+ 'webkitCancelFullScreen',
55
+ 'mozCancelFullScreen',
56
+ 'msExitFullscreen',
57
+ ]) {
58
+ if (key in document) {
59
+ return true;
 
60
  }
 
 
 
 
 
 
61
  }
62
+ return false;
63
+ }());
64
 
65
+ if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
66
+ container.className = "unity-mobile";
67
+ config.devicePixelRatio = 1;
68
+ }
69
+ loadingCover.style.display = "";
70
+
71
+ const script = document.createElement("script");
72
+ script.src = loaderUrl;
73
+ script.onload = () => {
74
+ createUnityInstance(canvas, config, (progress) => {
75
+ spinner.style.display = "none";
76
+ progressBarEmpty.style.display = "";
77
+ progressBarFull.style.width = `${100 * progress}%`;
78
+ }).then((unityInstance) => {
79
+ loadingCover.style.display = "none";
80
+ if (canFullscreen) {
81
+ if (!hideFullScreenButton) {
82
+ fullscreenButton.style.display = "";
83
  }
84
+ fullscreenButton.onclick = () => {
85
+ unityInstance.SetFullscreen(1);
86
+ };
87
+ }
88
+ }).catch((message) => {
89
+ alert(message);
90
+ });
91
+ };
92
+ document.body.appendChild(script);
93
+ </script>
94
+ <div id="infoBox">
95
+ <h1>Controls</h1>
96
+ <div id="controls">
97
+ <table>
98
+ <th>Binding</th>
99
+ <th>Description</th>
100
+ <tr>
101
+ <td>Right Mouse Click (Drag)</td>
102
+ <td>
103
+ Rotates the camera in the direction of the mouse drag.
104
+ </td>
105
+ </tr>
106
+ <tr>
107
+ <td>Left Mouse Click</td>
108
+ <td>
109
+ Sets the goal point to the location on the terrain where you clicked.
110
+ </td>
111
+ </tr>
112
+ <tr>
113
+ <td>W</td>
114
+ <td>
115
+ Move forward.
116
+ </td>
117
+ </tr>
118
+ <tr>
119
+ <td>S</td>
120
+ <td>
121
+ Move backward.
122
+ </td>
123
+ </tr>
124
+ <tr>
125
+ <td>A</td>
126
+ <td>
127
+ Move left.
128
+ </td>
129
+ </tr>
130
+ <tr>
131
+ <td>D</td>
132
+ <td>
133
+ Move right.
134
+ </td>
135
+ </tr>
136
+ <tr>
137
+ <td>R</td>
138
+ <td>
139
+ Restart the episode.
140
+ Note that the terrain does not change even if you are in random mode.
141
+ Deformations to the terrain are preserved as well.
142
+ </td>
143
+ </tr>
144
+ <tr>
145
+ <td>1</td>
146
+ <td>
147
+ <div class="cellHeader">Terrain Mode: RANDOM</div>
148
+ Restart with a random terrain shape (no perlin noise).
149
+ </td>
150
+ </tr>
151
+ <tr>
152
+ <td>2</td>
153
+ <td>
154
+ <div class="cellHeader">Terrain Mode: RANDOM_NOISE</div>
155
+ Restart with a random terrain shape (with perlin noise).
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td>3</td>
160
+ <td>
161
+ <div class="cellHeader">Terrain Mode: GAUSSIAN_SLOPE</div>
162
+ Restart with a gaussian slope shaped terrain.
163
+ </td>
164
+ </tr>
165
+ <tr>
166
+ <td>4</td>
167
+ <td>
168
+ <div class="cellHeader">Terrain Mode: POINTY_GAUSSIAN_SLOPE</div>
169
+ Restart with a <i>pointy</i> gaussian slope shaped terrain.
170
+ </td>
171
+ </tr>
172
+ <tr>
173
+ <td>5</td>
174
+ <td>
175
+ <div class="cellHeader">Terrain Mode: TRAPEZOIDAL_HILL</div>
176
+ Restart with a trapezoidal hill shaped terrain.
177
+ </td>
178
+ </tr>
179
+ </table>
180
+ </div>
181
+ <h1>Disclaimer</h1>
182
+ <div id="disclaimerBody">
183
+ <p>
184
+ <a href="https://docs.unity3d.com/Packages/[email protected]/manual/index.html#inference">
185
+ Unfortunately, MLAgents doesn't support GPU inference for WebGL builds.
186
+ </a><br>
187
+ The current model is small enough that it runs smoothly with GPU
188
+ inference, but large enough that it runs slowly with CPU inference.
189
+ If you would like to receive the latest build on your target platform,
190
+ PM cm107 on huggingface.
191
+ </p>
192
+ <p>
193
+ For more information about WebGL performance considerations, refer to
194
+ <a href="https://docs.unity3d.com/Manual/webgl-performance.html">
195
+ the unity documentation
196
+ </a>.
197
+ </p>
198
+ </div>
199
+ </div>
200
+ </body>
201
+
202
+ </html>
main.css ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #infoBox {
2
+ /* border: 5px solid red; */
3
+ width: 75%;
4
+ margin-left: auto;
5
+ margin-right: auto;
6
+ }
7
+
8
+ #controls {
9
+ margin-left: auto;
10
+ margin-right: auto;
11
+ margin-top: auto;
12
+ margin-bottom: auto;
13
+ justify-content: center;
14
+ justify-items: center;
15
+ }
16
+
17
+ table {
18
+ display: table;
19
+ justify-content: center;
20
+ margin-left: auto;
21
+ margin-right: auto;
22
+ }
23
+
24
+ table,
25
+ th,
26
+ td {
27
+ border: 1px solid;
28
+ border-collapse: collapse;
29
+ }
30
+
31
+ td {
32
+ justify-content: right;
33
+ }
34
+
35
+ .cellHeader {
36
+ display: flex;
37
+ color: purple;
38
+ justify-content: center;
39
+
40
+ }
41
+
42
+ #disclaimerBody {
43
+ color: red;
44
+ margin-left: 30px;
45
+ }