From 056a53d03063db1b42ef94a1606cdba52cc0fbf7 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Sun, 7 Jan 2024 21:59:12 -0300 Subject: [PATCH 1/3] remove street-parent element if it exists --- src/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.js b/src/index.js index bddee277e..6ed3aa770 100644 --- a/src/index.js +++ b/src/index.js @@ -35,6 +35,14 @@ AFRAME.registerComponent('street', { } const streetmixSegments = JSON.parse(data.JSON); + + // remove .street-parent element, if it exists, with old scene elements. + // Because it will be created next in the processSegments function + const streetParent = this.el.querySelector('.street-parent'); + if (streetParent) { + streetParent.remove(); + } + const streetEl = streetmixParsers.processSegments(streetmixSegments.streetmixSegmentsFeet, data.showStriping, data.length, data.globalAnimated, data.showVehicles); this.el.append(streetEl); From 719cd2c91825c4605e9ad7accea486f2831d3a75 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Sun, 7 Jan 2024 22:10:01 -0300 Subject: [PATCH 2/3] remove buildings-parent element if it exists --- src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6ed3aa770..04d645b67 100644 --- a/src/index.js +++ b/src/index.js @@ -36,12 +36,16 @@ AFRAME.registerComponent('street', { const streetmixSegments = JSON.parse(data.JSON); - // remove .street-parent element, if it exists, with old scene elements. - // Because it will be created next in the processSegments function + // 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 const streetParent = this.el.querySelector('.street-parent'); if (streetParent) { streetParent.remove(); } + const buildingParent = this.el.querySelector('buildings-parent'); + if (buildingParent) { + buildingParent.remove(); + } const streetEl = streetmixParsers.processSegments(streetmixSegments.streetmixSegmentsFeet, data.showStriping, data.length, data.globalAnimated, data.showVehicles); this.el.append(streetEl); From c4104fec3a83461f453f751e3324a2f9c19a2546 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Mon, 8 Jan 2024 14:32:57 -0300 Subject: [PATCH 3/3] fix selector name for .buildings-parent --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 04d645b67..696209e83 100644 --- a/src/index.js +++ b/src/index.js @@ -42,7 +42,7 @@ AFRAME.registerComponent('street', { if (streetParent) { streetParent.remove(); } - const buildingParent = this.el.querySelector('buildings-parent'); + const buildingParent = this.el.querySelector('.buildings-parent'); if (buildingParent) { buildingParent.remove(); }