-
Notifications
You must be signed in to change notification settings - Fork 0
/
eye_callada.html
265 lines (178 loc) · 7.71 KB
/
eye_callada.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Interaction – Demo – RE-Design</title>
<meta name="description" content="">
<meta content="initial-scale=1, width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" name="viewport">
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {padding-top: 60px;padding-bottom: 40px;}
/*body {overflow: hidden;}*/
#info .top {position: absolute;top: 0px;width: 100%;padding: 5px;text-align: center;}
#info a {color: #66F;text-decoration: none;}
#info a:hover {text-decoration: underline;}
#info .bottom {position: absolute;bottom: 0px;right: 5px;padding: 5px;}
</style>
<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<div class="container">
<!-- three.js container -->
<div id="output" style="margin:0 auto;"></div>
<!-- info on screen display -->
<div id="info">
<div class="top">
<a href="http://learningthreejs.com/blog/2011/12/20/boilerplate-for-three-js/" target="_blank">LearningThree.js</a>
boiler plate for
<a href="https://github.com/mrdoob/three.js/" target="_blank">three.js</a>
</div>
<div class="bottom" id="inlineDoc" >
- <i>p</i> for screenshot
</div>
</div>
<!-- Example row of columns -->
<hr>
<footer>
<p>© RE-Design 2013</p>
</footer>
</div> <!-- /container -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/main.js"></script>
<script src="js/vendor/three.js/Three.min.js"></script>
<script src="js/vendor/three.js/loaders/ColladaLoader.js"></script>
<script src="js/vendor/three.js/Detector.js"></script>
<script src="js/vendor/three.js/Stats.js"></script>
<script src="js/vendor/threex.dragpancontrols.js"></script>
<script type="text/javascript">
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var container, stats;
var scene, renderer, objects;
var camera, cameraControls;
var particleLight, pointLight;
var dae, skin;
var mouseX = 0;
var mouseY = 0;
var targetX = 0, targetY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
var loader = new THREE.ColladaLoader();
loader.options.convertUpAxis = true;
loader.load( './obj/sight/sight.dae', function ( collada ) {
dae = collada.scene;
skin = collada.skins[ 0 ];
dae.scale.x = dae.scale.y = dae.scale.z = 0.001;
dae.updateMatrix();
init();
animate();
} );
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.001, 10000 );
camera.position.set( 0, 0, 10 );
scene = new THREE.Scene();
// Grid
/*var size = 14, step = 1;
var geometry = new THREE.Geometry();
var material = new THREE.LineBasicMaterial( { color: 0x303030 } );
for ( var i = - size; i <= size; i += step ) {
geometry.vertices.push( new THREE.Vector3( - size, - 0.04, i ) );
geometry.vertices.push( new THREE.Vector3( size, - 0.04, i ) );
geometry.vertices.push( new THREE.Vector3( i, - 0.04, - size ) );
geometry.vertices.push( new THREE.Vector3( i, - 0.04, size ) );
}
var line = new THREE.Line( geometry, material, THREE.LinePieces );
scene.add( line );*/
// Add the COLLADA
scene.add( dae );
particleLight = new THREE.Mesh( new THREE.SphereGeometry( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) );
particleLight.scale.x = particleLight.scale.y = particleLight.scale.z = 4;
particleLight.position.x = 3009;
particleLight.position.y = 4000;
particleLight.position.z = 3009;
scene.add( particleLight );
// Lights
scene.add( new THREE.AmbientLight( 0x000000 ) );
var directionalLight = new THREE.DirectionalLight(/*Math.random() * 0xffffff*/0x000000 );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.add( directionalLight );
pointLight = new THREE.PointLight( 0xffffff, 1 );
pointLight.position = particleLight.position;
scene.add( pointLight );
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
//
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function onDocumentMouseMove( event ) {
mouseX = ( event.clientX - windowHalfX ) * 1;
mouseY = ( event.clientY - windowHalfY ) * 1;
}
//
var t = 0;
var clock = new THREE.Clock();
function animate() {
var delta = clock.getDelta();
requestAnimationFrame( animate );
if ( t > 1 ) t = 0;
if ( skin ) {
// guess this can be done smarter...
// (Indeed, there are way more frames than needed and interpolation is not used at all
// could be something like - one morph per each skinning pose keyframe, or even less,
// animation could be resampled, morphing interpolation handles sparse keyframes quite well.
// Simple animation cycles like this look ok with 10-15 frames instead of 100 ;)
for ( var i = 0; i < skin.morphTargetInfluences.length; i++ ) {
skin.morphTargetInfluences[ i ] = 0;
}
skin.morphTargetInfluences[ Math.floor( t * 30 ) ] = 1;
t += delta;
}
render();
stats.update();
}
function render() {
var timer = Date.now() * 0.0005;
targetX = mouseX * .001;
targetY = mouseY * .001;
if ( dae ) {
dae.rotation.y += 0.05 * ( targetX - dae.rotation.y );
dae.rotation.x += 0.05 * ( targetY - dae.rotation.x );
}
//camera.position.x = Math.cos( timer ) * 10;
//camera.position.y = 2;
//camera.position.z = Math.sin( timer ) * 10;
//camera.lookAt( scene.position );
//particleLight.position.x = Math.sin( timer * 4 ) * 3009;
//particleLight.position.y = Math.cos( timer * 5 ) * 4000;
//particleLight.position.z = Math.cos( timer * 4 ) * 3009;
renderer.render( scene, camera );
}
</script>
</body>
</html>