diff --git a/src/assets/avatars/BotDom_Avatar.glb b/src/assets/avatars/BotDom_Avatar.glb new file mode 100644 index 0000000000000000000000000000000000000000..9c72e3d2fc170d6b0782d741eca441a62780daad Binary files /dev/null and b/src/assets/avatars/BotDom_Avatar.glb differ diff --git a/src/components/player-info.js b/src/components/player-info.js new file mode 100644 index 0000000000000000000000000000000000000000..717b1d2a96336f38ced2ce511b68b12f8acdcddf --- /dev/null +++ b/src/components/player-info.js @@ -0,0 +1,32 @@ +AFRAME.registerComponent("player-info", { + schema: { + displayName: { type: "string" }, + avatar: { type: "string" } + }, + init() { + this.applyProperties = this.applyProperties.bind(this); + }, + play() { + this.el.addEventListener("model-loaded", this.applyProperties); + }, + pause() { + this.el.removeEventListener("model-loaded", this.applyProperties); + }, + update(oldProps) { + this.applyProperties(); + }, + applyProperties() { + const nametagEl = this.el.querySelector(".nametag"); + console.log("updating properties", this.data, nametagEl); + if (this.data.displayName && nametagEl) { + nametagEl.setAttribute("text", { + value: this.data.displayName + }); + } + + const modelEl = this.el.querySelector(".model"); + if (this.data.avatar && modelEl) { + modelEl.setAttribute("src", this.data.avatar); + } + } +});