Skip to content

Commit

Permalink
Merge pull request #302 from 3DStreet/regression-parking-T
Browse files Browse the repository at this point in the history
return parking-t mixin
  • Loading branch information
kfarr authored Jun 20, 2023
2 parents f3ddb9a + 7449772 commit 3414505
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
38 changes: 32 additions & 6 deletions src/aframe-streetmix-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ function cloneMixinAsChildren ({ objectMixinId = '', parentEl = null, step = 15,
placedObjectEl.setAttribute('mixin', objectMixinId);
placedObjectEl.setAttribute('class', objectMixinId);
placedObjectEl.setAttribute('position', positionXYString + ' ' + j);

if (length) {
placedObjectEl.addEventListener('loaded', (evt) => {
evt.target.setAttribute('geometry', 'height', length);
evt.target.setAttribute('atlas-uvs', 'column');
evt.target.setAttribute('atlas-uvs', 'c', 1);
});
}

Expand Down Expand Up @@ -1016,23 +1017,48 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
let reusableObjectStencilsParentEl;

groundMixinId = 'bright-lane';
let parkingMixin = 'stencils parking-t';

const carCount = 5;
const carStep = ((variantList[0] == 'sideways') || variantList[0].includes('angled')) ? 3 : 6;
const clonedStencilRadius = length / 2 - carStep;
let carStep = 6;

const rotationVars = {
'outbound': 90,
'inbound': 90,
'sideways': 0,
'angled-front-left': 30,
'angled-front-right': -30,
'angled-rear-left': -30,
'angled-rear-right': 30
};
const markingsRotZ = (variantList[0].includes('angled')) ? rotationVars[variantList[0]] : '0';
let markingsRotZ = rotationVars[variantList[0]];
let markingLength;

// calculate position X and rotation Z for T-markings
let markingPosX = segmentWidthInMeters / 2;
if (markingsRotZ == 90 && variantList[1] == 'right') {
markingsRotZ = -90;
markingPosX = -markingPosX + 0.75;
} else {
markingPosX = markingPosX - 0.75;
}

if ((variantList[0] == 'sideways') || variantList[0].includes('angled')) {
carStep = 3;
markingLength = segmentWidthInMeters;
markingPosX = 0;
parkingMixin = 'markings solid-stripe';
}
markingPosXY = markingPosX + ' 0';
const clonedStencilRadius = length / 2 - carStep;

segmentParentEl.append(createDriveLaneElement([...variantList, 'car'], positionX, segmentWidthInMeters, length, false, showVehicles, carCount, carStep));
if (variantList[1] === 'left') {
reusableObjectStencilsParentEl = createStencilsParentElement((positionX) + ' 0.015 0');
cloneMixinAsChildren({ objectMixinId: 'markings solid-stripe', parentEl: reusableObjectStencilsParentEl, rotation: '-90 ' + '90 ' + markingsRotZ, length: segmentWidthInMeters, step: carStep, radius: clonedStencilRadius });
cloneMixinAsChildren({ objectMixinId: parkingMixin, parentEl: reusableObjectStencilsParentEl, positionXYString: markingPosXY, rotation: '-90 ' + '90 ' + markingsRotZ, length: markingLength, step: carStep, radius: clonedStencilRadius });
} else {
reusableObjectStencilsParentEl = createStencilsParentElement((positionX) + ' 0.015 0');
cloneMixinAsChildren({ objectMixinId: 'markings solid-stripe', parentEl: reusableObjectStencilsParentEl, rotation: '-90 ' + '90 ' + markingsRotZ, length: segmentWidthInMeters, step: carStep, radius: clonedStencilRadius });
cloneMixinAsChildren({ objectMixinId: parkingMixin, parentEl: reusableObjectStencilsParentEl, positionXYString: markingPosXY, rotation: '-90 ' + '90 ' + markingsRotZ, length: markingLength, step: carStep, radius: clonedStencilRadius });
}
// add the stencils to the segment parent
segmentParentEl.append(reusableObjectStencilsParentEl);
Expand Down
6 changes: 3 additions & 3 deletions src/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ function buildAssetHTML (assetUrl, categories) {
<!-- lane separator markings -->
<img id="markings-atlas" src="${assetUrl}materials/lane-markings-atlas_1024.png" crossorigin="anonymous" />
<a-mixin id="markings" anisotropy atlas-uvs="totalRows: 1; totalColumns: 8; row: 1" scale="1 1 1" material="src: #markings-atlas;alphaTest: 0;transparent:true;repeat:1 25;" geometry="primitive: plane; buffer: false; skipCache: true; width:0.2; height:150;"></a-mixin>
<a-mixin id="solid-stripe" atlas-uvs="column: 3"></a-mixin>
<a-mixin id="dashed-stripe" atlas-uvs="column: 4"></a-mixin>
<a-mixin id="solid-stripe" atlas-uvs="column: 3; row: 1" material="repeat:1 5;"></a-mixin>
<a-mixin id="dashed-stripe" atlas-uvs="column: 4; row: 1"></a-mixin>
<a-mixin id="short-dashed-stripe" atlas-uvs="column: 4" material="repeat:1 50;"></a-mixin>
<a-mixin id="solid-doubleyellow" atlas-uvs="totalColumns: 4; column: 3" geometry="width: 0.5"></a-mixin>
<a-mixin id="solid-dashed" atlas-uvs="totalColumns: 4; column: 2" geometry="width: 0.4"></a-mixin>
Expand All @@ -154,7 +154,7 @@ function buildAssetHTML (assetUrl, categories) {
stencils: `
<!-- stencil markings -->
<img id="stencils-atlas" src="${assetUrl}materials/stencils-atlas_2048.png" crossorigin="anonymous" />
<a-mixin id="stencils" anisotropy atlas-uvs="totalRows: 4; totalColumns: 4" scale="2 2 2" material="src: #stencils-atlas;alphaTest: 0;transparent:true;" geometry="primitive: plane; buffer: false; skipCache: true"></a-mixin>
<a-mixin id="stencils" anisotropy atlas-uvs="totalRows: 4; totalColumns: 4" scale="2 2 2" material="src: #stencils-atlas;alphaTest: 0;transparent:true;" geometry="primitive: plane; buffer: false; skipCache: true;"></a-mixin>
<a-mixin id="right" atlas-uvs="column: 3; row: 2"></a-mixin>
<a-mixin id="left" atlas-uvs="column: 3; row: 3"></a-mixin>
<a-mixin id="both" atlas-uvs="column: 2; row: 1"></a-mixin>
Expand Down

0 comments on commit 3414505

Please sign in to comment.