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 stub XRRay

  • Loading branch information
Manishearth committed Apr 20, 2020
commit b6a9e41bb8ebb9640f698d02728f81d77c337b58
@@ -158,6 +158,7 @@ use webgpu::{
};
use webrender_api::{DocumentId, ImageKey};
use webxr_api::SwapChainId as WebXRSwapChainId;
use webxr_api::Ray;

unsafe_no_jsmanaged_fields!(Tm);

@@ -750,6 +751,13 @@ unsafe impl<U> JSTraceable for euclid::Rect<i32, U> {
}
}

unsafe impl<Space> JSTraceable for Ray<Space> {
#[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
}
}

unsafe impl JSTraceable for StyleLocked<FontFaceRule> {
unsafe fn trace(&self, _trc: *mut JSTracer) {
// Do nothing.
@@ -579,6 +579,7 @@ pub mod xrinputsourceschangeevent;
pub mod xrlayer;
pub mod xrmediabinding;
pub mod xrpose;
pub mod xrray;
pub mod xrreferencespace;
pub mod xrrenderstate;
pub mod xrrigidtransform;
@@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

// https://immersive-web.github.io/hit-test/#xrray-interface

[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
interface XRRay {
// constructor(optional DOMPointInit origin, optional DOMPointInit direction);
// constructor(XRRigidTransform transform);
// [SameObject] readonly attribute DOMPointReadOnly origin;
// [SameObject] readonly attribute DOMPointReadOnly direction;
// [SameObject] readonly attribute Float32Array matrix;
};
@@ -0,0 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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::root::DomRoot;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use webxr_api::{ApiSpace, Ray};

#[dom_struct]
pub struct XRRay {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webxr"]
ray: Ray<ApiSpace>,
}

impl XRRay {
fn new_inherited(ray: Ray<ApiSpace>) -> XRRay {
XRRay {
reflector_: Reflector::new(),
ray,
}
}

pub fn new(global: &GlobalScope, ray: Ray<ApiSpace>) -> DomRoot<XRRay> {
reflect_dom_object(Box::new(XRRay::new_inherited(ray)), global)
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.