Skip to content
Permalink
Browse files

Add XRPose.transform

  • Loading branch information...
Manishearth committed Apr 3, 2019
1 parent e1f0ad7 commit f9c25c612a84fe9c07ceb25dcf52f66b8b7ea951
@@ -6,6 +6,6 @@

[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
interface XRPose {
// readonly attribute XRRigidTransform transform;
readonly attribute XRRigidTransform transform;
// readonly attribute boolean emulatedPosition;
};
@@ -2,18 +2,43 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::dom::bindings::reflector::Reflector;
use crate::dom::bindings::codegen::Bindings::XRPoseBinding;
use crate::dom::bindings::codegen::Bindings::XRPoseBinding::XRPoseMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::window::Window;
use crate::dom::xrrigidtransform::XRRigidTransform;
use dom_struct::dom_struct;
use euclid::RigidTransform3D;

#[dom_struct]
pub struct XRPose {
reflector_: Reflector,
transform: Dom<XRRigidTransform>,
}

impl XRPose {
pub fn new_inherited() -> XRPose {
pub fn new_inherited(transform: &XRRigidTransform) -> XRPose {
XRPose {
reflector_: Reflector::new(),
transform: Dom::from_ref(transform),
}
}

#[allow(unused)]
pub fn new(global: &Window, transform: RigidTransform3D<f64>) -> DomRoot<XRPose> {
let transform = XRRigidTransform::new(global, transform);
reflect_dom_object(
Box::new(XRPose::new_inherited(&transform)),
global,
XRPoseBinding::Wrap,
)
}
}

impl XRPoseMethods for XRPose {
/// https://immersive-web.github.io/webxr/#dom-xrpose-transform
fn Transform(&self) -> DomRoot<XRRigidTransform> {
DomRoot::from_ref(&self.transform)
}
}
@@ -11,7 +11,7 @@ use crate::dom::xrreferencespace::XRReferenceSpace;
use crate::dom::xrrigidtransform::XRRigidTransform;
use crate::dom::xrsession::XRSession;
use dom_struct::dom_struct;
use euclid::{Rotation3D, RigidTransform3D, Vector3D};
use euclid::{RigidTransform3D, Rotation3D, Vector3D};
use webvr_traits::WebVRFrameData;

#[dom_struct]
@@ -65,7 +65,11 @@ impl XRView {
};

let offset = Vector3D::new(offset[0] as f64, offset[1] as f64, offset[2] as f64);
let view = pose.post_mul(&offset.into()).to_transform().cast().to_column_major_array();
let view = pose
.post_mul(&offset.into())
.to_transform()
.cast()
.to_column_major_array();

let cx = global.get_cx();
unsafe {

0 comments on commit f9c25c6

Please sign in to comment.
You can’t perform that action at this time.