Package Exports
- sparse-octree
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sparse-octree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Sparse Octree
A sparse octree data structure for three.js.
Extensive Demo :: API Reference
Installation
$ npm install sparse-octree
Usage
Basics
import { Octree, CubicOctant } from "sparse-octree";
export class CubicOctree extends Octree {
constructor(min, size) {
this.root = new CubicOctant(min, size);
}
}
Helper
import { Scene } from "three";
import { Octree, OctreeHelper } from "sparse-octree";
const scene = new Scene();
const octree = new Octree(...);
const octreeHelper = new OctreeHelper(octree);
try {
octreeHelper.update();
} catch(error) {
console.warn(error.message);
}
scene.add(octreeHelper);
Points
import { Vector3 } from "three";
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);
octree.add(new Vector3(0, 0, 0), {});
octree.fetch(new Vector3(0, 0, 0)); // {}
Features
- Base Functionality
- Handles octant splitting
- Adheres to a common octant layout
- Supports raycasting
- Supports culling
- Supports cubic octrees
- Can be extended to manage any data
- Provides a point management implementation
- Provides a helper that can visualise octrees
Contributing
Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.