Skip to content

Commit

Permalink
use hexasphere and browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
arscan committed Apr 14, 2014
1 parent 252ed0a commit 2cd92da
Show file tree
Hide file tree
Showing 15 changed files with 1,504 additions and 3,287 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
node_modules/*
bower_components/*
build
17 changes: 15 additions & 2 deletions Gruntfile.js
Expand Up @@ -24,8 +24,11 @@ module.exports = function(grunt) {
options: {
livereload: true
},
tasks: ['concat'],
files: ['src/*.js', 'index.html', 'styles.css', 'Gruntfile.js']
tasks: ['browserify'],
files: ['src/*.js', 'index.html', 'styles.css', 'Gruntfile.js', 'browserify.js']
},
browserify: {
'build/<%= pkg.name %>.js': ['browserify.js']
},
copy: {
main : {
Expand All @@ -39,13 +42,23 @@ module.exports = function(grunt) {
dest: 'include/vec2.js'
}]
}
},
shell: {
buildgrid: {
command: "bin/buildgrid -r 500 -o grid.json"
}
}

});


grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-browserify');

grunt.registerTask('buildgrid', ['shell:buildgrid']);


};
31 changes: 31 additions & 0 deletions bin/buildgrid
@@ -0,0 +1,31 @@
#!/usr/bin/env node

var argv = require('minimist')(process.argv.slice(2));
var Hexasphere = require('hexasphere.js');

var radius = 30;
var numDivisions = 45;
var scale = .55;

if(argv.r){
radius = parseInt(argv.r);
}
if(argv.d){
numDivisions = parseInt(argv.d);
}
if(argv.s){
scale = parseFloat(argv.s);
}

var hexasphere = new Hexasphere(radius, numDivisions, scale);
var output = "var grid = " + JSON.stringify(hexasphere, ['tiles', 'centerPoint', 'boundary', 'x', 'y', 'z']) + ";";

if(argv.o){
var fs = require('fs');

fs.writeFile(argv.o, output);

} else {
console.log(output);
}

3 changes: 3 additions & 0 deletions browserify.js
@@ -0,0 +1,3 @@
window.ENCOM = (window.ENCOM || {});
window.ENCOM.Globe = require('./src/Globe.js');

0 comments on commit 2cd92da

Please sign in to comment.