-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
198 lines (164 loc) · 10.9 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
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
<!DOCTYPE html>
<html>
<head>
<title>VR homework based on A-Frame</title>
<meta name="HW" content="VR homework based on A-Frame">
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script-->
<script src="https://unpkg.com/[email protected]/dist/aframe-animation-component.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-particle-system-component.min.js"></script>
<!-- script src="https://unpkg.com/aframe-extras.ocean@%5E3.5.x/dist/aframe-extras.ocean.min.js"></script-->
<script src="https://unpkg.com/[email protected]/dist/gradientsky.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-environment-component.min.js"></script>
<script src="https://npmcdn.com/[email protected]"></script>
<script src="https://npmcdn.com/[email protected]"></script>
<script src="https://npmcdn.com/[email protected]"></script>
</head>
<body>
<a-scene environment="preset: forest">
<!--a-scene-->
<!-- Asset management system. -->
<a-assets>
<a-asset-item id="drum-kit" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/drum-set/scene.gltf"></a-asset-item>
<img id="drum-texture" src="https://cdn.glitch.com/eb8fa426-390f-42da-bde2-b041aefa385f%2Fdrum-texture.png?1514223820171" preload="true">
<img id="cymbal-texture" src="https://raw.githubusercontent.com/Joelliu/vr-homework/master/assets/drum-kit-threejs/archmodels67_22_cymbal_bump.jpg" preload="true">
<img id="phome" src="https://raw.githubusercontent.com/Joelliu/vr-homework/master/assets/pic/home.jpg" preload="true">
<img id="pstory" src="https://raw.githubusercontent.com/Joelliu/vr-homework/master/assets/pic/story.jpg" preload="true">
<img id="plove" src="https://raw.githubusercontent.com/Joelliu/vr-homework/master/assets/pic/love.jpg" preload="true">
<audio id="shi-hat" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/hi-hat.mp3" preload="auto"></audio>
<audio id="scrash" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/crash.mp3" preload="auto"></audio>
<audio id="sride" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/ride.mp3" preload="auto"></audio>
<audio id="stom1" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/tom1.mp3" preload="auto"></audio>
<audio id="stom2" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/tom2.mp3" preload="auto"></audio>
<audio id="ssnare" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/snare.mp3" preload="auto"></audio>
<audio id="skick" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/kick.mp3" preload="auto"></audio>
<audio id="sfloor" src="https://cdn.rawgit.com/Joelliu/vr-homework/master/assets/sound/mp3/floor.mp3" preload="auto"></audio>
<audio id="story" src="https://cdn.rawgit.com/Joelliu/vr-homework-source/master/assets/story.mp3" preload="auto"></audio>
<audio id="home" src="https://cdn.rawgit.com/Joelliu/vr-homework-source/master/assets/home.mp3" preload="auto"></audio>
<audio id="love" src="https://cdn.rawgit.com/Joelliu/vr-homework-source/master/assets/love.mp3" preload="auto"></audio>
<!-- Image link template to be reused. -->
<script id="link" type="text/html">
<a-entity class="link"
geometry="primitive: plane; height: 1; width: 1"
material="shader: flat; src: ${thumb}; side: double"
event-set__1="_event: mousedown; scale: 1 1 1"
event-set__2="_event: mouseup; scale: 1.2 1.2 1"
event-set__3="_event: mouseenter; scale: 1.2 1.2 1"
event-set__4="_event: mouseleave; scale: 1 1 1"
sound="on: click; src: #click-sound"></a-entity>
</script>
</a-assets>
<!-- Scene. -->
<!--a-plane color="#2EA9DF" height="20" width="20" rotation="-90 0 0"></a-plane-->
<!-- https://sketchfab.com/models/3ed0f09afae546c3b6b2ac6816259b5b -->
<a-cylinder color="#884C3A" height="1.6" radius="0.02" position="-0.9 0.8 -0.6">
<!--a-circle id="Hi-hat" src="#cymbal-texture" radius="0.35" rotation="-90 0 0" position="0 0.7 0" side="double"></a-circle-->
<a-entity id="Hi-hat" rotation="-90 0 0" position="0 0.7 0"
geometry="primitive: circle; radius: 0.35"
material="src: #cymbal-texture; side: double"
sound="on: click; src: #shi-hat">
<a-animation attribute="rotation" begin="click" direction="alternate" dur="30" to="-80 -5 -5" repeat="3"></a-animation>
</a-entity>
</a-cylinder>
<a-cylinder color="#884C3A" height="1.8" radius="0.02" position="-0.5 0.9 -1.35">
<a-entity id="Crash-Cymbal" rotation="-55 10 -10" position="0 0.9 0"
geometry="primitive: circle; radius: 0.4"
material="src: #cymbal-texture; side: double"
sound="on: click; src: #scrash">
<a-animation attribute="rotation" begin="click" direction="alternate" dur="300" to="-50 20 -5" repeat="1"></a-animation>
</a-entity>
</a-cylinder>
<a-cylinder color="#884C3A" height="1.8" radius="0.02" position="1.4 0.9 -1.2">
<a-entity id="Ride-Cymbal" rotation="-60 -40 -25" position="0 0.9 0"
geometry="primitive: circle; radius: 0.35"
material="src: #cymbal-texture; side: double"
sound="on: click; src: #sride">
<a-animation attribute="rotation" begin="click" direction="alternate" dur="100" to="-55 -40 -30" repeat="1"></a-animation>
</a-entity>
</a-cylinder>
<!--a-cylinder id="snare-drum" src="#drum-texture" height="0.5" radius="0.3" position="-0.4 0.8 -1" rotation="10 -10 -10"></a-cylinder-->
<a-entity id="snare-drum" position="-0.4 0.8 -1" rotation="10 -10 -10"
geometry="primitive: cylinder; height: 0.5; radius: 0.3"
material="src: #drum-texture"
sound="on: click; src: #ssnare">
<a-animation attribute="position" direction="alternate" dur="2500" repeat="indefinite"
to="-0.4 0.85 -1"></a-animation>
</a-entity>
<!--a-cylinder id="kick-drum" src="#drum-texture" height="0.6" radius="0.4" position="0.3 0.4 -1.4" rotation="-90 -5 0"></a-cylinder-->
<a-entity id="kick-drum" position="0.3 0.45 -1.4" rotation="-90 -5 0"
geometry="primitive: cylinder; height: 0.6; radius: 0.4"
material="src: #drum-texture"
sound="on: click; src: #skick">
<a-animation attribute="position" direction="alternate" dur="2000" repeat="indefinite"
to="0.3 0.45 -1.35"></a-animation>
</a-entity>
<!--a-cylinder id="Tom-Tom1" src="#drum-texture" height="0.4" radius="0.2" position="0.1 0.95 -1.8" rotation="44.07 42.284 28.934"></a-cylinder-->
<a-entity id="Tom-Tom1" position="0.1 1.0 -1.8" rotation="44.07 42.284 28.934"
geometry="primitive: cylinder; height: 0.4; radius: 0.2"
material="src: #drum-texture"
sound="on: click; src: #stom1">
<a-animation attribute="position" direction="alternate" dur="2500" repeat="indefinite"
to="0.1 0.95 -1.8"></a-animation>
</a-entity>
<!--a-cylinder id="Tom-Tom2" src="#drum-texture" height="0.4" radius="0.2" position="0.6 0.95 -1.6" rotation="35 -30 20"></a-cylinder-->
<a-entity id="Tom-Tom2" position="0.6 0.95 -1.6" rotation="35 -30 20"
geometry="primitive: cylinder; height: 0.4; radius: 0.2"
material="src: #drum-texture"
sound="on: click; src: #stom2">
<a-animation attribute="position" direction="alternate" dur="2000" repeat="indefinite"
to="0.6 1.0 -1.6"></a-animation>
</a-entity>
<!--a-cylinder id="floor-drum" src="#drum-texture" height="1" radius="0.33" position="1 0.8 -1"></a-cylinder-->
<a-entity id="floor-drum" position="1 0.7 -1"
geometry="primitive: cylinder; height: 0.8; radius: 0.33"
material="src: #drum-texture"
sound="on: click; src: #sfloor">
<a-animation attribute="position" direction="alternate" dur="1500" repeat="indefinite"
to="1 0.85 -1"></a-animation>
</a-entity>
<a-cylinder id="seat" color="#78552B" height="0.1" radius="0.2" position="0 0.55 -0"></a-cylinder>
<!-- a-sky color="#ECECEC"></a-sky -->
<!--a-entity id="rain" particle-system="preset: rain; color: #24CAFF; particleCount: 5000"></a-entity-->
<a-text value="Simple Drum-kit" color="#F05E1C" position="-1 3 -3" scale="2 2 2"></a-text>
<a-entity id="sky" geometry="primitive: sphere; radius: 5000"
material="shader: gradient; topColor: 235 235 245; bottomColor: 185 185 210"
scale="-1 1 1"></a-entity>
<a-entity id="light" light="type: ambient; color: #888"></a-entity>
<a-entity gltf-model="#drum-kit" scale="0.4 0.4 0.4" position="0 0 2">
<a-box id="model" position="0 3.5 2" color="#DC9FB4"
sound="src: #story; loop: true; volume: 1"></a-box>
</a-entity>
<!-- Image links. -->
<a-entity id="links" layout="type: line; margin: 1.5" position="-2 3.5 3">
<a-entity id="pstoryp" template="src: #link" data-thumb="#pstory"></a-entity>
<a-entity id="phomep" template="src: #link" data-thumb="#phome"></a-entity>
<a-entity id="plovep" template="src: #link" data-thumb="#plove"></a-entity>
</a-entity>
<a-camera position="0 -0.5 0"><a-cursor position="0 0 -0.6"></a-cursor></a-camera>
</a-scene>
<script>
var drum = document.querySelector('#model');
var story = document.querySelector('#pstoryp');
var home = document.querySelector('#phomep');
var love = document.querySelector('#plovep');
drum.addEventListener('mouseenter', function () {
drum.components.sound.playSound();
});
story.addEventListener('click', function () {
drum.setAttribute('sound', {src: '#story'});
drum.components.sound.playSound();
});
home.addEventListener('click', function () {
drum.setAttribute('sound', {src: '#home'});
drum.components.sound.playSound();
});
love.addEventListener('click', function () {
drum.setAttribute('sound', {src: '#love'});
drum.components.sound.playSound();
});
drum.addEventListener('click', function () {
drum.components.sound.stopSound();
});
</script>
</body>
</html>