@terraware/web-components 5.0.5 → 5.0.6

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.
@@ -54,6 +54,12 @@ export interface VirtualWalkthroughViewerProps {
54
54
  * but couldn't be started, in which case the error says why.
55
55
  */
56
56
  onXrExit?: (error?: Error) => void;
57
+ /**
58
+ * Runs instead of ending the XR session when the user activates the in-headset exit button.
59
+ * Without it the button ends the session, which in turn reports `onXrExit`; with it the session
60
+ * stays running and neither happens, leaving the handler to decide what closing means.
61
+ */
62
+ onXrClose?: () => void;
57
63
  annotations: AnnotationProps[];
58
64
  onSaveAnnotations: (annotations: AnnotationProps[]) => void | Promise<void>;
59
65
  editable?: boolean;
@@ -62,6 +68,6 @@ export interface VirtualWalkthroughViewerProps {
62
68
  onToggleFullScreen?: () => void;
63
69
  maxImagesPerAnnotation?: number;
64
70
  }
65
- declare const VirtualWalkthroughViewer: ({ splatSrc, splatFormat, camera, origin, cameraPosition, sceneBounds, groundPlane: groundPlaneProp, skyColor, groundColor, averageCameraHeight, scaleFactor, splatModelProps, autoStartVr, onXrExit, annotations, onSaveAnnotations, editable, showFreeFly, isFullScreen, onToggleFullScreen, maxImagesPerAnnotation, }: VirtualWalkthroughViewerProps) => import("react/jsx-runtime").JSX.Element;
71
+ declare const VirtualWalkthroughViewer: ({ splatSrc, splatFormat, camera, origin, cameraPosition, sceneBounds, groundPlane: groundPlaneProp, skyColor, groundColor, averageCameraHeight, scaleFactor, splatModelProps, autoStartVr, onXrExit, onXrClose, annotations, onSaveAnnotations, editable, showFreeFly, isFullScreen, onToggleFullScreen, maxImagesPerAnnotation, }: VirtualWalkthroughViewerProps) => import("react/jsx-runtime").JSX.Element;
66
72
  export default VirtualWalkthroughViewer;
67
73
  //# sourceMappingURL=VirtualWalkthroughViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualWalkthroughViewer.d.ts","sourceRoot":"","sources":["../../../src/components/VirtualWalkthrough/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AA;KAAE,CAAC;IAC7D,uEAAuE;IACvE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,iBAAiB,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,QAAA,MAAM,wBAAwB,GAAI,oUAuB/B,6BAA6B,4CAqa/B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -67,6 +67,7 @@ const VirtualWalkthroughViewer = ({
67
67
  splatModelProps,
68
68
  autoStartVr = false,
69
69
  onXrExit,
70
+ onXrClose,
70
71
  annotations,
71
72
  onSaveAnnotations,
72
73
  editable = false,
@@ -316,7 +317,9 @@ const VirtualWalkthroughViewer = ({
316
317
  enableFly: !isTextFieldFocused,
317
318
  averageCameraHeight: averageCameraHeight
318
319
  })]
319
- }), /*#__PURE__*/jsx(XrExitButton, {}), /*#__PURE__*/jsx(Script, {
320
+ }), /*#__PURE__*/jsx(XrExitButton, {
321
+ onClose: onXrClose
322
+ }), /*#__PURE__*/jsx(Script, {
320
323
  script: XrControllers,
321
324
  enabled: !isEdit
322
325
  }), /*#__PURE__*/jsx(XrAnnotationInteraction, {
@@ -1,3 +1,7 @@
1
- declare const XrExitButton: () => import("react/jsx-runtime").JSX.Element;
1
+ interface XrExitButtonProps {
2
+ /** Runs instead of ending the XR session when the button is activated. */
3
+ onClose?: () => void;
4
+ }
5
+ declare const XrExitButton: ({ onClose }: XrExitButtonProps) => import("react/jsx-runtime").JSX.Element;
2
6
  export default XrExitButton;
3
7
  //# sourceMappingURL=XrExitButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"XrExitButton.d.ts","sourceRoot":"","sources":["../../../src/components/VirtualWalkthrough/XrExitButton.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,YAAY,+CAIjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"XrExitButton.d.ts","sourceRoot":"","sources":["../../../src/components/VirtualWalkthrough/XrExitButton.tsx"],"names":[],"mappings":"AAOA,UAAU,iBAAiB;IACzB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,YAAY,GAAI,aAAa,iBAAiB,4CAInD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -4,10 +4,13 @@ import { Script } from '@playcanvas/react/components';
4
4
  import { XrExitButton as XrExitButton$1 } from './xr-exit-button.js';
5
5
  import { jsx } from 'react/jsx-runtime';
6
6
 
7
- const XrExitButton = () => /*#__PURE__*/jsx(Entity, {
7
+ const XrExitButton = ({
8
+ onClose
9
+ }) => /*#__PURE__*/jsx(Entity, {
8
10
  name: "xr-exit-button",
9
11
  children: /*#__PURE__*/jsx(Script, {
10
- script: XrExitButton$1
12
+ script: XrExitButton$1,
13
+ onClose: onClose
11
14
  })
12
15
  });
13
16
 
@@ -12,6 +12,11 @@ export declare class XrExitButton extends Script {
12
12
  halfSize: number;
13
13
  /** World-space radius of the hover/hit sphere. Slightly larger than halfSize for easier targeting. */
14
14
  hitRadius: number;
15
+ /**
16
+ * Called in place of ending the XR session when the user activates the button, leaving the
17
+ * session running so the handler decides what happens next.
18
+ */
19
+ onClose?: () => void;
15
20
  private _material?;
16
21
  private _texture?;
17
22
  private _mesh?;
@@ -28,6 +33,8 @@ export declare class XrExitButton extends Script {
28
33
  private _onSelect;
29
34
  /** True when the ray points at the button's hit sphere. False while the button entity is disabled. */
30
35
  rayHitsButton(origin: Vec3, direction: Vec3): boolean;
36
+ /** The button's exit action: the `onClose` handler when one is set, otherwise ending the session. */
37
+ close(): void;
31
38
  /** The button's static artwork, painted once. Only the sweep changes per frame, and that lives in
32
39
  * the shader. */
33
40
  private _createMaskTexture;
@@ -1 +1 @@
1
- {"version":3,"file":"xr-exit-button.d.ts","sourceRoot":"","sources":["../../../src/components/VirtualWalkthrough/xr-exit-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,MAAM,EAGN,IAAI,EAGL,MAAM,YAAY,CAAC;AASpB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,IAAI,EAAE,WAAW,IAAI,EAAE,QAAQ,IAAI,EAAE,QAAQ,MAAM,KAAG,OAUhG,CAAC;AAUF,qBAAa,YAAa,SAAQ,MAAM;IACtC,MAAM,CAAC,UAAU,SAAkB;IAEnC,yGAAyG;IACzG,MAAM,OAA8B;IAEpC,oFAAoF;IACpF,QAAQ,SAAQ;IAEhB,sGAAsG;IACtG,SAAS,SAAQ;IAEjB,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAU;IAC3B,OAAO,CAAC,KAAK,CAAC,CAAO;IACrB,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,aAAa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O,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,YAAY,CAAgC;IAEpD,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,OAAO,CAA2B;IAE1C,OAAO,CAAC,WAAW,CAAyE;IAE5F,OAAO,CAAC,UAAU,CAGhB;IAEF,OAAO,CAAC,QAAQ,CAMd;IAEF,OAAO,CAAC,SAAS,CAOf;IAEF,sGAAsG;IACtG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO;IAQrD,qGAAqG;IACrG,KAAK;IASL;qBACiB;IACjB,OAAO,CAAC,kBAAkB;IAyB1B,OAAO,CAAC,cAAc;IAKtB,UAAU;IAwBV,MAAM,CAAC,EAAE,EAAE,MAAM;IAiDjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAuBlB,OAAO;CAcR"}
@@ -38,6 +38,12 @@ class XrExitButton extends Script {
38
38
 
39
39
  /** World-space radius of the hover/hit sphere. Slightly larger than halfSize for easier targeting. */
40
40
  hitRadius = 0.15;
41
+
42
+ /**
43
+ * Called in place of ending the XR session when the user activates the button, leaving the
44
+ * session running so the handler decides what happens next.
45
+ */
46
+
41
47
  _hovered = false;
42
48
  _headPosition = new Vec3();
43
49
  _headRotation = new Quat();
@@ -62,7 +68,7 @@ class XrExitButton extends Script {
62
68
  return;
63
69
  }
64
70
  if (this.rayHitsButton(inputSource.getOrigin(), inputSource.getDirection())) {
65
- this.app.xr?.end();
71
+ this.close();
66
72
  }
67
73
  };
68
74
 
@@ -74,6 +80,15 @@ class XrExitButton extends Script {
74
80
  return raySphereIntersect(origin, direction, this.entity.getPosition(), this.hitRadius);
75
81
  }
76
82
 
83
+ /** The button's exit action: the `onClose` handler when one is set, otherwise ending the session. */
84
+ close() {
85
+ if (this.onClose) {
86
+ this.onClose();
87
+ return;
88
+ }
89
+ this.app.xr?.end();
90
+ }
91
+
77
92
  /** The button's static artwork, painted once. Only the sweep changes per frame, and that lives in
78
93
  * the shader. */
79
94
  _createMaskTexture() {
@@ -141,7 +156,7 @@ class XrExitButton extends Script {
141
156
  // trigger. Edge-detected so holding a button and then aiming onto it doesn't fire.
142
157
  const facePressed = this._faceButtons.justPressed(source);
143
158
  if (sourceHovers && facePressed) {
144
- this.app.xr?.end();
159
+ this.close();
145
160
  return;
146
161
  }
147
162
 
@@ -155,7 +170,7 @@ class XrExitButton extends Script {
155
170
  this._hold = hold.state;
156
171
  this._material?.setParameter('uProgress', pieShaderProgress(hold.progress));
157
172
  if (hold.justFired) {
158
- this.app.xr?.end();
173
+ this.close();
159
174
  return;
160
175
  }
161
176
  if (hovered !== this._hovered) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terraware/web-components",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "author": "Terraformation Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {