Skip to content

Commit

Permalink
Rename project, add license file, and rearrange some stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
TriBlade9 committed Nov 26, 2014
1 parent 2cc6f08 commit e8bd249
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 69 deletions.
20 changes: 20 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2014 Stephen Andrews, http://triblade9.wc.lt

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.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Include CEWBS in your HTML file, after BabylonJS and its dependencies.
```html
<script src="CEWBS.min.js"></script>
```
Or, if using node-webkit, require the commonJS version.
Or, if using node-webkit, require the commonJS version. (The meshers directory must be in the same directory as CWEBS-commonjs.js.)
```javascript
var CEWBS = require('CEWBS-commonjs.js');
```
Expand Down
8 changes: 4 additions & 4 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cd src
rm -rf ../dist
mkdir ../dist
browserify COOBS.js -o ../dist/COOBS.js
sed -i -e 's/var COOBS/var COOBS = window.COOBS/g' ../dist/COOBS.js
uglifyjs ../dist/COOBS.js -c -o ../dist/COOBS.min.js
cp COOBS.js ../dist/COOBS-commonjs.js
browserify CEWBS.js -o ../dist/CEWBS.js
sed -i -e 's/var CEWBS/var CEWBS = window.CEWBS/g' ../dist/CEWBS.js
uglifyjs ../dist/CEWBS.js -c -o ../dist/CEWBS.min.js
cp CEWBS.js ../dist/CEWBS-commonjs.js
cp -rf meshers ../dist/meshers
42 changes: 21 additions & 21 deletions dist/COOBS-commonjs.js → dist/CEWBS-commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ var meshers = {
'monotone': require('./meshers/monotone.js').mesher,
}

var COOBS = {};
var CEWBS = {};

COOBS.VoxelMesh = function(name, scene) {
CEWBS.VoxelMesh = function(name, scene) {
BABYLON.Mesh.call(this, name, scene);
}
COOBS.VoxelMesh.prototype = Object.create(BABYLON.Mesh.prototype);
COOBS.VoxelMesh.prototype.constructor = COOBS.VoxelMesh;
COOBS.VoxelMesh.prototype.mesher = meshers.greedy;
CEWBS.VoxelMesh.prototype = Object.create(BABYLON.Mesh.prototype);
CEWBS.VoxelMesh.prototype.constructor = CEWBS.VoxelMesh;
CEWBS.VoxelMesh.prototype.mesher = meshers.greedy;

//Default coloring function
COOBS.VoxelMesh.prototype.coloringFunction = function(id) {
CEWBS.VoxelMesh.prototype.coloringFunction = function(id) {
return [id/5, id/5, id/5];
}

//Stores the voxel volume information
/*COOBS.VoxelMesh.prototype.voxelData = {
/*CEWBS.VoxelMesh.prototype.voxelData = {
dimensions: [16,16,16],
voxels: null,
}*/

//Switch between the greedy mesher (faster) and the monotone mesher (more accurate)
COOBS.VoxelMesh.prototype.setMesher = function(type) {
CEWBS.VoxelMesh.prototype.setMesher = function(type) {
if(type == 'greedy') {
this.mesher = meshers.greedy;
} else if (type == 'monotone') {
Expand All @@ -35,7 +35,7 @@ COOBS.VoxelMesh.prototype.setMesher = function(type) {
}

//Set the voxel at x,y,z position, with the id metadata.
COOBS.VoxelMesh.prototype.setVoxelAt = function(x,y,z, metaData) {
CEWBS.VoxelMesh.prototype.setVoxelAt = function(x,y,z, metaData) {
if(this.voxelData.voxels != null) {
if(Array.isArray(x)) {
this.voxelData.voxels[x[0]+(x[1]*this.voxelData.dimensions[0])+(x[2]*this.voxelData.dimensions[0]*this.voxelData.dimensions[1])] = y;
Expand All @@ -49,7 +49,7 @@ COOBS.VoxelMesh.prototype.setVoxelAt = function(x,y,z, metaData) {

//Set a collection of voxels at different positions. Each can have it's own id or use the group id.
//Useful for importing the non-raw export.
COOBS.VoxelMesh.prototype.setVoxelBatch = function(voxels, metaData) {
CEWBS.VoxelMesh.prototype.setVoxelBatch = function(voxels, metaData) {
for(var i = 0; i < voxels.length; i++) {
var voxel = voxels[i];
if(voxel.length < 4 && metaData != null) {
Expand All @@ -61,7 +61,7 @@ COOBS.VoxelMesh.prototype.setVoxelBatch = function(voxels, metaData) {
}

//Returns the voxel id at coordinates x,y,z.
COOBS.VoxelMesh.prototype.getVoxelAt = function(x,y,z) {
CEWBS.VoxelMesh.prototype.getVoxelAt = function(x,y,z) {
if(this.voxelData.voxels != null) {
return this.voxelData.voxels[x+(y*this.voxelData.dimensions[0])+(z*this.voxelData.dimensions[0]*this.voxelData.dimensions[1])];
} else {
Expand All @@ -74,18 +74,18 @@ COOBS.VoxelMesh.prototype.getVoxelAt = function(x,y,z) {
dimensions: [x,y,z]
voxels: [] // Length should be dimensions x*y*z
}*/
COOBS.VoxelMesh.prototype.setVoxelData = function(voxelData) {
CEWBS.VoxelMesh.prototype.setVoxelData = function(voxelData) {
this.voxelData = voxelData;
}

//Returns the entire voxel volume.
//Warning, this is dimension-dependant, so don't try to use it in a differently-sized volume. use exportVoxelData for that.
COOBS.VoxelMesh.prototype.getVoxelData = function() {
CEWBS.VoxelMesh.prototype.getVoxelData = function() {
return this.voxelData;
}

//Sets the dimensions of the voxel volume. Input should be ([x,y,z]);
COOBS.VoxelMesh.prototype.setDimensions = function(dims) {
CEWBS.VoxelMesh.prototype.setDimensions = function(dims) {
if (Array.isArray(dims) && dims.length == 3) {
if(this.voxelData == null) {
this.voxelData = {};
Expand All @@ -101,7 +101,7 @@ COOBS.VoxelMesh.prototype.setDimensions = function(dims) {
}

//Used to update the actual mesh after voxels have been set.
COOBS.VoxelMesh.prototype.updateMesh = function() {
CEWBS.VoxelMesh.prototype.updateMesh = function() {
var rawMesh = this.mesher(this.voxelData.voxels, this.voxelData.dimensions);

var positions = [];
Expand Down Expand Up @@ -149,7 +149,7 @@ COOBS.VoxelMesh.prototype.updateMesh = function() {

//Set the origin (pivot point) of the mesh to the center of the dimensions.
//If ignoreY is true, then the y axis will remain 0.
COOBS.VoxelMesh.prototype.originToCenterOfBounds = function(ignoreY) {
CEWBS.VoxelMesh.prototype.originToCenterOfBounds = function(ignoreY) {
var pivotX = -this.voxelData.dimensions[0]/2;
var pivotY = -this.voxelData.dimensions[1]/2;
var pivotZ = -this.voxelData.dimensions[2]/2;
Expand All @@ -162,7 +162,7 @@ COOBS.VoxelMesh.prototype.originToCenterOfBounds = function(ignoreY) {
}

//Sets the origin (pivot point) of the mesh.
COOBS.VoxelMesh.prototype.setPivot = function(pivotX, pivotY, pivotZ) {
CEWBS.VoxelMesh.prototype.setPivot = function(pivotX, pivotY, pivotZ) {
var pivot = BABYLON.Matrix.Translation(pivotX,pivotY,pivotZ);

this.setPivotMatrix(pivot);
Expand All @@ -178,7 +178,7 @@ format:
],
}
*/
COOBS.VoxelMesh.prototype.exportVoxelData = function(raw) {
CEWBS.VoxelMesh.prototype.exportVoxelData = function(raw) {
var convertedVoxels = [];
for (var i = 0; i < this.voxelData.voxels.length; i++) {
var voxel = this.voxelData.voxels[i];
Expand All @@ -193,7 +193,7 @@ COOBS.VoxelMesh.prototype.exportVoxelData = function(raw) {
}


COOBS.VoxelMesh.handlePick = function(pickResult) {
CEWBS.VoxelMesh.handlePick = function(pickResult) {
var mesh = pickResult.pickedMesh;
var point = pickResult.pickedPoint;

Expand Down Expand Up @@ -243,6 +243,6 @@ COOBS.VoxelMesh.handlePick = function(pickResult) {
}
}

if(!window.COOBS) {
module.exports = COOBS;
if(!window.CEWBS) {
module.exports = CEWBS;
}
42 changes: 21 additions & 21 deletions dist/COOBS.js → dist/CEWBS.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ var meshers = {
'monotone': require('./meshers/monotone.js').mesher,
}

var COOBS = window.COOBS = {};
var CEWBS = window.CEWBS = {};

COOBS.VoxelMesh = function(name, scene) {
CEWBS.VoxelMesh = function(name, scene) {
BABYLON.Mesh.call(this, name, scene);
}
COOBS.VoxelMesh.prototype = Object.create(BABYLON.Mesh.prototype);
COOBS.VoxelMesh.prototype.constructor = COOBS.VoxelMesh;
COOBS.VoxelMesh.prototype.mesher = meshers.greedy;
CEWBS.VoxelMesh.prototype = Object.create(BABYLON.Mesh.prototype);
CEWBS.VoxelMesh.prototype.constructor = CEWBS.VoxelMesh;
CEWBS.VoxelMesh.prototype.mesher = meshers.greedy;

//Default coloring function
COOBS.VoxelMesh.prototype.coloringFunction = function(id) {
CEWBS.VoxelMesh.prototype.coloringFunction = function(id) {
return [id/5, id/5, id/5];
}

//Stores the voxel volume information
/*COOBS.VoxelMesh.prototype.voxelData = {
/*CEWBS.VoxelMesh.prototype.voxelData = {
dimensions: [16,16,16],
voxels: null,
}*/

//Switch between the greedy mesher (faster) and the monotone mesher (more accurate)
COOBS.VoxelMesh.prototype.setMesher = function(type) {
CEWBS.VoxelMesh.prototype.setMesher = function(type) {
if(type == 'greedy') {
this.mesher = meshers.greedy;
} else if (type == 'monotone') {
Expand All @@ -36,7 +36,7 @@ COOBS.VoxelMesh.prototype.setMesher = function(type) {
}

//Set the voxel at x,y,z position, with the id metadata.
COOBS.VoxelMesh.prototype.setVoxelAt = function(x,y,z, metaData) {
CEWBS.VoxelMesh.prototype.setVoxelAt = function(x,y,z, metaData) {
if(this.voxelData.voxels != null) {
if(Array.isArray(x)) {
this.voxelData.voxels[x[0]+(x[1]*this.voxelData.dimensions[0])+(x[2]*this.voxelData.dimensions[0]*this.voxelData.dimensions[1])] = y;
Expand All @@ -50,7 +50,7 @@ COOBS.VoxelMesh.prototype.setVoxelAt = function(x,y,z, metaData) {

//Set a collection of voxels at different positions. Each can have it's own id or use the group id.
//Useful for importing the non-raw export.
COOBS.VoxelMesh.prototype.setVoxelBatch = function(voxels, metaData) {
CEWBS.VoxelMesh.prototype.setVoxelBatch = function(voxels, metaData) {
for(var i = 0; i < voxels.length; i++) {
var voxel = voxels[i];
if(voxel.length < 4 && metaData != null) {
Expand All @@ -62,7 +62,7 @@ COOBS.VoxelMesh.prototype.setVoxelBatch = function(voxels, metaData) {
}

//Returns the voxel id at coordinates x,y,z.
COOBS.VoxelMesh.prototype.getVoxelAt = function(x,y,z) {
CEWBS.VoxelMesh.prototype.getVoxelAt = function(x,y,z) {
if(this.voxelData.voxels != null) {
return this.voxelData.voxels[x+(y*this.voxelData.dimensions[0])+(z*this.voxelData.dimensions[0]*this.voxelData.dimensions[1])];
} else {
Expand All @@ -75,18 +75,18 @@ COOBS.VoxelMesh.prototype.getVoxelAt = function(x,y,z) {
dimensions: [x,y,z]
voxels: [] // Length should be dimensions x*y*z
}*/
COOBS.VoxelMesh.prototype.setVoxelData = function(voxelData) {
CEWBS.VoxelMesh.prototype.setVoxelData = function(voxelData) {
this.voxelData = voxelData;
}

//Returns the entire voxel volume.
//Warning, this is dimension-dependant, so don't try to use it in a differently-sized volume. use exportVoxelData for that.
COOBS.VoxelMesh.prototype.getVoxelData = function() {
CEWBS.VoxelMesh.prototype.getVoxelData = function() {
return this.voxelData;
}

//Sets the dimensions of the voxel volume. Input should be ([x,y,z]);
COOBS.VoxelMesh.prototype.setDimensions = function(dims) {
CEWBS.VoxelMesh.prototype.setDimensions = function(dims) {
if (Array.isArray(dims) && dims.length == 3) {
if(this.voxelData == null) {
this.voxelData = {};
Expand All @@ -102,7 +102,7 @@ COOBS.VoxelMesh.prototype.setDimensions = function(dims) {
}

//Used to update the actual mesh after voxels have been set.
COOBS.VoxelMesh.prototype.updateMesh = function() {
CEWBS.VoxelMesh.prototype.updateMesh = function() {
var rawMesh = this.mesher(this.voxelData.voxels, this.voxelData.dimensions);

var positions = [];
Expand Down Expand Up @@ -150,7 +150,7 @@ COOBS.VoxelMesh.prototype.updateMesh = function() {

//Set the origin (pivot point) of the mesh to the center of the dimensions.
//If ignoreY is true, then the y axis will remain 0.
COOBS.VoxelMesh.prototype.originToCenterOfBounds = function(ignoreY) {
CEWBS.VoxelMesh.prototype.originToCenterOfBounds = function(ignoreY) {
var pivotX = -this.voxelData.dimensions[0]/2;
var pivotY = -this.voxelData.dimensions[1]/2;
var pivotZ = -this.voxelData.dimensions[2]/2;
Expand All @@ -163,7 +163,7 @@ COOBS.VoxelMesh.prototype.originToCenterOfBounds = function(ignoreY) {
}

//Sets the origin (pivot point) of the mesh.
COOBS.VoxelMesh.prototype.setPivot = function(pivotX, pivotY, pivotZ) {
CEWBS.VoxelMesh.prototype.setPivot = function(pivotX, pivotY, pivotZ) {
var pivot = BABYLON.Matrix.Translation(pivotX,pivotY,pivotZ);

this.setPivotMatrix(pivot);
Expand All @@ -179,7 +179,7 @@ format:
],
}
*/
COOBS.VoxelMesh.prototype.exportVoxelData = function(raw) {
CEWBS.VoxelMesh.prototype.exportVoxelData = function(raw) {
var convertedVoxels = [];
for (var i = 0; i < this.voxelData.voxels.length; i++) {
var voxel = this.voxelData.voxels[i];
Expand All @@ -194,7 +194,7 @@ COOBS.VoxelMesh.prototype.exportVoxelData = function(raw) {
}


COOBS.VoxelMesh.handlePick = function(pickResult) {
CEWBS.VoxelMesh.handlePick = function(pickResult) {
var mesh = pickResult.pickedMesh;
var point = pickResult.pickedPoint;

Expand Down Expand Up @@ -244,8 +244,8 @@ COOBS.VoxelMesh.handlePick = function(pickResult) {
}
}

if(!window.COOBS) {
module.exports = COOBS;
if(!window.CEWBS) {
module.exports = CEWBS;
}

},{"./meshers/greedy_tri.js":2,"./meshers/monotone.js":3}],2:[function(require,module,exports){
Expand Down
Loading

0 comments on commit e8bd249

Please sign in to comment.