-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
37 lines (37 loc) · 4.73 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
"name": "voxel-engine",
"description": "make games with voxel.js",
"version": "0.5.3",
"repository": {
"type": "git",
"url": "git@github.com:maxogden/voxel-engine.git"
},
"dependencies": {
"voxel": "0.1.4",
"voxel-mesh": "0.1.1",
"voxel-chunks": "0.0.2",
"inherits": "1.0.0",
"player-physics": "0.1.0",
"three": "0.54.0",
"raf": "0.0.1",
"interact": "0.0.2",
"toolbar": "0.0.2",
"voxel-texture": "0.3.0",
"voxel-region-change": "0.0.2",
"collide-3d-tilemap": "0.0.1",
"aabb-3d": "0.0.0",
"spatial-events": "0.0.1",
"spatial-trigger": "0.0.0"
},
"readme": "# voxel-engine\n\n## A voxel engine in javascript using three.js\n\nLearn more at http://voxeljs.com\n\nhello world code: http://github.com/maxogden/voxel-hello-world\n\n# example\n\n``` js\nvar createGame = require('voxel-engine')\nvar game = createGame()\nvar container = document.querySelector('#container')\ngame.appendTo(container)\ncontainer.addEventListener('click', function() {\n game.requestPointerLock(container)\n})\n```\n\n# API\n\n## require('voxel-engine')(options)\n\nReturns a new game instance. `options` defaults to:\n\n```javascript\n{\n texturePath: './textures/',\n generate: function(x,y,z) {\n return x*x+y*y+z*z <= 20*20 ? 1 : 0 // sphere world\n },\n materials: [['grass', 'dirt', 'grass_dirt'], 'brick', 'dirt'],\n cubeSize: 25,\n chunkSize: 32,\n chunkDistance: 2,\n startingPosition: [35, 1024, 35],\n worldOrigin: [0,0,0],\n controlOptions: {jump: 6},\n controlLayout: 'qwerty'\n}\n```\n\n## Game events\n\nThere are a number of events you can listen to once you've instantiated a game. we use the node.js event emitter library which uses the following syntax for subscribing:\n\n`emitter.on('eventName', function(arg1, arg2, etc) {})`\n\n### game.on('tick', function(delta) {})\n\nemits every time the game renders (usually no more than 60 times a second). delta is the time in milliseconds between this render and the last render\n\n### game.voxelRegion.on('change', function(pos) {})\n\nemits when you move between voxels. pos has x, y, and z voxel coordinates of the voxel you just entered\n\n### game.chunkRegion.on('change', function(pos) {})\n\nemits when you move between chunks. pos has x, y, and z chunk coordinates of the chunk you just entered\n\n## Generating voxel worlds\n\nWorlds have many chunks and chunks have many voxels. Chunks are cube shaped and are `chunkSize` x/y/z (default 32/32/32 - 32768 voxels per chunk). When the game starts it takes the `worldOrigin` and generates `chunkDistance` chunks in every x/y/z dimension (`chunkDistance` default of 2 means the game will render 2 chunks behind you, 2 in front etc for a total of 16 chunks.). \n\nWhen you create a game you can also pass functions that the game will ask for voxel data. Here is an example `generate` function that makes a randomly textured cube world with a diameter of 20 voxels:\n\n```javascript\nfunction generator(x, y, z) {\n if (x*x + y*y + z*z > 20*20) return 0\n return Math.floor(Math.random() * 4) + 1\n}\n```\n\nThe `generate` function will be called once for each voxel in the world. `x`, `y` and `z` will be values in voxel coordinates.\n\n## Interacting with the voxel world\n\nWhen the game renders it draws each voxel at `cubeSize` wide in three.js world coordinates (something like pixels wide). So a default chunk is 32 (`chunkSize`) * 25 (default `cubeSize`) === 800 wide.\n\nTo get the players current position you can do `gameInstance.controls.yawObject.position`. This returns a THREE.js Vector3 object (which just means an object with 'x', 'y', and 'z'). The coordinates are in world coordinates.\n\nTo look up the chunk at some world coordinates:\n\n`gameInstance.voxels.chunkAtPosition(position)`\n\nTo look up the voxel at some world coordinates (relative to that voxels chunk):\n\n`gameInstance.voxels.voxelVector(position)`\n\nCreate a new voxel at some world coordinates (handles collisions with player, etc):\n\n`gameInstance.createBlock(pos, val)`\n\n`val` can be 0 or you can also use any single digit integer 0-9. These correspond to the materials array that you pass in to the game.\n\nSet the value of a voxel at some world coordinates:\n\n`gameInstance.setBlock(pos, val)`\n\nGet the value of a voxel at some world coordinates:\n\n`gameInstance.getBlock(pos)`\n\nIf you wanna see the lower level API for voxel data manipulation look at `chunker.js` inside the voxel module.\n\n## license\n\nBSD\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/maxogden/voxel-engine/issues"
},
"_id": "voxel-engine@0.5.3",
"dist": {
"shasum": "52de307474cc6d90b6d24347f67af1baaaf36c85"
},
"_from": "voxel-engine@0.5.3",
"_resolved": "https://registry.npmjs.org/voxel-engine/-/voxel-engine-0.5.3.tgz"
}