-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathexamples.html
More file actions
506 lines (447 loc) · 20.1 KB
/
examples.html
File metadata and controls
506 lines (447 loc) · 20.1 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
<!DOCTYPE html>
<html>
<head>
<title>Spark • Examples</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
:root {
--panel-width: 300px;
--border-style: 4px solid #ab2f3b;
}
body, html {
height: 100%;
width: 100%;
overflow: hidden;
}
body {
margin: 0;
padding: 0;
font-family: "Inter", sans-serif;
font-weight: 300;
}
.mobile-panel {
display: none;
}
.panel {
position: fixed;
z-index: 100;
left: 0px;
width: var(--panel-width);
height: 100%;
border-right: var(--border-style);
display: flex;
flex-direction: column;
transition: 0s 0s height;
background: #D43E4C;
}
.header {
display: flex;
height: 4rem;
align-items: center;
justify-content: center;
padding: 0 1rem;
flex-shrink: 0;
}
.header .logo {
height: 2rem;
padding-bottom: .8rem;
}
.header .title {
color: white;
font-size: 1.0rem;
text-transform: uppercase;
letter-spacing: 0.04rem;
}
.header a, .mobile-header a {
display: flex;
align-items: center;
text-decoration: none;
width: 90px;
}
.header a .logo, .mobile-header a .logo {
height: 1.25rem;
display: block;
}
.examples-container {
flex: 1;
overflow-y: auto;
overflow-x: hidden;
}
.content {
margin-left: var(--panel-width);
width: calc(100% - var(--panel-width));
height: 100%;
position: fixed;
top: 0;
}
.content iframe {
width: 100%;
height: 100%;
border: none;
}
.action-buttons {
position: fixed;
bottom: 16px;
right: 16px;
display: flex;
flex-direction: row;
gap: 12px;
z-index: 999;
}
.action-button {
padding: 12px;
border-radius: 50%;
background-color: #D43E4C;
opacity: .9;
box-shadow: 0 0 4px rgba(0, 0, 0, .15);
text-decoration: none;
transition: opacity 0.2s ease;
}
.action-button:hover {
opacity: 1;
}
.example-link {
display: block;
font-size: 1rem;
padding: 10px 15px;
text-decoration: none;
color: #ffffff;
}
.example-link:hover {
background-color: rgba(0, 0, 0, 0.15);
}
.example-link.active {
background-color: rgba(0, 0, 0, 0.15);
border-left: 4px solid #ffffff;
}
.mobile-header {
display: none;
}
@media screen and (max-width: 768px) {
.panel {
display: none !important;
}
.mobile-header {
display: flex !important;
justify-content: space-between;
align-items: center;
padding: 1rem;
background: #D43E4C;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
height: 2rem;
}
.mobile-header .logo-section {
display: flex;
flex-direction: row;
color: white;
}
.header a, .mobile-header a {
width: 56px;
padding-bottom: 15px;
}
.content {
margin: 0 !important;
padding-top: 4rem !important;
width: 100% !important;
height: calc(100vh - 4rem) !important;
}
.mobile-panel {
display: flex;
position: fixed;
flex-direction: column;
top: 4rem;
right: -100%;
left: auto;
width: 70%;
height: calc(100vh - 4rem);
transform: none;
transition: right 0.3s ease-in-out;
z-index: 1001;
background: #D43E4C;
border-left: var(--border-style);
overflow-y: auto;
}
.mobile-panel.active {
right: 0;
}
.mobile-panel .example-link.active {
border-left: none;
border-right: 4px solid #ffffff;
}
.mobile-panel .header {
display: none;
}
.overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
.overlay.active {
display: block;
}
}
</style>
<script>
const exampleMap = {
'hello-world': '/examples/hello-world/index.html',
'envmap': '/examples/envmap/index.html',
'interactivity': '/examples/interactivity/index.html',
'multiple-splats': '/examples/multiple-splats/index.html',
'multiple-viewpoints': '/examples/multiple-viewpoints/index.html',
'procedural-splats': '/examples/procedural-splats/index.html',
'raycasting': '/examples/raycasting/index.html',
'dynamic-lighting': '/examples/dynamic-lighting/index.html',
'particle-animation': '/examples/particle-animation/index.html',
'particle-simulation': '/examples/particle-simulation/index.html',
'splat-painter': '/examples/splat-painter/index.html',
'splat-reveal-effects': '/examples/splat-reveal-effects/index.html',
'splat-shader-effects': '/examples/splat-shader-effects/index.html',
'splat-dissolve-effects': '/examples/splat-dissolve-effects/index.html',
'splat-transitions': '/examples/splat-transitions/index.html',
'stochastic': '/examples/stochastic/index.html',
'sogs': '/examples/sogs/index.html',
'webxr': '/examples/webxr/index.html',
'glsl': '/examples/glsl/index.html',
'debug-color': '/examples/debug-color/index.html',
'depth-of-field': '/examples/depth-of-field/index.html',
'splat-texture': '/examples/splat-texture/index.html',
'editor': '/examples/editor/index.html'
};
function getExampleFromHash() {
const hash = window.location.hash.substring(1);
return hash || 'hello-world';
}
function setActiveExample(exampleKey) {
const path = exampleMap[exampleKey];
if (!path) return;
const iframe = document.querySelector('.example-frame');
const codeButton = document.querySelector('.code-button');
const fullPageButton = document.querySelector('.fullpage-button');
iframe.src = path;
if (codeButton) {
codeButton.href = `https://github.com/sparkjsdev/spark/blob/main${path}`;
}
if (fullPageButton) {
fullPageButton.href = path;
}
document.querySelectorAll('.example-link').forEach(link => {
link.classList.remove('active');
if (link.getAttribute('data-example') === exampleKey) {
link.classList.add('active');
}
});
if (window.location.hash.substring(1) !== exampleKey) {
history.replaceState(null, null, `#${exampleKey}`);
}
}
function loadExamples() {
const panel = document.querySelector('.panel');
const iframe = document.querySelector('.example-frame');
const actionButtons = document.createElement('div');
actionButtons.classList.add('action-buttons');
const fullPageButton = document.createElement('a');
fullPageButton.classList.add('action-button', 'fullpage-button');
fullPageButton.target = '_blank';
fullPageButton.title = 'Open this example in full page';
fullPageButton.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" style="display:block;">
<path fill="none" stroke="white" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6m10 0l-9 9m3-9h6v6"/>
</svg>
`;
const codeButton = document.createElement('a');
codeButton.classList.add('action-button', 'code-button');
codeButton.target = '_blank';
codeButton.title = 'View source code for this example on GitHub';
codeButton.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" style="display:block;">
<path fill="none" stroke="white" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m9 8l-4 4l4 4m6-8l4 4l-4 4"/>
</svg>
`;
actionButtons.appendChild(fullPageButton);
actionButtons.appendChild(codeButton);
document.body.appendChild(actionButtons);
const initialExample = getExampleFromHash();
setActiveExample(initialExample);
panel.querySelectorAll('.example-link').forEach((link) => {
link.addEventListener('click', (e) => {
e.preventDefault();
const exampleKey = link.getAttribute('data-example');
setActiveExample(exampleKey);
});
});
window.addEventListener('hashchange', () => {
const exampleKey = getExampleFromHash();
setActiveExample(exampleKey);
});
}
function setupMobileMenu() {
const hamburger = document.querySelector('.hamburger');
const panel = document.querySelector('.panel');
const overlay = document.querySelector('.overlay');
const iframe = document.querySelector('.example-frame');
const codeButton = document.querySelector('.code-button');
const mobilePanel = document.createElement('div');
mobilePanel.classList.add('mobile-panel');
const copyLinks = () => {
mobilePanel.innerHTML = '';
const links = panel.querySelectorAll('.example-link');
links.forEach(link => {
const newLink = link.cloneNode(true);
if (link.classList.contains('active')) {
newLink.classList.add('active');
}
mobilePanel.appendChild(newLink);
});
};
copyLinks();
const observer = new MutationObserver(copyLinks);
observer.observe(panel, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });
document.body.appendChild(mobilePanel);
function closeMenu() {
mobilePanel.classList.remove('active');
overlay.classList.remove('active');
}
function openMenu() {
mobilePanel.classList.add('active');
overlay.classList.add('active');
}
hamburger.addEventListener('click', (e) => {
e.stopPropagation();
if (mobilePanel.classList.contains('active')) {
closeMenu();
} else {
openMenu();
}
});
overlay.addEventListener('click', closeMenu);
mobilePanel.addEventListener('click', (e) => {
const link = e.target.closest('.example-link');
if (link) {
e.preventDefault();
const exampleKey = link.getAttribute('data-example');
setActiveExample(exampleKey);
closeMenu();
}
});
}
document.addEventListener('DOMContentLoaded', () => {
loadExamples();
setupMobileMenu();
});
</script>
</head>
<body>
<div class="overlay"></div>
<div class="mobile-header">
<div class="logo-section">
<a class="logo" href="/">
<svg>
<use xlink:href="#spark-logo" />
</svg>
</a>
<!-- <span class="title">EXAMPLES</span> -->
</div>
<div class="hamburger">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 12H21" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M3 6H21" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M3 18H21" stroke="white" stroke-width="2" stroke-linecap="round"/>
</svg>
</div>
</div>
<div class="panel">
<div class="header">
<a class="logo" href="/">
<svg style="width: 100%; height: 100%;">
<use xlink:href="#spark-logo" style="position: absolute; width: 100%; height: 100%;"/>
</svg>
</a>
<span class="title">EXAMPLES</span>
</div>
<div class="examples-container">
<a href="#hello-world" data-example="hello-world" class="example-link">Hello World</a>
<a href="#envmap" data-example="envmap" class="example-link">Environment Map</a>
<a href="#interactivity" data-example="interactivity" class="example-link">Interactivity</a>
<a href="#multiple-splats" data-example="multiple-splats" class="example-link">Multiple Splats</a>
<a href="#multiple-viewpoints" data-example="multiple-viewpoints" class="example-link">Multiple Viewpoints</a>
<a href="#procedural-splats" data-example="procedural-splats" class="example-link">Procedural Splats</a>
<a href="#raycasting" data-example="raycasting" class="example-link">Raycasting</a>
<a href="#dynamic-lighting" data-example="dynamic-lighting" class="example-link">Dynamic Lighting</a>
<a href="#particle-animation" data-example="particle-animation" class="example-link">Particle Animation</a>
<a href="#particle-simulation" data-example="particle-simulation" class="example-link">Particle Simulation</a>
<a href="#splat-painter" data-example="splat-painter" class="example-link">Splat Painter</a>
<a href="#splat-reveal-effects" data-example="splat-reveal-effects" class="example-link">Splat Reveal Effects</a>
<a href="#splat-shader-effects" data-example="splat-shader-effects" class="example-link">Splat Shader Effects</a>
<a href="#splat-dissolve-effects" data-example="splat-dissolve-effects" class="example-link">Splat Dissolve Effects</a>
<a href="#splat-transitions" data-example="splat-transitions" class="example-link">Splat Transitions</a>
<a href="#stochastic" data-example="stochastic" class="example-link">Stochastic splat sorting</a>
<a href="#sogs" data-example="sogs" class="example-link">SOGS Compression</a>
<a href="#webxr" data-example="webxr" class="example-link">WebXR</a>
<a href="#glsl" data-example="glsl" class="example-link">GLSL Shaders</a>
<a href="#debug-color" data-example="debug-color" class="example-link">Debug Coloring</a>
<a href="#depth-of-field" data-example="depth-of-field" class="example-link">Depth of Field</a>
<a href="#splat-texture" data-example="splat-texture" class="example-link">Splat Texture</a>
<a href="#editor" data-example="editor" class="example-link">Editor</a>
</div>
</div>
<div class="content">
<iframe class="example-frame" src=""></iframe>
</div>
<svg style="display: none" xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol id="spark-logo" viewBox="0 0 530 250" fill="none">
<path
d="M40.3564 215.311C45.3883 215.311 49.1623 214.583 51.6782 213.126C54.1942 211.67 55.4521 209.286 55.4521 205.976C55.4521 203.725 54.8563 201.937 53.6645 200.613C52.4727 199.289 50.354 197.964 47.3084 196.64L26.2539 186.907C18.4412 183.332 12.4161 178.565 8.17872 172.606C3.94132 166.647 1.82263 157.974 1.82263 146.586C1.82263 132.02 5.59656 121.162 13.1444 114.011C20.8247 106.728 33.4707 103.02 51.0823 102.888C58.3653 102.888 64.9863 103.219 70.9451 103.881C76.904 104.543 81.671 105.271 85.2463 106.066C88.8216 106.728 90.6093 107.059 90.6093 107.059L86.6367 139.038C86.6367 139.038 84.9815 138.84 81.671 138.442C78.493 138.045 74.5204 137.714 69.7533 137.449C64.9863 137.052 60.3516 136.853 55.8494 136.853C51.0823 136.853 47.4408 137.582 44.9249 139.038C42.5413 140.362 41.3496 142.944 41.3496 146.785C41.3496 148.903 42.2765 150.691 44.1304 152.148C45.9842 153.472 48.5664 154.862 51.8768 156.319L68.7602 163.668C77.7647 167.641 84.3194 172.606 88.4244 178.565C92.5293 184.392 94.5818 192.734 94.5818 203.592C94.5818 218.291 90.7417 229.612 83.0614 237.558C75.3811 245.503 62.7352 249.541 45.1235 249.674C36.3839 249.674 28.2401 249.078 20.6923 247.886C13.1444 246.827 6.45728 245.569 0.630859 244.112L4.60342 212.133C4.60342 212.133 6.19244 212.398 9.37048 212.928C12.6809 213.457 17.0508 213.987 22.4799 214.517C27.9091 215.046 33.8679 215.311 40.3564 215.311Z"
fill="black"
id="path264"
style="fill:#ffffff" />
<path
d="M105.441 247.688L105.283 104.676H151.721C163.639 104.676 173.504 106.331 181.317 109.641C189.13 112.819 194.956 118.248 198.796 125.929C202.636 133.609 204.556 144.07 204.556 157.312C204.556 175.586 200.187 188.761 191.447 196.839C182.707 204.916 169.466 208.955 151.721 208.955H144.174V247.688H105.441ZM144.174 180.551C150.53 180.551 155.231 178.83 158.276 175.387C161.454 171.944 163.043 165.787 163.043 156.915C163.043 150.161 162.447 145.063 161.256 141.62C160.196 138.177 158.276 135.86 155.495 134.668C152.847 133.344 149.073 132.682 144.174 132.682V180.551Z"
fill="black"
id="path266"
style="fill:#ffffff" />
<path
d="M240.887 228.421L237.113 247.688H195.6L226.418 114.017L183.707 76.5293L265.17 96.9426L244.641 123.649L283.517 121.162L310.804 247.688H269.688L265.914 228.421H240.887ZM244.859 197.633H261.743L253.4 145.593L244.859 197.633Z"
fill="black"
id="path268"
style="fill:#ffffff" />
<path
d="M359.88 104.676C371.533 104.676 381.266 106.198 389.079 109.244C396.891 112.157 402.718 117.123 406.558 124.141C410.53 131.027 412.517 140.495 412.517 152.545C412.517 162.609 410.994 170.885 407.948 177.373C404.903 183.729 400.268 188.828 394.044 192.668L418.277 247.688H375.175L359.483 201.209H353.127V247.688H314.395V125.135L341.069 131.557L318.133 104.676H359.88ZM353.127 174.593C359.218 174.593 363.72 173.07 366.634 170.024C369.547 166.978 371.003 161.616 371.003 153.935C371.003 147.844 370.474 143.342 369.414 140.429C368.355 137.383 366.501 135.33 363.853 134.271C361.337 133.212 357.762 132.682 353.127 132.682V174.593Z"
fill="black"
id="path270"
style="fill:#ffffff" />
<path
d="M428.21 104.676H466.942V162.079L488.195 104.676H529.907L503.291 173.997L528.517 247.688H486.805L466.942 187.106V247.688H428.21V104.676Z"
fill="black"
id="path272"
style="fill:#ffffff" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M309.449 81.6439L327.348 19.5389L375.544 0.839203L348.827 48.8799L309.449 81.6439Z"
fill="black"
id="path274"
style="fill:#ffffff" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M268.575 30.8712L282.27 79.3501L253.733 52.8261L268.575 30.8712Z"
fill="black"
id="path276"
style="fill:#ffffff" />
</symbol>
</defs>
<use href="#spark-logo"/>
</svg>
</body>
</html>