blob: b4e9b877f3c3943a30025e4b0f7878fe7e885c3a (
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
|
// Copyright 2019 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_PLANE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_H_
#include <memory>
#include "base/optional.h"
#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/core/geometry/dom_point_read_only.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class ExceptionState;
class XRRigidTransform;
class XRSession;
class XRSpace;
class XRPlane : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
enum Orientation { kHorizontal, kVertical };
XRPlane(uint64_t id,
XRSession* session,
const device::mojom::blink::XRPlaneData& plane_data,
double timestamp);
uint64_t id() const;
XRSpace* planeSpace() const;
base::Optional<TransformationMatrix> MojoFromObject() const;
String orientation() const;
HeapVector<Member<DOMPointReadOnly>> polygon() const;
double lastChangedTime() const;
ScriptPromise createAnchor(ScriptState* script_state,
XRRigidTransform* initial_pose,
XRSpace* space,
ExceptionState& exception_state);
// Updates plane data from passed in |plane_data|. The resulting instance
// should be equivalent to the instance that would be create by calling
// XRPlane(plane_data).
void Update(const device::mojom::blink::XRPlaneData& plane_data,
double timestamp);
void Trace(Visitor* visitor) override;
private:
XRPlane(uint64_t id,
XRSession* session,
const base::Optional<Orientation>& orientation,
const HeapVector<Member<DOMPointReadOnly>>& polygon,
double timestamp);
void SetMojoFromPlane(const TransformationMatrix& mojo_from_plane);
const uint64_t id_;
HeapVector<Member<DOMPointReadOnly>> polygon_;
base::Optional<Orientation> orientation_;
// Plane center's pose in device (mojo) space.
std::unique_ptr<TransformationMatrix> mojo_from_plane_;
Member<XRSession> session_;
double last_changed_time_;
// Cached plane space - it will be created by `planeSpace()` if it's not set.
mutable Member<XRSpace> plane_space_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_PLANE_H_
|