-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex copy.html
76 lines (63 loc) · 2.75 KB
/
index copy.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bevy Compute Shader</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Roboto+Mono&display=swap" rel="stylesheet">
</head>
<body class="color-scheme-home">
<div class="grid">
<div class="main-column">
<span class="nav-links">
<a href="https://alexharding.ooo" class="nice-links">alexharding.ooo</a>
<a href="https://bsky.app/profile/alexharding.bsky.social" class="nice-links">bluesky</a>
</span>
<p>Experiment with compute shader</p>
<div id="wasm-container" tabindex="-1"></div>
<br>
<h2><a href="https://github.com/arcadeperfect/bevy_compute_shader">Github</a></h2>
<br>
<!-- <p>Side project to learn the basics of wgsl and develop a look for my <a href="https://alexharding.ooo/posts/Rustroneer/">main Bevy project</a>.</p> -->
</div>
</div>
<script type="module">
import init from './out/bevy_compute_shader.js';
async function run() {
window.scrollTo(0, 0);
const wasmContainer = document.getElementById('wasm-container');
const observer = new MutationObserver((mutations) => {
for (let mutation of mutations) {
for (let node of mutation.addedNodes) {
if (node.tagName === 'CANVAS') {
node.setAttribute('tabindex', '-1');
const originalFocus = node.focus.bind(node);
node.focus = function() {
const scrollPos = window.scrollY;
originalFocus();
requestAnimationFrame(() => window.scrollTo(0, scrollPos));
};
node.style.width = '100%';
node.style.height = '100%';
wasmContainer.appendChild(node);
observer.disconnect();
}
}
}
});
observer.observe(document.body, { childList: true });
await init();
}
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
if (document.readyState === 'complete') {
run();
} else {
window.addEventListener('load', run);
}
</script>
</body>
</html>