From f468f43267048912017ea8eaadf35afd4efe6165 Mon Sep 17 00:00:00 2001 From: deathcap Date: Sun, 23 Feb 2014 12:59:34 -0800 Subject: [PATCH] Accept transparent voxel list for transgreedy mesher in mesherExtraData Ref https://github.com/maxogden/voxel/issues/16 Requires deathcap/voxel-mesh@4bc4d2b2f3b5804367360ffd16d506349e1dab09 --- meshers/transgreedy.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/meshers/transgreedy.js b/meshers/transgreedy.js index 321a2e0..87ae7c6 100644 --- a/meshers/transgreedy.js +++ b/meshers/transgreedy.js @@ -21,13 +21,7 @@ function removeFlags(v) { return (v & kNoFlagsMask); } -function getType(voxels, offset) { - // return voxels[offset]; - var type = voxels[offset]; - return type | (type in kTransparentTypes ? kTransparentMask : 0); -} - -return function ohSoGreedyMesher(volume, dims) { +return function ohSoGreedyMesher(volume, dims, mesherExtraData) { var vertices = [], faces = [] , dimsX = dims[0] , dimsY = dims[1] @@ -35,6 +29,13 @@ return function ohSoGreedyMesher(volume, dims) { var tVertices = [], tFaces = [] + var transparentTypes = mesherExtraData ? (mesherExtraData.transparentTypes || {}) : {}; + var getType = function(voxels, offset) { + var type = voxels[offset]; + return type | (type in transparentTypes ? kTransparentMask : 0); + } + + //Sweep over 3-axes for(var d=0; d<3; ++d) { var i, j, k, l, w, W, h, n, c