@dgreenheck/ez-tree

中文文档
1.1.0发布于 2026/01/15MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 11.9万

NPM Version NPM Downloads GitHub Repo stars ![X (formerly Twitter) Follow](https:

原始使用文档
文档目录4 节
  1. General Properties
  2. Bark Parameters
  3. Branch Parameters
  4. Leaf Parameters

EZ-Tree

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

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

  • seed: Sets the initial value for random generation, ensuring consistent tree generation when using the same seed.
  • type: Defines the type of the tree, which can be set to one of the options from the TreeType enumeration (e.g., TreeType.Deciduous).

Bark Parameters

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

  • type: Specifies the type of bark texture to use, selected from the BarkType enumeration (e.g., BarkType.Oak).
  • tint: Determines the color tint applied to the bark, defined as a hexadecimal color value (e.g., 0xffffff for white).
  • flatShading: Boolean property indicating whether to use flat shading (true) or smooth shading (false) for the bark.
  • textured: Boolean value that indicates if a texture is applied to the bark (true or false).
  • textureScale: Controls the scale of the bark texture in both the x and y axes. It is an object with properties x and y to define the scaling factors.

Branch Parameters

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

  • levels: Number of recursive branch levels. Setting this to 0 creates only the trunk, while higher values add more branches.
  • angle: Defines the angle, in degrees, at which child branches grow relative to their parent branch. This is specified separately for each level.
  • children: Specifies the number of child branches at each level, with the index (0, 1, 2, etc.) representing the level.
  • force: Represents an external directional force encouraging tree growth, defined by direction (a vector object { x, y, z }) and strength (a numeric value).
  • gnarliness: Defines how twisted or curled each branch level should be, specified for each level.
  • length: Length of the branches at each level. This is an object with keys representing each level.
  • radius: Radius (or thickness) of the branches at each level.
  • sections: Number of segments along the length of each branch level, controlling the resolution of the branch mesh.
  • segments: Number of radial segments that make up each branch, with a higher value resulting in a smoother cylinder.
  • start: Specifies where along the parent branch (as a fraction from 0 to 1) the child branches should start forming.
  • taper: Controls the tapering of the branches at each level. A value between 0 and 1 defines the reduction in radius from base to tip.
  • twist: Defines the amount of twisting applied to each branch level.

Leaf Parameters

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

  • type: Specifies the type of leaf texture, selected from the LeafType enumeration (e.g., LeafType.Oak).
  • billboard: Defines how leaves are rendered. The Billboard enumeration can be set to Single or Double to indicate single or perpendicular double-sided leaves.
  • angle: Defines the angle of the leaves relative to the parent branch, in degrees.
  • count: Number of leaves to generate.
  • start: Specifies where along the length of the branch (as a value between 0 and 1) leaves should start growing.
  • size: Size of the leaves, represented as a numeric value.
  • sizeVariance: Specifies how much variance in size each leaf instance should have, making the leaves look more natural.
  • tint: Tint color applied to the leaves, defined as a hexadecimal color value (e.g., 0xffffff for white).
  • alphaTest: Sets the alpha threshold for leaf transparency, controlling the transparency of the leaf textures.

版本与发布记录

@dgreenheck/ez-tree 共发布 7 个版本,首次发布于 2024/09/30;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.0latest2026/01/159 个月前
1.0.12026/01/149 个月前
1.0.02024/10/182 年前
0.1.42024/10/022 年前
0.1.32024/10/022 年前
0.1.22024/10/022 年前

关于 @dgreenheck/ez-tree 的常见问题

@dgreenheck/ez-tree 是什么?

![X (formerly Twitter) Follow](https:

如何安装 @dgreenheck/ez-tree?

在项目目录运行 npm install @dgreenheck/ez-tree,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:three(>=0.167)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dgreenheck/ez-tree 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dgreenheck/ez-tree 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dgreenheck/ez-tree 可以商用吗?

@dgreenheck/ez-tree 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dgreenheck/ez-tree 的下载量有多少?

根据 npm 官方下载统计,@dgreenheck/ez-tree 在 2026/10/12 – 2026/11/10 这 30 天内被下载 118,605 次,日均约 3,954 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dgreenheck/ez-tree 还在维护吗?

最新版本 1.1.0 发布于 2026/01/15(9 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 2 个;首次发布于 2024/09/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。