Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hit testing API #26171

Merged
merged 18 commits into from Apr 20, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add XRRay(transform) constructor

  • Loading branch information
Manishearth committed Apr 20, 2020
commit e7ba4e5a472e9e7f440f9f9a77d035e7550a54f6
@@ -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.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.