Introduction
I created this tool in summer 2020 with WebGL and Typescript. The goal was to create a fast, easy, and art-directable foliage generator. The demo can be found here.
L-Systems
To create the tree, I used L-Systems, a form of recursive language expansion. We draw the tree based on a string of characters, each of which is mapped to a specific drawing function. This string of characters is expanded recursively from an initial axiom, based on a set of predefined expansion rules. I explored L-Systems previously in my Ink Minecraft project, where I created rivers and trees in the context of a 3D Array of blocks. Here, I had much more freedom in terms of geometry and functionality, as I could use meshes and custom geometry as part of my drawing functions.
Geometry
Trunks and Stems
The trunk of the tree is composed of several cylindrical segments stacked together. In order to prevent discontinuities, I created a custom cylinder class that allows the user to specify the transformations of the two faces on the cylinder. This lets us align contiguous cylinder faces to prevent obvious breaks between geometry. The difference can be seen below, with the regular cylinders on the left and the new cylinders on the right: