diff --git a/src/assets/avatars/BotDefault_Avatar.glb b/src/assets/avatars/BotDefault_Avatar.glb index fea36f79201b45bc1cd4379c37b53f2de5557233..69b66c2954a64f17aa590790c50acfd0ee59c0c4 100644 Binary files a/src/assets/avatars/BotDefault_Avatar.glb and b/src/assets/avatars/BotDefault_Avatar.glb differ diff --git a/src/assets/avatars/BotDefault_Avatar_Unlit.glb b/src/assets/avatars/BotDefault_Avatar_Unlit.glb index 6e4b52771581f36009f7c642666c90b7ca9a845d..ba33589d4c42fe6bf9756d5164f331e9830dab91 100644 Binary files a/src/assets/avatars/BotDefault_Avatar_Unlit.glb and b/src/assets/avatars/BotDefault_Avatar_Unlit.glb differ diff --git a/src/elements/a-gltf-entity.js b/src/elements/a-gltf-entity.js index 8482dd7a78a14e4da287f0b0ad2de389f624821c..1335770ac9994794e32d257702c192802645ad1a 100644 --- a/src/elements/a-gltf-entity.js +++ b/src/elements/a-gltf-entity.js @@ -1,5 +1,24 @@ 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); }); diff --git a/src/gltf-component-mappings.js b/src/gltf-component-mappings.js new file mode 100644 index 0000000000000000000000000000000000000000..e73692a8ff9270985f3b533ff8bd1f8fdc0cb835 --- /dev/null +++ b/src/gltf-component-mappings.js @@ -0,0 +1,3 @@ +import "./elements/a-gltf-entity"; + +AFRAME.AGLTFEntity.registerComponent("scale-audio-feedback", "scale-audio-feedback"); diff --git a/src/room.html b/src/room.html index ec10608d38bf642b9fc23341533a182a6ba3525c..55c37488ab8061981692d14b203cf24314b641b7 100644 --- a/src/room.html +++ b/src/room.html @@ -74,9 +74,7 @@ <a-entity networked-audio-source networked-audio-analyser - scale-audio-feedback personal-space-invader - animation-mixer > </a-entity> </template> diff --git a/src/room.js b/src/room.js index 880ec88601cff14f737fcd972e25c2a40d29c7da..4c595b350a3e49a9cfe9b9226293fba29b1ec4b9 100644 --- a/src/room.js +++ b/src/room.js @@ -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();