diff --git a/Cargo.toml b/Cargo.toml index d0ec7705bad..411501e4ab3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,6 +82,7 @@ members = [ "examples/webaudio", "examples/webgl", "examples/websockets", + "examples/webxr", "examples/without-a-bundler", "examples/without-a-bundler-no-modules", "tests/no-std", diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 992154b0b44..264c3a801e3 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -1295,6 +1295,38 @@ XmlHttpRequestEventTarget = ["EventTarget"] XmlHttpRequestResponseType = [] XmlHttpRequestUpload = ["EventTarget", "XmlHttpRequestEventTarget"] XmlSerializer = [] +Xr = ["EventTarget"] +XrBoundedReferenceSpace = ["EventTarget", "XrReferenceSpace", "XrSpace"] +XrEye = [] +XrFrame = [] +XrHandedness = [] +XrInputSource = [] +XrInputSourceArray = [] +XrInputSourceEvent = ["Event"] +XrInputSourceEventInit = [] +XrInputSourcesChangeEvent = ["Event"] +XrInputSourcesChangeEventInit = [] +XrPose = [] +XrReferenceSpace = ["EventTarget", "XrSpace"] +XrReferenceSpaceEvent = ["Event"] +XrReferenceSpaceEventInit = [] +XrReferenceSpaceType = [] +XrRenderState = [] +XrRenderStateInit = [] +XrRigidTransform = [] +XrSession = ["EventTarget"] +XrSessionEvent = ["Event"] +XrSessionEventInit = [] +XrSessionInit = [] +XrSessionMode = [] +XrSpace = ["EventTarget"] +XrTargetRayMode = [] +XrView = [] +XrViewerPose = ["XrPose"] +XrViewport = [] +XrVisibilityState = [] +XrWebGlLayer = [] +XrWebGlLayerInit = [] XsltProcessor = [] console = [] css = [] diff --git a/crates/web-sys/src/features/gen_Navigator.rs b/crates/web-sys/src/features/gen_Navigator.rs index 3c6eb7a8f53..87bf5a2b277 100644 --- a/crates/web-sys/src/features/gen_Navigator.rs +++ b/crates/web-sys/src/features/gen_Navigator.rs @@ -105,6 +105,18 @@ extern "C" { #[doc = "*This API requires the following crate features to be activated: `CredentialsContainer`, `Navigator`*"] pub fn credentials(this: &Navigator) -> CredentialsContainer; #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "Xr")] + # [ wasm_bindgen ( structural , method , getter , js_class = "Navigator" , js_name = xr ) ] + #[doc = "Getter for the `xr` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/xr)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Navigator`, `Xr`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn xr(this: &Navigator) -> Xr; + #[cfg(web_sys_unstable_apis)] #[cfg(feature = "Gpu")] # [ wasm_bindgen ( structural , method , getter , js_class = "Navigator" , js_name = gpu ) ] #[doc = "Getter for the `gpu` field of this object."] diff --git a/crates/web-sys/src/features/gen_WebGl2RenderingContext.rs b/crates/web-sys/src/features/gen_WebGl2RenderingContext.rs index ed8a9a705cc..a2e849b224b 100644 --- a/crates/web-sys/src/features/gen_WebGl2RenderingContext.rs +++ b/crates/web-sys/src/features/gen_WebGl2RenderingContext.rs @@ -5844,6 +5844,13 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `WebGl2RenderingContext`, `WebGlProgram`*"] pub fn link_program(this: &WebGl2RenderingContext, program: &WebGlProgram); + # [ wasm_bindgen ( method , structural , js_class = "WebGL2RenderingContext" , js_name = makeXRCompatible ) ] + #[doc = "The `makeXRCompatible()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/makeXRCompatible)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGl2RenderingContext`*"] + pub fn make_xr_compatible(this: &WebGl2RenderingContext) -> ::js_sys::Promise; # [ wasm_bindgen ( method , structural , js_class = "WebGL2RenderingContext" , js_name = pixelStorei ) ] #[doc = "The `pixelStorei()` method."] #[doc = ""] diff --git a/crates/web-sys/src/features/gen_WebGlContextAttributes.rs b/crates/web-sys/src/features/gen_WebGlContextAttributes.rs index 7d25308c374..0832e53763f 100644 --- a/crates/web-sys/src/features/gen_WebGlContextAttributes.rs +++ b/crates/web-sys/src/features/gen_WebGlContextAttributes.rs @@ -148,4 +148,21 @@ impl WebGlContextAttributes { let _ = r; self } + #[doc = "Change the `xrCompatible` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGlContextAttributes`*"] + pub fn xr_compatible(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("xrCompatible"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } } diff --git a/crates/web-sys/src/features/gen_WebGlRenderingContext.rs b/crates/web-sys/src/features/gen_WebGlRenderingContext.rs index 892af5740ef..5a3e68338cc 100644 --- a/crates/web-sys/src/features/gen_WebGlRenderingContext.rs +++ b/crates/web-sys/src/features/gen_WebGlRenderingContext.rs @@ -1558,6 +1558,13 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `WebGlProgram`, `WebGlRenderingContext`*"] pub fn link_program(this: &WebGlRenderingContext, program: &WebGlProgram); + # [ wasm_bindgen ( method , structural , js_class = "WebGLRenderingContext" , js_name = makeXRCompatible ) ] + #[doc = "The `makeXRCompatible()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/makeXRCompatible)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGlRenderingContext`*"] + pub fn make_xr_compatible(this: &WebGlRenderingContext) -> ::js_sys::Promise; # [ wasm_bindgen ( method , structural , js_class = "WebGLRenderingContext" , js_name = pixelStorei ) ] #[doc = "The `pixelStorei()` method."] #[doc = ""] diff --git a/crates/web-sys/src/features/gen_Xr.rs b/crates/web-sys/src/features/gen_Xr.rs new file mode 100644 index 00000000000..c6316d2f774 --- /dev/null +++ b/crates/web-sys/src/features/gen_Xr.rs @@ -0,0 +1,80 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = EventTarget , extends = :: js_sys :: Object , js_name = XR , typescript_type = "XR" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `Xr` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XR)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Xr`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type Xr; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XR" , js_name = ondevicechange ) ] + #[doc = "Getter for the `ondevicechange` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XR/ondevicechange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Xr`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn ondevicechange(this: &Xr) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XR" , js_name = ondevicechange ) ] + #[doc = "Setter for the `ondevicechange` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XR/ondevicechange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Xr`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_ondevicechange(this: &Xr, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSessionMode")] + # [ wasm_bindgen ( method , structural , js_class = "XR" , js_name = isSessionSupported ) ] + #[doc = "The `isSessionSupported()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XR/isSessionSupported)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Xr`, `XrSessionMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn is_session_supported(this: &Xr, mode: XrSessionMode) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSessionMode")] + # [ wasm_bindgen ( method , structural , js_class = "XR" , js_name = requestSession ) ] + #[doc = "The `requestSession()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XR/requestSession)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Xr`, `XrSessionMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_session(this: &Xr, mode: XrSessionMode) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + #[cfg(all(feature = "XrSessionInit", feature = "XrSessionMode",))] + # [ wasm_bindgen ( method , structural , js_class = "XR" , js_name = requestSession ) ] + #[doc = "The `requestSession()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XR/requestSession)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Xr`, `XrSessionInit`, `XrSessionMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_session_with_options( + this: &Xr, + mode: XrSessionMode, + options: &XrSessionInit, + ) -> ::js_sys::Promise; +} diff --git a/crates/web-sys/src/features/gen_XrBoundedReferenceSpace.rs b/crates/web-sys/src/features/gen_XrBoundedReferenceSpace.rs new file mode 100644 index 00000000000..31ad20e317d --- /dev/null +++ b/crates/web-sys/src/features/gen_XrBoundedReferenceSpace.rs @@ -0,0 +1,29 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = XrReferenceSpace , extends = XrSpace , extends = EventTarget , extends = :: js_sys :: Object , js_name = XRBoundedReferenceSpace , typescript_type = "XRBoundedReferenceSpace" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrBoundedReferenceSpace` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRBoundedReferenceSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrBoundedReferenceSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrBoundedReferenceSpace; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRBoundedReferenceSpace" , js_name = boundsGeometry ) ] + #[doc = "Getter for the `boundsGeometry` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRBoundedReferenceSpace/boundsGeometry)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrBoundedReferenceSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bounds_geometry(this: &XrBoundedReferenceSpace) -> ::js_sys::Array; +} diff --git a/crates/web-sys/src/features/gen_XrEye.rs b/crates/web-sys/src/features/gen_XrEye.rs new file mode 100644 index 00000000000..a09d8100c27 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrEye.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `XrEye` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `XrEye`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum XrEye { + None = "none", + Left = "left", + Right = "right", +} diff --git a/crates/web-sys/src/features/gen_XrFrame.rs b/crates/web-sys/src/features/gen_XrFrame.rs new file mode 100644 index 00000000000..8641b284ed8 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrFrame.rs @@ -0,0 +1,57 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRFrame , typescript_type = "XRFrame" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrFrame` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRFrame)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrFrame; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSession")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRFrame" , js_name = session ) ] + #[doc = "Getter for the `session` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRFrame/session)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn session(this: &XrFrame) -> XrSession; + #[cfg(web_sys_unstable_apis)] + #[cfg(all(feature = "XrPose", feature = "XrSpace",))] + # [ wasm_bindgen ( method , structural , js_class = "XRFrame" , js_name = getPose ) ] + #[doc = "The `getPose()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRFrame/getPose)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrPose`, `XrSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_pose(this: &XrFrame, space: &XrSpace, base_space: &XrSpace) -> Option; + #[cfg(web_sys_unstable_apis)] + #[cfg(all(feature = "XrReferenceSpace", feature = "XrViewerPose",))] + # [ wasm_bindgen ( method , structural , js_class = "XRFrame" , js_name = getViewerPose ) ] + #[doc = "The `getViewerPose()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRFrame/getViewerPose)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrReferenceSpace`, `XrViewerPose`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_viewer_pose( + this: &XrFrame, + reference_space: &XrReferenceSpace, + ) -> Option; +} diff --git a/crates/web-sys/src/features/gen_XrHandedness.rs b/crates/web-sys/src/features/gen_XrHandedness.rs new file mode 100644 index 00000000000..a3095d7b772 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrHandedness.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `XrHandedness` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `XrHandedness`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum XrHandedness { + None = "none", + Left = "left", + Right = "right", +} diff --git a/crates/web-sys/src/features/gen_XrInputSource.rs b/crates/web-sys/src/features/gen_XrInputSource.rs new file mode 100644 index 00000000000..a2ffebaf398 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrInputSource.rs @@ -0,0 +1,77 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRInputSource , typescript_type = "XRInputSource" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrInputSource` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrInputSource; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrHandedness")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSource" , js_name = handedness ) ] + #[doc = "Getter for the `handedness` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/handedness)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrHandedness`, `XrInputSource`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn handedness(this: &XrInputSource) -> XrHandedness; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrTargetRayMode")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSource" , js_name = targetRayMode ) ] + #[doc = "Getter for the `targetRayMode` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/targetRayMode)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`, `XrTargetRayMode`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn target_ray_mode(this: &XrInputSource) -> XrTargetRayMode; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSpace")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSource" , js_name = targetRaySpace ) ] + #[doc = "Getter for the `targetRaySpace` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/targetRaySpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`, `XrSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn target_ray_space(this: &XrInputSource) -> XrSpace; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSpace")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSource" , js_name = gripSpace ) ] + #[doc = "Getter for the `gripSpace` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/gripSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`, `XrSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn grip_space(this: &XrInputSource) -> Option; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSource" , js_name = profiles ) ] + #[doc = "Getter for the `profiles` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource/profiles)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn profiles(this: &XrInputSource) -> ::js_sys::Array; +} diff --git a/crates/web-sys/src/features/gen_XrInputSourceArray.rs b/crates/web-sys/src/features/gen_XrInputSourceArray.rs new file mode 100644 index 00000000000..9f19437425e --- /dev/null +++ b/crates/web-sys/src/features/gen_XrInputSourceArray.rs @@ -0,0 +1,41 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRInputSourceArray , typescript_type = "XRInputSourceArray" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrInputSourceArray` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceArray)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceArray`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrInputSourceArray; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSourceArray" , js_name = length ) ] + #[doc = "Getter for the `length` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceArray/length)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceArray`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn length(this: &XrInputSourceArray) -> u32; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrInputSource")] + #[wasm_bindgen(method, structural, js_class = "XRInputSourceArray", indexing_getter)] + #[doc = "Indexing getter."] + #[doc = ""] + #[doc = ""] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`, `XrInputSourceArray`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get(this: &XrInputSourceArray, index: u32) -> Option; +} diff --git a/crates/web-sys/src/features/gen_XrInputSourceEvent.rs b/crates/web-sys/src/features/gen_XrInputSourceEvent.rs new file mode 100644 index 00000000000..ce4a1d25adc --- /dev/null +++ b/crates/web-sys/src/features/gen_XrInputSourceEvent.rs @@ -0,0 +1,42 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = Event , extends = :: js_sys :: Object , js_name = XRInputSourceEvent , typescript_type = "XRInputSourceEvent" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrInputSourceEvent` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrInputSourceEvent; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrFrame")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSourceEvent" , js_name = frame ) ] + #[doc = "Getter for the `frame` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent/frame)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrInputSourceEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn frame(this: &XrInputSourceEvent) -> XrFrame; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrInputSource")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSourceEvent" , js_name = inputSource ) ] + #[doc = "Getter for the `inputSource` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent/inputSource)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`, `XrInputSourceEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn input_source(this: &XrInputSourceEvent) -> XrInputSource; +} diff --git a/crates/web-sys/src/features/gen_XrInputSourceEventInit.rs b/crates/web-sys/src/features/gen_XrInputSourceEventInit.rs new file mode 100644 index 00000000000..66145eedbb3 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrInputSourceEventInit.rs @@ -0,0 +1,136 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRInputSourceEventInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrInputSourceEventInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrInputSourceEventInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrInputSourceEventInit { + #[cfg(all(feature = "XrFrame", feature = "XrInputSource",))] + #[doc = "Construct a new `XrInputSourceEventInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrInputSource`, `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(frame: &XrFrame, input_source: &XrInputSource) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.frame(frame); + ret.input_source(input_source); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `bubbles` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bubbles(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bubbles"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `cancelable` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cancelable(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("cancelable"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `composed` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn composed(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("composed"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrFrame")] + #[doc = "Change the `frame` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn frame(&mut self, val: &XrFrame) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("frame"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrInputSource")] + #[doc = "Change the `inputSource` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSource`, `XrInputSourceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn input_source(&mut self, val: &XrInputSource) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("inputSource"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_XrInputSourcesChangeEvent.rs b/crates/web-sys/src/features/gen_XrInputSourcesChangeEvent.rs new file mode 100644 index 00000000000..d4ada007318 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrInputSourcesChangeEvent.rs @@ -0,0 +1,52 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = Event , extends = :: js_sys :: Object , js_name = XRInputSourcesChangeEvent , typescript_type = "XRInputSourcesChangeEvent" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrInputSourcesChangeEvent` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourcesChangeEvent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrInputSourcesChangeEvent; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSession")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSourcesChangeEvent" , js_name = session ) ] + #[doc = "Getter for the `session` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourcesChangeEvent/session)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEvent`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn session(this: &XrInputSourcesChangeEvent) -> XrSession; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSourcesChangeEvent" , js_name = added ) ] + #[doc = "Getter for the `added` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourcesChangeEvent/added)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn added(this: &XrInputSourcesChangeEvent) -> ::js_sys::Array; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRInputSourcesChangeEvent" , js_name = removed ) ] + #[doc = "Getter for the `removed` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourcesChangeEvent/removed)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn removed(this: &XrInputSourcesChangeEvent) -> ::js_sys::Array; +} diff --git a/crates/web-sys/src/features/gen_XrInputSourcesChangeEventInit.rs b/crates/web-sys/src/features/gen_XrInputSourcesChangeEventInit.rs new file mode 100644 index 00000000000..374d5f4fbfa --- /dev/null +++ b/crates/web-sys/src/features/gen_XrInputSourcesChangeEventInit.rs @@ -0,0 +1,161 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRInputSourcesChangeEventInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrInputSourcesChangeEventInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrInputSourcesChangeEventInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrInputSourcesChangeEventInit { + #[cfg(feature = "XrSession")] + #[doc = "Construct a new `XrInputSourcesChangeEventInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new( + added: &::wasm_bindgen::JsValue, + removed: &::wasm_bindgen::JsValue, + session: &XrSession, + ) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.added(added); + ret.removed(removed); + ret.session(session); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `bubbles` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bubbles(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bubbles"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `cancelable` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cancelable(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("cancelable"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `composed` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn composed(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("composed"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `added` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn added(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("added"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `removed` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn removed(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("removed"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSession")] + #[doc = "Change the `session` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourcesChangeEventInit`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn session(&mut self, val: &XrSession) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("session"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_XrPose.rs b/crates/web-sys/src/features/gen_XrPose.rs new file mode 100644 index 00000000000..f921fbf96b8 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrPose.rs @@ -0,0 +1,41 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRPose , typescript_type = "XRPose" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrPose` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRPose)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrPose`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrPose; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRigidTransform")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRPose" , js_name = transform ) ] + #[doc = "Getter for the `transform` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRPose/transform)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrPose`, `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn transform(this: &XrPose) -> XrRigidTransform; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRPose" , js_name = emulatedPosition ) ] + #[doc = "Getter for the `emulatedPosition` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRPose/emulatedPosition)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrPose`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn emulated_position(this: &XrPose) -> bool; +} diff --git a/crates/web-sys/src/features/gen_XrReferenceSpace.rs b/crates/web-sys/src/features/gen_XrReferenceSpace.rs new file mode 100644 index 00000000000..618a7beccc5 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrReferenceSpace.rs @@ -0,0 +1,55 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = XrSpace , extends = EventTarget , extends = :: js_sys :: Object , js_name = XRReferenceSpace , typescript_type = "XRReferenceSpace" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrReferenceSpace` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrReferenceSpace; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRReferenceSpace" , js_name = onreset ) ] + #[doc = "Getter for the `onreset` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/onreset)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onreset(this: &XrReferenceSpace) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRReferenceSpace" , js_name = onreset ) ] + #[doc = "Setter for the `onreset` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/onreset)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onreset(this: &XrReferenceSpace, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRigidTransform")] + # [ wasm_bindgen ( method , structural , js_class = "XRReferenceSpace" , js_name = getOffsetReferenceSpace ) ] + #[doc = "The `getOffsetReferenceSpace()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/getOffsetReferenceSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`, `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_offset_reference_space( + this: &XrReferenceSpace, + origin_offset: &XrRigidTransform, + ) -> XrReferenceSpace; +} diff --git a/crates/web-sys/src/features/gen_XrReferenceSpaceEvent.rs b/crates/web-sys/src/features/gen_XrReferenceSpaceEvent.rs new file mode 100644 index 00000000000..2391165a132 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrReferenceSpaceEvent.rs @@ -0,0 +1,42 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = Event , extends = :: js_sys :: Object , js_name = XRReferenceSpaceEvent , typescript_type = "XRReferenceSpaceEvent" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrReferenceSpaceEvent` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceEvent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrReferenceSpaceEvent; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrReferenceSpace")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRReferenceSpaceEvent" , js_name = referenceSpace ) ] + #[doc = "Getter for the `referenceSpace` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceEvent/referenceSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`, `XrReferenceSpaceEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn reference_space(this: &XrReferenceSpaceEvent) -> XrReferenceSpace; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRigidTransform")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRReferenceSpaceEvent" , js_name = transform ) ] + #[doc = "Getter for the `transform` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceEvent/transform)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEvent`, `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn transform(this: &XrReferenceSpaceEvent) -> Option; +} diff --git a/crates/web-sys/src/features/gen_XrReferenceSpaceEventInit.rs b/crates/web-sys/src/features/gen_XrReferenceSpaceEventInit.rs new file mode 100644 index 00000000000..a1f0ff48400 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrReferenceSpaceEventInit.rs @@ -0,0 +1,139 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRReferenceSpaceEventInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrReferenceSpaceEventInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrReferenceSpaceEventInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrReferenceSpaceEventInit { + #[cfg(feature = "XrReferenceSpace")] + #[doc = "Construct a new `XrReferenceSpaceEventInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`, `XrReferenceSpaceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(reference_space: &XrReferenceSpace) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.reference_space(reference_space); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `bubbles` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bubbles(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bubbles"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `cancelable` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cancelable(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("cancelable"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `composed` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn composed(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("composed"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrReferenceSpace")] + #[doc = "Change the `referenceSpace` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpace`, `XrReferenceSpaceEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn reference_space(&mut self, val: &XrReferenceSpace) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("referenceSpace"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRigidTransform")] + #[doc = "Change the `transform` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceEventInit`, `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn transform(&mut self, val: &XrRigidTransform) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("transform"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_XrReferenceSpaceType.rs b/crates/web-sys/src/features/gen_XrReferenceSpaceType.rs new file mode 100644 index 00000000000..6801e0f0130 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrReferenceSpaceType.rs @@ -0,0 +1,18 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `XrReferenceSpaceType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum XrReferenceSpaceType { + Viewer = "viewer", + Local = "local", + LocalFloor = "local-floor", + BoundedFloor = "bounded-floor", + Unbounded = "unbounded", +} diff --git a/crates/web-sys/src/features/gen_XrRenderState.rs b/crates/web-sys/src/features/gen_XrRenderState.rs new file mode 100644 index 00000000000..0d4a6b0378a --- /dev/null +++ b/crates/web-sys/src/features/gen_XrRenderState.rs @@ -0,0 +1,63 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRRenderState , typescript_type = "XRRenderState" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrRenderState` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRenderState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrRenderState; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRenderState" , js_name = depthNear ) ] + #[doc = "Getter for the `depthNear` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRenderState/depthNear)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_near(this: &XrRenderState) -> f64; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRenderState" , js_name = depthFar ) ] + #[doc = "Getter for the `depthFar` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRenderState/depthFar)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_far(this: &XrRenderState) -> f64; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRenderState" , js_name = inlineVerticalFieldOfView ) ] + #[doc = "Getter for the `inlineVerticalFieldOfView` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRenderState/inlineVerticalFieldOfView)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn inline_vertical_field_of_view(this: &XrRenderState) -> Option; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrWebGlLayer")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRenderState" , js_name = baseLayer ) ] + #[doc = "Getter for the `baseLayer` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRenderState/baseLayer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderState`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn base_layer(this: &XrRenderState) -> Option; +} diff --git a/crates/web-sys/src/features/gen_XrRenderStateInit.rs b/crates/web-sys/src/features/gen_XrRenderStateInit.rs new file mode 100644 index 00000000000..36566e4cc69 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrRenderStateInit.rs @@ -0,0 +1,115 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRRenderStateInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrRenderStateInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrRenderStateInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrRenderStateInit { + #[doc = "Construct a new `XrRenderStateInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrWebGlLayer")] + #[doc = "Change the `baseLayer` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn base_layer(&mut self, val: Option<&XrWebGlLayer>) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("baseLayer"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `depthFar` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_far(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthFar"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `depthNear` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth_near(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("depthNear"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `inlineVerticalFieldOfView` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn inline_vertical_field_of_view(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("inlineVerticalFieldOfView"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_XrRigidTransform.rs b/crates/web-sys/src/features/gen_XrRigidTransform.rs new file mode 100644 index 00000000000..43785322597 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrRigidTransform.rs @@ -0,0 +1,64 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRRigidTransform , typescript_type = "XRRigidTransform" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrRigidTransform` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRigidTransform)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrRigidTransform; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "DomPointReadOnly")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRigidTransform" , js_name = position ) ] + #[doc = "Getter for the `position` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRigidTransform/position)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `DomPointReadOnly`, `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn position(this: &XrRigidTransform) -> DomPointReadOnly; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "DomPointReadOnly")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRigidTransform" , js_name = orientation ) ] + #[doc = "Getter for the `orientation` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRigidTransform/orientation)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `DomPointReadOnly`, `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn orientation(this: &XrRigidTransform) -> DomPointReadOnly; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRigidTransform" , js_name = matrix ) ] + #[doc = "Getter for the `matrix` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRigidTransform/matrix)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn matrix(this: &XrRigidTransform) -> Vec; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRRigidTransform" , js_name = inverse ) ] + #[doc = "Getter for the `inverse` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRRigidTransform/inverse)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRigidTransform`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn inverse(this: &XrRigidTransform) -> XrRigidTransform; +} diff --git a/crates/web-sys/src/features/gen_XrSession.rs b/crates/web-sys/src/features/gen_XrSession.rs new file mode 100644 index 00000000000..255446b972b --- /dev/null +++ b/crates/web-sys/src/features/gen_XrSession.rs @@ -0,0 +1,257 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = EventTarget , extends = :: js_sys :: Object , js_name = XRSession , typescript_type = "XRSession" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrSession` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrSession; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrVisibilityState")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = visibilityState ) ] + #[doc = "Getter for the `visibilityState` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/visibilityState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`, `XrVisibilityState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn visibility_state(this: &XrSession) -> XrVisibilityState; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRenderState")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = renderState ) ] + #[doc = "Getter for the `renderState` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/renderState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderState`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn render_state(this: &XrSession) -> XrRenderState; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrInputSourceArray")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = inputSources ) ] + #[doc = "Getter for the `inputSources` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/inputSources)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrInputSourceArray`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn input_sources(this: &XrSession) -> XrInputSourceArray; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = onend ) ] + #[doc = "Getter for the `onend` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onend)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onend(this: &XrSession) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRSession" , js_name = onend ) ] + #[doc = "Setter for the `onend` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onend)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onend(this: &XrSession, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = onselect ) ] + #[doc = "Getter for the `onselect` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onselect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onselect(this: &XrSession) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRSession" , js_name = onselect ) ] + #[doc = "Setter for the `onselect` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onselect)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onselect(this: &XrSession, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = oninputsourceschange ) ] + #[doc = "Getter for the `oninputsourceschange` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/oninputsourceschange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn oninputsourceschange(this: &XrSession) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRSession" , js_name = oninputsourceschange ) ] + #[doc = "Setter for the `oninputsourceschange` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/oninputsourceschange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_oninputsourceschange(this: &XrSession, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = onselectstart ) ] + #[doc = "Getter for the `onselectstart` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onselectstart)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onselectstart(this: &XrSession) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRSession" , js_name = onselectstart ) ] + #[doc = "Setter for the `onselectstart` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onselectstart)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onselectstart(this: &XrSession, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = onselectend ) ] + #[doc = "Getter for the `onselectend` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onselectend)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onselectend(this: &XrSession) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRSession" , js_name = onselectend ) ] + #[doc = "Setter for the `onselectend` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onselectend)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onselectend(this: &XrSession, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSession" , js_name = onvisibilitychange ) ] + #[doc = "Getter for the `onvisibilitychange` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onvisibilitychange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onvisibilitychange(this: &XrSession) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , setter , js_class = "XRSession" , js_name = onvisibilitychange ) ] + #[doc = "Setter for the `onvisibilitychange` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/onvisibilitychange)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onvisibilitychange(this: &XrSession, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( method , structural , js_class = "XRSession" , js_name = cancelAnimationFrame ) ] + #[doc = "The `cancelAnimationFrame()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/cancelAnimationFrame)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cancel_animation_frame(this: &XrSession, handle: i32); + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( method , structural , js_class = "XRSession" , js_name = end ) ] + #[doc = "The `end()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/end)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn end(this: &XrSession) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( method , structural , js_class = "XRSession" , js_name = requestAnimationFrame ) ] + #[doc = "The `requestAnimationFrame()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/requestAnimationFrame)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_animation_frame(this: &XrSession, callback: &::js_sys::Function) -> i32; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrReferenceSpaceType")] + # [ wasm_bindgen ( method , structural , js_class = "XRSession" , js_name = requestReferenceSpace ) ] + #[doc = "The `requestReferenceSpace()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/requestReferenceSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrReferenceSpaceType`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request_reference_space( + this: &XrSession, + type_: XrReferenceSpaceType, + ) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( method , structural , js_class = "XRSession" , js_name = updateRenderState ) ] + #[doc = "The `updateRenderState()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/updateRenderState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn update_render_state(this: &XrSession); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRenderStateInit")] + # [ wasm_bindgen ( method , structural , js_class = "XRSession" , js_name = updateRenderState ) ] + #[doc = "The `updateRenderState()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSession/updateRenderState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRenderStateInit`, `XrSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn update_render_state_with_state(this: &XrSession, state: &XrRenderStateInit); +} diff --git a/crates/web-sys/src/features/gen_XrSessionEvent.rs b/crates/web-sys/src/features/gen_XrSessionEvent.rs new file mode 100644 index 00000000000..931d43312e9 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrSessionEvent.rs @@ -0,0 +1,30 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = Event , extends = :: js_sys :: Object , js_name = XRSessionEvent , typescript_type = "XRSessionEvent" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrSessionEvent` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSessionEvent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrSessionEvent; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSession")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRSessionEvent" , js_name = session ) ] + #[doc = "Getter for the `session` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSessionEvent/session)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`, `XrSessionEvent`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn session(this: &XrSessionEvent) -> XrSession; +} diff --git a/crates/web-sys/src/features/gen_XrSessionEventInit.rs b/crates/web-sys/src/features/gen_XrSessionEventInit.rs new file mode 100644 index 00000000000..44c36dc3a19 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrSessionEventInit.rs @@ -0,0 +1,117 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRSessionEventInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrSessionEventInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrSessionEventInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrSessionEventInit { + #[cfg(feature = "XrSession")] + #[doc = "Construct a new `XrSessionEventInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`, `XrSessionEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(session: &XrSession) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.session(session); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `bubbles` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn bubbles(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("bubbles"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `cancelable` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn cancelable(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("cancelable"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `composed` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn composed(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("composed"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSession")] + #[doc = "Change the `session` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`, `XrSessionEventInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn session(&mut self, val: &XrSession) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("session"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_XrSessionInit.rs b/crates/web-sys/src/features/gen_XrSessionInit.rs new file mode 100644 index 00000000000..e4b10edd517 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrSessionInit.rs @@ -0,0 +1,72 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRSessionInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrSessionInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrSessionInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrSessionInit { + #[doc = "Construct a new `XrSessionInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `optionalFeatures` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn optional_features(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("optionalFeatures"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `requiredFeatures` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSessionInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn required_features(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("requiredFeatures"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_XrSessionMode.rs b/crates/web-sys/src/features/gen_XrSessionMode.rs new file mode 100644 index 00000000000..c4bdc89b7a8 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrSessionMode.rs @@ -0,0 +1,15 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `XrSessionMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `XrSessionMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum XrSessionMode { + Inline = "inline", + ImmersiveVr = "immersive-vr", +} diff --git a/crates/web-sys/src/features/gen_XrSpace.rs b/crates/web-sys/src/features/gen_XrSpace.rs new file mode 100644 index 00000000000..1a774775458 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrSpace.rs @@ -0,0 +1,18 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = EventTarget , extends = :: js_sys :: Object , js_name = XRSpace , typescript_type = "XRSpace" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrSpace` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRSpace)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSpace`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrSpace; +} diff --git a/crates/web-sys/src/features/gen_XrTargetRayMode.rs b/crates/web-sys/src/features/gen_XrTargetRayMode.rs new file mode 100644 index 00000000000..94b59335f0a --- /dev/null +++ b/crates/web-sys/src/features/gen_XrTargetRayMode.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `XrTargetRayMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `XrTargetRayMode`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum XrTargetRayMode { + Gaze = "gaze", + TrackedPointer = "tracked-pointer", + Screen = "screen", +} diff --git a/crates/web-sys/src/features/gen_XrView.rs b/crates/web-sys/src/features/gen_XrView.rs new file mode 100644 index 00000000000..b3cd87c689b --- /dev/null +++ b/crates/web-sys/src/features/gen_XrView.rs @@ -0,0 +1,53 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRView , typescript_type = "XRView" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrView` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRView)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrView; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrEye")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRView" , js_name = eye ) ] + #[doc = "Getter for the `eye` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRView/eye)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrEye`, `XrView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn eye(this: &XrView) -> XrEye; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRView" , js_name = projectionMatrix ) ] + #[doc = "Getter for the `projectionMatrix` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRView/projectionMatrix)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn projection_matrix(this: &XrView) -> Vec; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrRigidTransform")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRView" , js_name = transform ) ] + #[doc = "Getter for the `transform` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRView/transform)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrRigidTransform`, `XrView`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn transform(this: &XrView) -> XrRigidTransform; +} diff --git a/crates/web-sys/src/features/gen_XrViewerPose.rs b/crates/web-sys/src/features/gen_XrViewerPose.rs new file mode 100644 index 00000000000..f5fbbeaa20b --- /dev/null +++ b/crates/web-sys/src/features/gen_XrViewerPose.rs @@ -0,0 +1,29 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = XrPose , extends = :: js_sys :: Object , js_name = XRViewerPose , typescript_type = "XRViewerPose" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrViewerPose` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewerPose)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewerPose`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrViewerPose; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRViewerPose" , js_name = views ) ] + #[doc = "Getter for the `views` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewerPose/views)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewerPose`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn views(this: &XrViewerPose) -> ::js_sys::Array; +} diff --git a/crates/web-sys/src/features/gen_XrViewport.rs b/crates/web-sys/src/features/gen_XrViewport.rs new file mode 100644 index 00000000000..53b32e22eff --- /dev/null +++ b/crates/web-sys/src/features/gen_XrViewport.rs @@ -0,0 +1,62 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRViewport , typescript_type = "XRViewport" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrViewport` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewport)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewport`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrViewport; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRViewport" , js_name = x ) ] + #[doc = "Getter for the `x` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewport/x)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewport`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn x(this: &XrViewport) -> i32; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRViewport" , js_name = y ) ] + #[doc = "Getter for the `y` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewport/y)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewport`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn y(this: &XrViewport) -> i32; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRViewport" , js_name = width ) ] + #[doc = "Getter for the `width` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewport/width)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewport`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn width(this: &XrViewport) -> i32; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRViewport" , js_name = height ) ] + #[doc = "Getter for the `height` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRViewport/height)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrViewport`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn height(this: &XrViewport) -> i32; +} diff --git a/crates/web-sys/src/features/gen_XrVisibilityState.rs b/crates/web-sys/src/features/gen_XrVisibilityState.rs new file mode 100644 index 00000000000..f82ab22a974 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrVisibilityState.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `XrVisibilityState` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `XrVisibilityState`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum XrVisibilityState { + Visible = "visible", + VisibleBlurred = "visible-blurred", + Hidden = "hidden", +} diff --git a/crates/web-sys/src/features/gen_XrWebGlLayer.rs b/crates/web-sys/src/features/gen_XrWebGlLayer.rs new file mode 100644 index 00000000000..b0a7bc531c4 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrWebGlLayer.rs @@ -0,0 +1,168 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRWebGLLayer , typescript_type = "XRWebGLLayer" ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrWebGlLayer` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrWebGlLayer; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRWebGLLayer" , js_name = antialias ) ] + #[doc = "Getter for the `antialias` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/antialias)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn antialias(this: &XrWebGlLayer) -> bool; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRWebGLLayer" , js_name = ignoreDepthValues ) ] + #[doc = "Getter for the `ignoreDepthValues` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/ignoreDepthValues)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn ignore_depth_values(this: &XrWebGlLayer) -> bool; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "WebGlFramebuffer")] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRWebGLLayer" , js_name = framebuffer ) ] + #[doc = "Getter for the `framebuffer` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/framebuffer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGlFramebuffer`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn framebuffer(this: &XrWebGlLayer) -> WebGlFramebuffer; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRWebGLLayer" , js_name = framebufferWidth ) ] + #[doc = "Getter for the `framebufferWidth` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/framebufferWidth)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn framebuffer_width(this: &XrWebGlLayer) -> u32; + #[cfg(web_sys_unstable_apis)] + # [ wasm_bindgen ( structural , method , getter , js_class = "XRWebGLLayer" , js_name = framebufferHeight ) ] + #[doc = "Getter for the `framebufferHeight` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/framebufferHeight)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn framebuffer_height(this: &XrWebGlLayer) -> u32; + #[cfg(web_sys_unstable_apis)] + #[cfg(all(feature = "WebGlRenderingContext", feature = "XrSession",))] + #[wasm_bindgen(catch, constructor, js_class = "XRWebGLLayer")] + #[doc = "The `new XrWebGlLayer(..)` constructor, creating a new instance of `XrWebGlLayer`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/XRWebGLLayer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGlRenderingContext`, `XrSession`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new_with_web_gl_rendering_context( + session: &XrSession, + context: &WebGlRenderingContext, + ) -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(all(feature = "WebGl2RenderingContext", feature = "XrSession",))] + #[wasm_bindgen(catch, constructor, js_class = "XRWebGLLayer")] + #[doc = "The `new XrWebGlLayer(..)` constructor, creating a new instance of `XrWebGlLayer`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/XRWebGLLayer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGl2RenderingContext`, `XrSession`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new_with_web_gl2_rendering_context( + session: &XrSession, + context: &WebGl2RenderingContext, + ) -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(all( + feature = "WebGlRenderingContext", + feature = "XrSession", + feature = "XrWebGlLayerInit", + ))] + #[wasm_bindgen(catch, constructor, js_class = "XRWebGLLayer")] + #[doc = "The `new XrWebGlLayer(..)` constructor, creating a new instance of `XrWebGlLayer`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/XRWebGLLayer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGlRenderingContext`, `XrSession`, `XrWebGlLayer`, `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new_with_web_gl_rendering_context_and_layer_init( + session: &XrSession, + context: &WebGlRenderingContext, + layer_init: &XrWebGlLayerInit, + ) -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(all( + feature = "WebGl2RenderingContext", + feature = "XrSession", + feature = "XrWebGlLayerInit", + ))] + #[wasm_bindgen(catch, constructor, js_class = "XRWebGLLayer")] + #[doc = "The `new XrWebGlLayer(..)` constructor, creating a new instance of `XrWebGlLayer`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/XRWebGLLayer)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WebGl2RenderingContext`, `XrSession`, `XrWebGlLayer`, `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new_with_web_gl2_rendering_context_and_layer_init( + session: &XrSession, + context: &WebGl2RenderingContext, + layer_init: &XrWebGlLayerInit, + ) -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "XrSession")] + # [ wasm_bindgen ( static_method_of = XrWebGlLayer , js_class = "XRWebGLLayer" , js_name = getNativeFramebufferScaleFactor ) ] + #[doc = "The `getNativeFramebufferScaleFactor()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/getNativeFramebufferScaleFactor)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrSession`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_native_framebuffer_scale_factor(session: &XrSession) -> f64; + #[cfg(web_sys_unstable_apis)] + #[cfg(all(feature = "XrView", feature = "XrViewport",))] + # [ wasm_bindgen ( method , structural , js_class = "XRWebGLLayer" , js_name = getViewport ) ] + #[doc = "The `getViewport()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/getViewport)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrView`, `XrViewport`, `XrWebGlLayer`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn get_viewport(this: &XrWebGlLayer, view: &XrView) -> Option; +} diff --git a/crates/web-sys/src/features/gen_XrWebGlLayerInit.rs b/crates/web-sys/src/features/gen_XrWebGlLayerInit.rs new file mode 100644 index 00000000000..b233d100600 --- /dev/null +++ b/crates/web-sys/src/features/gen_XrWebGlLayerInit.rs @@ -0,0 +1,148 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = XRWebGLLayerInit ) ] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `XrWebGlLayerInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type XrWebGlLayerInit; +} +#[cfg(web_sys_unstable_apis)] +impl XrWebGlLayerInit { + #[doc = "Construct a new `XrWebGlLayerInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `alpha` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn alpha(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("alpha"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `antialias` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn antialias(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("antialias"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `depth` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn depth(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("depth"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `framebufferScaleFactor` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn framebuffer_scale_factor(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("framebufferScaleFactor"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `ignoreDepthValues` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn ignore_depth_values(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("ignoreDepthValues"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `stencil` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `XrWebGlLayerInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn stencil(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("stencil"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index 183ec46ae3d..164b43e9617 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -7588,6 +7588,198 @@ mod gen_XmlSerializer; #[cfg(feature = "XmlSerializer")] pub use gen_XmlSerializer::*; +#[cfg(feature = "Xr")] +#[allow(non_snake_case)] +mod gen_Xr; +#[cfg(feature = "Xr")] +pub use gen_Xr::*; + +#[cfg(feature = "XrBoundedReferenceSpace")] +#[allow(non_snake_case)] +mod gen_XrBoundedReferenceSpace; +#[cfg(feature = "XrBoundedReferenceSpace")] +pub use gen_XrBoundedReferenceSpace::*; + +#[cfg(feature = "XrEye")] +#[allow(non_snake_case)] +mod gen_XrEye; +#[cfg(feature = "XrEye")] +pub use gen_XrEye::*; + +#[cfg(feature = "XrFrame")] +#[allow(non_snake_case)] +mod gen_XrFrame; +#[cfg(feature = "XrFrame")] +pub use gen_XrFrame::*; + +#[cfg(feature = "XrHandedness")] +#[allow(non_snake_case)] +mod gen_XrHandedness; +#[cfg(feature = "XrHandedness")] +pub use gen_XrHandedness::*; + +#[cfg(feature = "XrInputSource")] +#[allow(non_snake_case)] +mod gen_XrInputSource; +#[cfg(feature = "XrInputSource")] +pub use gen_XrInputSource::*; + +#[cfg(feature = "XrInputSourceArray")] +#[allow(non_snake_case)] +mod gen_XrInputSourceArray; +#[cfg(feature = "XrInputSourceArray")] +pub use gen_XrInputSourceArray::*; + +#[cfg(feature = "XrInputSourceEvent")] +#[allow(non_snake_case)] +mod gen_XrInputSourceEvent; +#[cfg(feature = "XrInputSourceEvent")] +pub use gen_XrInputSourceEvent::*; + +#[cfg(feature = "XrInputSourceEventInit")] +#[allow(non_snake_case)] +mod gen_XrInputSourceEventInit; +#[cfg(feature = "XrInputSourceEventInit")] +pub use gen_XrInputSourceEventInit::*; + +#[cfg(feature = "XrInputSourcesChangeEvent")] +#[allow(non_snake_case)] +mod gen_XrInputSourcesChangeEvent; +#[cfg(feature = "XrInputSourcesChangeEvent")] +pub use gen_XrInputSourcesChangeEvent::*; + +#[cfg(feature = "XrInputSourcesChangeEventInit")] +#[allow(non_snake_case)] +mod gen_XrInputSourcesChangeEventInit; +#[cfg(feature = "XrInputSourcesChangeEventInit")] +pub use gen_XrInputSourcesChangeEventInit::*; + +#[cfg(feature = "XrPose")] +#[allow(non_snake_case)] +mod gen_XrPose; +#[cfg(feature = "XrPose")] +pub use gen_XrPose::*; + +#[cfg(feature = "XrReferenceSpace")] +#[allow(non_snake_case)] +mod gen_XrReferenceSpace; +#[cfg(feature = "XrReferenceSpace")] +pub use gen_XrReferenceSpace::*; + +#[cfg(feature = "XrReferenceSpaceEvent")] +#[allow(non_snake_case)] +mod gen_XrReferenceSpaceEvent; +#[cfg(feature = "XrReferenceSpaceEvent")] +pub use gen_XrReferenceSpaceEvent::*; + +#[cfg(feature = "XrReferenceSpaceEventInit")] +#[allow(non_snake_case)] +mod gen_XrReferenceSpaceEventInit; +#[cfg(feature = "XrReferenceSpaceEventInit")] +pub use gen_XrReferenceSpaceEventInit::*; + +#[cfg(feature = "XrReferenceSpaceType")] +#[allow(non_snake_case)] +mod gen_XrReferenceSpaceType; +#[cfg(feature = "XrReferenceSpaceType")] +pub use gen_XrReferenceSpaceType::*; + +#[cfg(feature = "XrRenderState")] +#[allow(non_snake_case)] +mod gen_XrRenderState; +#[cfg(feature = "XrRenderState")] +pub use gen_XrRenderState::*; + +#[cfg(feature = "XrRenderStateInit")] +#[allow(non_snake_case)] +mod gen_XrRenderStateInit; +#[cfg(feature = "XrRenderStateInit")] +pub use gen_XrRenderStateInit::*; + +#[cfg(feature = "XrRigidTransform")] +#[allow(non_snake_case)] +mod gen_XrRigidTransform; +#[cfg(feature = "XrRigidTransform")] +pub use gen_XrRigidTransform::*; + +#[cfg(feature = "XrSession")] +#[allow(non_snake_case)] +mod gen_XrSession; +#[cfg(feature = "XrSession")] +pub use gen_XrSession::*; + +#[cfg(feature = "XrSessionEvent")] +#[allow(non_snake_case)] +mod gen_XrSessionEvent; +#[cfg(feature = "XrSessionEvent")] +pub use gen_XrSessionEvent::*; + +#[cfg(feature = "XrSessionEventInit")] +#[allow(non_snake_case)] +mod gen_XrSessionEventInit; +#[cfg(feature = "XrSessionEventInit")] +pub use gen_XrSessionEventInit::*; + +#[cfg(feature = "XrSessionInit")] +#[allow(non_snake_case)] +mod gen_XrSessionInit; +#[cfg(feature = "XrSessionInit")] +pub use gen_XrSessionInit::*; + +#[cfg(feature = "XrSessionMode")] +#[allow(non_snake_case)] +mod gen_XrSessionMode; +#[cfg(feature = "XrSessionMode")] +pub use gen_XrSessionMode::*; + +#[cfg(feature = "XrSpace")] +#[allow(non_snake_case)] +mod gen_XrSpace; +#[cfg(feature = "XrSpace")] +pub use gen_XrSpace::*; + +#[cfg(feature = "XrTargetRayMode")] +#[allow(non_snake_case)] +mod gen_XrTargetRayMode; +#[cfg(feature = "XrTargetRayMode")] +pub use gen_XrTargetRayMode::*; + +#[cfg(feature = "XrView")] +#[allow(non_snake_case)] +mod gen_XrView; +#[cfg(feature = "XrView")] +pub use gen_XrView::*; + +#[cfg(feature = "XrViewerPose")] +#[allow(non_snake_case)] +mod gen_XrViewerPose; +#[cfg(feature = "XrViewerPose")] +pub use gen_XrViewerPose::*; + +#[cfg(feature = "XrViewport")] +#[allow(non_snake_case)] +mod gen_XrViewport; +#[cfg(feature = "XrViewport")] +pub use gen_XrViewport::*; + +#[cfg(feature = "XrVisibilityState")] +#[allow(non_snake_case)] +mod gen_XrVisibilityState; +#[cfg(feature = "XrVisibilityState")] +pub use gen_XrVisibilityState::*; + +#[cfg(feature = "XrWebGlLayer")] +#[allow(non_snake_case)] +mod gen_XrWebGlLayer; +#[cfg(feature = "XrWebGlLayer")] +pub use gen_XrWebGlLayer::*; + +#[cfg(feature = "XrWebGlLayerInit")] +#[allow(non_snake_case)] +mod gen_XrWebGlLayerInit; +#[cfg(feature = "XrWebGlLayerInit")] +pub use gen_XrWebGlLayerInit::*; + #[cfg(feature = "XsltProcessor")] #[allow(non_snake_case)] mod gen_XsltProcessor; diff --git a/crates/web-sys/webidls/unstable/WebXRDevice.webidl b/crates/web-sys/webidls/unstable/WebXRDevice.webidl new file mode 100644 index 00000000000..bb81ef2f0cb --- /dev/null +++ b/crates/web-sys/webidls/unstable/WebXRDevice.webidl @@ -0,0 +1,283 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * WebXR Device API + * W3C Working Draft, 10 October 2019 + * The origin of this IDL file is: + * https://www.w3.org/TR/2019/WD-webxr-20191010/ + */ + +partial interface Navigator { + [SecureContext, SameObject] readonly attribute XR xr; +}; + +[SecureContext, Exposed=Window] interface XR : EventTarget { + // Methods + Promise isSessionSupported(XRSessionMode mode); + [NewObject] Promise requestSession(XRSessionMode mode, optional XRSessionInit options = {}); + + // Events + attribute EventHandler ondevicechange; +}; + +enum XRSessionMode { + "inline", + "immersive-vr" +}; + +dictionary XRSessionInit { + sequence requiredFeatures; + sequence optionalFeatures; +}; + +enum XRVisibilityState { + "visible", + "visible-blurred", + "hidden", +}; + +[SecureContext, Exposed=Window] interface XRSession : EventTarget { + // Attributes + readonly attribute XRVisibilityState visibilityState; + [SameObject] readonly attribute XRRenderState renderState; + [SameObject] readonly attribute XRInputSourceArray inputSources; + + // Methods + void updateRenderState(optional XRRenderStateInit state = {}); + [NewObject] Promise requestReferenceSpace(XRReferenceSpaceType type); + + long requestAnimationFrame(XRFrameRequestCallback callback); + void cancelAnimationFrame(long handle); + + Promise end(); + + // Events + attribute EventHandler onend; + attribute EventHandler onselect; + attribute EventHandler oninputsourceschange; + attribute EventHandler onselectstart; + attribute EventHandler onselectend; + attribute EventHandler onvisibilitychange; +}; + +dictionary XRRenderStateInit { + double depthNear; + double depthFar; + double inlineVerticalFieldOfView; + XRWebGLLayer? baseLayer; +}; + +[SecureContext, Exposed=Window] interface XRRenderState { + readonly attribute double depthNear; + readonly attribute double depthFar; + readonly attribute double? inlineVerticalFieldOfView; + readonly attribute XRWebGLLayer? baseLayer; +}; + +callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame); + +[SecureContext, Exposed=Window] interface XRFrame { + [SameObject] readonly attribute XRSession session; + + XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace); + XRPose? getPose(XRSpace space, XRSpace baseSpace); +}; + +[SecureContext, Exposed=Window] interface XRSpace : EventTarget { + +}; + +enum XRReferenceSpaceType { + "viewer", + "local", + "local-floor", + "bounded-floor", + "unbounded" +}; + +[SecureContext, Exposed=Window] +interface XRReferenceSpace : XRSpace { + [NewObject] XRReferenceSpace getOffsetReferenceSpace(XRRigidTransform originOffset); + + attribute EventHandler onreset; +}; + +[SecureContext, Exposed=Window] +interface XRBoundedReferenceSpace : XRReferenceSpace { + // TODO: Re-enable FrozenArray when supported. See https://bugzilla.mozilla.org/show_bug.cgi?id=1236777 + //readonly attribute FrozenArray boundsGeometry; + [Frozen, Cached, Pure] + readonly attribute sequence boundsGeometry; +}; + +enum XREye { + "none", + "left", + "right" +}; + +[SecureContext, Exposed=Window] interface XRView { + readonly attribute XREye eye; + readonly attribute Float32Array projectionMatrix; + [SameObject] readonly attribute XRRigidTransform transform; +}; + +[SecureContext, Exposed=Window] interface XRViewport { + readonly attribute long x; + readonly attribute long y; + readonly attribute long width; + readonly attribute long height; +}; + +[SecureContext, Exposed=Window] +interface XRRigidTransform { + constructor(optional DOMPointInit position = {}, optional DOMPointInit orientation = {}); + [SameObject] readonly attribute DOMPointReadOnly position; + [SameObject] readonly attribute DOMPointReadOnly orientation; + readonly attribute Float32Array matrix; + [SameObject] readonly attribute XRRigidTransform inverse; +}; + +[SecureContext, Exposed=Window] interface XRPose { + [SameObject] readonly attribute XRRigidTransform transform; + readonly attribute boolean emulatedPosition; +}; + +[SecureContext, Exposed=Window] interface XRViewerPose : XRPose { + // TODO: Re-enable FrozenArray when supported. See https://bugzilla.mozilla.org/show_bug.cgi?id=1236777 + //[SameObject] readonly attribute FrozenArray views; + [SameObject, Frozen, Cached, Pure] + readonly attribute sequence views; +}; + +enum XRHandedness { + "none", + "left", + "right" +}; + +enum XRTargetRayMode { + "gaze", + "tracked-pointer", + "screen" +}; + +[SecureContext, Exposed=Window] +interface XRInputSource { + readonly attribute XRHandedness handedness; + readonly attribute XRTargetRayMode targetRayMode; + [SameObject] readonly attribute XRSpace targetRaySpace; + [SameObject] readonly attribute XRSpace? gripSpace; + // TODO: Re-enable FrozenArray when supported. See https://bugzilla.mozilla.org/show_bug.cgi?id=1236777 + //[SameObject] readonly attribute FrozenArray profiles; + [SameObject, Frozen, Cached, Pure] + readonly attribute sequence profiles; +}; + +[SecureContext, Exposed=Window] +interface XRInputSourceArray { + iterable; + readonly attribute unsigned long length; + getter XRInputSource(unsigned long index); +}; + +typedef (WebGLRenderingContext or + WebGL2RenderingContext) XRWebGLRenderingContext; + +dictionary XRWebGLLayerInit { + boolean antialias = true; + boolean depth = true; + boolean stencil = false; + boolean alpha = true; + boolean ignoreDepthValues = false; + double framebufferScaleFactor = 1.0; +}; + +// TODO: Change constructor back to original webidl +// [SecureContext, Exposed=Window] +[SecureContext, Exposed=Window, Constructor(XRSession session, XRWebGLRenderingContext context, optional XRWebGLLayerInit layerInit = {})] +interface XRWebGLLayer { + //constructor(XRSession session, + // XRWebGLRenderingContext context, + // optional XRWebGLLayerInit layerInit = {}); + + // Attributes + readonly attribute boolean antialias; + readonly attribute boolean ignoreDepthValues; + + [SameObject] readonly attribute WebGLFramebuffer framebuffer; + readonly attribute unsigned long framebufferWidth; + readonly attribute unsigned long framebufferHeight; + + // Methods + XRViewport? getViewport(XRView view); + + // Static Methods + static double getNativeFramebufferScaleFactor(XRSession session); +}; + +partial dictionary WebGLContextAttributes { + boolean xrCompatible = null; +}; + +partial interface mixin WebGLRenderingContextBase { + Promise makeXRCompatible(); +}; + +[SecureContext, Exposed=Window] +interface XRSessionEvent : Event { + constructor(DOMString type, XRSessionEventInit eventInitDict); + [SameObject] readonly attribute XRSession session; +}; + +dictionary XRSessionEventInit : EventInit { + required XRSession session; +}; + +[SecureContext, Exposed=Window] +interface XRInputSourceEvent : Event { + constructor(DOMString type, XRInputSourceEventInit eventInitDict); + [SameObject] readonly attribute XRFrame frame; + [SameObject] readonly attribute XRInputSource inputSource; +}; + +dictionary XRInputSourceEventInit : EventInit { + required XRFrame frame; + required XRInputSource inputSource; +}; + +[SecureContext, Exposed=Window] +interface XRInputSourcesChangeEvent : Event { + constructor(DOMString type, XRInputSourcesChangeEventInit eventInitDict); + [SameObject] readonly attribute XRSession session; + // TODO: Re-enable FrozenArray when supported. See https://bugzilla.mozilla.org/show_bug.cgi?id=1236777 + //[SameObject] readonly attribute FrozenArray added; + [SameObject, Frozen, Cached, Pure] + readonly attribute sequence added; + //[SameObject] readonly attribute FrozenArray removed; + [SameObject, Frozen, Cached, Pure] + readonly attribute sequence removed; +}; + +dictionary XRInputSourcesChangeEventInit : EventInit { + required XRSession session; + // TODO: Re-enable FrozenArray when supported. See https://bugzilla.mozilla.org/show_bug.cgi?id=1236777 + //required FrozenArray added; + [Frozen, Cached, Pure] + required sequence added; + //required FrozenArray removed; + [Frozen, Cached, Pure] + required sequence removed; + +}; + +[SecureContext, Exposed=Window] +interface XRReferenceSpaceEvent : Event { + constructor(DOMString type, XRReferenceSpaceEventInit eventInitDict); + [SameObject] readonly attribute XRReferenceSpace referenceSpace; + [SameObject] readonly attribute XRRigidTransform? transform; +}; + +dictionary XRReferenceSpaceEventInit : EventInit { + required XRReferenceSpace referenceSpace; + XRRigidTransform transform; +}; diff --git a/examples/webxr/Cargo.toml b/examples/webxr/Cargo.toml new file mode 100644 index 00000000000..00de3d1738b --- /dev/null +++ b/examples/webxr/Cargo.toml @@ -0,0 +1,72 @@ +[package] +name = "webxr" +version = "0.1.0" +authors = ["The wasm-bindgen Developers"] +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +futures = "0.3.4" +js-sys = "0.3.36" +wasm-bindgen = {version = "0.2.59", features = ["serde-serialize"]} +wasm-bindgen-futures = "0.4.9" +serde = { version = "1.0.80", features = ["derive"] } +serde_derive = "^1.0.59" + +[dependencies.web-sys] +version = "0.3.36" +features = [ + 'Document', + 'Element', + 'Gpu', + 'Headers', + 'HtmlCanvasElement', + 'Navigator', + 'Request', + 'RequestInit', + 'RequestMode', + 'Response', + 'WebGl2RenderingContext', + 'Window', + 'Xr', + 'XrBoundedReferenceSpace', + 'XrEye', + 'XrFrame', + 'XrHandedness', + 'XrInputSource', + 'XrInputSourceArray', + 'XrInputSourceEvent', + 'XrInputSourceEventInit', + 'XrInputSourcesChangeEvent', + 'XrPose', + 'XrReferenceSpace', + 'XrReferenceSpaceEvent', + 'XrReferenceSpaceEventInit', + 'XrReferenceSpaceType', + 'XrRenderState', + 'XrRenderStateInit', + 'XrRigidTransform', + 'XrSession', + 'XrSessionEvent', + 'XrSessionEventInit', + 'XrSessionInit', + 'XrSessionMode', + 'XrSpace', + 'XrTargetRayMode', + 'XrView', + 'XrViewerPose', + 'XrViewport', + 'XrVisibilityState', + 'XrWebGlLayer', + 'XrWebGlLayerInit', + 'console' +] + + +[patch.crates-io] +wasm-bindgen = { path = '../../wasm-bindgen' } +wasm-bindgen-futures = { path = '../../wasm-bindgen/crates/futures' } +js-sys = { path = '../../wasm-bindgen/crates/js-sys' } +web-sys = { path = '../../wasm-bindgen/crates/web-sys' } diff --git a/examples/webxr/README.md b/examples/webxr/README.md new file mode 100644 index 00000000000..a322e390ea6 --- /dev/null +++ b/examples/webxr/README.md @@ -0,0 +1,16 @@ +# WebXR Example + +[View documentation for this example online][dox] or [View compiled example +online][compiled] + +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/ +[dox]: https://rustwasm.github.io/docs/wasm-bindgen/examples/webxr.html + +You can build the example locally with: + +``` +# Note: Requires unstable flag whilst WebXR in development +$ RUSTFLAGS=--cfg=web_sys_unstable_apis npm run serve +``` + +and then visiting http://localhost:8080 in a browser should run the example! diff --git a/examples/webxr/index.html b/examples/webxr/index.html new file mode 100644 index 00000000000..319ffd0edca --- /dev/null +++ b/examples/webxr/index.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/examples/webxr/index.js b/examples/webxr/index.js new file mode 100644 index 00000000000..2e01f8b3dbf --- /dev/null +++ b/examples/webxr/index.js @@ -0,0 +1,4 @@ +// For more comments about what's going on here, check out the `hello_world` +// example. +import("./webxr.js") + .catch(e => console.error("Error importing web assembly:", e)); \ No newline at end of file diff --git a/examples/webxr/package.json b/examples/webxr/package.json new file mode 100644 index 00000000000..1a3ab33cac4 --- /dev/null +++ b/examples/webxr/package.json @@ -0,0 +1,17 @@ +{ + "scripts": { + "build": "webpack", + "serve": "webpack-dev-server" + }, + "dependencies": { + "webxr": "./pkg" + }, + "devDependencies": { + "@wasm-tool/wasm-pack-plugin": "1.0.1", + "text-encoding": "^0.7.0", + "html-webpack-plugin": "^3.2.0", + "webpack": "^4.29.4", + "webpack-cli": "^3.1.1", + "webpack-dev-server": "^3.1.0" + } +} diff --git a/examples/webxr/src/lib.rs b/examples/webxr/src/lib.rs new file mode 100644 index 00000000000..f3e218ef929 --- /dev/null +++ b/examples/webxr/src/lib.rs @@ -0,0 +1,151 @@ +#[macro_use] mod utils; + +use futures::{future, Future}; +use js_sys::Promise; +use wasm_bindgen::prelude::*; +use wasm_bindgen::prelude::*; +use wasm_bindgen::JsCast; +use wasm_bindgen_futures::future_to_promise; +use wasm_bindgen_futures::JsFuture; +use web_sys::*; +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; +use utils::set_panic_hook; + + +// A macro to provide `println!(..)`-style syntax for `console.log` logging. +macro_rules! log { + ( $( $t:tt )* ) => { + web_sys::console::log_1(&format!( $( $t )* ).into()); + } +} + + +fn request_animation_frame(session: &XrSession, f: &Closure) -> i32 { + // This turns the Closure into a js_sys::Function + // See https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html#casting-a-closure-to-a-js_sysfunction + session + .request_animation_frame(f.as_ref().unchecked_ref()) +} + + +pub fn create_webgl_context(xr_mode: bool) -> Result { + let canvas = web_sys::window() + .unwrap() + .document() + .unwrap() + .get_element_by_id("canvas") + .unwrap() + .dyn_into::() + .unwrap(); + + let gl: WebGl2RenderingContext = if xr_mode { + let mut gl_attribs = HashMap::new(); + gl_attribs.insert(String::from("xrCompatible"), true); + let js_gl_attribs = JsValue::from_serde(&gl_attribs).unwrap(); + + canvas.get_context_with_context_options("webgl2", &js_gl_attribs)?.unwrap().dyn_into()? + } + else { + canvas.get_context("webgl2")?.unwrap().dyn_into()? + }; + + Ok(gl) +} + + +#[wasm_bindgen] +pub struct XrApp { + session: Rc>>, + gl: Rc +} + + +#[wasm_bindgen] +impl XrApp { + + #[wasm_bindgen(constructor)] + pub fn new() -> XrApp { + set_panic_hook(); + + let session = Rc::new(RefCell::new(None)); + + let xr_mode = true; + let gl = Rc::new(create_webgl_context(xr_mode).unwrap()); + + XrApp { session, gl } + } + + pub fn init(&self) -> Promise { + log!("Starting WebXR..."); + let navigator: web_sys::Navigator = web_sys::window().unwrap().navigator(); + let gpu = navigator.gpu(); + let xr = navigator.xr(); + let session_mode = XrSessionMode::Inline; + let session_supported_promise = xr.is_session_supported(session_mode); + + // Note: &self is on the stack so we can't use it in a future (which will + // run after the &self reference is out or scope). Clone ref to the parts + // of self we'll need, then move them into the Future + // See https://github.com/rustwasm/wasm-bindgen/issues/1858#issuecomment-552095511 + let session = self.session.clone(); + let gl = self.gl.clone(); + + let future_ = async move { + let supports_session = wasm_bindgen_futures::JsFuture::from(session_supported_promise).await; + let supports_session = supports_session.unwrap(); + if supports_session == false { + log!("XR session not supported"); + return Ok(JsValue::from("XR session not supported")); + } + + let xr_session_promise = xr.request_session(session_mode); + let xr_session = wasm_bindgen_futures::JsFuture::from(xr_session_promise).await; + let xr_session: XrSession = xr_session.unwrap().into(); + + let xr_gl_layer = XrWebGlLayer::new_with_web_gl2_rendering_context(&xr_session, &gl)?; + let mut render_state_init = XrRenderStateInit::new(); + render_state_init.base_layer(Some(&xr_gl_layer)); + xr_session.update_render_state_with_state(&render_state_init); + + let mut session = session.borrow_mut(); + session.replace(xr_session); + + Ok(JsValue::from("Session set")) + }; + + future_to_promise(future_) + } + + pub fn start(&self) { + let f = Rc::new(RefCell::new(None)); + let g = f.clone(); + + let mut i = 0; + *g.borrow_mut() = Some(Closure::wrap(Box::new(move |time: f64, frame: XrFrame| { + log!("Frame rendering..."); + if i > 2 { + log!("All done!"); + + // Drop our handle to this closure so that it will get cleaned + // up once we return. + let _ = f.borrow_mut().take(); + return; + } + + let sess: XrSession = frame.session(); + i += 1; + + // Schedule ourself for another requestAnimationFrame callback. + // TODO: WebXR Samples call this at top of request_animation_frame - should this be moved? + request_animation_frame(&sess, f.borrow().as_ref().unwrap()); + + }) as Box)); + + let session: &Option = &self.session.borrow(); + let sess: &XrSession = if let Some(sess) = session { sess } else { return () }; + + request_animation_frame(sess, g.borrow().as_ref().unwrap()); + } +} diff --git a/examples/webxr/src/utils.rs b/examples/webxr/src/utils.rs new file mode 100644 index 00000000000..b1d7929dc9c --- /dev/null +++ b/examples/webxr/src/utils.rs @@ -0,0 +1,10 @@ +pub fn set_panic_hook() { + // When the `console_error_panic_hook` feature is enabled, we can call the + // `set_panic_hook` function at least once during initialization, and then + // we will get better error messages if our code ever panics. + // + // For more details see + // https://github.com/rustwasm/console_error_panic_hook#readme + #[cfg(feature = "console_error_panic_hook")] + console_error_panic_hook::set_once(); +} diff --git a/examples/webxr/webpack.config.js b/examples/webxr/webpack.config.js new file mode 100644 index 00000000000..797f429f0f7 --- /dev/null +++ b/examples/webxr/webpack.config.js @@ -0,0 +1,27 @@ +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const webpack = require('webpack'); +const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); + +module.exports = { + entry: './index.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'index.js', + }, + plugins: [ + new HtmlWebpackPlugin({ + template: 'index.html' + }), + new WasmPackPlugin({ + crateDirectory: path.resolve(__dirname, ".") + }), + // Have this example work in Edge which doesn't ship `TextEncoder` or + // `TextDecoder` at this time. + new webpack.ProvidePlugin({ + TextDecoder: ['text-encoding', 'TextDecoder'], + TextEncoder: ['text-encoding', 'TextEncoder'] + }) + ], + mode: 'development' +}; diff --git a/examples/webxr/webxr.js b/examples/webxr/webxr.js new file mode 100644 index 00000000000..b604d868b42 --- /dev/null +++ b/examples/webxr/webxr.js @@ -0,0 +1,8 @@ +import * as wasm from "webxr"; + +var xrApp = new wasm.XrApp(); +xrApp.init() + .then(res => { + console.log(res); + xrApp.start(); + }); \ No newline at end of file