voxel-chunks

detached voxel chunk geometries with independent matrix translations

voxel-chunks

detached voxel chunk geometry with independent matrix transforms on each chunk matrix collection

example

See the voxel-servo example for a more concrete use of this module.

methods

var voxelChunks = require('voxel-chunks')

Given a voxel-engine game instance, return a new voxel chunk group. The chunk matricies in each group have their own matricies to independently transform their chunks.

Create a block at world coordinates (pos.x, pos.y, pos.z) in the pos.direction direction from the existing block.

pos.chunkMatrix should be the chunk matrix instance to use to set the block to val, a block value integer.

Set a block value to val at the woord coordinates (pos.x, pos.y, pos.z).

pos.chunkMatrix should be the chunk matrix instance to use

Get the block at the world coordinates (pos.x, pos.y, pos.z) in the chunk matrix instance pos.chunkMatrix.

Return an object with the chunk index ix.chunk and the voxel index ix.voxel at the world coordinates pos.

Create a new detached chunk matrix geometry to transform a collection of chunks.

The optional generate(x,y,z) function is used to generate blocks in the chunk as necessary. It defaults to return 0 (empty space).

Set the block at the chunk-local coordinates pos to value.

Get the block at the chunk-local coordinates pos.

attributes

An array of all the active chunk surface meshes in the scene. This array updates every time an 'add' or 'remove' event occurs.

This array is useful for computing ray intersections with blocks in the scene.

chunk matrix rotation reference to the underlying rotation matrix

chunk matrix position reference to the underlying translation matrix

events

Emitted when a chunk mesh gets computed.

Emitted when a chunk mesh gets recomputed and the old surface mesh is no longer active.

install

With npm do:

npm install voxel-chunks

license

MIT