immersive-web / hit-test

https://immersive-web.github.io/hit-test/
Other
78 stars 31 forks source link

Current XRRay construction semantics incorrect #84

Closed Manishearth closed 4 years ago

Manishearth commented 4 years ago

(Previously https://github.com/immersive-web/hit-test/pull/83)

Currently the XRRay vector constructor is specified as

 [Constructor(optional DOMPointInit origin, optional DOMPointInit direction)]

however, this is no longer allowed by the current WebIDL spec, it needs to be

   constructor(optional DOMPointInit origin = {}, optional DOMPointInit direction = {}); 

(https://github.com/heycam/webidl/pull/750 forces us to default to {})

Given that https://github.com/heycam/webidl/pull/750 forces optional dictionary arguments to specify a default, we can no longer distinguish between "direction was not specified" and "direction was specified as {0, 0, 0, 1}".

Unfortunately, {0, 0, 0, 1} is not a valid direction value! The w coordinate should be zero; and ideally we should throw for nonzero w (which is what Chrome does, despite being unspecced). But we can't tell the difference between "direction unspecified" and "direction is {0, 0, 0, 1}", so this would end up throwing for new XRRay({...}) with an unspecified direction.

We'd like to default it to the -Z axis instead. We should use a new dictionary here. We should also potentially handle the w coordinate in origin instead of ignoring it.

Manishearth commented 4 years ago

https://github.com/immersive-web/hit-test/pull/85