mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add XRRigidTransform constructor
This commit is contained in:
parent
bc03d32142
commit
c775820a79
3 changed files with 39 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{
|
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{
|
||||||
DOMPointReadOnlyMethods, Wrap,
|
DOMPointReadOnlyMethods, Wrap,
|
||||||
};
|
};
|
||||||
|
@ -50,6 +51,10 @@ impl DOMPointReadOnly {
|
||||||
) -> Fallible<DomRoot<DOMPointReadOnly>> {
|
) -> Fallible<DomRoot<DOMPointReadOnly>> {
|
||||||
Ok(DOMPointReadOnly::new(global, x, y, z, w))
|
Ok(DOMPointReadOnly::new(global, x, y, z, w))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot<DOMPointReadOnly> {
|
||||||
|
DOMPointReadOnly::new(global, p.x, p.y, p.z, p.w)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DOMPointReadOnlyMethods for DOMPointReadOnly {
|
impl DOMPointReadOnlyMethods for DOMPointReadOnly {
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
// https://immersive-web.github.io/webxr/#xrrigidtransform-interface
|
// https://immersive-web.github.io/webxr/#xrrigidtransform-interface
|
||||||
|
|
||||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled",
|
||||||
// [Constructor(optional DOMPointInit position, optional DOMPointInit orientation)]
|
Constructor(optional DOMPointInit position, optional DOMPointInit orientation)]
|
||||||
interface XRRigidTransform {
|
interface XRRigidTransform {
|
||||||
// readonly attribute DOMPointReadOnly position;
|
// readonly attribute DOMPointReadOnly position;
|
||||||
// readonly attribute DOMPointReadOnly orientation;
|
// readonly attribute DOMPointReadOnly orientation;
|
||||||
|
|
|
@ -2,30 +2,57 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding;
|
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding;
|
||||||
|
use crate::dom::bindings::error::Fallible;
|
||||||
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::dompointreadonly::DOMPointReadOnly;
|
||||||
|
use crate::dom::window::Window;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct XRRigidTransform {
|
pub struct XRRigidTransform {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
position: Dom<DOMPointReadOnly>,
|
||||||
|
orientation: Dom<DOMPointReadOnly>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XRRigidTransform {
|
impl XRRigidTransform {
|
||||||
fn new_inherited() -> XRRigidTransform {
|
fn new_inherited(
|
||||||
|
position: &DOMPointReadOnly,
|
||||||
|
orientation: &DOMPointReadOnly,
|
||||||
|
) -> XRRigidTransform {
|
||||||
XRRigidTransform {
|
XRRigidTransform {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
position: Dom::from_ref(position),
|
||||||
|
orientation: Dom::from_ref(orientation),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn new(global: &GlobalScope) -> DomRoot<XRRigidTransform> {
|
pub fn new(
|
||||||
|
global: &Window,
|
||||||
|
position: &DOMPointReadOnly,
|
||||||
|
orientation: &DOMPointReadOnly,
|
||||||
|
) -> DomRoot<XRRigidTransform> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(XRRigidTransform::new_inherited()),
|
Box::new(XRRigidTransform::new_inherited(position, orientation)),
|
||||||
global,
|
global,
|
||||||
XRRigidTransformBinding::Wrap,
|
XRRigidTransformBinding::Wrap,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://immersive-web.github.io/webxr/#dom-xrrigidtransform-xrrigidtransform
|
||||||
|
pub fn Constructor(
|
||||||
|
window: &Window,
|
||||||
|
position: &DOMPointInit,
|
||||||
|
orientation: &DOMPointInit,
|
||||||
|
) -> Fallible<DomRoot<Self>> {
|
||||||
|
let global = window.global();
|
||||||
|
let position = DOMPointReadOnly::new_from_init(&global, &position);
|
||||||
|
let orientation = DOMPointReadOnly::new_from_init(&global, &orientation);
|
||||||
|
Ok(XRRigidTransform::new(window, &position, &orientation))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue