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); diff --git a/src/json-utils.js b/src/json-utils.js index 546954b3f..e72d13b06 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,8 +141,12 @@ function toPropString (propData) { return Object.entries(propData) .map(([key, value]) => { if (key == 'src') { - if (value.id) { + if (value.id && value.src.includes(assetsUrl)) { + // asset came from 3dstreet return `${key}: #${value.id}`; + } else if (value.src && !value.src.includes(assetsUrl)) { + // asset came from external sources + return `${key}: ${value.src}`; } else { return `${key}: ${value}`; }