-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
45 lines (40 loc) · 1.22 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
<!-- SPDX-FileCopyrightText: Copyright 2023 Jaswant Panchumarti -->
<!-- SPDX-License-Identifier: BSD-3-Clause -->
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<canvas id="canvas" style="position: absolute; left: 0; top: 0;" tabindex="0"></canvas>
<script type="text/javascript" src="imgui_vtk_app.js"></script>
<script type='text/javascript'>
var Module = {
canvas: (function () {
var canvas = document.getElementById('canvas');
canvas.addEventListener(
"webglcontextlost",
function (e) {
console.error('WebGL context lost. You will need to reload the page.');
e.preventDefault();
},
false
);
return canvas;
})(),
onRuntimeInitialized: function () {
console.log('initialized');
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, 0);
},
};
// Use the export name to instantiate the app
var app = vtkApp(Module);
console.log('App created');
canvas.setAttribute('tabindex', '0'); // needed to put focus on the canvas
canvas.addEventListener('click', () => canvas.focus());
canvas.focus();
</script>
</body>
</html>