Re: [mediacapture-image] Add pan and tilt constraints

> Easier to understand and use for web developers.

I agree degrees are more commonly used and intuitive, but I still worry about it leading to iffy code because of the rounding problems.

For example, a UI that lets the user control pan and tilt would probably want to wait for them to take effect before letting the user make another adjustment (or at least debounce their input) to prevent the camera from lagging behind and feeling out of sync. A developer might choose to implement that as:

```
input.oninput = function(event) {
  lockUI = true;  // Stand in for some method of locking the UI
  var panValue = event.target.value;
  track.applyConstraints({pan: panValue});

  var waitingForUpdate = true;

  while (waitingForUpdate) {
    if (track.getSettings().pan == panValue) {
      lockUI = false;
      waitingForUpdate = false;
    }
  }
}
```

Obviously that's not great code, but it's in the vein of code someone might write if they have to wait for a setting to take effect.

Now, if they had an input set up that used the pan value and step increments, with arc-degrees this would always be an integer and there is no rounding problem. With degrees, adding the step to the current value might lead to a very slightly different number then gets returned by `getSettings()`, which would break simple equality checking.

I may be overblowing the "risk" here, but I've definitely seen float rounding problems bite people in the real world, where order of operation leads to slightly different results. It's stuck with me enough to make me weary of situations where it could occur.

@yellowdoge, would the promise returned by `applyConstraints()` only resolve once the settings have taken effect (if pan takes 500ms to apply) or does it resolve once the constraint has been set, without waiting for it to take effect?

> @dsanders11 BTW, why just Pan and Tilt without Roll? I have a camera where pan, tilt and roll can be controlled separately.

Roll can easily be added, in my experience it isn't commonly available in consumer webcams so I didn't add it at this time. Most webcams in laptops and phones aren't going to have support for pan/tilt/roll at all, but I know Logitech brand webcams have support for pan/tilt, but not roll.

> Also, I think it would be better to specify order for applying 'rotation' constraints, so that vendors can implement interoperable API (pan-tilt-roll, zyx).

You'll have to expand on that a bit, I don't quite follow. There's not currently any notion of ordering constraints in this spec, I think adding it would change the API a decent amount unless you had an idea in mind?

-- 
GitHub Notification of comment by dsanders11
Please view or discuss this issue at https://github.com/w3c/mediacapture-image/pull/182#issuecomment-308837309 using your GitHub account

Received on Thursday, 15 June 2017 19:03:25 UTC