-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
176 lines (152 loc) · 4.35 KB
/
index.html
File metadata and controls
176 lines (152 loc) · 4.35 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>spearwolf/shae-offscreen-canvas playground</title>
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
background-color: #111f21;
color: #f0f0f0;
overflow: hidden;
}
main {
height: 100%;
height: 100dvh;
}
.hello {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 1em;
z-index: 1000;
padding: 0.25em 1em 0.75em;
background-color: rgba(0, 0, 0, 0.5);
margin: 0;
font-size: 11px;
font-weight: 400;
font-family: monospace;
}
.display {
position: relative;
display: flex;
flex-direction: column;
height: 100%;
align-items: center;
justify-content: center;
flex-grow: 1;
}
.display.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.grid .layer {
position: relative;
height: 300px;
}
.stacked .layer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.layer.blur {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.grid .layer.blur {
z-index: 1;
}
.stacked .minimap-layer {
top: 0;
left: auto;
right: 0;
width: 320px;
height: 240px;
max-width: 50%;
max-height: 75%;
animation: moveitx 4s, moveity 3s;
animation-direction: alternate;
animation-iteration-count: infinite;
}
@keyframes moveitx {
from {
right: 0;
}
to {
right: calc(100% - 320px);
}
}
@keyframes moveity {
from {
top: 0;
}
to {
top: calc(100% - 320px);
}
}
</style>
</head>
<body>
<main>
<p class="hello">hello spearwolf/shae-offscreen-canvas ❗</p>
<shae-worker src="src/worker-sample.js"></shae-worker>
<shae-worker local ns=foo src="src/worker-sample.js"></shae-worker>
<shae-ent token="ThreeMultiViewRenderer">
<shae-ent ns="foo" token="ThreeMultiViewRenderer">
<div class="display stacked">
<shae-offscreen-canvas class="layer" pixel-zoom="8" fps="90">
<shae-ent id="layer0" token="test-image-0"></shae-ent>
</shae-offscreen-canvas>
<div class="layer">
<div class="layer blur" id="blur-layer"></div>
<shae-offscreen-canvas class="layer" fps="60" ns="foo">
<shae-ent ns="foo" id="layer1" token="test-image-1"></shae-ent>
</shae-offscreen-canvas>
</div>
<shae-offscreen-canvas class="layer minimap-layer" pixel-zoom="3">
<shae-ent id="layer2" token="cube"></shae-ent>
</shae-offscreen-canvas>
</div>
</shae-ent>
</shae-ent>
</main>
<script type="module" src="src/bundle.js"></script>
<script type="module">
import GUI from 'lil-gui';
const LAYERS = ['layer0', 'layer1', 'layer2'];
const TOKENS = ['test-image-0', 'test-image-1', 'cube'];
const gui = new GUI();
const layers = Object.fromEntries(LAYERS.map((layer) => [layer, document.getElementById(layer)?.getAttribute('token')]));
for (const layer of ['layer0', 'layer1', 'layer2']) {
gui.add(layers, layer, TOKENS).onChange((token) => {
document.getElementById(layer)?.setAttribute('token', token);
});
}
const cfg = {
blur: 0,
};
gui.add(cfg, 'blur', 0, 64, 2)
.name('blur layer0')
.onChange((value) => {
document.getElementById('blur-layer')?.style.setProperty('backdrop-filter', value == 0 ? 'none' : `blur(${value}px)`);
});
const LAYOUTS = ['stacked', 'grid'];
gui.add({ layout: 'stacked' }, 'layout', LAYOUTS)
.name('layout')
.onChange((value) => {
const el = document.querySelector('.display');
el.classList.remove(...LAYOUTS);
el.classList.add(value);
});
</script>
</body>
</html>