diff --git a/src/components/character-controller.js b/src/components/character-controller.js index 05bb83ff30d85cd3a74cc6fc78cff4ba2e72c6c6..80260e0fcfbf258492e536fa1ab930811cfef1eb 100644 --- a/src/components/character-controller.js +++ b/src/components/character-controller.js @@ -126,7 +126,11 @@ AFRAME.registerComponent("character-controller", { } const acc = userinput.readFrameValueAtPath(paths.actions.characterAcceleration); if (acc) { - this.accelerationInput.set(acc[0], 0, acc[1]); + this.accelerationInput.set( + this.accelerationInput.x + acc[0], + this.accelerationInput.y + 0, + this.accelerationInput.z + acc[1] + ); } pivotPos.copy(pivot.position); @@ -138,6 +142,7 @@ AFRAME.registerComponent("character-controller", { pivotRotationMatrix.makeRotationAxis(rotationAxis, pivot.rotation.y); pivotRotationInvMatrix.makeRotationAxis(rotationAxis, -pivot.rotation.y); this.updateVelocity(deltaSeconds); + this.accelerationInput.set(0, 0, 0); const boost = userinput.readFrameValueAtPath(paths.actions.boost) ? 2 : 1; move.makeTranslation( diff --git a/src/components/virtual-gamepad-controls.js b/src/components/virtual-gamepad-controls.js index 309b2210bfa34be8daed0df28d91d31b8770ca38..f4790dd2b0c02cf9e1565c9d8426c6af359c4c71 100644 --- a/src/components/virtual-gamepad-controls.js +++ b/src/components/virtual-gamepad-controls.js @@ -94,7 +94,7 @@ AFRAME.registerComponent("virtual-gamepad-controls", { onMoveJoystickChanged(event, joystick) { const angle = joystick.angle.radian; const force = joystick.force < 1 ? joystick.force : 1; - const moveStrength = 0.85; + const moveStrength = 1.85; const x = Math.cos(angle) * force * moveStrength; const z = Math.sin(angle) * force * moveStrength; this.moving = true; diff --git a/src/hub.html b/src/hub.html index a5eef877d23f95f2782385c898aeb4b047689571..de2bf1f52bf6e43857f08bbd0616ac0c74ae8f09 100644 --- a/src/hub.html +++ b/src/hub.html @@ -30,7 +30,6 @@ freeze-controller="toggleEvent: action_freeze" personal-space-bubble="debug: false;" vr-mode-ui="enabled: false" - pinch-to-move stats-plus="false" > diff --git a/src/systems/userinput/bindings/touchscreen-user.js b/src/systems/userinput/bindings/touchscreen-user.js index 770fe3f38d9547f401c18aa4f3390b1bcfbb2a5c..92ef99eab630a7677d94a8df7eebe1ca10b22698 100644 --- a/src/systems/userinput/bindings/touchscreen-user.js +++ b/src/systems/userinput/bindings/touchscreen-user.js @@ -2,8 +2,25 @@ import { paths } from "../paths"; import { sets } from "../sets"; import { xforms } from "./xforms"; +const zero = "/vars/touchscreen/zero"; +const forward = "/vars/touchscreen/pinchDeltaForward"; + export const touchscreenUserBindings = { [sets.global]: [ + { + src: { value: paths.device.touchscreen.pinch.delta }, + dest: { value: forward }, + xform: xforms.scale(0.25) + }, + { + dest: { value: zero }, + xform: xforms.always(0) + }, + { + src: { x: zero, y: forward }, + dest: { value: paths.actions.characterAcceleration }, + xform: xforms.compose_vec2 + }, { src: { value: paths.device.touchscreen.cursorPose }, dest: { value: paths.actions.cursor.pose }, diff --git a/src/systems/userinput/devices/app-aware-touchscreen.js b/src/systems/userinput/devices/app-aware-touchscreen.js index 31bf0fb7b9c625a5c060a31174f973eee79f39a9..ab30d2e2528f3f88f5596abcce207c2c276db353 100644 --- a/src/systems/userinput/devices/app-aware-touchscreen.js +++ b/src/systems/userinput/devices/app-aware-touchscreen.js @@ -36,7 +36,7 @@ export class AppAwareTouchscreenDevice { constructor() { this.raycaster = new THREE.Raycaster(new THREE.Vector3(), new THREE.Vector3(), 0, 3); this.assignments = []; - this.pinch = {}; + this.pinch = { initialDistance: 0, currentDistance: 0, delta: 0 }; this.events = []; ["touchstart", "touchend", "touchmove", "touchcancel"].map(x => document.querySelector("canvas").addEventListener(x, this.events.push.bind(this.events)) @@ -57,7 +57,7 @@ export class AppAwareTouchscreenDevice { break; case FIRST_PINCHER_JOB: unassign(assignment.touch, assignment.job, this.assignments); - this.pinch = undefined; + this.pinch = { initialDistance: 0, currentDistance: 0, delta: 0 }; if (jobIsAssigned(SECOND_PINCHER_JOB, this.assignments)) { const second = findByJob(SECOND_PINCHER_JOB, this.assignments); @@ -78,7 +78,7 @@ export class AppAwareTouchscreenDevice { break; case SECOND_PINCHER_JOB: unassign(assignment.touch, assignment.job, this.assignments); - this.pinch = undefined; + this.pinch = { initialDistance: 0, currentDistance: 0, delta: 0 }; if (jobIsAssigned(FIRST_PINCHER_JOB, this.assignments) && !jobIsAssigned(MOVE_CAMERA_JOB, this.assignments)) { //reassign firstPincher to moveCamera const first = findByJob(FIRST_PINCHER_JOB, this.assignments); @@ -235,10 +235,8 @@ export class AppAwareTouchscreenDevice { frame[path.cameraDelta] = findByJob(MOVE_CAMERA_JOB, this.assignments).delta; } - if (this.pinch) { - frame[path.pinchDelta] = this.pinch.delta; - frame[path.initialPinchDistance] = this.pinch.initialDistance; - frame[path.currentPinchDistance] = this.pinch.currentDistance; - } + frame[path.pinch.delta] = this.pinch.delta; + frame[path.pinch.initialDistance] = this.pinch.initialDistance; + frame[path.pinch.currentDistance] = this.pinch.currentDistance; } } diff --git a/src/systems/userinput/paths.js b/src/systems/userinput/paths.js index 9ec46049120e0e12a77010b5146e2e9f33f24db3..3acb4a740b21462368e08c2674f273b3b78ff849 100644 --- a/src/systems/userinput/paths.js +++ b/src/systems/userinput/paths.js @@ -70,9 +70,10 @@ paths.device.smartMouse.cameraDelta = "/device/smartMouse/cameraDelta"; paths.device.touchscreen = {}; paths.device.touchscreen.cursorPose = "/device/touchscreen/cursorPose"; paths.device.touchscreen.cameraDelta = "/device/touchscreen/cameraDelta"; -paths.device.touchscreen.pinchDelta = "/device/touchscreen/pinchDelta"; -paths.device.touchscreen.initialPinchDistance = "/device/touchscreen/initialPinchDistance"; -paths.device.touchscreen.currentPinchDistance = "/device/touchscreen/currentPinchDistance"; +paths.device.touchscreen.pinch = {}; +paths.device.touchscreen.pinch.delta = "/device/touchscreen/pinch/delta"; +paths.device.touchscreen.pinch.initialDistance = "/device/touchscreen/pinch/initialDistance"; +paths.device.touchscreen.pinch.currentDistance = "/device/touchscreen/pinch/currentDistance"; paths.device.touchscreen.isTouchingGrabbable = "/device/touchscreen/isTouchingGrabbable"; paths.device.hud = {}; paths.device.hud.penButton = "/device/hud/penButton";