diff --git a/src/assets/avatars/BotDefault_Avatar_Unlit.glb b/src/assets/avatars/BotDefault_Avatar_Unlit.glb new file mode 100644 index 0000000000000000000000000000000000000000..ba33589d4c42fe6bf9756d5164f331e9830dab91 Binary files /dev/null and b/src/assets/avatars/BotDefault_Avatar_Unlit.glb differ diff --git a/src/assets/avatars/Bot_SkinnedWithAnim.glb b/src/assets/avatars/Bot_SkinnedWithAnim.glb deleted file mode 100644 index 192bbed19788cb4c5cb71a3f23da428173766948..0000000000000000000000000000000000000000 Binary files a/src/assets/avatars/Bot_SkinnedWithAnim.glb and /dev/null differ diff --git a/src/elements/a-gltf-entity.js b/src/elements/a-gltf-entity.js index ee59e3a24ead224a4095c69c70d2ea0da1c9cbd5..0a4bbe41e3c395bc72197323ca29057d12096e8e 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 246fd20bb5177fa7a655e2618edf22386c9d19d1..39c12a3be763a7062cfbeed83c3dea8eb01729ee 100644 --- a/src/room.html +++ b/src/room.html @@ -35,10 +35,11 @@ > <a-assets> - <a-asset-item id="bot-skinned-mesh" response-type="arraybuffer" src="./assets/avatars/Bot_SkinnedWithAnim.glb"></a-asset-item> <img id="unmuted" src="./assets/hud/unmuted.png" > <img id="muted" src="./assets/hud/muted.png" > <img id="avatar" src="./assets/hud/avatar.jpg" > + + <a-asset-item id="bot-skinned-mesh" response-type="arraybuffer" src="./assets/avatars/BotDefault_Avatar_Unlit.glb"></a-asset-item> <a-asset-item id="watch-model" response-type="arraybuffer" src="./assets/hud/watch.glb"></a-asset-item> <a-asset-item id="meeting-space1-mesh" response-type="arraybuffer" src="./assets/environments/MeetingSpace1_mesh.glb"></a-asset-item> @@ -79,9 +80,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 63259f83c0641971449ff2c8c3737559e44270a4..e2b4d275c37f2bb12d845f4862ec7709dbc7e5df 100644 --- a/src/room.js +++ b/src/room.js @@ -45,7 +45,7 @@ import "./systems/app-mode"; import "./elements/a-gltf-entity"; -import "./elements/a-gltf-entity"; +import "./gltf-component-mappings"; import { promptForName, getCookie, parseJwt } from "./utils/identity"; import registerNetworkSchemas from "./network-schemas";