diff --git a/src/components/pin-networked-object-button.js b/src/components/pin-networked-object-button.js new file mode 100644 index 0000000000000000000000000000000000000000..a522fbb51931449b39b604adf66e263e699c36bd --- /dev/null +++ b/src/components/pin-networked-object-button.js @@ -0,0 +1,20 @@ +AFRAME.registerComponent("pin-networked-object-button", { + init() { + this.scene = document.querySelector("a-scene"); + + this.onClick = () => { + this.targetEl.setAttribute("pinned", ""); + this.scene.emit("object_pinned", { el: 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/pinned.js b/src/components/pinned.js new file mode 100644 index 0000000000000000000000000000000000000000..225fd7208152199c0afc5cf285be3e4265c200f0 --- /dev/null +++ b/src/components/pinned.js @@ -0,0 +1,8 @@ +AFRAME.registerComponent("pinned", { + init() {}, + + update() { + console.log("Disabling"); + console.log(this.el); + } +}); diff --git a/src/hub.html b/src/hub.html index 991212013b04ae0f15a6fc413eebb6bd04ca4697..cda3976f09403f830a6c9c4e65e05874d6507070 100644 --- a/src/hub.html +++ b/src/hub.html @@ -164,10 +164,10 @@ activatable__decrease-scale="buttonStartEvents: scroll_left; buttonEndEvents: horizontal_scroll_release; activatedState: scaleDown;" > <a-entity class="action-buttons" visible-while-frozen> - <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 0.125 0.01"> </a-entity> - <a-entity text=" value:Pin; width:1.75; align:center;" text-raycast-hack position="0 0.125 0.02"></a-entity> + <a-entity mixin="rounded-text-button" pin-networked-object-button position="0 0.125 0.01"> </a-entity> + <a-entity text=" value:pin; width:1.75; align:center;" text-raycast-hack position="0 0.125 0.02"></a-entity> <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 -0.125 0.01"> </a-entity> - <a-entity text=" value:Remove; width:1.75; align:center;" text-raycast-hack position="0 -0.125 0.02"></a-entity> + <a-entity text=" value:remove; width:1.75; align:center;" text-raycast-hack position="0 -0.125 0.02"></a-entity> </a-entity> </a-entity> </template> @@ -200,7 +200,7 @@ ></a-sphere> <a-entity class="delete-button" visible-while-frozen> <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 0 0"> </a-entity> - <a-entity text=" value:Remove; width:2.5; align:center;" text-raycast-hack position="0 0 0.01"></a-entity> + <a-entity text=" value:remove; width:2.5; align:center;" text-raycast-hack position="0 0 0.01"></a-entity> </a-entity> </a-entity> </template> @@ -222,7 +222,7 @@ > <a-entity class="delete-button" visible-while-frozen> <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 0 0"> </a-entity> - <a-entity text=" value:Remove; width:2.5; align:center;" text-raycast-hack position="0 0 0.01"></a-entity> + <a-entity text=" value:remove; width:2.5; align:center;" text-raycast-hack position="0 0 0.01"></a-entity> </a-entity> </a-entity> </template> diff --git a/src/hub.js b/src/hub.js index 03b191d39c63e4d9cf72d18d8def26b413dd404e..64ab033dbfa30a965fbdf2a05ca7702c9f96a5e1 100644 --- a/src/hub.js +++ b/src/hub.js @@ -67,6 +67,8 @@ import "./components/pitch-yaw-rotator"; import "./components/input-configurator"; import "./components/auto-scale-cannon-physics-body"; import "./components/position-at-box-shape-border"; +import "./components/pinned"; +import "./components/pin-networked-object-button"; import "./components/remove-networked-object-button"; import "./components/destroy-at-extreme-distances"; import "./components/gamma-factor"; diff --git a/src/scene-entry-manager.js b/src/scene-entry-manager.js index b39159838952cb60917d471b4d31ce65f0569c3b..70a1ee73415215f4eea6ea9b690d0b2dcb5e766d 100644 --- a/src/scene-entry-manager.js +++ b/src/scene-entry-manager.js @@ -216,6 +216,11 @@ export default class SceneEntryManager { spawnMediaInfrontOfPlayer(e.detail, contentOrigin); }); + this.scene.addEventListener("object_pinned", e => { + console.log("pinned"); + console.log(e); + }); + this.scene.addEventListener("object_spawned", e => { this.hubChannel.sendObjectSpawnedEvent(e.detail.objectType); });