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
|
<!DOCTYPE html>
<html>
<head>
<script src="three.min.js"></script>
<script src="mannequin.js"></script>
<style>
body {color: black; text-shadow: 0 0 4px gray; font-family: Calibri;}
h1 {position: fixed; z-index: 10; top: 0; left: 0; text-align: center; width: 100%;}
div {position: fixed; z-index: 10; bottom: 1em; left: 1em; font-size: 1.5em; font-style: italic;}
</style>
</head>
<body>
<!-- Сложете реално заглавие -->
<h1>Jotaro vs Kira</h1>
<!-- Сложете описание на сцената (опитайте с рима) -->
<div>
Сцена на една аниме битка<br>
която може да се види <a href="https://www.youtube.com/watch?v=aCFXvoJKEPM" target="_blank">тука</a>!
</div>
<script>
/**
** Сцена
**/
/*
* Инициализация
*/
var renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.domElement.style = 'width:100%; height:100%; position:fixed; top:0; left:0;';
renderer.setAnimationLoop(drawFrame);
renderer.shadowMap.enabled = true;
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
scene.background = new THREE.Color( 0xdcba5c );
var aspect = window.innerWidth/window.innerHeight;
var camera = new THREE.PerspectiveCamera( 30, aspect );
camera.position.set( 400, 50, 90 );
var camLookAt = lookingDirectionVec(camera, [-10, 0, 0]);
camera.lookAt( camLookAt );
function onWindowResize(event)
{
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight, true);
}
window.addEventListener('resize', onWindowResize, false);
onWindowResize();
clock = new THREE.Clock();
/*
* Земя
*/
const sceneSize = 1000;
var ground = new THREE.Mesh(new THREE.PlaneBufferGeometry(sceneSize * 1.5, sceneSize),
new THREE.MeshPhongMaterial({ color: 0x8eb5b2 }));
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
/*
* Осветяване
*/
var sun = new THREE.PointLight(0xffffff, 0.3);
sun.position.set( 0, 100, 00 );
sun.target = ground;
sun.castShadow = true;
scene.add( sun );
var ambient = new THREE.AmbientLight(0xffffff, 0.7);
scene.add(ambient);
/*
* Обекти
*/
var cube = new THREE.Mesh(new THREE.BoxGeometry(1.0, 125, 1.0), new THREE.MeshPhongMaterial({color: 'red'}));
cube.position.y = 0.5;
//scene.add(cube);
var jotaro = newJotaro();
//jotaro.rotation.x = Math.PI / 2;
jotaro.position.x = 120;
jotaro.position.z = 60;
jotaro.rotation.y = Math.PI / 2;
scene.add(jotaro);
// scene.add(newKira());
var koichi = newKoichi();
koichi.rotation.x = Math.PI / 2;
koichi.rotation.z = Math.PI * 0.9;
koichi.position.set(90, 1, 60);
koichi.head.turn = 90;
koichi.head.tilt = 20;
koichi.l_ankle.turn = 85;
koichi.r_ankle.turn = -85;
koichi.torso.turn = 10;
koichi.r_arm.raise = 190;
koichi.r_arm.straddle = 250;
koichi.r_arm.turn = -90;
koichi.r_elbow.bend = 70;
koichi.r_wrist.bend = 4;
koichi.l_arm.raise = 14;
koichi.l_arm.turn = 90;
scene.add(koichi);
var middleBuilding = new THREE.Group();
var patio = new THREE.Mesh(new THREE.BoxGeometry(300, 1, 300),
new THREE.MeshPhongMaterial({ color: 0x978661 }));
middleBuilding.add(patio);
var patioRoad = new THREE.Mesh(new THREE.BoxGeometry(75, 1, 300),
new THREE.MeshPhongMaterial({ color: 0xd2cdca }));
patioRoad.position.y = 0.5;
middleBuilding.add(patioRoad);
middleBuilding.add(newBushPot(0x7e4451, 45, 9, 15, 0, -120,135));
middleBuilding.add(newBushPot(0x7e4451, 45, 9, 15, 0, 120,135));
middleBuilding.position.set(0, 1, -125 -150);
scene.add(middleBuilding);
var tailorShop = new THREE.Group();
tailorShop.add(newTailorShop());
tailorShop.add(newBushPot(0xb29858, 30, 7, 10, 0, 55,-90-5));
tailorShop.add(newBushPot(0xb29858, 30, 7, 10, 0, -55,-90-5));
tailorShop.position.set(60, 0, 225);
scene.add(tailorShop);
var greenWall = new THREE.Group();
greenWall.add(newOutsideWall(300, 0xa8bda7, 1, 0,0));
greenWall.add(newOutsideWall(300, 0xa8bda7, 0, -145,150));
greenWall.position.set(-220, 0, -275);
scene.add(greenWall);
var brownWall = new THREE.Group();
brownWall.add(newOutsideWall(300, 0xccb696, -1, 0,0));
brownWall.add(newOutsideWall(300, 0xccb696, 0, 145,150));
brownWall.position.set(380, 0, -275);
scene.add(brownWall);
var blueWall = new THREE.Group();
blueWall.add(newOutsideWall(300, 0x718d9e, -1, 0,0));
blueWall.add(newOutsideWall(300, 0x718d9e, 2, 145,-150));
blueWall.position.set(380, 0, 275);
scene.add(blueWall);
enableCastShadow(scene);
/**
** Анимация (система)
**/
// На дъното на файла има animationData променлива. То е обект, чиито атрибути са секунди от началото на анимацията (t).
// Всеки атрибут е масив, който определя всичките "действия" който трябва да се "регистрират"
// Едно "действие" също е масив с шаблон
// [<времетраене в сек.>, <манекен за променяне>, <начална поза>, <крайна поза>, <отместване на позиция с координати>]
// или
// [<времетраене в сек.>, <отместване на камера>, <отместване на гледане>, <не е отместване?>]
var executeHooks = [];
function animate(t)
{
t = Math.floor(t) / 100;
var propInd = approxProp(animationData, t);
if (propInd) {
for (var instr of animationData[propInd]) {
if (instr[1].constructor === Array) {
executeHooks.push({
start : t,
end : t+instr[0],
iscamera : true,
camposold : vecToArr(camera.position),
campos : (instr[3] || !instr[1]) ? instr[1] : arrSum(vecToArr(camera.position), instr[1]),
camwatold : camLookAt.clone(),
camwatch : arrToVec(((instr[3] || !instr[2]) ? instr[2] : arrSum(vecToArr(camLookAt), instr[2]))),
isabsol : instr[3],
});
}
else {
executeHooks.push({
start : t,
end : t + instr[0],
iscamera : false,
mannequin : instr[1],
A : (instr[2]) ? instr[2] : fixPostureY(instr[1].posture),
B : fixPostureY(instr[3]),
cpos : instr[1].position.clone(),
npos : (instr.length < 5 || !instr[4]) ? null : vecSum(instr[1].position, arrToVec(instr[4])),
crot : instr[1].rotation.clone(),
nrot : (instr.length < 6 || !instr[5]) ? null : vecMultScal(arrToVec(instr[5]), Math.PI / 2),
});
}
}
delete animationData[propInd];
}
const executeLength = executeHooks.length;
for (var i = 0; i < executeLength; i++) {
var mo = executeHooks.shift();
var blendPer = (t - mo.start) / mo.end;
if (!mo.iscamera) {
if (mo.B)
mo.mannequin.posture = Mannequin.blend(mo.A, mo.B, blendPer);
if (mo.npos)
mo.mannequin.position.set(...vecBlend(mo.cpos, mo.npos, blendPer));
if (mo.nrot)
mo.mannequin.rotation.set(...vecBlend(mo.crot, mo.nrot, blendPer));
}
else {
if (mo.campos !== null) {
camera.position.set(...arrBlend(mo.camposold, mo.campos, blendPer));
}
if (mo.camwatch !== null) {
camLookAt = new THREE.Vector3(...vecBlend(mo.camwatold, mo.camwatch, blendPer));
camera.lookAt(camLookAt);
}
}
if (t <= mo.end)
executeHooks.push(mo);
}
}
/**
** Помощни функции
**/
/*
* За общи настройки
*/
function enableCastShadow(object) {
if (object.type === "AmbientLight") return;
if (object.children.length === 0) {
object.castShadow = true;
object.receiveShadow = true;
}
else
object.children.forEach((child) => enableCastShadow(child));
}
function lookingDirectionVec(camera, vec) {
return new THREE.Vector3(
camera.position.x + vec[0],
camera.position.y + vec[1],
camera.position.z + vec[2]);
}
/*
* За анимация
*/
function arrSum(a1, a2) {
return [a1[0] + a2[0], a1[1] + a2[1], a1[2] + a2[2]];
}
function vecPlusArr(vec, arr) {
return [vec.x + arr[0], vec.y + arr[1], vec.z + arr[2]];
}
function vecMultScal(vec, scal) {
return {
x: vec.x * scal,
y: vec.y * scal,
z: vec.z * scal,
};
}
function vecSum(a, b) {
return {
x: a.x + b.x,
y: a.y + b.y,
z: a.z + b.z,
};
}
function vecBlend(a, b, per) {
return [
a.x * (1.0 - per) + b.x * per,
a.y * (1.0 - per) + b.y * per,
a.z * (1.0 - per) + b.z * per,
];
}
function arrBlend(a1, a2, per) {
return [
a1[0] * (1.0 - per) + a2[0] * per,
a1[1] * (1.0 - per) + a2[1] * per,
a1[2] * (1.0 - per) + a2[2] * per,
];
}
function vecToArr(a) {
return [a.x, a.y, a.z];
}
function arrToVec(a) {
return {
x: a[0],
y: a[1],
z: a[2],
};
}
function fixPostureY(p) {
p.data[0] = 0;
return p;
}
function approxProp(object, property) {
if (object.hasOwnProperty(property))
return property;
var toCheck = property.toFixed(1);
if (object.hasOwnProperty(toCheck))
return toCheck;
toCheck = property.toFixed(0);
if (object.hasOwnProperty(toCheck))
return toCheck;
return null;
}
function arrToRotVec(a) {
return {
x: a[0] * Math.PI / 2,
y: a[1] * Math.PI / 2,
z: a[2] * Math.PI / 2,
};
}
/*
* За функции, генериращи обекти
*/
function thc(value) {
return new THREE.Color(value);
}
/*
* Функции, генериращи обекти
*/
function newBushPot(color, length, height, width, orientation, x, z) {
const density = 6;
const bushColor = 0x4d3573;
var bushes = new THREE.Group();
var bush = new THREE.Mesh(new THREE.SphereGeometry(width / 1.5),
new THREE.MeshPhongMaterial({ color: bushColor, flatShading: true }));
bush.position.y = height + width / 2 * 0.7;
for (var i = -length / 2 + width / 2; i <= length / 2 - width / 2; i += length / density) {
bush.position.x = i;
bushes.add(bush.clone());
}
var pot = new THREE.Mesh(new THREE.BoxGeometry(length, height, width),
new THREE.MeshPhongMaterial({ color: color }));
pot.position.y = height / 2;
var bushPot = new THREE.Group();
bushPot.add(bushes, pot);
bushPot.position.set(x, 0, z);
bushPot.rotation.y = orientation * Math.PI / 2;
return bushPot;
}
function newTailorShop() {
const size = 180;
const bottomHeight = 25;
const eaveSize = 20;
const eaveTileRad = 2;
const floorColor = 0xd4cdb7;
const floorHeight = 55 + eaveSize;
const floorSeparatorHeight = 20;
const borderColor = 0x715949;
const borderSize = 2;
const doorHeight = 70;
const doorWidth = 34;
const windowSize = 30;
const mailBoxSize = 8;
var tailorShop = new THREE.Group();
var bricks = new THREE.Mesh(new THREE.BoxGeometry(size, bottomHeight, size),
new THREE.MeshPhongMaterial({ color: 0x965f4d }));
bricks.position.y = bottomHeight / 2;
tailorShop.add(bricks);
var floor1 = new THREE.Mesh(new THREE.BoxGeometry(size, floorHeight, size),
new THREE.MeshPhongMaterial({ color: floorColor }));
floor1.position.y = bottomHeight + floorHeight / 2;
tailorShop.add(floor1);
var floorSeparator = new THREE.Mesh(new THREE.BoxGeometry(size, floorSeparatorHeight, size),
new THREE.MeshPhongMaterial({ color: 0xf5f7e1 }));
floorSeparator.position.y = bottomHeight + floorHeight + floorSeparatorHeight / 2;
tailorShop.add(floorSeparator);
var floor2 = new THREE.Mesh(new THREE.BoxGeometry(size, floorHeight, size),
new THREE.MeshPhongMaterial({ color: floorColor }));
floor2.position.y = bottomHeight + floorHeight * 1.5 + floorSeparatorHeight;
tailorShop.add(floor2);
var shopEave = new THREE.Group();
var eaveShape = new THREE.Shape();
eaveShape.lineTo(-eaveSize, 0);
eaveShape.lineTo(0,eaveSize);
var eave = new THREE.Mesh(new THREE.ExtrudeGeometry(eaveShape, { depth: size, bevelEnabled: true, bevelSize: 0.1, bevelThickness: 0.1 }),
new THREE.MeshPhongMaterial({ color: 0xdeddcc }));
shopEave.add(eave);
var eaveTileLength = Math.sqrt(2 * eaveSize * eaveSize);
var eaveTile = new THREE.Mesh(new THREE.CylinderGeometry(eaveTileRad, eaveTileRad, eaveTileLength),
new THREE.MeshPhongMaterial({ color: 0x85967a }));
eaveTile.rotation.z = -Math.PI / 4;
eaveTile.position.y = eaveSize / 2 + eaveTileRad;
eaveTile.position.x = -eaveSize / 2 - eaveTileRad;
for (var i = 0; i <= size + eaveTileRad; i+=2*eaveTileRad) {
eaveTile.position.z = i;
shopEave.add(eaveTile.clone());
}
eaveTile.rotation.z = 0;
eaveTile.rotation.x = Math.PI / 2;
eaveTile.position.x = 0;
eaveTile.position.y = eaveSize + eaveTileRad * 2;
for (var i = -eaveTileRad + eaveTileLength / 2; i <= size + eaveTileRad - eaveTileLength; i++) {
eaveTile.position.z = i;
shopEave.add(eaveTile.clone());
}
eaveTile.position.z = size + eaveTileRad - eaveTileLength / 2;
shopEave.add(eaveTile);
shopEave.rotation.y = -Math.PI / 2;
shopEave.position.set(size/2, bottomHeight + floorHeight - eaveSize, -size/2);
tailorShop.add(shopEave);
var door = new THREE.Group();
var doorVoid = new THREE.Mesh(new THREE.BoxGeometry(doorWidth - borderSize * 2, doorHeight - borderSize, borderSize / 2),
new THREE.MeshPhongMaterial({ color: 'black' }));
door.add(doorVoid);
var doorMat = new THREE.MeshPhongMaterial({ color: borderColor });
var doorFrameVert = new THREE.Mesh(new THREE.BoxGeometry(borderSize, doorHeight - borderSize, borderSize),
doorMat);
doorFrameVert.position.x = doorWidth / 2 - borderSize / 2;
door.add(doorFrameVert.clone());
doorFrameVert.position.x = -doorWidth / 2 + borderSize / 2;
door.add(doorFrameVert);
var doorFrameTop = new THREE.Mesh(new THREE.BoxGeometry(doorWidth, borderSize, borderSize),
doorMat);
doorFrameTop.position.y = doorHeight / 2;
door.add(doorFrameTop);
door.position.set(10, doorHeight / 2 - borderSize / 2, -size / 2);
tailorShop.add(door);
var window = new THREE.Group();
var windowVoid = new THREE.Mesh(new THREE.BoxGeometry(windowSize - borderSize * 2, windowSize - borderSize * 2, borderSize / 2),
new THREE.MeshPhongMaterial({ color: 'black' }));
window.add(windowVoid);
var windowBorder = new THREE.Mesh(new THREE.BoxGeometry(windowSize, borderSize, borderSize),
new THREE.MeshPhongMaterial({ color: borderColor }));
windowBorder.position.set(0, -windowSize / 2 + borderSize / 2, 0);
window.add(windowBorder.clone());
windowBorder.position.y = windowSize / 2 - borderSize / 2;
window.add(windowBorder.clone());
windowBorder.rotation.z = Math.PI / 2;
windowBorder.position.set(-windowSize / 2 + borderSize / 2, 0, 0);
window.add(windowBorder.clone());
windowBorder.position.x = windowSize / 2 - borderSize / 2;
window.add(windowBorder);
window.position.set(60, doorHeight * 0.9 - windowSize / 2, -size / 2);
tailorShop.add(window.clone());
window.position.x = -60;
tailorShop.add(window);
var mailBox = new THREE.Mesh(new THREE.BoxGeometry(mailBoxSize, mailBoxSize * 0.75, mailBoxSize / 3),
new THREE.MeshPhongMaterial({ color: 0x376651 }));
mailBox.position.set(-16, doorHeight * 0.6, -size / 2);
tailorShop.add(mailBox);
return tailorShop;
}
function newJotaro() {
const coatC = thc(0xedf4eb);
const skinC = thc(0xdcc7b4);
const acctC = thc(0x8166be);
Mannequin.colors = [
skinC, // head
acctC, // shoes
coatC, // pelvis
coatC, // joints
coatC, // limbs
coatC, // torso
];
var jotaro = new Male(0.975);
jotaro.position.y = 33;
jotaro.r_wrist.recolor(skinC, acctC);
jotaro.l_wrist.recolor(skinC, acctC);
jotaro.r_fingers.recolor(skinC);
jotaro.l_fingers.recolor(skinC);
jotaro.r_fingers.tips.recolor(skinC);
jotaro.l_fingers.tips.recolor(skinC);
var hat = new THREE.Group();
hat.position.y = 6;
hat.rotation.y = Math.PI / 2;
jotaro.head.attach(hat);
var shape = new THREE.Mesh(new THREE.CylinderGeometry(3.5, 3.5, 3.5, 32), new THREE.MeshPhongMaterial());
hat.add(shape);
var goldHand = new THREE.Mesh(new THREE.BoxGeometry(1.5, 2, 0.5), new THREE.MeshPhongMaterial({ color: 0xead57f }));
const goldHandAngle = Math.PI * 4/25;
goldHand.position.z = 3.5 * Math.cos(goldHandAngle);
goldHand.position.x = 3.5 * Math.sin(goldHandAngle);
goldHand.rotation.y = goldHandAngle;
hat.add(goldHand);
var ornament = new THREE.Group();
var ornamentMaterial = new THREE.MeshPhongMaterial({ color: 0x17171b });
var orCircle = new THREE.Mesh(new THREE.RingGeometry(0.2, 0.5, 32), ornamentMaterial);
orCircle.position.y = 0.5;
ornament.add(orCircle);
var orVBar = new THREE.Mesh(new THREE.PlaneGeometry(0.3, 1.2), ornamentMaterial);
orVBar.position.y = -0.5;
ornament.add(orVBar);
var orHBar = new THREE.Mesh(new THREE.PlaneGeometry(1, 0.3), ornamentMaterial);
orHBar.position.y = -0.5 -0.1 + 0.5;
ornament.add(orHBar);
var orSBar = new THREE.Mesh(new THREE.PlaneGeometry(0.5, 0.3), ornamentMaterial);
orSBar.position.y = -0.8;
orSBar.rotation.z = -Math.PI / 4;
orSBar.position.x = -0.2;
ornament.add(orSBar.clone());
orSBar.rotation.z = Math.PI / 4;
orSBar.position.x = 0.2;
ornament.add(orSBar);
[-Math.PI / 4, -Math.PI / 8, 0].forEach((angle) => {
ornament.position.z = 3.52 * Math.cos(angle);
ornament.position.x = 3.52 * Math.sin(angle);
ornament.rotation.y = angle;
hat.add(ornament.clone());
});
var brimShape = new THREE.Shape();
brimShape.moveTo(-3.45,0);
brimShape.quadraticCurveTo(0,15, 3.45,0);
var brim = new THREE.Mesh(new THREE.ExtrudeGeometry(brimShape, { depth: 0.2, bevelEnabled: true, bevelSize: 0.1, bevelThickness: 0.1 }),
[new THREE.MeshPhongMaterial(), new THREE.MeshPhongMaterial({ color: 0xf4cb71 })]);
brim.rotation.x = Math.PI / 2;
brim.position.y = -1.5;
hat.add(brim);
return jotaro;
}
function newKira() {
const suitC = thc(0xb983d7);
const skinC = thc(0xf1e3bf);
const shoeC = thc(0x775834);
Mannequin.colors = [
skinC, // head
shoeC, // shoes
suitC, // pelvis
suitC, // joints
suitC, // limbs
suitC, // torso
];
var kira = new Male(0.875);
kira.position.y = 29.5;
kira.r_wrist.recolor(skinC);
kira.l_wrist.recolor(skinC);
kira.r_fingers.recolor(skinC);
kira.l_fingers.recolor(skinC);
kira.r_fingers.tips.recolor(skinC);
kira.l_fingers.tips.recolor(skinC);
var hair = new THREE.Mesh(new THREE.SphereGeometry(3.5, 6, 32, 0, Math.PI),
new THREE.MeshPhongMaterial({ color: 0xd7d86f, flatShading: 1 }));
hair.rotation.z = -Math.PI / 2;
hair.rotation.x = -Math.PI / 2;
hair.position.y = 3.9;
hair.position.x = -0.4;
kira.head.attach(hair);
var tieShape = new THREE.Shape();
tieShape.lineTo(-1, -1.5);
tieShape.lineTo(0, -3);
tieShape.lineTo(-1.1, -10);
tieShape.lineTo(0, -12);
tieShape.lineTo(1.1, -10);
tieShape.lineTo(0, -3);
tieShape.lineTo(1, -1.5);
var tie = new THREE.Mesh(new THREE.ExtrudeGeometry(tieShape, { depth: 0.2, bevelEnabled: true, bevelSize: 0.1, bevelThickness: 0.1 }),
new THREE.MeshPhongMaterial());
tie.position.x = 3.5;
tie.rotation.y = -Math.PI / 2;
tie.position.y = 16;
kira.torso.attach(tie);
return kira;
}
function newKoichi() {
const suitC = thc(0x2f5951);
const skinC = thc(0xe0cbbc);
const shoeC = thc(0x919177);
Mannequin.colors = [
skinC, // head
shoeC, // shoes
suitC, // pelvis
suitC, // joints
suitC, // limbs
suitC, // torso
];
var koichi = new Male(0.76);
koichi.position.y = 26;
koichi.r_wrist.recolor(skinC);
koichi.l_wrist.recolor(skinC);
koichi.r_fingers.recolor(skinC);
koichi.l_fingers.recolor(skinC);
koichi.r_fingers.tips.recolor(skinC);
koichi.l_fingers.tips.recolor(skinC);
var hair = new THREE.Mesh(new THREE.SphereGeometry(3.6, 10, 32, 0, 2 * Math.PI, 0, Math.PI / 2),
new THREE.MeshPhongMaterial({ color: 0xb4b7ae, flatShading: 1 }));
hair.position.y = 3.9;
hair.position.x = -0.4;
koichi.head.attach(hair);
return koichi;
}
function newOutsideWall(width, color, rotation, x, z) {
const wallHeight = 100;
const wallDepth = 10;
const wallHighlightHeight = 0.15625 * wallHeight;
const highlightColor = 0xf4f8e6;
const brimHeight = 0.0625 * wallHeight;
const brimDepthAdd = 5;
var wall = new THREE.Group();
wall.rotation.y = rotation * Math.PI / 2;
wall.position.set(x, 0, z);
var mainPart = new THREE.Mesh(new THREE.BoxGeometry(width, wallHeight - wallHighlightHeight - brimHeight, wallDepth),
new THREE.MeshPhongMaterial({ color: color }));
mainPart.position.y = wallHighlightHeight + (wallHeight - wallHighlightHeight - brimHeight) / 2;
wall.add(mainPart);
var highlight = new THREE.Mesh(new THREE.BoxGeometry(width, wallHighlightHeight, wallDepth),
new THREE.MeshPhongMaterial({ color: highlightColor }));
highlight.position.y = wallHighlightHeight / 2;
wall.add(highlight);
var brim = new THREE.Mesh(new THREE.BoxGeometry(width + brimDepthAdd * 2, brimHeight, wallDepth + brimDepthAdd),
new THREE.MeshPhongMaterial({ color: highlightColor }));
brim.position.y = wallHeight - brimHeight / 2;
brim.position.z = brimDepthAdd / 2;
wall.add(brim);
return wall;
}
/**
** Анимационни действия
**/
var animationData = {
0: [
[
5, jotaro,
null,
{"version":6,"data":[3.8,[0,-90,0],[-1.3,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[7,-0.6,-5],[15],[-15,0,0],[10,10],[-86.8,50.3,65.1],[15],[15,0,0],[10,10]]},
[50, 0, 0],
[2, 0, 0],
],
[
3, [50, 0, 0], [0, -10, 0], false
]
],
5: [
[
3, jotaro,
null,
{"version":6,"data":[3.8,[0,-90,0],[0,0,-2],[0,0,5],[6,0,0],[0],[-6,-6,-0.6],[-6,0,0],[0],[6,6,-0.6],[-38.1,-66.6,-62],[15],[-15,0,0],[10,10],[89.2,85,-124.8],[15],[15,0,0],[10,10]]}
]
],
};
</script>
</body>
</html>
|