void RecursivePartition(List <int> triangles, int depth, Node parent)
        {
            TrianglesExtents extents          = GetTrianglesExtents(triangles);
            Vector3          extentsMagnitude = extents.HalfExtent();
            Vector3          partitionNormal  = Vector3.zero;

            if (extentsMagnitude.x >= extentsMagnitude.y && extentsMagnitude.x >= extentsMagnitude.z)
            {
                partitionNormal = Vector3.right;
            }
            else if (extentsMagnitude.y >= extentsMagnitude.x && extentsMagnitude.y >= extentsMagnitude.z)
            {
                partitionNormal = Vector3.up;
            }
            else
            {
                partitionNormal = Vector3.forward;
            }

            List <int> positiveTriangles;
            List <int> negativeTriangles;

            Split(triangles, extents.trianglesCenter, partitionNormal, out positiveTriangles, out negativeTriangles);

            parent.Set(extents);
            parent.positiveChild = new Node();
            parent.negativeChild = new Node();

            if (positiveTriangles.Count < triangles.Count && positiveTriangles.Count > maxTrianglesPerNode)
            {
                RecursivePartition(positiveTriangles, depth + 1, parent.positiveChild);
            }
            else
            {
                parent.positiveChild.triangles = positiveTriangles.ToArray();
                parent.positiveChild.Set(GetTrianglesExtents(positiveTriangles));
            }

            if (negativeTriangles.Count < triangles.Count && negativeTriangles.Count > maxTrianglesPerNode)
            {
                RecursivePartition(negativeTriangles, depth + 1, parent.negativeChild);
            }
            else
            {
                parent.negativeChild.triangles = negativeTriangles.ToArray();
                parent.negativeChild.Set(GetTrianglesExtents(negativeTriangles));
            }
        }
 public void Set(TrianglesExtents extents)
 {
     Set(extents.Center(), extents.HalfExtent());
 }