Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vanruesc/sparse-octree
A sparse octree data structure.
https://github.com/vanruesc/sparse-octree
3d culling octree raycasting sparse
Last synced: 6 days ago
JSON representation
A sparse octree data structure.
- Host: GitHub
- URL: https://github.com/vanruesc/sparse-octree
- Owner: vanruesc
- License: zlib
- Created: 2016-05-15T20:49:31.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-05T14:41:43.000Z (7 months ago)
- Last Synced: 2025-01-12T17:08:36.710Z (13 days ago)
- Topics: 3d, culling, octree, raycasting, sparse
- Language: TypeScript
- Homepage:
- Size: 5.79 MB
- Stars: 121
- Watchers: 6
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Sparse Octree
[![CI](https://github.com/vanruesc/sparse-octree/actions/workflows/ci.yml/badge.svg)](https://github.com/vanruesc/sparse-octree/actions/workflows/ci.yml)
[![Version](https://badgen.net/npm/v/sparse-octree?color=green)](https://www.npmjs.com/package/sparse-octree)A sparse, pointer-based octree data structure. For a linear implementation see [linear-octree](https://github.com/vanruesc/linear-octree).
*[Demo](https://vanruesc.github.io/sparse-octree/demo) · [Sandbox](https://codesandbox.io/s/sparse-octree-3yn8o) · [Documentation](https://vanruesc.github.io/sparse-octree/docs)*
## Installation
This library requires the peer dependency [three](https://github.com/mrdoob/three.js/).
```sh
npm install three sparse-octree
```## Usage
##### Points
```js
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);
const myData = {};
const p1 = new Vector3(0, 0, 0);
const p2 = new Vector3(0, 0, 0.5);octree.set(p1, myData);
octree.move(p1, p2);
octree.get(p2); // => myDataoctree.remove(p2);
octree.get(p2); // => null
```##### Custom Octrees
```js
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](https://vanruesc.github.io/sparse-octree/docs/index.html#layout)
- Supports raycasting
- Supports culling
- Can be extended to manage any data
- Provides a point management implementation## Contributing
Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.