XRNativeOriginViewer.cpp (1200B)
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/. */ 6 7 #include "XRNativeOriginViewer.h" 8 9 #include "VRDisplayClient.h" 10 11 namespace mozilla::dom { 12 13 XRNativeOriginViewer::XRNativeOriginViewer(gfx::VRDisplayClient* aDisplay) 14 : mDisplay(aDisplay) { 15 MOZ_ASSERT(aDisplay); 16 } 17 18 gfx::PointDouble3D XRNativeOriginViewer::GetPosition() { 19 const gfx::VRHMDSensorState& sensorState = mDisplay->GetSensorState(); 20 return gfx::PointDouble3D(sensorState.pose.position[0], 21 sensorState.pose.position[1], 22 sensorState.pose.position[2]); 23 } 24 25 gfx::QuaternionDouble XRNativeOriginViewer::GetOrientation() { 26 const gfx::VRHMDSensorState& sensorState = mDisplay->GetSensorState(); 27 return gfx::QuaternionDouble( 28 sensorState.pose.orientation[0], sensorState.pose.orientation[1], 29 sensorState.pose.orientation[2], sensorState.pose.orientation[3]); 30 } 31 32 } // namespace mozilla::dom