From 8da4d8264005dcd6fbb4be89c090cde456fdde4b Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Mon, 29 Apr 2024 15:19:53 -0400 Subject: [PATCH] return the code needed to change the parameters of the street component --- src/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.js b/src/index.js index ed2e54dc7..6c533d2c2 100644 --- a/src/index.js +++ b/src/index.js @@ -38,6 +38,18 @@ AFRAME.registerComponent('street', { return; } + // remove .street-parent and .buildings-parent elements, if they exists, with old scene elements. + // Because they will be created next in the processSegments and processBuildings functions. + // this is also necessary when changing the parameters of the street component to reload the scene const streetParent = this.el.querySelector('.street-parent'); + const streetParent = this.el.querySelector('.street-parent'); + if (streetParent) { + streetParent.remove(); + } + const buildingParent = this.el.querySelector('.buildings-parent'); + if (buildingParent) { + buildingParent.remove(); + } + const streetmixSegments = JSON.parse(data.JSON); const streetEl = streetmixParsers.processSegments(streetmixSegments.streetmixSegmentsMetric, data.showStriping, data.length, data.globalAnimated, data.showVehicles);