From 4f500805c481a0fb49936aa6d9bf9d81f67b62ef Mon Sep 17 00:00:00 2001 From: netpro2k <netpro2k@gmail.com> Date: Wed, 24 Oct 2018 19:14:43 -0700 Subject: [PATCH] readFrameValueAtPath -> get --- src/components/action-to-event.js | 2 +- src/components/camera-tool.js | 2 +- src/components/character-controller.js | 8 ++++---- src/components/cursor-controller.js | 6 +++--- src/components/hand-controls2.js | 8 ++++---- src/components/pinch-to-move.js | 2 +- src/components/pitch-yaw-rotator.js | 2 +- src/components/super-networked-interactable.js | 2 +- src/components/super-spawner.js | 4 ++-- src/components/tools/pen.js | 10 +++++----- src/systems/userinput/userinput.js | 2 +- src/systems/userinput/userinput.md | 6 +++--- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/components/action-to-event.js b/src/components/action-to-event.js index ee6f39744..8bcd22e43 100644 --- a/src/components/action-to-event.js +++ b/src/components/action-to-event.js @@ -8,7 +8,7 @@ AFRAME.registerComponent("action-to-event", { tick() { const userinput = AFRAME.scenes[0].systems.userinput; - if (userinput.readFrameValueAtPath(this.data.path)) { + if (userinput.get(this.data.path)) { this.el.emit(this.data.event); } } diff --git a/src/components/camera-tool.js b/src/components/camera-tool.js index eacfaf8f4..9882eb88f 100644 --- a/src/components/camera-tool.js +++ b/src/components/camera-tool.js @@ -110,7 +110,7 @@ AFRAME.registerComponent("camera-tool", { const grabber = this.el.components.grabbable.grabbers[0]; if (grabber && !!pathsMap[grabber.id]) { const paths = pathsMap[grabber.id]; - if (AFRAME.scenes[0].systems.userinput.readFrameValueAtPath(paths.takeSnapshot)) { + if (AFRAME.scenes[0].systems.userinput.get(paths.takeSnapshot)) { this.takeSnapshotNextTick = true; } } diff --git a/src/components/character-controller.js b/src/components/character-controller.js index 910123ba8..184164007 100644 --- a/src/components/character-controller.js +++ b/src/components/character-controller.js @@ -119,13 +119,13 @@ AFRAME.registerComponent("character-controller", { root.updateMatrix(); const userinput = AFRAME.scenes[0].systems.userinput; - if (userinput.readFrameValueAtPath(paths.actions.snapRotateLeft)) { + if (userinput.get(paths.actions.snapRotateLeft)) { this.snapRotateLeft(); } - if (userinput.readFrameValueAtPath(paths.actions.snapRotateRight)) { + if (userinput.get(paths.actions.snapRotateRight)) { this.snapRotateRight(); } - const acc = userinput.readFrameValueAtPath(paths.actions.characterAcceleration); + const acc = userinput.get(paths.actions.characterAcceleration); if (acc) { this.accelerationInput.set( this.accelerationInput.x + acc[0], @@ -145,7 +145,7 @@ AFRAME.registerComponent("character-controller", { this.updateVelocity(deltaSeconds); this.accelerationInput.set(0, 0, 0); - const boost = userinput.readFrameValueAtPath(paths.actions.boost) ? 2 : 1; + const boost = userinput.get(paths.actions.boost) ? 2 : 1; move.makeTranslation( this.velocity.x * distance * boost, this.velocity.y * distance * boost, diff --git a/src/components/cursor-controller.js b/src/components/cursor-controller.js index c5113dba8..1b095fc05 100644 --- a/src/components/cursor-controller.js +++ b/src/components/cursor-controller.js @@ -94,8 +94,8 @@ AFRAME.registerComponent("cursor-controller", { } const userinput = AFRAME.scenes[0].systems.userinput; - const cursorPose = userinput.readFrameValueAtPath(paths.actions.cursor.pose); - const rightHandPose = userinput.readFrameValueAtPath(paths.actions.rightHand.pose); + const cursorPose = userinput.get(paths.actions.cursor.pose); + const rightHandPose = userinput.get(paths.actions.rightHand.pose); this.data.cursor.object3D.visible = this.enabled && !!cursorPose; this.el.setAttribute("line", "visible", this.enabled && !!rightHandPose); @@ -119,7 +119,7 @@ AFRAME.registerComponent("cursor-controller", { const { cursor, near, far, camera, cursorColorHovered, cursorColorUnhovered } = this.data; - const cursorModDelta = userinput.readFrameValueAtPath(paths.actions.cursor.modDelta); + const cursorModDelta = userinput.get(paths.actions.cursor.modDelta); if (isGrabbing && cursorModDelta) { this.distance = THREE.Math.clamp(this.distance - cursorModDelta, near, far); } diff --git a/src/components/hand-controls2.js b/src/components/hand-controls2.js index 534f796c4..3a97888b1 100644 --- a/src/components/hand-controls2.js +++ b/src/components/hand-controls2.js @@ -106,10 +106,10 @@ AFRAME.registerComponent("hand-controls2", { const hand = this.data; const userinput = AFRAME.scenes[0].systems.userinput; const subpath = hand === "left" ? paths.actions.leftHand : paths.actions.rightHand; - const hasPose = userinput.readFrameValueAtPath(subpath.pose); - const thumb = userinput.readFrameValueAtPath(subpath.thumb); - const index = userinput.readFrameValueAtPath(subpath.index); - const middleRingPinky = userinput.readFrameValueAtPath(subpath.middleRingPinky); + const hasPose = userinput.get(subpath.pose); + const thumb = userinput.get(subpath.thumb); + const index = userinput.get(subpath.index); + const middleRingPinky = userinput.get(subpath.middleRingPinky); const pose = this.poseForFingers(thumb, index, middleRingPinky); if (pose !== this.pose) { this.el.emit("hand-pose", { previous: this.pose, current: pose }); diff --git a/src/components/pinch-to-move.js b/src/components/pinch-to-move.js index 28dc43cb5..bc5c57a76 100644 --- a/src/components/pinch-to-move.js +++ b/src/components/pinch-to-move.js @@ -9,7 +9,7 @@ AFRAME.registerComponent("pinch-to-move", { }, tick() { const userinput = AFRAME.scenes[0].systems.userinput; - const pinch = userinput.readFrameValueAtPath(paths.device.touchscreen.pinchDelta); + const pinch = userinput.get(paths.device.touchscreen.pinchDelta); if (pinch) { this.axis[1] = pinch * this.data.speed; this.el.emit("move", { axis: this.axis }); diff --git a/src/components/pitch-yaw-rotator.js b/src/components/pitch-yaw-rotator.js index 297bf4f81..a2c2ebdea 100644 --- a/src/components/pitch-yaw-rotator.js +++ b/src/components/pitch-yaw-rotator.js @@ -36,7 +36,7 @@ AFRAME.registerComponent("pitch-yaw-rotator", { tick() { const userinput = AFRAME.scenes[0].systems.userinput; - const cameraDelta = userinput.readFrameValueAtPath(paths.actions.cameraDelta); + const cameraDelta = userinput.get(paths.actions.cameraDelta); let lookX = this.pendingXRotation; let lookY = 0; if (cameraDelta) { diff --git a/src/components/super-networked-interactable.js b/src/components/super-networked-interactable.js index 4c96f2452..1fbbaa37c 100644 --- a/src/components/super-networked-interactable.js +++ b/src/components/super-networked-interactable.js @@ -98,6 +98,6 @@ AFRAME.registerComponent("super-networked-interactable", { if (!(grabber && pathsMap[grabber.id])) return; const userinput = AFRAME.scenes[0].systems.userinput; - this._changeScale(userinput.readFrameValueAtPath(pathsMap[grabber.id].scaleGrabbedGrabbable)); + this._changeScale(userinput.get(pathsMap[grabber.id].scaleGrabbedGrabbable)); } }); diff --git a/src/components/super-spawner.js b/src/components/super-spawner.js index a786639e1..7ff4e1189 100644 --- a/src/components/super-spawner.js +++ b/src/components/super-spawner.js @@ -116,8 +116,8 @@ AFRAME.registerComponent("super-spawner", { async onSpawnEvent() { const userinput = AFRAME.scenes[0].systems.userinput; - const leftPose = userinput.readFrameValueAtPath(paths.actions.leftHand.pose); - const rightPose = userinput.readFrameValueAtPath(paths.actions.rightHand.pose); + const leftPose = userinput.get(paths.actions.leftHand.pose); + const rightPose = userinput.get(paths.actions.rightHand.pose); const controllerCount = leftPose && rightPose ? 2 : leftPose || rightPose ? 1 : 0; const using6DOF = controllerCount > 1 && this.el.sceneEl.is("vr-mode"); const hand = using6DOF ? this.data.superHand : this.data.cursorSuperHand; diff --git a/src/components/tools/pen.js b/src/components/tools/pen.js index dd52ca4ab..f09e63101 100644 --- a/src/components/tools/pen.js +++ b/src/components/tools/pen.js @@ -103,20 +103,20 @@ AFRAME.registerComponent("pen", { const userinput = AFRAME.scenes[0].systems.userinput; if (grabber && pathsMap[grabber.id]) { const paths = pathsMap[grabber.id]; - if (userinput.readFrameValueAtPath(paths.startDrawing)) { + if (userinput.get(paths.startDrawing)) { this._startDraw(); } - if (userinput.readFrameValueAtPath(paths.stopDrawing)) { + if (userinput.get(paths.stopDrawing)) { this._endDraw(); } - const penScaleMod = userinput.readFrameValueAtPath(paths.scalePenTip); + const penScaleMod = userinput.get(paths.scalePenTip); if (penScaleMod) { this._changeRadius(penScaleMod); } - if (userinput.readFrameValueAtPath(paths.penNextColor)) { + if (userinput.get(paths.penNextColor)) { this._changeColor(1); } - if (userinput.readFrameValueAtPath(paths.penPrevColor)) { + if (userinput.get(paths.penPrevColor)) { this._changeColor(-1); } } diff --git a/src/systems/userinput/userinput.js b/src/systems/userinput/userinput.js index f6f37a6a9..7cbbe5331 100644 --- a/src/systems/userinput/userinput.js +++ b/src/systems/userinput/userinput.js @@ -55,7 +55,7 @@ function prioritizeBindings(registeredMappings, activeSets) { } AFRAME.registerSystem("userinput", { - readFrameValueAtPath(path) { + get(path) { return this.frame && this.frame[path]; }, diff --git a/src/systems/userinput/userinput.md b/src/systems/userinput/userinput.md index d3701d5c9..2bd9a7eee 100644 --- a/src/systems/userinput/userinput.md +++ b/src/systems/userinput/userinput.md @@ -25,7 +25,7 @@ The userinput system is a module that manages mappings from device state changes ## Overview -The userinput system happens to be an `aframe` `system`; its `tick` is called once a frame within the `aframe` `scene`'s `tick`. When the userinput system `tick` happens, it is responsible for creating a map called the frame. The keys of the frame are called "paths". The values stored in the frame can be any type, but are usually one of: bool, number, vec2, vec3, vec4, pose. On each tick, each connected `device` writes "raw" input values to known "device paths" within the frame. Configuration units called `bindings` are then applied to transform "raw" input values to app-specific "actions". The userinput system exposes the state of a given `action` in the current frame via `readFrameValueAtPath`. The `bindings` that are applied to transform input to "actions" must be `available`, `active`, and `prioritized`. +The userinput system happens to be an `aframe` `system`; its `tick` is called once a frame within the `aframe` `scene`'s `tick`. When the userinput system `tick` happens, it is responsible for creating a map called the frame. The keys of the frame are called "paths". The values stored in the frame can be any type, but are usually one of: bool, number, vec2, vec3, vec4, pose. On each tick, each connected `device` writes "raw" input values to known "device paths" within the frame. Configuration units called `bindings` are then applied to transform "raw" input values to app-specific "actions". The userinput system exposes the state of a given `action` in the current frame via `get`. The `bindings` that are applied to transform input to "actions" must be `available`, `active`, and `prioritized`. 1. A `binding` is made `available` when the userinput system detects a change to the user's device configuration that matches certain criteria. A touchscreen user only has `availableBindings` related to touchscreen input. A mouse-and-keyboard user only has `availableBindings` related to mouse-and-keyboard input. An oculus/vive user has `bindings` related to mouse, keyboard, and oculus/vive controllers. @@ -70,14 +70,14 @@ A path is used as a key when writing or querying the state a user input frame. P A path used by app code when reading a user input frame. const userinput = AFRAME.scenes[0].systems.userinput; - if (userinput.readFrameValueAtPath("/actions/rightHandGrab")) { + if (userinput.get("/actions/rightHandGrab")) { this.startInteraction(); } The value in the frame can be of any type, but we have tried to keep it to simple types like bool, number, vec2, vec3, and pose. const userinput = AFRAME.scenes[0].systems.userinput; - const acceleration = userinput.readFrameValueAtPath("/actions/characterAcceleration"); + const acceleration = userinput.get("/actions/characterAcceleration"); this.updateVelocity( this.velocity, acceleration || zero ); this.move( this.velocity ); -- GitLab