Skip to content

Commit

Permalink
load models from catalog.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarr committed Nov 25, 2023
1 parent 2fca082 commit 61f58e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
<a-scene
xr-mode-ui="XRMode: ar"
renderer="colorManagement: true;"
load-catalog="source: #catalog"
>
<a-assets>
<a-asset-item id="catalog" src="catalog.json"></a-asset-item>
<!-- <img id="groundTexture" src="https://cdn.aframe.io/a-painter/images/floor.jpg" crossorigin="anonymous" /> -->
<!-- <img id="skyTexture" src="https://cdn.aframe.io/a-painter/images/sky.jpg" crossorigin="anonymous" /> -->
<audio id="click-ogg"
Expand Down
17 changes: 17 additions & 0 deletions src/app/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ function getModelPathFromState(state) {
return state.model.list[modelKey].dist;
}

/**
* Load models from catalog json
*/
AFRAME.registerComponent('load-catalog', {
schema: {
source: {type: 'selector'}
},
init: function () {
this.jsonCatalogData = JSON.parse(this.data.source.data);
console.log(this.jsonCatalogData)
for (let i = 0; i < this.jsonCatalogData.length; i++) {
const modelMetadataObject = this.jsonCatalogData[i];
AFRAME.scenes[0].emit('addModel', modelMetadataObject);
}
}
});

/**
* Set color for material based on current index from state
*/
Expand Down

0 comments on commit 61f58e2

Please sign in to comment.