Need private packages and team management tools?Check out npm Teams »

sparse-octree

6.0.2 • Public • Published

Sparse Octree

Build status npm version Peer dependencies

A sparse, pointer-based octree data structure. For a linear implementation see linear-octree.

Demo · Sandbox · Documentation

Installation

This library requires the peer dependencies iterator-result and math-ds.

npm install iterator-result math-ds
npm install sparse-octree

Usage

Points
import { Vector3 } from "math-ds";
import { PointOctree } from "sparse-octree";
 
const min = new Vector3(-1, -1, -1);
const max = new Vector3(1, 1, 1);
 
const octree = new PointOctree(min, max);
 
const myData = {};
const p1 = new Vector3(0, 0, 0);
const p2 = new Vector3(0, 0, 0.5);
 
octree.insert(p1, myData);
octree.move(p1, p2);
octree.get(p2); // => myData
 
octree.remove(p2);
octree.get(p2); // => null
Custom Octrees
import { Octree, CubicOctant } from "sparse-octree";
 
export class CubicOctree extends Octree {
 
    constructor(min, size) {
 
        this.root = new CubicOctant(min, size);
 
    }
 
}

Features

  • Pointer-based structure
    • Handles octant splitting
    • Supports cubic octrees for reduced memory usage
    • Dynamic depth
  • Adheres to a common octant layout
  • Supports raycasting
  • Supports culling
  • Can be extended to manage any data
  • Provides a point management implementation

Octree Helper

The octree-helper module provides an octree visualization tool for three.js.

Contributing

Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Install

npm i sparse-octree

DownloadsWeekly Downloads

76

Version

6.0.2

License

Zlib

Unpacked Size

94.6 kB

Total Files

6

Last publish

Collaborators

  • avatar