Skip to content

Commit

Permalink
Merge pull request #465 from 3DStreet/fix-saving-user-modified-texture
Browse files Browse the repository at this point in the history
Fix saving user modified texture
  • Loading branch information
kfarr authored Feb 23, 2024
2 parents 7b4c56b + 2e579fc commit 0436212
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/assets.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion src/json-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* version: 1.0 */

var STREET = {};
var assetsUrl;
STREET.utils = {};

function getSceneUuidFromURLHash () {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`;
}
Expand Down

0 comments on commit 0436212

Please sign in to comment.