An experimental voxel engine.
Under active development, best way to try it is to clone and hack on it:
cd noanpm installnpm start # runs /examples/hello-worldnpm test # runs /examples/test
Here are live versions of the examples:
To build a new world app, use
noa as a dependency:
npm install --save noa-engine
var engine =var noa =
The source is pretty fully commented. There is a partial API reference at the end of this file, but I haven't been able to find a good way of generating JSDocs that I can live with, so for now it's best to consult the source.
onLoadwhen a block is created as part of a newly-loaded chunk
onUnload- when the block goes away because its chunk was unloaded
onSet- when a block gets set to that particular id
onUnset- when a block that had that id gets set to something else
onCustomMeshCreate- when that block's custom mesh is instantiated (either due to load or set)
noa.targetedBlockwith details on whatever block is currently targeted.
Main engine object.
Emits: tick, beforeRender, afterRender, targetBlockChanged
var noaEngine =var noa =
playerEntity - Entity id for the player entity
playerBody - reference to player entity's physics body
setPaused (paused) - Pausing the engine will also stop render/tick events, etc.
addBlock (id,x,y,z) - Adds a block unless obstructed by entities
pick (pos, vec, dist) - Raycast through the world, returning a result object for any non-air block
Wrangles entities. This class is an instance of ECS, and as such implements the usual ECS methods. It's also decorated with helpers and accessor functions for getting component existence/state.
Expects entity definitions in a specific format - see source
components folder for examples.
names - Hash containing the component names of built-in components.
add (position, width, height..)
Helper to set up a general entity, and populate with some common components depending on arguments.
Parameters: position, width, height [, mesh, meshOffset, doPhysics, shadow]
Module for managing the world, and its chunks
setChunkData (id, array) - client should call this after creating a chunk's worth of data (as an ndarray)