Re: [w3c/gamepad] Added GamepadPose and GamepadCapabilities (#25)

(Editorial review note: the rendered version is broken, and only shows the text "MUSTMUST".)

I believe I've mentioned this before somewhere, but I can't find where, so let me raise it here again. I think this pattern of using Float32Arrays is very un-idiomatic and is not something we should be doing on the platform. Here are a few reasons:

- It does not fit with the purpose of the typed array specification, which is to provide facilities for manipulating blocks of packed binary data (including with multiple views). One way of seeing this is that for most binary data, accessing the underlying buffer makes sense and is useful, whereas for these properties, `pose.position.buffer` is meaningless and confusing.
- It is awkward for authors. Other places in the platform that use points or vectors use named properties, such as `x`/`y`/`z`/`w`, which is much easier to read and work with. `pose.position[2]` is very strange.
- It means that these vectors will not benefit from existing platform APIs. For example, the `DOMPoint(ReadOnly)` classes have a very useful method, `matrixTransform`, which allows you to transform them, and have a nice pretty-printing toString() method. As we add more methods to DOMPoint(ReadOnly), those will spread throughout all places that use those classes. Cutting authors off from such future improvements is hostile.
- It has incorrect mutability semantics. You can set arbitrary elements of the typed array. What does `pose.position[2] = 5` do? What does `pose.position[99] = 10` do? What does `new Float64Array(pose.position.buffer)[0] = 1e20` do? The result is mainly confusion; presumably this doesn't actually communicate with the gamepad to update your position in some way. All of these would not be possible in a well-designed class. Using `DOMPointReadOnly` would give you the correct semantics of only reflecting the actual position (etc.), as properties with only getters.

I hope this is convincing.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/pull/25#issuecomment-235748277

Received on Wednesday, 27 July 2016 23:04:56 UTC