blob: 15e9e5996fd4aa9e3e6db8c36757f50761cb09a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// Copyright 2017 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_FRAME_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_FRAME_H_
#include <memory>
#include "device/vr/public/mojom/vr_service.mojom-blink-forward.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
namespace blink {
class ExceptionState;
class XRAnchorSet;
class XRHitTestResult;
class XRHitTestSource;
class XRInputSource;
class XRPose;
class XRReferenceSpace;
class XRRigidTransform;
class XRSession;
class XRSpace;
class XRTransientInputHitTestResult;
class XRTransientInputHitTestSource;
class XRViewerPose;
class XRWorldInformation;
class XRFrame final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
explicit XRFrame(XRSession* session, XRWorldInformation* world_information);
XRSession* session() const { return session_; }
XRViewerPose* getViewerPose(XRReferenceSpace*, ExceptionState&) const;
XRPose* getPose(XRSpace*, XRSpace*, ExceptionState&);
XRWorldInformation* worldInformation() const { return world_information_; }
XRAnchorSet* trackedAnchors() const;
void Trace(Visitor*) override;
void Deactivate();
void SetAnimationFrame(bool is_animation_frame) {
is_animation_frame_ = is_animation_frame;
}
HeapVector<Member<XRHitTestResult>> getHitTestResults(
XRHitTestSource* hit_test_source,
ExceptionState& exception_state);
HeapVector<Member<XRTransientInputHitTestResult>>
getHitTestResultsForTransientInput(
XRTransientInputHitTestSource* hit_test_source,
ExceptionState& exception_state);
ScriptPromise createAnchor(ScriptState* script_state,
XRRigidTransform* initial_pose,
XRSpace* space,
ExceptionState& exception_state);
private:
std::unique_ptr<TransformationMatrix> GetAdjustedPoseMatrix(XRSpace*) const;
XRPose* GetTargetRayPose(XRInputSource*, XRSpace*) const;
XRPose* GetGripPose(XRInputSource*, XRSpace*) const;
Member<XRWorldInformation> world_information_;
const Member<XRSession> session_;
// Frames are only active during callbacks. getPose and getViewerPose should
// only be called from JS on active frames.
bool is_active_ = true;
// Only frames created by XRSession.requestAnimationFrame callbacks are
// animation frames. getViewerPose should only be called from JS on active
// animation frames.
bool is_animation_frame_ = false;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_FRAME_H_
|