{"action":"created","issue":{"url":"https://api.github.com/repos/aframevr/aframe/issues/1248","repository_url":"https://api.github.com/repos/aframevr/aframe","labels_url":"https://api.github.com/repos/aframevr/aframe/issues/1248/labels{/name}","comments_url":"https://api.github.com/repos/aframevr/aframe/issues/1248/comments","events_url":"https://api.github.com/repos/aframevr/aframe/issues/1248/events","html_url":"https://github.com/aframevr/aframe/pull/1248","id":143154932,"number":1248,"title":"Controls refactor + extensibility.","user":{"login":"donmccurdy","id":1848368,"avatar_url":"https://avatars.githubusercontent.com/u/1848368?v=3","gravatar_id":"","url":"https://api.github.com/users/donmccurdy","html_url":"https://github.com/donmccurdy","followers_url":"https://api.github.com/users/donmccurdy/followers","following_url":"https://api.github.com/users/donmccurdy/following{/other_user}","gists_url":"https://api.github.com/users/donmccurdy/gists{/gist_id}","starred_url":"https://api.github.com/users/donmccurdy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donmccurdy/subscriptions","organizations_url":"https://api.github.com/users/donmccurdy/orgs","repos_url":"https://api.github.com/users/donmccurdy/repos","events_url":"https://api.github.com/users/donmccurdy/events{/privacy}","received_events_url":"https://api.github.com/users/donmccurdy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aframevr/aframe/labels/needs%20review","name":"needs review","color":"e1fd39"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":63,"created_at":"2016-03-24T05:18:25Z","updated_at":"2016-07-01T03:15:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/aframevr/aframe/pulls/1248","html_url":"https://github.com/aframevr/aframe/pull/1248","diff_url":"https://github.com/aframevr/aframe/pull/1248.diff","patch_url":"https://github.com/aframevr/aframe/pull/1248.patch"},"body":"## Description:\r\n\r\nFixes #975, #848, #543. ~~Includes @bnolan's PR #1056 for pointerlock.~~\r\n\r\nProposed in #975, this attempts to address a couple issues:\r\n\r\n1. Integrating third-party controls is a bit problematic.\r\n2. Adding pointerlock as an option (default or no) would be awesome.\r\n3. If a physics implementation is added, collision detection on the player would be a nice-to-have. The abstraction makes this much easier.\r\n\r\n## Changes proposed:\r\n- Add `controls` component to fetch user input from input device components and apply position/rotation to the object.\r\n- Add device-specific components `wasd-controls`, ~~`gamepad-controls`~~, ~~`touch-controls` (touch-to-move)~~, `hmd-controls`, and `mouse-controls`. Probably not all of these should be enabled by default, but they could be.\r\n- ~~Adds `velocity` component to update position over time. (Not necessary to the PR, but makes physics integration easier).~~\r\n\r\n### Usage:\r\n\r\n**Default:**\r\n\r\n```html\r\n<a-entity camera controls></a-entity>\r\n```\r\n\r\n**Custom:**\r\n\r\n```html\r\n<a-entity camera controls=\"rotation: custom-controls hmd-controls gamepad-controls mouse-controls\"></a-entity>\r\n```\r\n\r\n## Interface:\r\n\r\n### Controls Component\r\nNo exposed interface, but the basic implementation is:\r\n1. Iterate over rotation controls, by order of precedence, finding first active control and setting rotation. \r\n2. Iterate over movement controls, by order of precedence, and get velocity relative to heading.\r\n3. Apply rotation to velocity, to get absolute velocity.\r\n4. Set velocity.\r\n\r\nDevelopers can modify the `movement` and `rotation` properties to enable/disable input devices, or change the order of precedence.\r\n\r\n### Movement Controls\r\n- **isVelocityActive()** – *(required)* Returns true if this control is actively in use. For example, a connected gamepad should return false unless the left joystick is tilted.\r\n- **getVelocityDelta(dt)** – Returns an incremental THREE.Vector3 velocity change, with values [-1,1]. In general, this will affect the X and Z axes.\r\n- **getVelocity()** – Returns a self-sufficient THREE.Vector3 velocity. May not be necessary, I can't think of a need.\r\n\r\n### Rotation Controls\r\n- **isRotationActive()** – *(required)* Returns true if the control is actively in use. For example, mouse controls would only return true if the mouse is currently moving. HMD controls can probably return true any time an HMD is detected.\r\n- **getRotationDelta(dt)** – Returns an incremental THREE.Vector2 rotation change, with X and Y rotation values. To be roughly calibrated, these should be near the range [-1,1].\r\n- **getRotation()** – Returns a self-sufficient THREE.Vector3 (XYZ euler) world orientation, in degrees.\r\n\r\n## Pending:\r\n- [x] I'm assuming `controls` should inject the other components if they aren't present, rather than specifying all 5-6 in HTML.\r\n- [x] Need to polyfill KeyboardEvent.code, which tangentially happens to fix #333 (ZQSD controls) in Chrome.\r\n- :heavy_multiplication_x:  ~~Maybe `mouse-controls` should be split into mousedrag and pointerlock components?~~\r\n- [x] Inject velocity component automatically\r\n- [x] Deprecate look-controls and wasd-controls.\r\n- [x] Rename movement -> position\r\n- [x] Update all examples to use the new controls.\r\n- [x] Update the default camera configuration in `systems/camera.js`.\r\n- [x] Documentation\r\n- [x] Unit tests\r\n- [ ] Resolve conflicts with #1474 \r\n- [ ] Consider adding `touch-controls` back in.\r\n\r\n## Demos:\r\n- Within A-Frame, updated the \"Controls\" demo.\r\n- [Wall collision detection](https://sandbox.donmccurdy.com/vr/walls/) with gamepad/wasd/touch movement.\r\n- [Motion sickness-inducing physics demo](https://sandbox.donmccurdy.com/vr/playground/) with ramps and moving platforms, because hey why not.\r\n\r\nSide note, on physics integration, the wrapper around input controls is actually less critical than the `velocity` component. An example implementation (2nd and 3rd demos above) is [kinematic-body.js](https://github.com/donmccurdy/sandbox-aframe/blob/master/src/physics/kinematic-body.js), and the key need is having access to rotation/position/velocity data."},"comment":{"url":"https://api.github.com/repos/aframevr/aframe/issues/comments/229844393","html_url":"https://github.com/aframevr/aframe/pull/1248#issuecomment-229844393","issue_url":"https://api.github.com/repos/aframevr/aframe/issues/1248","id":229844393,"user":{"login":"dmarcos","id":39342,"avatar_url":"https://avatars.githubusercontent.com/u/39342?v=3","gravatar_id":"","url":"https://api.github.com/users/dmarcos","html_url":"https://github.com/dmarcos","followers_url":"https://api.github.com/users/dmarcos/followers","following_url":"https://api.github.com/users/dmarcos/following{/other_user}","gists_url":"https://api.github.com/users/dmarcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dmarcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmarcos/subscriptions","organizations_url":"https://api.github.com/users/dmarcos/orgs","repos_url":"https://api.github.com/users/dmarcos/repos","events_url":"https://api.github.com/users/dmarcos/events{/privacy}","received_events_url":"https://api.github.com/users/dmarcos/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T03:15:13Z","updated_at":"2016-07-01T03:15:13Z","body":"Let's look at this first thing post 0.3.0. This is a big change and I'm worried about rushing it."}}
{"actor":{"display_login":"dmarcos"}}