@reactvision/react-viro 2.41.6 → 2.43.0

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.
Files changed (121) hide show
  1. package/android/react_viro/react_viro-release.aar +0 -0
  2. package/components/AR/ViroARPlaneSelector.tsx +76 -37
  3. package/components/AR/ViroARScene.tsx +7 -4
  4. package/components/AR/ViroARSceneNavigator.tsx +1 -2
  5. package/components/Utilities/ViroVersion.ts +1 -1
  6. package/components/Viro3DSceneNavigator.tsx +1 -1
  7. package/components/ViroCamera.tsx +1 -0
  8. package/components/ViroOrbitCamera.tsx +1 -0
  9. package/components/ViroScene.tsx +7 -3
  10. package/components/ViroSceneContext.tsx +4 -3
  11. package/components/ViroSceneNavigator.tsx +1 -1
  12. package/dist/components/AR/ViroARCamera.d.ts +1 -1
  13. package/dist/components/AR/ViroARCamera.js +17 -7
  14. package/dist/components/AR/ViroARImageMarker.d.ts +2 -2
  15. package/dist/components/AR/ViroARImageMarker.js +17 -7
  16. package/dist/components/AR/ViroARObjectMarker.d.ts +2 -2
  17. package/dist/components/AR/ViroARObjectMarker.js +17 -7
  18. package/dist/components/AR/ViroARPlane.d.ts +2 -2
  19. package/dist/components/AR/ViroARPlane.js +17 -7
  20. package/dist/components/AR/ViroARPlaneSelector.d.ts +3 -3
  21. package/dist/components/AR/ViroARPlaneSelector.js +63 -25
  22. package/dist/components/AR/ViroARScene.d.ts +2 -2
  23. package/dist/components/AR/ViroARScene.js +17 -7
  24. package/dist/components/AR/ViroARSceneNavigator.d.ts +2 -2
  25. package/dist/components/AR/ViroARSceneNavigator.js +17 -9
  26. package/dist/components/Types/ViroEvents.d.ts +6 -6
  27. package/dist/components/Types/ViroEvents.js +6 -6
  28. package/dist/components/Types/ViroUtils.d.ts +0 -1
  29. package/dist/components/Utilities/ViroProps.js +1 -2
  30. package/dist/components/Utilities/ViroUtils.js +3 -4
  31. package/dist/components/Utilities/ViroVersion.d.ts +1 -1
  32. package/dist/components/Utilities/ViroVersion.js +1 -1
  33. package/dist/components/Viro360Image.d.ts +1 -1
  34. package/dist/components/Viro360Image.js +17 -7
  35. package/dist/components/Viro360Video.d.ts +1 -1
  36. package/dist/components/Viro360Video.js +17 -7
  37. package/dist/components/Viro3DObject.d.ts +2 -2
  38. package/dist/components/Viro3DObject.js +17 -7
  39. package/dist/components/Viro3DSceneNavigator.d.ts +2 -2
  40. package/dist/components/Viro3DSceneNavigator.js +17 -7
  41. package/dist/components/ViroAmbientLight.d.ts +1 -1
  42. package/dist/components/ViroAmbientLight.js +17 -7
  43. package/dist/components/ViroAnimatedComponent.d.ts +1 -1
  44. package/dist/components/ViroAnimatedComponent.js +17 -7
  45. package/dist/components/ViroAnimatedImage.d.ts +2 -2
  46. package/dist/components/ViroAnimatedImage.js +17 -7
  47. package/dist/components/ViroBase.js +17 -7
  48. package/dist/components/ViroBox.d.ts +2 -2
  49. package/dist/components/ViroBox.js +17 -7
  50. package/dist/components/ViroButton.d.ts +1 -1
  51. package/dist/components/ViroButton.js +18 -8
  52. package/dist/components/ViroCamera.d.ts +3 -1
  53. package/dist/components/ViroCamera.js +17 -7
  54. package/dist/components/ViroConstants.js +3 -3
  55. package/dist/components/ViroController.d.ts +1 -1
  56. package/dist/components/ViroController.js +17 -7
  57. package/dist/components/ViroDirectionalLight.d.ts +1 -1
  58. package/dist/components/ViroDirectionalLight.js +17 -7
  59. package/dist/components/ViroFlexView.d.ts +2 -2
  60. package/dist/components/ViroFlexView.js +17 -7
  61. package/dist/components/ViroGeometry.d.ts +2 -2
  62. package/dist/components/ViroGeometry.js +17 -7
  63. package/dist/components/ViroImage.d.ts +2 -2
  64. package/dist/components/ViroImage.js +17 -7
  65. package/dist/components/ViroLightingEnvironment.d.ts +1 -1
  66. package/dist/components/ViroLightingEnvironment.js +17 -7
  67. package/dist/components/ViroMaterialVideo.d.ts +1 -1
  68. package/dist/components/ViroMaterialVideo.js +17 -7
  69. package/dist/components/ViroNode.d.ts +2 -2
  70. package/dist/components/ViroNode.js +17 -7
  71. package/dist/components/ViroOmniLight.d.ts +1 -1
  72. package/dist/components/ViroOmniLight.js +17 -7
  73. package/dist/components/ViroOrbitCamera.d.ts +3 -1
  74. package/dist/components/ViroOrbitCamera.js +17 -7
  75. package/dist/components/ViroParticleEmitter.d.ts +1 -1
  76. package/dist/components/ViroParticleEmitter.js +17 -7
  77. package/dist/components/ViroPolygon.d.ts +2 -2
  78. package/dist/components/ViroPolygon.js +17 -7
  79. package/dist/components/ViroPolyline.d.ts +2 -2
  80. package/dist/components/ViroPolyline.js +17 -7
  81. package/dist/components/ViroPortal.d.ts +2 -2
  82. package/dist/components/ViroPortal.js +17 -7
  83. package/dist/components/ViroPortalScene.d.ts +2 -2
  84. package/dist/components/ViroPortalScene.js +17 -7
  85. package/dist/components/ViroQuad.d.ts +2 -2
  86. package/dist/components/ViroQuad.js +17 -7
  87. package/dist/components/ViroScene.d.ts +10 -2
  88. package/dist/components/ViroScene.js +17 -7
  89. package/dist/components/ViroSceneContext.d.ts +4 -3
  90. package/dist/components/ViroSceneContext.js +17 -7
  91. package/dist/components/ViroSceneNavigator.d.ts +2 -2
  92. package/dist/components/ViroSceneNavigator.js +17 -7
  93. package/dist/components/ViroSkyBox.d.ts +1 -1
  94. package/dist/components/ViroSkyBox.js +17 -7
  95. package/dist/components/ViroSound.d.ts +1 -1
  96. package/dist/components/ViroSound.js +17 -7
  97. package/dist/components/ViroSoundField.d.ts +1 -1
  98. package/dist/components/ViroSoundField.js +17 -7
  99. package/dist/components/ViroSpatialSound.d.ts +1 -1
  100. package/dist/components/ViroSpatialSound.js +17 -7
  101. package/dist/components/ViroSphere.d.ts +2 -2
  102. package/dist/components/ViroSphere.js +17 -7
  103. package/dist/components/ViroSpinner.d.ts +2 -2
  104. package/dist/components/ViroSpinner.js +17 -7
  105. package/dist/components/ViroSpotLight.d.ts +1 -1
  106. package/dist/components/ViroSpotLight.js +17 -7
  107. package/dist/components/ViroSurface.d.ts +2 -2
  108. package/dist/components/ViroSurface.js +17 -7
  109. package/dist/components/ViroText.d.ts +2 -2
  110. package/dist/components/ViroText.js +17 -7
  111. package/dist/components/ViroVRSceneNavigator.d.ts +2 -2
  112. package/dist/components/ViroVRSceneNavigator.js +17 -7
  113. package/dist/components/ViroVideo.d.ts +10 -2
  114. package/dist/components/ViroVideo.js +17 -7
  115. package/dist/index.d.ts +1 -2
  116. package/dist/index.js +1 -3
  117. package/dist/plugins/withViroAndroid.js +15 -11
  118. package/dist/plugins/withViroIos.js +1 -1
  119. package/index.ts +0 -2
  120. package/package.json +23 -14
  121. package/components/Telemetry/ViroTelemetry.ts +0 -93
@@ -68,52 +68,91 @@ export class ViroARPlaneSelector extends React.Component<Props, State> {
68
68
  }
69
69
 
70
70
  _getARPlanes() {
71
- if (this.state.selectedSurface == -1) {
72
- let arPlanes: JSX.Element[] = [];
73
- let numPlanes = this.props.maxPlanes || _maxPlanes;
74
- for (let i = 0; i < numPlanes; i++) {
75
- let foundARPlane = this.state.foundARPlanes[i];
76
- let surfaceWidth = foundARPlane ? foundARPlane.width : 0;
77
- let surfaceHeight = foundARPlane ? foundARPlane.height : 0;
78
- let surfacePosition = foundARPlane ? foundARPlane.center : [0, 0, 0];
79
- arPlanes.push(
80
- <ViroARPlane
81
- key={_planePrefix + i}
82
- minWidth={this.props.minWidth}
83
- minHeight={this.props.minHeight}
84
- alignment={this.props.alignment}
85
- onAnchorUpdated={this._onARPlaneUpdated(i)}
86
- >
87
- <ViroQuad
88
- materials={"ViroARPlaneSelector_Translucent"}
89
- onClickState={(clickState, position, source) =>
90
- this._getOnClickSurface(i, { clickState, position, source })
91
- }
92
- position={surfacePosition}
93
- width={surfaceWidth}
94
- height={surfaceHeight}
95
- rotation={[-90, 0, 0]}
96
- />
97
- </ViroARPlane>
98
- );
99
- }
100
- return arPlanes;
101
- } else {
102
- return (
71
+ // Always render a fixed number of planes, controlling visibility instead of conditional rendering
72
+ let arPlanes: JSX.Element[] = [];
73
+ let numPlanes = this.props.maxPlanes || _maxPlanes;
74
+
75
+ // Create all plane slots (both detected and placeholder)
76
+ for (let i = 0; i < numPlanes; i++) {
77
+ // Determine if this is the selected plane
78
+ const isSelected = this.state.selectedSurface === i;
79
+
80
+ // Get real plane data if available, or use defaults
81
+ const foundARPlane = this.state.foundARPlanes[i];
82
+ const hasPlaneData = !!foundARPlane;
83
+
84
+ // Extract plane data or use defaults
85
+ const surfaceWidth = hasPlaneData ? foundARPlane.width || 0.5 : 0.5;
86
+ const surfaceHeight = hasPlaneData ? foundARPlane.height || 0.5 : 0.5;
87
+ const surfacePosition = hasPlaneData
88
+ ? foundARPlane.center || [0, 0, 0]
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(
103
100
  <ViroARPlane
104
- key={_planePrefix + this.state.selectedSurface}
105
- {...this.props}
106
- ></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>
107
132
  );
108
133
  }
134
+
135
+ return arPlanes;
109
136
  }
110
137
 
111
138
  _getOnClickSurface = (index: number, event: ViroClickStateEvent) => {
112
139
  if (event.clickState < 3) {
113
140
  return;
114
141
  }
115
- this.setState({ selectedSurface: index });
116
- this._onPlaneSelected(this.state.foundARPlanes[index]);
142
+
143
+ // Get the plane data before updating state to avoid race conditions
144
+ const selectedPlane = this.state.foundARPlanes[index];
145
+ if (!selectedPlane) {
146
+ console.warn(
147
+ "ViroARPlaneSelector: Cannot select plane - plane data not found"
148
+ );
149
+ return;
150
+ }
151
+
152
+ // Update state and call callback with the captured data
153
+ this.setState({ selectedSurface: index }, () => {
154
+ this._onPlaneSelected(selectedPlane);
155
+ });
117
156
  };
118
157
 
119
158
  _onARPlaneUpdated = (index: number) => {
@@ -47,7 +47,7 @@ import { ViroBase } from "../ViroBase";
47
47
  import { ViroCamera } from "../ViroCamera";
48
48
  import { ViroTrackingStateConstants } from "../ViroConstants";
49
49
  import { ViroCommonProps } from "./ViroCommonProps";
50
- import { ViroTelemetry } from "../Telemetry/ViroTelemetry";
50
+ import { ViroOrbitCamera } from "components/ViroOrbitCamera";
51
51
 
52
52
  const ViroCameraModule = NativeModules.ViroCameraModule;
53
53
 
@@ -394,7 +394,7 @@ export class ViroARScene extends ViroBase<Props> {
394
394
  return (
395
395
  <ViroSceneContext.Provider
396
396
  value={{
397
- cameraDidMount: (camera: ViroCamera) => {
397
+ cameraDidMount: (camera: ViroCamera | ViroOrbitCamera) => {
398
398
  if (camera.props.active) {
399
399
  NativeModules.VRTCameraModule.setSceneCamera(
400
400
  findNodeHandle(this),
@@ -402,7 +402,7 @@ export class ViroARScene extends ViroBase<Props> {
402
402
  );
403
403
  }
404
404
  },
405
- cameraWillUnmount: (camera: ViroCamera) => {
405
+ cameraWillUnmount: (camera: ViroCamera | ViroOrbitCamera) => {
406
406
  if (camera.props.active) {
407
407
  NativeModules.VRTCameraModule.removeSceneCamera(
408
408
  findNodeHandle(this),
@@ -410,7 +410,10 @@ export class ViroARScene extends ViroBase<Props> {
410
410
  );
411
411
  }
412
412
  },
413
- cameraDidUpdate: (camera: ViroCamera, active: boolean) => {
413
+ cameraDidUpdate: (
414
+ camera: ViroCamera | ViroOrbitCamera,
415
+ active: boolean
416
+ ) => {
414
417
  if (active) {
415
418
  NativeModules.VRTCameraModule.setSceneCamera(
416
419
  findNodeHandle(this),
@@ -27,7 +27,7 @@ import {
27
27
  ViroScene,
28
28
  ViroSceneDictionary,
29
29
  } from "../Types/ViroUtils";
30
- import { ViroTelemetry } from "../Telemetry/ViroTelemetry";
30
+
31
31
 
32
32
  const ViroARSceneNavigatorModule = NativeModules.VRTARSceneNavigatorModule;
33
33
 
@@ -80,7 +80,6 @@ export class ViroARSceneNavigator extends React.Component<Props, State> {
80
80
 
81
81
  constructor(props: Props) {
82
82
  super(props);
83
- ViroTelemetry.recordTelemetry("INIT", { ar: true });
84
83
  let initialSceneTag = this.props.initialSceneKey;
85
84
  if (initialSceneTag == null) {
86
85
  initialSceneTag = this.getRandomTag();
@@ -1 +1 @@
1
- export const VIRO_VERSION = "2.41.6";
1
+ export const VIRO_VERSION = "2.43.0";
@@ -25,7 +25,7 @@ import {
25
25
  ViroSceneDictionary,
26
26
  } from "./Types/ViroUtils";
27
27
  import { ViroScene } from "./ViroScene";
28
- import { ViroTelemetry } from "./Telemetry/ViroTelemetry";
28
+
29
29
  const Viro3DSceneNavigatorModule = NativeModules.VRT3DSceneNavigatorModule;
30
30
 
31
31
  var mathRandomOffset = 0;
@@ -46,6 +46,7 @@ type State = {
46
46
  export class ViroCamera extends React.Component<Props, State> {
47
47
  _component: any;
48
48
  static contextType?: React.Context<any> | undefined = ViroSceneContext;
49
+ declare context: React.ContextType<typeof ViroSceneContext>;
49
50
 
50
51
  componentDidMount() {
51
52
  this.context.cameraDidMount(this);
@@ -29,6 +29,7 @@ export class ViroOrbitCamera extends React.Component<Props> {
29
29
  _component: ViroNativeRef = null;
30
30
 
31
31
  static contextType?: React.Context<any> | undefined = ViroSceneContext;
32
+ declare context: React.ContextType<typeof ViroSceneContext>;
32
33
 
33
34
  componentDidMount() {
34
35
  this.context.cameraDidMount(this);
@@ -31,6 +31,7 @@ import {
31
31
  import { ViroBase } from "./ViroBase";
32
32
  import { ViroCamera } from "./ViroCamera";
33
33
  import { ViroSceneContext } from "./ViroSceneContext";
34
+ import { ViroOrbitCamera } from "./ViroOrbitCamera";
34
35
 
35
36
  type Props = ViroCommonProps & {
36
37
  onPlatformUpdate?: (platformInfo: ViroPlatformInfo) => void;
@@ -185,7 +186,7 @@ export class ViroScene extends ViroBase<Props> {
185
186
  return (
186
187
  <ViroSceneContext.Provider
187
188
  value={{
188
- cameraDidMount: (camera: ViroCamera) => {
189
+ cameraDidMount: (camera: ViroCamera | ViroOrbitCamera) => {
189
190
  if (camera.props.active) {
190
191
  NativeModules.VRTCameraModule.setSceneCamera(
191
192
  findNodeHandle(this),
@@ -193,7 +194,7 @@ export class ViroScene extends ViroBase<Props> {
193
194
  );
194
195
  }
195
196
  },
196
- cameraWillUnmount: (camera: ViroCamera) => {
197
+ cameraWillUnmount: (camera: ViroCamera | ViroOrbitCamera) => {
197
198
  if (camera.props.active) {
198
199
  NativeModules.VRTCameraModule.removeSceneCamera(
199
200
  findNodeHandle(this),
@@ -201,7 +202,10 @@ export class ViroScene extends ViroBase<Props> {
201
202
  );
202
203
  }
203
204
  },
204
- cameraDidUpdate: (camera: ViroCamera, active: boolean) => {
205
+ cameraDidUpdate: (
206
+ camera: ViroCamera | ViroOrbitCamera,
207
+ active: boolean
208
+ ) => {
205
209
  if (active) {
206
210
  NativeModules.VRTCameraModule.setSceneCamera(
207
211
  findNodeHandle(this),
@@ -1,14 +1,15 @@
1
1
  import * as React from "react";
2
2
  import { ViroCamera } from "./ViroCamera";
3
+ import { ViroOrbitCamera } from "./ViroOrbitCamera";
3
4
 
4
5
  export const ViroSceneContext = React.createContext({
5
- cameraDidMount: (camera: ViroCamera) => {
6
+ cameraDidMount: (camera: ViroCamera | ViroOrbitCamera) => {
6
7
  console.log("ViroSceneContext.cameraDidMount: " + camera);
7
8
  },
8
- cameraWillUnmount: (camera: ViroCamera) => {
9
+ cameraWillUnmount: (camera: ViroCamera | ViroOrbitCamera) => {
9
10
  console.log("ViroSceneContext.cameraWillUnmount: " + camera);
10
11
  },
11
- cameraDidUpdate: (camera: ViroCamera, active: boolean) => {
12
+ cameraDidUpdate: (camera: ViroCamera | ViroOrbitCamera, active: boolean) => {
12
13
  console.log(
13
14
  "ViroSceneContext.cameraDidUpdate: " + camera + " active: " + active
14
15
  );
@@ -25,7 +25,7 @@ import { ViroExitViroEvent } from "./Types/ViroEvents";
25
25
  import { Viro3DPoint } from "./Types/ViroUtils";
26
26
  import { ViroSceneDictionary } from "./Types/ViroUtils";
27
27
  import { ViroScene } from "./ViroScene";
28
- import { ViroTelemetry } from "./Telemetry/ViroTelemetry";
28
+
29
29
  var ViroSceneNavigatorModule = NativeModules.VRTSceneNavigatorModule;
30
30
 
31
31
  var mathRandomOffset = 0;
@@ -3,5 +3,5 @@ import { ViewProps } from "react-native";
3
3
  import { ViroCamera } from "../ViroCamera";
4
4
  export declare class ViroARCamera extends React.Component<ViewProps> {
5
5
  _component: ViroCamera | null;
6
- render(): JSX.Element;
6
+ render(): React.JSX.Element;
7
7
  }
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
26
26
  }) : function(o, v) {
27
27
  o["default"] = v;
28
28
  });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
36
46
  Object.defineProperty(exports, "__esModule", { value: true });
37
47
  exports.ViroARCamera = void 0;
38
48
  const React = __importStar(require("react"));
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @providesModule ViroARImageMarker
10
10
  */
11
- /// <reference types="react" />
11
+ import * as React from "react";
12
12
  import { NativeSyntheticEvent } from "react-native";
13
13
  import { ViroARAnchorFoundEvent, ViroARAnchorRemovedEvent, ViroARAnchorUpdatedEvent } from "../Types/ViroEvents";
14
14
  import { ViroBase } from "../ViroBase";
@@ -19,5 +19,5 @@ export declare class ViroARImageMarker extends ViroBase<{}> {
19
19
  _onAnchorFound: (event: NativeSyntheticEvent<ViroARAnchorFoundEvent>) => void;
20
20
  _onAnchorUpdated: (event: NativeSyntheticEvent<ViroARAnchorUpdatedEvent>) => void;
21
21
  _onAnchorRemoved: (_event: NativeSyntheticEvent<ViroARAnchorRemovedEvent>) => void;
22
- render(): JSX.Element;
22
+ render(): React.JSX.Element;
23
23
  }
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  Object.defineProperty(exports, "__esModule", { value: true });
36
46
  exports.ViroARImageMarker = void 0;
37
47
  const React = __importStar(require("react"));
@@ -8,8 +8,8 @@
8
8
  *
9
9
  * @providesModule ViroARObjectMarker
10
10
  */
11
- /// <reference types="react" />
12
11
  import { ViroBase } from "../ViroBase";
12
+ import * as React from "react";
13
13
  import { NativeSyntheticEvent } from "react-native";
14
14
  import { ViroARAnchorFoundEvent, ViroARAnchorRemovedEvent, ViroARAnchorUpdatedEvent } from "../Types/ViroEvents";
15
15
  type Props = {};
@@ -20,6 +20,6 @@ export declare class ViroARObjectMarker extends ViroBase<Props> {
20
20
  _onAnchorFound(event: NativeSyntheticEvent<ViroARAnchorFoundEvent>): void;
21
21
  _onAnchorUpdated(event: NativeSyntheticEvent<ViroARAnchorUpdatedEvent>): void;
22
22
  _onAnchorRemoved(_event: NativeSyntheticEvent<ViroARAnchorRemovedEvent>): void;
23
- render(): JSX.Element;
23
+ render(): React.JSX.Element;
24
24
  }
25
25
  export {};
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  Object.defineProperty(exports, "__esModule", { value: true });
36
46
  exports.ViroARObjectMarker = void 0;
37
47
  const ViroBase_1 = require("../ViroBase");
@@ -8,9 +8,9 @@
8
8
  *
9
9
  * @providesModule ViroARPlane
10
10
  */
11
- /// <reference types="react" />
12
11
  import { ViroARAnchorFoundEvent, ViroARAnchorRemovedEvent, ViroARAnchorUpdatedEvent } from "../Types/ViroEvents";
13
12
  import { ViroBase } from "../ViroBase";
13
+ import * as React from "react";
14
14
  import { NativeSyntheticEvent } from "react-native";
15
15
  type Props = {
16
16
  anchorId?: string;
@@ -25,6 +25,6 @@ export declare class ViroARPlane extends ViroBase<Props> {
25
25
  _onAnchorFound: (event: NativeSyntheticEvent<ViroARAnchorFoundEvent>) => void;
26
26
  _onAnchorUpdated: (event: NativeSyntheticEvent<ViroARAnchorUpdatedEvent>) => void;
27
27
  _onAnchorRemoved: (_event: NativeSyntheticEvent<ViroARAnchorRemovedEvent>) => void;
28
- render(): JSX.Element;
28
+ render(): React.JSX.Element;
29
29
  }
30
30
  export {};
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  Object.defineProperty(exports, "__esModule", { value: true });
36
46
  exports.ViroARPlane = void 0;
37
47
  const ViroBase_1 = require("../ViroBase");
@@ -33,11 +33,11 @@ export declare class ViroARPlaneSelector extends React.Component<Props, State> {
33
33
  _component: ViroNativeRef;
34
34
  state: {
35
35
  selectedSurface: number;
36
- foundARPlanes: any[];
36
+ foundARPlanes: ViroARPlaneType[];
37
37
  arPlaneSizes: number[];
38
38
  };
39
- render(): JSX.Element;
40
- _getARPlanes(): JSX.Element | JSX.Element[];
39
+ render(): React.JSX.Element;
40
+ _getARPlanes(): JSX.Element[];
41
41
  _getOnClickSurface: (index: number, event: ViroClickStateEvent) => void;
42
42
  _onARPlaneUpdated: (index: number) => (updateMap: ViroPlaneUpdatedMap) => void;
43
43
  _onPlaneSelected: (updateMap: ViroPlaneUpdatedMap) => void;
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  Object.defineProperty(exports, "__esModule", { value: true });
36
46
  exports.ViroARPlaneSelector = void 0;
37
47
  const React = __importStar(require("react"));
@@ -59,30 +69,58 @@ class ViroARPlaneSelector extends React.Component {
59
69
  return <ViroNode_1.ViroNode>{this._getARPlanes()}</ViroNode_1.ViroNode>;
60
70
  }
61
71
  _getARPlanes() {
62
- if (this.state.selectedSurface == -1) {
63
- let arPlanes = [];
64
- let numPlanes = this.props.maxPlanes || _maxPlanes;
65
- for (let i = 0; i < numPlanes; i++) {
66
- let foundARPlane = this.state.foundARPlanes[i];
67
- let surfaceWidth = foundARPlane ? foundARPlane.width : 0;
68
- let surfaceHeight = foundARPlane ? foundARPlane.height : 0;
69
- let surfacePosition = foundARPlane ? foundARPlane.center : [0, 0, 0];
70
- arPlanes.push(<ViroARPlane_1.ViroARPlane key={_planePrefix + i} minWidth={this.props.minWidth} minHeight={this.props.minHeight} alignment={this.props.alignment} onAnchorUpdated={this._onARPlaneUpdated(i)}>
71
- <ViroQuad_1.ViroQuad materials={"ViroARPlaneSelector_Translucent"} onClickState={(clickState, position, source) => this._getOnClickSurface(i, { clickState, position, source })} position={surfacePosition} width={surfaceWidth} height={surfaceHeight} rotation={[-90, 0, 0]}/>
72
- </ViroARPlane_1.ViroARPlane>);
73
- }
74
- return arPlanes;
75
- }
76
- else {
77
- return (<ViroARPlane_1.ViroARPlane key={_planePrefix + this.state.selectedSurface} {...this.props}></ViroARPlane_1.ViroARPlane>);
72
+ // Always render a fixed number of planes, controlling visibility instead of conditional rendering
73
+ let arPlanes = [];
74
+ let numPlanes = this.props.maxPlanes || _maxPlanes;
75
+ // Create all plane slots (both detected and placeholder)
76
+ for (let i = 0; i < numPlanes; i++) {
77
+ // Determine if this is the selected plane
78
+ const isSelected = this.state.selectedSurface === i;
79
+ // Get real plane data if available, or use defaults
80
+ const foundARPlane = this.state.foundARPlanes[i];
81
+ const hasPlaneData = !!foundARPlane;
82
+ // Extract plane data or use defaults
83
+ const surfaceWidth = hasPlaneData ? foundARPlane.width || 0.5 : 0.5;
84
+ const surfaceHeight = hasPlaneData ? foundARPlane.height || 0.5 : 0.5;
85
+ const surfacePosition = hasPlaneData
86
+ ? foundARPlane.center || [0, 0, 0]
87
+ : [0, 0, 0];
88
+ const anchorId = hasPlaneData
89
+ ? foundARPlane.anchorId
90
+ : undefined;
91
+ // Determine visibility based on selection state
92
+ // - In selection mode (selectedSurface === -1): show all planes
93
+ // - In selected mode: only show the selected plane
94
+ const isVisible = this.state.selectedSurface === -1 || isSelected;
95
+ arPlanes.push(<ViroARPlane_1.ViroARPlane key={_planePrefix + i} minWidth={this.props.minWidth || 0.5} minHeight={this.props.minHeight || 0.5} alignment={this.props.alignment} anchorId={anchorId} onAnchorFound={(anchor) => {
96
+ // If we find an anchor, update our plane data
97
+ this._onARPlaneUpdated(i)(anchor);
98
+ }} onAnchorUpdated={this._onARPlaneUpdated(i)}>
99
+ {/* Always render both the quad and children, controlling only visibility */}
100
+ <ViroQuad_1.ViroQuad materials={"ViroARPlaneSelector_Translucent"} onClickState={(clickState, position, source) => this._getOnClickSurface(i, { clickState, position, source })} position={surfacePosition} width={surfaceWidth} height={surfaceHeight} rotation={[-90, 0, 0]} opacity={isSelected ? 0 : isVisible ? 1 : 0}/>
101
+
102
+ {/* Wrap children in a ViroNode to control visibility if children exist */}
103
+ {this.props.children && (<ViroNode_1.ViroNode opacity={isSelected ? 1 : 0}>
104
+ {this.props.children}
105
+ </ViroNode_1.ViroNode>)}
106
+ </ViroARPlane_1.ViroARPlane>);
78
107
  }
108
+ return arPlanes;
79
109
  }
80
110
  _getOnClickSurface = (index, event) => {
81
111
  if (event.clickState < 3) {
82
112
  return;
83
113
  }
84
- this.setState({ selectedSurface: index });
85
- this._onPlaneSelected(this.state.foundARPlanes[index]);
114
+ // Get the plane data before updating state to avoid race conditions
115
+ const selectedPlane = this.state.foundARPlanes[index];
116
+ if (!selectedPlane) {
117
+ console.warn("ViroARPlaneSelector: Cannot select plane - plane data not found");
118
+ return;
119
+ }
120
+ // Update state and call callback with the captured data
121
+ this.setState({ selectedSurface: index }, () => {
122
+ this._onPlaneSelected(selectedPlane);
123
+ });
86
124
  };
87
125
  _onARPlaneUpdated = (index) => {
88
126
  return (updateMap) => {
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  import { NativeSyntheticEvent } from "react-native";
3
3
  import { ViroAmbientLightInfo, ViroAmbientLightUpdateEvent, ViroARAnchorFoundEvent, ViroARAnchorRemovedEvent, ViroARAnchorUpdatedEvent, ViroARPointCloud, ViroARPointCloudUpdateEvent, ViroCameraARHitTest, ViroCameraARHitTestEvent, ViroCameraTransform, ViroCameraTransformEvent, ViroPlatformInfo, ViroPlatformUpdateEvent, ViroTrackingReason, ViroTrackingState, ViroTrackingUpdatedEvent } from "../Types/ViroEvents";
4
4
  import { Viro3DPoint, ViroPhysicsWorld, ViroRay, ViroScale, ViroSoundRoom, ViroSource } from "../Types/ViroUtils";
@@ -67,6 +67,6 @@ export declare class ViroARScene extends ViroBase<Props> {
67
67
  up: any[];
68
68
  }>;
69
69
  getCameraPositionAsync: () => Promise<any>;
70
- render(): JSX.Element;
70
+ render(): React.JSX.Element;
71
71
  }
72
72
  export {};