-
Notifications
You must be signed in to change notification settings - Fork 0
/
page2.html
650 lines (535 loc) · 21.7 KB
/
page2.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
<html lang="en">
<head>
<title>Choice Room</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="main.css">
<style>
body{
overflow: hidden;
background-color: #000000;
margin: 0px;
background-size: cover;
background-repeat: no-repeat;
}
a {
color: #2fa1d6;
}
p {
max-width: 600px;
margin-left: auto;
margin-right: auto;
padding: 0 2em;
}
.progress-bar-container{
position:absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.8);
display: flex;
flex-direction: column;
justify-content: center;
align-items:center;
}
#progress-bar{
width: 30%;
margin-top: 0.5%;
height: 2%;
}
label{
color:white;
font-size: 2rem;
}
</style>
</head>
<body>
<div class="progress-bar-container">
<label for="progress-bar">Loading...</label>
<progress id="progress-bar" value ="0" max="100"></progress>
</div>
<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "./build/three.module.js"
}
}
</script>
<script id="vertexShader" type="x-shader/x-vertex">
varying vec3 vNormal;
varying vec3 vPositionNormal;
void main()
{
vNormal = normalize( normalMatrix * normal );
vPositionNormal = normalize(( modelViewMatrix * vec4(position, 1.0) ).xyz);
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
</script>
<!-- fragment shader a.k.a. pixel shader -->
<script id="fragmentShader" type="x-shader/x-vertex">
uniform vec3 glowColor;
uniform float b;
uniform float p;
uniform float s;
varying vec3 vNormal;
varying vec3 vPositionNormal;
void main()
{
float a = pow( b + s * abs(dot(vNormal, vPositionNormal)), p );
gl_FragColor = vec4( glowColor, a );
}
</script>
<script type="module">
import * as THREE from 'three';
import Stats from './jsm/libs/stats.module.js';
import { GUI } from './jsm/libs/lil-gui.module.min.js';
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { GLTFLoader } from './jsm/loaders/GLTFLoader.js';
import { CSS3DRenderer, CSS3DObject } from './jsm/renderers/CSS3DRenderer.js';
import { FontLoader } from './jsm/loaders/FontLoader.js';
import { TextGeometry } from './jsm/geometries/TextGeometry.js';
import { ShadowMapViewer } from './jsm/utils/ShadowMapViewer.js';
import { OBJLoader } from './jsm/loaders/OBJLoader.js';
let container, stats, clock, gui, mixer, actions, activeAction, previousAction;
let camera, scene, renderer, model, face,renderer2,scene2;
let t;
let model2;
const SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
const api = { state: 'Walking' };
let current_state = 'Idle';
var xSpeed = 0.1;
var ySpeed = 0.25;
let object;
init();
animate();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.25, 400 );
camera.position.set(60, 70,-20 );
scene = new THREE.Scene();
clock = new THREE.Clock();
scene.fog = new THREE.FogExp2( 0xccddff, .005 );
const mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2000,2000 ), new THREE.MeshPhongMaterial( { color: 0x000000, depthWrite: false } ) );
mesh.position.set(0,0,50);
mesh.rotation.y=3.14/2;
scene.add( mesh );
const mesh2 = new THREE.Mesh( new THREE.PlaneGeometry( 2000,2000 ), new THREE.MeshPhongMaterial( { color: 0x00000, depthWrite: false } ) );
mesh2.position.set(0,0,-50);
scene.add( mesh2 );
const mesh3 = new THREE.Mesh( new THREE.PlaneGeometry(2000,2000 ), new THREE.MeshPhongMaterial( { color: 0x000000, depthWrite: false } ) );
mesh3.position.set(-50,0,0);
mesh3.rotation.y=3.14/2;
scene.add( mesh3 );
// lights
const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 );
hemiLight.position.set( 0, 20, 0 );
scene.add( hemiLight );
const dirLight = new THREE.DirectionalLight( 0xffffff,10 );
dirLight.position.set( 0, 20, 0 );
dirLight.target.position.set(-25, 25,0);
//scene.add( dirLight.target );
//scene.add( dirLight );
//const Helper= new THREE.DirectionalLightHelper(dirLight, 3);
//scene.add(Helper);
const ambientLight = new THREE.AmbientLight( 0xa3e8ff, 0.4 );
scene.add( ambientLight );
let light = new THREE.SpotLight( 0xab5cff, 2, 0, Math.PI / 5, 0.3 );
light.position.set(0,10, 0);
light.target.position.set( 5, 25,-25);
light.castShadow = true;
light.shadow.camera.near = 100;
light.shadow.camera.far = 500;
light.shadow.bias = 0.0001;
light.shadow.mapSize.width = SHADOW_MAP_WIDTH;
light.shadow.mapSize.height = SHADOW_MAP_HEIGHT;
scene.add( light );
scene.add( light.target );
let light2 = new THREE.SpotLight( 0xab5cff,2, 0, Math.PI / 5, 0.3 );
light2.position.set(0, 0, 0);
light2.target.position.set( -25, 25,0);
light2.castShadow = true;
light2.shadow.camera.near = 100;
light2.shadow.camera.far = 500;
light2.shadow.bias = 0.0001;
light2.shadow.mapSize.width = SHADOW_MAP_WIDTH;
light2.shadow.mapSize.height = SHADOW_MAP_HEIGHT;
scene.add( light2 );
scene.add( light2.target );
let light3 = new THREE.SpotLight( 0xab5cff,2, 0, Math.PI / 5, 0.3 );
light3.position.set(0, 0, 0);
light3.target.position.set( 0, 25,25);
light3.castShadow = true;
light3.shadow.camera.near = 100;
light3.shadow.camera.far = 500;
light3.shadow.bias = 0.0001;
light3.shadow.mapSize.width = SHADOW_MAP_WIDTH;
light3.shadow.mapSize.height = SHADOW_MAP_HEIGHT;
scene.add( light3 );
scene.add( light3.target );
const progressBar =document.getElementById('progress-bar');
const loadingManager =new THREE.LoadingManager();
loadingManager.onProgress =function(url,loaded,total){
progressBar.value = (loaded/total)*100;
}
const progressBarContainer =document.querySelector('.progress-bar-container');
console.log(progressBarContainer);
loadingManager.onLoad =function(){
progressBarContainer.style.display ='none';
}
const geometry = new THREE.BoxGeometry( 20, 30, 2);
const material = new THREE.MeshBasicMaterial( {color: 0x000000} );
const cube = new THREE.Mesh( geometry, material );
const geometry3 = new THREE.BoxGeometry( 50, 50, 1);
const material2 = new THREE.MeshBasicMaterial( {color: 0x000000} );
const ground = new THREE.Mesh( geometry3, material2 );
ground.position.set(5,10,0);
ground.rotation.x=3.14/2;
scene.add( ground );
const loader2 = new GLTFLoader(loadingManager);
loader2.load( './videos/wall/scene.gltf', function ( gltf ) {
model2 = gltf.scene;
model2.scale.set(.06,.1,.005);
model2.position.set(-74,40,20);
scene.add( model2 );
});
const loader3 = new GLTFLoader(loadingManager);
loader3.load( './videos/wall/scene.gltf', function ( gltf ) {
let model3 = gltf.scene;
model3.scale.set(0.06,.1,.005);
model3.position.set(-42,40,20);
scene.add( model3 );
});
const loader4 = new GLTFLoader(loadingManager);
loader4.load( './videos/wall/scene.gltf', function ( gltf ) {
let model4 = gltf.scene;
model4.scale.set(0.06,0.1,.005);
model4.position.set(-25,40,80);
model4.rotation.y=3.14/2;
scene.add( model4 );
});
const loader6 = new GLTFLoader(loadingManager);
loader6.load( './videos/wall/scene.gltf', function ( gltf ) {
let model6 = gltf.scene;
model6.scale.set(0.06,0.1,.005);
model6.position.set(-25,40,48);
model6.rotation.y=3.14/2;
scene.add( model6 );
});
const loader7 = new GLTFLoader(loadingManager);
loader7.load( './videos/wall/scene.gltf', function ( gltf ) {
let model7 = gltf.scene;
model7.scale.set(0.06,0.1,.005);
model7.position.set(-74,40,-30);
scene.add( model7 );
});
const loader8 = new GLTFLoader(loadingManager);
loader8.load( './videos/wall/scene.gltf', function ( gltf ) {
let model8 = gltf.scene;
model8.scale.set(0.06,0.1,.005);
model8.position.set(-40,40,-30);
scene.add( model8 );
});
const loader9 = new GLTFLoader(loadingManager);
loader9.load( './videos/wall/scene.gltf', function ( gltf ) {
let model9 = gltf.scene;
model9.scale.set(0.06,.06,.005);
model9.position.set(-57,40,20);
scene.add( model9 );
});
const loader10 = new GLTFLoader(loadingManager);
loader10.load( './videos/wall/scene.gltf', function ( gltf ) {
let model10 = gltf.scene;
model10.scale.set(0.06,.06,.005);
model10.position.set(-25,40,65);
model10.rotation.y=3.14/2;
scene.add( model10 );
});
const loader11 = new GLTFLoader(loadingManager);
loader11.load( './videos/wall/scene.gltf', function ( gltf ) {
let model11 = gltf.scene;
model11.scale.set(0.06,.06,.005);
model11.position.set(-57,40,-30);
scene.add( model11 );
});
const loader5 = new GLTFLoader(loadingManager);
loader5.load( 'models/gltf/RobotExpressive/RobotExpressive.glb', function ( gltf ) {
model = gltf.scene;
model.scale.set(1.25,1.25,1.25);
model.position.set(5,11,0);
scene.add( model );
createGUI( model, gltf.animations );
}, undefined, function ( e ) {
console.error( e );
} );
const loader12 = new GLTFLoader(loadingManager);
loader12.load( 'videos/ground/scene.gltf', function ( gltf ) {
let model12 = gltf.scene;
model12.scale.set(25,25,1);
model12.position.set(5,10,0);
model12.rotation.x=3.14/2;
scene.add( model12 );
} );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.outputEncoding = THREE.sRGBEncoding;
renderer.domElement.style.top = 0;
renderer.domElement.style.zIndex = '1';
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize );
// stats
stats = new Stats();
container.appendChild( stats.dom );
//font on screen 1
var customMaterial = new THREE.ShaderMaterial({
uniforms:
{
"s": { type: "f", value: -1.0},
"b": { type: "f", value: 1.0},
"p": { type: "f", value: 2.0 },
glowColor: { type: "c", value: new THREE.Color(0x00ffff) }
},
vertexShader: document.getElementById( 'vertexShader' ).textContent,
fragmentShader: document.getElementById( 'fragmentShader' ).textContent,
side: THREE.FrontSide,
blending: THREE.AdditiveBlending,
transparent: true
})
const loader_font = new FontLoader();
loader_font.load('fonts/helvetiker_bold.typeface.json', function ( font ) {
const textGeo = new TextGeometry( 'SKILLS', {
font: font,
size: 4,
height: 2,
curveSegments: 12,
bevelThickness: .1,
bevelSize: .1,
bevelEnabled: true
} );
const textGeo2 = new TextGeometry( 'PROJECTS', {
font: font,
size: 4,
height: 2,
curveSegments: 12,
bevelThickness: .1,
bevelSize: .1,
bevelEnabled: true
} );
const textGeo3 = new TextGeometry( 'ABOUT ME', {
font: font,
size: 4,
height: 2,
curveSegments: 12,
bevelThickness: .1,
bevelSize: .1,
bevelEnabled: true
} );
const textMaterial = new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0xffffff } );
const mesh1 = new THREE.Mesh( textGeo, textMaterial );
mesh1.position.x = 15;
mesh1.position.y = 25;
mesh1.position.z = 25;
mesh1.rotation.y = 3.14;
mesh1.castShadow = true;
mesh1.receiveShadow = true;
scene.add( mesh1 )
const mesh2 = new THREE.Mesh( textGeo2, textMaterial );
mesh2.position.x = -20;
mesh2.position.y = 25;
mesh2.position.z = 15;
mesh2.rotation.y = 3.14/2;
mesh2.castShadow = true;
mesh2.receiveShadow = true;
scene.add( mesh2 )
const mesh3 = new THREE.Mesh( textGeo3, textMaterial );
mesh3.position.x = -10;
mesh3.position.y = 25;
mesh3.position.z = -25;
mesh3.rotation.y = 0;
mesh3.castShadow = true;
mesh3.receiveShadow = true;
scene.add( mesh3 )
});
const controls = new OrbitControls( camera, renderer.domElement );
controls.enablePan = true;
controls.minDistance = 5;
controls.maxDistance = 200;
document.addEventListener("keydown", onDocumentKeyDown, false);
}
function onDocumentKeyDown(event) {
if(t==0){
fadeToAction('Walking',0.5);
t=1;}
var keyCode = event.which;
if (model.position.z > 19.5 && (model.position.x >9 || model.position.x < 2) )
{
console.log("1");
fadeToAction('Death',.1);
setTimeout(() => { }, 2000);
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
t=0;
}
else if (model.position.z > 20 )
{
window.open('skills.html','_parent');
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
}
else if (model.position.z < -23 && (model.position.x >9 || model.position.x < 2) )
{
fadeToAction('Death',.1);
setTimeout(() => { }, 2000);
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
t=0;
}
else if (model.position.z < -25 )
{
window.open('about_me.html','_parent');
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
}
else if (model.position.x < -18 && (model.position.z < -3 || model.position.z > 4) )
{
console.log(model.position.z);
fadeToAction('Death',.1);
setTimeout(() => { }, 2000);
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
t=0;
}
else if (model.position.x < -19 )
{
window.open('projects.html','_parent');
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
}
else if (model.position.x >25)
{
console.log(model.position.z);
fadeToAction('Death',.1);
setTimeout(() => { }, 2000);
camera.position.set(60, 70,-20 );
model.position.set(5,11,0);
}
else if (keyCode == 39 ) {
model.rotation.set(0,-3.14/2,0);
model.position.x -= ySpeed;
camera.position.set( camera.position.x- ySpeed, camera.position.y, camera.position.z );
}
else if (keyCode == 37 ) {
model.rotation.set(0,3.14/2,0);
model.position.x +=ySpeed;
camera.position.set( camera.position.x+ySpeed, camera.position.y, camera.position.z );
}
else if (keyCode == 38 ) {
model.rotation.set(0,0,0);
model.position.z += ySpeed;
camera.position.set( camera.position.x, camera.position.y, camera.position.z+ ySpeed );
}
else if (keyCode == 40 ) {
model.rotation.set(0,3.14,0);
model.position.z -= ySpeed;
camera.position.set( camera.position.x, camera.position.y, camera.position.z- ySpeed );
}
if ( keyCode == 49 )
{//1
window.open('skills.html','_parent');
}
else if ( keyCode == 50 )
{//2
window.open('projects.html','_parent');
}
else if ( keyCode == 51 )
{//3
window.open('about_me.html','_parent');
}
render();
console.log(keyCode);
};
function createGUI( model, animations ) {
const states = [ 'Idle', 'Walking', 'Running', 'Dance', 'Death', 'Sitting', 'Standing' ];
const emotes = [ 'Jump', 'Yes', 'No', 'Wave', 'Punch', 'ThumbsUp' ];
gui = new GUI();
mixer = new THREE.AnimationMixer( model );
actions = {};
for ( let i = 0; i < animations.length; i ++ ) {
const clip = animations[ i ];
const action = mixer.clipAction( clip );
actions[ clip.name ] = action;
if ( emotes.indexOf( clip.name ) >= 0 || states.indexOf( clip.name ) >= 4 ) {
action.clampWhenFinished = true;
action.loop = THREE.LoopOnce;
}
}
// states
var options = {
Move_Forward: '↑',
Move_Backward: '↓',
Move_Left: '←',
Move_Right: '→'
}
var options2 = {
Project: 'Press-Room-No.',
Skills: '1',
Projects: '2',
About_me: '3',
}
const statesFolder = gui.addFolder( 'ROBOT CONTROL' );
statesFolder.add(options, 'Move_Forward');
statesFolder.add(options, 'Move_Backward');
statesFolder.add(options, 'Move_Left');
statesFolder.add(options, 'Move_Right');
const statesFolder2 = gui.addFolder( 'GO TO ROOM' );
statesFolder2.add(options2, 'ROOM');
statesFolder2.add(options2, 'Skills');
statesFolder2.add(options2, 'Projects');
statesFolder2.add(options2, 'About_me');
statesFolder.open();
statesFolder.open();
// emotes
function restoreState() {
mixer.removeEventListener( 'finished', restoreState );
fadeToAction( api.state, 0.2 );
}
activeAction = actions[ 'Walking' ];
activeAction.play();
}
function fadeToAction( name, duration ) {
previousAction = activeAction;
activeAction = actions[ name ];
if ( previousAction !== activeAction ) {
previousAction.fadeOut( duration );
}
activeAction
.reset()
.setEffectiveTimeScale( 1 )
.setEffectiveWeight( 1 )
.fadeIn( duration )
.play();
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function render() {
renderer.render( scene, camera );
}
//
function animate() {
const dt = clock.getDelta();
if ( mixer ) mixer.update( dt );
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
</script>
</body>
</html>