Automatically add and remove chunks from continuous ndarrays as required.
Take a continuous ndarray and, given a set of "observable" positions, automatically add and remove chunks as required.
Use this for painless chunk management with one or more visible perspectives.
npm install continuous-observer
Returns a function that can be used to update the chunks in use, given a
continuous ndarray (
rangeis the amount of surrounding chunks to include. Defaults to 1.
lingeris the amount of surrounding chunks to not remove when cleaning up. Defaults to
range, and cannot be set to below
points is an array of arrays, with each array representing an observer's
position. Can also handle a single array as well, if you're only using one
// Create a continuous ndarray with 32x32 chunksvar field = require'ndarray-continuous' shape: 32 32// Create the observervar moveTo = require'continuous-observer'field 1 2// "Move" the observer to the originmoveTo0 0// Ahead one chunkmoveTo32 32// Ahead another chunk - this will remove// some of the older chunks.moveTo32 32// Including another observer just involves// adding another position to the array.moveTo32 32 0 0