diff --git a/src/components/remove-networked-object-button.js b/src/components/remove-networked-object-button.js new file mode 100644 index 0000000000000000000000000000000000000000..ff903435725101b1dff82b697be8e12d7832afcb --- /dev/null +++ b/src/components/remove-networked-object-button.js @@ -0,0 +1,21 @@ +AFRAME.registerComponent("remove-networked-object-button", { + init() { + this.onClick = () => { + // const texture = this.targetEl.getObject3D("mesh").material.map; + // console.log(texture); + // texture.image.src = ""; + this.targetEl.parentNode.removeChild(this.targetEl); + }; + NAF.utils.getNetworkedEntity(this.el).then(networkedEl => { + this.targetEl = networkedEl; + }); + }, + + play() { + this.el.addEventListener("click", this.onClick); + }, + + pause() { + this.el.removeEventListener("click", this.onClick); + } +}); diff --git a/src/components/sticky-object.js b/src/components/sticky-object.js index ee82bdbf65205d8b2e6f2d3b3afaef39e1cbe942..9e9d8bff32b729edc341d8d7fb424abbfc7e166f 100644 --- a/src/components/sticky-object.js +++ b/src/components/sticky-object.js @@ -1,23 +1,4 @@ /* global THREE, CANNON, AFRAME */ -AFRAME.registerComponent("remove-object-button", { - init() { - this.onClick = () => { - this.targetEl.parentNode.removeChild(this.targetEl); - }; - NAF.utils.getNetworkedEntity(this.el).then(networkedEl => { - this.targetEl = networkedEl; - }); - }, - - play() { - this.el.addEventListener("click", this.onClick); - }, - - pause() { - this.el.removeEventListener("click", this.onClick); - } -}); - AFRAME.registerComponent("sticky-object", { dependencies: ["body", "super-networked-interactable"], diff --git a/src/hub.html b/src/hub.html index 3d1eb594544eefa98ad90dbb0ce6b2a4566b1664..caa2673881aee6bd9ade75a5f2a5df1aca55bbb4 100644 --- a/src/hub.html +++ b/src/hub.html @@ -207,7 +207,7 @@ sticky-object="autoLockOnLoad: true; autoLockOnRelease: true;" > <a-entity visible-while-frozen> - <a-entity mixin="rounded-text-button" remove-object-button position="0 0 .08"> </a-entity> + <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 0 .08"> </a-entity> <a-entity text=" value:Delete; width:2.5; align:center;" text-raycast-hack position="0 0 0.09"></a-entity> </a-entity> </a-entity> diff --git a/src/hub.js b/src/hub.js index 6631d12006ca3d4dd7bcc434eda054adedf075e7..12f6ccff29a400f12cffca2f754fc0c67316e620 100644 --- a/src/hub.js +++ b/src/hub.js @@ -72,6 +72,7 @@ import "./components/input-configurator"; import "./components/sticky-object"; import "./components/auto-scale-cannon-physics-body"; import "./components/position-at-box-shape-border"; +import "./components/remove-networked-object-button"; import ReactDOM from "react-dom"; import React from "react";