erasta / three-octree-vertices

Octree of vertices for three.js

Home Page:https://erasta.github.io/three-octree-vertices/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

three-octree-vertices

Octree of vertices for three.js

npm

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.

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

npm install --save three-octree-vertices

Usage

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)

About

Octree of vertices for three.js

https://erasta.github.io/three-octree-vertices/index.html

License:MIT License


Languages

Language:JavaScript 82.7%Language:HTML 17.3%