-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathshell.html
More file actions
101 lines (84 loc) · 3.29 KB
/
shell.html
File metadata and controls
101 lines (84 loc) · 3.29 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
91
92
93
94
95
96
97
98
99
100
101
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>wgpuEngine (Web Build)</title>
<script src="https://mrdoob.github.io/stats.js/build/stats.min.js"></script>
</head>
<body>
<button id="xr-button" style="z-index:10;position:absolute;top:1%;left:30%" disabled>WebXR or WebGPU not supported</button>
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1
style="outline:none;position:absolute;"></canvas>
<template id="main-script">
{{{ SCRIPT }}}
</template>
<style>
html, body, canvas {
margin: 0 !important;
padding: 0 !important;
}
</style>
<script type='text/javascript'>
var Module = {
isHiDPIAware: true,
html5ResizeTarget: "#canvas-area",
preRun: [],
postRun: [],
canvas: (function () {
var canvas = document.getElementById('canvas');
canvas.width = window.innerWidth
canvas.height = window.innerHeight
function scaleCanvas() {
const devicePixelRatio = window.devicePixelRatio;
canvas.style.width = window.innerWidth + "px";
canvas.style.height = window.innerHeight + "px";
canvas.width = window.innerWidth * devicePixelRatio
canvas.height = window.innerHeight * devicePixelRatio
}
// Event handler to resize the canvas when the document view is changed
window.addEventListener('resize', scaleCanvas, 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() {
}
(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>