Skip to content

Commit

Permalink
Merge pull request #448 from 3DStreet/recreating-street-parent-element
Browse files Browse the repository at this point in the history
remove parent elements if they exists before add new ones
  • Loading branch information
kfarr authored Jan 15, 2024
2 parents 938e55f + c4104fe commit cb12595
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ AFRAME.registerComponent('street', {
}

const streetmixSegments = JSON.parse(data.JSON);

// 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);

Expand Down

0 comments on commit cb12595

Please sign in to comment.