Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Unified Diff: third_party/WebKit/Source/modules/vr/VRPose.cpp

Issue 1918143007: Updated Blink WebVR interfaces to WebVR v1 spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webvr_mojo
Patch Set: Fixed layout test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRPose.h ('k') | third_party/WebKit/Source/modules/vr/VRPose.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/vr/VRPose.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRPose.cpp b/third_party/WebKit/Source/modules/vr/VRPose.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..25dd17ee1f9a498b43f46ba7212bc4ec67f04387
--- /dev/null
+++ b/third_party/WebKit/Source/modules/vr/VRPose.cpp
@@ -0,0 +1,64 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/vr/VRPose.h"
+
+namespace blink {
+
+namespace {
+
+DOMFloat32Array* vecToFloat32Array(const WebVRVector4& vec, bool valid)
+{
+ if (valid) {
+ DOMFloat32Array* out = DOMFloat32Array::create(4);
+ out->data()[0] = vec.x;
+ out->data()[1] = vec.y;
+ out->data()[2] = vec.z;
+ out->data()[3] = vec.w;
+ return out;
+ }
+ return nullptr;
+}
+
+DOMFloat32Array* vecToFloat32Array(const WebVRVector3& vec, bool valid)
+{
+ if (valid) {
+ DOMFloat32Array* out = DOMFloat32Array::create(3);
+ out->data()[0] = vec.x;
+ out->data()[1] = vec.y;
+ out->data()[2] = vec.z;
+ return out;
+ }
+ return nullptr;
+}
+
+} // namespace
+
+VRPose::VRPose()
+ : m_timeStamp(0.0)
+{
+}
+
+void VRPose::setPose(const WebHMDSensorState &state)
+{
+ m_timeStamp = state.timestamp;
+ m_orientation = vecToFloat32Array(state.orientation, state.flags & WebVRSensorStateOrientation);
+ m_position = vecToFloat32Array(state.position, state.flags & WebVRSensorStatePosition);
+ m_angularVelocity = vecToFloat32Array(state.angularVelocity, state.flags & WebVRSensorStateAngularVelocity);
+ m_linearVelocity = vecToFloat32Array(state.linearVelocity, state.flags & WebVRSensorStateLinearVelocity);
+ m_angularAcceleration = vecToFloat32Array(state.angularAcceleration, state.flags & WebVRSensorStateAngularAcceleration);
+ m_linearAcceleration = vecToFloat32Array(state.linearAcceleration, state.flags & WebVRSensorStateLinearAcceleration);
+}
+
+DEFINE_TRACE(VRPose)
+{
+ visitor->trace(m_orientation);
+ visitor->trace(m_position);
+ visitor->trace(m_angularVelocity);
+ visitor->trace(m_linearVelocity);
+ visitor->trace(m_angularAcceleration);
+ visitor->trace(m_linearAcceleration);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRPose.h ('k') | third_party/WebKit/Source/modules/vr/VRPose.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698