Just added one more parameter to tile()
function - dungeonMap
, and then inside this function just do:
var hasTop = row - 1 < 0 ? true : dungeonMap.getTile ( row - 1, column ).getGlyph()._character !== char;
var hasBottom = row + 1 == dungeonMap._width ? true : dungeonMap.getTile ( row + 1, column ).getGlyph()._character !== char;
var hasLeft = column - 1 < 0 ? true : dungeonMap.getTile ( row, column - 1 ).getGlyph()._character !== char;
var hasRight = column + 1 == dungeonMap._height ? true : dungeonMap.getTile ( row, column + 1 ).getGlyph()._character !== char;
var geometry = new THREE.BoxBufferGeometry ();
var index = [];
if (hasRight) index.push(0, 2, 1, 2, 3, 1);
if (hasLeft) {index.push(4, 6, 5, 6, 7, 5);}
index.push(8, 10, 9, 10, 11, 9, 12, 14, 13, 14, 15, 13);
if (hasBottom) {index.push(16, 18, 17, 18, 19, 17);}
if (hasTop) {index.push(20, 22, 21, 22, 23, 21);}
geometry.setIndex(index);
Can’t say it’s something elegant. At least it does what it intended to
The trick with index is just to know how the box buffer geometry created under the hood: