-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3D-Fairey-IIID.html
680 lines (590 loc) · 22.4 KB
/
3D-Fairey-IIID.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
<!DOCTYPE html>
<html lang="pt-PT">
<head>
<title>3D MODELS - © 2018 Jorge Rosa</title>
<meta charset="UTF-8" />
<!--
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="s-web-app-capable" content="yes"/>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
-->
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size:14px;
color:#BBBBBB;
background-color:#000000;
margin:0px;
overflow:hidden;
}
#info {
color:#BBBBBB;
position:absolute;
top:10px;
width:100%;
text-align:center;
z-index:100;
display:block;
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
#info a, .button {
font-weight:bold;
color:#FFFFFF;
text-decoration:none;
width:100%;
text-align:center;
}
/*
#progressbar {
width:30px;
height:20px;
color:#ffffff;
background-color:Red;
border:1px solid #cccccc;
align-items:center;
text-align:center;
margin: 0 auto;
}
*/
/* Loading */
#loading_container {
width: 50px;
height: 50px;
position: fixed;
color: #ffffff;
background-color: transparent;
top: 50%;
left: 50%;
margin-top: -25px;
margin-left: -25px;
border: 0px solid #000000;
}
#loading_image {
border: 0px solid #000000;
}
</style>
</head>
<body>
<!-- HTML Displayers -->
<!-- <div id="progressbar"></div> -->
<div id="loading_container"><img id="loading_image" src="loading.gif" alt="Loading..."></div>
<div id="info"></div>
<!-- 3D Core -->
<script type="text/javascript" src="THREE/Detector.js" charset="UTF-8"></script>
<script type="text/javascript" src="THREE/BUILD/three.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="THREE/libs/stats.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="THREE/Mirror.js" charset="UTF-8"></script>
<script type="text/javascript" src="THREE/controls/OrbitControls.js" charset="UTF-8"></script>
<!-- Loaders -->
<script type="text/javascript" src="THREE/loaders/MTLLoader.js" charset="UTF-8"></script>
<script type="text/javascript" src="THREE/loaders/OBJLoader.js" charset="UTF-8"></script>
<!-- The 3D Scene -->
<script type="text/javascript" charset="ISO-8859-1">
/*
Author: Jorge Rosa (Portugal) with love to ASCR! - Email: jorge.bigarte@gmail.com
Portfolio: https://jorgerosa.github.io/angelimoto/JORGE-ROSA-PORTFOLIO
Facebook: https://www.facebook.com/jorge.bigarte
*/
// --------------------------------------------------------------------------
// This Model Specific Variables:
var path = '3D-Fairey-IIID/'; // <--- Path for WEB VIEW
// var path = 'https://jorgerosa.github.io/angelimoto/JORGE-ROSA-PORTFOLIO/works-3D/3D-Fairey-IIID/' // <--- Path for LOCAL DEBUG
var distance = 560; // 650
// --------------------------------------------------------------------------
// Internet Browser has WebGl?...
if (!Detector.webgl){
document.getElementById('info').innerHTML = 'INFO:<br>Your web browser does not support WebGL';
};
// Common Global Variables:
var container;
var stats;
var camera, mirrorscamera, scene, renderer, controls;
var mWIDTH = window.innerWidth/2;
var mHEIGHT = window.innerHeight/2;
var autorotatetimeout;
var maxanisotropy = 1;
var ambientlight;
var light1, lightIsOn = false; rotationStarted = false;
// var helper1, helper2;
var mirrors;
var skytexture;
// var composer, hblur, vblur;
// Run:
initialize();
fill();
draw();
// --------------------------------------------------------------------------
// Function: Initialize 3D Javascript
function initialize() {
window.addEventListener('resize', onWindowResize, false);
container = document.createElement('div');
document.body.appendChild(container);
document.body.style.cursor = 'move';
// Renderer:
renderer = new THREE.WebGLRenderer({ antialias:true, alpha:true });
container.appendChild(renderer.domElement);
renderer.setClearColor(0x000000, 1.0);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.sortObjects = true; // false == The objects will render in the order they are added to the scene
renderer.autoClear = true;
renderer.shadowMap.enabled = true;
renderer.shadowMapSoft = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // THREE.BasicShadowMap | THREE.PCFShadowMap | THREE.PCFSoftShadowMap
maxanisotropy = renderer.getMaxAnisotropy();
// Scene:
scene = new THREE.Scene();
// Global light:
ambientlight = new THREE.AmbientLight(0x1A1A1A); // ex: 0x303030, ex: 0xFFFFFF, ex: 0xCCCCCC - Hexadecimal color (recommended)
scene.add(ambientlight);
// Fog:
// scene.fog = new THREE.FogExp2(0xBBBBBB, 0.0010); // Near
// Camera: (Normal)
camera = new THREE.PerspectiveCamera(25, window.innerWidth/window.innerHeight, 1.0, 3000); // Normal FOV is 45, PerspectiveCamera( fov, aspect, near, far )
scene.add(camera); // Attach first!
camera.position.set(0, 55, distance);
// camera.position.set(0, -110.0, distance);
// camera.target.set(0, 77, 0); // view direction perpendicular to XY-plane
camera.castShadow = false;
camera.receiveShadow = false;
// Light 1: (Attached to the camera)
light1 = new THREE.SpotLight(0xFFFFFF); // https://threejs.org/docs/api/lights/SpotLight.html
camera.add(light1); // Attach first!
// light1.position.set(camera.position.x, camera.position.y, camera.position.z); // == To be in the SAMME position of camera == Gives Glitches !!!
light1.castShadow = true;
light1.receiveShadow = false;
// light1.shadowMapVisible = true;
light1.shadow.mapSize.width = 1024; // 1024
light1.shadow.mapSize.height = 1024; // 1024
light1.shadow.camera.near = 1;
light1.shadow.camera.far = 3000;
light1.shadow.camera.fov = THREE.Math.radToDeg(2*light1.angle);
light1.intensity = 0.50;
/*
// Light 1 Target:
var light1target = new THREE.Object3D();
camera.add(light1target); // Attach first!
light1target.name = 'lightTarget1';
light1target.position.set(0, 70.0, 0);
light1target.add(light1);
light1target.castShadow = true;
light1target.receiveShadow = false;
// Add a target to this light:
light1.target = light1target;
light1.visible = false; // Light is OFF
*/
// Controls:
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.target.set(0, 70.0, 0); // View direction
controls.autoRotate = false;
controls.enableRotate = true;
controls.enableZoom = false;
controls.enablePan = false;
controls.enableDamping = false;
// Movements:
controls.autoRotateSpeed = 5.0;
controls.dampingFactor = 0.25; // 0.25 is default
controls.rotationSpeed = 0.50;
controls.movementSpeed = 0.50;
controls.lookSpeed = 0.05;
controls.rollSpeed = 0.50;
// Zoom:
controls.zoomSpeed = 0.50; // 1.0 is default
controls.minDistance = distance;
controls.maxDistance = 250;
// Where to stop Y rotation:
// controls.minPolarAngle = Math.PI/8; // radians (Altura maxima)
// controls.maxPolarAngle = Math.PI/2 - 0.05; // radians (Altura minima), - 0.05 para evitar transparencies glitches (sombra que vem com o modelo)
// controls.mouseButtons = { PAN:THREE.MOUSE.LEFT, ZOOM:THREE.MOUSE.MIDDLE, ORBIT:THREE.MOUSE.RIGHT }; // swapping left and right buttons
// THREE.MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 0 };
controls.mouseButtons = { ORBIT: THREE.MOUSE.LEFT };
// stop autorotate after the first interaction
controls.addEventListener('start', function(){
clearTimeout(autorotatetimeout); // Reset Delay
controls.autoRotate = false;
});
// Restart autorotate after the last interaction & an idle time has passed
controls.addEventListener('end', function(){
autorotatetimeout = setTimeout(function(){
controls.autoRotate = true;
}, 1000); // Delay 1000 == 1 Second
});
// Effects:
/*
composer = new THREE.EffectComposer( renderer );
composer.addPass( new THREE.RenderPass( scene, camera ) );
hblur = new THREE.ShaderPass( THREE.HorizontalBlurShader );
composer.addPass( hblur );
vblur = new THREE.ShaderPass( THREE.VerticalBlurShader );
vblur.renderToScreen = true;
composer.addPass( vblur );
*/
}; // End: initialize()
// --------------------------------------------------------------------------
// Function: Create 3D World
function fill() {
// Progressbar:
/*
var progressbar = document.getElementById('progressbar');
var loadingmanager = new THREE.LoadingManager();
// Loading...
loadingmanager.onProgress = function (item, loaded, total) {
progressbar.style.width = (loaded/total*100) + '%';
console.log(item, loaded, total); // Write to console...
};
// Loaded...
loadingmanager.onLoad = function () {
progressbar.style.display = 'none'; // Hide
progressbar.style.visibility = 'hidden'; // Hide
// document.getElementById('info').innerHTML = 'Botão esquerdo do RATO: <strong>Rotação</strong>';
console.log('All items were loaded!'); // Write to console...
};
// Error...
loadingmanager.onError = function () {
progressbar.style.display = 'none'; // Hide
progressbar.style.visibility = 'hidden'; // Hide
console.log('There has been an error...'); // Write to console...
};
*/
// Animated Loading GIF:
var loading_container = document.getElementById('loading_container');
var loading_image = document.getElementById('loading_image');
var loadingmanager = new THREE.LoadingManager();
// Loading...
loadingmanager.onProgress = function (item, loaded, total) {
console.log(item, loaded, total); // Write to console...
};
// Loaded...
loadingmanager.onLoad = function () {
loading_container.style.display = 'none'; // Hide
loading_container.style.visibility = 'hidden'; // Hide
loading_image.style.display = 'none'; // Hide
loading_image.style.visibility = 'hidden'; // Hide
// document.getElementById('info').innerHTML = 'Botão esquerdo do RATO: <strong>Rotação</strong>';
console.log('All items were loaded!'); // Write to console...
};
// Error...
loadingmanager.onError = function () {
loading_container.style.display = 'none'; // Hide
loading_container.style.visibility = 'hidden'; // Hide
loading_image.style.display = 'none'; // Hide
loading_image.style.visibility = 'hidden'; // Hide
console.log('There has been an error...'); // Write to console...
};
// Tool: Degrees Function
var setDegrees = function(degree) { return degree*(Math.PI/180); };
// 1) 3D Model: Create the SKY (Background)
var skygeometry = new THREE.SphereGeometry(500, 8, 8);
skytexture = new THREE.TextureLoader(loadingmanager).load(path+'maps/World-Map.jpg', function(material) {
material = new THREE.MeshBasicMaterial({ map:skytexture }); // MeshBasicMaterial == No affected by lights
var skymesh = new THREE.Mesh(skygeometry, material);
scene.add(skymesh);
// skymesh.material.side = THREE.BackSide; // Side to render
skymesh.scale.x = -1; // Flip mesh (texture) horizontally
skymesh.castShadow = false;
skymesh.receiveShadow = false;
});
// 2) 3D Model: Plane Model
var mtlLoader = new THREE.MTLLoader(loadingmanager);
mtlLoader.setTexturePath(path);
mtlLoader.setPath(path);
mtlLoader.load('FAIREY-III.mtl', function(materials) {
materials.preload();
var objLoader = new THREE.OBJLoader(loadingmanager);
objLoader.setMaterials(materials);
objLoader.setPath(path);
objLoader.load('FAIREY-III.obj', function (object) {
scene.add(object); // Attach first!
object.name = 'Model1';
object.scale.set(1,1,1);
object.position.set(0, 70.0, 0);
// object.rotateY(-Math.PI/2.8); // To start with a lateral view
// object.rotateY(setDegrees(-60)); // To start with a lateral view
// object.renderOrder = 2;
set_materials_for('Model1');
// create_mirror_effect_for('Espelho_001');
// create_mirror_effect_for('Espelho_002');
// create_reflexes_for('Body_01'); --- TODO
});
});
// 3) 3D Model: Helice Model
var mtlLoader = new THREE.MTLLoader(loadingmanager);
mtlLoader.setTexturePath(path);
mtlLoader.setPath(path);
mtlLoader.load('FAIREY-III-HELICE.mtl', function(materials) {
materials.preload();
var objLoader = new THREE.OBJLoader(loadingmanager);
objLoader.setMaterials(materials);
objLoader.setPath(path);
objLoader.load('FAIREY-III-HELICE.obj', function (object) {
scene.add(object); // Attach first!
object.name = 'Model2';
object.scale.set(1,1,1);
object.position.set(-0.0, 62.0, 54.0);
// object.rotateY(-Math.PI/2.8); // To start with a lateral view
// object.rotateY(setDegrees(-60)); // To start with a lateral view
// object.renderOrder = 2;
set_materials_for('Model2');
// create_mirror_effect_for('Espelho_001');
// create_mirror_effect_for('Espelho_002');
// create_reflexes_for('Body_01'); --- TODO
});
});
// THREE.SceneUtils.attach( child, scene, parent );
// THREE.SceneUtils.attach( 'Model2', scene, 'Model1' );
// Make all materials double sided:
function set_materials_for(name) {
var object = scene.getObjectByName(name, true);
if (object!=null){
object.traverse( function(node) {
if (node.texture){
node.texture.anisotropy = maxanisotropy; // High quality textures
};
if (node.material){
node.material.side = THREE.DoubleSide;
node.material.fog = false;
node.castShadow = true;
node.receiveShadow = true;
// console.log( name + ' mat' ); // Write to console...
};
});
};
};
/*
// Create real-time mirrors: (material from camera)
mirrorscamera = new THREE.CubeCamera(50, 5000, 64); // Since the sky, to be reflected, is at 4000...
mirrors = new THREE.MeshPhongMaterial({ side:THREE.FrontSide, emissive:0xFFFFFF, envMap:mirrorscamera.renderTarget });
// mirrors = new THREE.MeshBasicMaterial({ side:THREE.FrontSide, emissive:0xFFFFFF, envMap:mirrorscamera.renderTarget });
mirrors.castShadow = false;
mirrors.receiveShadow = false;
// Apply mirror materials:
function create_mirror_effect_for(name) {
var object = scene.getObjectByName(name, true);
if (object!=null){
object.traverse( function(node) {
if (node.name == name){
node.material = mirrors; // Apply mirror material
mirrorscamera.position = node.position;
mirrorscamera.rotation = node.rotation;
};
});
console.log( 'Mirror: Found node: ' + name ); // Write to console...
} else {
console.log( 'Mirror: Missing node: ' + name ); // Write to console...
};
};
*/
/*
// 3) Lines: Create Lines...
var groupinfos = new THREE.Object3D(); // Create an empty container
scene.add(groupinfos); // Attach first!
var linesmaterial = new THREE.LineBasicMaterial({ color:0xFFFFFF }); // Common lines material
// Line n.1: (Altura chao ate ao guiador)
var geometry1 = new THREE.Geometry();
geometry1.vertices.push( new THREE.Vector3(-5, 50.5, 5), new THREE.Vector3(-5, 74.5, 5) );
var line1 = new THREE.Line(geometry1, linesmaterial);
groupinfos.add(line1);
// Line n.2: (Altura chao ate ao selim)
var geometry2 = new THREE.Geometry();
geometry2.vertices.push( new THREE.Vector3(5, 50.5, 5), new THREE.Vector3(5, 66.0, 5) );
var line2 = new THREE.Line(geometry2, linesmaterial);
groupinfos.add(line2);
// Line n.3: (Comprimento total do veiculo)
var geometry3 = new THREE.Geometry();
geometry3.vertices.push( new THREE.Vector3(-16, 50.5, 5), new THREE.Vector3(18, 50.5, 5) );
var line3 = new THREE.Line(geometry3, linesmaterial);
groupinfos.add(line3);
// Line n.4: (Largura do guiador)
var geometry4 = new THREE.Geometry();
geometry4.vertices.push( new THREE.Vector3(-5, 74.5, 8), new THREE.Vector3(-5, 74.5, -8) );
var line4 = new THREE.Line(geometry4, linesmaterial);
groupinfos.add(line4);
// 4) 2D Stuff: Sprites
// Sprite n.1: (Largura do guiador)
var spriteInfo1TextureLoader = new THREE.TextureLoader(loadingmanager).load(path+'maps/sprite_dim1.png', function(material) {
material = new THREE.SpriteMaterial({ map:spriteInfo1TextureLoader }); // SpriteMaterial == No affected by lights
var sprite = new THREE.Sprite(material);
groupinfos.add(sprite); // Attach first!
sprite.name = 'mySpriteInfo1';
sprite.position.set(-5, 76, 0);
sprite.scale.set(6, 3, 1); // imageWidth, imageHeight
// sprite.material.side = THREE.BackSide;
sprite.castShadow = false;
sprite.receiveShadow = false;
});
// Sprite n.2: (Altura chao ate ao selim)
var spriteInfo2TextureLoader = new THREE.TextureLoader(loadingmanager).load(path+'maps/sprite_dim2.png', function(material) {
material = new THREE.SpriteMaterial({ map:spriteInfo2TextureLoader }); // SpriteMaterial == No affected by lights
var sprite = new THREE.Sprite(material);
groupinfos.add(sprite); // Attach first!
sprite.name = 'mySpriteInfo2';
sprite.position.set(5, 60, 6);
sprite.scale.set(6, 3, 1); // imageWidth, imageHeight
// sprite.material.side = THREE.BackSide;
sprite.castShadow = false;
sprite.receiveShadow = false;
});
// Sprite n.3: (Altura chao ate ao guiador)
var spriteInfo3TextureLoader = new THREE.TextureLoader(loadingmanager).load(path+'maps/sprite_dim3.png', function(material) {
material = new THREE.SpriteMaterial({ map:spriteInfo3TextureLoader }); // SpriteMaterial == No affected by lights
var sprite = new THREE.Sprite(material);
groupinfos.add(sprite); // Attach first!
sprite.name = 'mySpriteInfo3';
sprite.position.set(-5, 66, 6);
sprite.scale.set(6, 3, 1); // imageWidth, imageHeight
// sprite.material.side = THREE.BackSide;
sprite.castShadow = false;
sprite.receiveShadow = false;
});
// Sprite n.4: (Comprimento total do veiculo)
var spriteInfo4TextureLoader = new THREE.TextureLoader(loadingmanager).load(path+'maps/sprite_dim4.png', function(material) {
material = new THREE.SpriteMaterial({ map:spriteInfo4TextureLoader }); // SpriteMaterial == No affected by lights
var sprite = new THREE.Sprite(material);
groupinfos.add(sprite); // Attach first!
sprite.name = 'mySpriteInfo4';
sprite.position.set(18, 52, 5);
sprite.scale.set(6, 3, 1); // imageWidth, imageHeight
// sprite.material.side = THREE.BackSide;
sprite.castShadow = false;
sprite.receiveShadow = false;
});
*/
/*
// Fonts ( Convert font '.ttf' to '.json' or '.js': http://gero3.github.io/facetype.js/ )
var fontLoader = new THREE.FontLoader(loadingmanager);
fontLoader.load(path+'maps/fonte1.json', function (font) {
var textgeometry = new THREE.TextGeometry("Bicicleta", {
font:font,
size:3,
height:1,
curveSegments:12,
bevelThickness:0,
bevelSize:0,
bevelEnabled:false
});
var textmaterial = new THREE.MeshBasicMaterial({side:THREE.DoubleSide, color:0xFFFFFF});
var textmesh = new THREE.Mesh(textgeometry, textmaterial);
groupinfos.add(textmesh);
// camera.add(textmesh);
textmesh.position.set(0, 70, 0);
});
*/
/*
// Add this infos group to the main scene:
groupinfos.rotateY(setDegrees(-40)); // To match lines with the main model rotation
groupinfos.visible = true;
*/
/*
// load a texture, set wrap mode to repeat
var original = new THREE.TextureLoader().load(path+'maps/text_metallics.jpg');
var reflex = new THREE.TextureLoader().load(path+'maps/reflex.jpg');
// var originaltexture = new THREE.TextureLoader(loadingmanager).load(path+'maps/text_metallics.jpg', function(material) {
var reflexes = new THREE.MeshPhongMaterial({
side:THREE.DoubleSide,
color:0xFFFFFF,
// ambient:0xFFFFFF,
// shininess: 50,
// specular:0x555555,
map:original,
// envMap:skytexture,
// envMap:reflex,
alphaMap:mirrorscamera.renderTarget,
// alphaMap:mirrorscamera.renderTarget,
combine:THREE.MixOperation,
reflectivity:0.9
});
reflexes.needsUpdate = true;
// Apply reflective materials:
function create_reflexes_for(name) {
var object = scene.getObjectByName(name, true);
if (object!=null){
object.traverse( function(node) {
if (node.name == name){
node.material = reflexes; // Apply reflex material
node.material.side = THREE.DoubleSide;
node.material.fog = false;
node.castShadow = true;
node.receiveShadow = true;
};
});
console.log( 'Reflex: Found node: ' + name ); // Write to console...
} else {
console.log( 'Reflex: Missing node: ' + name ); // Write to console...
};
};
*/
// 3) 2D Stuff: Create Sprites
var spriteTitleTextureLoader = new THREE.TextureLoader(loadingmanager).load(path+'maps/sprite_title.png', function(material) {
material = new THREE.SpriteMaterial({ map:spriteTitleTextureLoader }); // SpriteMaterial == No affected by lights
var sprite = new THREE.Sprite(material);
camera.add(sprite); // Attach first!
sprite.name = 'mySpriteTitle';
sprite.position.set(0, 17.8, -105);
sprite.scale.set(20, 10, 1.0); // x,y imageWidth, z imageHeight
// sprite.material.side = THREE.BackSide;
sprite.castShadow = false;
sprite.receiveShadow = false;
});
}; // End: fill()
// --------------------------------------------------------------------------
// Animation: Rotation (for Helice)
function rotation_animation(name) {
var object = scene.getObjectByName(name, true);
if (object!=null){
object.traverse( function(node) {
if (node!=null){
node.rotation.z -= 0.30; // 0.15
};
});
};
};
// Lights:
function lightwaiting() {
// setTimeout(function (){ light1.visible = true; }, 1000); // Delay 1000 == 1 Second
setTimeout(function (){ light1.visible = true; lightIsOn = true; ambientlight.color.setHex(0x5A5A5A); }, 1000); // Delay 1000 == 1 Second
};
// Starts now the rotation:
function rotationwaiting() {
setTimeout(function (){ controls.autoRotate = true; rotationStarted = true; }, 1000); // Delay 1000 == 1 Second
};
// Global:
function onWindowResize() {
// mWIDTH = window.innerWidth/2;
// mHEIGHT = window.innerHeight/2;
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
};
// --------------------------------------------------------------------------
// Function: Render 3D World
function draw() {
// Debug Only:
// console.log( 'Camera X: ' + camera.position.x ); // Write to console...
// Turn ON Lights & Start the Screen Rotation & Start Helice Rotation:
if(!lightIsOn){ lightwaiting(); };
if(lightIsOn && !rotationStarted){ rotationwaiting(); };
if(lightIsOn){ rotation_animation('Model2'); };
// Controls:
if (controls != null){ controls.update(); };
// Render Elements:
if (renderer != null){ renderer.render(scene, camera); };
// Render real-time Mirrors:
// if (mirrorscamera != null){ mirrorscamera.updateCubeMap(renderer, scene); };
// Effects:
// composer.render();
// Mirror: (Must be after main renderer!... Else sometimes render, sometimes not)
// if (mirror1 != null){ mirror1.render(); };
// if (mirror2 != null){ mirror2.render(); };
// Stats:
// if (stats != null){ stats.update(); };
// Render: (Loops this function itself)
requestAnimationFrame(draw);
};
</script>
</body>
</html>