-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate possibility of synchronizing coordinate systems #257
Comments
@larsgk has provided related feedback in the past in the context of the Screen Orientation API. Looping him in to gather further feedback, since it's been a while. @larsgk, for the context, we're discussing whether there should be affordances in the low-level sensor APIs^ Accelerometer, Gyroscope Magnetometer, Orientation Sensor to sync the local coordinate system used by these sensors with the current orientation type of the screen, defined by the Screen Orientation API. Currently, the local coordinate system used by these low-level sensors is said to be "relative to the device’s screen when the device in its default orientation", aka the natural orientation in the Screen Orientation API. ^ This is a new set of sensor APIs that decompose the Device Orientation into low-level primitives. |
Related: w3c/deviceorientation#4 |
sorry, I missed this one (drowned in github notification mails, I think). Is it still relevant? |
@kenchris' https://github.com/kenchris/sensor-polyfills now implements the synchronization of the sensor and screen coordinate systems as discussed in this issue. The sync is enabled by default in the polyfill for testing purposes. To try it out:
When you change the orientation from portrait to landscape and back, you should see the back of the rendered object always point towards the center of the Earth. Would people like to see this feature cherry picked into the v1 spec and implemented natively? If so, we should spec the opt-in mechanism. The most obvious extension point would be to add a new flag to I'll start the bikeshedding with an initial name proposal for such a flag:
|
@alexshalamov made a point that the feature is specific to sensors that operate in a device coordinate system (currently motion sensors) and as such is not applicable to environment sensors. So rather than extending the generic
Or alternatively, spec |
I'm not in favor of using IMO it's simpler from both implementation and usage perspectives if sensors always stick to the device coord system, like it happens now. However we could provide some convenience conversion functions (or methods), like they do on Android. For example, |
I do automatic mapping in the polyfill right now, https://github.com/kenchris/sensor-polyfills/blob/master/src/motion-sensors.js#L310 Basically that makes things move along with screen orientation, ie. if an object is being rotated, then it will stay in the same place (from user point of view) when the screen changes orientation. In my experience that is the most common use-case and what feels more natural. Unless you need to do your own mapping, I think this is what makes the most sense, which is why I would like to have that be the default. Most people get really confused about coordinate systems (even me!) and how to do these mapping, so I rather let the burden on who really know what they are doing (so they do the extra work to turn off the auto mapping and add their own) and make things behave like what normal people would expect :-) |
We could provide a remap method or similar which is implemented natively and used by default. If people want to provide their own, or turn off remapping, they would just reimplement that method. |
After taking a deeper look at this issue I think:
After discussing this with @alexshalamov we'd like to propose the following plan for fixing the issue:
to be used for construction of all motion sensors
In future we could add |
@pozdnyakov 👍 and to provide backward compatibility with older APIs, and native platform behavior, by default, sensors would be providing data in 'device coordinate system'. |
All - please review @pozdnyakov's proposed solution #257 (comment) and let us know your feedback. Unless we hear concerns from the group participants, I'd ask the editors to start prepare a PR to address this issue in order to get it landed before we branch for the CR release in the near future. As discussed on the 11 Jan WG call, the motivation for the group to cherry pick this feature into Level 1 was feedback received from web developers during the still ongoing Chrome Origin Trial. This feature will hide the complexity of remapping of coordinate systems from web developers -- a process that is both tedious and error prone. There's also small performance advantage in handling this remap natively. |
I am fine with this. 👍 Should we spell out coordinate? like coordinateSystem or does the Web Platform use coord in other places? |
@kenchris yeah, it make sense to spell it out like |
I am wondering whether
is the best way or not. I think most other APIs apply the individual options directly on the object, like
Basically a bit like they were applied to the object,
Having it as "options" makes it seem like what was given to the constructor, where as having it as class fields (properties) makes it feel like what was applied |
This looks convenient for frequency, however |
That is a spec'ing issue. I haven't seen any API where the options were stored seperately, and I do think it support from the problem I stated above
We need to define coordinateSystem for the sensors who needs it anyway, so adding one attribute to those specs, shouldn't really be much work. @anssiko maybe you have ideas? |
I see your point now, the problem with returning the applied attributes is that for some of them (i.e. frequency) we do not know their values until the sensor is started.. I suggest to remove this item from the plan for now and address it separately in future as it's just for convenience and not mandatory for solving this particular issue. WDYT? |
@kenchris, the extensibility story recommended by the spec has been to extend What comes to the naming coord(s) vs. coordinate(s). There's some precedence for both: https://html.spec.whatwg.org/#dom-a-coords I tend to feel spelling out
|
Since dictionaries are not JS-exposed, their names are for spec purposes only. As such I wouldn’t worry too much about having the names perfect. Perhaps inheritance is slightly easier to spec in this case. (Related, there’s an inconclusive issue on adding feature detection mechanism for dictionary members: whatwg/webidl#107) |
This is required for fixing w3c#257
This is required for fixing w3c#257
This is required for fixing w3c#257
This is required for fixing w3c#257
The `SpatialSensorOptions` dictionary and the "construct spatial sensor object" are used, so that the client can set the local coordinate system for a Gyroscope instance from the constructor. This patch is a part of fix for w3c/sensors#257
The `SpatialSensorOptions` dictionary and the "construct spatial sensor object" are used, so that the client can set the local coordinate system for a Gyroscope instance from the constructor. This patch is a part of fix for w3c/sensors#257
The `SpatialSensorOptions` dictionary and the "construct spatial sensor object" are used, so that the client can set the local coordinate system for a Gyroscope instance from the constructor. This patch is a part of fix for w3c/sensors#257
The `SpatialSensorOptions` dictionary and the "construct spatial sensor object" are used, so that the client can set the local coordinate system for a Magnetometer instance from the constructor. This patch is a part of fix for w3c/sensors#257
Introduce MagnetometerSensorOptions that can control whether screen or device coordinate system is used. This patch is a part of fix for w3c/sensors#257
Introduce MagnetometerSensorOptions that can control whether screen or device coordinate system is used. This patch is a part of fix for w3c/sensors#257
Introduce MagnetometerSensorOptions that can control whether screen or device coordinate system is used. This patch is a part of fix for w3c/sensors#257
Introduce MagnetometerSensorOptions that can control whether screen or device coordinate system is used. This patch is a part of fix for w3c/sensors#257
This patch is a part of fix for w3c/sensors#257.
All the spatial sensor classes are now updated, so that the screen coordinate system is used to resolve their readings once the user passes |
Hey guys, @foolip and I have been monitoring spec changes without corresponding tests, and it looks like the commits referenced here fall into this category. For example, most of the IDLs in interfaces/ haven't been updated except for web-platform-tests/wpt#9357. Is there anything preventing WPT updates from happening concurrently with the spec changes? |
Chinese New Year. @Honry will get to this when he’s back in business. |
@rakuco, thanks for your reminder, I just merge the rest PRs for updating the IDLs in interfaces/.
And will consider some functional tests for this new feature after my vacation. |
Many sensors operate in device coordinate system, where X and Y axes are aligned with screen X & Y axes in the natural orientation.
When OS changes rendering surface orientation from it's natural orientation, sensor and screen coordinate systems may become out of sync, thus, require usage of ScreenOrientation API, matrix math, swapping of X / Y or changing Euler angle order.
Would be nice to have a way to say to such sensors to be in sync with screen coordinate system, so that extra calculations and/or API usage is not required from developers.
The text was updated successfully, but these errors were encountered: