@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
|
Binary file
|
|
Binary file
|
|
@@ -12,39 +12,49 @@
|
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
ViroARPlaneSizes,
|
|
16
15
|
ViroClickStateEvent,
|
|
17
16
|
ViroPlaneUpdatedMap,
|
|
18
17
|
} from "../Types/ViroEvents";
|
|
19
18
|
import { ViroARPlaneType, ViroNativeRef } from "../Types/ViroUtils";
|
|
19
|
+
|
|
20
|
+
type ViroARPlaneClassification =
|
|
21
|
+
| "None"
|
|
22
|
+
| "Wall"
|
|
23
|
+
| "Floor"
|
|
24
|
+
| "Ceiling"
|
|
25
|
+
| "Table"
|
|
26
|
+
| "Seat"
|
|
27
|
+
| "Door"
|
|
28
|
+
| "Window"
|
|
29
|
+
| "Unknown";
|
|
20
30
|
import * as React from "react";
|
|
21
31
|
import { ViroMaterials } from "../Material/ViroMaterials";
|
|
22
32
|
import { ViroNode } from "../ViroNode";
|
|
23
33
|
import { ViroQuad } from "../ViroQuad";
|
|
34
|
+
import { ViroPolygon } from "../ViroPolygon";
|
|
24
35
|
import { ViroARPlane } from "./ViroARPlane";
|
|
25
|
-
import { ViroCommonProps, ViroObjectProps } from "./ViroCommonProps";
|
|
26
36
|
|
|
27
|
-
var _maxPlanes = 15;
|
|
28
37
|
var _planePrefix = "ViroARPlaneSelector_Plane_";
|
|
29
38
|
|
|
30
|
-
type Props =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
type Props = {
|
|
40
|
+
minHeight?: number;
|
|
41
|
+
minWidth?: number;
|
|
42
|
+
alignment?:
|
|
43
|
+
| "Horizontal"
|
|
44
|
+
| "HorizontalUpward"
|
|
45
|
+
| "HorizontalDownward"
|
|
46
|
+
| "Vertical"
|
|
47
|
+
| "Both"; // Added "Both" option to detect both horizontal and vertical
|
|
48
|
+
onPlaneSelected?: (updateMap: ViroPlaneUpdatedMap) => void;
|
|
49
|
+
onPlaneDetected?: (updateMap: ViroPlaneUpdatedMap) => boolean; // Optional validation callback
|
|
50
|
+
disableClickSelection?: boolean; // Disable click-based selection, only show planes visually
|
|
51
|
+
useActualShape?: boolean; // Use boundary vertices for accurate shape (default: true)
|
|
52
|
+
children?: React.ReactNode;
|
|
53
|
+
};
|
|
43
54
|
|
|
44
55
|
type State = {
|
|
45
|
-
|
|
46
|
-
foundARPlanes: ViroARPlaneType
|
|
47
|
-
arPlaneSizes: ViroARPlaneSizes;
|
|
56
|
+
selectedPlaneId: string | null;
|
|
57
|
+
foundARPlanes: Map<string, ViroARPlaneType>;
|
|
48
58
|
};
|
|
49
59
|
|
|
50
60
|
/**
|
|
@@ -54,10 +64,9 @@ type State = {
|
|
|
54
64
|
*/
|
|
55
65
|
export class ViroARPlaneSelector extends React.Component<Props, State> {
|
|
56
66
|
_component: ViroNativeRef = null;
|
|
57
|
-
state = {
|
|
58
|
-
|
|
59
|
-
foundARPlanes:
|
|
60
|
-
arPlaneSizes: [] as number[],
|
|
67
|
+
state: State = {
|
|
68
|
+
selectedPlaneId: null,
|
|
69
|
+
foundARPlanes: new Map<string, ViroARPlaneType>(),
|
|
61
70
|
};
|
|
62
71
|
|
|
63
72
|
render() {
|
|
@@ -68,80 +77,172 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
|
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
_getARPlanes() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
: [0, 0, 0];
|
|
90
|
-
const anchorId = hasPlaneData
|
|
91
|
-
? (foundARPlane as any).anchorId
|
|
92
|
-
: undefined;
|
|
93
|
-
|
|
94
|
-
// Determine visibility based on selection state
|
|
95
|
-
// - In selection mode (selectedSurface === -1): show all planes
|
|
96
|
-
// - In selected mode: only show the selected plane
|
|
97
|
-
const isVisible = this.state.selectedSurface === -1 || isSelected;
|
|
98
|
-
|
|
99
|
-
arPlanes.push(
|
|
100
|
-
<ViroARPlane
|
|
101
|
-
key={_planePrefix + i}
|
|
102
|
-
minWidth={this.props.minWidth || 0.5}
|
|
103
|
-
minHeight={this.props.minHeight || 0.5}
|
|
104
|
-
alignment={this.props.alignment}
|
|
105
|
-
anchorId={anchorId}
|
|
106
|
-
onAnchorFound={(anchor) => {
|
|
107
|
-
// If we find an anchor, update our plane data
|
|
108
|
-
this._onARPlaneUpdated(i)(anchor);
|
|
109
|
-
}}
|
|
110
|
-
onAnchorUpdated={this._onARPlaneUpdated(i)}
|
|
111
|
-
>
|
|
112
|
-
{/* Always render both the quad and children, controlling only visibility */}
|
|
113
|
-
<ViroQuad
|
|
114
|
-
materials={"ViroARPlaneSelector_Translucent"}
|
|
115
|
-
onClickState={(clickState, position, source) =>
|
|
116
|
-
this._getOnClickSurface(i, { clickState, position, source })
|
|
117
|
-
}
|
|
118
|
-
position={surfacePosition}
|
|
119
|
-
width={surfaceWidth}
|
|
120
|
-
height={surfaceHeight}
|
|
121
|
-
rotation={[-90, 0, 0]}
|
|
122
|
-
opacity={isSelected ? 0 : isVisible ? 1 : 0}
|
|
123
|
-
/>
|
|
124
|
-
|
|
125
|
-
{/* Wrap children in a ViroNode to control visibility if children exist */}
|
|
126
|
-
{this.props.children && (
|
|
127
|
-
<ViroNode opacity={isSelected ? 1 : 0}>
|
|
128
|
-
{this.props.children}
|
|
129
|
-
</ViroNode>
|
|
130
|
-
)}
|
|
131
|
-
</ViroARPlane>
|
|
80
|
+
const arPlanes: React.JSX.Element[] = [];
|
|
81
|
+
const detectBothAlignments =
|
|
82
|
+
this.props.alignment === "Both" || !this.props.alignment;
|
|
83
|
+
|
|
84
|
+
// Determine which alignments to detect
|
|
85
|
+
const alignmentsToDetect: Array<
|
|
86
|
+
"Horizontal" | "HorizontalUpward" | "HorizontalDownward" | "Vertical"
|
|
87
|
+
> = [];
|
|
88
|
+
if (detectBothAlignments) {
|
|
89
|
+
alignmentsToDetect.push("Horizontal", "Vertical");
|
|
90
|
+
} else if (this.props.alignment) {
|
|
91
|
+
// Type assertion safe here because we know it's not "Both" due to detectBothAlignments check
|
|
92
|
+
alignmentsToDetect.push(
|
|
93
|
+
this.props.alignment as
|
|
94
|
+
| "Horizontal"
|
|
95
|
+
| "HorizontalUpward"
|
|
96
|
+
| "HorizontalDownward"
|
|
97
|
+
| "Vertical"
|
|
132
98
|
);
|
|
133
99
|
}
|
|
134
100
|
|
|
101
|
+
// Create detector ViroARPlane components for each alignment type
|
|
102
|
+
// These don't have anchorId set initially, but will discover and track planes
|
|
103
|
+
// We add visual children based on detected plane data
|
|
104
|
+
const detectorsPerAlignment = 25; // 25 detectors per alignment type
|
|
105
|
+
|
|
106
|
+
alignmentsToDetect.forEach((alignment) => {
|
|
107
|
+
for (let i = 0; i < detectorsPerAlignment; i++) {
|
|
108
|
+
const detectorKey = `${_planePrefix}detector_${alignment}_${i}`;
|
|
109
|
+
|
|
110
|
+
// Check if this detector has discovered a plane
|
|
111
|
+
// We'll match by checking if any plane in foundARPlanes has this alignment
|
|
112
|
+
// and hasn't been assigned to a previous detector
|
|
113
|
+
// Note: ARCore returns "HorizontalUpward", "HorizontalDownward", etc.
|
|
114
|
+
// so we need to check if alignment starts with the requested type
|
|
115
|
+
const detectedPlanes = Array.from(
|
|
116
|
+
this.state.foundARPlanes.entries()
|
|
117
|
+
).filter(([_id, plane]) => {
|
|
118
|
+
if (alignment === "Horizontal") {
|
|
119
|
+
return plane.alignment.includes("Horizontal");
|
|
120
|
+
} else if (alignment === "Vertical") {
|
|
121
|
+
return plane.alignment.includes("Vertical");
|
|
122
|
+
}
|
|
123
|
+
return plane.alignment === alignment;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const planeData = detectedPlanes[i]?.[1];
|
|
127
|
+
const anchorId = detectedPlanes[i]?.[0];
|
|
128
|
+
const hasPlaneData = !!planeData;
|
|
129
|
+
|
|
130
|
+
// Extract visual rendering data if plane detected
|
|
131
|
+
let visualElement = null;
|
|
132
|
+
if (hasPlaneData) {
|
|
133
|
+
const isSelected = this.state.selectedPlaneId === anchorId;
|
|
134
|
+
const surfaceWidth = planeData.width || 0.5;
|
|
135
|
+
const surfaceHeight = planeData.height || 0.5;
|
|
136
|
+
const vertices3D = (planeData as any).vertices;
|
|
137
|
+
|
|
138
|
+
// Convert 3D vertices to 2D based on plane alignment
|
|
139
|
+
// ViroARPlane provides vertices in the plane's LOCAL coordinate system
|
|
140
|
+
// where the plane is always in the XZ plane. The anchor handles world orientation.
|
|
141
|
+
// Always extract [x, z] since vertices are in the plane's local XZ plane
|
|
142
|
+
const vertices2D =
|
|
143
|
+
vertices3D && vertices3D.length >= 3
|
|
144
|
+
? vertices3D.map(
|
|
145
|
+
([x, _y, z]: [number, number, number]): [number, number] => [
|
|
146
|
+
x,
|
|
147
|
+
z,
|
|
148
|
+
]
|
|
149
|
+
)
|
|
150
|
+
: undefined;
|
|
151
|
+
|
|
152
|
+
// Rotation for ViroPolygon:
|
|
153
|
+
// ViroPolygon renders in XY plane by default, vertices are provided in XZ
|
|
154
|
+
// Need to rotate to map XZ plane to XY rendering plane
|
|
155
|
+
const polygonRotation: [number, number, number] = [-90, 0, 0];
|
|
156
|
+
|
|
157
|
+
const isVisible = this.state.selectedPlaneId === null || isSelected;
|
|
158
|
+
|
|
159
|
+
// Use actual plane shapes (ViroPolygon with vertices)
|
|
160
|
+
const forceQuadForAndroid = false; // Now using actual shapes on Android
|
|
161
|
+
|
|
162
|
+
const useActualShape =
|
|
163
|
+
!forceQuadForAndroid &&
|
|
164
|
+
this.props.useActualShape !== false &&
|
|
165
|
+
vertices2D &&
|
|
166
|
+
vertices2D.length >= 3;
|
|
167
|
+
|
|
168
|
+
const finalOpacity = isSelected ? 0 : isVisible ? 1 : 0;
|
|
169
|
+
|
|
170
|
+
visualElement = useActualShape ? (
|
|
171
|
+
<ViroPolygon
|
|
172
|
+
key={`polygon-${anchorId}`}
|
|
173
|
+
vertices={vertices2D!}
|
|
174
|
+
holes={[]}
|
|
175
|
+
materials={["ViroARPlaneSelector_Translucent"]}
|
|
176
|
+
{...(!this.props.disableClickSelection && {
|
|
177
|
+
onClickState: (clickState, position, source) =>
|
|
178
|
+
this._getOnClickSurface(anchorId, {
|
|
179
|
+
clickState,
|
|
180
|
+
position,
|
|
181
|
+
source,
|
|
182
|
+
}),
|
|
183
|
+
})}
|
|
184
|
+
position={[0, 0, 0]}
|
|
185
|
+
rotation={polygonRotation}
|
|
186
|
+
opacity={finalOpacity}
|
|
187
|
+
/>
|
|
188
|
+
) : (
|
|
189
|
+
<ViroQuad
|
|
190
|
+
key={`quad-${anchorId}`}
|
|
191
|
+
materials={["ViroARPlaneSelector_Translucent"]}
|
|
192
|
+
{...(!this.props.disableClickSelection && {
|
|
193
|
+
onClickState: (clickState, position, source) =>
|
|
194
|
+
this._getOnClickSurface(anchorId, {
|
|
195
|
+
clickState,
|
|
196
|
+
position,
|
|
197
|
+
source,
|
|
198
|
+
}),
|
|
199
|
+
})}
|
|
200
|
+
position={[0, 0, 0]}
|
|
201
|
+
width={surfaceWidth}
|
|
202
|
+
height={surfaceHeight}
|
|
203
|
+
rotation={polygonRotation}
|
|
204
|
+
opacity={finalOpacity}
|
|
205
|
+
/>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
arPlanes.push(
|
|
210
|
+
<ViroARPlane
|
|
211
|
+
key={detectorKey}
|
|
212
|
+
minWidth={this.props.minWidth || 0}
|
|
213
|
+
minHeight={this.props.minHeight || 0}
|
|
214
|
+
alignment={alignment}
|
|
215
|
+
anchorId={hasPlaneData ? anchorId : undefined}
|
|
216
|
+
onAnchorFound={(anchor) => {
|
|
217
|
+
this._onARPlaneUpdated(anchor);
|
|
218
|
+
}}
|
|
219
|
+
onAnchorUpdated={(anchor) => {
|
|
220
|
+
this._onARPlaneUpdated(anchor);
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
{visualElement}
|
|
224
|
+
{hasPlaneData && this.props.children && (
|
|
225
|
+
<ViroNode
|
|
226
|
+
opacity={this.state.selectedPlaneId === anchorId ? 1 : 0}
|
|
227
|
+
>
|
|
228
|
+
{this.props.children}
|
|
229
|
+
</ViroNode>
|
|
230
|
+
)}
|
|
231
|
+
</ViroARPlane>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
135
236
|
return arPlanes;
|
|
136
237
|
}
|
|
137
238
|
|
|
138
|
-
_getOnClickSurface = (
|
|
239
|
+
_getOnClickSurface = (anchorId: string, event: ViroClickStateEvent) => {
|
|
139
240
|
if (event.clickState < 3) {
|
|
140
241
|
return;
|
|
141
242
|
}
|
|
142
243
|
|
|
143
244
|
// Get the plane data before updating state to avoid race conditions
|
|
144
|
-
const selectedPlane = this.state.foundARPlanes
|
|
245
|
+
const selectedPlane = this.state.foundARPlanes.get(anchorId);
|
|
145
246
|
if (!selectedPlane) {
|
|
146
247
|
console.warn(
|
|
147
248
|
"ViroARPlaneSelector: Cannot select plane - plane data not found"
|
|
@@ -150,32 +251,54 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
|
|
|
150
251
|
}
|
|
151
252
|
|
|
152
253
|
// Update state and call callback with the captured data
|
|
153
|
-
this.setState({
|
|
254
|
+
this.setState({ selectedPlaneId: anchorId }, () => {
|
|
154
255
|
this._onPlaneSelected(selectedPlane);
|
|
155
256
|
});
|
|
156
257
|
};
|
|
157
258
|
|
|
158
|
-
_onARPlaneUpdated = (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
259
|
+
_onARPlaneUpdated = (anchor: any) => {
|
|
260
|
+
if (!anchor.anchorId) {
|
|
261
|
+
console.warn("ViroARPlaneSelector: Anchor missing anchorId");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const updateMap: ViroPlaneUpdatedMap = {
|
|
266
|
+
anchorId: anchor.anchorId,
|
|
267
|
+
type: anchor.type || "plane",
|
|
268
|
+
position: anchor.position,
|
|
269
|
+
rotation: anchor.rotation,
|
|
270
|
+
scale: anchor.scale,
|
|
271
|
+
center: anchor.center,
|
|
272
|
+
width: anchor.width,
|
|
273
|
+
height: anchor.height,
|
|
274
|
+
alignment: anchor.alignment,
|
|
275
|
+
classification: anchor.classification,
|
|
276
|
+
vertices: anchor.vertices,
|
|
166
277
|
};
|
|
278
|
+
|
|
279
|
+
// Update or add plane in Map
|
|
280
|
+
this.setState((prevState) => {
|
|
281
|
+
const newPlanes = new Map(prevState.foundARPlanes);
|
|
282
|
+
newPlanes.set(anchor.anchorId, updateMap as ViroARPlaneType);
|
|
283
|
+
return { foundARPlanes: newPlanes };
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Call validation callback if provided
|
|
287
|
+
if (this.props.onPlaneDetected) {
|
|
288
|
+
this.props.onPlaneDetected(updateMap);
|
|
289
|
+
}
|
|
167
290
|
};
|
|
168
291
|
|
|
169
292
|
_onPlaneSelected = (updateMap: ViroPlaneUpdatedMap) => {
|
|
170
293
|
this.props.onPlaneSelected && this.props.onPlaneSelected(updateMap);
|
|
171
294
|
};
|
|
172
295
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
296
|
+
/**
|
|
297
|
+
* This function allows the user to reset the surface and select a new plane.
|
|
298
|
+
*/
|
|
176
299
|
reset = () => {
|
|
177
300
|
this.setState({
|
|
178
|
-
|
|
301
|
+
selectedPlaneId: null,
|
|
179
302
|
});
|
|
180
303
|
};
|
|
181
304
|
}
|
|
@@ -183,6 +306,9 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
|
|
|
183
306
|
ViroMaterials.createMaterials({
|
|
184
307
|
ViroARPlaneSelector_Translucent: {
|
|
185
308
|
lightingModel: "Constant",
|
|
186
|
-
diffuseColor: "
|
|
309
|
+
diffuseColor: "rgba(0, 122, 255, 0.5)", // Bright blue with 50% opacity for better visibility
|
|
310
|
+
blendMode: "Alpha",
|
|
311
|
+
cullMode: "None", // Render both sides for better Android compatibility
|
|
312
|
+
writesToDepthBuffer: false,
|
|
187
313
|
},
|
|
188
314
|
});
|
|
@@ -16,8 +16,10 @@ import {
|
|
|
16
16
|
NativeModules,
|
|
17
17
|
processColor,
|
|
18
18
|
} from "react-native";
|
|
19
|
+
|
|
19
20
|
// @ts-ignore
|
|
20
|
-
import
|
|
21
|
+
import { getAssetByID } from "react-native/Libraries/Image/AssetRegistry";
|
|
22
|
+
|
|
21
23
|
// @ts-ignore
|
|
22
24
|
import resolveAssetSource from "react-native/Libraries/Image/resolveAssetSource";
|
|
23
25
|
import { ViroSource } from "../Types/ViroUtils";
|
|
@@ -104,7 +106,7 @@ export class ViroMaterials {
|
|
|
104
106
|
} else {
|
|
105
107
|
var assetType = "unknown";
|
|
106
108
|
if (typeof material[prop] !== "object") {
|
|
107
|
-
var asset =
|
|
109
|
+
var asset = getAssetByID(material[prop]);
|
|
108
110
|
if (asset) {
|
|
109
111
|
assetType = asset.type;
|
|
110
112
|
}
|
|
@@ -212,6 +212,55 @@ export type ViroAnimatedComponentFinishEvent = {};
|
|
|
212
212
|
/** ===========================================================================
|
|
213
213
|
* Viro AR Anchor Events
|
|
214
214
|
* ============================================================================ */
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Classification of detected planes.
|
|
218
|
+
* iOS 12+ provides ML-based classification via ARKit.
|
|
219
|
+
* Android provides basic inference from plane orientation.
|
|
220
|
+
*/
|
|
221
|
+
export type ViroARPlaneClassification =
|
|
222
|
+
| "None"
|
|
223
|
+
| "Wall"
|
|
224
|
+
| "Floor"
|
|
225
|
+
| "Ceiling"
|
|
226
|
+
| "Table"
|
|
227
|
+
| "Seat"
|
|
228
|
+
| "Door"
|
|
229
|
+
| "Window"
|
|
230
|
+
| "Unknown";
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Alignment of detected planes with respect to gravity.
|
|
234
|
+
*/
|
|
235
|
+
export type ViroARPlaneAlignment =
|
|
236
|
+
| "Horizontal"
|
|
237
|
+
| "HorizontalUpward"
|
|
238
|
+
| "HorizontalDownward"
|
|
239
|
+
| "Vertical";
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Represents an AR anchor detected in the real world.
|
|
243
|
+
*/
|
|
244
|
+
export type ViroAnchor = {
|
|
245
|
+
anchorId: string;
|
|
246
|
+
type: "anchor" | "plane" | "image";
|
|
247
|
+
position: [number, number, number];
|
|
248
|
+
rotation: [number, number, number]; // In degrees
|
|
249
|
+
scale: [number, number, number];
|
|
250
|
+
// Plane-specific properties (present when type === "plane")
|
|
251
|
+
center?: [number, number, number];
|
|
252
|
+
width?: number;
|
|
253
|
+
height?: number;
|
|
254
|
+
alignment?: ViroARPlaneAlignment;
|
|
255
|
+
classification?: ViroARPlaneClassification;
|
|
256
|
+
vertices?: Array<[number, number, number]>;
|
|
257
|
+
// Image-specific properties (present when type === "image")
|
|
258
|
+
trackingMethod?: string;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export type ViroAnchorFoundMap = ViroAnchor;
|
|
262
|
+
export type ViroAnchorUpdatedMap = ViroAnchor;
|
|
263
|
+
|
|
215
264
|
export type ViroARAnchorRemovedEvent = {
|
|
216
265
|
anchor: ViroAnchor;
|
|
217
266
|
};
|
|
@@ -223,15 +272,11 @@ export type ViroARAnchorFoundEvent = {
|
|
|
223
272
|
anchorFoundMap: ViroAnchorFoundMap;
|
|
224
273
|
anchor: ViroAnchor;
|
|
225
274
|
};
|
|
226
|
-
export type ViroAnchor = any;
|
|
227
|
-
|
|
228
|
-
export type ViroAnchorFoundMap = any;
|
|
229
|
-
export type ViroAnchorUpdatedMap = any;
|
|
230
275
|
|
|
231
276
|
/** ===========================================================================
|
|
232
277
|
* Viro AR Plane Events
|
|
233
278
|
* ============================================================================ */
|
|
234
|
-
export type ViroPlaneUpdatedMap =
|
|
279
|
+
export type ViroPlaneUpdatedMap = ViroAnchor;
|
|
235
280
|
export type ViroPlaneUpdatedEvent = any;
|
|
236
281
|
export type ViroARPlaneSizes = any;
|
|
237
282
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VIRO_VERSION = "2.44.
|
|
1
|
+
export const VIRO_VERSION = "2.44.2";
|
|
@@ -8,21 +8,22 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ViroARPlaneSelector
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { ViroClickStateEvent, ViroPlaneUpdatedMap } from "../Types/ViroEvents";
|
|
12
12
|
import { ViroARPlaneType, ViroNativeRef } from "../Types/ViroUtils";
|
|
13
13
|
import * as React from "react";
|
|
14
|
-
|
|
15
|
-
type Props = ViroCommonProps & ViroObjectProps & {
|
|
16
|
-
maxPlanes?: number;
|
|
14
|
+
type Props = {
|
|
17
15
|
minHeight?: number;
|
|
18
16
|
minWidth?: number;
|
|
19
|
-
alignment?: "Horizontal" | "HorizontalUpward" | "HorizontalDownward" | "Vertical";
|
|
17
|
+
alignment?: "Horizontal" | "HorizontalUpward" | "HorizontalDownward" | "Vertical" | "Both";
|
|
20
18
|
onPlaneSelected?: (updateMap: ViroPlaneUpdatedMap) => void;
|
|
19
|
+
onPlaneDetected?: (updateMap: ViroPlaneUpdatedMap) => boolean;
|
|
20
|
+
disableClickSelection?: boolean;
|
|
21
|
+
useActualShape?: boolean;
|
|
22
|
+
children?: React.ReactNode;
|
|
21
23
|
};
|
|
22
24
|
type State = {
|
|
23
|
-
|
|
24
|
-
foundARPlanes: ViroARPlaneType
|
|
25
|
-
arPlaneSizes: ViroARPlaneSizes;
|
|
25
|
+
selectedPlaneId: string | null;
|
|
26
|
+
foundARPlanes: Map<string, ViroARPlaneType>;
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* This component wraps the logic required to enable user selection
|
|
@@ -31,16 +32,15 @@ type State = {
|
|
|
31
32
|
*/
|
|
32
33
|
export declare class ViroARPlaneSelector extends React.Component<Props, State> {
|
|
33
34
|
_component: ViroNativeRef;
|
|
34
|
-
state:
|
|
35
|
-
selectedSurface: number;
|
|
36
|
-
foundARPlanes: ViroARPlaneType[];
|
|
37
|
-
arPlaneSizes: number[];
|
|
38
|
-
};
|
|
35
|
+
state: State;
|
|
39
36
|
render(): React.JSX.Element;
|
|
40
37
|
_getARPlanes(): React.JSX.Element[];
|
|
41
|
-
_getOnClickSurface: (
|
|
42
|
-
_onARPlaneUpdated: (
|
|
38
|
+
_getOnClickSurface: (anchorId: string, event: ViroClickStateEvent) => void;
|
|
39
|
+
_onARPlaneUpdated: (anchor: any) => void;
|
|
43
40
|
_onPlaneSelected: (updateMap: ViroPlaneUpdatedMap) => void;
|
|
41
|
+
/**
|
|
42
|
+
* This function allows the user to reset the surface and select a new plane.
|
|
43
|
+
*/
|
|
44
44
|
reset: () => void;
|
|
45
45
|
}
|
|
46
46
|
export {};
|