Skip to content

Commit

Permalink
make work with url passed in hash
Browse files Browse the repository at this point in the history
use this url to test:

http://localhost:7001/streetplan.html#https://api.allorigins.win/raw?url=https://upd.streetplan.net/streets-3d-data/79303
  • Loading branch information
kfarr committed Apr 11, 2024
1 parent a043771 commit d44f098
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/components/streetplan-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ AFRAME.registerComponent('streetplan-loader', {
console.log('therefore setting metadata sceneTitle as streetplanName', streetplanName);
}

el.setAttribute('data-layer-name', 'Streetplan • ' + streetplanName);
el.setAttribute('data-layer-name', 'StreetPlan • ' + streetplanName);

if (data.showBuildings) {
el.setAttribute('street', 'right', streetData.rightBuildingVariant);
Expand All @@ -52,15 +52,15 @@ AFRAME.registerComponent('streetplan-loader', {
update: function (oldData) { // fired at start and at each subsequent change of any schema value
// This method may fire a few times when viewing a streetmix street in 3dstreet:
// First to find the proper path, once to actually load the street, and then subsequent updates such as street name
const that = this;
const data = this.data;
const el = this.el;

/* ***** debugging ***** */
setTimeout(()=> {
this.streetplanResponseParse(exampleJSON);
}, 1000);

return;
// /* ***** debugging ***** */
// setTimeout(()=> {
// this.streetplanResponseParse(exampleJSON);
// }, 1000);
// return;

// load from URL encoded Streetplan JSON
if (data.streetplanEncJSON) {
Expand All @@ -83,7 +83,7 @@ AFRAME.registerComponent('streetplan-loader', {
if (this.status >= 200 && this.status < 400) {
// Connection success
const streetplanResponseObject = JSON.parse(this.response);
this.streetplanResponseParse(streetplanResponseObject);
that.streetplanResponseParse(streetplanResponseObject);
} else {
// We reached our target server, but it returned an error
console.log('[streetplan-loader]', 'Loading Error: We reached the target server, but it returned an error');
Expand Down
6 changes: 3 additions & 3 deletions src/json-utils_1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,16 @@ AFRAME.registerComponent('set-loader-from-hash', {
'streetmixStreetURL',
streetURL
);
} else if (streetURL.startsWith('streetplanJSON:')) {
} else if (streetURL.includes('streetplan.net')) {
// load from Streetplan encoded JSON in URL
console.log(
'[set-loader-from-hash]',
'Set streetplan-loader streetplanEncJSON to',
'Set streetplan-loader streetplanAPIURL to',
streetURL
);
this.el.setAttribute(
'streetplan-loader',
'streetplanEncJSON',
'streetplanAPIURL',
streetURL
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion streetplan.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</a-assets>

<a-entity id="street-container" data-layer-name="3D Street Layers" data-layer-show-children>
<a-entity id="default-street" street streetplan-loader="streetplanAPIURL: https://upd.streetplan.net/streets-3d-data/79303" set-loader-from-hash></a-entity>
<a-entity id="default-street" street streetplan-loader="NOTstreetplanAPIURL: https://api.allorigins.win/raw?url=https://upd.streetplan.net/streets-3d-data/79303" set-loader-from-hash></a-entity>
</a-entity>

<a-entity id="reference-layers" data-layer-name="Reference Layers" data-layer-show-children></a-entity>
Expand Down

0 comments on commit d44f098

Please sign in to comment.