softbox 4.24.0 → 4.25.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.
@@ -8750,28 +8750,59 @@ function gc({ source: e, options: t, clearPresetRow: n }) {
8750
8750
  });
8751
8751
  }
8752
8752
  //#endregion
8753
+ //#region src/presentation/components/PosterOverlay.tsx
8754
+ var _c = 400;
8755
+ function vc({ src: e, visible: t }) {
8756
+ let [n, r] = k(!1);
8757
+ return E(() => {
8758
+ if (t) return;
8759
+ let e = setTimeout(() => r(!0), 500);
8760
+ return () => clearTimeout(e);
8761
+ }, [t]), n ? null : /* @__PURE__ */ H("img", {
8762
+ "data-testid": "viewer-poster",
8763
+ src: e,
8764
+ alt: "",
8765
+ "aria-hidden": "true",
8766
+ draggable: !1,
8767
+ onTransitionEnd: () => {
8768
+ t || r(!0);
8769
+ },
8770
+ style: {
8771
+ position: "absolute",
8772
+ inset: 0,
8773
+ width: "100%",
8774
+ height: "100%",
8775
+ objectFit: "cover",
8776
+ zIndex: 15,
8777
+ pointerEvents: t ? "auto" : "none",
8778
+ opacity: +!!t,
8779
+ transition: `opacity ${_c}ms ease`
8780
+ }
8781
+ });
8782
+ }
8783
+ //#endregion
8753
8784
  //#region src/presentation/components/loadingIndicatorConfig.ts
8754
- var _c = {
8785
+ var yc = {
8755
8786
  enabled: !0,
8756
8787
  label: "Loading…",
8757
8788
  color: "#ffffff",
8758
8789
  backdrop: "rgba(15,16,20,0.6)"
8759
8790
  };
8760
- function vc(e) {
8761
- return e === void 0 || e === !0 ? _c : e === !1 ? {
8762
- ..._c,
8791
+ function bc(e) {
8792
+ return e === void 0 || e === !0 ? yc : e === !1 ? {
8793
+ ...yc,
8763
8794
  enabled: !1
8764
8795
  } : {
8765
8796
  enabled: e.enabled ?? !0,
8766
- label: e.label ?? _c.label,
8797
+ label: e.label ?? yc.label,
8767
8798
  errorLabel: e.errorLabel,
8768
- color: e.color ?? _c.color,
8769
- backdrop: e.backdrop ?? _c.backdrop
8799
+ color: e.color ?? yc.color,
8800
+ backdrop: e.backdrop ?? yc.backdrop
8770
8801
  };
8771
8802
  }
8772
8803
  //#endregion
8773
8804
  //#region src/presentation/components/SimpleViewer.tsx
8774
- var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = ne(({ object: e, options: t = {}, preset: n, pathTraced: r, turntable: i, animations: a, children: s }, c) => {
8805
+ var xc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), Sc = ne(({ object: e, options: t = {}, preset: n, pathTraced: r, turntable: i, animations: a, children: s }, c) => {
8775
8806
  let l = O(null), { activePreset: u, pickerEnabled: d, selectPreset: f } = Lo(t.preset ?? n, t.ui), { viewer: p, isInitialized: m, initError: h } = Fo(l, Ro(t, u, r, i, a)), g = zo(p, m, e), y = Vo(p);
8776
8807
  Ho(p, h, t);
8777
8808
  let x = p ? _(p.getCamera()) : null, S = p ? b(p.getControls()) : null, ee = p ? o(p.getRenderer()) : null, te = re(() => {
@@ -8785,7 +8816,27 @@ var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = n
8785
8816
  let e = () => ie(p.getModelUrl());
8786
8817
  return e(), y.on("model:loaded", e), () => y.off("model:loaded", e);
8787
8818
  }, [p, y]);
8788
- let oe = ne ?? e, A = D(() => vc(t.loadingIndicator), [t.loadingIndicator]), se = g.status === "error" || !!h, ce = A.enabled && (g.status === "loading" || se);
8819
+ let oe = ne ?? e, A = t.poster || null, [se, ce] = k(!1);
8820
+ E(() => {
8821
+ if (!A || se) return;
8822
+ if (g.status === "loaded") {
8823
+ ce(!0);
8824
+ return;
8825
+ }
8826
+ let e = !1, t = () => {
8827
+ e = !0;
8828
+ }, n = () => {
8829
+ e && ce(!0);
8830
+ };
8831
+ return y.on("model:loaded", t), y.on("render:complete", n), () => {
8832
+ y.off("model:loaded", t), y.off("render:complete", n);
8833
+ };
8834
+ }, [
8835
+ A,
8836
+ se,
8837
+ y
8838
+ ]);
8839
+ let le = D(() => bc(t.loadingIndicator), [t.loadingIndicator]), ue = g.status === "error" || !!h, de = le.enabled && (g.status === "loading" || ue), fe = !se && !(ue && !le.enabled);
8789
8840
  return ae(c, () => ({
8790
8841
  scene: p ? v(p.getScene()) : null,
8791
8842
  camera: x,
@@ -8793,18 +8844,18 @@ var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = n
8793
8844
  controls: S,
8794
8845
  events: y,
8795
8846
  loadModel: async (e) => {
8796
- if (!p) throw yc();
8847
+ if (!p) throw xc();
8797
8848
  let t = typeof e == "string" ? e : new on(e), n = await p.loadModel(t);
8798
8849
  if (!n.ok) throw n.error;
8799
8850
  },
8800
8851
  captureStill: async (e) => {
8801
- if (!p) throw yc();
8852
+ if (!p) throw xc();
8802
8853
  let t = await p.captureStill(e);
8803
8854
  if (!t.ok) throw t.error;
8804
8855
  return t.value;
8805
8856
  },
8806
8857
  captureVideo: async (e) => {
8807
- if (!p) throw yc();
8858
+ if (!p) throw xc();
8808
8859
  let t = await p.captureVideo(e);
8809
8860
  if (!t.ok) throw t.error;
8810
8861
  return t.value;
@@ -8812,12 +8863,12 @@ var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = n
8812
8863
  getAnimationNames: () => p?.getAnimationNames() ?? [],
8813
8864
  getVariantNames: () => p?.getVariantNames() ?? [],
8814
8865
  setVariant: (e) => {
8815
- if (!p) throw yc();
8866
+ if (!p) throw xc();
8816
8867
  let t = p.setMaterialVariant(e);
8817
8868
  if (!t.ok) throw t.error;
8818
8869
  },
8819
8870
  playAnimations: (e) => {
8820
- if (!p) throw yc();
8871
+ if (!p) throw xc();
8821
8872
  let t = p.playAnimations(e);
8822
8873
  if (!t.ok) throw t.error;
8823
8874
  },
@@ -8825,22 +8876,22 @@ var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = n
8825
8876
  p?.pauseAnimations();
8826
8877
  },
8827
8878
  setEnvironmentMap: async (e) => {
8828
- if (!p) throw yc();
8879
+ if (!p) throw xc();
8829
8880
  let t = await p.setEnvironmentMap(e);
8830
8881
  if (!t.ok) throw t.error;
8831
8882
  },
8832
8883
  resetEnvironment: () => {
8833
- if (!p) throw yc();
8884
+ if (!p) throw xc();
8834
8885
  let e = p.resetEnvironment();
8835
8886
  if (!e.ok) throw e.error;
8836
8887
  },
8837
8888
  setBackgroundImage: async (e) => {
8838
- if (!p) throw yc();
8889
+ if (!p) throw xc();
8839
8890
  let t = await p.setBackgroundImage(e);
8840
8891
  if (!t.ok) throw t.error;
8841
8892
  },
8842
8893
  setBackgroundColor: (e) => {
8843
- if (!p) throw yc();
8894
+ if (!p) throw xc();
8844
8895
  let t = p.setBackgroundColor(e);
8845
8896
  if (!t.ok) throw t.error;
8846
8897
  },
@@ -8871,11 +8922,11 @@ var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = n
8871
8922
  placement: w.placement,
8872
8923
  size: w.size
8873
8924
  }),
8874
- ce && /* @__PURE__ */ H(ic, {
8875
- status: se ? "error" : "loading",
8876
- label: se ? A.errorLabel ?? h?.message ?? g.error ?? "Failed to load model" : A.label,
8877
- color: A.color,
8878
- backdrop: A.backdrop
8925
+ de && /* @__PURE__ */ H(ic, {
8926
+ status: ue ? "error" : "loading",
8927
+ label: ue ? le.errorLabel ?? h?.message ?? g.error ?? "Failed to load model" : le.label,
8928
+ color: le.color,
8929
+ backdrop: le.backdrop
8879
8930
  }),
8880
8931
  d && /* @__PURE__ */ H(cc, {
8881
8932
  active: u ?? "studio",
@@ -8886,22 +8937,26 @@ var yc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), bc = n
8886
8937
  options: T,
8887
8938
  clearPresetRow: d
8888
8939
  }),
8940
+ A && /* @__PURE__ */ H(vc, {
8941
+ src: A,
8942
+ visible: fe
8943
+ }),
8889
8944
  s
8890
8945
  ]
8891
8946
  })
8892
8947
  }) });
8893
8948
  });
8894
- bc.displayName = "SimpleViewer";
8949
+ Sc.displayName = "SimpleViewer";
8895
8950
  //#endregion
8896
8951
  //#region src/SimpleViewerWrapper.tsx
8897
- var xc = ne((e, t) => /* @__PURE__ */ H(bc, {
8952
+ var Cc = ne((e, t) => /* @__PURE__ */ H(Sc, {
8898
8953
  ref: t,
8899
8954
  ...e
8900
8955
  }));
8901
- xc.displayName = "SimpleViewer";
8956
+ Cc.displayName = "SimpleViewer";
8902
8957
  //#endregion
8903
8958
  //#region src/presentation/components/Hotspot.tsx
8904
- var Sc = () => /* @__PURE__ */ H("span", {
8959
+ var wc = () => /* @__PURE__ */ H("span", {
8905
8960
  "aria-hidden": "true",
8906
8961
  style: {
8907
8962
  display: "block",
@@ -8913,7 +8968,7 @@ var Sc = () => /* @__PURE__ */ H("span", {
8913
8968
  boxShadow: "0 2px 8px rgba(0,0,0,0.35)"
8914
8969
  }
8915
8970
  });
8916
- function Cc({ position: e, occlude: t = !1, children: n }) {
8971
+ function Tc({ position: e, occlude: t = !1, children: n }) {
8917
8972
  let { viewer: r } = Go(), i = O(null), [a, o, s] = e;
8918
8973
  E(() => {
8919
8974
  if (!r) return;
@@ -8966,8 +9021,8 @@ function Cc({ position: e, occlude: t = !1, children: n }) {
8966
9021
  zIndex: 5,
8967
9022
  pointerEvents: c ? "auto" : "none"
8968
9023
  },
8969
- children: c ? n : /* @__PURE__ */ H(Sc, {})
9024
+ children: c ? n : /* @__PURE__ */ H(wc, {})
8970
9025
  });
8971
9026
  }
8972
9027
  //#endregion
8973
- export { Xa as ControlType, wo as DEFAULT_OUTDOOR_CONCRETE_TEXTURES, Co as DEFAULT_OUTDOOR_HDRI_URL, Eo as DEFAULT_SCENE, Za as DEFAULT_STUDIO_LOOK, i as ErrorCode, Cc as Hotspot, xc as SimpleViewer, t as ThreeViewerError, n as TypedEventEmitter, Oo as VIEWER_PRESETS, To as VIEWER_SCENES, So as defaultOptions, ko as resolvePreset, Do as resolveScene };
9028
+ export { Xa as ControlType, wo as DEFAULT_OUTDOOR_CONCRETE_TEXTURES, Co as DEFAULT_OUTDOOR_HDRI_URL, Eo as DEFAULT_SCENE, Za as DEFAULT_STUDIO_LOOK, i as ErrorCode, Tc as Hotspot, Cc as SimpleViewer, t as ThreeViewerError, n as TypedEventEmitter, Oo as VIEWER_PRESETS, To as VIEWER_SCENES, So as defaultOptions, ko as resolvePreset, Do as resolveScene };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "softbox",
3
3
  "private": false,
4
- "version": "4.24.0",
4
+ "version": "4.25.0",
5
5
  "homepage": "https://leming.github.io/softbox/",
6
6
  "type": "module",
7
7
  "description": "Batteries-included React 3D viewer — any GLB looks studio-shot in one line",