Skip to content

Commit

Permalink
use geometry width for making boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarr committed Nov 7, 2023
1 parent 49516ed commit e7e5e5f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/aframe-streetmix-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e7e5e5f

Please sign in to comment.