JSPM

  • Created
  • Published
  • Downloads 1106
  • Score
    100M100P100Q165693F
  • License Zlib

A sparse octree data structure.

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

Build status npm version Dependencies

A sparse octree data structure for three.js. Sparse octrees can have empty nodes. Nodes that aren't empty can either have children themselves or they can be leaf nodes that contain data.

Installation

$ npm install sparse-octree

Usage

// Attention: Three is not yet an ES2015 module!
import {
  WebGLRenderer, Scene, PerspectiveCamera,
  Points, PointsMaterial, BoxBufferGeometry, Box3
} from "three";

import { Octree, OctreeHelper } from "sparse-octree";

const renderer = new WebGLRenderer();
const scene = new Scene();

const camera = new PerspectiveCamera();
scene.add(camera);

const points = new Points(
  new TorusKnotBufferGeometry(1, 1, 64, 64),
  new PointsMaterial({
    color: 0xffffff, size: 1, sizeAttenuation: false
  })
);

scene.add(points);

const bbox = new Box3();
bbox.setFromObject(scene);

const octree = new Octree(bbox.min, bbox.max, 0.0, 8, 8);
octree.addPoints(points.geometry.getAttribute("position").array, points);

scene.add(new OctreeHelper(octree));

(function render(now) {

  requestAnimationFrame(render);
  renderer.render(scene, camera);

}());

The full setup can be found here.

Demo

Octree Raycasting

Documentation

API

Contributing

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

License

Zlib