building = function(svg, dime) {
const building = svg.append('g')
const h = height-dime.height-dime.y+10
const x = { left:dime.x-60, middle:dime.x, right:dime.x + 60 }
const y = { topTop:h-30, topMiddle:h, topBottom:h+30, bottomMiddle:h+dime.height, bottomBottom:h+dime.height+30 }
const z = { level1: y.topBottom+50 }
const colours = { top:'#000000', left:'#000000', right:'#000000' }
building.append('polygon').attr('points',
x.middle+', '+ y.topTop + ' '+
x.right+', '+ y.topMiddle + ' '+
x.middle+', '+ y.topBottom + ' '+
x.left +', '+ y.topMiddle
).attr('fill', colours.top)
.attr('stroke', '#FFFFFF')
.attr('stroke-width', 2)
const sides = ['left', 'right']
sides.forEach((side) =>
building.append('polygon').attr('points',
x.middle+','+y.topBottom+' '+
x[side]+','+y.topMiddle+' '+
x[side]+','+y.bottomMiddle+' '+
x.middle+','+y.bottomBottom
).attr('fill', colours[side])
.attr('stroke', '#FFFFFF')
.attr('stroke-width', 2)
)
const windowSpace = 50;
let windowCount = dime.height/windowSpace;
while(windowCount > 1) {
let top = h-40 + (windowSpace * windowCount)
building.append('polyline')
.attr('points', x.left+','+(top-9)+' '+x.middle+','+(top+21)+' '+x.right+','+(top-9))
.attr('stroke', '#FFFFFF')
.attr('fill', 'transparent')
.attr('stroke-width', 2)
.attr('opacity', 1)
--windowCount
}
if (dime.buildingId == dime.key){
var floorId = dime.floorId;
var tempLeftBottom = -floorId * windowSpace + y.bottomMiddle;
var tempLeftUp= -(floorId+1) * windowSpace + y.bottomMiddle;
var tempMiddleBottom = -floorId * windowSpace + y.bottomBottom;
var tempMiddleUp= -(floorId+1) * windowSpace + y.bottomBottom;
building.append('polygon').attr('points',
x.middle+', '+ tempMiddleBottom + ' '+
x.middle+', '+ tempMiddleUp + ' '+
x.left +', '+ tempLeftUp + ' '+
x.left +', '+ tempLeftBottom
).attr('fill', '#FFE4B5')
.attr('stroke', '#FFFFFF')
.attr('class','house')
.attr('stroke-width', 2);
building.append('polygon').attr('points',
x.middle+', '+ tempMiddleBottom + ' '+
x.middle+', '+ tempMiddleUp + ' '+
x.right +', '+ tempLeftUp + ' '+
x.right +', '+ tempLeftBottom
).attr('fill', '#FFE4B5')
.attr('stroke', '#FFFFFF')
.attr('class','house')
.attr('stroke-width', 2);
};
}