-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.html
More file actions
90 lines (76 loc) · 3 KB
/
shell.html
File metadata and controls
90 lines (76 loc) · 3 KB
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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rooms</title>
</head>
<body>
<button id="xr-button" style="z-index:10;position:absolute;top:2%;left:2%" disabled>WebXR or WebGPU not supported</button>
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1
style="position:fixed;height:100%;width:100%;top:0%;left:0%;resize:both;"></canvas>
<template id="main-script">
{{{ SCRIPT }}}
</template>
<script type='text/javascript'>
var Module = {
preRun: [],
postRun: [],
canvas: (function () {
var canvas = document.getElementById('canvas');
// Event handler to resize the canvas when the document view is changed
window.addEventListener('resize', () => {
canvas.clientWidth = window.innerWidth;
canvas.clientHeight = window.innerHeight;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}, false);
return canvas;
})(),
totalDependencies: 0
};
async function onEnginePreInitialized() {
await Promise.resolve( Module.Engine.getInstance() ).then( result => {
if ( !result ) {
console.error( "Module Instance is null" );
}
window.engineInstance = result;
} ).catch( error => {
console.log( error );
});
Promise.resolve( window.engineInstance.setWasmModuleInitialized(true) ).then().catch( error => {
console.log( error );
});
}
function onEngineInitialized() {
var script = document.createElement('script');
script.type = 'module';
script.src = "./script.js";
script.async = false;
document.getElementsByTagName('head')[0].appendChild(script);
}
(async () => {
// Custom for WebGPU
if (!navigator.gpu) {
console.error("Sorry, WebGPU is not supported by your browser.");
const msg = document.createElement("div");
Object.assign(msg.style, {
width: "50%",
fontSize: "36px",
fontWeight: "500",
textAlign: "center",
margin: "0 auto",
marginTop: "25%"
});
msg.innerText = "Sorry, WebGPU is not supported by your browser.";
document.body.appendChild(msg);
return;
} else {
const jsTemplate = document.getElementById("main-script");
const js = jsTemplate.content.cloneNode(true);
document.body.appendChild(js);
}
})();
</script>
</body>
</html>