HelixToolkit.Wpf.MeshBuilder.GetUnitSphere C# (CSharp) Method

GetUnitSphere() private static method

Gets a unit sphere from the cache.
private static GetUnitSphere ( int subdivisions ) : System.Windows.Media.Media3D.MeshGeometry3D
subdivisions int /// The number of subdivisions. ///
return System.Windows.Media.Media3D.MeshGeometry3D
        private static MeshGeometry3D GetUnitSphere(int subdivisions)
        {
            if (UnitSphereCache.ContainsKey(subdivisions))
            {
                return UnitSphereCache[subdivisions];
            }

            var mb = new MeshBuilder(false, false);
            mb.AddRegularIcosahedron(new Point3D(), 1, false);
            for (int i = 0; i < subdivisions; i++)
            {
                mb.SubdivideLinear();
            }

            for (int i = 0; i < mb.positions.Count; i++)
            {
                var v = mb.Positions[i].ToVector3D();
                v.Normalize();
                mb.Positions[i] = v.ToPoint3D();
            }

            var mesh = mb.ToMesh();
            UnitSphereCache[subdivisions] = mesh;
            return mesh;
        }