Skip to content

Commit

Permalink
fix for case when metadata component not set
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarr committed Oct 5, 2023
1 parent ecdc5b2 commit dc9f434
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,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);
Expand Down

0 comments on commit dc9f434

Please sign in to comment.