@webspatial/react-sdk 0.1.15 → 0.1.17

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/README.md ADDED
@@ -0,0 +1,16 @@
1
+ <div align="left">
2
+ <img src="../../docs/assets/logo.png" alt="WebSpatial Logo" width="400"/>
3
+ </div>
4
+ <br/>
5
+
6
+ # React SDK for WebSpatial
7
+
8
+ The React SDK from the WebSpatial SDK makes the WebSpatial API immediately available inside React.
9
+
10
+ ## Documentation
11
+
12
+ - [Table of Contents](../../docs/en/README.md)
13
+ - [Introduction](../../docs/en/introduction/README.md)
14
+ - [Quick Start](../../docs/en/quick-start/README.md)
15
+ - [Core Concepts](../../docs/en/core-concepts/README.md)
16
+ - [Development Guide](../../docs/en/development-guide/README.md)
@@ -3,6 +3,7 @@ import React__default, { ReactNode, CSSProperties, ElementType, ForwardedRef } f
3
3
  import { BackgroundMaterialType, CornerRadius, SpatialEntity, Vec3, SpatialSession, WindowContainerOptions as WindowContainerOptions$1 } from '@webspatial/core-sdk';
4
4
  import { ModelViewerElement } from '@google/model-viewer';
5
5
  import { WindowContainerOptions } from '@webspatial/core-sdk/';
6
+ export { WindowContainerOptions } from '@webspatial/core-sdk/';
6
7
 
7
8
  type vecType = {
8
9
  x: number;
@@ -2,7 +2,7 @@
2
2
  (function(){
3
3
  if(typeof window === 'undefined') return;
4
4
  if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
- window.__webspatialsdk__['react-sdk-version'] = "0.1.15"
5
+ window.__webspatialsdk__['react-sdk-version'] = "0.1.17"
6
6
  window.__webspatialsdk__['XR_ENV'] = "avp"
7
7
  })()
8
8
 
@@ -1548,15 +1548,18 @@ function parseTransform(computedStyle) {
1548
1548
  const idxOfMatrix = transform.indexOf(matrixFlagString);
1549
1549
  if (idxOfMatrix !== -1) {
1550
1550
  const transformDataArray = transform.substring(matrixFlagString.length, transform.length - 1).split(",").map((item) => parseFloat(item));
1551
- return parse2dMatrix(transformDataArray);
1551
+ return { transformExist: true, matrix: parse2dMatrix(transformDataArray) };
1552
1552
  } else {
1553
1553
  const matrix3dFlagString = "matrix3d(";
1554
1554
  const idxOfMatrix3d = transform.indexOf(matrix3dFlagString);
1555
1555
  if (idxOfMatrix3d !== -1) {
1556
1556
  const transform3dDataArray = transform.substring(matrix3dFlagString.length, transform.length - 1).split(",").map((item) => parseFloat(item));
1557
- return parse3dMatrix(transform3dDataArray);
1557
+ return {
1558
+ transformExist: true,
1559
+ matrix: parse3dMatrix(transform3dDataArray)
1560
+ };
1558
1561
  } else {
1559
- return new Matrix4();
1562
+ return { transformExist: false, matrix: new Matrix4() };
1560
1563
  }
1561
1564
  }
1562
1565
  }
@@ -1583,7 +1586,7 @@ function parseXRZIndex(computedStyle) {
1583
1586
  function parseSpatialStyle(node) {
1584
1587
  const computedStyle = getComputedStyle(node);
1585
1588
  const mat4ForBack = parseBack(computedStyle);
1586
- const mat4ForTransform = parseTransform(computedStyle);
1589
+ const { transformExist, matrix: mat4ForTransform } = parseTransform(computedStyle);
1587
1590
  const resultMatrix = new Matrix4();
1588
1591
  resultMatrix.multiplyMatrices(mat4ForBack, mat4ForTransform);
1589
1592
  const position = new Vector3();
@@ -1608,7 +1611,8 @@ function parseSpatialStyle(node) {
1608
1611
  material: {
1609
1612
  type: backgroundMaterialType || "none"
1610
1613
  },
1611
- visible
1614
+ visible,
1615
+ transformExist
1612
1616
  };
1613
1617
  }
1614
1618
  function useSpatialStyle() {
@@ -1621,7 +1625,8 @@ function useSpatialStyle() {
1621
1625
  material: {
1622
1626
  type: "none"
1623
1627
  },
1624
- visible: true
1628
+ visible: true,
1629
+ transformExist: false
1625
1630
  });
1626
1631
  const [ready, setReady] = useState3(false);
1627
1632
  const checkSpatialStyleUpdate = useCallback2(() => {
@@ -2011,7 +2016,7 @@ function renderRootCSSSpatialComponent(inProps, refIn) {
2011
2016
  };
2012
2017
  const spatialDivStyle = {
2013
2018
  ...style,
2014
- transform: "none"
2019
+ transform: spatialStyle.transformExist ? "translateZ(0)" : "none"
2015
2020
  };
2016
2021
  const El = inProps.component || "div";
2017
2022
  const spatialDivRef = useHijackSpatialDivRef(refIn, ref);
@@ -2085,7 +2090,7 @@ function renderInPortalInstance(cssSpatialRootContextObject, cssSpatialID, inPro
2085
2090
  };
2086
2091
  const spatialDivStyle = {
2087
2092
  ...style,
2088
- transform: "none"
2093
+ transform: spatialStyle.transformExist ? "translateZ(0)" : "none"
2089
2094
  };
2090
2095
  const El = inProps.component || "div";
2091
2096
  const divRefClassName = className + " " + InjectClassName;
@@ -3250,7 +3255,7 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
3250
3255
  const visible = spatialStyle.visible;
3251
3256
  const model3DStyle = {
3252
3257
  ...style,
3253
- transform: "none"
3258
+ transform: spatialStyle.transformExist ? "translateZ(0)" : "none"
3254
3259
  };
3255
3260
  return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3256
3261
  ready && /* @__PURE__ */ jsx13(
@@ -3328,7 +3333,7 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
3328
3333
  };
3329
3334
  const model3DStyle = {
3330
3335
  ...style,
3331
- transform: "none"
3336
+ transform: spatialStyle.transformExist ? "translateZ(0)" : "none"
3332
3337
  };
3333
3338
  return /* @__PURE__ */ jsxs5(Fragment4, { children: [
3334
3339
  ready && /* @__PURE__ */ jsx15(
@@ -3769,7 +3774,7 @@ function spatialPolyfill() {
3769
3774
  }
3770
3775
 
3771
3776
  // src/index.ts
3772
- var version = "0.1.15";
3777
+ var version = "0.1.17";
3773
3778
  export {
3774
3779
  CSSSpatialDiv,
3775
3780
  CSSSpatialPrimitive,