-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass.html
175 lines (133 loc) · 5.8 KB
/
class.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
<!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 objects = [];
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);
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.enableZoom = false;
// events
addEvents();
}
function setup() {
var cubeMap = getCubeMap(14);
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(.2, .1, .2);
scene.add(light);
// objects
var material = new THREE.MeshStandardMaterial({
//color:0xFF0000,
metalness: 1,
roughness: 0.6,
envMap: cubeMap,
shading: THREE.FlatShading
});//shading: THREE.FlatShading
var geo = new THREE.TetrahedronGeometry(.1, 0);
for (var i = 0; i < 64; i++) {
var mesh = new THREE.Mesh(geo, material);
scene.add(mesh);
objects.push(mesh)
mesh.position.x = -3 + Math.random() * 6;
mesh.position.y = -3 + Math.random() * 6;
mesh.position.z = -3 + Math.random() * 6;
mesh.rotation.set(Math.random() * Math.PI * 2, Math.random() * Math.PI * 2, Math.random() * Math.PI * 2)
}
}
function render() {
var time = Date.now() * 0.001;
//light.position.x = Math.sin(time*10);
//light.position.z = Math.cos(10*time);
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)
}
// vr
if (vr) {
vrControls.update();
controller1.update();
controller2.update();
effect.requestAnimationFrame(render);
//camera.position.y-=1;
effect.render(scene, camera);
//camera.position.y+=1;
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>