@webspatial/react-sdk 0.1.1 → 0.1.2

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
@@ -3400,9 +3400,23 @@ function ModelBase(inProps, ref) {
3400
3400
  const isDragging = useRef12(false);
3401
3401
  let [modelViewerExists, setModelViewerExists] = useState6(false);
3402
3402
  useEffect16(() => {
3403
+ var modelViewerFound = false;
3403
3404
  customElements.whenDefined("model-viewer").then(function() {
3404
- setModelViewerExists(true);
3405
+ modelViewerFound = true;
3406
+ setModelViewerExists(modelViewerFound);
3405
3407
  });
3408
+ setTimeout(() => {
3409
+ if (!modelViewerFound) {
3410
+ console.warn(
3411
+ 'model-viewer element not loaded yet, if you want to fallback to webGL model loading, you must include the model-viewer library manually in your html file eg. \n\n <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>'
3412
+ );
3413
+ if (props2.onLoad) {
3414
+ props2.onLoad({
3415
+ target: { ready: false, currentSrc: gltfSourceURL }
3416
+ });
3417
+ }
3418
+ }
3419
+ }, 500);
3406
3420
  }, []);
3407
3421
  useEffect16(() => {
3408
3422
  if (!modelViewerExists) {
@@ -3493,7 +3507,14 @@ function ModelBase(inProps, ref) {
3493
3507
  "touch-action": "pan-y",
3494
3508
  poster: props2.poster
3495
3509
  }
3496
- ) : /* @__PURE__ */ jsx16(Fragment5, {}) });
3510
+ ) : /* @__PURE__ */ jsx16(Fragment5, { children: props2.poster ? /* @__PURE__ */ jsx16(
3511
+ "img",
3512
+ {
3513
+ className,
3514
+ style: Object.assign(style, { objectFit: "contain" }),
3515
+ src: props2.poster
3516
+ }
3517
+ ) : /* @__PURE__ */ jsx16(Fragment5, {}) }) });
3497
3518
  } else {
3498
3519
  return renderInModel3D(props, ref, usdzSourceURL, placeHolder);
3499
3520
  }