Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/erasta/three-octree-vertices
Octree of vertices for three.js
https://github.com/erasta/three-octree-vertices
3d javascript octree space-partitioning threejs vertices
Last synced: 19 days ago
JSON representation
Octree of vertices for three.js
- Host: GitHub
- URL: https://github.com/erasta/three-octree-vertices
- Owner: erasta
- License: mit
- Created: 2022-09-11T18:09:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-17T06:40:49.000Z (over 2 years ago)
- Last Synced: 2024-12-11T04:53:30.577Z (about 1 month ago)
- Topics: 3d, javascript, octree, space-partitioning, threejs, vertices
- Language: JavaScript
- Homepage: https://erasta.github.io/three-octree-vertices/index.html
- Size: 1.88 MB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# three-octree-vertices
Octree of vertices for three.js[![npm](https://img.shields.io/npm/v/three-octree-vertices?style=plastic)](https://www.npmjs.com/package/three-octree-vertices)
Octree is a space partitioning tree data structure in which each internal node has exactly eight children, used for O(logn) spatial queries.
For information on Octree from [wikipedia](https://en.wikipedia.org/wiki/Octree).## Demo
Show the octree of a mesh and adds a few more points every second.
https://erasta.github.io/three-octree-vertices/index.html## Install
```sh
npm install --save three-octree-vertices
```## Usage
```js
import { Octree } from 'three-octree-vertices';
const octree = new Octree(mesh.geometry);
const found = octree.search(new THREE.Sphere(point, radius));
```#### `octree = new Octree(vertices, maxVerticesPerNode)`
Builds an Octree from the vertices.
vertices - (array-like of Vector3 | BufferGeometry) points to build the tree from.
maxVerticesPerNode - (Integer) threshold for splitting a tree node into 8 sub-trees.#### `octree.addVertex(vertex)`
Adding a vertex (Vector3) to the tree#### `foundIndices = octree.search(sphere)`
Searches for vertices inside the sphere and returns their indices (array of Integer)