Home

Awesome

EZ-Tree

NPM Version NPM Downloads GitHub Repo stars X (formerly Twitter) Follow YouTube Channel Subscribers

<p align="center"> <img src="https://github.com/user-attachments/assets/cb5f5edd-3e1b-453d-925f-734965126b17"> </p>

About

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.

App

https://eztree.dev

Installation

npm i @dgreenheck/ez-tree

Usage

// 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.

Running Standalone App Locally

To run the standalone app locally, you first need to build the EZ-Tree library before running the app.

npm install
npm run app

Running App with Docker

docker compose build
docker compose up -d

Tree Parameters

The TreeOptions class defines an options object that controls various parameters of a procedurally generated tree. Each property of this object allows for customization of the tree's appearance, including bark, branches, and leaves. Below is a detailed explanation of each property of the TreeOptions object.

General Properties

Bark Parameters

The bark object controls the appearance and properties of the tree trunk.

Branch Parameters

The branch object defines parameters for the trunk and branch levels of the tree.

Leaf Parameters

The leaves object defines properties that control the appearance and placement of leaves.