-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
79 lines (60 loc) · 1.93 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
background-color: #ffffff;
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/94/three.min.js"></script>
<script>
var scene = new THREE.Scene();
var aspect = window.innerWidth / window.innerHeight;
var width = window.innerWidth;
var height = window.innerHeight;
var camera = new THREE.OrthographicCamera( width/-2, width/2,height/2, height/-2,1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var Square_Len = 50;
var Num_Boxes_High = Math.ceil(window.innerHeight / Square_Len);
var Num_Boxes_Len = Math.ceil(window.innerWidth / Square_Len);
var geometry = new THREE.BoxGeometry(Square_Len,Square_Len,Square_Len);
var startx = -window.innerWidth/1+25;
var starty = -window.innerHeight/1+25;
if (aspect < 1){
var startx = -window.innerWidth/0.75+25;
var starty = -window.innerHeight/1+25;
}
var xincrement = 0;
var yincrement = 0;
for (var i = 0; i < Num_Boxes_Len*3; i++){
for (var j = 0; j < Num_Boxes_Len*3; j++){
var material = new THREE.MeshBasicMaterial({color:'rgba(' + [255,Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.random()].join(',') + ')'});
var cube = new THREE.Mesh(geometry,material)
scene.add(cube)
cube.position.y = starty + i*50;
cube.position.x = startx + j*50;
}
}
camera.position.z = 1;
var render = function () {
requestAnimationFrame( render );
scene.traverse( function( node ) {
if ( node instanceof THREE.Mesh ) {
node.rotation.x += Math.random() * 0.03;
node.rotation.y += Math.random() * 0.03;
}
camera.rotation.z +=0.0000005
} );
renderer.render( scene, camera );
};
render();
</script>
</body>
</html>