From 6304ffe5147f2f56a59b542b96d889e9ec58062e Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Sun, 28 Jan 2024 22:10:59 -0300 Subject: [PATCH 1/3] save src instead of id for external assets --- src/json-utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/json-utils.js b/src/json-utils.js index 05d471845..e3e09c8fb 100644 --- a/src/json-utils.js +++ b/src/json-utils.js @@ -137,8 +137,12 @@ function toPropString (propData) { return Object.entries(propData) .map(([key, value]) => { if (key == 'src') { - if (value.id) { + if (value.id && value.src.includes('assets.3dstreet.app')) { + // asset came from 3dstreet return `${key}: #${value.id}`; + } else if (value.src && !value.src.includes('assets.3dstreet.app')) { + // asset came from external sources + return `${key}: ${value.src}`; } else { return `${key}: ${value}`; } From d46c4231173021da89415f35ef83d39c90d346be Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Mon, 29 Jan 2024 14:09:02 -0300 Subject: [PATCH 2/3] always save assets url in the street-assets --- src/assets.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/assets.js b/src/assets.js index f59bbeb68..8f9b45580 100644 --- a/src/assets.js +++ b/src/assets.js @@ -1,7 +1,7 @@ /* global AFRAME, customElements */ function buildAssetHTML (assetUrl, categories) { - if (!assetUrl) assetUrl = 'https://assets.3dstreet.app/'; + //if (!assetUrl) assetUrl = 'https://assets.3dstreet.app/'; console.log('[street]', 'Using street assets from', assetUrl); const surfacesRoughness = 0.8; var assetsObj = { @@ -295,7 +295,12 @@ class StreetAssets extends AFRAME.ANode { const self = this; var categories = this.getAttribute('categories'); var assetUrl = this.getAttribute('url'); + if (!assetUrl) { + assetUrl = 'https://assets.3dstreet.app/'; + this.setAttribute('url', assetUrl); + } const assetsHTML = buildAssetHTML(assetUrl, categories); + this.insertAdjacentHTML('afterend', assetsHTML); AFRAME.ANode.prototype.load.call(self); From 2e579fcae797d516d7c9b64492c0e25d68118d5c Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Mon, 29 Jan 2024 15:00:19 -0300 Subject: [PATCH 3/3] get assetsUrl during saving JSON --- src/json-utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/json-utils.js b/src/json-utils.js index e3e09c8fb..d49e4de5f 100644 --- a/src/json-utils.js +++ b/src/json-utils.js @@ -2,6 +2,7 @@ /* version: 1.0 */ var STREET = {}; +var assetsUrl; STREET.utils = {}; function getSceneUuidFromURLHash () { @@ -43,6 +44,9 @@ function convertDOMElToObject (entity) { const referenceEntities = document.querySelector('#reference-layers'); const sceneEntities = [entity, environmentElement, referenceEntities]; + // get assets url address + assetsUrl = document.querySelector('street-assets').getAttribute('url'); + for (const entry of sceneEntities) { const entityData = getElementData(entry); if (entityData) { @@ -137,10 +141,10 @@ function toPropString (propData) { return Object.entries(propData) .map(([key, value]) => { if (key == 'src') { - if (value.id && value.src.includes('assets.3dstreet.app')) { + if (value.id && value.src.includes(assetsUrl)) { // asset came from 3dstreet return `${key}: #${value.id}`; - } else if (value.src && !value.src.includes('assets.3dstreet.app')) { + } else if (value.src && !value.src.includes(assetsUrl)) { // asset came from external sources return `${key}: ${value.src}`; } else {