1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "XRNativeOriginViewer.h"
8 #include "VRDisplayClient.h"
10 namespace mozilla::dom
{
12 XRNativeOriginViewer::XRNativeOriginViewer(gfx::VRDisplayClient
* aDisplay
)
13 : mDisplay(aDisplay
) {
17 gfx::PointDouble3D
XRNativeOriginViewer::GetPosition() {
18 const gfx::VRHMDSensorState
& sensorState
= mDisplay
->GetSensorState();
19 return gfx::PointDouble3D(sensorState
.pose
.position
[0],
20 sensorState
.pose
.position
[1],
21 sensorState
.pose
.position
[2]);
24 gfx::QuaternionDouble
XRNativeOriginViewer::GetOrientation() {
25 const gfx::VRHMDSensorState
& sensorState
= mDisplay
->GetSensorState();
26 return gfx::QuaternionDouble(
27 sensorState
.pose
.orientation
[0], sensorState
.pose
.orientation
[1],
28 sensorState
.pose
.orientation
[2], sensorState
.pose
.orientation
[3]);
31 } // namespace mozilla::dom