Skip to content

Commit

Permalink
Fixed dimension issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Fechner authored and Florian Fechner committed Apr 15, 2018
1 parent d67d028 commit bd50d89
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions voxel-visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,29 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe
let height = data.value.Height.value;
let length = data.value.Length.value;

let dimension = Math.max(width, height, length);

let blockIds = data.value.Blocks.value;
let metaData = data.value.Data.value;

let blocks = new Array(dimension * dimension * dimension).fill({ id: 0, metaData: 0 });
let blocks = new Array(width * height * length).fill({ id: 0, metaData: 0 });

for(let x=0; x<width; x++)
{
for(let y=0; y<height; y++)
{
for(let z=0; z<length; z++)
{
let blockId = blockIds[x + y * length * width + z * width];
let blockMetaData = metaData[x + y * length * width + z * width];
let sourceIndex = (y * length + z) * width + x;
let destinationIndex = x + y * width + z * width * height;

let blockId = blockIds[sourceIndex];
let blockMetaData = metaData[sourceIndex];

blocks[x + y * dimension + z * dimension * dimension] = { id: this._charToUnsignedChar(blockId), metaData: blockMetaData };
blocks[destinationIndex] = { id: this._charToUnsignedChar(blockId), metaData: blockMetaData };
}
}
}

this.schematic = { width: dimension, height: dimension, depth: dimension, blocks : blocks };
this.schematic = { width: width, height: height, depth: length, blocks : blocks };
});
}
}
Expand Down

0 comments on commit bd50d89

Please sign in to comment.