diff --git a/src/behaviours/keyboard-dpad4.js b/src/behaviours/keyboard-dpad4.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/components/axis-dpad.js b/src/components/axis-dpad.js deleted file mode 100644 index b4ccef1298dd0ac434eba62138f7860b1da1b024..0000000000000000000000000000000000000000 --- a/src/components/axis-dpad.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @fileOverview - * Treats a pair of axes and a button as a dpad - * This is useful for Vive trackpad and Oculus Touch thumbstick - * - * @name axis-dpad.js - * @TODO allow use of thumbstick without press - * @TODO make axes configurable - */ - -import angleToDirection from "../utils"; - -AFRAME.registerComponent("axis-dpad", { - schema: { - centerZone: { default: 0.5 }, - moveEvents: { default: ["axismove"] }, - downEvents: { default: ["trackpaddown", "thumbstickdown"] }, - upEvents: { default: ["trackpadup", "thumbstickup"] } - }, - - init: function() { - this.onAxisMove = this.onAxisMove.bind(this); - this.onButtonPressed = this.onButtonPressed.bind(this); - this.lastPos = [0, 0]; - }, - - play: function() { - const { moveEvents, downEvents, upEvents } = this.data; - moveEvents.forEach(moveEvent => { - this.el.addEventListener(moveEvent, this.onAxisMove); - }); - downEvents.concat(upEvents).forEach(eventName => { - this.el.addEventListener(eventName, this.onButtonPressed); - }); - }, - - pause: function() { - const { moveEvents, downEvents, upEvents } = this.data; - moveEvents.forEach(moveEvent => { - this.el.removeEventListener(moveEvent, this.onAxisMove); - }); - downEvents.concat(upEvents).forEach(eventName => { - this.el.removeEventListener(eventName, this.onButtonPressed); - }); - }, - - onAxisMove: function(e) { - this.lastPos = e.detail.axis; - }, - - onButtonPressed: function(e) { - const [x, y] = this.lastPos; - const { upEvents, centerZone } = this.data; - const state = upEvents.includes(e.type) ? "up" : "down"; - const direction = - state === "up" && this.lastDirection // Always trigger the up event for the last down event - ? this.lastDirection - : x * x + y * y < centerZone * centerZone // If within center zone angle does not matter - ? "center" - : angleToDirection(Math.atan2(x, y)); - - const hand = e.detail.target.id === "left-hand" ? "left" : "right"; - this.el.emit(`${hand}dpad${direction}${state}`); - - if (state === "down") { - this.lastDirection = direction; - } else { - delete this.lastDirection; - } - } -}); diff --git a/src/components/dpad-as-axes.js b/src/components/dpad-as-axes.js deleted file mode 100644 index 1529552daaaa35f6f6c49f7d9fb26ea0140d151c..0000000000000000000000000000000000000000 --- a/src/components/dpad-as-axes.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -function DPadAsAnalog2D (el, buttonName){ - this.output = [0,0]; - el.addEventListener("dpad") -}; - - */ - -AFRAME.registerComponent("wasd-to-analog2d", { - schema: { - analog2dOutputAction: { default: "keyboard_dpad_axes" } - }, - - init: function() { - this.directionsAndAxes = { - north: [0, 1], - northeast: [1, 1], - east: [1, 0], - southeast: [1, -1], - south: [0, -1], - southwest: [-1, -1], - west: [-1, 0], - northwest: [-1, 1] - }; - this.onWasd = this.onWasd.bind(this); - }, - - play: function() { - this.addEventListener("wasd", onWasd); - }, - - pause: function() { - this.removeEventListener("wasd", onWasd); - }, - - onWasd: function(event) { - console.log(event); - }, - - emitAnalog2d: function(axes) {} -}); diff --git a/src/components/keyboard-dpad.js b/src/components/keyboard-dpad.js deleted file mode 100644 index 7ce1eb8d5e4629bbce486642e2efbd95b9cc58d6..0000000000000000000000000000000000000000 --- a/src/components/keyboard-dpad.js +++ /dev/null @@ -1,56 +0,0 @@ -/// Listens to four keyboard events, then emits dpad events. -AFRAME.registerComponent("keyboard-dpad", { - schema: { - north: { default: "w" }, - east: { default: "d" }, - south: { default: "s" }, - west: { default: "a" }, - dpadActionPrefix: { type: "string" } - }, - - init: function() { - this.onKeyPress = this.onKeyPress.bind(this); - this.onKeyUp = this.onKeyUp.bind(this); - this.keys = {}; - }, - - play: function() { - window.addEventListener("keypress", this.onKeyPress); - window.addEventListener("keyup", this.onKeyUp); - }, - - pause: function() { - window.remove("keypress", this.onKeyPress); - window.remove("keyup", this.onKeyUp); - }, - - tick: function(t, dt) { - const { north, east, south, west, dpadActionPrefix } = this.data; - var direction = ""; - direction += this.keys[north] ? "north" : ""; - direction += this.keys[south] ? "south" : ""; - direction += this.keys[east] ? "east" : ""; - direction += this.keys[west] ? "west" : ""; - if (direction !== "") { - this.el.emit(`${dpadActionPrefix}_${direction}`); - } - }, - - onKeyPress: function(event) { - const { north, east, south, west } = this.data; - for (var dir of [north, south, east, west]) { - if (event.key === dir) { - this.keys[dir] = true; - } - } - }, - - onKeyUp: function(event) { - const { north, east, south, west } = this.data; - for (var dir of [north, south, east, west]) { - if (event.key === dir) { - this.keys[dir] = false; - } - } - } -}); diff --git a/src/components/oculus-touch-controls-extended.js b/src/components/oculus-touch-controls-extended.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/components/split-axis-events.js b/src/components/split-axis-events.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/components/vive-controls-extended.js b/src/components/vive-controls-extended.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/room.js b/src/room.js index a1caf6ddabbab455a67bb5b23e3f12aa124cb9bb..db02dada5aac3fb03b9a5ed56f27a7f90b01c83f 100644 --- a/src/room.js +++ b/src/room.js @@ -13,7 +13,6 @@ AFRAME.registerComponent("animation-mixer", animationMixer); import { vive_trackpad_dpad4 } from "./behaviours/vive-trackpad-dpad4"; import { oculus_touch_joystick_dpad4 } from "./behaviours/oculus-touch-joystick-dpad4"; import { PressedMove } from "./activators/pressedmove"; -import "./behaviours/keyboard-dpad4"; import "./components/wasd-to-analog2d"; //Might be a behaviour or activator in the future import "./components/mute-mic";