EZ-Tree is a procedural tree generator with dozens of tunable parameters. The standalone tree generation code is published as a library and can be imported into your own application for dynamically generating trees on demand. Additionally, there is a standalone web app which allows you to create trees within the browser and export as .PNG or .GLB files.
npm i @dgreenheck/ez-tree
// Create new instance
const tree = new Tree();
// Set parameters
tree.options.seed = 12345;
tree.options.trunk.length = 20;
tree.options.branch.levels = 3;
// Generate tree and add to your Three.js scene
tree.generate();
scene.add(tree);
Any time the tree parameters are changed, you must call generate()
to regenerate the geometry.
To run the standalone app locally, you first need to build the EZ-Tree library before running the app.
npm install
npm run build:lib
npm run app
docker compose build
docker compose up -d
seed
- Seed for RNG
color
- Color of the tree trunkflatShading
- Use face normals for shading instead of vertex normalslength
- Length of the base trunkradius
- Starting radius of the trunk
levels
- Number of branch recursions ( Keep under 5 )children
- Number of child branchesstart
- Defines where child branches start forming on the parent branch. A value of 0.6 means the child branches can start forming 60% of the way up the parent branchstop
- Defines where child branches stop forming on the parent branch. A value of 0.9 means the child branches stop forming 90% of the way up the parent branchangle
- Angle between child branch and parent branch (radians)angleVariance
- Variation inangle
(radians)lengthVariance
- Variation in branch lengthlengthMultiplier
- Length of child branch relative to parentradiusMultiplier
- Radius of child branch relative to parenttaper
- Radius of end of branch relative to the start of the branchgnarliness
- Max amplitude of random angle added to each section's orientationtwist
- Amount of twisting about the vertical axis
direction
- Influences the direction the tree grows towardsstrength
- Strength of the sun influence
sections
- Number of sections that make up this branchsegments
- Number of faces around the circumference of the branchlengthVariance
- % variance in the nominal section lengthradiusVariance
- % variance in the nominal section radiusrandomization
- Randomization factor applied to vertices
style
- Leaf billboard style (single or double)type
- Leaf type (Ash, Aspen or Oak)color
- Leaf colorcount
- Number of leaves per branchsize
- Size of leaf texturesizeVariance
- Variance in leaf size between branches