From e7e5e5f68aeeb77682dae3ae76d00e646e3c9110 Mon Sep 17 00:00:00 2001 From: Kieran Farr Date: Mon, 6 Nov 2023 18:11:06 -0800 Subject: [PATCH] use geometry width for making boxes --- src/aframe-streetmix-parsers.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/aframe-streetmix-parsers.js b/src/aframe-streetmix-parsers.js index 9c728c3db..5d966ef91 100644 --- a/src/aframe-streetmix-parsers.js +++ b/src/aframe-streetmix-parsers.js @@ -694,24 +694,23 @@ function createCenteredStreetElement (segments) { return streetEl; } -function createSegmentElement (scaleX, positionY, rotationY, mixinId, length, repeatCount, elevation = 0) { +function createSegmentElement (segmentWidthInMeters, scaleX, positionY, rotationY, mixinId, length, repeatCount, elevation = 0) { var segmentEl = document.createElement('a-entity'); const scaleY = length / 150; const scalePlane = scaleX + ' ' + scaleY + ' 1'; - const scaleBox = scaleX + ' 1 1'; if (mixinId === 'sidewalk' || elevation === 1) { segmentEl.setAttribute('geometry', 'primitive', 'box'); segmentEl.setAttribute('geometry', 'height: 0.4'); segmentEl.setAttribute('geometry', 'depth', length); - segmentEl.setAttribute('scale', scaleBox); + segmentEl.setAttribute('geometry', 'width', segmentWidthInMeters); } else if (mixinId.match('lane')) { positionY -= 0.1; segmentEl.setAttribute('geometry', 'primitive', 'box'); segmentEl.setAttribute('geometry', 'height: 0.2'); segmentEl.setAttribute('geometry', 'depth', length); - segmentEl.setAttribute('scale', scaleBox); + segmentEl.setAttribute('geometry', 'width', segmentWidthInMeters); } else { // segmentEl.setAttribute('geometry', 'height', length); // alternative to modifying scale segmentEl.setAttribute('rotation', '270 ' + rotationY + ' 0'); @@ -1110,7 +1109,7 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe const elevation = segments[i].elevation; // add new object - segmentParentEl.append(createSegmentElement(scaleX, positionY, rotationY, groundMixinId, length, repeatCount, elevation)); + segmentParentEl.append(createSegmentElement(segmentWidthInMeters, scaleX, positionY, rotationY, groundMixinId, length, repeatCount, elevation)); // returns JSON output instead // append the new surfaceElement to the segmentParentEl streetParentEl.append(segmentParentEl);