-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpyramid.html
298 lines (238 loc) · 10.9 KB
/
pyramid.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Camp Workshop</title>
<meta charset="utf-8">
<meta property="og:title" content="Camp 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">
<style>
body {
margin: 0px;
overflow: hidden;
background-color: #000000;
}
</style>
</head>
<body>
<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, light;
var controller1, controller2;
var mobile = false;
var vr = false;
var max = 40;
var material;
var container
var globalContainer
var objects = [];
var slides = []
init();
setup();
render();
function init() {
// audio
//audio = new AudioReactive({});
//audio.playMedia('assets/sound/ritual');
// renderer
renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
document.body.appendChild(renderer.domElement);
// scene
scene = new THREE.Scene();
// camera
camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 0.1, 10000);
camera.position.set(0, 0, 3);
// controls
controls = new THREE.OrbitControls(camera);
controls.minDistance = 2.5;
controls.maxDistance = 6;
//controls.maxPolarAngle = Math.PI / 2;
controls.autoRotate = true;
controls.enablePan = false;
//controls.autoRotate = true;
// events
addEvents();
}
function setup() {
var cubeMap = getCubeMap(0);
var cubeShader = THREE.ShaderLib['cube'];
cubeShader.uniforms['tCube'].value = cubeMap;
var skyBoxMaterial = new THREE.ShaderMaterial({
fragmentShader: cubeShader.fragmentShader,
vertexShader: cubeShader.vertexShader,
uniforms: cubeShader.uniforms,
depthWrite: false,
side: THREE.BackSide
});
var skyBox = new THREE.Mesh(new THREE.CubeGeometry(1000, 1000, 1000), skyBoxMaterial);
//scene.add(skyBox);
// lights
light = new THREE.DirectionalLight(0xFFFFFF);
light.position.set(.1, .5, .2);
light.castShadow = true;
//directionalLight.shadowDarkness = .1
var roz = 2
light.shadow.camera.near = -roz * 2
light.shadow.camera.far = roz * 2
light.shadow.camera.left = -roz * 2
light.shadow.camera.right = roz * 2
light.shadow.camera.top = roz
light.shadow.camera.bottom = -roz
light.shadow.mapSize.width = 1024;
light.shadow.mapSize.height = 1024;
light.shadow.bias = -0.002
scene.add(light);
// objects
material = new THREE.MeshStandardMaterial({
//color:0xFF0000,
metalness: 1,
roughness: .3,
envMap: cubeMap,
shading: THREE.FlatShading
});//shading: THREE.FlatShading
globalContainer = new THREE.Group();
scene.add(globalContainer);
// gold diamonds
container = new THREE.Group();
for (var i = 0; i < 99; i++) {
var geo = new THREE.TetrahedronGeometry(.1, Math.floor(Math.random() * 3));
var mesh = new THREE.Mesh(geo, material);
while (mesh.position.distanceTo(scene.position) > 2 || mesh.position.distanceTo(scene.position) < 1.5 || mesh.position.x == 0 || mesh.position.y < -1) {
mesh.position.x = -3 + Math.random() * 6;
mesh.position.y = -3 + Math.random() * 6;
mesh.position.z = -3 + Math.random() * 6;
}
var s = Math.random() * 2
mesh.scale.set(s, s, s)
mesh.rotation.set(Math.random() * 4, Math.random() * 4, Math.random() * 4)
container.add(mesh);
}
var geo = new THREE.TetrahedronGeometry(.1, 2);
var mesh = new THREE.Mesh(geo, material);
mesh.position.y = -1.5;
mesh.scale.set(15, 15 / 10, 15)
container.add(mesh);
var geom = new THREE.Geometry();
for (var i = 0; i < container.children.length; i++) {
container.children[i].updateMatrix();
geom.merge(container.children[i].geometry, container.children[i].matrix);
}
container = new THREE.Mesh(geom, material);
container.castShadow = true;
container.receiveShadow = true;
globalContainer.add(container)
// black diamonds
var blackMaterial = new THREE.MeshStandardMaterial({
//color:0xFF0000,
metalness: 1,
roughness: 0,
envMap: getCubeMap(13),
shading: THREE.FlatShading
});//shading: THREE.FlatShading
var container = new THREE.Group();
var geo = new THREE.TetrahedronGeometry(.1, 0);
for (var i = 0; i < 199; i++) {
var mesh = new THREE.Mesh(geo, blackMaterial);
while (mesh.position.distanceTo(scene.position) < 5) {
mesh.position.x = -10 + Math.random() * 20;
mesh.position.y = -10 + Math.random() * 20;
mesh.position.z = -10 + Math.random() * 20;
}
var s = 5 + Math.random() * 10
mesh.scale.set(s, s, s)
mesh.rotation.set(Math.random() * 4, Math.random() * 4, Math.random() * 4)
container.add(mesh);
}
var geom = new THREE.Geometry();
for (var i = 0; i < container.children.length; i++) {
container.children[i].updateMatrix();
geom.merge(container.children[i].geometry, container.children[i].matrix);
}
container = new THREE.Mesh(geom, blackMaterial);
container.castShadow = true;
container.receiveShadow = true;
globalContainer.add(container)
for (var i = 0; i < 10; i++) {
//var geo = new THREE.BoxGeometry(1, .1, 1);
var geo = new THREE.CylinderGeometry(.1 * i, .1 * (1 + i), .2, 6);
var mesh = new THREE.Mesh(geo, material);
mesh.position.y = -.2 * i + 1
mesh.castShadow = true;
mesh.receiveShadow = true;
globalContainer.add(mesh)
slides.push(mesh);
}
animate()
}
function animate() {
for (var i = 0; i < slides.length; i++) {
var mesh = slides[i]
TweenLite.to(mesh.rotation, 1, {
delay: 1 - .1 * i,
y: mesh.rotation.y + Math.PI * 2 / 6,
ease: Back.easeOut
});
}
TweenLite.delayedCall(2, animate)
//console.log("ROTATE")
}
function render() {
var time = Date.now() * 0.0001;
light.position.x = Math.sin(time) * .1;
light.position.z = Math.cos(time) * .1;
/*audio.frequencyData = audio.update();
for (var i = 0; i < objects.length; i++) {
var s = 5 * audio.frequencies[i] / 128
objects[i].scale.set(s, s, s)
}*/
/*var i = 0
var perlinScale = Math.sin(time * .3) / 5;
for (var _x = 0; _x < max; _x++) {
for (var _y = 0; _y < max; _y++) {
for (var _z = 0; _z < 1; _z++) {
var mesh = objects[i];
var perlinValue = noise.perlin3(_x * perlinScale + time, _y * perlinScale, _z * perlinScale) * .5 + .5
mesh.scale.set(perlinValue, perlinValue, perlinValue)
//mesh.rotation.y = perlinValue;
i++;
}
}
}*/
// vr
if (vr) {
vrControls.update();
controller1.update();
controller2.update();
effect.requestAnimationFrame(render);
globalContainer.position.y = 1;
effect.render(scene, camera);
return;
}
// web and mobile
requestAnimationFrame(render);
controls.update();
if (mobile) {
camera.position.set(0, 0, 0);
camera.translateZ(3);
}
renderer.render(scene, camera);
}
</script>
</body>
</html>