Skip to content
Snippets Groups Projects
Commit 3aa4356b authored by Robert Long's avatar Robert Long
Browse files

Merge master

parents 444f91e9 8e77089e
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
const GLTFCache = {};
AFRAME.AGLTFEntity = {
defaultInflator(el, componentName, componentData) {
if (AFRAME.components[componentName].multiple && Array.isArray(componentData)) {
for (let i = 0; i < componentData.length; i++) {
el.setAttribute(componentName + "__" + i, componentData[i]);
}
} else {
el.setAttribute(componentName, componentData);
}
},
registerComponent(componentKey, componentName, inflator) {
AFRAME.AGLTFEntity.components[componentKey] = {
inflator: inflator || AFRAME.AGLTFEntity.defaultInflator,
componentName
};
},
components: {}
};
// From https://gist.github.com/cdata/f2d7a6ccdec071839bc1954c32595e87
// Tracking glTF cloning here: https://github.com/mrdoob/three.js/issues/11573
function cloneGltf(gltf) {
......@@ -83,6 +102,20 @@ const inflateEntities = function(classPrefix, parentEl, node) {
el.setObject3D(node.type.toLowerCase(), node);
const entityComponents = node.userData.components;
if (entityComponents) {
for (const prop in entityComponents) {
if (entityComponents.hasOwnProperty(prop)) {
const { inflator, componentName } = AFRAME.AGLTFEntity.components[prop];
if (inflator) {
inflator(el, componentName, entityComponents[prop]);
}
}
}
}
children.forEach(childNode => {
inflateEntities(classPrefix, el, childNode);
});
......
import "./elements/a-gltf-entity";
AFRAME.AGLTFEntity.registerComponent("scale-audio-feedback", "scale-audio-feedback");
......@@ -74,9 +74,7 @@
<a-entity
networked-audio-source
networked-audio-analyser
scale-audio-feedback
personal-space-invader
animation-mixer
>
</a-entity>
</template>
......
......@@ -41,7 +41,7 @@ import "./components/spawn-controller";
import "./systems/personal-space-bubble";
import "./elements/a-gltf-entity";
import "./gltf-component-mappings";
const qs = queryString.parse(location.search);
const isMobile = AFRAME.utils.device.isMobile();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment