@webspatial/react-sdk 0.1.3 → 0.1.5
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/default/index.js +64 -25
- package/dist/default/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx/{jsx-runtime-Cztcv8Q7.d.ts → jsx-runtime-DEGCo-TS.d.ts} +1 -0
- package/dist/jsx/jsx-runtime.d.ts +1 -1
- package/dist/web/index.js +64 -25
- package/dist/web/index.js.map +1 -1
- package/package.json +2 -2
package/dist/default/index.js
CHANGED
|
@@ -948,11 +948,15 @@ function syncDefaultSpatialStyle(openedWindow, debugName) {
|
|
|
948
948
|
styleElement.innerHTML = " .xr-spatial-default { --xr-back: 0.001; --xr-background-material: none } ";
|
|
949
949
|
openedWindow.document.head.appendChild(styleElement);
|
|
950
950
|
openedWindow.document.body.style.display = "inline-block";
|
|
951
|
+
openedWindow.document.body.style.minWidth = "auto";
|
|
952
|
+
openedWindow.document.body.style.minHeight = "auto";
|
|
953
|
+
openedWindow.document.body.style.maxWidth = "fit-content";
|
|
954
|
+
openedWindow.document.body.style.minWidth = "fit-content";
|
|
951
955
|
}
|
|
952
956
|
function useSyncSpatialProps(spatialWindowManager, props, domRect, anchor, cornerRadiusFromStyle, opacity, stylePosition, isSubPortal) {
|
|
953
957
|
let { allowScroll, scrollWithParent, style, spatialStyle = {} } = props;
|
|
954
958
|
let {
|
|
955
|
-
position = { x: 0, y: 0, z:
|
|
959
|
+
position = { x: 0, y: 0, z: 0 },
|
|
956
960
|
rotation = { x: 0, y: 0, z: 0, w: 1 },
|
|
957
961
|
scale = { x: 1, y: 1, z: 1 },
|
|
958
962
|
material = { type: "none" },
|
|
@@ -1220,7 +1224,7 @@ function PortalInstance(inProps) {
|
|
|
1220
1224
|
const needRenderPlaceHolder = isSubPortal && inheritedPortalStyle.position !== "absolute" && inheritedPortalStyle.position !== "fixed";
|
|
1221
1225
|
return /* @__PURE__ */ jsxs(SpatialWindowManagerContext.Provider, { value: spatialWindowManager, children: [
|
|
1222
1226
|
needRenderPlaceHolder && /* @__PURE__ */ jsx2(
|
|
1223
|
-
"
|
|
1227
|
+
"span",
|
|
1224
1228
|
{
|
|
1225
1229
|
className,
|
|
1226
1230
|
"data-subportal-spatialid": spatialId,
|
|
@@ -1228,7 +1232,8 @@ function PortalInstance(inProps) {
|
|
|
1228
1232
|
position: "relative",
|
|
1229
1233
|
width: `${domRect.width}px`,
|
|
1230
1234
|
height: `${domRect.height}px`,
|
|
1231
|
-
visibility: "hidden"
|
|
1235
|
+
visibility: "hidden",
|
|
1236
|
+
display: inheritedPortalStyle.display
|
|
1232
1237
|
}
|
|
1233
1238
|
}
|
|
1234
1239
|
),
|
|
@@ -1504,7 +1509,8 @@ import { Quaternion } from "three/src/math/Quaternion.js";
|
|
|
1504
1509
|
// src/spatial-react-components/CSSSpatialDiv/const.ts
|
|
1505
1510
|
var SpatialCustomVars = {
|
|
1506
1511
|
back: "--xr-back",
|
|
1507
|
-
backgroundMaterial: "--xr-background-material"
|
|
1512
|
+
backgroundMaterial: "--xr-background-material",
|
|
1513
|
+
xrZIndex: "--xr-z-index"
|
|
1508
1514
|
};
|
|
1509
1515
|
var BackgroundMaterialDefault = "none";
|
|
1510
1516
|
|
|
@@ -1560,7 +1566,18 @@ function parseBack(computedStyle) {
|
|
|
1560
1566
|
back = parseFloat(backProperty);
|
|
1561
1567
|
} catch (error) {
|
|
1562
1568
|
}
|
|
1563
|
-
return new Matrix4().makeTranslation(0, 0, back ||
|
|
1569
|
+
return new Matrix4().makeTranslation(0, 0, back || 0);
|
|
1570
|
+
}
|
|
1571
|
+
function parseXRZIndex(computedStyle) {
|
|
1572
|
+
let xrZIndexProperty = computedStyle.getPropertyValue(
|
|
1573
|
+
SpatialCustomVars.xrZIndex
|
|
1574
|
+
);
|
|
1575
|
+
let xrZIndex = 0;
|
|
1576
|
+
try {
|
|
1577
|
+
xrZIndex = parseFloat(xrZIndexProperty);
|
|
1578
|
+
} catch (error) {
|
|
1579
|
+
}
|
|
1580
|
+
return xrZIndex;
|
|
1564
1581
|
}
|
|
1565
1582
|
function parseSpatialStyle(node) {
|
|
1566
1583
|
const computedStyle = getComputedStyle(node);
|
|
@@ -1572,7 +1589,7 @@ function parseSpatialStyle(node) {
|
|
|
1572
1589
|
const quaternion = new Quaternion();
|
|
1573
1590
|
const scale = new Vector3();
|
|
1574
1591
|
resultMatrix.decompose(position, quaternion, scale);
|
|
1575
|
-
const zIndex =
|
|
1592
|
+
const zIndex = parseXRZIndex(computedStyle);
|
|
1576
1593
|
const visible = computedStyle.getPropertyValue("visibility") === "visible";
|
|
1577
1594
|
const backgroundMaterialType = computedStyle.getPropertyValue(
|
|
1578
1595
|
SpatialCustomVars.backgroundMaterial
|
|
@@ -1596,7 +1613,7 @@ function parseSpatialStyle(node) {
|
|
|
1596
1613
|
function useSpatialStyle() {
|
|
1597
1614
|
const ref = useRef5(null);
|
|
1598
1615
|
const [spatialStyle, setSpatialStyle] = useState3({
|
|
1599
|
-
position: { x: 0, y: 0, z:
|
|
1616
|
+
position: { x: 0, y: 0, z: 0 },
|
|
1600
1617
|
rotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
1601
1618
|
scale: { x: 1, y: 1, z: 1 },
|
|
1602
1619
|
zIndex: 0,
|
|
@@ -1752,10 +1769,15 @@ function useHijackSpatialDivRef(refIn, cssParserRef) {
|
|
|
1752
1769
|
} else if (property === "transform") {
|
|
1753
1770
|
ref.current?.style.setProperty(property, value);
|
|
1754
1771
|
return true;
|
|
1772
|
+
} else if (property === SpatialCustomVars.xrZIndex) {
|
|
1773
|
+
ref.current?.style.setProperty(
|
|
1774
|
+
SpatialCustomVars.xrZIndex,
|
|
1775
|
+
value
|
|
1776
|
+
);
|
|
1755
1777
|
}
|
|
1756
1778
|
} else if (prop === "removeProperty") {
|
|
1757
1779
|
const [property] = args;
|
|
1758
|
-
if (property === SpatialCustomVars.backgroundMaterial || property === SpatialCustomVars.back || property === "transform") {
|
|
1780
|
+
if (property === SpatialCustomVars.backgroundMaterial || property === SpatialCustomVars.back || property === "transform" || property === SpatialCustomVars.xrZIndex) {
|
|
1759
1781
|
ref.current?.style.removeProperty(property);
|
|
1760
1782
|
}
|
|
1761
1783
|
} else if (prop === "getPropertyValue") {
|
|
@@ -1790,6 +1812,11 @@ function useHijackSpatialDivRef(refIn, cssParserRef) {
|
|
|
1790
1812
|
SpatialCustomVars.back,
|
|
1791
1813
|
value
|
|
1792
1814
|
);
|
|
1815
|
+
} else if (property === SpatialCustomVars.xrZIndex) {
|
|
1816
|
+
ref.current?.style.setProperty(
|
|
1817
|
+
SpatialCustomVars.xrZIndex,
|
|
1818
|
+
value
|
|
1819
|
+
);
|
|
1793
1820
|
} else if (property === "transform") {
|
|
1794
1821
|
ref.current?.style.setProperty(property, value);
|
|
1795
1822
|
return true;
|
|
@@ -1801,7 +1828,8 @@ function useHijackSpatialDivRef(refIn, cssParserRef) {
|
|
|
1801
1828
|
"transform",
|
|
1802
1829
|
"visibility",
|
|
1803
1830
|
SpatialCustomVars.back,
|
|
1804
|
-
SpatialCustomVars.backgroundMaterial
|
|
1831
|
+
SpatialCustomVars.backgroundMaterial,
|
|
1832
|
+
SpatialCustomVars.xrZIndex
|
|
1805
1833
|
];
|
|
1806
1834
|
const { extractedValues, filteredCssText } = extractAndRemoveCustomProperties(
|
|
1807
1835
|
value,
|
|
@@ -3385,6 +3413,7 @@ function ModelBase(inProps, ref) {
|
|
|
3385
3413
|
);
|
|
3386
3414
|
const isWebEnv = !getSession();
|
|
3387
3415
|
if (isWebEnv) {
|
|
3416
|
+
const loadFailed = useRef12(false);
|
|
3388
3417
|
useEffect16(() => {
|
|
3389
3418
|
if (gltfSourceURL == "") {
|
|
3390
3419
|
console.warn("Unable to display model, no gltf/glb source provided");
|
|
@@ -3393,6 +3422,7 @@ function ModelBase(inProps, ref) {
|
|
|
3393
3422
|
target: { ready: false, currentSrc: gltfSourceURL }
|
|
3394
3423
|
});
|
|
3395
3424
|
}
|
|
3425
|
+
loadFailed.current = true;
|
|
3396
3426
|
}
|
|
3397
3427
|
}, []);
|
|
3398
3428
|
const myModelViewer = useRef12(null);
|
|
@@ -3415,6 +3445,7 @@ function ModelBase(inProps, ref) {
|
|
|
3415
3445
|
target: { ready: false, currentSrc: gltfSourceURL }
|
|
3416
3446
|
});
|
|
3417
3447
|
}
|
|
3448
|
+
loadFailed.current = true;
|
|
3418
3449
|
}
|
|
3419
3450
|
}, 500);
|
|
3420
3451
|
}, []);
|
|
@@ -3429,6 +3460,7 @@ function ModelBase(inProps, ref) {
|
|
|
3429
3460
|
target: { ready: false, currentSrc: gltfSourceURL }
|
|
3430
3461
|
});
|
|
3431
3462
|
}
|
|
3463
|
+
loadFailed.current = true;
|
|
3432
3464
|
}
|
|
3433
3465
|
});
|
|
3434
3466
|
myModelViewer.current.addEventListener("load", (event) => {
|
|
@@ -3437,6 +3469,7 @@ function ModelBase(inProps, ref) {
|
|
|
3437
3469
|
target: { ready: true, currentSrc: gltfSourceURL }
|
|
3438
3470
|
});
|
|
3439
3471
|
}
|
|
3472
|
+
loadFailed.current = false;
|
|
3440
3473
|
});
|
|
3441
3474
|
myModelViewer.current.addEventListener("pointerdown", (event) => {
|
|
3442
3475
|
isDragging.current = true;
|
|
@@ -3494,27 +3527,33 @@ function ModelBase(inProps, ref) {
|
|
|
3494
3527
|
);
|
|
3495
3528
|
}
|
|
3496
3529
|
}, [props2.contentMode, props2.resizable, props2.aspectRatio]);
|
|
3497
|
-
return /* @__PURE__ */ jsx16("div", { ref, className, style, children: modelViewerExists ? /* @__PURE__ */
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
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.current ? "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.current ? /* @__PURE__ */ jsx16(Fragment5, { children: placeHolder }) : /* @__PURE__ */ jsx16(Fragment5, { children: " " })
|
|
3547
|
+
] }) : /* @__PURE__ */ jsx16(Fragment5, { children: props2.poster ? /* @__PURE__ */ jsx16(
|
|
3511
3548
|
"img",
|
|
3512
3549
|
{
|
|
3513
3550
|
className,
|
|
3514
|
-
style: Object.assign(style, {
|
|
3551
|
+
style: Object.assign(structuredClone(style), {
|
|
3552
|
+
objectFit: "contain"
|
|
3553
|
+
}),
|
|
3515
3554
|
src: props2.poster
|
|
3516
3555
|
}
|
|
3517
|
-
) : /* @__PURE__ */ jsx16(Fragment5, {}) }) });
|
|
3556
|
+
) : /* @__PURE__ */ jsx16(Fragment5, { children: placeHolder }) }) });
|
|
3518
3557
|
} else {
|
|
3519
3558
|
return renderInModel3D(props, ref, usdzSourceURL, placeHolder);
|
|
3520
3559
|
}
|