Skip to content

Commit

Permalink
Change this.transparent data structure from array to dict to match tr…
Browse files Browse the repository at this point in the history
…ansgreedy mesher

Ref max-mapper/voxel#16
  • Loading branch information
deathcap committed Feb 23, 2014
1 parent 2e1db37 commit 7963475
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Texture(opts) {
this.THREE = this.game.THREE;
this.names = [];
this.materials = [];
this.transparents = [];
this.transparents = {};
this.artPacks = opts.artPacks;
if (!this.artPacks) throw new Error('voxel-texture-shader requires artPacks option');
this.loading = 0;
Expand Down Expand Up @@ -350,7 +350,7 @@ Texture.prototype.pack = function(name, done) {
if (typeof name === 'string') {
self.artPacks.getTextureImage(name, function(img) {
if (isTransparent(img)) {
self.transparents.push(name);
self.transparents[name] = true;
}
// repeat 2x2 for mipmap padding 4-tap trick
// TODO: replace with atlaspack padding, but changed to 2x2: https://github.com/deathcap/atlaspack/tree/tilepadamount
Expand Down Expand Up @@ -485,7 +485,7 @@ Texture.prototype.paint = function(mesh, materials) {
if (!atlasuv) return;

// If a transparent texture use transparent material
face.materialIndex = (self.transparents.indexOf(name) !== -1) ? 1 : 0;
face.materialIndex = self.transparents[name] ? 1 : 0;

// 0 -- 1
// | |
Expand Down

0 comments on commit 7963475

Please sign in to comment.