-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex_v2.html
More file actions
204 lines (159 loc) · 5.99 KB
/
index_v2.html
File metadata and controls
204 lines (159 loc) · 5.99 KB
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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="keywords" content="polystructor,pontania,much room">
<title>Polystructor</title>
<script type="text/javascript" src="lib/three.js/build/three.js"></script>
<style>
body {
margin: 0;
overflow: hidden;
font-family: Arial, Helvetica, sans-serif;
}
.webgl {
position: fixed;
top: 50px;
left: 50%;
transform: translate(-50%, 0);
}
.caption {
position: fixed;
top: 300px;
left: 50%;
transform: translate(-50%, 0);
}
</style>
</head>
<body>
<!-- Div which will hold the Output -->
<div id="WebGL-output" class="webgl"></div>
<div class="caption">coming soon</div>
<!-- Javascript code that runs our Three.js examples -->
<script type="text/javascript">
// once everything is loaded, we run our Three.js stuff.
function init() {
// create a scene, that will hold all our elements such as objects, cameras and lights.
var scene = new THREE.Scene();
// create a camera, which defines where we're looking at.
// var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
var camera = new THREE.PerspectiveCamera(45, 500 / 300, 1, 100);
// create a render and set the size
var renderer = new THREE.WebGLRenderer();
renderer.setClearColor(new THREE.Color(0xFFFFFF, 1.0));
// renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setSize(500, 300);
renderer.shadowMapEnabled = true;
// show axes in the screen
// var axes = new THREE.AxisHelper(20);
// scene.add(axes);
// create the ground plane
var planeGeometry = new THREE.PlaneGeometry(50, 50);
var planeMaterial = new THREE.MeshBasicMaterial({color: 0xFFFFFF});
var plane = new THREE.Mesh(planeGeometry, planeMaterial);
// rotate and position the plane
plane.rotation.x = -0.5 * Math.PI;
plane.position.x = 0;
plane.position.y = -5.05;
plane.position.z = 0;
// add the plane to the scene
scene.add(plane);
plane.receiveShadow = true;
// create a cube
var cubeGeometry = new THREE.BoxGeometry(10, 10, 0.5);
var cubeMaterial = new THREE.MeshLambertMaterial({color: 0xff0000});
var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
// position the cube
cube.position.x = 0;
cube.position.y = 0;
cube.position.z = 0;
// cube.receiveShadow = true;
cube.castShadow = true;
var corner = function(dx, dy) {
// create a cube
var cubeGeometry2 = new THREE.BoxGeometry(2.5, 2.5, 0.6);
var cubeMaterial2 = new THREE.MeshLambertMaterial({color: 0xAA0000});
var cube2 = new THREE.Mesh(cubeGeometry2, cubeMaterial2);
// position the cube
cube2.position.x = 3.8 * dx;
cube2.position.y = 3.8 * dy;
cube2.position.z = 0;
cube2.receiveShadow = true;
cube2.castShadow = true;
return cube2;
};
var corners = [
corner(1, 1),
corner(1, -1),
corner(-1, 1),
corner(-1, -1)];
var group = new THREE.Object3D();
group.add(cube);
for (var i = 0; i < 4; i++)
group.add(corners[i]);
scene.add(group);
// position and point the camera to the center of the scene
camera.position.x = -30;
camera.position.y = 10;
camera.position.z = 30;
var pos = scene.position;
pos.y += 13;
// camera.lookAt(scene.position);
camera.lookAt(pos);
var spotLight = new THREE.SpotLight(0xffffff);
spotLight.position.set(-60, 60, 20);
spotLight.castShadow = true;
scene.add(spotLight);
// add the output of the renderer to the html element
document.getElementById("WebGL-output").appendChild(renderer.domElement);
// render the scene
// renderer.render(scene, camera);
// add subtle ambient lighting
var ambientLight = new THREE.AmbientLight(0x0c0c0c);
// ambientLight.castShadow = true;
scene.add(ambientLight);
// call the render function
var step = 0;
renderScene();
function renderScene() {
// stats.update();
// rotate the cube around its axes
// cube.rotation.x += 0.02;
group.rotation.y += 0.02;
// for (var i = 0; i < 4; i++)
// corners[i].rotation.y += 0.01;
// cube.rotation.z += 0.02;
// bounce the sphere up and down
step += 0.04;
// sphere.position.x = 20 + ( 10 * (Math.cos(step)));
// sphere.position.y = 2 + ( 10 * Math.abs(Math.sin(step)));
// render using requestAnimationFrame
requestAnimationFrame(renderScene);
renderer.render(scene, camera);
}
// function initStats() {
//
// var stats = new Stats();
//
// stats.setMode(0); // 0: fps, 1: ms
//
// // Align top-left
// stats.domElement.style.position = 'absolute';
// stats.domElement.style.left = '0px';
// stats.domElement.style.top = '0px';
//
// document.getElementById("Stats-output").appendChild(stats.domElement);
//
// return stats;
// }
}
window.onload = init;
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69243067-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>