-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
111 lines (97 loc) · 3.81 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>AR with sound</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- The following libraries and polyfills are recommended to maximize browser support -->
<!-- NOTE: you must adjust the paths as appropriate for your project -->
<!-- 🚨 REQUIRED: Web Components polyfill to support Edge and Firefox < 63 -->
<script src="https://unpkg.com/@webcomponents/[email protected]/webcomponents-loader.js"></script>
<!-- 💁 OPTIONAL: Intersection Observer polyfill for better performance in Safari and IE11 -->
<script src="https://unpkg.com/[email protected]/intersection-observer.js"></script>
<!-- 💁 OPTIONAL: Resize Observer polyfill improves resize behavior in non-Chrome browsers -->
<script src="https://unpkg.com/[email protected]/dist/ResizeObserver.js"></script>
<!-- 💁 OPTIONAL: Fullscreen polyfill is required for experimental AR features in Canary -->
<!--<script src="https://unpkg.com/[email protected]/dist/fullscreen.polyfill.js"></script>-->
<!-- 💁 OPTIONAL: Include prismatic.js for Magic Leap support -->
<script src="https://unpkg.com/@magicleap/prismatic/prismatic.min.js"></script>
</head>
<body>
<!-- pfc sync between audio time and model-viewer animation time -->
<script>
function Sync(selector, audioSelector) {
var sound = document.querySelector(audioSelector);
var modelViewer = document.querySelector(selector);
if (modelViewer && sound) {
sound.addEventListener("timeupdate", () => {
if (sound.currentTime > modelViewer.duration) {
// restart both model and sound
modelViewer.currentTime = 0;
sound.currentTime = 0;
} else {
modelViewer.currentTime = sound.currentTime;
}
});
}
// I commented these two because currentTime=0 doesn't affect those.
modelViewer.setAttribute("camera-controls", true);
modelViewer.setAttribute("auto-rotate", true);
modelViewer.setAttribute("autoplay", true);
sound.play();
modelViewer.play();
}
</script>
<!--
Penguin + Train Sound = ok
"https://cdn.glitch.com/7d7e8236-5fa5-4809-ab74-eb6bf2bef1c6%2Fmodel.glb?sound=https://cdn.glitch.com/99537520-86ee-43b2-9c9a-4e6b399f9e42%2FSteamTrain.ogg&link=https://prefrontalcortex.de"
Train + Train sound = kein Sound
"https://cdn.glitch.com/99537520-86ee-43b2-9c9a-4e6b399f9e42%2FTrain-br111.glb?sound=https://cdn.glitch.com/99537520-86ee-43b2-9c9a-4e6b399f9e42%2FSteamTrain.ogg&link=https://prefrontalcortex.de"
-->
<model-viewer
src="./train.glb?sound=train.mp3"
ar
background-color="#fffff"
alt="BR 111"
exposure="1"
shadow-intensity="1"
id="modelviewer"
style="
position: absolute;
left: 0;
top: 0;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
"
>
</model-viewer>
<section class="attribution">
<span>
<span
><audio controls loop id="sound">
<source
src="train.mp3"
type="audio/mp3"
/>
</audio
></span>
</span>
</section>
<script>
Sync("#modelviewer", "#sound");
</script>
<!-- 💁 Include both scripts below to support all browsers! -->
<!-- Import the component -->
<script
type="module"
src="https://unpkg.com/@google/model-viewer/dist/model-viewer.js"
></script>
<script
nomodule
src="https://unpkg.com/@google/model-viewer/dist/model-viewer-legacy.js"
></script>
</body>
</html>