diff --git a/src/components/menu-selected-challenge-image.js b/src/components/menu-selected-challenge-image.js
index e4049cd..be301f9 100644
--- a/src/components/menu-selected-challenge-image.js
+++ b/src/components/menu-selected-challenge-image.js
@@ -1,24 +1,27 @@
/**
- * Reuse images from the search results to not create another texture.
+ * Reuse images from the search result.
*/
AFRAME.registerComponent('menu-selected-challenge-image', {
+ dependencies: ['geometry', 'material'],
+
schema: {
- selectedChallengeId: {type: 'string'}
+ selectedChallengeIndex: {type: 'number'}
},
init: function () {
- this.searchResultEls = document.getElementById('searchResultList');
+ const el = this.el;
+ this.searchThumbnails = document.getElementById('searchThumbnailImages');
+ el.getObject3D('mesh').material.map = this.searchThumbnails.getObject3D('mesh').material.map;
+ el.getObject3D('mesh').material.needsUpdate = true;
},
update: function () {
const data = this.data;
const el = this.el;
- if (!data.selectedChallengeId) { return; }
+ if (data.selectedChallengeIndex === -1 || data.selectedChallengeIndex === '') { return; }
- const imageEl = this.searchResultEls
- .querySelector(`[data-id="${data.selectedChallengeId}"] .searchResultImage`);
- el.getObject3D('mesh').material.map = imageEl.getObject3D('mesh').material.map;
- el.getObject3D('mesh').material.needsUpdate = true;
+ // Update UVs.
+ el.setAttribute('atlas-uvs', 'row', data.selectedChallengeIndex + 1);
}
});
diff --git a/src/state/index.js b/src/state/index.js
index f7e35df..a8b28c1 100644
--- a/src/state/index.js
+++ b/src/state/index.js
@@ -48,7 +48,7 @@ AFRAME.registerState({
downloads: '',
downloadsText: '',
id: '',
- index: '',
+ index: -1,
image: '',
songName: '',
songSubName: ''
diff --git a/src/templates/dialogs.html b/src/templates/dialogs.html
index 61d4804..77b33e4 100644
--- a/src/templates/dialogs.html
+++ b/src/templates/dialogs.html
@@ -42,22 +42,17 @@
-
-
-
diff --git a/src/templates/menu.html b/src/templates/menu.html
index 932fac2..092d918 100644
--- a/src/templates/menu.html
+++ b/src/templates/menu.html
@@ -165,9 +165,10 @@
bind__visible="!!menuSelectedChallenge.id"
position="0.82 0 0.001">