-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #23159 - Manishearth:rigid-transforms, r=<try>
Update XR code to use rigid transforms and new pose/transform stuff from the spec This updates our XR code to use euclid's new [RigidTransform3D type](servo/euclid#328), which is more efficent and convenient to work with. It additionally brings us up to speed with the spec: - `XRViewerPose` was made a subclass of `XRPose` (immersive-web/webxr#496) - `XRView.viewMatrix` was removed in favor of `XRRigidTransform.inverse.matrix` (immersive-web/webxr#531) - `XRRigidTransform.inverse` is an attribute (immersive-web/webxr#560) - `XRRigidTransform` now validates positions in its constructor (immersive-web/webxr#568) Furthermore, it adds support for `XRRigidTransform.matrix`. While fixing this I also noticed that our view matrix code was incorrect, we calculated view matrices as `pose.to_column_major_array()`, whereas it *should* be `pose.inverse().to_row_major_array()` (since Euclid uses row vectors, whenever the spec says it wants a column major array we should use `.to_row_major_array()` since all web specs implicitly use column vectors). For 3DOF devices poses are mostly rotations anyway, so the effective transpose behaved _like_ an inversion, but was incorrect. This PR gets rid of `view.viewMatrix` anyway, however I felt like I should mention this discrepancy, since otherwise the replacement of `view.viewMatrix` with `view.transform.inverse.matrix` doesn't make sense r? @jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23159) <!-- Reviewable:end -->
- Loading branch information
Showing
18 changed files
with
225 additions
and
216 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
// https://immersive-web.github.io/webxr/#xrpose-interface | ||
|
||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"] | ||
interface XRPose { | ||
readonly attribute XRRigidTransform transform; | ||
// readonly attribute boolean emulatedPosition; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
use crate::dom::bindings::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::globalscope::GlobalScope; | ||
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(transform: &XRRigidTransform) -> XRPose { | ||
XRPose { | ||
reflector_: Reflector::new(), | ||
transform: Dom::from_ref(transform), | ||
} | ||
} | ||
|
||
#[allow(unused)] | ||
pub fn new(global: &GlobalScope, 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.