@neurodyn/react-model-viewer 0.0.5 → 0.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.
package/dist/index.d.ts CHANGED
@@ -64,6 +64,12 @@ declare interface ModelViewerRootProps {
64
64
  sizeType?: SizeType;
65
65
  /** Which axes' measurements the "Show dimensions" overlay draws. Defaults to all three. */
66
66
  dimensionAxes?: SizeAxis[];
67
+ /** Initial camera angle, in `<model-viewer>`'s own `"theta phi radius"` format. */
68
+ cameraOrbit?: string;
69
+ /** Lower bound for orbit dragging, same format as `cameraOrbit`. Matching `maxCameraOrbit` on an axis locks it. */
70
+ minCameraOrbit?: string;
71
+ /** Upper bound for orbit dragging, same format as `cameraOrbit`. Matching `minCameraOrbit` on an axis locks it. */
72
+ maxCameraOrbit?: string;
67
73
  /** Controls which viewer UI elements are shown. */
68
74
  layout?: ModelViewerLayout;
69
75
  /** Controls the viewer container background. */
package/dist/index.js CHANGED
@@ -2459,6 +2459,10 @@ button, input:where([type="button"], [type="reset"], [type="submit"]) {
2459
2459
  stroke-dasharray: 2;
2460
2460
  }
2461
2461
 
2462
+ .running {
2463
+ animation-play-state: running;
2464
+ }
2465
+
2462
2466
  .group-focus-within\\/editor-mesh-item\\:text-icons-dark:is(:where(.group\\/editor-mesh-item):focus-within *) {
2463
2467
  color: var(--v-icons-dark);
2464
2468
  }
@@ -6838,7 +6842,7 @@ function isCanvasBlank(modelViewerEl) {
6838
6842
  return true;
6839
6843
  }
6840
6844
  const ModelViewerContext = /*#__PURE__*/ createContext(null);
6841
- function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExperience, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, handoffUrl, hid, launchAr, layout, background, sizeType, dimensionAxes, viewerSurface }) {
6845
+ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExperience, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, handoffUrl, hid, launchAr, layout, background, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, viewerSurface }) {
6842
6846
  const { object, material, error, isLoading, setMaterialHid: setObjectMaterialHid, widgetSession } = useObjectData(tinuuid, hid, {
6843
6847
  apiBaseUrl,
6844
6848
  apiKey,
@@ -6967,6 +6971,9 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
6967
6971
  mode,
6968
6972
  sizeType,
6969
6973
  dimensionAxes,
6974
+ cameraOrbit,
6975
+ minCameraOrbit,
6976
+ maxCameraOrbit,
6970
6977
  isLoading,
6971
6978
  isModelLoading,
6972
6979
  state,
@@ -6994,6 +7001,9 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
6994
7001
  mode,
6995
7002
  sizeType,
6996
7003
  dimensionAxes,
7004
+ cameraOrbit,
7005
+ minCameraOrbit,
7006
+ maxCameraOrbit,
6997
7007
  isLoading,
6998
7008
  isModelLoading,
6999
7009
  state,
@@ -7015,7 +7025,7 @@ function useModelViewer() {
7015
7025
  }
7016
7026
  function resolveDirectArExperience(mode, arExperience) {
7017
7027
  if ('ar-view' === mode) return 'standard';
7018
- if ('advanced-ar-view' === mode || 'ar-viewer' === mode) return 'advanced';
7028
+ if ('advanced-ar-view' === mode || 'ar-viewer' === mode || 'embedded-3d-viewer' === mode) return 'advanced';
7019
7029
  if ('qr-code' === mode) return arExperience;
7020
7030
  }
7021
7031
  function getUserAgent() {
@@ -7037,7 +7047,7 @@ function isSupportedAppClipDevice() {
7037
7047
  if (!isIOSDevice()) return false;
7038
7048
  const versionText = getUserAgent().match(/\bOS (\d+)/)?.[1] ?? getUserAgent().match(/Version\/(\d+)/)?.[1];
7039
7049
  if (!versionText) return false;
7040
- return Number.parseInt(versionText, 10) >= 17;
7050
+ return Number.parseInt(versionText, 10) >= 18;
7041
7051
  }
7042
7052
  function buildAppClipUrl(bundleId, tinuuid, hostname, hid) {
7043
7053
  const url = new URL('https://appclip.apple.com/id');
@@ -7052,8 +7062,13 @@ function buildNativeArUrl(glbUrl, usdzUrl, objectType, ios = isIOSDevice()) {
7052
7062
  const verticalPlacement = 'wall' === objectType || 'ceiling' === objectType ? '&enable_vertical_placement=true' : '';
7053
7063
  return `intent://arvr.google.com/scene-viewer/1.0?file=${encodeURIComponent(new URL(glbUrl).toString())}&resizable=false${verticalPlacement}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`;
7054
7064
  }
7055
- function launchDirectAr(options) {
7056
- if ('advanced' === options.experience && isSupportedAppClipDevice()) return void window.location.assign(buildAppClipUrl(options.appClipBundleId, options.tinuuid, options.hostname, options.hid));
7065
+ function launchDirectAr(options, openAppClipInNewTab = false) {
7066
+ if ('advanced' === options.experience && isSupportedAppClipDevice()) {
7067
+ const appClipUrl = buildAppClipUrl(options.appClipBundleId, options.tinuuid, options.hostname, options.hid);
7068
+ if (openAppClipInNewTab) window.open(appClipUrl, '_blank');
7069
+ else window.location.assign(appClipUrl);
7070
+ return;
7071
+ }
7057
7072
  const link = document.createElement('a');
7058
7073
  const image = document.createElement('img');
7059
7074
  link.rel = 'ar';
@@ -7200,6 +7215,11 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
7200
7215
  if (await launchArOverride(launchAr, arTarget)) return void onBeforeActivateAr?.();
7201
7216
  if (directArLaunchOptions && isMobileArDevice()) {
7202
7217
  onBeforeActivateAr?.();
7218
+ if ('advanced' === directArLaunchOptions.experience && isSupportedAppClipDevice()) {
7219
+ launchDirectAr(directArLaunchOptions, true);
7220
+ trackEvent('ar_launched');
7221
+ return;
7222
+ }
7203
7223
  await flushWidgetEvent(trackEvent('ar_launched'));
7204
7224
  launchDirectAr(directArLaunchOptions);
7205
7225
  } else if (modelViewerEl.canActivateAR) {
@@ -7833,7 +7853,7 @@ function useDimensions({ isVisible, axes }) {
7833
7853
  };
7834
7854
  }
7835
7855
  function ModelViewerContainer({ showDialogCloseButton = false }) {
7836
- const { glbUrl, isModelLoading, object, previewUrl, state, setContainerEl, setModelViewerEl, usdzUrl, layout, background, dimensionAxes, trackEvent } = useModelViewer();
7856
+ const { glbUrl, isModelLoading, object, previewUrl, state, setContainerEl, setModelViewerEl, usdzUrl, layout, background, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, trackEvent } = useModelViewer();
7837
7857
  const [isDimensionsVisible, setDimensionsVisible] = useState(false);
7838
7858
  const isModelLayout = 'model' === layout;
7839
7859
  const showViewerLoader = 'loading' === state || 'ready' === state && isModelLoading;
@@ -7871,6 +7891,9 @@ function ModelViewerContainer({ showDialogCloseButton = false }) {
7871
7891
  poster: previewUrl ?? void 0,
7872
7892
  ar: true,
7873
7893
  cameraControls: true,
7894
+ cameraOrbit: cameraOrbit,
7895
+ minCameraOrbit: minCameraOrbit,
7896
+ maxCameraOrbit: maxCameraOrbit,
7874
7897
  arModes: "webxr scene-viewer quick-look",
7875
7898
  arScale: "fixed",
7876
7899
  shadowIntensity: 1,
@@ -7969,7 +7992,7 @@ const root_queryClient = new QueryClient({
7969
7992
  }
7970
7993
  }
7971
7994
  });
7972
- function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip', arExperience, hid, apiBaseUrl = "https://api.vizbl.com", legacyApiBaseUrl = "https://api.vizbl.com/v1", mode = 'embedded-3d-viewer', initialWidgetSessionToken, handoffUrl = "https://integrations.vizbl.com/model-viewer", launchAr, sizeType = 'cm', dimensionAxes = ALL_DIMENSION_AXES, layout = 'default', background = 'default', showDialogCloseButton = false, viewerSurface = 'inline' }) {
7995
+ function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip', arExperience, hid, apiBaseUrl = "https://api.vizbl.com", legacyApiBaseUrl = "https://api.vizbl.com/v1", mode = 'embedded-3d-viewer', initialWidgetSessionToken, handoffUrl = "https://integrations.vizbl.com/model-viewer", launchAr, sizeType = 'cm', dimensionAxes = ALL_DIMENSION_AXES, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout = 'default', background = 'default', showDialogCloseButton = false, viewerSurface = 'inline' }) {
7973
7996
  const normalizedApiKey = normalizeApiKey(apiKey);
7974
7997
  return /*#__PURE__*/ jsx(QueryClientProvider, {
7975
7998
  client: root_queryClient,
@@ -7989,6 +8012,9 @@ function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip
7989
8012
  background: background,
7990
8013
  sizeType: sizeType,
7991
8014
  dimensionAxes: dimensionAxes,
8015
+ cameraOrbit: cameraOrbit,
8016
+ minCameraOrbit: minCameraOrbit,
8017
+ maxCameraOrbit: maxCameraOrbit,
7992
8018
  viewerSurface: viewerSurface,
7993
8019
  children: /*#__PURE__*/ jsx(ModelViewerContainer, {
7994
8020
  showDialogCloseButton: showDialogCloseButton
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neurodyn/react-model-viewer",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },