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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/vr/VRPose.h"
6
7 namespace blink {
8
9 namespace {
10
11 DOMFloat32Array* vecToFloat32Array(const WebVRVector4& vec, bool valid)
12 {
13 if (valid) {
14 DOMFloat32Array* out = DOMFloat32Array::create(4);
15 out->data()[0] = vec.x;
16 out->data()[1] = vec.y;
17 out->data()[2] = vec.z;
18 out->data()[3] = vec.w;
19 return out;
20 }
21 return nullptr;
22 }
23
24 DOMFloat32Array* vecToFloat32Array(const WebVRVector3& vec, bool valid)
25 {
26 if (valid) {
27 DOMFloat32Array* out = DOMFloat32Array::create(3);
28 out->data()[0] = vec.x;
29 out->data()[1] = vec.y;
30 out->data()[2] = vec.z;
31 return out;
32 }
33 return nullptr;
34 }
35
36 } // namespace
37
38 VRPose::VRPose()
39 : m_timeStamp(0.0)
40 {
41 }
42
43 void VRPose::setPose(const WebHMDSensorState &state)
44 {
45 m_timeStamp = state.timestamp;
46 m_orientation = vecToFloat32Array(state.orientation, state.flags & WebVRSens orStateOrientation);
47 m_position = vecToFloat32Array(state.position, state.flags & WebVRSensorStat ePosition);
48 m_angularVelocity = vecToFloat32Array(state.angularVelocity, state.flags & W ebVRSensorStateAngularVelocity);
49 m_linearVelocity = vecToFloat32Array(state.linearVelocity, state.flags & Web VRSensorStateLinearVelocity);
50 m_angularAcceleration = vecToFloat32Array(state.angularAcceleration, state.f lags & WebVRSensorStateAngularAcceleration);
51 m_linearAcceleration = vecToFloat32Array(state.linearAcceleration, state.fla gs & WebVRSensorStateLinearAcceleration);
52 }
53
54 DEFINE_TRACE(VRPose)
55 {
56 visitor->trace(m_orientation);
57 visitor->trace(m_position);
58 visitor->trace(m_angularVelocity);
59 visitor->trace(m_linearVelocity);
60 visitor->trace(m_angularAcceleration);
61 visitor->trace(m_linearAcceleration);
62 }
63
64 } // namespace blink
OLDNEW
« 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