@webspatial/react-sdk 0.1.2 → 0.1.4
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 +37 -9
- package/dist/default/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx/{jsx-runtime-CgwWInpr.d.ts → jsx-runtime-DEGCo-TS.d.ts} +10 -1
- package/dist/jsx/jsx-runtime.d.ts +1 -1
- package/dist/web/index.js +37 -9
- 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,
|