From ca22c98fd3a737ed48138216c324ab886e9723b6 Mon Sep 17 00:00:00 2001 From: netpro2k <netpro2k@gmail.com> Date: Mon, 2 Jul 2018 14:09:23 -0700 Subject: [PATCH] Make remove-object-button its own file --- .../remove-networked-object-button.js | 21 +++++++++++++++++++ src/components/sticky-object.js | 19 ----------------- src/hub.html | 2 +- src/hub.js | 1 + 4 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 src/components/remove-networked-object-button.js diff --git a/src/components/remove-networked-object-button.js b/src/components/remove-networked-object-button.js new file mode 100644 index 000000000..ff9034357 --- /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 ee82bdbf6..9e9d8bff3 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 3d1eb5945..caa267388 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 6631d1200..12f6ccff2 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"; -- GitLab