Skip to content
Snippets Groups Projects
Commit 57566dea authored by netpro2k's avatar netpro2k
Browse files

Merge branch 'feature/avatar-switching' of...

Merge branch 'feature/avatar-switching' of https://github.com/robertlong/social-vr-demo into feature/avatar-switching
parents a78b0729 78cba0ff
No related branches found
No related tags found
No related merge requests found
File added
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);
}
}
});
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