-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
104 lines (103 loc) · 3.99 KB
/
index.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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Space Shooter</title>
<link rel="stylesheet" href="TemplateData/style.css">
<link rel="shortcut icon" href="TemplateData/favicon.ico" />
<script src="TemplateData/UnityProgress.js"></script>
</head>
<body class="template">
<p class="header"><span>Unity WebGL Player | </span>Space Shooter</p>
<div class="template-wrap clear">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="900px" width="600px"></canvas>
<div class="logo"></div>
<div class="fullscreen"><img src="TemplateData/fullscreen.png" width="38" height="38" alt="Fullscreen" title="Fullscreen" onclick="SetFullscreen(1);" /></div>
<div class="title">Space Shooter</div>
</div>
<p class="footer">« created with <a href="http://unity3d.com/" title="Go to unity3d.com">Unity</a> »</p>
<script type='text/javascript'>
// connect to canvas
var Module = {
filePackagePrefixURL: "Release/",
memoryInitializerPrefixURL: "Release/",
preRun: [],
postRun: [],
print: (function() {
return function(text) {
console.log (text);
};
})(),
printErr: function(text) {
console.error (text);
},
canvas: document.getElementById('canvas'),
progress: null,
setStatus: function(text) {
if (this.progress == null)
{
if (typeof UnityProgress != 'function')
return;
this.progress = new UnityProgress (canvas);
}
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.text) return;
this.progress.SetMessage (text);
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
if (m)
this.progress.SetProgress (parseInt(m[2])/parseInt(m[4]));
if (text === "")
this.progress.Clear()
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading (0.0/1)');
</script>
<script src="Release/UnityConfig.js"></script>
<script src="Release/fileloader.js"></script>
<script>if (!(!Math.fround)) {
var script = document.createElement('script');
script.src = "Release/Space_Shooter.js";
document.body.appendChild(script);
} else {
var codeXHR = new XMLHttpRequest();
codeXHR.open('GET', 'Release/Space_Shooter.js', true);
codeXHR.onload = function() {
var code = codeXHR.responseText;
if (!Math.fround) {
try {
console.log('optimizing out Math.fround calls');
var m = /var ([^=]+)=global\.Math\.fround;/.exec(code);
var minified = m[1];
if (!minified) throw 'fail';
var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS');
var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS');
var asm = code.substring(startAsm, endAsm);
do {
var moar = false; // we need to re-do, as x(x( will not be fixed
asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' });
} while (moar);
code = code.substring(0, startAsm) + asm + code.substring(endAsm);
code = code.replace("'use asm'", "'almost asm'");
} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) }
}
var blob = new Blob([code], { type: 'text/javascript' });
codeXHR = null;
var src = URL.createObjectURL(blob);
var script = document.createElement('script');
script.src = URL.createObjectURL(blob);
script.onload = function() {
URL.revokeObjectURL(script.src);
};
document.body.appendChild(script);
};
codeXHR.send(null);
}
</script>
</body>
</html>