В чем ошибка? Почему рекурсивная функция не останавливается?
let a = [ 0.0, 0.0, 0.0 ]
            let b = [ 1.0, 0.0, 0.0 ]
            let c = [ 0.5, 0.0, 0.8 ]
            let ab = [];
            let bc = [];
            let ac = [];

            let arrayTriangle = [];
            let arrayTriangle2 = [];
            let arrayTriangle3 = [];
            let triangle = [];
            arrayTriangle.push ( [a, b, c] );

            function addTriangle(arrayTriangle) {
                for (let i = 0; i < arrayTriangle.length; i++) {
                    triangle = arrayTriangle[i];
                    console.log(triangle[0][0]);
                    ab = [ 
                        (triangle[0][0] + triangle[1][0])/2,
                        (triangle[0][1] + triangle[1][1])/2,
                        (triangle[0][2] + triangle[1][2])/2,
                    ];
                    bc = [ 
                        (triangle[1][0] + triangle[2][0])/2,
                        (triangle[1][1] + triangle[2][1])/2,
                        (triangle[1][2] + triangle[2][2])/2,
                    ];
                    ac = [
                        (triangle[0][0] + triangle[2][0])/2,
                        (triangle[0][1] + triangle[2][1])/2,
                        (triangle[0][2] + triangle[2][2])/2,
                    ];
                    console.log(' a: ' + a + ' b: ' + b + ' c: ' + c + ' ab: ' + ab + ' ac: ' + ac + ' bc: ' + bc );
                    arrayTriangle2.push ( [ a, ab, ac ], [ ab, b, bc ], [ ac, bc, c ] );
                    console.log(arrayTriangle2);
                }
                // console.log('arrayTriangle: ' + arrayTriangle);
                // console.log('arrayTriangle 2: ' + arrayTriangle2);
                return arrayTriangle2;
            }
            function recursiveFunction(arrayTriangle, count) {
                if (count > 0) {
                    // arrayTriangle3 = addTriangle(arrayTriangle);

                    for (let i = 0; i < arrayTriangle.length; i++) {
                        triangle = arrayTriangle[i];
                        console.log(triangle[0][0]);
                        ab = [ 
                            (triangle[0][0] + triangle[1][0])/2,
                            (triangle[0][1] + triangle[1][1])/2,
                            (triangle[0][2] + triangle[1][2])/2,
                        ];
                        bc = [ 
                            (triangle[1][0] + triangle[2][0])/2,
                            (triangle[1][1] + triangle[2][1])/2,
                            (triangle[1][2] + triangle[2][2])/2,
                        ];
                        ac = [
                            (triangle[0][0] + triangle[2][0])/2,
                            (triangle[0][1] + triangle[2][1])/2,
                            (triangle[0][2] + triangle[2][2])/2,
                        ];
                        console.log(' a: ' + a + ' b: ' + b + ' c: ' + c + ' ab: ' + ab + ' ac: ' + ac + ' bc: ' + bc );
                        arrayTriangle2.push ( [ a, ab, ac ], [ ab, b, bc ], [ ac, bc, c ] );
                        console.log(arrayTriangle2);
                    }
                    arrayTriangle = arrayTriangle2
                    count = count - 1;
                    recursiveFunction(arrayTriangle,count);
                } else {
                    console.log('Вызовы рекурсивной функции завершены.');
                }
            }
            recursiveFunction(arrayTriangle,2);