Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
shama committed Jan 14, 2013
0 parents commit 534abe1
Show file tree
Hide file tree
Showing 19 changed files with 41,081 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/node_modules/
/example/textures/
2 changes: 2 additions & 0 deletions .npmignore
@@ -0,0 +1,2 @@
/node_modules/
/example/textures/
39 changes: 39 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,39 @@
module.exports = function(grunt) {

grunt.initConfig({
watch: {
files: ['index.js'],
tasks: ['default']
}
});

grunt.loadNpmTasks('grunt-contrib-watch');

// run example
grunt.registerTask('default', function() {
var done = this.async();
grunt.util.async.forEachSeries([
'cp -R ./node_modules/voxel-engine/textures/ ./example/textures/',
'cp -R ./textures/ ./example/textures/',
'browserify example/index.js -o example/bundle.js',
'node example/server',
], function(cmd, next) {
grunt.log.writeln('> ' + cmd);
require('child_process').exec(cmd, {stdio:'inherit'}, function(err, stdout, stderr) {
if (err || stderr) return next(err || new Error(stderr));
if (stdout) grunt.log.writeln(stdout);
next();
});
}, done);
});

// move example for gh-pages
grunt.registerTask('gh-pages', function() {
var done = this.async();
require('child_process').exec('cp -R ./example/* ./', {stdio:'inherit'}, function(err, stdout, stderr) {
if (err || stderr) return next(err || new Error(stderr));
if (stdout) grunt.log.writeln(stdout);
done();
});
});
};
22 changes: 22 additions & 0 deletions LICENSE-MIT
@@ -0,0 +1,22 @@
Copyright (c) 2013 Kyle Robinson Young

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
101 changes: 101 additions & 0 deletions README.md
@@ -0,0 +1,101 @@
# voxel-texture

> A texture helper for [voxeljs](http://voxeljs.com).
View [the demo](https://shama.github.com/voxel-texture).

## example
```js
// Pass it a copy of the game
var createMaterials = require('voxel-texture')(game);

// Create 6 sided material, all sides same texture
var materials = createMaterials('grass');
```

This will load `'./textures/grass.png'` assuming your
`game.texturePath === './textures/'`.

Then you can use the materials like such:
```js
var cube = new game.THREE.Mesh(
new game.THREE.CubeGeometry(game.cubeSize, game.cubeSize, game.cubeSize),
materials
);
```

OR specify each side of the material:
```js
var materials = createMaterials([
'grass', // BACK
'dirt', // FRONT
'brick', // TOP
'bedrock', // BOTTOM
'glowstone', // LEFT
'obsidian' // RIGHT
]);
```

OR just the top and sides:
```js
var materials = createMaterials([
'grass', // TOP/BOTTOM
'grass_dirt', // SIDES
]);
```

OR the top, bottom and sides:
```js
var materials = createMaterials([
'grass', // TOP
'dirt', // BOTTOM
'grass_dirt', // SIDES
]);
```

OR the top, bottom, front/back and left/right:
```js
var materials = createMaterials([
'grass', // TOP
'dirt', // BOTTOM
'grass_dirt', // FRONT/BACK
'brick', // LEFT/RIGHT
]);
```

OR if your memory sucks like mine:
```js
var materials = createMaterials({
top: 'grass',
bottom: 'dirt',
left: 'grass_dirt',
right: 'grass_dirt',
front: 'grass_dirt',
back: 'grass_dirt'
});
```
_Just be sure to include all the keys_

### Alternate File Extension

If your texture isn't a `.png`, just specify the extension:
```js
var materials = createMaterials([
'diamond',
'crate.gif',
]);
```

## install
With [npm](http://npmjs.org) do:

```
npm install voxel-texture
```

## release history
* 0.1.0 - initial release

## license
Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.

0 comments on commit 534abe1

Please sign in to comment.