mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Add origin/direction methods to XRRay
This commit is contained in:
parent
b6a9e41bb8
commit
98ff97783e
3 changed files with 30 additions and 4 deletions
|
@ -157,8 +157,8 @@ use webgpu::{
|
||||||
WebGPUPipelineLayout, WebGPUQueue, WebGPUShaderModule,
|
WebGPUPipelineLayout, WebGPUQueue, WebGPUShaderModule,
|
||||||
};
|
};
|
||||||
use webrender_api::{DocumentId, ImageKey};
|
use webrender_api::{DocumentId, ImageKey};
|
||||||
use webxr_api::SwapChainId as WebXRSwapChainId;
|
|
||||||
use webxr_api::Ray;
|
use webxr_api::Ray;
|
||||||
|
use webxr_api::SwapChainId as WebXRSwapChainId;
|
||||||
|
|
||||||
unsafe_no_jsmanaged_fields!(Tm);
|
unsafe_no_jsmanaged_fields!(Tm);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
interface XRRay {
|
interface XRRay {
|
||||||
// constructor(optional DOMPointInit origin, optional DOMPointInit direction);
|
// constructor(optional DOMPointInit origin, optional DOMPointInit direction);
|
||||||
// constructor(XRRigidTransform transform);
|
// constructor(XRRigidTransform transform);
|
||||||
// [SameObject] readonly attribute DOMPointReadOnly origin;
|
[SameObject] readonly attribute DOMPointReadOnly origin;
|
||||||
// [SameObject] readonly attribute DOMPointReadOnly direction;
|
[SameObject] readonly attribute DOMPointReadOnly direction;
|
||||||
// [SameObject] readonly attribute Float32Array matrix;
|
// [SameObject] readonly attribute Float32Array matrix;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::bindings::root::DomRoot;
|
||||||
|
use crate::dom::dompointreadonly::DOMPointReadOnly;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webxr_api::{ApiSpace, Ray};
|
use webxr_api::{ApiSpace, Ray};
|
||||||
|
@ -27,3 +29,27 @@ impl XRRay {
|
||||||
reflect_dom_object(Box::new(XRRay::new_inherited(ray)), global)
|
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.,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue