Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (32 sloc) 1.675 kB
655acd4 @maxogden initial checkin
authored
1 # voxel-mesh
2
3 generate a three.js mesh from voxel data. extracted from some code by @mikolalysenko
4
5 - original repo: https://github.com/mikolalysenko/mikolalysenko.github.com/tree/master/MinecraftMeshes2
6 - blog post: http://0fps.wordpress.com/2012/07/07/meshing-minecraft-part-2/
7 - webgl demo: http://mikolalysenko.github.com/MinecraftMeshes2/
8
9 # installation
10
fdb6f8f @maxogden depend on three from npm
authored
11 it is recommended that you use browserify to use this module
655acd4 @maxogden initial checkin
authored
12
13 ```
14 npm install voxel-mesh
15 npm install browserify -g
16 browserify -r voxel-mesh > voxel-mesh-browserified.js
17 ```
18
19 # usage
20
21 ```javascript
a1ba58b @maxogden remove incorrect examples from readme
authored
22 var Mesh = require('voxel-mesh')
e3de06c @maxogden 0.1.0 no more voxel dependency
authored
23 var voxelData = require('voxel').generator['Hilly Terrain']
7031fa9 @maxogden add documentation
authored
24 var mesh = new Mesh(voxelData)
25 mesh.createSurfaceMesh()
26 threeJSScene.add(mesh)
27 ```
28
e3de06c @maxogden 0.1.0 no more voxel dependency
authored
29 ## new Mesh(voxelData, meshingAlgorithm, scaleFactor)
7031fa9 @maxogden add documentation
authored
30
e3de06c @maxogden 0.1.0 no more voxel dependency
authored
31 `voxelData` and `meshingAlgorithm` are required, `scaleFactor` defaults to `new Three.Vector3(10, 10, 10)`.
7031fa9 @maxogden add documentation
authored
32
33 ## Mesh.prototype.createSurfaceMesh(material)
34
35 returns the generated surface mesh. `material` defaults to `new THREE.MeshNormalMaterial()`. after calling this method your mesh will also have `.surfaceMesh` populated with the new mesh
36
37 ## Mesh.prototype.createWireMesh(hexColor)
38
39 returns the generated wire mesh. `hexColor` defaults to `0xffffff`. after calling this method your mesh will also have `.wireMesh` populated with the new mesh
40
41 ## Mesh.prototype.addToScene(scene)
42
43 convenience method for adding the currently generated meshes (either `surfaceMesh` or `wireMesh`) to a `three.js` scene instance
44
45 ## Mesh.prototype.setPosition(x, y, z)
46
47 convenience method for setting the position of the currently generated meshes (either `surfaceMesh` or `wireMesh`)
655acd4 @maxogden initial checkin
authored
48
49 # license
50
51 MIT
Something went wrong with that request. Please try again.