Skip to content

Commit

Permalink
Merge branch 'main' into wheel-animation
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarr authored Oct 16, 2022
2 parents 2fbbf19 + a871313 commit e844ea8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# How to contribute to 3DStreet

We welcome community contributions to 3dstreet.

## Instructions
* fork the repo
* make your contribution
* make sure to run lint and test
--- `npm run lint` - you want no errors. You can try `npm run lint:fix` to automatically fix errors. sometimes you need to manually fix the errors
--- `npm run test` - you want all passing or pending, no failures. See below for how to handle test failures
* If linting and tests all pass, then create a pull request to merge into main 3dstreet repo with a description of the changes and a link to an associated issue if any.
* Notify us on the 3dstreet discord if you don't hear a reply within a few days or want a faster review

### If failed test:
* Either change your code so that the test passes once again, or
* You might need to update the tests

### About 3dstreet test

A small portion of 3dstreet code is tested. All of this code lives in this directory [/src/tested/](https://github.com/3DStreet/3dstreet/tree/main/src/tested)

When running `npm run test` it uses tests located in [this directory /test](https://github.com/3DStreet/3dstreet/tree/main/test).

If you have made changes to code that has test coverage, you will need to update the corresponding test in that directory.

## License for contributed works
3DStreet license information can be found here: [LICENSE](https://github.com/3DStreet/3dstreet/blob/main/LICENSE)

We follow the GitHub terms of service for assigning your code the same license of this repository.
Those terms are pasted here for convenience, [here is a direct link to GitHub's terms](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#6-contributions-under-repository-license
).

> Whenever you make a contribution to a repository containing notice of a license, you license your contribution under the same terms, and you agree that you have the right to license your contribution under those terms. If you have a separate agreement to license your contributions under different terms, such as a contributor license agreement, that agreement will supersede.
> Isn't this just how it works already? Yep. This is widely accepted as the norm in the open-source community; it's commonly referred to by the shorthand "inbound=outbound". We're just making it explicit.
2 changes: 1 addition & 1 deletion dist/aframe-street-component.js

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions src/aframe-streetmix-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,19 @@ function createCenteredStreetElement (segments) {
return streetEl;
}

function createSegmentElement (scaleX, positionX, positionY, rotationY, mixinId, length) {
function createSegmentElement (scaleX, positionX, positionY, rotationY, mixinId, length, repeatCount) {
var segmentEl = document.createElement('a-entity');
const scaleY = length / 150;

const scaleNew = scaleX + ' ' + scaleY + ' 1';
segmentEl.setAttribute('scale', scaleNew);
// segmentEl.setAttribute('geometry', 'height', length); // alternative to modifying scale
segmentEl.setAttribute('position', positionX + ' ' + positionY + ' 0');

if (repeatCount.length !== 0) {
segmentEl.setAttribute('material', `repeat: ${repeatCount[0]} ${repeatCount[1]}`);
}

segmentEl.setAttribute('rotation', '270 ' + rotationY + ' 0');
segmentEl.setAttribute('mixin', mixinId);
return segmentEl;
Expand Down Expand Up @@ -600,6 +605,9 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
// the A-Frame mixin ID is often identical to the corresponding streetmix segment "type" by design, let's start with that
var groundMixinId = segments[i].type;

// repeat value for material property - repeatCount[0] is x texture repeat and repeatCount[1] is y texture repeat
const repeatCount = [];

// look at segment type and variant(s) to determine specific cases
if (segments[i].type === 'drive-lane' && variantList[1] === 'sharrow') {
// make a parent entity for the stencils
Expand Down Expand Up @@ -662,12 +670,13 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
}
} else if (segments[i].type === 'divider' && variantList[0] === 'bollard') {
groundMixinId = 'divider';

// make some safehits
const safehitsParentEl = createSafehitsParentElement(positionX);
cloneMixinAsChildren({ objectMixinId: 'safehit', parentEl: safehitsParentEl, step: 4, radius: clonedObjectRadius });
// add the safehits to the segment parent
segmentParentEl.append(safehitsParentEl);
repeatCount[0] = 1;
repeatCount[1] = parseInt(length);
} else if (segments[i].type === 'divider' && variantList[0] === 'flowers') {
groundMixinId = 'grass';
segmentParentEl.append(createDividerVariant('flowers', positionX, clonedObjectRadius, 2.25));
Expand All @@ -693,6 +702,8 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
} else if (segments[i].type === 'divider' && variantList[0] === 'dome') {
groundMixinId = 'divider';
segmentParentEl.append(createDividerVariant('dome', positionX, clonedObjectRadius, 2.25));
repeatCount[0] = 1;
repeatCount[1] = parseInt(length);
} else if (segments[i].type === 'temporary' && variantList[0] === 'barricade') {
groundMixinId = 'drive-lane';
segmentParentEl.append(createClonedVariants('temporary-barricade', positionX, clonedObjectRadius, 2.25));
Expand Down Expand Up @@ -834,6 +845,9 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
groundMixinId = 'markings dashed-stripe';
positionY = positionY + 0.01; // make sure the lane marker is above the asphalt
scaleX = 1;
// for all markings material property repeat = "1 25". So every 150/25=6 meters put a dash
repeatCount[0] = 1;
repeatCount[1] = parseInt(length / 6);
} else if (segments[i].type === 'separator' && variantList[0] === 'solid') {
groundMixinId = 'markings solid-stripe';
positionY = positionY + 0.01; // make sure the lane marker is above the asphalt
Expand All @@ -846,6 +860,9 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
groundMixinId = 'markings yellow short-dashed-stripe';
positionY = positionY + 0.01; // make sure the lane marker is above the asphalt
scaleX = 1;
// for short-dashed-stripe every 3 meters put a dash
repeatCount[0] = 1;
repeatCount[1] = parseInt(length / 3);
} else if (segments[i].type === 'separator' && variantList[0] === 'soliddashedyellow') {
groundMixinId = 'markings yellow solid-dashed';
positionY = positionY + 0.01; // make sure the lane marker is above the asphalt
Expand All @@ -855,6 +872,8 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe
positionY = positionY + 0.01; // make sure the lane marker is above the asphalt
scaleX = 1;
rotationY = '180';
repeatCount[0] = 1;
repeatCount[1] = parseInt(length / 6);
} else if (segments[i].type === 'parking-lane') {
let reusableObjectStencilsParentEl;

Expand All @@ -873,10 +892,13 @@ function processSegments (segments, showStriping, length, globalAnimated, showVe

if (streetmixParsersTested.isSidewalk(segments[i].type)) {
groundMixinId = 'sidewalk';
repeatCount[0] = 1.5;
// every 2 meters repeat sidewalk texture
repeatCount[1] = parseInt(length / 2);
}

// add new object
segmentParentEl.append(createSegmentElement(scaleX, positionX, positionY, rotationY, groundMixinId, length));
segmentParentEl.append(createSegmentElement(scaleX, positionX, positionY, rotationY, groundMixinId, length, repeatCount));
// returns JSON output instead
// append the new surfaceElement to the segmentParentEl
streetParentEl.append(segmentParentEl);
Expand Down

0 comments on commit e844ea8

Please sign in to comment.