@reactvision/react-viro 2.44.0 → 2.44.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/react_viro/react_viro-release.aar +0 -0
- package/android/viro_renderer/viro_renderer-release.aar +0 -0
- package/components/AR/ViroARPlaneSelector.tsx +226 -100
- package/components/Material/ViroMaterials.ts +4 -2
- package/components/Types/ViroEvents.ts +50 -5
- package/components/Utilities/ViroVersion.ts +1 -1
- package/dist/components/AR/ViroARPlaneSelector.d.ts +15 -15
- package/dist/components/AR/ViroARPlaneSelector.js +130 -55
- package/dist/components/Material/ViroMaterials.js +2 -2
- package/dist/components/Types/ViroEvents.d.ts +30 -4
- package/dist/components/Utilities/ViroVersion.d.ts +1 -1
- package/dist/components/Utilities/ViroVersion.js +1 -1
- package/ios/dist/ViroRenderer/ViroKit.framework/ARCoreResources.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/CardboardSDK.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARDeclarativeNode.h +1 -1
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARDeclarativePlane.h +21 -2
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARPlaneAnchor.h +191 -4
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROVector2f.h +124 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Info.plist +0 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/ViroKit +0 -0
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/ARCoreResources.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/CardboardSDK.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/Headers/VROARDeclarativeNode.h +1 -1
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/Headers/VROARDeclarativePlane.h +21 -2
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/Headers/VROARPlaneAnchor.h +191 -4
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/Headers/VROVector2f.h +124 -0
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/Info.plist +0 -0
- package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/ViroKit +0 -0
- package/ios/dist/ViroRenderer/x86_64/ViroKit.framework/CardboardSDK.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/x86_64/ViroKit.framework/Info.plist +0 -0
- package/ios/dist/armv7_arm64/libViroReact.a +0 -0
- package/ios/dist/lib/libViroReact.a +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VROVector2f.h
|
|
3
|
+
// ViroRenderer
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2025 Viro Media. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
// a copy of this software and associated documentation files (the
|
|
9
|
+
// "Software"), to deal in the Software without restriction, including
|
|
10
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
// the following conditions:
|
|
14
|
+
//
|
|
15
|
+
// The above copyright notice and this permission notice shall be included
|
|
16
|
+
// in all copies or substantial portions of the Software.
|
|
17
|
+
//
|
|
18
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
#ifndef VROVECTOR2F_H_
|
|
27
|
+
#define VROVECTOR2F_H_
|
|
28
|
+
|
|
29
|
+
#include <stdlib.h>
|
|
30
|
+
#include <math.h>
|
|
31
|
+
#include <string>
|
|
32
|
+
|
|
33
|
+
class VROVector2f {
|
|
34
|
+
public:
|
|
35
|
+
float x;
|
|
36
|
+
float y;
|
|
37
|
+
|
|
38
|
+
VROVector2f() noexcept : x(0), y(0) {}
|
|
39
|
+
VROVector2f(float x, float y) : x(x), y(y) {}
|
|
40
|
+
|
|
41
|
+
VROVector2f &operator*=(const float multiplier) {
|
|
42
|
+
x *= multiplier;
|
|
43
|
+
y *= multiplier;
|
|
44
|
+
return *this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
VROVector2f &operator/=(const float divisor) {
|
|
48
|
+
x /= divisor;
|
|
49
|
+
y /= divisor;
|
|
50
|
+
return *this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
VROVector2f &operator+=(const VROVector2f &rhs) {
|
|
54
|
+
x += rhs.x;
|
|
55
|
+
y += rhs.y;
|
|
56
|
+
return *this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
VROVector2f &operator-=(const VROVector2f &rhs) {
|
|
60
|
+
x -= rhs.x;
|
|
61
|
+
y -= rhs.y;
|
|
62
|
+
return *this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
VROVector2f operator+(const VROVector2f &vec) const {
|
|
66
|
+
VROVector2f result = *this;
|
|
67
|
+
result += vec;
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
VROVector2f operator-(const VROVector2f &vec) const {
|
|
72
|
+
VROVector2f result = *this;
|
|
73
|
+
result -= vec;
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
VROVector2f operator*(const float multiplier) const {
|
|
78
|
+
VROVector2f result = *this;
|
|
79
|
+
result *= multiplier;
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
VROVector2f operator/(const float divisor) const {
|
|
84
|
+
VROVector2f result = *this;
|
|
85
|
+
result /= divisor;
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
bool operator==(const VROVector2f &rhs) const {
|
|
90
|
+
return x == rhs.x && y == rhs.y;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
bool operator!=(const VROVector2f &rhs) const {
|
|
94
|
+
return !(*this == rhs);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
float magnitude() const {
|
|
98
|
+
return sqrtf(x * x + y * y);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
float distance(const VROVector2f &to) const {
|
|
102
|
+
float dx = to.x - x;
|
|
103
|
+
float dy = to.y - y;
|
|
104
|
+
return sqrtf(dx * dx + dy * dy);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
VROVector2f normalize() const {
|
|
108
|
+
float mag = magnitude();
|
|
109
|
+
if (mag > 0) {
|
|
110
|
+
return VROVector2f(x / mag, y / mag);
|
|
111
|
+
}
|
|
112
|
+
return VROVector2f(0, 0);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
float dot(const VROVector2f &rhs) const {
|
|
116
|
+
return x * rhs.x + y * rhs.y;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
std::string toString() const {
|
|
120
|
+
return "[" + std::to_string(x) + ", " + std::to_string(y) + "]";
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
#endif /* VROVECTOR2F_H_ */
|
|
Binary file
|
|
Binary file
|
package/ios/dist/ViroRenderer/armv7_arm64/ViroKit.framework/ARCoreResources.bundle/Info.plist
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -46,14 +46,31 @@ public:
|
|
|
46
46
|
|
|
47
47
|
/*
|
|
48
48
|
Returns whether or not the given VROARAnchor fulfills this plane's requirements.
|
|
49
|
+
|
|
50
|
+
NOTE: This uses hysteresis for CONSTRAINT MATCHING only - it doesn't affect the
|
|
51
|
+
precision of plane data from ARCore/ARKit. Hysteresis prevents nodes from rapidly
|
|
52
|
+
attaching/detaching when plane dimensions fluctuate near the app's minimum requirements.
|
|
53
|
+
|
|
54
|
+
This is application-level logic and does not filter or modify ARCore/ARKit plane data.
|
|
49
55
|
*/
|
|
50
56
|
bool hasRequirementsFulfilled(std::shared_ptr<VROARAnchor> candidate) {
|
|
51
57
|
std::shared_ptr<VROARPlaneAnchor> planeAnchor = std::dynamic_pointer_cast<VROARPlaneAnchor>(candidate->getAnchorForTrackable());
|
|
52
58
|
if (!planeAnchor) {
|
|
53
59
|
return false;
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
if
|
|
61
|
+
|
|
62
|
+
// Apply hysteresis: if the plane is already attached to this anchor,
|
|
63
|
+
// allow it to be 10% smaller before detaching. This prevents flickering
|
|
64
|
+
// when plane dimensions fluctuate near the application's size threshold.
|
|
65
|
+
// This does NOT affect the precision of the plane data itself.
|
|
66
|
+
bool isCurrentlyAttached = (getAnchor() == candidate);
|
|
67
|
+
float hysteresisMargin = isCurrentlyAttached ? 0.90f : 1.0f;
|
|
68
|
+
|
|
69
|
+
float effectiveMinWidth = _minWidth * hysteresisMargin;
|
|
70
|
+
float effectiveMinHeight = _minHeight * hysteresisMargin;
|
|
71
|
+
|
|
72
|
+
if (planeAnchor->getExtent().x < effectiveMinWidth ||
|
|
73
|
+
planeAnchor->getExtent().z < effectiveMinHeight) {
|
|
57
74
|
return false;
|
|
58
75
|
}
|
|
59
76
|
|
|
@@ -98,10 +115,12 @@ public:
|
|
|
98
115
|
&& _alignment != VROARPlaneAlignment::HorizontalDownward) {
|
|
99
116
|
return false;
|
|
100
117
|
}
|
|
118
|
+
break;
|
|
101
119
|
case VROARPlaneAlignment::Vertical:
|
|
102
120
|
if (_alignment != VROARPlaneAlignment::Vertical) {
|
|
103
121
|
return false;
|
|
104
122
|
}
|
|
123
|
+
break;
|
|
105
124
|
default:
|
|
106
125
|
break;
|
|
107
126
|
}
|
|
@@ -29,6 +29,20 @@
|
|
|
29
29
|
|
|
30
30
|
#include "VROARAnchor.h"
|
|
31
31
|
#include "VROVector3f.h"
|
|
32
|
+
#include "VROVector2f.h"
|
|
33
|
+
#include <chrono>
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
ENABLED: Change detection and update throttling to reduce noise and artifacts.
|
|
37
|
+
This filters out small plane changes and prevents excessive updates, which is
|
|
38
|
+
particularly important for vertical plane detection where ARCore can be noisy.
|
|
39
|
+
|
|
40
|
+
Thresholds:
|
|
41
|
+
- Minimum extent change: 1cm or 5%
|
|
42
|
+
- Minimum center change: 1cm
|
|
43
|
+
- Update throttle: 100ms (10 updates/sec max)
|
|
44
|
+
*/
|
|
45
|
+
#define VRO_PLANE_CHANGE_DETECTION_ENABLED
|
|
32
46
|
|
|
33
47
|
enum class VROARPlaneAlignment {
|
|
34
48
|
Horizontal = 0x1,
|
|
@@ -37,14 +51,33 @@ enum class VROARPlaneAlignment {
|
|
|
37
51
|
Vertical = 0x10,
|
|
38
52
|
};
|
|
39
53
|
|
|
54
|
+
/*
|
|
55
|
+
Classification of detected planes (iOS 12+, ARCore semantic labels).
|
|
56
|
+
Indicates the semantic meaning of a detected plane.
|
|
57
|
+
*/
|
|
58
|
+
enum class VROARPlaneClassification {
|
|
59
|
+
None,
|
|
60
|
+
Wall,
|
|
61
|
+
Floor,
|
|
62
|
+
Ceiling,
|
|
63
|
+
Table,
|
|
64
|
+
Seat,
|
|
65
|
+
Door,
|
|
66
|
+
Window,
|
|
67
|
+
Unknown
|
|
68
|
+
};
|
|
69
|
+
|
|
40
70
|
/*
|
|
41
71
|
Anchor representing a planar surface.
|
|
42
72
|
*/
|
|
43
73
|
class VROARPlaneAnchor : public VROARAnchor {
|
|
44
|
-
|
|
74
|
+
|
|
45
75
|
public:
|
|
46
|
-
|
|
47
|
-
VROARPlaneAnchor()
|
|
76
|
+
|
|
77
|
+
VROARPlaneAnchor() :
|
|
78
|
+
_lastUpdateTime(std::chrono::steady_clock::now()),
|
|
79
|
+
_updateCount(0),
|
|
80
|
+
_significantChangeCount(0) {}
|
|
48
81
|
virtual ~VROARPlaneAnchor() {}
|
|
49
82
|
|
|
50
83
|
/*
|
|
@@ -85,7 +118,140 @@ public:
|
|
|
85
118
|
std::vector<VROVector3f> getBoundaryVertices() {
|
|
86
119
|
return _boundaryVertices;
|
|
87
120
|
}
|
|
88
|
-
|
|
121
|
+
|
|
122
|
+
/*
|
|
123
|
+
Full mesh geometry (iOS 11.3+ only - ARSCNPlaneGeometry equivalent).
|
|
124
|
+
Provides detailed tessellated surface representation beyond just boundary.
|
|
125
|
+
On Android/ARCore, these will be empty as ARCore only provides boundaries.
|
|
126
|
+
*/
|
|
127
|
+
void setMeshVertices(std::vector<VROVector3f> vertices) {
|
|
128
|
+
_meshVertices = std::move(vertices);
|
|
129
|
+
}
|
|
130
|
+
std::vector<VROVector3f> getMeshVertices() const {
|
|
131
|
+
return _meshVertices;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
void setTextureCoordinates(std::vector<VROVector2f> uvs) {
|
|
135
|
+
_textureCoordinates = std::move(uvs);
|
|
136
|
+
}
|
|
137
|
+
std::vector<VROVector2f> getTextureCoordinates() const {
|
|
138
|
+
return _textureCoordinates;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
void setTriangleIndices(std::vector<int> indices) {
|
|
142
|
+
_triangleIndices = std::move(indices);
|
|
143
|
+
}
|
|
144
|
+
std::vector<int> getTriangleIndices() const {
|
|
145
|
+
return _triangleIndices;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
Plane classification (iOS 12+, ARCore semantic labels).
|
|
150
|
+
Indicates what type of surface this plane represents.
|
|
151
|
+
*/
|
|
152
|
+
void setClassification(VROARPlaneClassification classification) {
|
|
153
|
+
_classification = classification;
|
|
154
|
+
}
|
|
155
|
+
VROARPlaneClassification getClassification() const {
|
|
156
|
+
return _classification;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
Change detection and throttling for plane updates.
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
// Check if plane properties have changed significantly
|
|
164
|
+
bool hasSignificantChanges(VROVector3f newCenter, VROVector3f newExtent,
|
|
165
|
+
VROARPlaneAlignment newAlignment,
|
|
166
|
+
const std::vector<VROVector3f> &newBoundaryVertices) const {
|
|
167
|
+
// Thresholds for detecting significant changes
|
|
168
|
+
static const float EXTENT_THRESHOLD = 0.01f; // 1cm change in dimensions
|
|
169
|
+
static const float CENTER_THRESHOLD = 0.01f; // 1cm change in center
|
|
170
|
+
static const float EXTENT_PERCENT_THRESHOLD = 0.05f; // 5% change in size
|
|
171
|
+
|
|
172
|
+
// Check alignment change
|
|
173
|
+
if (newAlignment != _alignment) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Check extent change (absolute and percentage)
|
|
178
|
+
VROVector3f extentDiff = newExtent - _extent;
|
|
179
|
+
float maxExtentDiff = std::max(std::abs(extentDiff.x), std::abs(extentDiff.z));
|
|
180
|
+
if (maxExtentDiff > EXTENT_THRESHOLD) {
|
|
181
|
+
// Also check percentage change for larger planes
|
|
182
|
+
if (_extent.magnitude() > 0.001f) {
|
|
183
|
+
float percentChange = maxExtentDiff / _extent.magnitude();
|
|
184
|
+
if (percentChange > EXTENT_PERCENT_THRESHOLD) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
// For very small planes, any change is significant
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Check center change
|
|
194
|
+
VROVector3f centerDiff = newCenter - _center;
|
|
195
|
+
if (centerDiff.magnitude() > CENTER_THRESHOLD) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Check boundary vertices count change
|
|
200
|
+
if (newBoundaryVertices.size() != _boundaryVertices.size()) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Check boundary vertices significant changes (sample-based for performance)
|
|
205
|
+
if (!newBoundaryVertices.empty() && !_boundaryVertices.empty()) {
|
|
206
|
+
// Sample a few vertices instead of checking all for performance
|
|
207
|
+
size_t sampleCount = std::min(size_t(4), newBoundaryVertices.size());
|
|
208
|
+
size_t step = newBoundaryVertices.size() / sampleCount;
|
|
209
|
+
if (step < 1) step = 1;
|
|
210
|
+
|
|
211
|
+
for (size_t i = 0; i < newBoundaryVertices.size(); i += step) {
|
|
212
|
+
VROVector3f diff = newBoundaryVertices[i] - _boundaryVertices[i];
|
|
213
|
+
if (diff.magnitude() > CENTER_THRESHOLD) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Check if update should be throttled
|
|
223
|
+
bool shouldThrottleUpdate() const {
|
|
224
|
+
// Minimum time between updates (milliseconds)
|
|
225
|
+
static const int MIN_UPDATE_INTERVAL_MS = 100; // 10 updates per second max
|
|
226
|
+
|
|
227
|
+
auto now = std::chrono::steady_clock::now();
|
|
228
|
+
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - _lastUpdateTime).count();
|
|
229
|
+
|
|
230
|
+
return elapsed < MIN_UPDATE_INTERVAL_MS;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Mark that an update occurred
|
|
234
|
+
void recordUpdate(bool wasSignificant) {
|
|
235
|
+
_lastUpdateTime = std::chrono::steady_clock::now();
|
|
236
|
+
_updateCount++;
|
|
237
|
+
if (wasSignificant) {
|
|
238
|
+
_significantChangeCount++;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Get update statistics for diagnostics
|
|
243
|
+
uint32_t getUpdateCount() const { return _updateCount; }
|
|
244
|
+
uint32_t getSignificantChangeCount() const { return _significantChangeCount; }
|
|
245
|
+
float getSignificantChangeRatio() const {
|
|
246
|
+
return _updateCount > 0 ? (float)_significantChangeCount / _updateCount : 0.0f;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Get time since last update (milliseconds) - useful for debugging update frequency
|
|
250
|
+
int64_t getTimeSinceLastUpdate() const {
|
|
251
|
+
auto now = std::chrono::steady_clock::now();
|
|
252
|
+
return std::chrono::duration_cast<std::chrono::milliseconds>(now - _lastUpdateTime).count();
|
|
253
|
+
}
|
|
254
|
+
|
|
89
255
|
private:
|
|
90
256
|
|
|
91
257
|
/*
|
|
@@ -108,6 +274,27 @@ private:
|
|
|
108
274
|
A vector of points representing the vertex boundaries of this plane, if any.
|
|
109
275
|
*/
|
|
110
276
|
std::vector<VROVector3f> _boundaryVertices;
|
|
277
|
+
|
|
278
|
+
/*
|
|
279
|
+
Full mesh geometry (iOS 11.3+ only).
|
|
280
|
+
Detailed tessellated mesh from ARSCNPlaneGeometry.
|
|
281
|
+
Empty on Android as ARCore only provides boundary polygon.
|
|
282
|
+
*/
|
|
283
|
+
std::vector<VROVector3f> _meshVertices;
|
|
284
|
+
std::vector<VROVector2f> _textureCoordinates;
|
|
285
|
+
std::vector<int> _triangleIndices;
|
|
286
|
+
|
|
287
|
+
/*
|
|
288
|
+
Plane classification (iOS 12+, ARCore semantic labels).
|
|
289
|
+
*/
|
|
290
|
+
VROARPlaneClassification _classification = VROARPlaneClassification::None;
|
|
291
|
+
|
|
292
|
+
/*
|
|
293
|
+
Update tracking and throttling.
|
|
294
|
+
*/
|
|
295
|
+
std::chrono::steady_clock::time_point _lastUpdateTime;
|
|
296
|
+
uint32_t _updateCount;
|
|
297
|
+
uint32_t _significantChangeCount;
|
|
111
298
|
};
|
|
112
299
|
|
|
113
300
|
#endif /* VROARPlaneAnchor_h */
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VROVector2f.h
|
|
3
|
+
// ViroRenderer
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2025 Viro Media. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
// a copy of this software and associated documentation files (the
|
|
9
|
+
// "Software"), to deal in the Software without restriction, including
|
|
10
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
// the following conditions:
|
|
14
|
+
//
|
|
15
|
+
// The above copyright notice and this permission notice shall be included
|
|
16
|
+
// in all copies or substantial portions of the Software.
|
|
17
|
+
//
|
|
18
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
#ifndef VROVECTOR2F_H_
|
|
27
|
+
#define VROVECTOR2F_H_
|
|
28
|
+
|
|
29
|
+
#include <stdlib.h>
|
|
30
|
+
#include <math.h>
|
|
31
|
+
#include <string>
|
|
32
|
+
|
|
33
|
+
class VROVector2f {
|
|
34
|
+
public:
|
|
35
|
+
float x;
|
|
36
|
+
float y;
|
|
37
|
+
|
|
38
|
+
VROVector2f() noexcept : x(0), y(0) {}
|
|
39
|
+
VROVector2f(float x, float y) : x(x), y(y) {}
|
|
40
|
+
|
|
41
|
+
VROVector2f &operator*=(const float multiplier) {
|
|
42
|
+
x *= multiplier;
|
|
43
|
+
y *= multiplier;
|
|
44
|
+
return *this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
VROVector2f &operator/=(const float divisor) {
|
|
48
|
+
x /= divisor;
|
|
49
|
+
y /= divisor;
|
|
50
|
+
return *this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
VROVector2f &operator+=(const VROVector2f &rhs) {
|
|
54
|
+
x += rhs.x;
|
|
55
|
+
y += rhs.y;
|
|
56
|
+
return *this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
VROVector2f &operator-=(const VROVector2f &rhs) {
|
|
60
|
+
x -= rhs.x;
|
|
61
|
+
y -= rhs.y;
|
|
62
|
+
return *this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
VROVector2f operator+(const VROVector2f &vec) const {
|
|
66
|
+
VROVector2f result = *this;
|
|
67
|
+
result += vec;
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
VROVector2f operator-(const VROVector2f &vec) const {
|
|
72
|
+
VROVector2f result = *this;
|
|
73
|
+
result -= vec;
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
VROVector2f operator*(const float multiplier) const {
|
|
78
|
+
VROVector2f result = *this;
|
|
79
|
+
result *= multiplier;
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
VROVector2f operator/(const float divisor) const {
|
|
84
|
+
VROVector2f result = *this;
|
|
85
|
+
result /= divisor;
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
bool operator==(const VROVector2f &rhs) const {
|
|
90
|
+
return x == rhs.x && y == rhs.y;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
bool operator!=(const VROVector2f &rhs) const {
|
|
94
|
+
return !(*this == rhs);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
float magnitude() const {
|
|
98
|
+
return sqrtf(x * x + y * y);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
float distance(const VROVector2f &to) const {
|
|
102
|
+
float dx = to.x - x;
|
|
103
|
+
float dy = to.y - y;
|
|
104
|
+
return sqrtf(dx * dx + dy * dy);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
VROVector2f normalize() const {
|
|
108
|
+
float mag = magnitude();
|
|
109
|
+
if (mag > 0) {
|
|
110
|
+
return VROVector2f(x / mag, y / mag);
|
|
111
|
+
}
|
|
112
|
+
return VROVector2f(0, 0);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
float dot(const VROVector2f &rhs) const {
|
|
116
|
+
return x * rhs.x + y * rhs.y;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
std::string toString() const {
|
|
120
|
+
return "[" + std::to_string(x) + ", " + std::to_string(y) + "]";
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
#endif /* VROVECTOR2F_H_ */
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"version": "2.44.
|
|
6
|
+
"version": "2.44.2",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -88,6 +88,6 @@
|
|
|
88
88
|
"bugs": {
|
|
89
89
|
"url": "https://github.com/ReactVision/viro/issues"
|
|
90
90
|
},
|
|
91
|
-
"homepage": "https://
|
|
92
|
-
"author": ""
|
|
91
|
+
"homepage": "https://reactvision.xyz/viro-react",
|
|
92
|
+
"author": "ReactVision, Inc"
|
|
93
93
|
}
|