-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexamples.js
More file actions
61 lines (50 loc) · 1.81 KB
/
examples.js
File metadata and controls
61 lines (50 loc) · 1.81 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
/**
* @examples
* MATRIX_ENGINE_WGPU EXAMPLE WORKSPACE
*/
// import {loadJamb} from "./examples/load-jamb.js";
import {loadCameraTexture} from "./examples/camera-texture.js";
import {loadGLBLoader} from "./examples/glb-loader.js";
import {loadObjFile} from "./examples/load-obj-file.js";
import {loadObjsSequence} from "./examples/load-objs-sequence.js";
import {physicsPlayground} from "./examples/physics-playground.js";
import {loadVideoTexture} from "./examples/video-texture.js";
import {byId, urlQuery} from "./src/engine/utils.js";
window.urlQ = urlQuery;
if('serviceWorker' in navigator) {
if(location.hostname.indexOf('localhost') == -1) {
navigator.serviceWorker.register('cache.js');
}
}
// A helper function to change the demo without breaking the URL
const switchDemo = (id) => {
const url = new URL(window.location.href);
url.searchParams.set('demo', id);
window.location.href = url.toString();
// Setting href automatically triggers the reload with the new param
};
// Demo 1
byId('loadObjFile').addEventListener("click", () => switchDemo('1'));
// Demo 2
byId('physicsPlayground').addEventListener("click", () => switchDemo('2'));
// Demo 3
byId('camera-texture').addEventListener("click", () => switchDemo('3'));
// Demo 4
byId('video-texture').addEventListener("click", () => switchDemo('4'));
// Demo 5 - Fixed ID
byId('objs-anim').addEventListener("click", () => switchDemo('5'));
// Demo 6 - Fixed ID
byId('glb-loader').addEventListener("click", () => switchDemo('6'));
if(urlQ['demo'] === '1') {
loadObjFile();
} else if(urlQ['demo'] === '2') {
physicsPlayground()
} else if(urlQ['demo'] === '3') {
loadCameraTexture();
} else if(urlQ['demo'] === '4') {
loadVideoTexture();
} else if(urlQ['demo'] === '5') {
loadObjsSequence()
} else if(urlQ['demo'] === '6') {
loadGLBLoader();
}