npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@akb2/three-tree-geometry

v1.1.1

Published

Tree geomentry for Three.js

Readme

🌳 @akb2/three-tree-geometry

A lightweight procedural tree geometry generator for Three.js, written in TypeScript. It creates realistic, branching 3D tree structures using custom geometry based on configurable parameters.

Installation

npm install @akb2/three-tree-geometry

Overview

@akb2/three-tree-geometry provides a procedural tree mesh generator built on top of THREE.BufferGeometry. It constructs a complete 3D tree — including branches, segments, and UV-mapped faces — ready for rendering or further manipulation in Three.js.

The library is part of the @akb2 toolset, and integrates well with:

Usage Example

import { MeshStandardMaterial, Mesh } from "three";
import { TreeGeometry } from "@akb2/three-tree-geometry";

// Define geometry parameters
const params = {
  generations: 5,
  length: 2.5,
  uvLength: 2,
  radius: 0.15,
  radiusSegments: 8,
  heightSegments: 5
};

// Create tree geometry and mesh
const geometry = new TreeGeometry(params);
const material = new MeshStandardMaterial({ color: 0x8B4513 });
const tree = new Mesh(geometry, material);

// Add to scene
scene.add(tree);

Class: TreeGeometry

Extends: THREE.BufferGeometry

Constructor

new TreeGeometry(parameters: TreeGeometryParams)

Parameters (TreeGeometryParams)

| Name | Type | Description | | ---------------- | ------------------------ | -------------------------------------------------- | | generations | number | Number of recursive branch generations | | length | number | Base branch length | | uvLength | number | UV scaling along branch height | | radius | number | Base radius of the trunk | | radiusSegments | number | Number of segments around the branch circumference | | heightSegments | number | Number of vertical segments per branch | | from? | TreeSegment \| Vector3 | Optional starting point for sub-branches | | rotation? | Matrix4 | Optional rotation matrix | | uvOffset? | number | UV offset value | | generation? | number | Current branch generation index | | spawner? | TreeSpawner | Optional reference for procedural spawning |


Properties

| Property | Type | Description | | --------------------- | ----------- | --------------------------------------------- | | branchesEnds | Vector3[] | Endpoints of all generated branches | | positionsOfBranches | Vector3[] | Cached list of averaged points along branches | | type | string | Always "TreeGeometry" |


Methods

getPositionsOfBranches(skip?: number): Vector3[]

Returns all branch points (center positions of each segment), sorted by Y coordinate. Optional skip parameter allows skipping the first n points.


clone(): this

Creates a deep copy of the geometry, including its parameters and computed branches.

copy(source: this): this

Copies geometry data and parameters from another TreeGeometry instance.


Internal Methods (for advanced use)

These are used internally but can be overridden for custom generation:

  • buildBranches(branch: TreeBranch, offset?: number): BuildData
  • buildBranch(branch: TreeBranch, offset?: number): BuildData

Both methods construct vertices, faces, and UVs for each branch and its children recursively.


Dependencies


License

MIT © 2025 Andrei Kobelev @akb2 | Github repository | LinkedIn