Web Dev Solutions

Catalin Mititiuc

From cff0cc6dd6e244da9c35f620585598a4e396652b Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 3 Jul 2024 09:26:48 -0700 Subject: Make stairs visible on roof levels --- src/radial.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/radial.js') diff --git a/src/radial.js b/src/radial.js index 046b608..c6e52a6 100644 --- a/src/radial.js +++ b/src/radial.js @@ -413,7 +413,7 @@ function addElevationClass(element) { return el => element.classList.add(elevationClass(el)); } -function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) { +function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, features) { return buildings.reduce((acc, building) => { const buildingContainer = document.createElementNS(xmlns, 'g'); buildingContainer.classList.add(`building`); @@ -465,17 +465,19 @@ function drawBuildings(buildings, container, { q: pq, r: pr, s: ps }, furniture) if ((use.classList.contains('doors') || use.classList.contains('door-edges')) && !use.classList.contains('exits')) building.elevationLevels.slice(0, -1).forEach(addElevationClass(use)); - if (use.classList.contains('furniture')) - building.elevationLevels.slice(0, -1).forEach(addElevationClass(use)); - buildingStructure.appendChild(use); } - const furnitureEl = furniture && furniture.querySelector(`.${building.type} .furniture`); + const featuresEl = features && features.querySelector(`.${building.type}`); + + for (let child of [...featuresEl.children]) { + if (child.classList.contains('furniture')) + building.elevationLevels.slice(0, -1).forEach(addElevationClass(child)); + + if (child.classList.contains('stairs')) + building.elevationLevels.forEach(addElevationClass(child)); - if (furnitureEl) { - building.elevationLevels.slice(0, -1).forEach(addElevationClass(furnitureEl)); - buildingStructure.appendChild(furnitureEl); + buildingStructure.appendChild(child); } return acc; -- cgit v1.2.3