From 056a53d03063db1b42ef94a1606cdba52cc0fbf7 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Sun, 7 Jan 2024 21:59:12 -0300 Subject: [PATCH] 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);