1.3.0 • Published 8 years ago

three-buffergeometry-sort v1.3.0

Weekly downloads
2
License
MPL-2.0
Repository
github
Last release
8 years ago

three-buffergeometry-sort

I primarily made this so working with THREE.js BufferGeometry would be easier to work with. Some of this code is based on this StackOverflow post.

How to use

// Import this library
var BGSorter = require("three-buffergeometry-sort");

// Create your BufferGeometry with 'positions' attribute
this.points = new THREE.BufferGeometry();
this.points.addAttribute('position', positions);

// Initialize the sorter
var sorter = BGSorter();

function render() {
  // Sort positions in ascending order in terms of distance from camera every frame
  sorter.sort(this.points.attributes, cameraPosition);

  window.requestAnimationFrame(render);
}
window.requestAnimationFrame(render);

You can also make it sort every N frames

var sorter = BGSorter(5);

function render() {
  // Sort positions every 5 frames
  sorter.sort(this.points.attributes, cameraPosition);

  window.requestAnimationFrame(render);
}
window.requestAnimationFrame(render);

License

Mozilla Public License version 2

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

9 years ago

1.0.0

9 years ago

1.0.0-alpha4

9 years ago

1.0.0-alpha3

9 years ago

1.0.0-alpha2

9 years ago

1.0.0-alpha1

9 years ago