-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex_backup.html
135 lines (101 loc) · 4.64 KB
/
index_backup.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebVR Workshop</title>
<meta charset="utf-8">
<meta property="og:title" content="WebVR Workshop"/>
<meta property="og:type" content="website"/>
<meta property="og:image" content="https://worlds.marpi.pl/assets/image.jpg"/>
<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: #000;
}
</style>
</head>
<body>
<script src="js/third-party/threejs/three.js"></script>
<script src="js/third-party/threejs/WebVR.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/utils/helpers.js"></script>
<script>
var camera, scene, renderer;
var mobile = false;
init();
setup();
render();
function init() {
// 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, 0, 3);
camera.focalLength = camera.position.distanceTo(scene.position);
// controls
controls = new THREE.OrbitControls(camera);
controls.autoRotate = true;
if (WEBVR.isAvailable() === true) {
controls = new THREE.VRControls(camera);
controls.standing = false;
renderer = new THREE.VREffect(renderer);
document.body.appendChild(WEBVR.getButton(renderer));
}
// events
window.addEventListener('deviceorientation', setOrientationControls, true);
window.addEventListener('resize', onWindowResize, false);
}
function setup() {
// central object
var geometry = new THREE.TorusKnotGeometry(0.84, 0.25, 25, 6);
var material = new THREE.MeshPhongMaterial({shading: THREE.FlatShading});
var object = new THREE.Mesh(geometry, material);
scene.add(object);
// cubes
var group = new THREE.Object3D();
for (var _x = -3; _x <= 3; _x++) {
for (var _y = -3; _y <= 3; _y++) {
for (var _z = -3; _z <= 3; _z++) {
var geo = new THREE.BoxGeometry(.1, .1, .1, 1, 1, 1)
var mesh = new THREE.Mesh(geo, material)
mesh.position.set(_x, _y, _z)
group.add(mesh);
}
}
}
// merge
var geom = new THREE.Geometry()
for (var i = 0; i < group.children.length; i++) {
group.children[i].updateMatrix();
geom.merge(group.children[i].geometry, group.children[i].matrix);
}
group = new THREE.Mesh(geom, material);
scene.add(group)
// light
var light = new THREE.DirectionalLight(0xffffff);
light.position.set(-1, 1.5, 0.5);
scene.add(light);
}
function render() {
requestAnimationFrame(render);
controls.update();
if (mobile) {
camera.position.set(0, 0, 0)
camera.translateZ(5);
}
renderer.render(scene, camera);
}
</script>
</body>
</html>