Skip to content

Commit

Permalink
fix saving issue
Browse files Browse the repository at this point in the history
- saving car position. Fix issue
- prevent save/load streets twice
  • Loading branch information
Algorush committed Aug 2, 2023
1 parent 9e7ef92 commit 89d80fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/aframe-streetmix-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,13 @@ function createDriveLaneElement (variantList, positionX, segmentWidthInMeters, s
const params = carParams[carType];

const reusableObjectEl = document.createElement('a-entity');
reusableObjectEl.object3D.position.setX(positionX);
if (positionZ) {
reusableObjectEl.object3D.position.setZ(positionZ);
} else {
randomPosition(reusableObjectEl, 'z', streetLength, params['length']);

if (!positionZ) {
positionZ = randomPosition(reusableObjectEl, 'z', streetLength, params['length']);
}
reusableObjectEl.setAttribute('position', `${positionX} 0 ${positionZ}`);
reusableObjectEl.setAttribute('mixin', params['mixin']);
reusableObjectEl.object3D.rotation.set(0, THREE.MathUtils.degToRad(rotationY), 0);
reusableObjectEl.setAttribute('rotation', `0 ${rotationY} 0`);

if (animated) {
speed = 5; // meters per second
Expand Down
5 changes: 2 additions & 3 deletions src/json-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ function filterJSONstreet (removeProps, renameProps, streetJSON) {
});
// rename components
for (var renameKey in renameProps) {
const reKey = new RegExp(`"${renameKey}":`);
stringJSON = stringJSON.replace(reKey, `"${renameProps[renameKey]}":`);
const reKey = new RegExp(`"${renameKey}":`, 'g');
stringJSON = stringJSON.replaceAll(reKey, `"${renameProps[renameKey]}":`);
}
return stringJSON;
}
Expand Down Expand Up @@ -250,7 +250,6 @@ function getModifiedProperty (entity, componentName) {
// skip properties, if they exists in element's mixin
return null;
}

// If its single-property like position, rotation, etc
if (isSingleProperty(defaultData)) {
const defaultValue = defaultData.default;
Expand Down

0 comments on commit 89d80fb

Please sign in to comment.