GithubHelp home page GithubHelp logo

noa's Introduction

noa-engine

An experimental voxel engine.

Live demo of test app here!

Usage

Under active development, best way to try it is to clone and hack on it:

(clone this repo)
cd noa
npm install
npm start       # runs /examples/hello-world
npm 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 = require('noa-engine')
var noa = engine({
    inverseY: true,
    // see source or examples for more options and usage
})

Docs

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.

Recent changes:

  • 0.20.0
    • Near chunks get loaded and distant ones get unloaded faster and more sensibly
    • Greatly speeds up chunk init, meshing, and disposal (and fixes some new Chrome deopts)
  • 0.19.0
    • Revise per-block callbacks:
      • onLoad when 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)
  • 0.18.0
    • Simplifies block targeting. Instead of several accessor methods, now there's a persistent noa.targetedBlock with details on whatever block is currently targeted.
    • noa now emits targetBlockChanged
    • Built-in block highlighting can now be overridden or turned off with option skipDefaultHighlighting
  • 0.17.0
    • Adds per-block callbacks: onCreate, onDestroy, onCustomMeshCreate
  • 0.16.0
    • Simplifies block registration - now takes an options argument, and the same API is used for custom mesh blocks
    • Removes the idea of registration for meshes

Partial API reference:

noa

Main engine object.
Emits: tick, beforeRender, afterRender, targetBlockChanged

var noaEngine = require('noa-engine')
var noa = noaEngine(opts)
  • 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.

  • getBlock (x,y,z)

  • setBlock (x,y,z)

  • addBlock (id,x,y,z) - Adds a block unless obstructed by entities

  • getPlayerPosition()

  • getPlayerMesh()

  • setPlayerEyeOffset()

  • getPlayerEyePosition()

  • getCameraVector()

  • pick (pos, vec, dist) - Raycast through the world, returning a result object for any non-air block


noa.entities

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.

  • addComponentAgain (id,name,state)

  • isTerrainBlocked (x,y,z)

  • setEntitySize (x,y,z)

  • getEntitiesInAABB (box)

  • 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]


noa.world

Module for managing the world, and its chunks

  • getBlockID (x,y,z)

  • getBlockSolidity (x,y,z)

  • getBlockOpacity (x,y,z)

  • getBlockTransparency (x,y,z)

  • getBlockFluidity (x,y,z)

  • getBlockProperties (x,y,z)

  • getBlockObjectMesh (x,y,z)

  • setBlockID (x,y,z)

  • isBoxUnobstructed (x,y,z)

  • setChunkData (id, array) - client should call this after creating a chunk's worth of data (as an ndarray)


noa's People

Contributors

fenomas avatar terrac avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.