softbox 4.23.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.
- package/README.md +47 -0
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/simple-viewer.cjs +4 -4
- package/dist/simple-viewer.es.js +207 -33
- package/package.json +1 -1
package/dist/simple-viewer.es.js
CHANGED
|
@@ -492,7 +492,7 @@ var Jt = class {
|
|
|
492
492
|
}
|
|
493
493
|
}, Yt = class {
|
|
494
494
|
constructor(e) {
|
|
495
|
-
this.currentModel = null, this.currentVariants = [], this.modelLoader = e.modelLoader, this.scene = e.scene, this.camera = e.camera, this.controls = e.controls, this.floorAlignmentService = e.floorAlignmentService, this.sceneSetupService = e.sceneSetupService, this.autoFitToObject = e.autoFitToObject ?? !1, this.floorAlignment = e.floorAlignment ?? !0, this.unitsScaleToMeters = e.unitsScaleToMeters ?? 1;
|
|
495
|
+
this.currentModel = null, this.currentModelUrl = null, this.currentVariants = [], this.modelLoader = e.modelLoader, this.scene = e.scene, this.camera = e.camera, this.controls = e.controls, this.floorAlignmentService = e.floorAlignmentService, this.sceneSetupService = e.sceneSetupService, this.autoFitToObject = e.autoFitToObject ?? !1, this.floorAlignment = e.floorAlignment ?? !0, this.unitsScaleToMeters = e.unitsScaleToMeters ?? 1;
|
|
496
496
|
}
|
|
497
497
|
getCurrentModel() {
|
|
498
498
|
return this.currentModel;
|
|
@@ -500,6 +500,9 @@ var Jt = class {
|
|
|
500
500
|
getLastModelUrl() {
|
|
501
501
|
return this.lastModelUrl;
|
|
502
502
|
}
|
|
503
|
+
getCurrentModelUrl() {
|
|
504
|
+
return this.currentModelUrl;
|
|
505
|
+
}
|
|
503
506
|
getVariantNames() {
|
|
504
507
|
return [...this.currentVariants];
|
|
505
508
|
}
|
|
@@ -517,8 +520,8 @@ var Jt = class {
|
|
|
517
520
|
});
|
|
518
521
|
});
|
|
519
522
|
if (!t.ok) throw t.error;
|
|
520
|
-
o = t.value.scene, this.currentVariants = t.value.userData?.softboxVariants ?? [];
|
|
521
|
-
} else o = e, this.currentVariants = [];
|
|
523
|
+
o = t.value.scene, this.currentModelUrl = e, this.currentVariants = t.value.userData?.softboxVariants ?? [];
|
|
524
|
+
} else o = e, this.currentModelUrl = null, this.currentVariants = [];
|
|
522
525
|
if (this.unitsScaleToMeters !== 1) {
|
|
523
526
|
if (!this.sceneSetupService) throw new t("A units conversion is configured but no scene setup service is available to apply it", i.INVALID_PARAMETER);
|
|
524
527
|
let e = this.sceneSetupService.wrapInUnitsScaleGroup(o, this.unitsScaleToMeters);
|
|
@@ -1148,6 +1151,9 @@ var $t = (e) => [
|
|
|
1148
1151
|
getVariantNames() {
|
|
1149
1152
|
return this.modelManager.getVariantNames();
|
|
1150
1153
|
}
|
|
1154
|
+
getModelUrl() {
|
|
1155
|
+
return this.modelManager.getCurrentModelUrl();
|
|
1156
|
+
}
|
|
1151
1157
|
setMaterialVariant(e) {
|
|
1152
1158
|
let n = this.modelManager.getCurrentModel();
|
|
1153
1159
|
return n && e !== null && !this.modelManager.getVariantNames().includes(e) ? r.err(new t(`Unknown material variant '${e}'`, i.INVALID_PARAMETER)) : (this.options.variant = e ?? void 0, !n || !this.sceneSetupService || this.sceneSetupService.applyMaterialVariant(n, e).then((e) => {
|
|
@@ -8645,33 +8651,192 @@ function cc({ active: e, onSelect: t }) {
|
|
|
8645
8651
|
});
|
|
8646
8652
|
}
|
|
8647
8653
|
//#endregion
|
|
8654
|
+
//#region src/presentation/components/arHandoff.ts
|
|
8655
|
+
var lc = "#softbox-ar-failed";
|
|
8656
|
+
function uc() {
|
|
8657
|
+
return typeof document > "u" || typeof navigator > "u" ? null : document.createElement("a").relList?.supports?.("ar") ? "quick-look" : /android/i.test(navigator.userAgent) ? "scene-viewer" : null;
|
|
8658
|
+
}
|
|
8659
|
+
function dc(e) {
|
|
8660
|
+
if (typeof window > "u" || typeof e != "string" || e.length === 0) return null;
|
|
8661
|
+
try {
|
|
8662
|
+
let t = new URL(e, window.location.href);
|
|
8663
|
+
return t.protocol === "https:" ? t.toString() : null;
|
|
8664
|
+
} catch {
|
|
8665
|
+
return null;
|
|
8666
|
+
}
|
|
8667
|
+
}
|
|
8668
|
+
function fc(e, t) {
|
|
8669
|
+
let n = `file=${encodeURIComponent(e)}&mode=ar_preferred`;
|
|
8670
|
+
t && (n += `&title=${encodeURIComponent(t)}`);
|
|
8671
|
+
let r = new URL(window.location.href);
|
|
8672
|
+
return r.hash = lc, `intent://arvr.google.com/scene-viewer/1.0?${n}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(r.toString())};end;`;
|
|
8673
|
+
}
|
|
8674
|
+
function pc(e) {
|
|
8675
|
+
let t = document.createElement("a");
|
|
8676
|
+
t.rel = "ar", t.appendChild(document.createElement("img")), t.href = e, t.click();
|
|
8677
|
+
}
|
|
8678
|
+
function mc(e) {
|
|
8679
|
+
let t = document.createElement("a");
|
|
8680
|
+
t.href = e, t.click();
|
|
8681
|
+
}
|
|
8682
|
+
//#endregion
|
|
8683
|
+
//#region src/presentation/components/ArButton.tsx
|
|
8684
|
+
var hc = {
|
|
8685
|
+
"top-left": {
|
|
8686
|
+
top: 16,
|
|
8687
|
+
left: 16
|
|
8688
|
+
},
|
|
8689
|
+
"top-right": {
|
|
8690
|
+
top: 16,
|
|
8691
|
+
right: 16
|
|
8692
|
+
},
|
|
8693
|
+
"bottom-left": {
|
|
8694
|
+
bottom: 16,
|
|
8695
|
+
left: 16
|
|
8696
|
+
},
|
|
8697
|
+
"bottom-right": {
|
|
8698
|
+
bottom: 16,
|
|
8699
|
+
right: 16
|
|
8700
|
+
}
|
|
8701
|
+
};
|
|
8702
|
+
function gc({ source: e, options: t, clearPresetRow: n }) {
|
|
8703
|
+
let [r, i] = k(null);
|
|
8704
|
+
E(() => {
|
|
8705
|
+
i(uc());
|
|
8706
|
+
}, []);
|
|
8707
|
+
let [a, o] = k(!1);
|
|
8708
|
+
E(() => {
|
|
8709
|
+
let e = () => {
|
|
8710
|
+
window.location.hash === "#softbox-ar-failed" && (history.replaceState(null, "", window.location.pathname + window.location.search), o(!0));
|
|
8711
|
+
};
|
|
8712
|
+
return window.addEventListener("hashchange", e), () => window.removeEventListener("hashchange", e);
|
|
8713
|
+
}, []);
|
|
8714
|
+
let s = dc(e), c = D(() => {
|
|
8715
|
+
if (a) return null;
|
|
8716
|
+
if (r === "quick-look" && t.iosSrc) {
|
|
8717
|
+
let e = t.iosSrc;
|
|
8718
|
+
return () => pc(e);
|
|
8719
|
+
}
|
|
8720
|
+
return r === "scene-viewer" && s ? () => mc(fc(s, t.title)) : null;
|
|
8721
|
+
}, [
|
|
8722
|
+
a,
|
|
8723
|
+
r,
|
|
8724
|
+
t.iosSrc,
|
|
8725
|
+
t.title,
|
|
8726
|
+
s
|
|
8727
|
+
]);
|
|
8728
|
+
if (!c) return null;
|
|
8729
|
+
let l = { ...hc[t.placement ?? "bottom-left"] };
|
|
8730
|
+
return n && l.bottom !== void 0 && (l.bottom = 64), /* @__PURE__ */ H("button", {
|
|
8731
|
+
type: "button",
|
|
8732
|
+
"data-testid": "viewer-ar-button",
|
|
8733
|
+
"aria-label": "View in your space (AR)",
|
|
8734
|
+
onClick: c,
|
|
8735
|
+
style: {
|
|
8736
|
+
position: "absolute",
|
|
8737
|
+
zIndex: 10,
|
|
8738
|
+
padding: "8px 16px",
|
|
8739
|
+
borderRadius: 999,
|
|
8740
|
+
color: "#111318",
|
|
8741
|
+
fontFamily: ac,
|
|
8742
|
+
fontSize: 13,
|
|
8743
|
+
fontWeight: 600,
|
|
8744
|
+
lineHeight: 1,
|
|
8745
|
+
cursor: "pointer",
|
|
8746
|
+
...l,
|
|
8747
|
+
...oc
|
|
8748
|
+
},
|
|
8749
|
+
children: "AR"
|
|
8750
|
+
});
|
|
8751
|
+
}
|
|
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
|
|
8648
8784
|
//#region src/presentation/components/loadingIndicatorConfig.ts
|
|
8649
|
-
var
|
|
8785
|
+
var yc = {
|
|
8650
8786
|
enabled: !0,
|
|
8651
8787
|
label: "Loading…",
|
|
8652
8788
|
color: "#ffffff",
|
|
8653
8789
|
backdrop: "rgba(15,16,20,0.6)"
|
|
8654
8790
|
};
|
|
8655
|
-
function
|
|
8656
|
-
return e === void 0 || e === !0 ?
|
|
8657
|
-
...
|
|
8791
|
+
function bc(e) {
|
|
8792
|
+
return e === void 0 || e === !0 ? yc : e === !1 ? {
|
|
8793
|
+
...yc,
|
|
8658
8794
|
enabled: !1
|
|
8659
8795
|
} : {
|
|
8660
8796
|
enabled: e.enabled ?? !0,
|
|
8661
|
-
label: e.label ??
|
|
8797
|
+
label: e.label ?? yc.label,
|
|
8662
8798
|
errorLabel: e.errorLabel,
|
|
8663
|
-
color: e.color ??
|
|
8664
|
-
backdrop: e.backdrop ??
|
|
8799
|
+
color: e.color ?? yc.color,
|
|
8800
|
+
backdrop: e.backdrop ?? yc.backdrop
|
|
8665
8801
|
};
|
|
8666
8802
|
}
|
|
8667
8803
|
//#endregion
|
|
8668
8804
|
//#region src/presentation/components/SimpleViewer.tsx
|
|
8669
|
-
var
|
|
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) => {
|
|
8670
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);
|
|
8671
8807
|
Ho(p, h, t);
|
|
8672
8808
|
let x = p ? _(p.getCamera()) : null, S = p ? b(p.getControls()) : null, ee = p ? o(p.getRenderer()) : null, te = re(() => {
|
|
8673
8809
|
p?.requestRender();
|
|
8674
|
-
}, [p]), C = t.helpers?.gizmo !== void 0 && t.helpers.gizmo !== !1, w = typeof t.helpers?.gizmo == "object" ? t.helpers.gizmo : {}, T =
|
|
8810
|
+
}, [p]), C = t.helpers?.gizmo !== void 0 && t.helpers.gizmo !== !1, w = typeof t.helpers?.gizmo == "object" ? t.helpers.gizmo : {}, T = t.ar === !0 ? {} : t.ar || null, [ne, ie] = k(null);
|
|
8811
|
+
E(() => {
|
|
8812
|
+
if (!p) {
|
|
8813
|
+
ie(null);
|
|
8814
|
+
return;
|
|
8815
|
+
}
|
|
8816
|
+
let e = () => ie(p.getModelUrl());
|
|
8817
|
+
return e(), y.on("model:loaded", e), () => y.off("model:loaded", e);
|
|
8818
|
+
}, [p, y]);
|
|
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);
|
|
8675
8840
|
return ae(c, () => ({
|
|
8676
8841
|
scene: p ? v(p.getScene()) : null,
|
|
8677
8842
|
camera: x,
|
|
@@ -8679,18 +8844,18 @@ var dc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), fc = n
|
|
|
8679
8844
|
controls: S,
|
|
8680
8845
|
events: y,
|
|
8681
8846
|
loadModel: async (e) => {
|
|
8682
|
-
if (!p) throw
|
|
8847
|
+
if (!p) throw xc();
|
|
8683
8848
|
let t = typeof e == "string" ? e : new on(e), n = await p.loadModel(t);
|
|
8684
8849
|
if (!n.ok) throw n.error;
|
|
8685
8850
|
},
|
|
8686
8851
|
captureStill: async (e) => {
|
|
8687
|
-
if (!p) throw
|
|
8852
|
+
if (!p) throw xc();
|
|
8688
8853
|
let t = await p.captureStill(e);
|
|
8689
8854
|
if (!t.ok) throw t.error;
|
|
8690
8855
|
return t.value;
|
|
8691
8856
|
},
|
|
8692
8857
|
captureVideo: async (e) => {
|
|
8693
|
-
if (!p) throw
|
|
8858
|
+
if (!p) throw xc();
|
|
8694
8859
|
let t = await p.captureVideo(e);
|
|
8695
8860
|
if (!t.ok) throw t.error;
|
|
8696
8861
|
return t.value;
|
|
@@ -8698,12 +8863,12 @@ var dc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), fc = n
|
|
|
8698
8863
|
getAnimationNames: () => p?.getAnimationNames() ?? [],
|
|
8699
8864
|
getVariantNames: () => p?.getVariantNames() ?? [],
|
|
8700
8865
|
setVariant: (e) => {
|
|
8701
|
-
if (!p) throw
|
|
8866
|
+
if (!p) throw xc();
|
|
8702
8867
|
let t = p.setMaterialVariant(e);
|
|
8703
8868
|
if (!t.ok) throw t.error;
|
|
8704
8869
|
},
|
|
8705
8870
|
playAnimations: (e) => {
|
|
8706
|
-
if (!p) throw
|
|
8871
|
+
if (!p) throw xc();
|
|
8707
8872
|
let t = p.playAnimations(e);
|
|
8708
8873
|
if (!t.ok) throw t.error;
|
|
8709
8874
|
},
|
|
@@ -8711,22 +8876,22 @@ var dc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), fc = n
|
|
|
8711
8876
|
p?.pauseAnimations();
|
|
8712
8877
|
},
|
|
8713
8878
|
setEnvironmentMap: async (e) => {
|
|
8714
|
-
if (!p) throw
|
|
8879
|
+
if (!p) throw xc();
|
|
8715
8880
|
let t = await p.setEnvironmentMap(e);
|
|
8716
8881
|
if (!t.ok) throw t.error;
|
|
8717
8882
|
},
|
|
8718
8883
|
resetEnvironment: () => {
|
|
8719
|
-
if (!p) throw
|
|
8884
|
+
if (!p) throw xc();
|
|
8720
8885
|
let e = p.resetEnvironment();
|
|
8721
8886
|
if (!e.ok) throw e.error;
|
|
8722
8887
|
},
|
|
8723
8888
|
setBackgroundImage: async (e) => {
|
|
8724
|
-
if (!p) throw
|
|
8889
|
+
if (!p) throw xc();
|
|
8725
8890
|
let t = await p.setBackgroundImage(e);
|
|
8726
8891
|
if (!t.ok) throw t.error;
|
|
8727
8892
|
},
|
|
8728
8893
|
setBackgroundColor: (e) => {
|
|
8729
|
-
if (!p) throw
|
|
8894
|
+
if (!p) throw xc();
|
|
8730
8895
|
let t = p.setBackgroundColor(e);
|
|
8731
8896
|
if (!t.ok) throw t.error;
|
|
8732
8897
|
},
|
|
@@ -8757,32 +8922,41 @@ var dc = () => new t("Viewer is not ready yet", i.COMPONENT_NOT_MOUNTED), fc = n
|
|
|
8757
8922
|
placement: w.placement,
|
|
8758
8923
|
size: w.size
|
|
8759
8924
|
}),
|
|
8760
|
-
|
|
8761
|
-
status:
|
|
8762
|
-
label:
|
|
8763
|
-
color:
|
|
8764
|
-
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
|
|
8765
8930
|
}),
|
|
8766
8931
|
d && /* @__PURE__ */ H(cc, {
|
|
8767
8932
|
active: u ?? "studio",
|
|
8768
8933
|
onSelect: f
|
|
8769
8934
|
}),
|
|
8935
|
+
T && /* @__PURE__ */ H(gc, {
|
|
8936
|
+
source: oe,
|
|
8937
|
+
options: T,
|
|
8938
|
+
clearPresetRow: d
|
|
8939
|
+
}),
|
|
8940
|
+
A && /* @__PURE__ */ H(vc, {
|
|
8941
|
+
src: A,
|
|
8942
|
+
visible: fe
|
|
8943
|
+
}),
|
|
8770
8944
|
s
|
|
8771
8945
|
]
|
|
8772
8946
|
})
|
|
8773
8947
|
}) });
|
|
8774
8948
|
});
|
|
8775
|
-
|
|
8949
|
+
Sc.displayName = "SimpleViewer";
|
|
8776
8950
|
//#endregion
|
|
8777
8951
|
//#region src/SimpleViewerWrapper.tsx
|
|
8778
|
-
var
|
|
8952
|
+
var Cc = ne((e, t) => /* @__PURE__ */ H(Sc, {
|
|
8779
8953
|
ref: t,
|
|
8780
8954
|
...e
|
|
8781
8955
|
}));
|
|
8782
|
-
|
|
8956
|
+
Cc.displayName = "SimpleViewer";
|
|
8783
8957
|
//#endregion
|
|
8784
8958
|
//#region src/presentation/components/Hotspot.tsx
|
|
8785
|
-
var
|
|
8959
|
+
var wc = () => /* @__PURE__ */ H("span", {
|
|
8786
8960
|
"aria-hidden": "true",
|
|
8787
8961
|
style: {
|
|
8788
8962
|
display: "block",
|
|
@@ -8794,7 +8968,7 @@ var mc = () => /* @__PURE__ */ H("span", {
|
|
|
8794
8968
|
boxShadow: "0 2px 8px rgba(0,0,0,0.35)"
|
|
8795
8969
|
}
|
|
8796
8970
|
});
|
|
8797
|
-
function
|
|
8971
|
+
function Tc({ position: e, occlude: t = !1, children: n }) {
|
|
8798
8972
|
let { viewer: r } = Go(), i = O(null), [a, o, s] = e;
|
|
8799
8973
|
E(() => {
|
|
8800
8974
|
if (!r) return;
|
|
@@ -8847,8 +9021,8 @@ function hc({ position: e, occlude: t = !1, children: n }) {
|
|
|
8847
9021
|
zIndex: 5,
|
|
8848
9022
|
pointerEvents: c ? "auto" : "none"
|
|
8849
9023
|
},
|
|
8850
|
-
children: c ? n : /* @__PURE__ */ H(
|
|
9024
|
+
children: c ? n : /* @__PURE__ */ H(wc, {})
|
|
8851
9025
|
});
|
|
8852
9026
|
}
|
|
8853
9027
|
//#endregion
|
|
8854
|
-
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,
|
|
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