-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1347 lines (1028 loc) · 39.6 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
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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html style="background-color:#333">
<head>
<script src="./js/dataurls.js"></script>
<script src="./js/three.min.js"></script>
<script src="./js/PointerLockControls.js"></script>
<script src="./js/CanvasRenderer.js"></script>
<script src="./js/Projector.js"></script>
<script src="./js/THREE.Terrain.min.js"></script>
<!--<script src="./js/VignetteShader.js"></script>-->
<!--THREE JS version 91-->
<script async src="./js/GLTFLoader.js"></script>
<!--
<script src="https://unpkg.com/[email protected]/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://cdn.jsdelivr.net/gh/mrdoob/three.js@master/examples/js/loaders/GLTFLoader.js" </script>
-->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>:: Play ::</title>
<link rel="apple-touch-icon" sizes="57x57" href="./images/favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="./images/favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="./images/favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="./images/favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="./images/favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="./images/favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="./images/favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="./images/favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="./images/favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="./images/favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="./images/favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="./images/favicons/favicon-16x16.png">
<link rel="manifest" href="./images/favicons/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="./images/favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<style>
/* Standard syntax */
:fullscreen {
background-color: #333;
}
#overlay {
position: absolute;
top: 500px;
color: #555;
text-align: center;
font-size: 20px;
width: 100%;
padding: 10px 0;
z-index: 100;
}
#video {
z-index: 1;
}
canvas {
filter: hue-rotate(2deg) opacity(35%) contrast(420%) blur( 18px );
box-shadow: 0 0 0 0.2em #000,0 0 0 0.4em #f875c2,0 0 0 0.6em #000, 0 0 0 2.4em #39bddc,0 0 0 0.8em #fff, 0 0 0 2.6em #000;
/*mask-image: radial-gradient(circle, black 57%, rgba(0, 0, 0, 0.1) 20%);*/
margin: 4em; transition: 1.2s;
}
</style>
<!-- DIFFERENT TIMES OF DAY//NIGHT//TONES//FILTER//PAGE COLOUR
BLUEY WASHED OUT//EYE ADJUSTMENT ANIMATION//CUTSCENE
filter: contrast(40%) brightness(221%) blur(2.3px) hue-rotate(270deg); -->
<script type="text/javascript">
var THREE;
var objects = [];
var raycaster;
var moveForward = false;
var moveBackward = false;
var moveLeft = false;
var moveRight = false;
var canJump = false;
var prevTime = performance.now();
var velocity = new THREE.Vector3();
var direction = new THREE.Vector3();
var vertex = new THREE.Vector3();
var color = new THREE.Color();
var VRButton = "";
var controls = "";
var playCanvas, learnCanvas, actionCanvas, camera, scene, renderer, clock, player, terrainScene, terrainPath, decoScene, lastOptions, fpsCamera, skyDome, skyLight, sand, water, blocker, instructions, play, learn, action, star, starlight, wall01, wall02, wall03, wall04;
//RAYCASTER ////////////////////////////////////////////////
var INTERSECTED;
var theta = 0;
var pointer = new THREE.Vector2();
var radius = 100;
/////////////////////////////////////////////////////////
scene = new THREE.Scene();
scene.background = new THREE.Color(0x555555);
//purple fog
scene.fog = new THREE.FogExp2(0x860081, 0.003);
//var playCanvas = document.getElementById('playCanvas')
var renderer = new THREE.WebGLRenderer( { canvas: playCanvas } );
renderer.setSize(1000, 600);
aspr = 1.0;
//camera = new THREE.PerspectiveCamera(50, aspr, 10, 11000);
camera = new THREE.PerspectiveCamera(60, renderer.domElement.width / renderer.domElement.height, 1, 10000);
document.addEventListener("keydown", function(event) {
if (event.keyCode === 70) {
openFullscreen();
}
}, false); /* f key fullscreen FIX CSS BLUR*/
document.addEventListener("keydown", function(event) {
if (event.key === "Escape") {
document.getElementById("play").innerHTML= ":: Resume :: ";
closeFullscreen();
}
}, false);
function closeFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) { /* Safari */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) { /* IE11 */
document.msExitFullscreen();
}
renderer.domElement.style.filter = `hue-rotate(2deg) opacity(35%) contrast(420%) blur( 18px )`;
}
/*document.body.addEventListener("wheel", wheelJump);
function wheelJump() {
if (canJump === true) velocity.y += 450;
canJump = false;
console.log("canJump");
}
*/
function openFullscreen() {
playScreen();
hideVideo();
controls.lock();
//var canvas = document.getElementById("playcanvas");
var elem = document.getElementsByTagName("canvas")[1];
//blocker.style.display = 'block'; //block
//instructions.style.display = ''; //""
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) { /* Firefox */
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE/Edge */
elem.msRequestFullscreen();
}
elem.style.width = '100%';
elem.style.height = '100%';
}
function rotateObject(object, degreeX=0, degreeY=0, degreeZ=0) {
object.rotateX(THREE.Math.degToRad(degreeX));
object.rotateY(THREE.Math.degToRad(degreeY));
object.rotateZ(THREE.Math.degToRad(degreeZ));
}
//HEIGHTMAPS///////////////////////////////////////////////////////
var heightmapImage = new Image();
heightmapImage.src = mindataurl;
var grassImage = new Image();
grassImage.src = grassdataurl;
var grassTexture = new THREE.ImageUtils.loadTexture(forestdataurl);//was grassdataurl
// Remove a terrain
//scene.remove(terrainScene);
// Generate a terrain
var xS = 63, yS = 63;
terrainScene = THREE.Terrain({
easing: THREE.Terrain.Linear,
frequency: 2.5,
heightmap: heightmapImage,
//heightmap: customInfluences,
material: new THREE.MeshBasicMaterial({map:grassTexture}),
//material: new THREE.MeshBasicMaterial({color: 0xFF2200}),
map: grassImage,
maxHeight: 100,
minHeight: -100,
steps: 1,
useBufferGeometry: false,
xSegments: xS,
xSize: 1024,
ySegments: yS,
ySize: 1024,
});
scene.add(terrainScene);
//terrainPath//////////////////////////////////////////////////////
var pathImage = new Image();
pathImage.src = pathdataurl002;
//debug with :: pathdataurl002 : sanddataurl
var sandTexture = new THREE.ImageUtils.loadTexture(forestdataurl);// was sanddataurl
var xS = 40, yS = 40;
terrainPath = THREE.Terrain({
easing: THREE.Terrain.Linear,
frequency: 2.5,
heightmap: pathImage,
//heightmap: customInfluences,
material: new THREE.MeshBasicMaterial({map:sandTexture}),
//material: new THREE.MeshBasicMaterial({color: 0xFF2200}),
//map: grassImage,
maxHeight: 100,
minHeight: -100,
steps: 1,
useBufferGeometry: false,
xSegments: xS,
xSize: 1024,
ySegments: yS,
ySize: 1024,
});
terrainPath.position.y += 5;
scene.add(terrainPath);
//terrainPath instance??? //////////////////////////////////////////////////////
var pathImage = new Image();
pathImage.src = pathdataurl002;
//debug with :: pathdataurl002 : sanddataurl
var sandTexture = new THREE.ImageUtils.loadTexture(sanddataurl);
//LIGHT BLUE #798cb3
//DARK BLUE 0x335599
//CORAL #ff7f50
//var waterImage = new Image();
//waterImage.src = "./images/water.jpg";
//var waterTexture = new THREE.ImageUtils.loadTexture(waterImage);
var waterTexture = new THREE.ImageUtils.loadTexture( 'images/water.jpg' );
//ANIMATED WATERFALL
// var waterTexture = new THREE.ImageUtils.loadTexture( 'images/water.jpg' );
// waterTexture.wrapS = waterTexture.wrapT = THREE.RepeatWrapping;
//
// // use "this." to create global object
// this.customUniforms2 = {
// baseTexture: { type: "t", value: waterTexture },
// baseSpeed: { type: "f", value: 1.15 },
// noiseTexture: { type: "t", value: noiseTexture },
// noiseScale: { type: "f", value: 0.2 },
// alpha: { type: "f", value: 0.8 },
// time: { type: "f", value: 1.0 }
// };
//
// // create custom material from the shader code above
// // that is within specially labeled script tags
// var customMaterial2 = new THREE.ShaderMaterial(
// {
// uniforms: customUniforms2,
// vertexShader: document.getElementById( 'vertexShader' ).textContent,
// fragmentShader: document.getElementById( 'fragmentShader' ).textContent
// } );
//
// // other material properties
// customMaterial2.side = THREE.DoubleSide;
// customMaterial2.transparent = true;
//
// // apply the material to a surface
// var flatGeometry = new THREE.PlaneGeometry( 100, 100 );
// var surface = new THREE.Mesh( flatGeometry, customMaterial2 );
// surface.position.set(60,50,150);
// scene.add( surface );
var xS = 63, yS = 63;
terrainPath = THREE.Terrain({
easing: THREE.Terrain.Linear,
frequency: 1.5,
heightmap: pathImage,
//heightmap: customInfluences,
//material: new THREE.MeshBasicMaterial({map:waterTexture}),
material: new THREE.MeshBasicMaterial({color: 0x335599}),
//map: waterTexture,
maxHeight: 100,
minHeight: -105,
steps: 1,
useBufferGeometry: false,
xSegments: xS,
xSize: 1024,
ySegments: yS,
ySize: 1024,
});
terrainPath.position.y += 5;
scene.add(terrainPath);
render();
//terrainDeck//////////////////////////////////////////////////////
var deckImage = new Image();
deckImage.src = "data:image/png;base64,"+deckdataurl003;
//debug with :: deckdataurl : sanddataurl
var deckTexture = new THREE.ImageUtils.loadTexture(forestdataurl);
var xS = 63, yS = 63;
terrainDeck = THREE.Terrain({
easing: THREE.Terrain.Linear,
frequency: 12.5,
heightmap: deckImage,
//heightmap: customInfluences,
//material: new THREE.MeshBasicMaterial({map:deckTexture}),
material: new THREE.MeshBasicMaterial({color: 0x52361b}),
//map: grassImage,
maxHeight: -15,
minHeight: -112,
steps: 1,
useBufferGeometry: false,
xSegments: xS,
xSize: 1024,
ySegments: yS,
ySize: 1024,
});
terrainDeck.position.y += 11;
//terrainDeck.geometry = new THREE.BoxBufferGeometry(100,100,1000).toNonIndexed();
scene.add(terrainDeck);
render();
//CLIPPING DECK ///////////////////////////////////////////////
//var localPlane = new THREE.Plane( new THREE.Vector3( 0, 0, 0 ), 1 );
//var globalPlane = new THREE.Plane( new THREE.Vector3( 0, 10, 0 ), 1 );
// ??? //globalPlane.material = new THREE.MeshBasicMaterial({color: 0xff0000});
//renderer.clippingPlanes = [ globalPlane ];
//renderer.localClippingEnabled = true;
/*
var material = new THREE.MeshNormalMaterial( {
clippingPlanes: [ localPlane ],
//clipShadows: true
} );
*/
/////////////////////////////////////////////////////////
//INTERESTING RAMP GEOMETRY
/*
var xS = 63, yS = 1;
terrainDeck = THREE.Terrain({
easing: THREE.Terrain.Linear,
frequency: 2.5,
heightmap: deckImage,
//heightmap: customInfluences,
material: new THREE.MeshBasicMaterial({map:deckTexture}),
//material: new THREE.MeshBasicMaterial({color: 0xFF2200}),
//map: grassImage,
maxHeight: 50,
minHeight: -100,
steps: 1,
useBufferGeometry: false,
xSegments: xS,
xSize: 1024,
ySegments: yS,
ySize: 1024,
});
*/
//////////////////////////////////////////////////////////////////
// Optional:
// Get the geometry of the terrain across which you want to scatter meshes
var geo = terrainScene.children[0].geometry;
// Add randomly distributed foliage
decoScene = THREE.Terrain.ScatterMeshes(geo, {
mesh: new THREE.Mesh(new THREE.CylinderGeometry(2, 2, 12, 6)),
w: xS,
h: yS,
spread: 0.02,
randomness: Math.random,
});
render();
//terrainScene.add(decoScene);
// ADD BOXES AS LADDER ////////////////////////////////////////////////////////////////
/* var boxGeometry = new THREE.BoxBufferGeometry( 20, 20, 200 ).toNonIndexed();
position = boxGeometry.attributes.position;
for ( let i = 0; i < 20; i ++ ) {
const box = new THREE.Mesh( boxGeometry );
box.position.x = 400 + Math.floor( Math.random() * 10 - 10 ) * 10;
box.position.y = -100 + Math.floor( Math.random() * 10 ) * 10 + 10;
//box.position.z = -200 + Math.floor( Math.random() * 10 - 10 ) * 10;
scene.add( box );
objects.push( box );
} */
// DECK TEST //////////////////////////////////////////////////////////////
var geometry = new THREE.BoxBufferGeometry(100, 30, 500).toNonIndexed();
//var pos = geometry.attributes.position;
var material = new THREE.MeshBasicMaterial({color: 0x335599});
var deck01 = new THREE.Mesh(geometry, material);
deck01.position.x =250;
deck01.position.y =-20;
deck01.position.z =0;
deck01.name ="deck01";
scene.add(deck01);
objects.push( deck01 );
var geometry02 = new THREE.BoxBufferGeometry(200, 30, 500).toNonIndexed();
var material = new THREE.MeshBasicMaterial({color: 0x52361b});
var deck02 = new THREE.Mesh(geometry02, material); deck02.position.set(50,-700,-100);
deck02.rotation.set(0,0,0);
deck02.name ="deck02";
scene.add(deck02);
objects.push( deck02 );
var geometry02 = new THREE.BoxBufferGeometry(200, 30, 500).toNonIndexed();
var material = new THREE.MeshBasicMaterial({color: 0x52361b});
var deck03 = new THREE.Mesh(geometry02, material);
deck03.position.set(0,-30,250);
deck03.rotation.set(0,120,0);
deck03.name ="deck03";
scene.add(deck03);
objects.push( deck03 );
var geometry03 = new THREE.BoxBufferGeometry(200, 30, 500).toNonIndexed();
var material = new THREE.MeshBasicMaterial({color: 0x52361b});
var deck04 = new THREE.Mesh(geometry02, material);
deck04.position.x =-150;
deck04.position.y =10;
deck04.position.z =100;
deck04.name ="deck04";
scene.add(deck04);
objects.push( deck04 );
//AMBIENT LIGHT
var ambient = new THREE.AmbientLight( 0x00FFFF );
scene.add(ambient);
ambient.position.x =1000;
ambient.position.y =780;
ambient.position.z =-1400;
//FLIP MESH///////////////////////////////////////
var geo = terrainScene.children[0].geometry;
var crate = new THREE.Mesh( geo.clone());
flipMesh(crate);
// Add Terrain//////////////////////////////////////
render();
//}//END OF setupThreeJS
//VIGNETTE OVERLAY///////////////////////////////////////
/*
const shaderVignette = THREE.VignetteShader;
const effectVignette = new ShaderPass( shaderVignette );
effectVignette.uniforms[ 'offset' ].value = 0.95;
effectVignette.uniforms[ 'darkness' ].value = 1.6;
const rtParameters = {stencilBuffer: true};
const rtWidth = width / 2;
const rtHeight = height / 2;
shaderActive == "true";
composer = new EffectComposer( renderer, new THREE.WebGLRenderTarget( rtWidth, rtHeight, rtParameters ) );
composer.addPass( effectVignette );
*/
//PERFORMANCE :: RENDER ORDER & CULL SCENE FRONT TO BACK
//const renderBackground = new RenderPass( sceneBG, cameraOrtho );
//const renderModel = new RenderPass( sceneModel, cameraPerspective );
//renderModel.clear = false;
//composer = new EffectComposer( renderer, new THREE.WebGLRenderTarget( rtWidth * 2, rtHeight * 2, rtParameters ) );
//composer.addPass( renderBackground );
//composer.addPass( renderModel );
//composer.addPass( renderMaskInverse );
//composer.addPass( effectHBlur );
//composer.addPass( effectVBlur );
//composer.addPass( clearMask );
//renderScene = new TexturePass( composer.renderTarget2.texture );
//CBBOX////////////////////////////////////
var imagePrefix = "./images/bg04";
var directions = ["xpos", "xneg", "ypos", "yneg", "zpos", "zneg"];
var imageSuffix = ".png";
var skyGeometry = new THREE.CubeGeometry( 800, 800, 800 );
var materialArray = [];
for (var i = 0; i < 6; i++)
materialArray.push( new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture( imagePrefix + imageSuffix ) , /* + directions[i] + */
side: THREE.DoubleSide
}));
var skyMaterial = new THREE.MeshFaceMaterial( materialArray );
var skyBox = new THREE.Mesh( skyGeometry, skyMaterial );
scene.add( skyBox );
var light = new THREE.PointLight(0xffffff);
light.position.set(0,450,0);
scene.add(light);
//PLAYER START POSITION ///////////////////////////////////////
camera.position.set(250,10,26);
camera.lookAt(new THREE.Vector3(-250, -150, -2550));
scene.add(camera);
//START CAMERA SHAKE & ANIMATION
camera.lookAt(new THREE.Vector3(-250, -150, -2550));
//SETUP THREEJS
function setupThreeJS() {
document.getElementById('scenes').appendChild(renderer.domElement);
//renderer.domElement.setAttribute('tabindex', -1);
//GLTF LOADERS///////////////////////////////////////////////
// FIX :: textures & compress
var loader = new THREE.GLTFLoader();
loader.load( './models/arewerolling_jump.glb', function ( gltf ) {
var rolling = gltf.scene;
rolling.scale.set(80*rolling.scale.x,80*rolling.scale.y,80*rolling.scale.z)
rolling.rotation.y = 180;
rolling.position.set(-150,300,-250);
//var rolling2 = rolling.clone();
//rolling2.rotation.y = 100;//70
//rolling2.position.set(-150,350,-250);
scene.add( rolling );
render();
} );
var loader2 = new THREE.GLTFLoader();
loader2.load( './models/tmgw_logo_jump.glb', function ( gltf ) {
var logo = gltf.scene;
logo.scale.set(80*logo.scale.x,80*logo.scale.y,80*logo.scale.z)
logo.rotation.y = 360;
logo.position.set(-100,150,-250);
//var logo2 = logo.clone();
//logo2.position.set(-250,80,-150);
//logo2.rotation.y = 270;
scene.add( logo );
render();
} );
//ADD :: feather particles
var loader3 = new THREE.GLTFLoader();
loader3.load( './models/tmgw_text_pillowfight.glb', function ( gltf ) {
var text = gltf.scene;
text.scale.set(80*text.scale.x, 80*text.scale.y, 80 * text.scale.z)
text.rotation.y = 310;
text.position.set(-100,200,-150);
scene.add( text );
render();
} );
/*
var loader5 = new THREE.GLTFLoader();
loader5.load( './models/SCENES_X4_001_nonindexed.glb', function ( gltf ) {
var scenesx4 = gltf.scene;
scenesx4.scale.set(50*scenesx4.scale.x, 50*scenesx4.scale.y, 50*scenesx4.scale.z)
scenesx4.rotation.y = 360;
scenesx4.position.set(0,0,0);
scene.add( scenesx4);
render();
} );*/
var loader6 = new THREE.GLTFLoader();
loader6.load( './models/random_objects_01.glb', function ( gltf ) {
var random01 = gltf.scene;
random01.scale.set(80*random01.scale.x, 80*random01.scale.y, 80*random01.scale.z)
random01.rotation.set(0,-30,0);
random01.position.set(0,-90,0);
scene.add( random01);
render();
} );
var ambient = new THREE.AmbientLight( 0x555555 );
scene.add(ambient);
/*var materialSphere01 = new THREE.MeshLambertMaterial({
color: 0x0000ff,
transparent: true,
opacity: 0.5
});
*/
clock = new THREE.Clock(false);
// STAR//////////////
///*
var starPoints = [];
starPoints.push( new THREE.Vector2 ( 0, 50 ) );
starPoints.push( new THREE.Vector2 ( 10, 10 ) );
starPoints.push( new THREE.Vector2 ( 40, 10 ) );
starPoints.push( new THREE.Vector2 ( 20, -10 ) );
starPoints.push( new THREE.Vector2 ( 30, -50 ) );
starPoints.push( new THREE.Vector2 ( 0, -20 ) );
starPoints.push( new THREE.Vector2 ( -30, -50 ) );
starPoints.push( new THREE.Vector2 ( -20, -10 ) );
starPoints.push( new THREE.Vector2 ( -40, 10 ) );
starPoints.push( new THREE.Vector2 ( -10, 10 ) );
var starShape = new THREE.Shape( starPoints );
var extrusionSettings = {
size: 5, height: 2, curveSegments: 3,
bevelThickness: 1, bevelSize: 2, bevelEnabled: false,
material: 0, extrudeMaterial: 1
};
var starGeometry = new THREE.ExtrudeGeometry( starShape, extrusionSettings );
var materialFront = new THREE.MeshBasicMaterial( { color: 0xFFFFFF } );
var materialSide = new THREE.MeshBasicMaterial( { color: 0xFFFFFF } );
var materialArray = [ materialFront, materialSide ];
var starMaterial = new THREE.MeshFaceMaterial(materialArray);
var star = new THREE.Mesh( starGeometry, starMaterial );
star.name = "star";
//var wireframeTexture = new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, transparent: true } );
//var star = new THREE.Mesh( starGeometry, wireframeTexture );
star.position.set(-202,90,231);
//star.position.set(250,50,131);
star.rotation.y = Math.PI / 2;
scene.add(star);
objects.push( star );
var color = 0xFF0000;
var intensity = 2;
var starlight = new THREE.DirectionalLight(color, intensity);
//var lightz = new THREE.SpotLightHelper();
starlight.position.set(-212,90,231);
starlight.target.position.set(-212,90,231);
scene.add(starlight);
scene.add(starlight.target);
//ATTACH HELP TO CAMERA AS GUIDE GAME MECHANIC
var helper = new THREE.DirectionalLightHelper(starlight);
scene.add(helper);
////////TRIGGER NEW SCENES :: KITCHEN //////
//ADMIN SHORTCUTS :: SCENE NUMBERS :: 0 MENU
// ATTACH TRIGGER//RAYCASTER TO STAR + CAMERA
//RAYCASTER ////////////////////////////////////////////////
/* document.addEventListener( 'mousemove', onPointerMove );
//
window.addEventListener( 'resize', onWindowResize );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function onPointerMove( event ) {
pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
}*/
/////////////////////////////////////////////////////////
////////////////////////////////////////
//*/
// MERGING
/*
var blueMaterial = new THREE.MeshPhongMaterial({
color: 0x0000FF
});
var redMaterial = new THREE.MeshPhongMaterial({
color: 0xFF0000
});
var boxGeometry = new THREE.BoxGeometry(10, 10, 10);
for (var face in boxGeometry.faces) {
boxGeometry.faces[face].materialIndex = 0;
}
var sphereGeometry = new THREE.SphereGeometry(5, 16, 16);
sphereGeometry.applyMatrix(new THREE.Matrix4().makeTranslation(0, 5, 0));
var mergeGeometry = new THREE.Geometry();
mergeGeometry.merge(boxGeometry, boxGeometry.matrix);
mergeGeometry.merge(sphereGeometry, sphereGeometry.matrix, 1);
var mesh = new THREE.Mesh(mergeGeometry, [blueMaterial, redMaterial]);
mesh.position.set(-202,60,-331);
scene.add(mesh);
var material = new THREE.MeshNormalMaterial();
var cubeGeometry = new THREE.CubeGeometry( 80, 80, 80 );
var cube = new THREE.Mesh( mesh, material );
cube.position.set(-200,-60,-331);
//scene.add( cube );
*/
//OUTLINES////////////////////////////////////////////////
//ADD OUTLINE for loop OR direct function ?
var cbBox = new THREE.CubeGeometry( 400, 400, 400 );
var cbTexture = new THREE.ImageUtils.loadTexture( 'images/cbmerch01.png' );
var cbMaterial = new THREE.MeshBasicMaterial( { map: cbTexture, side: THREE.DoubleSide } );
var cbMerch01 = new THREE.Mesh( cbBox, cbMaterial );
cbMerch01.position.set(-200,-60,-331);
scene.add( cbMerch01 );
//purple
/*
var outlineMaterial2 = new THREE.MeshBasicMaterial( { color: 0xffffff, side: THREE.BackSide } );
var outlineMesh2 = new THREE.Mesh( cbBox, outlineMaterial2 );
outlineMesh2.position = cbMerch01.position;
outlineMesh2.scale.multiplyScalar(1.02);
*/
//white
/*
var outlineMaterial3 = new THREE.MeshBasicMaterial( { color: 0x860081, side: THREE.BackSide } );
var outlineMesh3 = new THREE.Mesh( cbBox, outlineMaterial3 );
outlineMesh3.position = cbMerch01.position;
outlineMesh3.scale.multiplyScalar(1.01);
scene.add( cbMerch01, outlineMesh3 , outlineMesh2);
*/
//note:: GROUP "add" & SET THE DRAW ORDER !!! RENDER ERROR SOLUTION???
///CUSTOM CARDBOARD BOX IMAGES////////////////////////////
/* create an array with six textures for a cool cube
var materialArray = [];
materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'images/Dice-Blue-1.png' ) }));
materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'images/Dice-Blue-6.png' ) }));
materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'images/Dice-Blue-2.png' ) }));
materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'images/Dice-Blue-5.png' ) }));
materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'images/Dice-Blue-3.png' ) }));
materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'images/Dice-Blue-4.png' ) }));
var DiceBlueMaterial = new THREE.MeshFaceMaterial(materialArray);
var DiceBlueGeom = new THREE.CubeGeometry( 85, 85, 85, 1, 1, 1 );
var DiceBlue = new THREE.Mesh( DiceBlueGeom, DiceBlueMaterial );
DiceBlue.position.set(60, 50, -100);
scene.add( DiceBlue );
*/
//CLONE & REPOSITION
////////////////////////////////////////////////////////////////
blocker = document.getElementById('blocker');
instructions = document.getElementById('instructions');
play = document.getElementById('play');
};
//??? CHANGE TO PLAY, LEARN, ACTION + REMOVE LISTENERS
//END THREEJS SETUP ///////////////////
function removeEntity(object) {
var selectedObject = scene.getObjectByName(object.name);
scene.remove( selectedObject );
animate();
}
function loadKitchenScene() {
//REMOVE OBJECTS FROM LAST SCENES
for( var i = scene.children.length - 1; i >= 0; i--) {
obj = scene.children[i];
scene.remove(obj);
}
var geometry04 = new THREE.BoxBufferGeometry(2100, 30, 800).toNonIndexed();
var material = new THREE.MeshBasicMaterial({color: 0x00FFFF});
var island = new THREE.Mesh(geometry04, material);
island.position.x =700;
island.position.y =380;
island.position.z =-1400;
island.name ="island";
scene.add(island);
objects.push( island );
scene.add( skyBox );
// ON DEMAND LOAD KITCHEN + ELEMENTS
var loader4 = new THREE.GLTFLoader();
loader4.load( './models/kitchen/kitchen09.glb', function ( gltf ) {
var kitchen = gltf.scene;
kitchen.scale.set(500*kitchen.scale.x, 500*kitchen.scale.y, 500*kitchen.scale.z)
//kitchen.rotation.y = 360;
kitchen.position.set(-1902,-100,-1931);
scene.add( kitchen);
render();
} );
//KITCHEN FLOOR
var floorGeometry1 = new THREE.PlaneGeometry(10000, 10000, 10, 10);
var floor1 = new THREE.Mesh(floorGeometry1, floorMaterial );
floor1.position.y = 3000;
//floor1.position.z = 3000;
//floor1.rotation.x = Math.PI /4;
scene.add(floor1);
rotateObject(floor1, 40, 30, 20);
var floor1 = new THREE.Mesh(floorGeometry1, floorMaterial );
floor1.position.y = 3000;
scene.add(floor1);
rotateObject(floor1, 40, 30, 20);
//KITCHEN WALLS
//from island right
var wall01 = new THREE.Mesh(floorGeometry1, floorMaterial );
wall01.name = "wall01";
wall01.color
wall01.rotation.y = Math.PI / 2;
wall01.rotation.x = Math.PI / 2;
wall01.position.x = -6000;
//
var wall02 = new THREE.Mesh(floorGeometry1, floorMaterial );
wall01.name = "wall02";
wall01.rotation.x = Math.PI;
wall01.position.z = 6000;
var wall03 = new THREE.Mesh(floorGeometry1, floorMaterial );
wall01.name = "wall03";
wall03.rotation.x = Math.PI ;
wall03.position.z = 6000;
var wall04 = new THREE.Mesh(floorGeometry1, floorMaterial );
wall01.name = "wall04";
wall04.rotation.x = Math.PI * 4;
wall04.position.z = -6000;
scene.add(wall01,wall02,wall03,wall04);
// MOVE BALLOONS, MERCH FLOOD WATER + OPEN BOX LID
//MOVE TO ISLAND TOP + REMOVE FOG
scene.fog = '';
scene.fog = new THREE.FogExp2(0x330088, 0.0009);
camera.position.set(302,410,-1200);
camera.lookAt(new THREE.Vector3(0, 0, 0));
//scene.remove(floor1,wall01,wall02,wall03,wall04);
// floor terrain star lights cbmerch //gltfs balloons
//close kitchen scene
};
//listener
//play.addEventListener('click', function() {
function playScreen() {
//hide mask image ???
//renderer.domElement.style.maskImage = "";
// CREATE FILTER SETTINGS BLURRED PAUSED & CURRENT SCENE ACTIVE
renderer.domElement.style.filter = `hue-rotate(2deg) opacity(35%) contrast(220%) blur( 1px )`;
controls.lock();
};
// }, false);
controls = new THREE.PointerLockControls(camera, renderer.domElement);
controls.addEventListener('lock', function() {
instructions.style.display = 'none';
blocker.style.display = 'none';
hideVideo()
});
controls.addEventListener('unlock', function() {
blocker.style.display = 'block'; //block
instructions.style.display = ''; //""
});
scene.add(controls.getObject());
var onKeyDown = function(event) {
switch (event.keyCode) {
case 38: // up
case 87: // w
moveForward = true;
break;
case 37: // left
case 65: // a
moveLeft = true;
break;
case 40: // down
case 83: // s
moveBackward = true;
break;
case 39: // right
case 68: // d
moveRight = true;
break;
case 46:// c
case 45:// x
case 44:// z
case 32: // space
if (canJump === true) velocity.y += 450;
canJump = false;
break;
}
};
var onKeyUp = function(event) {
switch (event.keyCode) {
case 38: // up
case 87: // w
moveForward = false;
break;
case 37: // left
case 65: // a
moveLeft = false;
break;