diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2020-04-08 14:52:04 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2020-04-19 20:29:14 -0700 |
commit | 98ff97783e7bc083b3f0dd461c6743bd34aa1680 (patch) | |
tree | cd807c311a173c06855ce76cf2930785dd990fdd /components/script/dom/xrray.rs | |
parent | b6a9e41bb8ebb9640f698d02728f81d77c337b58 (diff) | |
download | servo-98ff97783e7bc083b3f0dd461c6743bd34aa1680.tar.gz servo-98ff97783e7bc083b3f0dd461c6743bd34aa1680.zip |
Add origin/direction methods to XRRay
Diffstat (limited to 'components/script/dom/xrray.rs')
-rw-r--r-- | components/script/dom/xrray.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/components/script/dom/xrray.rs b/components/script/dom/xrray.rs index f850e00e906..30327ea0a15 100644 --- a/components/script/dom/xrray.rs +++ b/components/script/dom/xrray.rs @@ -2,8 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; +use crate::dom::bindings::codegen::Bindings::XRRayBinding::XRRayMethods; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; +use crate::dom::dompointreadonly::DOMPointReadOnly; use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; use webxr_api::{ApiSpace, Ray}; @@ -27,3 +29,27 @@ impl XRRay { reflect_dom_object(Box::new(XRRay::new_inherited(ray)), global) } } + +impl XRRayMethods for XRRay { + /// https://immersive-web.github.io/hit-test/#dom-xrray-origin + fn Origin(&self) -> DomRoot<DOMPointReadOnly> { + DOMPointReadOnly::new( + &self.global(), + self.ray.origin.x as f64, + self.ray.origin.y as f64, + self.ray.origin.z as f64, + 1., + ) + } + + /// https://immersive-web.github.io/hit-test/#dom-xrray-direction + fn Direction(&self) -> DomRoot<DOMPointReadOnly> { + DOMPointReadOnly::new( + &self.global(), + self.ray.direction.x as f64, + self.ray.direction.y as f64, + self.ray.direction.z as f64, + 0., + ) + } +} |