detached voxel chunk geometries with independent matrix translations
npm install voxel-chunksdetached voxel chunk geometry with independent matrix
transforms on each chunk matrix collection
See the voxel-servo
example for a more concrete use of this module.
`` js`
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 thepos.direction direction from the existing block.
pos.chunkMatrix should be the chunk matrix instance to use to set the block toval, 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 chunkpos.chunkMatrix
matrix instance .
Return an object with the chunk index ix.chunk and the voxel index ix.voxelpos
at the world coordinates .
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 chunkreturn 0
as necessary. It defaults to (empty space).
Set the block at the chunk-local coordinates pos to value.
Get the block at the chunk-local coordinates pos.
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
Emitted when a chunk mesh gets computed.
Emitted when a chunk mesh gets recomputed and the old surface mesh is no
longer active.
With npm do:
```
npm install voxel-chunks
MIT