@webspatial/react-sdk 0.0.14 → 0.0.16-alpha.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/dist/default/index.js +26 -17
- package/dist/default/index.js.map +1 -1
- package/dist/web/index.js +26 -17
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
package/dist/default/index.js
CHANGED
|
@@ -194,7 +194,8 @@ function simplifyEntityTree(rootTree) {
|
|
|
194
194
|
cornerRadius: node.components[0].cornerRadius,
|
|
195
195
|
backgroundMaterial: node.components[0].backgroundMaterial,
|
|
196
196
|
isOpaque: node.components[0].isOpaque,
|
|
197
|
-
isScrollEnabled: node.components[0].isScrollEnabled
|
|
197
|
+
isScrollEnabled: node.components[0].isScrollEnabled,
|
|
198
|
+
scrollWithParent: node.components[0].scrollWithParent
|
|
198
199
|
};
|
|
199
200
|
nodeMap[node.id] = newNode;
|
|
200
201
|
if (!parent) {
|
|
@@ -531,9 +532,9 @@ var SpatialWindowManager = class {
|
|
|
531
532
|
this.initPromise = this.initInternalFromWindow();
|
|
532
533
|
await this.initPromise;
|
|
533
534
|
}
|
|
534
|
-
async resize(rect, offset, rotation = { x: 0, y: 0, z: 0, w: 1 }, scale = { x: 1, y: 1, z: 1 }, rotationOrigin = { x: 0, y: 0, z: 0 }) {
|
|
535
|
+
async resize(rect, offset, rotation = { x: 0, y: 0, z: 0, w: 1 }, scale = { x: 1, y: 1, z: 1 }, rotationOrigin = { x: 0, y: 0, z: 0 }, parrentOffset = 0) {
|
|
535
536
|
let targetPosX = rect.x + rect.width / 2;
|
|
536
|
-
let targetPosY = rect.y + rect.height / 2 +
|
|
537
|
+
let targetPosY = rect.y + rect.height / 2 + parrentOffset;
|
|
537
538
|
if (!this.webview) {
|
|
538
539
|
return;
|
|
539
540
|
}
|
|
@@ -661,7 +662,9 @@ function getInheritedStyleProps(computedStyle) {
|
|
|
661
662
|
// background also need to be synced
|
|
662
663
|
"background",
|
|
663
664
|
// position also need to be synced
|
|
664
|
-
"position"
|
|
665
|
+
"position",
|
|
666
|
+
"width",
|
|
667
|
+
"height"
|
|
665
668
|
];
|
|
666
669
|
var props = {};
|
|
667
670
|
for (var cssName of propNames) {
|
|
@@ -849,7 +852,7 @@ function initScene(name, callback) {
|
|
|
849
852
|
|
|
850
853
|
// src/spatial-react-components/SpatialReactComponent/PortalInstance.tsx
|
|
851
854
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
852
|
-
function renderJSXPortalInstance(inProps,
|
|
855
|
+
function renderJSXPortalInstance(inProps, inheritedPortalStyle, className) {
|
|
853
856
|
const { El, style: inStyle = {}, className: _, ...props } = inProps;
|
|
854
857
|
const extraStyle = {
|
|
855
858
|
visibility: "visible",
|
|
@@ -864,15 +867,10 @@ function renderJSXPortalInstance(inProps, elWidth, elHeight, inheritedPortalStyl
|
|
|
864
867
|
borderRadius: "0px",
|
|
865
868
|
overflow: ""
|
|
866
869
|
};
|
|
867
|
-
const elWHStyle = {
|
|
868
|
-
width: `${elWidth}px`,
|
|
869
|
-
height: `${elHeight}px`
|
|
870
|
-
};
|
|
871
870
|
const style = {
|
|
872
871
|
...inStyle,
|
|
873
872
|
...inheritedPortalStyle,
|
|
874
|
-
...extraStyle
|
|
875
|
-
...elWHStyle
|
|
873
|
+
...extraStyle
|
|
876
874
|
};
|
|
877
875
|
return /* @__PURE__ */ jsx2(El, { style, className, ...props });
|
|
878
876
|
}
|
|
@@ -949,8 +947,9 @@ function syncDefaultSpatialStyle(openedWindow, debugName) {
|
|
|
949
947
|
styleElement.type = "text/css";
|
|
950
948
|
styleElement.innerHTML = " .xr-spatial-default { --xr-back: 0.001; --xr-background-material: none } ";
|
|
951
949
|
openedWindow.document.head.appendChild(styleElement);
|
|
950
|
+
openedWindow.document.body.style.display = "inline-block";
|
|
952
951
|
}
|
|
953
|
-
function useSyncSpatialProps(spatialWindowManager, props, domRect, anchor, cornerRadiusFromStyle, opacity, stylePosition) {
|
|
952
|
+
function useSyncSpatialProps(spatialWindowManager, props, domRect, anchor, cornerRadiusFromStyle, opacity, stylePosition, isSubPortal) {
|
|
954
953
|
let { allowScroll, scrollWithParent, style, spatialStyle = {} } = props;
|
|
955
954
|
let {
|
|
956
955
|
position = { x: 0, y: 0, z: 1 },
|
|
@@ -1043,7 +1042,8 @@ function useSyncSpatialProps(spatialWindowManager, props, domRect, anchor, corne
|
|
|
1043
1042
|
position,
|
|
1044
1043
|
rotation,
|
|
1045
1044
|
scale,
|
|
1046
|
-
anchor
|
|
1045
|
+
anchor,
|
|
1046
|
+
isSubPortal ? 0 : window.scrollY
|
|
1047
1047
|
);
|
|
1048
1048
|
spatialWindowManager?.setZIndex(zIndex);
|
|
1049
1049
|
})();
|
|
@@ -1207,12 +1207,11 @@ function PortalInstance(inProps) {
|
|
|
1207
1207
|
anchor,
|
|
1208
1208
|
cornerRadius,
|
|
1209
1209
|
opacity,
|
|
1210
|
-
inheritedPortalStyle.position
|
|
1210
|
+
inheritedPortalStyle.position,
|
|
1211
|
+
isSubPortal
|
|
1211
1212
|
);
|
|
1212
1213
|
const JSXPortalInstance = renderJSXPortalInstance(
|
|
1213
1214
|
props,
|
|
1214
|
-
domRect.width,
|
|
1215
|
-
domRect.height,
|
|
1216
1215
|
inheritedPortalStyle,
|
|
1217
1216
|
className
|
|
1218
1217
|
);
|
|
@@ -2426,7 +2425,7 @@ var Model3DNative = class {
|
|
|
2426
2425
|
return;
|
|
2427
2426
|
}
|
|
2428
2427
|
const targetPosX = rect.x + rect.width / 2;
|
|
2429
|
-
const targetPosY = rect.y + rect.height / 2
|
|
2428
|
+
const targetPosY = rect.y + rect.height / 2;
|
|
2430
2429
|
const { position, rotation, scale } = spatialTransform;
|
|
2431
2430
|
const entity = this.entity;
|
|
2432
2431
|
entity.transform.position.x = targetPosX + position.x;
|
|
@@ -3348,6 +3347,16 @@ function ModelBase(inProps, ref) {
|
|
|
3348
3347
|
);
|
|
3349
3348
|
const isWebEnv = !getSession();
|
|
3350
3349
|
if (isWebEnv) {
|
|
3350
|
+
useEffect16(() => {
|
|
3351
|
+
if (gltfSourceURL == "") {
|
|
3352
|
+
console.warn("Unable to display model, no gltf/glb source provided");
|
|
3353
|
+
if (props2.onLoad) {
|
|
3354
|
+
props2.onLoad({
|
|
3355
|
+
target: { ready: false, currentSrc: gltfSourceURL }
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
}, []);
|
|
3351
3360
|
const myModelViewer = useRef12(null);
|
|
3352
3361
|
const { className, style = {}, ...props2 } = inProps;
|
|
3353
3362
|
const isDragging = useRef12(false);
|