Skip to content

Commit

Permalink
Merge pull request #495 from 3DStreet/not-support-segment-or-variant-…
Browse files Browse the repository at this point in the history
…situation

Not support segment or variant situation
  • Loading branch information
kfarr authored Mar 7, 2024
2 parents 740f784 + 727a8ec commit 7d6bb94
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/aframe-street-component.js

Large diffs are not rendered by default.

31 changes: 27 additions & 4 deletions src/aframe-streetmix-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Orientation - default model orientation is "outbound" (away from camera)
var streetmixParsersTested = require('./tested/aframe-streetmix-parsers-tested');
var streetmixUtils = require('./tested/streetmix-utils');
var segmentsVariants = require('./segments-variants.json');

function cloneMixinAsChildren ({ objectMixinId = '', parentEl = null, step = 15, radius = 60, rotation = '0 0 0', positionXYString = '0 0', length = undefined, randomY = false }) {
for (let j = (radius * -1); j <= radius; j = j + step) {
Expand Down Expand Up @@ -373,11 +374,11 @@ function createDriveLaneElement (variantList, segmentWidthInMeters, streetLength
} else {
rotationY = rotationVariants[lineVariant];
}
/*

if (carType === 'pedestrian') {
return createSidewalkClonedVariants(segmentWidthInMeters, 'normal', streetLength, lineVariant, animated);
return createSidewalkClonedVariants(segmentWidthInMeters, 'normal', 0, streetLength, direction, animated);
}
*/

const driveLaneParentEl = document.createElement('a-entity');

if (variantList.length == 1) {
Expand Down Expand Up @@ -413,6 +414,10 @@ function createDriveLaneElement (variantList, segmentWidthInMeters, streetLength
}
};

// default drive-lane variant if selected variant (carType) is not supported
if (!carParams[carType]) {
carType = 'car';
}
function createCar (positionZ = undefined, carType = 'car') {
const params = carParams[carType];

Expand Down Expand Up @@ -448,6 +453,7 @@ function createDriveLaneElement (variantList, segmentWidthInMeters, streetLength
);
const randPlaces = allPlaces.slice(0, count);
const carSizeZ = (lineVariant == 'sideways' || lineVariant.includes('angled')) ? 'width' : 'length';

const carSizeValueZ = carParams[carType][carSizeZ];

randPlaces.forEach(randPositionZ => {
Expand Down Expand Up @@ -747,6 +753,20 @@ function createSeparatorElement (positionY, rotationY, mixinId, length, repeatCo
return segmentEl;
}

// show warning message if segment or variantString are not supported
function supportCheck (segmentType, segmentVariantString) {
if (segmentType == 'separator') return;
// variants supported in 3DStreet
const supportedVariants = segmentsVariants[segmentType];
if (!supportedVariants) {
STREET.notify.warningMessage(`The '${segmentType}' segment type is not yet supported in 3DStreet`);
console.log(`The '${segmentType}' segment type is not yet supported in 3DStreet`);
} else if (!supportedVariants.includes(segmentVariantString)) {
STREET.notify.warningMessage(`The '${segmentVariantString}' variant of segment '${segmentType}' is not yet supported in 3DStreet`);
console.log(`The '${segmentVariantString}' variant of segment '${segmentType}' is not yet supported in 3DStreet`);
}
}

// OLD: takes a street's `segments` (array) from streetmix and a `streetElementId` (string) and places objects to make up a street with all segments
// NEW: takes a `segments` (array) from streetmix and return an element and its children which represent the 3D street scene
function processSegments (segments, showStriping, length, globalAnimated, showVehicles) {
Expand Down Expand Up @@ -780,6 +800,9 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
// get variantString
var variantList = segments[i].variantString.split('|');

// show warning message if segment or variantString are not supported
supportCheck(segments[i].type, segments[i].variantString);

// elevation property from streetmix segment
const elevation = segments[i].elevation;

Expand Down Expand Up @@ -933,7 +956,7 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
} else if (segments[i].type === 'drive-lane') {
const isAnimated = (variantList[2] === 'animated') || globalAnimated;
const count = getRandomIntInclusive(2, 3);
const carStep = 7;
const carStep = 7.3;
segmentParentEl.append(createDriveLaneElement(variantList, segmentWidthInMeters, length, isAnimated, showVehicles, count, carStep));
} else if (segments[i].type === 'food-truck') {
groundMixinId = 'drive-lane';
Expand Down
27 changes: 27 additions & 0 deletions src/segments-variants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"sidewalk": ["empty", "sparse", "normal", "dense"],
"bus-lane": ["inbound|colored|typical", "outbound|colored|typical", "inbound|regular|typical", "outbound|regular|typical"],
"drive-lane": ["inbound|car","outbound|car", "inbound|truck","outbound|truck", "outbound|av", "inbound|av", "outbound|pedestrian", "inbound|pedestrian", "inbound|sharrow", "outbound|sharrow"],
"light-rail": ["inbound|regular", "inbound|colored", "inbound|grass", "outbound|regular", "outbound|colored", "outbound|grass"],
"streetcar": ["inbound|regular", "inbound|colored", "inbound|grass", "outbound|regular", "outbound|colored", "outbound|grass"],
"turn-lane": ["inbound|left", "inbound|right", "inbound|left-right-straight", "inbound|shared", "inbound|both", "inbound|left-straight", "inbound|right-straight", "inbound|straight", "outbound|left", "outbound|right", "outbound|left-right-straight", "outbound|shared", "outbound|both", "outbound|left-straight", "outbound|right-straight", "outbound|straight"],
"divider": ["buffer", "flowers", "planting-strip", "planter-box", "palm-tree", "big-tree", "bush", "dome", "bollard", "striped-buffer"],
"temporary": ["barricade", "traffic-cone", "jersey-barrier-plastic", "jersey-barrier-concrete"],
"food-truck": ["left", "right"],
"flex-zone": ["taxi|inbound|right", "taxi|inbound|left", "taxi|outbound|right", "taxi|outbound|left", "rideshare|outbound|right", "rideshare|outbound|right", "rideshare|inbound|right", "rideshare|inbound|left"],
"sidewalk-wayfinding": ["large"],
"sidewalk-bench": ["left", "right", "center"],
"sidewalk-bike-rack":["left|sidewalk-parallel", "right|sidewalk-parallel", "left|sidewalk", "right|sidewalk"],
"magic-carpet": ["aladdin"],
"outdoor-dining": ["empty"],
"parklet": ["left", "right"],
"bikeshare": ["left|road", "right|road", "left|sidewalk", "right|sidewalk"],
"utilities": ["left", "right"],
"sidewalk-tree": ["big", "palm-tree"],
"sidewalk-lamp": ["right|modern","both|modern", "left|modern", "right|traditional", "both|traditional", "left|traditional", "right|pride", "both|pride", "left|pride"],
"transit-shelter": ["left|street-level", "right|street-level", "right|light-rail", "left|light-rail"],
"brt-station": ["center"],
"parking-lane": ["sideways|right", "sideways|left", "inbound|right", "inbound|left", "outbound|left", "outbound|right", "angled-front-left|left", "angled-front-right|left", "angled-rear-left|left", "angled-rear-right|left", "angled-front-left|right", "angled-front-right|right", "angled-rear-left|right", "angled-rear-right|right"],
"bike-lane": ["inbound|green|sidewalk", "inbound|green|road", "outbound|green|sidewalk", "outbound|green|road", "inbound|regular|sidewalk", "inbound|regular|road", "outbound|regular|sidewalk", "outbound|regular|road", "inbound|red|sidewalk", "inbound|red|road", "outbound|red|sidewalk", "outbound|red|road"],
"scooter": ["inbound|regular", "inbound|green", "inbound|red", "outbound|regular", "outbound|green", "outbound|red"]
}
2 changes: 1 addition & 1 deletion src/tested/aframe-streetmix-parsers-tested.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function isSidewalk (string) { // eslint-disable-line no-unused-vars
// https://streetmix.net/api/v1/streets/3f1a9810-0a8f-11ea-adff-7fe273b63f1d
// return if string sidewalk* or "scooter-drop-zone", bikeshare, flex-zone-curb, transit-shelter
const sidewalkList = ['utilities', 'scooter-drop-zone', 'bikeshare', 'flex-zone-curb', 'transit-shelter', 'brt-station'];
const sidewalkList = ['utilities', 'scooter-drop-zone', 'bikeshare', 'flex-zone-curb', 'transit-shelter', 'brt-station', 'street-vendor'];
return string.startsWith('sidewalk') || sidewalkList.includes(string);
}
module.exports.isSidewalk = isSidewalk;
Expand Down

0 comments on commit 7d6bb94

Please sign in to comment.