mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Add XRRay(transform) constructor
This commit is contained in:
parent
977b36d855
commit
e7ba4e5a47
3 changed files with 16 additions and 5 deletions
|
@ -7,7 +7,7 @@
|
|||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRRay {
|
||||
constructor(optional DOMPointInit origin = {}, optional DOMPointInit direction = {});
|
||||
// constructor(XRRigidTransform transform);
|
||||
constructor(XRRigidTransform transform);
|
||||
[SameObject] readonly attribute DOMPointReadOnly origin;
|
||||
[SameObject] readonly attribute DOMPointReadOnly direction;
|
||||
// [SameObject] readonly attribute Float32Array matrix;
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::dom::bindings::root::DomRoot;
|
|||
use crate::dom::dompointreadonly::DOMPointReadOnly;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::window::Window;
|
||||
use crate::dom::xrrigidtransform::XRRigidTransform;
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::Vector3D;
|
||||
use webxr_api::{ApiSpace, Ray};
|
||||
|
@ -45,6 +46,18 @@ impl XRRay {
|
|||
|
||||
Self::new(&window.global(), Ray { origin, direction })
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
/// https://immersive-web.github.io/hit-test/#dom-xrray-xrray-transform
|
||||
pub fn Constructor_(window: &Window, transform: &XRRigidTransform) -> DomRoot<Self> {
|
||||
let transform = transform.transform();
|
||||
let origin = transform.translation;
|
||||
let direction = transform
|
||||
.rotation
|
||||
.transform_vector3d(Vector3D::new(0., 0., -1.));
|
||||
|
||||
Self::new(&window.global(), Ray { origin, direction })
|
||||
}
|
||||
}
|
||||
|
||||
impl XRRayMethods for XRRay {
|
||||
|
|
|
@ -47,8 +47,8 @@ use std::f64::consts::{FRAC_PI_2, PI};
|
|||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use webxr_api::{
|
||||
self, util, Display, EnvironmentBlendMode, Event as XREvent, Frame, SelectEvent, SelectKind,
|
||||
Session, SessionId, View, Viewer, Visibility,
|
||||
self, util, ApiSpace, Display, EnvironmentBlendMode, Event as XREvent, Frame, SelectEvent,
|
||||
SelectKind, Session, SessionId, View, Viewer, Visibility,
|
||||
};
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -711,8 +711,6 @@ impl XRSessionMethods for XRSession {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ApiSpace;
|
||||
// The pose of an object in native-space. Should never be exposed.
|
||||
pub type ApiPose = RigidTransform3D<f32, ApiSpace, webxr_api::Native>;
|
||||
// The pose of the viewer in some api-space.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue