-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfractals.js
1904 lines (1370 loc) · 70.8 KB
/
fractals.js
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
//----------------------------------------------------------------------------
//
// Global Variables
//
var canvas = null;
var numLevels = 0;
var fractalSelected = 0;
var gl = null; // WebGL context
var shaderProgram = null;
var triangleVertexPositionBuffer = null;
var triangleVertexNormalBuffer = null; //NEW
// The GLOBAL transformation parameters
var globalAngleYY = 0.0;
var globalTz = 0.0;
// The local transformation parameters
// The translation vector
var tx = 0.0;
var ty = 0.0;
var tz = 0.0;
// The rotation angles in degrees
var angleXX = -22.5;
var angleYY = 16.0;
var angleZZ = 0.0;
// The scaling factors
var sx = 0.5;
var sy = 0.5;
var sz = 0.5;
// GLOBAL Animation controls
var globalRotationYY_ON = 1;
var globalRotationYY_DIR = 1;
var globalRotationYY_SPEED = 1;
// Local Animation controls
var rotationXX_ON = 0;
var rotationXX_DIR = 1;
var rotationXX_SPEED = 1;
var rotationYY_ON = 0;
var rotationYY_DIR = 1;
var rotationYY_SPEED = 1;
var rotationZZ_ON = 0;
var rotationZZ_DIR = 1;
var rotationZZ_SPEED = 1;
// To allow choosing the way of drawing the model triangles
var primitiveType = null;
// To allow choosing the projection type
var projectionType = 0;
// NEW --- The viewer position
// It has to be updated according to the projection type
var pos_Viewer = [ 0.0, 0.0, 0.0, 1.0 ];
// NEW --- Point Light Source Features
// Directional --- Homogeneous coordinate is ZERO
var pos_Light_Source = [ 0.0, 0.0, 1.0, 0.0 ];
// White light
var int_Light_Source = [ 1.0, 1.0, 1.0 ];
// Low ambient illumination
var ambient_Illumination = [ 0.3, 0.3, 0.3 ];
// NEW --- Model Material Features
// Ambient coef.
var kAmbi = [ 0.2, 0.2, 0.2 ];
// Diffuse coef.
var kDiff = [ 0.2, 0.48, 0.72 ]; // COLOR
// Specular coef.
var kSpec = [ 0.0, 0.0, 0.0 ];
// Phong coef.
var nPhong = 100;
// Initial model has just ONE TRIANGLE
var vertices = [ ];
var normals = [ ];
//----------------------------------------------------------------------------
//
// The WebGL code
//
//----------------------------------------------------------------------------
//
// Rendering
//
// Handling the Vertex Coordinates and the Vertex Normal Vectors
function initBuffers() {
switch(fractalSelected) {
case 0 :
computeSierpinskiGasket();
break;
case 1 :
computeKochSnowflake();
break;
case 2 :
computeMosely();
break;
case 3 :
computeMengerSponge();
break;
case 4 :
computeJerusalemCube();
break;
case 5 :
computeCantorDust();
break;
}
triangleVertexPositionBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
triangleVertexPositionBuffer.itemSize = 3;
triangleVertexPositionBuffer.numItems = vertices.length / 3;
// Associating to the vertex shader
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute,
triangleVertexPositionBuffer.itemSize,
gl.FLOAT, false, 0, 0);
// Vertex Normal Vectors
triangleVertexNormalBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexNormalBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normals), gl.STATIC_DRAW);
triangleVertexNormalBuffer.itemSize = 3;
triangleVertexNormalBuffer.numItems = normals.length / 3;
// Associating to the vertex shader
gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute,
triangleVertexNormalBuffer.itemSize,
gl.FLOAT, false, 0, 0);
}
//----------------------------------------------------------------------------
// Drawing the model
function drawModel( angleXX, angleYY, angleZZ,
sx, sy, sz,
tx, ty, tz,
mvMatrix,
primitiveType ) {
// The the global model transformation is an input
// Concatenate with the particular model transformations
// Pay attention to transformation order !!
mvMatrix = mult( mvMatrix, translationMatrix( tx, ty, tz ) );
mvMatrix = mult( mvMatrix, rotationZZMatrix( angleZZ ) );
mvMatrix = mult( mvMatrix, rotationYYMatrix( angleYY ) );
mvMatrix = mult( mvMatrix, rotationXXMatrix( angleXX ) );
mvMatrix = mult( mvMatrix, scalingMatrix( sx, sy, sz ) );
// Passing the Model View Matrix to apply the current transformation
var mvUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
gl.uniformMatrix4fv(mvUniform, false, new Float32Array(flatten(mvMatrix)));
// Multiplying the reflection coefficents
var ambientProduct = mult( kAmbi, ambient_Illumination );
var diffuseProduct = mult( kDiff, int_Light_Source );
var specularProduct = mult( kSpec, int_Light_Source );
// Associating the data to the vertex shader
// This can be done in a better way !!
// Vertex Coordinates and Vertex Normal Vectors
initBuffers();
// Partial illumonation terms and shininess Phong coefficient
gl.uniform3fv( gl.getUniformLocation(shaderProgram, "ambientProduct"),
flatten(ambientProduct) );
gl.uniform3fv( gl.getUniformLocation(shaderProgram, "diffuseProduct"),
flatten(diffuseProduct) );
gl.uniform3fv( gl.getUniformLocation(shaderProgram, "specularProduct"),
flatten(specularProduct) );
gl.uniform1f( gl.getUniformLocation(shaderProgram, "shininess"),
nPhong );
//Position of the Light Source
gl.uniform4fv( gl.getUniformLocation(shaderProgram, "lightPosition"),
flatten(pos_Light_Source) );
// Drawing
// primitiveType allows drawing as filled triangles / wireframe / vertices
if( primitiveType == gl.LINE_LOOP ) {
// To simulate wireframe drawing!
// No faces are defined! There are no hidden lines!
// Taking the vertices 3 by 3 and drawing a LINE_LOOP
var i;
for( i = 0; i < triangleVertexPositionBuffer.numItems / 3; i++ ) {
gl.drawArrays( primitiveType, 3 * i, 3 );
}
}
else {
gl.drawArrays(primitiveType, 0, triangleVertexPositionBuffer.numItems);
}
}
//----------------------------------------------------------------------------
// Drawing the 3D scene
function drawScene() {
var pMatrix;
var mvMatrix = mat4();
// Clearing the frame-buffer and the depth-buffer
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Computing the Projection Matrix
if( projectionType == 0 ) {
// For now, the default orthogonal view volume
pMatrix = ortho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
// Global transformation !!
globalTz = 0.0;
// NEW --- The viewer is on the ZZ axis at an indefinite distance
pos_Viewer[0] = pos_Viewer[1] = pos_Viewer[3] = 0.0;
pos_Viewer[2] = 1.0;
// TO BE DONE !
// Allow the user to control the size of the view volume
}
else {
// A standard view volume.
// Viewer is at (0,0,0)
// Ensure that the model is "inside" the view volume
pMatrix = perspective( 45, 1, 0.05, 15 );
// Global transformation !!
globalTz = -2.5;
// NEW --- The viewer is on (0,0,0)
pos_Viewer[0] = pos_Viewer[1] = pos_Viewer[2] = 0.0;
pos_Viewer[3] = 1.0;
// TO BE DONE !
// Allow the user to control the size of the view volume
}
// Passing the Projection Matrix to apply the current projection
var pUniform = gl.getUniformLocation(shaderProgram, "uPMatrix");
gl.uniformMatrix4fv(pUniform, false, new Float32Array(flatten(pMatrix)));
// NEW --- Passing the viewer position to the vertex shader
gl.uniform4fv( gl.getUniformLocation(shaderProgram, "viewerPosition"),
flatten(pos_Viewer) );
// GLOBAL TRANSFORMATION FOR THE WHOLE SCENE
mvMatrix = translationMatrix( 0, 0, globalTz );
// Instantianting the current model
drawModel( angleXX, angleYY, angleZZ,
sx, sy, sz,
tx, ty, tz,
mvMatrix,
primitiveType );
}
//----------------------------------------------------------------------------
//
// NEW --- Animation
//
// Animation --- Updating transformation parameters
var lastTime = 0;
function animate() {
var timeNow = new Date().getTime();
if( lastTime != 0 ) {
var elapsed = timeNow - lastTime;
// Global rotation
if( globalRotationYY_ON ) {
globalAngleYY += globalRotationYY_DIR * globalRotationYY_SPEED * (90 * elapsed) / 1000.0;
}
// Local rotations
if( rotationXX_ON ) {
angleXX += rotationXX_DIR * rotationXX_SPEED * (90 * elapsed) / 1000.0;
}
if( rotationYY_ON ) {
angleYY += rotationYY_DIR * rotationYY_SPEED * (90 * elapsed) / 1000.0;
}
if( rotationZZ_ON ) {
angleZZ += rotationZZ_DIR * rotationZZ_SPEED * (90 * elapsed) / 1000.0;
}
}
lastTime = timeNow;
}
//----------------------------------------------------------------------------
// Timer
function tick() {
requestAnimFrame(tick);
drawScene();
animate();
}
//----------------------------------------------------------------------------
//
// User Interaction
//
function outputInfos(){
}
function updateColor(color) {
color = '#' + color;
var r = hexToR(color);
var g = hexToG(color);
var b = hexToB(color);
r /= 255;
g /= 255;
b /= 255;
kDiff = [r, g, b];
}
// Hex to RGB Parser
// Retired from: http://www.javascripter.net/faq/hextorgb.htm
function hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Handling mouse events
// Adapted from www.learningwebgl.com
var mouseDown = false;
var lastMouseX = null;
var lastMouseY = null;
function handleMouseDown(event) {
mouseDown = true;
lastMouseX = event.clientX;
lastMouseY = event.clientY;
}
function handleMouseUp(event) {
mouseDown = false;
}
function handleMouseMove(event) {
if (!mouseDown) {
return;
}
// Rotation angles proportional to cursor displacement
var newX = event.clientX;
var newY = event.clientY;
var deltaX = newX - lastMouseX;
angleYY += radians( 10 * deltaX );
var deltaY = newY - lastMouseY;
angleXX += radians( 10 * deltaY );
lastMouseX = newX;
lastMouseY = newY;
}
function setEventListeners() {
// Dropdown list
var list = document.getElementById("rendering-mode-selection");
list.addEventListener("click", function(){
// Getting the selection
var mode = list.selectedIndex;
switch(mode){
case 0 : primitiveType = gl.TRIANGLES;
break;
case 1 : primitiveType = gl.LINE_LOOP;
break;
case 2 : primitiveType = gl.POINTS;
break;
}
});
var projectionList = document.getElementById("projection-selection");
projectionList.addEventListener("click", function(){
// Getting the selection
var p = projectionList.selectedIndex;
switch(p){
case 0 : projectionType = 0;
break;
case 1 : projectionType = 1;
break;
}
});
var fractalList = document.getElementById("fractal-selection");
fractalList.addEventListener("click", function(){
// Getting the selection
var mode = fractalList.selectedIndex;
switch(mode){
case 0 :
fractalSelected = 0;
computeSierpinskiGasket();
break;
case 1 :
fractalSelected = 1;
computeKochSnowflake();
break;
case 2 :
fractalSelected = 2;
computeMosely();
break;
case 3 :
fractalSelected = 3;
computeMengerSponge();
break;
case 4 :
fractalSelected = 4;
computeJerusalemCube();
break;
case 5 :
fractalSelected = 5;
computeCantorDust();
break;
}
});
// Button events
document.getElementById("XX-on-off-button").onclick = function(){
// Switching on / off
if( rotationXX_ON ) {
rotationXX_ON = 0;
}
else {
rotationXX_ON = 1;
}
};
document.getElementById("XX-direction-button").onclick = function(){
// Switching the direction
if( rotationXX_DIR == 1 ) {
rotationXX_DIR = -1;
}
else {
rotationXX_DIR = 1;
}
};
document.getElementById("XX-slower-button").onclick = function(){
rotationXX_SPEED *= 0.75;
};
document.getElementById("XX-faster-button").onclick = function(){
rotationXX_SPEED *= 1.25;
};
document.getElementById("YY-on-off-button").onclick = function(){
// Switching on / off
if( rotationYY_ON ) {
rotationYY_ON = 0;
}
else {
rotationYY_ON = 1;
}
};
document.getElementById("YY-direction-button").onclick = function(){
// Switching the direction
if( rotationYY_DIR == 1 ) {
rotationYY_DIR = -1;
}
else {
rotationYY_DIR = 1;
}
};
document.getElementById("YY-slower-button").onclick = function(){
rotationYY_SPEED *= 0.75;
};
document.getElementById("YY-faster-button").onclick = function(){
rotationYY_SPEED *= 1.25;
};
document.getElementById("ZZ-on-off-button").onclick = function(){
// Switching on / off
if( rotationZZ_ON ) {
rotationZZ_ON = 0;
}
else {
rotationZZ_ON = 1;
}
};
document.getElementById("ZZ-direction-button").onclick = function(){
// Switching the direction
if( rotationZZ_DIR == 1 ) {
rotationZZ_DIR = -1;
}
else {
rotationZZ_DIR = 1;
}
};
document.getElementById("ZZ-slower-button").onclick = function(){
rotationZZ_SPEED *= 0.75;
};
document.getElementById("ZZ-faster-button").onclick = function(){
rotationZZ_SPEED *= 1.25;
};
document.getElementById("reset-button").onclick = function(){
// The initial values
// The translation vector
tx = 0.0;
ty = 0.0;
tz = 0.0;
// The rotation angles in degrees
angleXX = -22.5;
angleYY = 16.0;
angleZZ = 0.0;
// The scaling factors
sx = 0.5;
sy = 0.5;
sz = 0.5;
// Local Animation controls
rotationXX_ON = 0;
rotationXX_DIR = 1;
rotationXX_SPEED = 1;
rotationYY_ON = 0;
rotationYY_DIR = 1;
rotationYY_SPEED = 1;
rotationZZ_ON = 0;
rotationZZ_DIR = 1;
rotationZZ_SPEED = 1;
projectionType = 0;
kDiff = [ 0.2, 0.48, 0.72 ]; // COLOR
initBuffers();
};
document.getElementById("add-recursion-button").onclick = function(){
numLevels = numLevels+1;
document.getElementById("num-iterations").innerHTML = numLevels;
switch(fractalSelected) {
case 0 :
computeSierpinskiGasket();
break;
case 1 :
computeKochSnowflake();
break;
case 2 :
computeMosely();
break;
case 3 :
computeMengerSponge();
break;
case 4 :
computeJerusalemCube();
break;
case 5 :
computeCantorDust();
break;
}
initBuffers();
};
document.getElementById("reduce-recursion-button").onclick = function(){
if (numLevels > 0){
numLevels = numLevels-1;
document.getElementById("num-iterations").innerHTML = numLevels;
}
initBuffers();
};
canvas.onmousedown = handleMouseDown;
document.onmouseup = handleMouseUp;
document.onmousemove = handleMouseMove;
// Roda do rato
canvas.addEventListener('wheel', function(event) {
//document.onwheel = function(){ return false; }
if(event.deltaY > 0) {
// Aproxima
if (sx <= 0.1) {
sx = 0.1;
sy = 0.1;
sz = 0.1;
} else {
sx -= 0.1;
sy -= 0.1;
sz -= 0.1;
}
}
else {
// Afasta
if (sx >= 1) {
sx = 0.9;
sy = 0.9;
sz = 0.9;
} else {
sx += 0.1;
sy += 0.1;
sz += 0.1;
}
}
drawScene();
}, false);
/* document.getElementById('fractalControls').onwheel = function() {
console.log('fractalControls');
return true;
} */
}
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function disableScroll() {
if (window.addEventListener) // older FF
window.addEventListener('DOMMouseScroll', preventDefault, false);
window.onwheel = preventDefault; // modern standard
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
window.ontouchmove = preventDefault; // mobile
}
function enableScroll() {
if (window.removeEventListener)
window.removeEventListener('DOMMouseScroll', preventDefault, false);
window.onmousewheel = document.onmousewheel = null;
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
}
//----------------------------------------------------------------------------
//
// WebGL Initialization
//
function initWebGL( canvas ) {
try {
// Create the WebGL context
// Some browsers still need "experimental-webgl"
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
// DEFAULT: The viewport occupies the whole canvas
// DEFAULT: The viewport background color is WHITE
// NEW - Drawing the triangles defining the model
primitiveType = gl.TRIANGLES;
// DEFAULT: Face culling is DISABLED
// Enable FACE CULLING
gl.enable( gl.CULL_FACE );
// DEFAULT: The BACK FACE is culled!!
// The next instruction is not needed...
gl.cullFace( gl.BACK );
// Enable DEPTH-TEST
gl.enable( gl.DEPTH_TEST );
} catch (e) {
}
if (!gl) {
alert("Could not initialise WebGL, sorry! :-(");
}
}
//----------------------------------------------------------------------------
function runWebGL() {
canvas = document.getElementById("my-canvas");
initWebGL( canvas );
shaderProgram = initShaders( gl );
setEventListeners();
initBuffers();
tick(); // NEW --- A timer controls the rendering / animation
outputInfos();
}
//----------------------------------------------------------------------------
// The fractal code
//----------------------------------------------------------------------------
function computeSierpinskiGasket() {
var v1 = [ -1.0, 0.0, -0.707 ];
var v2 = [ 0.0, 1.0, 0.707 ];
var v3 = [ 1.0, 0.0, -0.707 ];
var v4 = [ 0.0, -1.0, 0.707 ];
vertices = [];
normals = [];
divideTetrahedron(v1, v2, v3, v4, numLevels);
computeVertexNormals(vertices, normals);
//vertices = flatten( vertices );
}
function divideTetrahedron(v1, v2, v3, v4, recursionLevel) {
if (recursionLevel == 0) {
var coordinatesToAdd = [].concat(v1, v2, v3,
v3, v2, v4,
v4, v2, v1,
v1, v3, v4);
for (var i = 0; i < 36; i += 1) {
vertices.push(coordinatesToAdd[i]);
}
}
else {
var vertex12 = computeMidPoint(v1, v2);
var vertex13 = computeMidPoint(v1, v3);
var vertex14 = computeMidPoint(v1, v4);
var vertex23 = computeMidPoint(v2, v3);
var vertex24 = computeMidPoint(v2, v4);
var vertex34 = computeMidPoint(v3, v4);
recursionLevel--;
divideTetrahedron(v1, vertex12, vertex13, vertex14, recursionLevel);
divideTetrahedron(vertex12, v2, vertex23, vertex24, recursionLevel);
divideTetrahedron(vertex13, vertex23, v3, vertex34, recursionLevel);
divideTetrahedron(vertex14, vertex24, vertex34, v4, recursionLevel);