diff --git a/src/aframe-streetmix-parsers.js b/src/aframe-streetmix-parsers.js index 364fd32f0..d3dd28ba1 100644 --- a/src/aframe-streetmix-parsers.js +++ b/src/aframe-streetmix-parsers.js @@ -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 diff --git a/src/json-utils.js b/src/json-utils.js index 9dfe52103..d9d41c280 100644 --- a/src/json-utils.js +++ b/src/json-utils.js @@ -171,8 +171,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; } @@ -252,7 +252,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;