-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
209 lines (181 loc) · 5.88 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
<html>
<head>
<title> fifty6 </title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="stylesheets/css/56.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="scripts/three.min.js"></script>
<script src="scripts/three6.js"></script>
</head>
<body>
<div id="featured">
</div>
</body>
<script>
var mouse = {x: 0, y: 0};
var distMouse = {x:0,y:0};
var prevMouse = {x:0,y:0};
var mouseDown = false;
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 1, 10000);
var renderer = new THREE.WebGLRenderer({alpha:true});
document.getElementById('featured').appendChild(renderer.domElement);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor( 0x000000, 0 );
var geometry1 = new THREE.BoxGeometry(13, 9, 0, 10, 10, 10);
var feature1 = THREE.ImageUtils.loadTexture('assets/three-assets/kid.png', {}, function(){},function(){});
var material1 = new THREE.MeshBasicMaterial({map: feature1, transparent: true, opacity: 0.5, color: 0xFF0000});
// ultra hard var material1 = new THREE.MeshBasicMaterial({map: feature1, transparent: true, opacity: 0.5, color: 0xFF0000});
var cube1 = new THREE.Mesh(geometry1, material1);
var geometry2 = new THREE.BoxGeometry(13, 9, 0, 10, 10, 10);
var feature2 = THREE.ImageUtils.loadTexture('assets/three-assets/88.png', {}, function(){},function(){});
var material2 = new THREE.MeshBasicMaterial({map: feature2, transparent: true, opacity: 0.5, color: 0xFF0000});
var cube2 = new THREE.Mesh(geometry2, material2);
var geometry3 = new THREE.BoxGeometry(13, 9, 0, 10, 10, 10);
var feature3 = THREE.ImageUtils.loadTexture('assets/three-assets/aa.png', {}, function(){},function(){});
var material3 = new THREE.MeshBasicMaterial({map: feature3, transparent: true, opacity: 0.5, color: 0xFF0000});
var cube3 = new THREE.Mesh(geometry3, material3);
var geometry4 = new THREE.BoxGeometry(13, 9, 0, 10, 10, 10);
var feature4 = THREE.ImageUtils.loadTexture('assets/three-assets/willis.png', {}, function(){},function(){});
var material4 = new THREE.MeshBasicMaterial({map: feature4, transparent: true, opacity: 0.5, color: 0xFF0000});
var cube4 = new THREE.Mesh(geometry4, material4);
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'mousedown', onMouseDown, false);
document.addEventListener( 'mouseup', onMouseUp, false);
document.addEventListener( 'keydown', onKeyDown, false);
function onDocumentMouseMove(e){
mouse.x = (e.clientX / window.innerWidth);
mouse.y = (e.clientY / window.innerHeight);
}
function onKeyDown(e){
switch (e.keyCode){
case 37:
camera.position.x += 0.5;
break;
case 38:
camera.position.y -= 0.5;
break;
case 39:
camera.position.x -= 0.5;
break;
case 40:
camera.position.y += 0.5;
break;
}
}
function onMouseDown(e){
console.log("down");
mouseDown = true;
prevMouse.x = mouse.x;
prevMouse.y = mouse.y;
}
function onMouseUp( ){
console.log("up");
mouseDown = false;
}
function dragMove() {
distMouse.x = prevMouse.x - mouse.x;
distMouse.y = prevMouse.y - mouse.y;
camera.rotation.y -= distMouse.x * 2;
camera.rotation.x -= distMouse.y * 2;
prevMouse.x = mouse.x;
prevMouse.y = mouse.y;
}
scene.add(cube1);
scene.add(cube2);
scene.add(cube3);
scene.add(cube4);
camera.position.z = 10;
camera.position.x = -4;
cube2.position.x = -5;
cube3.position.x = -10;
cube4.position.x = -15;
cube2.position.y = -1;
cube3.position.y = -2;
cube4.position.y = -3;
cube2.position.z = -3;
cube3.position.z = -6;
cube4.position.z = -9;
cube1.rotation.y = 0.25;
cube2.rotation.y = 0.25;
cube3.rotation.y = 0.25;
cube4.rotation.y = 0.25;
// cube2.rotation.x = 0.25;
// cube3.rotation.x = 0.5;
// cube4.rotation.x = 0.75;
function render() {
requestAnimationFrame(render);
if(mouseDown){
dragMove();
}
if (cube1.position.z > 3){
cube1.position.z = -9;
cube1.position.x = -15;
cube1.position.y = -3;
}
if (cube2.position.z > 3){
cube2.position.z = -9;
cube2.position.x = -15;
cube2.position.y = -3;
}
if (cube3.position.z > 3){
cube3.position.z = -9;
cube3.position.x = -15;
cube3.position.y = -3;
}
if (cube4.position.z > 3){
cube4.position.z = -9;
cube4.position.x = -15;
cube4.position.y = -3;
}
if (cube1.position.z > -9 && cube1.position.z < 0){
if(cube1.material.opacity <= 0.5){
cube1.material.opacity += 0.01;
}
}
if (cube2.position.z > -9 && cube2.position.z < 0){
if(cube2.material.opacity <= 0.5){
cube2.material.opacity += 0.01;
}
}
if (cube3.position.z > -9 && cube3.position.z < 0){
if(cube3.material.opacity <= 0.5){
cube3.material.opacity += 0.01;
}
}
if (cube4.position.z > -9 && cube4.position.z < 0){
if(cube4.material.opacity <= 0.5){
cube4.material.opacity += 0.01;
}
}
if (cube1.position.z > 1){
cube1.material.opacity -= 0.01;
}
if (cube2.position.z > 1){
cube2.material.opacity -= 0.01;
}
if (cube3.position.z > 1){
cube3.material.opacity -= 0.01;
}
if (cube4.position.z > 1){
cube4.material.opacity -= 0.01;
}
cube1.position.z += 0.03;
cube2.position.z += 0.03;
cube3.position.z += 0.03;
cube4.position.z += 0.03;
cube1.position.x += 0.05;
cube2.position.x += 0.05;
cube3.position.x += 0.05;
cube4.position.x += 0.05;
cube1.position.y += 0.01;
cube2.position.y += 0.01;
cube3.position.y += 0.01;
cube4.position.y += 0.01;
renderer.render(scene, camera);
};
render();
</script>
</html>