From 1f89010be465bdec7b2643cb2359811720933c11 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Fri, 22 Sep 2023 19:56:44 -0300 Subject: [PATCH 1/4] dont save street propery in JSON --- src/json-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/json-utils.js b/src/json-utils.js index 1b48bb698..abb57a916 100644 --- a/src/json-utils.js +++ b/src/json-utils.js @@ -133,7 +133,7 @@ const removeProps = { normalMap: {}, 'set-loader-from-hash': '*', 'create-from-json': '*', - street: { JSON: '*' } + street: '*' }; // a list of component_name:new_component_name pairs to rename in JSON string const renameProps = { From 6889c91bc72ba7825a2b02a0957d38a46dbf3412 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Wed, 11 Oct 2023 17:42:13 -0300 Subject: [PATCH 2/4] prevent reload street prevent reload street after change properties of street component --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index 87aae1a02..5ffdba187 100644 --- a/src/index.js +++ b/src/index.js @@ -34,7 +34,11 @@ AFRAME.registerComponent('street', { } const streetmixSegments = JSON.parse(data.JSON); + const streetParent = this.el.querySelector('.street-parent'); const streetEl = streetmixParsers.processSegments(streetmixSegments.streetmixSegmentsFeet, data.showStriping, data.length, data.globalAnimated, data.showVehicles); + if (streetParent) { + streetParent.remove(); + } this.el.append(streetEl); if (data.left || data.right) { From 37c527629a757f90cd6ea2a237ffbe24c6efc29f Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Wed, 11 Oct 2023 21:09:26 -0300 Subject: [PATCH 3/4] dont save listed properties in JSON --- src/json-utils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/json-utils.js b/src/json-utils.js index abb57a916..286e907f1 100644 --- a/src/json-utils.js +++ b/src/json-utils.js @@ -133,7 +133,7 @@ const removeProps = { normalMap: {}, 'set-loader-from-hash': '*', 'create-from-json': '*', - street: '*' + street: {JSON: '*'} }; // a list of component_name:new_component_name pairs to rename in JSON string const renameProps = { @@ -151,15 +151,15 @@ function filterJSONstreet(removeProps, renameProps, streetJSON) { } let stringJSON = JSON.stringify(streetJSON, function replacer(key, value) { + const compAttributes = AFRAME.utils.styleParser.parse(value); for (var removeKey in removeProps) { // check for removing components if (key === removeKey) { const removeVal = removeProps[removeKey]; // check for deleting component's attribute if (typeof removeVal === 'object' && !isEmpty(removeVal)) { - // remove attribute in component - const compAttributes = value; + // remove attribute in component const attrNames = Object.keys(removeVal); for (var attrName of attrNames) { const attrVal = removeVal[attrName]; @@ -167,9 +167,10 @@ function filterJSONstreet(removeProps, renameProps, streetJSON) { Object.prototype.hasOwnProperty.call(compAttributes, attrName) && removeValueCheck(attrVal, compAttributes[attrName]) ) { - delete value[attrName]; + delete compAttributes[attrName]; } } + } // for other cases if (removeValueCheck(removeVal, value)) { @@ -178,7 +179,7 @@ function filterJSONstreet(removeProps, renameProps, streetJSON) { } } - return value; + return compAttributes; }); // rename components for (var renameKey in renameProps) { From 016217bab5789e6fa56bead2a270672d56ec9dfd Mon Sep 17 00:00:00 2001 From: Kieran Farr Date: Mon, 30 Oct 2023 15:01:03 -0700 Subject: [PATCH 4/4] remove street parent changes --- src/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 5ffdba187..feb8cf5b1 100644 --- a/src/index.js +++ b/src/index.js @@ -34,11 +34,7 @@ AFRAME.registerComponent('street', { } const streetmixSegments = JSON.parse(data.JSON); - const streetParent = this.el.querySelector('.street-parent'); const streetEl = streetmixParsers.processSegments(streetmixSegments.streetmixSegmentsFeet, data.showStriping, data.length, data.globalAnimated, data.showVehicles); - if (streetParent) { - streetParent.remove(); - } this.el.append(streetEl); if (data.left || data.right) { @@ -94,7 +90,10 @@ AFRAME.registerComponent('streetmix-loader', { console.log('streetmixName', streetmixName); el.setAttribute('streetmix-loader', 'name', streetmixName); - const currentSceneTitle = AFRAME.scenes[0].getAttribute('metadata').sceneTitle; + let currentSceneTitle; + if (AFRAME.scenes[0] && AFRAME.scenes[0].getAttribute('metadata')) { + currentSceneTitle = AFRAME.scenes[0].getAttribute('metadata').sceneTitle; + } if (!currentSceneTitle) { // only set title from streetmix if none exists AFRAME.scenes[0].setAttribute('metadata', 'sceneTitle', streetmixName); console.log('therefore setting metadata sceneTitle as streetmixName', streetmixName);