-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
211 lines (159 loc) · 7.24 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
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html lang="en">
<head>
<title>Resonate Workshop</title>
<meta charset="utf-8">
<meta property="og:title" content="Resonate Workshop"/>
<meta property="og:type" content="website"/>
<meta property="og:image" content=""/>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="author" content="Marpi">
<meta name="description" content="Building generative VR worlds">
<meta property="og:title" content="Resonate Workshop">
<meta property="og:description" content="Building generative VR worlds">
<meta property="og:url" content="https://classes.marpi.pl/resonate/">
<meta property="og:site_name" content="Resonate Workshop">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:url" content="https://classes.marpi.pl/resonate/">
<meta name="twitter:title" content="Resonate Workshop">
<meta property="og:image" content="https://classes.marpi.pl/resonate/og_image.jpg">
<meta name="twitter:image" content="https://classes.marpi.pl/resonate/og_image.jpg">
<style>
body {
margin: 0px;
overflow: hidden;
background-color: #000000;
}
</style>
</head>
<body>
<script src="https://demo.marpi.pl/_/scripts/demo-ui.js"></script>
<script type="text/javascript">
MarpiDemoUI.init("resonate");
</script>
<script src="js/third-party/threejs/three.js"></script>
<script src="js/third-party/threejs/vr/ViveController.js"></script>
<script src="js/third-party/threejs/vr/WebVR.js"></script>
<script src="js/third-party/threejs/loaders/OBJLoader.js"></script>
<script src="js/third-party/threejs/effects/VREffect.js"></script>
<script src="js/third-party/threejs/effects/StereoEffect.js"></script>
<script src="js/third-party/threejs/controls/VRControls.js"></script>
<script src="js/third-party/threejs/controls/DeviceOrientationControls.js"></script>
<script src="js/third-party/threejs/controls/OrbitControls.js"></script>
<script src="js/third-party/TweenMax.min.js"></script>
<script src="js/third-party/perlin.js"></script>
<script src="js/utils/helpers.js"></script>
<script src="js/utils/AudioReactive.js"></script>
<script>
var camera, scene, renderer, effect, controls, vrControls;
var controller1, controller2;
var mobile = false;
var vr = false;
var object;
var group2
var allObjects = [], lights = []
init();
setup();
render();
function init() {
// audio
audio = new AudioReactive({});
audio.playMedia('assets/sound/sept');
// renderer
renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// scene
scene = new THREE.Scene();
// camera
camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, 9, 7);
// controls
controls = new THREE.OrbitControls(camera);
controls.autoRotate = true;
// events
addEvents();
}
function setup() {
// lights
var k = Math.random()
for (var i = 0; i < 2; i++) {
var c = new THREE.Color()
c.setHSL(k + i / 12, 1, 0)
var light = new THREE.PointLight(c, .8, 13000);
scene.add(light);
lights.push(light)
}
// objects
var material = new THREE.MeshPhongMaterial();
for (var i = 0; i < 100; i++) {
var geo = new THREE.TorusGeometry(.1 + i * .2, .1, 10, 3)
var mesh = new THREE.Mesh(geo, material);
mesh.rotation.set(Math.PI / 2, 0, 0);
scene.add(mesh);
allObjects.push(mesh);
}
animate()
}
function animate() {
TweenMax.delayedCall(3, animate)
// lights
var k = Math.random()
for (var i = 0; i < lights.length; i++) {
var light = lights[i]
var c = new THREE.Color()
c.setHSL(k + i / 4, 1, .7)
TweenMax.to(light.color, 1, {r: c.r, g: c.g, b: c.b})
TweenMax.to(light.color, 1, {r: c.r, g: c.g, b: c.b})
}
// objects
var r = 0
var ri = (Math.random() - .5) / 10
for (var i = 0; i < allObjects.length; i++) {
var o = allObjects[i]
r += ri
TweenMax.to(o.rotation, 2, {delay: Math.sin(i / 10) * .2 + .2, y: r, z: r, ease: Back.easeOut})
}
}
function render() {
var time = Date.now() * 0.0001;
// audio
audio.update();
// lights
for (var i = 0; i < lights.length; i++) {
var light = lights[i]
light.position.set(
Math.sin(time * 10 + Math.PI * 2 * i / 3) * 15,
Math.sin(time * 10 * 2 + Math.PI * 2 * i / 3) * 3 + 3,
Math.cos(time * 10 + Math.PI * 2 * i / 3) * 15
)
}
// objects
for (var i = 0; i < allObjects.length; i++) {
var m = allObjects[i]
var s = .1 + 3 * audio.frequencies[i] / 255
m.scale.set(1, 1, 1 * s)
}
// vr
if (vr) {
vrControls.update();
controller1.update();
controller2.update();
effect.requestAnimationFrame(render);
effect.render(scene, camera);
return;
}
// everything else
requestAnimationFrame(render);
controls.update();
if (mobile) {
camera.position.set(0, 0, 0)
camera.translateZ(5);
}
renderer.render(scene, camera);
}
</script>
</body>
</html>