@webspatial/react-sdk 0.1.4 → 0.1.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/web/index.js CHANGED
@@ -3413,6 +3413,7 @@ function ModelBase(inProps, ref) {
3413
3413
  );
3414
3414
  const isWebEnv = !getSession();
3415
3415
  if (isWebEnv) {
3416
+ const [loadFailed, setLoadFailed] = useState6(false);
3416
3417
  useEffect16(() => {
3417
3418
  if (gltfSourceURL == "") {
3418
3419
  console.warn("Unable to display model, no gltf/glb source provided");
@@ -3421,6 +3422,7 @@ function ModelBase(inProps, ref) {
3421
3422
  target: { ready: false, currentSrc: gltfSourceURL }
3422
3423
  });
3423
3424
  }
3425
+ setLoadFailed(true);
3424
3426
  }
3425
3427
  }, []);
3426
3428
  const myModelViewer = useRef12(null);
@@ -3443,6 +3445,7 @@ function ModelBase(inProps, ref) {
3443
3445
  target: { ready: false, currentSrc: gltfSourceURL }
3444
3446
  });
3445
3447
  }
3448
+ setLoadFailed(true);
3446
3449
  }
3447
3450
  }, 500);
3448
3451
  }, []);
@@ -3457,6 +3460,7 @@ function ModelBase(inProps, ref) {
3457
3460
  target: { ready: false, currentSrc: gltfSourceURL }
3458
3461
  });
3459
3462
  }
3463
+ setLoadFailed(true);
3460
3464
  }
3461
3465
  });
3462
3466
  myModelViewer.current.addEventListener("load", (event) => {
@@ -3465,6 +3469,7 @@ function ModelBase(inProps, ref) {
3465
3469
  target: { ready: true, currentSrc: gltfSourceURL }
3466
3470
  });
3467
3471
  }
3472
+ setLoadFailed(false);
3468
3473
  });
3469
3474
  myModelViewer.current.addEventListener("pointerdown", (event) => {
3470
3475
  isDragging.current = true;
@@ -3522,27 +3527,33 @@ function ModelBase(inProps, ref) {
3522
3527
  );
3523
3528
  }
3524
3529
  }, [props2.contentMode, props2.resizable, props2.aspectRatio]);
3525
- return /* @__PURE__ */ jsx16("div", { ref, className, style, children: modelViewerExists ? /* @__PURE__ */ jsx16(
3526
- "model-viewer",
3527
- {
3528
- ref: myModelViewer,
3529
- style: {
3530
- width: "100%",
3531
- height: "100%"
3532
- },
3533
- src: gltfSourceURL,
3534
- "camera-controls": true,
3535
- "touch-action": "pan-y",
3536
- poster: props2.poster
3537
- }
3538
- ) : /* @__PURE__ */ jsx16(Fragment5, { children: props2.poster ? /* @__PURE__ */ jsx16(
3530
+ return /* @__PURE__ */ jsx16("div", { ref, className, style, children: modelViewerExists ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
3531
+ /* @__PURE__ */ jsx16(
3532
+ "model-viewer",
3533
+ {
3534
+ ref: myModelViewer,
3535
+ style: {
3536
+ display: loadFailed ? "none" : "",
3537
+ width: "100%",
3538
+ height: "100%"
3539
+ },
3540
+ src: gltfSourceURL,
3541
+ "camera-controls": true,
3542
+ "touch-action": "pan-y",
3543
+ poster: props2.poster
3544
+ }
3545
+ ),
3546
+ loadFailed ? /* @__PURE__ */ jsx16(Fragment5, { children: placeHolder }) : /* @__PURE__ */ jsx16(Fragment5, { children: " " })
3547
+ ] }) : /* @__PURE__ */ jsx16(Fragment5, { children: props2.poster ? /* @__PURE__ */ jsx16(
3539
3548
  "img",
3540
3549
  {
3541
3550
  className,
3542
- style: Object.assign(style, { objectFit: "contain" }),
3551
+ style: Object.assign(structuredClone(style), {
3552
+ objectFit: "contain"
3553
+ }),
3543
3554
  src: props2.poster
3544
3555
  }
3545
- ) : /* @__PURE__ */ jsx16(Fragment5, {}) }) });
3556
+ ) : /* @__PURE__ */ jsx16(Fragment5, { children: placeHolder }) }) });
3546
3557
  } else {
3547
3558
  return renderInModel3D(props, ref, usdzSourceURL, placeHolder);
3548
3559
  }