private void AddStem(LatheMeshBuilder lathe)
    {
        var   sideVertices      = new Vector2[numStemSegments];
        float stemSegmentHeight = stemHeight / (numStemSegments - 1);

        for (int i = 0; i < numStemSegments; ++i)
        {
            sideVertices[i] = new Vector2(stemRadius, i * stemSegmentHeight);
        }

        lathe.Add(sideVertices, rotationPerHeightUnitEuler);
    }
    private void AddCap(LatheMeshBuilder lathe)
    {
        var sideVertices = new Vector2[numCapSegments];

        for (int i = 0; i < numCapSegments; ++i)
        {
            float t      = (float)i / (numCapSegments - 1);
            float height = stemHeight + Mathf.Lerp(0f, capHeight, t);

            float radius = GetCapRadius(t);

            sideVertices[i] = new Vector2(radius, height);
        }

        lathe.Add(sideVertices);
    }
        //this method updates the mesh if needed
        public void UpdateMesh()
        {
            //nothing changed
            if (isDirty == false)
            {
                return;
            }

            //start building mesh
            var lathe = new LatheMeshBuilder(numSplines);

            lathe.Add(sideVertices, rotationPerUnitHeightEuler);

            //generate mesh and apply it to meshfilter
            MeshFilter meshFilter = GetComponent <MeshFilter>();

            meshFilter.sharedMesh = lathe.CreateMesh();
        }