OLD | NEW |
| (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/VRPositionState.h" | |
6 | |
7 namespace blink { | |
8 | |
9 namespace { | |
10 | |
11 DOMPoint* vecToDomPoint(const WebVRVector4& vec, bool valid) | |
12 { | |
13 if (valid) | |
14 return DOMPoint::create(vec.x, vec.y, vec.z, vec.w); | |
15 return nullptr; | |
16 } | |
17 DOMPoint* vecToDomPoint(const WebVRVector3& vec, bool valid) | |
18 { | |
19 if (valid) | |
20 return DOMPoint::create(vec.x, vec.y, vec.z, 1.0); | |
21 return nullptr; | |
22 } | |
23 | |
24 } // namespace | |
25 | |
26 VRPositionState::VRPositionState() | |
27 : m_timeStamp(0.0) | |
28 { | |
29 } | |
30 | |
31 void VRPositionState::setState(const WebHMDSensorState &state) | |
32 { | |
33 m_timeStamp = state.timestamp; | |
34 m_orientation = vecToDomPoint(state.orientation, state.flags & WebVRSensorSt
ateOrientation); | |
35 m_position = vecToDomPoint(state.position, state.flags & WebVRSensorStatePos
ition); | |
36 m_angularVelocity = vecToDomPoint(state.angularVelocity, state.flags & WebVR
SensorStateAngularVelocity); | |
37 m_linearVelocity = vecToDomPoint(state.linearVelocity, state.flags & WebVRSe
nsorStateLinearVelocity); | |
38 m_angularAcceleration = vecToDomPoint(state.angularAcceleration, state.flags
& WebVRSensorStateAngularAcceleration); | |
39 m_linearAcceleration = vecToDomPoint(state.linearAcceleration, state.flags
& WebVRSensorStateLinearAcceleration); | |
40 } | |
41 | |
42 DEFINE_TRACE(VRPositionState) | |
43 { | |
44 visitor->trace(m_orientation); | |
45 visitor->trace(m_position); | |
46 visitor->trace(m_angularVelocity); | |
47 visitor->trace(m_linearVelocity); | |
48 visitor->trace(m_angularAcceleration); | |
49 visitor->trace(m_linearAcceleration); | |
50 } | |
51 | |
52 } // namespace blink | |
OLD | NEW |