node package manager



Model vision in a 2D world.

Get the code


To install npm, visit

Install Glazz

$ npm install glazz


$ git clone git://

Import the code


var SolidityMap = require('solidityMap').SolidityMap;
var Glazz = require('glazz').glazz;


<script type="text/javascript" src="glazz.js"></script>
<script type="text/javascript" src="solidityMap.js"></script>
<script type="text/javascript" src="raytracer.js"></script>
<script type="text/javascript" src="eyes.js"></script>


See /index.html


Require SolidityMap. Instantiate it, passing in the width and height of your world. This initialises every solidity map cell to 0, the empty material value.

var SolidityMap = require('src/solidityMap').SolidityMap;
var sm = new SolidityMap(10, 10);

Define an Obj constructor that includes getPosition(), getSize() and getMaterial() accessors. Use it to instantiate the actor, the object that will have eyes.

var Obj = function(posX, posY, sizeX, sizeY) {
  this.pos = { x:posX, y:posY };
  this.size = { x:sizeX, y:sizeY };

  this.getPosition = function() {
    return this.pos;

  this.getSize = function() {
    return this.size;

  this.getMaterial = function() {
    return 1;

var actor = new Obj(1, 1, 1, 1);

Give the actor eyes.

var eyes = new Eyes(actor, sm);

Instantiate an object for the actor to look at. Put it in the solidity map.

var obj = new Obj(3, 3, 1, 1);

Make the actor look at the object. See that he sees.

var lookEndpoint = eyes.lookAt(obj);
console.log(lookEndpoint.obj === obj); // => true

The object moves. Update the solidity map with its new position.

obj.pos = { x:4, y:4 };

Run the tests

Install Node.js and npm:

Install the node dependencies and run the tests with:

$ cd path/to/glazz
$ npm install
$ npm test