Code Monkey home page Code Monkey logo

sparse-octree's Introduction

Sparse Octree

CI Version

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

Demo · Sandbox · Documentation

Installation

This library requires the peer dependency three.

npm install three sparse-octree

Usage

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);

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); // => 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

Contributing

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

sparse-octree's People

Contributors

vanruesc avatar canadaduane avatar mattbradbury avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.