{"_id":"@akb2/three-tree-geometry","_rev":"2-4fb0a26e6deadeb3e3c45f74cc4193d4","name":"@akb2/three-tree-geometry","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@akb2/three-tree-geometry","version":"1.0.0","keywords":["three","three.js","geometry"],"author":{"name":"Андрей"},"license":"MIT","_id":"@akb2/three-tree-geometry@1.0.0","maintainers":[{"name":"akb2","email":"akb2-online@ya.ru"}],"homepage":"https://github.com/akb2/three-tree-geometry#readme","bugs":{"url":"https://github.com/akb2/three-tree-geometry/issues"},"dist":{"shasum":"376f85588e40e2a582a16299143cdbdb83a26207","tarball":"https://registry.npmjs.org/@akb2/three-tree-geometry/-/three-tree-geometry-1.0.0.tgz","fileCount":6,"integrity":"sha512-8PbUeav6zs/EYxqpoJ5lhoHKz3P6TgOHChU2Jt2vjkQQ02JIxZjllLw3PWuhGN/hTmhqz48+w/nV/vudGEhRYg==","signatures":[{"sig":"MEUCIBDm4kXLdqyMDRv6cy+BlrV4xwNCuVvTbB6syZwoC9eVAiEAhF0vVxFjmjcvsfHwI3qSIIaujYNYV/PaUyQpYb18vfA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43977},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"a97be5bda3e7843ddcbd773ce320fa87b1916ae1","scripts":{"build":"tsup src/index.ts --dts --format esm,cjs --clean --out-dir dist","prepublishOnly":"npm run build"},"_npmUser":{"name":"akb2","email":"akb2-online@ya.ru"},"repository":{"url":"git+https://github.com/akb2/three-tree-geometry.git","type":"git"},"_npmVersion":"10.9.0","description":"Tree geomentry for Three.js","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","dependencies":{"three":"^0.159.0","@akb2/math":"^1.0.0","@types/three":"^0.159.0","@akb2/types-tools":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.4.0"},"peerDependencies":{"three":">=0.159 <1","@akb2/math":">=1 <2","@types/three":">=0.159 <1","@akb2/types-tools":">=1 <2"},"_npmOperationalInternal":{"tmp":"tmp/three-tree-geometry_1.0.0_1759625073099_0.01772827549601841","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@akb2/three-tree-geometry","version":"1.1.1","description":"Tree geomentry for Three.js","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"sideEffects":false,"keywords":["three","three.js","geometry"],"author":{"name":"Андрей"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/akb2/three-tree-geometry.git"},"bugs":{"url":"https://github.com/akb2/three-tree-geometry/issues"},"peerDependencies":{"@akb2/math":">=1 <2","@akb2/types-tools":">=1 <2","@types/three":">=0.159 <1","three":">=0.159 <1"},"devDependencies":{"@akb2/math":"^1.0","@akb2/types-tools":"^1.0","@storybook/preact-vite":"^9.1.10","@types/jest":"^30.0.0","@types/three":"^0.159.0","jest":"^30.2.0","preact":"^10.27.2","storybook":"^9.1.10","three":"^0.159.0","ts-jest":"^29.4.5","tsup":"^8.0.0","typescript":"^5.9.3","vite":"^7.1.10"},"scripts":{"build":"tsup src/index.ts --dts --format esm,cjs --clean --out-dir dist --minify","prepublishOnly":"npm run build","storybook":"storybook dev -p 6006","publish":"npm run build && npm publish --access public"},"_id":"@akb2/three-tree-geometry@1.1.1","gitHead":"111370e879d6c045a2f7244587046c8608e25e4e","homepage":"https://github.com/akb2/three-tree-geometry#readme","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-ZvMzbDxzWrt1y8mbpOz7Ji5saOghCZ9OjkVFUiHfSnZcAXT19XDnzLx59sQdR3iqgTlh7JzQbj588BV0sI9ZcQ==","shasum":"1be41dc070f188edeb17c340902cd5690fa1b95d","tarball":"https://registry.npmjs.org/@akb2/three-tree-geometry/-/three-tree-geometry-1.1.1.tgz","fileCount":6,"unpackedSize":28408,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGGNfuAiuVoz19MAG+Ts09wV/XutuziMjJzFrWay0JG6AiBOEBL/oEuaW1CpuxUL9W/GaBQxmpZq+Q1rRV1JnAlixA=="}]},"_npmUser":{"name":"akb2","email":"akb2-online@ya.ru"},"directories":{},"maintainers":[{"name":"akb2","email":"akb2-online@ya.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/three-tree-geometry_1.1.1_1760560805552_0.580072783476959"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-05T00:44:33.005Z","modified":"2025-10-15T20:40:05.974Z","1.0.0":"2025-10-05T00:44:33.312Z","1.1.1":"2025-10-15T20:40:05.769Z"},"bugs":{"url":"https://github.com/akb2/three-tree-geometry/issues"},"author":{"name":"Андрей"},"license":"MIT","homepage":"https://github.com/akb2/three-tree-geometry#readme","keywords":["three","three.js","geometry"],"repository":{"type":"git","url":"git+https://github.com/akb2/three-tree-geometry.git"},"description":"Tree geomentry for Three.js","maintainers":[{"name":"akb2","email":"akb2-online@ya.ru"}],"readme":"# 🌳 @akb2/three-tree-geometry\n\nA lightweight procedural **tree geometry generator** for [Three.js](https://threejs.org), written in TypeScript. It creates realistic, branching 3D tree structures using custom geometry based on configurable parameters.\n\n## Installation\n\n```bash\nnpm install @akb2/three-tree-geometry\n```\n\n## Overview\n\n`@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.\n\nThe library is part of the [`@akb2` toolset](https://www.npmjs.com/org/akb2), and integrates well with:\n\n* [`@akb2/math`](https://www.npmjs.com/package/@akb2/math)\n* [`@akb2/types-tools`](https://www.npmjs.com/package/@akb2/types-tools)\n\n## Usage Example\n\n```ts\nimport { MeshStandardMaterial, Mesh } from \"three\";\nimport { TreeGeometry } from \"@akb2/three-tree-geometry\";\n\n// Define geometry parameters\nconst params = {\n  generations: 5,\n  length: 2.5,\n  uvLength: 2,\n  radius: 0.15,\n  radiusSegments: 8,\n  heightSegments: 5\n};\n\n// Create tree geometry and mesh\nconst geometry = new TreeGeometry(params);\nconst material = new MeshStandardMaterial({ color: 0x8B4513 });\nconst tree = new Mesh(geometry, material);\n\n// Add to scene\nscene.add(tree);\n```\n\n---\n\n## Class: `TreeGeometry`\n\nExtends: `THREE.BufferGeometry`\n\n### Constructor\n\n```ts\nnew TreeGeometry(parameters: TreeGeometryParams)\n```\n\n#### Parameters (`TreeGeometryParams`)\n\n| Name             | Type                     | Description                                        |\n| ---------------- | ------------------------ | -------------------------------------------------- |\n| `generations`    | `number`                 | Number of recursive branch generations             |\n| `length`         | `number`                 | Base branch length                                 |\n| `uvLength`       | `number`                 | UV scaling along branch height                     |\n| `radius`         | `number`                 | Base radius of the trunk                           |\n| `radiusSegments` | `number`                 | Number of segments around the branch circumference |\n| `heightSegments` | `number`                 | Number of vertical segments per branch             |\n| `from?`          | `TreeSegment \\| Vector3` | Optional starting point for sub-branches           |\n| `rotation?`      | `Matrix4`                | Optional rotation matrix                           |\n| `uvOffset?`      | `number`                 | UV offset value                                    |\n| `generation?`    | `number`                 | Current branch generation index                    |\n| `spawner?`       | `TreeSpawner`            | Optional reference for procedural spawning         |\n\n---\n\n### Properties\n\n| Property              | Type        | Description                                   |\n| --------------------- | ----------- | --------------------------------------------- |\n| `branchesEnds`        | `Vector3[]` | Endpoints of all generated branches           |\n| `positionsOfBranches` | `Vector3[]` | Cached list of averaged points along branches |\n| `type`                | `string`    | Always `\"TreeGeometry\"`                       |\n\n---\n\n### Methods\n\n#### `getPositionsOfBranches(skip?: number): Vector3[]`\n\nReturns all branch points (center positions of each segment), sorted by Y coordinate.\nOptional `skip` parameter allows skipping the first *n* points.\n\n---\n\n#### `clone(): this`\n\nCreates a deep copy of the geometry, including its parameters and computed branches.\n\n#### `copy(source: this): this`\n\nCopies geometry data and parameters from another `TreeGeometry` instance.\n\n---\n\n### Internal Methods (for advanced use)\n\nThese are used internally but can be overridden for custom generation:\n\n* `buildBranches(branch: TreeBranch, offset?: number): BuildData`\n* `buildBranch(branch: TreeBranch, offset?: number): BuildData`\n\nBoth methods construct vertices, faces, and UVs for each branch and its children recursively.\n\n---\n\n## Dependencies\n\n* [`three`](https://www.npmjs.com/package/three)\n* [`@akb2/math`](https://www.npmjs.com/package/@akb2/math)\n* [`@akb2/types-tools`](https://www.npmjs.com/package/@akb2/types-tools)\n\n---\n\n## License\n\nMIT © 2025 [Andrei Kobelev @akb2](https://github.com/akb2)\n| [Github repository](https://github.com/akb2/three-tree-geometry)\n| [LinkedIn](http://linkedin.com/in/akb2)\n","readmeFilename":"README.md"}