OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/vr/VREyeParameters.h" | 5 #include "modules/vr/VREyeParameters.h" |
6 | 6 |
| 7 #include "bindings/core/v8/GeometryInterfaces.h" |
| 8 |
7 namespace blink { | 9 namespace blink { |
8 | 10 |
9 namespace { | 11 ScriptValue& VREyeParameters::eyeTranslation(ScriptState* scriptState) |
10 | |
11 void setDomPoint(DOMPoint* point, const WebVRVector3& vec) | |
12 { | 12 { |
13 point->setX(vec.x); | 13 m_eyeTranslation = GeometryInterfaces::createDOMPoint(scriptState, |
14 point->setY(vec.y); | 14 m_eyeTranslationVector.x, |
15 point->setZ(vec.z); | 15 m_eyeTranslationVector.y, |
16 point->setW(1.0); | 16 m_eyeTranslationVector.z); |
| 17 return m_eyeTranslation; |
17 } | 18 } |
18 | 19 |
19 } // namespace | |
20 | |
21 VREyeParameters::VREyeParameters() | 20 VREyeParameters::VREyeParameters() |
22 { | 21 { |
23 m_minimumFieldOfView = new VRFieldOfView(); | 22 m_minimumFieldOfView = new VRFieldOfView(); |
24 m_maximumFieldOfView = new VRFieldOfView(); | 23 m_maximumFieldOfView = new VRFieldOfView(); |
25 m_recommendedFieldOfView = new VRFieldOfView(); | 24 m_recommendedFieldOfView = new VRFieldOfView(); |
26 m_eyeTranslation = DOMPoint::create(0, 0, 0, 0); | |
27 | 25 |
28 m_currentFieldOfView = new VRFieldOfView(); | 26 m_currentFieldOfView = new VRFieldOfView(); |
29 m_renderRect = DOMRect::create(0, 0, 0, 0); | 27 m_renderRect = DOMRect::create(0, 0, 0, 0); |
30 } | 28 } |
31 | 29 |
32 void VREyeParameters::setFromWebVREyeParameters(const WebVREyeParameters &state) | 30 void VREyeParameters::setFromWebVREyeParameters(const WebVREyeParameters &state) |
33 { | 31 { |
34 // FIXME: We should expose proper min/max FOV eventually but for now set the | 32 // FIXME: We should expose proper min/max FOV eventually but for now set the |
35 // min/max equal to the recommended FOV to reduce need for synchronous | 33 // min/max equal to the recommended FOV to reduce need for synchronous |
36 // queries and reduce rendering complexity. | 34 // queries and reduce rendering complexity. |
37 m_minimumFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); | 35 m_minimumFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); |
38 m_maximumFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); | 36 m_maximumFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); |
39 m_recommendedFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfVi
ew); | 37 m_recommendedFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfVi
ew); |
40 setDomPoint(m_eyeTranslation, state.eyeTranslation); | 38 m_eyeTranslationVector = state.eyeTranslation; |
41 | 39 |
42 m_currentFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); | 40 m_currentFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); |
43 m_renderRect = DOMRect::create(state.renderRect.x, state.renderRect.y, state
.renderRect.width, state.renderRect.height); | 41 m_renderRect = DOMRect::create(state.renderRect.x, state.renderRect.y, state
.renderRect.width, state.renderRect.height); |
44 } | 42 } |
45 | 43 |
46 DEFINE_TRACE(VREyeParameters) | 44 DEFINE_TRACE(VREyeParameters) |
47 { | 45 { |
48 visitor->trace(m_minimumFieldOfView); | 46 visitor->trace(m_minimumFieldOfView); |
49 visitor->trace(m_maximumFieldOfView); | 47 visitor->trace(m_maximumFieldOfView); |
50 visitor->trace(m_recommendedFieldOfView); | 48 visitor->trace(m_recommendedFieldOfView); |
51 visitor->trace(m_eyeTranslation); | |
52 visitor->trace(m_currentFieldOfView); | 49 visitor->trace(m_currentFieldOfView); |
53 visitor->trace(m_renderRect); | 50 visitor->trace(m_renderRect); |
54 } | 51 } |
55 | 52 |
56 } // namespace blink | 53 } // namespace blink |
OLD | NEW |