@webspatial/react-sdk 0.0.0 → 0.0.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/cjs/default/index.js +156 -156
- package/dist/cjs/default/index.js.map +4 -4
- package/dist/cjs/default/spatial-react-components/index.d.ts +0 -1
- package/dist/cjs/default/spatial-react-components/index.d.ts.map +1 -1
- package/dist/cjs/web/index.js +155 -155
- package/dist/cjs/web/index.js.map +4 -4
- package/dist/cjs/web/spatial-react-components/index.d.ts +0 -1
- package/dist/cjs/web/spatial-react-components/index.d.ts.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +299 -303
- package/dist/jsx/jsx-dev-runtime.js.map +4 -4
- package/dist/jsx/jsx-runtime.js +299 -303
- package/dist/jsx/jsx-runtime.js.map +4 -4
- package/npm/plugin/vite.d.ts +5 -0
- package/package.json +6 -6
package/dist/cjs/web/index.js
CHANGED
|
@@ -31,11 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
-
CSSModel3D: () => CSSModel3D,
|
|
35
34
|
CSSSpatialDiv: () => CSSSpatialDiv,
|
|
36
35
|
CSSSpatialPrimitive: () => CSSSpatialPrimitive,
|
|
37
36
|
Model: () => Model,
|
|
38
|
-
Model3D: () => Model3D,
|
|
39
37
|
SpatialDiv: () => SpatialDiv,
|
|
40
38
|
SpatialMonitor: () => SpatialMonitor,
|
|
41
39
|
SpatialPrimitive: () => SpatialPrimitive,
|
|
@@ -2063,14 +2061,70 @@ var CSSSpatialPrimitive = {};
|
|
|
2063
2061
|
}, "createSpatialPrimitive"))(CSSSpatialPrimitive);
|
|
2064
2062
|
var CSSSpatialDiv = CSSSpatialPrimitive.div;
|
|
2065
2063
|
|
|
2064
|
+
// src/spatial-react-components/SpatialView.tsx
|
|
2065
|
+
var import_react21 = require("react");
|
|
2066
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2067
|
+
var runAsync = /* @__PURE__ */ __name((fn) => {
|
|
2068
|
+
return fn();
|
|
2069
|
+
}, "runAsync");
|
|
2070
|
+
var SpatialViewEl = (0, import_react21.forwardRef)(
|
|
2071
|
+
(props, ref) => {
|
|
2072
|
+
const divRef = (0, import_react21.useRef)(null);
|
|
2073
|
+
const spatialEntity = (0, import_react21.useRef)(null);
|
|
2074
|
+
const activePromise = (0, import_react21.useRef)(null);
|
|
2075
|
+
(0, import_react21.useImperativeHandle)(ref, () => ({
|
|
2076
|
+
...divRef.current,
|
|
2077
|
+
getViewEntity: /* @__PURE__ */ __name(async () => {
|
|
2078
|
+
if (activePromise.current) {
|
|
2079
|
+
await activePromise.current;
|
|
2080
|
+
}
|
|
2081
|
+
return spatialEntity.current;
|
|
2082
|
+
}, "getViewEntity")
|
|
2083
|
+
}));
|
|
2084
|
+
if (getSession() == null) {
|
|
2085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
|
|
2086
|
+
}
|
|
2087
|
+
(0, import_react21.useEffect)(() => {
|
|
2088
|
+
if (true) return;
|
|
2089
|
+
activePromise.current = runAsync(async () => {
|
|
2090
|
+
if (activePromise.current) {
|
|
2091
|
+
await activePromise.current;
|
|
2092
|
+
}
|
|
2093
|
+
let sh = new SpatialHelper(getSession());
|
|
2094
|
+
let x = await sh.dom.attachSpatialView(divRef.current);
|
|
2095
|
+
spatialEntity.current = x.entity;
|
|
2096
|
+
if (props.onViewLoad) {
|
|
2097
|
+
props.onViewLoad(x.entity);
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
return () => {
|
|
2101
|
+
if (true) return;
|
|
2102
|
+
runAsync(async () => {
|
|
2103
|
+
await activePromise.current;
|
|
2104
|
+
spatialEntity.current?.destroy();
|
|
2105
|
+
if (props.onViewUnload) {
|
|
2106
|
+
props.onViewUnload();
|
|
2107
|
+
}
|
|
2108
|
+
});
|
|
2109
|
+
};
|
|
2110
|
+
}, []);
|
|
2111
|
+
const { onViewLoad, onViewUnload, ...divProps } = props;
|
|
2112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...divProps });
|
|
2113
|
+
}
|
|
2114
|
+
);
|
|
2115
|
+
var SpatialView = SpatialViewEl;
|
|
2116
|
+
|
|
2117
|
+
// src/spatial-react-components/Model/index.tsx
|
|
2118
|
+
var import_react31 = require("react");
|
|
2119
|
+
|
|
2066
2120
|
// src/spatial-react-components/Model3D/Model3D.tsx
|
|
2067
|
-
var
|
|
2121
|
+
var import_react27 = require("react");
|
|
2068
2122
|
|
|
2069
2123
|
// src/spatial-react-components/Model3D/useDetectLayoutDomUpdated.ts
|
|
2070
|
-
var
|
|
2124
|
+
var import_react22 = require("react");
|
|
2071
2125
|
function useDetectLayoutDomUpdated(onDomUpdated) {
|
|
2072
|
-
const ref = (0,
|
|
2073
|
-
(0,
|
|
2126
|
+
const ref = (0, import_react22.useRef)(null);
|
|
2127
|
+
(0, import_react22.useEffect)(() => {
|
|
2074
2128
|
if (!ref.current) {
|
|
2075
2129
|
console.warn("Ref is not attached to the DOM");
|
|
2076
2130
|
return;
|
|
@@ -2083,7 +2137,7 @@ function useDetectLayoutDomUpdated(onDomUpdated) {
|
|
|
2083
2137
|
ro.disconnect();
|
|
2084
2138
|
};
|
|
2085
2139
|
}, []);
|
|
2086
|
-
(0,
|
|
2140
|
+
(0, import_react22.useEffect)(() => {
|
|
2087
2141
|
if (!ref.current) {
|
|
2088
2142
|
console.warn("Ref is not attached to the DOM");
|
|
2089
2143
|
return;
|
|
@@ -2105,7 +2159,7 @@ function useDetectLayoutDomUpdated(onDomUpdated) {
|
|
|
2105
2159
|
__name(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
|
|
2106
2160
|
|
|
2107
2161
|
// src/spatial-react-components/Model3D/useModel3DNative.ts
|
|
2108
|
-
var
|
|
2162
|
+
var import_react23 = require("react");
|
|
2109
2163
|
|
|
2110
2164
|
// src/spatial-react-components/Model3D/utils.ts
|
|
2111
2165
|
function PopulatePartialSpatialTransformType(spatialTransform = {}) {
|
|
@@ -2333,12 +2387,12 @@ var Model3DNative = class {
|
|
|
2333
2387
|
|
|
2334
2388
|
// src/spatial-react-components/Model3D/useModel3DNative.ts
|
|
2335
2389
|
function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DNativeReadyCb) {
|
|
2336
|
-
let model3DNativeRef = (0,
|
|
2337
|
-
const [phase, setPhase] = (0,
|
|
2390
|
+
let model3DNativeRef = (0, import_react23.useRef)(null);
|
|
2391
|
+
const [phase, setPhase] = (0, import_react23.useState)(
|
|
2338
2392
|
"loading"
|
|
2339
2393
|
);
|
|
2340
|
-
const [failureReason, setFailureReason] = (0,
|
|
2341
|
-
(0,
|
|
2394
|
+
const [failureReason, setFailureReason] = (0, import_react23.useState)("");
|
|
2395
|
+
(0, import_react23.useEffect)(() => {
|
|
2342
2396
|
let isDestroyed = false;
|
|
2343
2397
|
const model3DContainer = new Model3DNative(parentEntity);
|
|
2344
2398
|
model3DContainer.init(
|
|
@@ -2365,32 +2419,32 @@ function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DN
|
|
|
2365
2419
|
setPhase("loading");
|
|
2366
2420
|
};
|
|
2367
2421
|
}, [modelUrl]);
|
|
2368
|
-
(0,
|
|
2422
|
+
(0, import_react23.useEffect)(() => {
|
|
2369
2423
|
if (model3DNativeRef.current) {
|
|
2370
2424
|
model3DNativeRef.current.onDragStart = eventHandlers.onDragStart;
|
|
2371
2425
|
}
|
|
2372
2426
|
}, [model3DNativeRef.current, eventHandlers.onDragStart]);
|
|
2373
|
-
(0,
|
|
2427
|
+
(0, import_react23.useEffect)(() => {
|
|
2374
2428
|
if (model3DNativeRef.current) {
|
|
2375
2429
|
model3DNativeRef.current.onDrag = eventHandlers.onDrag;
|
|
2376
2430
|
}
|
|
2377
2431
|
}, [model3DNativeRef.current, eventHandlers.onDrag]);
|
|
2378
|
-
(0,
|
|
2432
|
+
(0, import_react23.useEffect)(() => {
|
|
2379
2433
|
if (model3DNativeRef.current) {
|
|
2380
2434
|
model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd;
|
|
2381
2435
|
}
|
|
2382
2436
|
});
|
|
2383
|
-
(0,
|
|
2437
|
+
(0, import_react23.useEffect)(() => {
|
|
2384
2438
|
if (model3DNativeRef.current) {
|
|
2385
2439
|
model3DNativeRef.current.onTap = eventHandlers.onTap;
|
|
2386
2440
|
}
|
|
2387
2441
|
}, [model3DNativeRef.current, eventHandlers.onTap]);
|
|
2388
|
-
(0,
|
|
2442
|
+
(0, import_react23.useEffect)(() => {
|
|
2389
2443
|
if (model3DNativeRef.current) {
|
|
2390
2444
|
model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap;
|
|
2391
2445
|
}
|
|
2392
2446
|
}, [model3DNativeRef.current, eventHandlers.onDoubleTap]);
|
|
2393
|
-
(0,
|
|
2447
|
+
(0, import_react23.useEffect)(() => {
|
|
2394
2448
|
if (model3DNativeRef.current) {
|
|
2395
2449
|
model3DNativeRef.current.onLongPress = eventHandlers.onLongPress;
|
|
2396
2450
|
}
|
|
@@ -2400,8 +2454,8 @@ function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DN
|
|
|
2400
2454
|
__name(useModel3DNative, "useModel3DNative");
|
|
2401
2455
|
|
|
2402
2456
|
// src/spatial-react-components/Model3D/Model3DNotInSpatialDiv.tsx
|
|
2403
|
-
var
|
|
2404
|
-
var
|
|
2457
|
+
var import_react24 = require("react");
|
|
2458
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2405
2459
|
function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
2406
2460
|
const {
|
|
2407
2461
|
className,
|
|
@@ -2422,7 +2476,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2422
2476
|
onLongPress
|
|
2423
2477
|
} = props;
|
|
2424
2478
|
const theSpatialTransform = PopulatePartialSpatialTransformType(spatialTransform);
|
|
2425
|
-
const onDomUpdated = (0,
|
|
2479
|
+
const onDomUpdated = (0, import_react24.useCallback)(() => {
|
|
2426
2480
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
2427
2481
|
const model3DNative = model3DNativeRef.current;
|
|
2428
2482
|
model3DNative.updateByDom(layoutInstanceRef.current, {
|
|
@@ -2441,7 +2495,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2441
2495
|
theSpatialTransform.scale.y,
|
|
2442
2496
|
theSpatialTransform.scale.z
|
|
2443
2497
|
]);
|
|
2444
|
-
const onModel3DContainerReadyCb = (0,
|
|
2498
|
+
const onModel3DContainerReadyCb = (0, import_react24.useCallback)(() => {
|
|
2445
2499
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
2446
2500
|
model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
|
|
2447
2501
|
spatialTransform: theSpatialTransform
|
|
@@ -2459,7 +2513,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2459
2513
|
theSpatialTransform.scale.y,
|
|
2460
2514
|
theSpatialTransform.scale.z
|
|
2461
2515
|
]);
|
|
2462
|
-
const onDragStartCb = (0,
|
|
2516
|
+
const onDragStartCb = (0, import_react24.useCallback)(
|
|
2463
2517
|
(spatialDragEvent) => {
|
|
2464
2518
|
if (onDragStart) {
|
|
2465
2519
|
const dragEvent = {
|
|
@@ -2471,7 +2525,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2471
2525
|
},
|
|
2472
2526
|
[onDragStart]
|
|
2473
2527
|
);
|
|
2474
|
-
const onDragCb = (0,
|
|
2528
|
+
const onDragCb = (0, import_react24.useCallback)(
|
|
2475
2529
|
(spatialDragEvent) => {
|
|
2476
2530
|
if (onDrag) {
|
|
2477
2531
|
const dragEvent = {
|
|
@@ -2483,7 +2537,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2483
2537
|
},
|
|
2484
2538
|
[onDrag]
|
|
2485
2539
|
);
|
|
2486
|
-
const onDragEndCb = (0,
|
|
2540
|
+
const onDragEndCb = (0, import_react24.useCallback)(
|
|
2487
2541
|
(spatialDragEvent) => {
|
|
2488
2542
|
if (onDragEnd) {
|
|
2489
2543
|
const dragEvent = {
|
|
@@ -2495,7 +2549,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2495
2549
|
},
|
|
2496
2550
|
[onDragEnd]
|
|
2497
2551
|
);
|
|
2498
|
-
const onTapCb = (0,
|
|
2552
|
+
const onTapCb = (0, import_react24.useCallback)(() => {
|
|
2499
2553
|
if (onTap) {
|
|
2500
2554
|
const event = {
|
|
2501
2555
|
target: layoutInstanceRef.current
|
|
@@ -2503,7 +2557,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2503
2557
|
onTap(event);
|
|
2504
2558
|
}
|
|
2505
2559
|
}, [onTap]);
|
|
2506
|
-
const onDoubleTapCb = (0,
|
|
2560
|
+
const onDoubleTapCb = (0, import_react24.useCallback)(() => {
|
|
2507
2561
|
if (onDoubleTap) {
|
|
2508
2562
|
const event = {
|
|
2509
2563
|
target: layoutInstanceRef.current
|
|
@@ -2511,7 +2565,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2511
2565
|
onDoubleTap(event);
|
|
2512
2566
|
}
|
|
2513
2567
|
}, [onDoubleTap]);
|
|
2514
|
-
const onLongPressCb = (0,
|
|
2568
|
+
const onLongPressCb = (0, import_react24.useCallback)(() => {
|
|
2515
2569
|
if (onLongPress) {
|
|
2516
2570
|
const event = {
|
|
2517
2571
|
target: layoutInstanceRef.current
|
|
@@ -2533,7 +2587,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2533
2587
|
},
|
|
2534
2588
|
onModel3DContainerReadyCb
|
|
2535
2589
|
);
|
|
2536
|
-
const onSuccess = (0,
|
|
2590
|
+
const onSuccess = (0, import_react24.useCallback)(() => {
|
|
2537
2591
|
;
|
|
2538
2592
|
layoutInstanceRef.current.ready = true;
|
|
2539
2593
|
if (onLoad) {
|
|
@@ -2542,7 +2596,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2542
2596
|
});
|
|
2543
2597
|
}
|
|
2544
2598
|
}, [onLoad]);
|
|
2545
|
-
const onFailure = (0,
|
|
2599
|
+
const onFailure = (0, import_react24.useCallback)(
|
|
2546
2600
|
(_) => {
|
|
2547
2601
|
const modelElement = layoutInstanceRef.current;
|
|
2548
2602
|
modelElement.ready = false;
|
|
@@ -2554,19 +2608,19 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2554
2608
|
},
|
|
2555
2609
|
[onLoad]
|
|
2556
2610
|
);
|
|
2557
|
-
(0,
|
|
2611
|
+
(0, import_react24.useEffect)(() => {
|
|
2558
2612
|
if (phase === "failure") {
|
|
2559
2613
|
onFailure(failureReason);
|
|
2560
2614
|
} else if (phase === "success") {
|
|
2561
2615
|
onSuccess();
|
|
2562
2616
|
}
|
|
2563
2617
|
}, [phase]);
|
|
2564
|
-
(0,
|
|
2618
|
+
(0, import_react24.useEffect)(() => {
|
|
2565
2619
|
if (model3DNativeRef.current) {
|
|
2566
2620
|
model3DNativeRef.current.setVisible(visible);
|
|
2567
2621
|
}
|
|
2568
2622
|
}, [model3DNativeRef.current, visible]);
|
|
2569
|
-
(0,
|
|
2623
|
+
(0, import_react24.useEffect)(() => {
|
|
2570
2624
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
2571
2625
|
model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
|
|
2572
2626
|
spatialTransform: theSpatialTransform
|
|
@@ -2584,17 +2638,17 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2584
2638
|
theSpatialTransform.scale.y,
|
|
2585
2639
|
theSpatialTransform.scale.z
|
|
2586
2640
|
]);
|
|
2587
|
-
(0,
|
|
2641
|
+
(0, import_react24.useEffect)(() => {
|
|
2588
2642
|
if (model3DNativeRef.current) {
|
|
2589
2643
|
model3DNativeRef.current.setContentMode(contentMode);
|
|
2590
2644
|
}
|
|
2591
2645
|
}, [model3DNativeRef.current, contentMode]);
|
|
2592
|
-
(0,
|
|
2646
|
+
(0, import_react24.useEffect)(() => {
|
|
2593
2647
|
if (model3DNativeRef.current) {
|
|
2594
2648
|
model3DNativeRef.current.setResizable(resizable);
|
|
2595
2649
|
}
|
|
2596
2650
|
}, [model3DNativeRef.current, resizable]);
|
|
2597
|
-
(0,
|
|
2651
|
+
(0, import_react24.useEffect)(() => {
|
|
2598
2652
|
if (model3DNativeRef.current) {
|
|
2599
2653
|
model3DNativeRef.current.setAspectRatio(aspectRatio);
|
|
2600
2654
|
}
|
|
@@ -2604,7 +2658,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2604
2658
|
visibility: phase === "failure" ? "visible" : "hidden",
|
|
2605
2659
|
transform: ""
|
|
2606
2660
|
};
|
|
2607
|
-
const proxyRef = (0,
|
|
2661
|
+
const proxyRef = (0, import_react24.useMemo)(
|
|
2608
2662
|
() => new Proxy(layoutInstanceRef, {
|
|
2609
2663
|
get(target, prop, receiver) {
|
|
2610
2664
|
return Reflect.get(target, prop, receiver);
|
|
@@ -2629,7 +2683,7 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2629
2683
|
}),
|
|
2630
2684
|
[layoutInstanceRef, refIn]
|
|
2631
2685
|
);
|
|
2632
|
-
(0,
|
|
2686
|
+
(0, import_react24.useEffect)(() => {
|
|
2633
2687
|
return () => {
|
|
2634
2688
|
if (layoutInstanceRef.current) {
|
|
2635
2689
|
const modelElement = layoutInstanceRef.current;
|
|
@@ -2638,18 +2692,18 @@ function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
|
2638
2692
|
}
|
|
2639
2693
|
};
|
|
2640
2694
|
}, [modelUrl]);
|
|
2641
|
-
return /* @__PURE__ */ (0,
|
|
2695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style: layoutDomStyle, ref: proxyRef, children: phase === "failure" && children });
|
|
2642
2696
|
}
|
|
2643
2697
|
__name(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
|
|
2644
2698
|
|
|
2645
2699
|
// src/spatial-react-components/Model3D/Model3DStandardInstance.tsx
|
|
2646
|
-
var
|
|
2700
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2647
2701
|
function renderModel3DStandardInstance(spatialId, props, refIn) {
|
|
2648
2702
|
const { className, style } = props;
|
|
2649
2703
|
const extraProps = {
|
|
2650
2704
|
[SpatialID]: spatialId
|
|
2651
2705
|
};
|
|
2652
|
-
return /* @__PURE__ */ (0,
|
|
2706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2653
2707
|
"div",
|
|
2654
2708
|
{
|
|
2655
2709
|
"data-model3d-spatialid": spatialId,
|
|
@@ -2663,28 +2717,28 @@ function renderModel3DStandardInstance(spatialId, props, refIn) {
|
|
|
2663
2717
|
__name(renderModel3DStandardInstance, "renderModel3DStandardInstance");
|
|
2664
2718
|
|
|
2665
2719
|
// src/spatial-react-components/Model3D/Model3DPortalInstance.tsx
|
|
2666
|
-
var
|
|
2720
|
+
var import_react26 = require("react");
|
|
2667
2721
|
|
|
2668
2722
|
// src/spatial-react-components/Model3D/useSyncDomInfoFromStandardInstance.ts
|
|
2669
|
-
var
|
|
2723
|
+
var import_react25 = require("react");
|
|
2670
2724
|
function useSyncDomInfoFromStandardInstance(spatialId) {
|
|
2671
|
-
const [domRect, setDomRect] = (0,
|
|
2725
|
+
const [domRect, setDomRect] = (0, import_react25.useState)({
|
|
2672
2726
|
x: 0,
|
|
2673
2727
|
y: 0,
|
|
2674
2728
|
width: 0,
|
|
2675
2729
|
height: 0
|
|
2676
2730
|
});
|
|
2677
|
-
const inheritedPortalStyleRef = (0,
|
|
2678
|
-
const anchorRef = (0,
|
|
2731
|
+
const inheritedPortalStyleRef = (0, import_react25.useRef)({});
|
|
2732
|
+
const anchorRef = (0, import_react25.useRef)({
|
|
2679
2733
|
x: 0.5,
|
|
2680
2734
|
y: 0.5,
|
|
2681
2735
|
z: 0.5
|
|
2682
2736
|
});
|
|
2683
|
-
const opacityRef = (0,
|
|
2684
|
-
const spatialReactContextObject = (0,
|
|
2685
|
-
const inheritedPortalClassNameRef = (0,
|
|
2686
|
-
const modelRef = (0,
|
|
2687
|
-
(0,
|
|
2737
|
+
const opacityRef = (0, import_react25.useRef)(1);
|
|
2738
|
+
const spatialReactContextObject = (0, import_react25.useContext)(SpatialReactContext);
|
|
2739
|
+
const inheritedPortalClassNameRef = (0, import_react25.useRef)("");
|
|
2740
|
+
const modelRef = (0, import_react25.useRef)(null);
|
|
2741
|
+
(0, import_react25.useEffect)(() => {
|
|
2688
2742
|
const syncDomRect = /* @__PURE__ */ __name(() => {
|
|
2689
2743
|
const dom = spatialReactContextObject?.querySpatialDom(spatialId);
|
|
2690
2744
|
if (!dom) {
|
|
@@ -2726,7 +2780,7 @@ function useSyncDomInfoFromStandardInstance(spatialId) {
|
|
|
2726
2780
|
__name(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
|
|
2727
2781
|
|
|
2728
2782
|
// src/spatial-react-components/Model3D/Model3DPortalInstance.tsx
|
|
2729
|
-
var
|
|
2783
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2730
2784
|
function useModelEvents(props, modelRef) {
|
|
2731
2785
|
const {
|
|
2732
2786
|
onDragStart,
|
|
@@ -2736,7 +2790,7 @@ function useModelEvents(props, modelRef) {
|
|
|
2736
2790
|
onDoubleTap,
|
|
2737
2791
|
onLongPress
|
|
2738
2792
|
} = props;
|
|
2739
|
-
const onDragStartCb = (0,
|
|
2793
|
+
const onDragStartCb = (0, import_react26.useCallback)(
|
|
2740
2794
|
(spatialDragEvent) => {
|
|
2741
2795
|
if (onDragStart) {
|
|
2742
2796
|
const dragEvent = {
|
|
@@ -2748,7 +2802,7 @@ function useModelEvents(props, modelRef) {
|
|
|
2748
2802
|
},
|
|
2749
2803
|
[onDragStart]
|
|
2750
2804
|
);
|
|
2751
|
-
const onDragCb = (0,
|
|
2805
|
+
const onDragCb = (0, import_react26.useCallback)(
|
|
2752
2806
|
(spatialDragEvent) => {
|
|
2753
2807
|
if (onDrag) {
|
|
2754
2808
|
const dragEvent = {
|
|
@@ -2760,7 +2814,7 @@ function useModelEvents(props, modelRef) {
|
|
|
2760
2814
|
},
|
|
2761
2815
|
[onDrag]
|
|
2762
2816
|
);
|
|
2763
|
-
const onDragEndCb = (0,
|
|
2817
|
+
const onDragEndCb = (0, import_react26.useCallback)(
|
|
2764
2818
|
(spatialDragEvent) => {
|
|
2765
2819
|
if (onDragEnd) {
|
|
2766
2820
|
const dragEvent = {
|
|
@@ -2772,7 +2826,7 @@ function useModelEvents(props, modelRef) {
|
|
|
2772
2826
|
},
|
|
2773
2827
|
[onDragEnd]
|
|
2774
2828
|
);
|
|
2775
|
-
const onTapCb = (0,
|
|
2829
|
+
const onTapCb = (0, import_react26.useCallback)(() => {
|
|
2776
2830
|
if (onTap) {
|
|
2777
2831
|
const event = {
|
|
2778
2832
|
target: modelRef.current
|
|
@@ -2780,7 +2834,7 @@ function useModelEvents(props, modelRef) {
|
|
|
2780
2834
|
onTap(event);
|
|
2781
2835
|
}
|
|
2782
2836
|
}, [onTap]);
|
|
2783
|
-
const onDoubleTapCb = (0,
|
|
2837
|
+
const onDoubleTapCb = (0, import_react26.useCallback)(() => {
|
|
2784
2838
|
if (onDoubleTap) {
|
|
2785
2839
|
const event = {
|
|
2786
2840
|
target: modelRef.current
|
|
@@ -2788,7 +2842,7 @@ function useModelEvents(props, modelRef) {
|
|
|
2788
2842
|
onDoubleTap(event);
|
|
2789
2843
|
}
|
|
2790
2844
|
}, [onDoubleTap]);
|
|
2791
|
-
const onLongPressCb = (0,
|
|
2845
|
+
const onLongPressCb = (0, import_react26.useCallback)(() => {
|
|
2792
2846
|
if (onLongPress) {
|
|
2793
2847
|
const event = {
|
|
2794
2848
|
target: modelRef.current
|
|
@@ -2818,7 +2872,7 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2818
2872
|
onLoad,
|
|
2819
2873
|
children
|
|
2820
2874
|
} = props;
|
|
2821
|
-
const theSpatialTransform = (0,
|
|
2875
|
+
const theSpatialTransform = (0, import_react26.useMemo)(() => {
|
|
2822
2876
|
return PopulatePartialSpatialTransformType(spatialTransform);
|
|
2823
2877
|
}, [spatialTransform]);
|
|
2824
2878
|
const {
|
|
@@ -2829,7 +2883,7 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2829
2883
|
opacity,
|
|
2830
2884
|
className
|
|
2831
2885
|
} = useSyncDomInfoFromStandardInstance(spatialId);
|
|
2832
|
-
const parentSpatialWindowManager = (0,
|
|
2886
|
+
const parentSpatialWindowManager = (0, import_react26.useContext)(SpatialWindowManagerContext);
|
|
2833
2887
|
const eventHandlers = useModelEvents(
|
|
2834
2888
|
props,
|
|
2835
2889
|
modelRef
|
|
@@ -2839,7 +2893,7 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2839
2893
|
parentSpatialWindowManager.entity,
|
|
2840
2894
|
eventHandlers
|
|
2841
2895
|
);
|
|
2842
|
-
(0,
|
|
2896
|
+
(0, import_react26.useEffect)(() => {
|
|
2843
2897
|
if (model3DNativeRef.current) {
|
|
2844
2898
|
model3DNativeRef.current.updateRectAndTransform(
|
|
2845
2899
|
domRect,
|
|
@@ -2847,37 +2901,37 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2847
2901
|
);
|
|
2848
2902
|
}
|
|
2849
2903
|
}, [model3DNativeRef.current, domRect, theSpatialTransform]);
|
|
2850
|
-
(0,
|
|
2904
|
+
(0, import_react26.useEffect)(() => {
|
|
2851
2905
|
if (model3DNativeRef.current) {
|
|
2852
2906
|
model3DNativeRef.current.setRotationAnchor(anchor);
|
|
2853
2907
|
}
|
|
2854
2908
|
}, [model3DNativeRef.current, anchor]);
|
|
2855
|
-
(0,
|
|
2909
|
+
(0, import_react26.useEffect)(() => {
|
|
2856
2910
|
if (model3DNativeRef.current) {
|
|
2857
2911
|
model3DNativeRef.current.setVisible(visible);
|
|
2858
2912
|
}
|
|
2859
2913
|
}, [model3DNativeRef.current, visible]);
|
|
2860
|
-
(0,
|
|
2914
|
+
(0, import_react26.useEffect)(() => {
|
|
2861
2915
|
if (model3DNativeRef.current) {
|
|
2862
2916
|
model3DNativeRef.current.setContentMode(contentMode);
|
|
2863
2917
|
}
|
|
2864
2918
|
}, [model3DNativeRef.current, contentMode]);
|
|
2865
|
-
(0,
|
|
2919
|
+
(0, import_react26.useEffect)(() => {
|
|
2866
2920
|
if (model3DNativeRef.current) {
|
|
2867
2921
|
model3DNativeRef.current.setResizable(resizable);
|
|
2868
2922
|
}
|
|
2869
2923
|
}, [model3DNativeRef.current, resizable]);
|
|
2870
|
-
(0,
|
|
2924
|
+
(0, import_react26.useEffect)(() => {
|
|
2871
2925
|
if (model3DNativeRef.current) {
|
|
2872
2926
|
model3DNativeRef.current.setAspectRatio(aspectRatio);
|
|
2873
2927
|
}
|
|
2874
2928
|
}, [model3DNativeRef.current, aspectRatio]);
|
|
2875
|
-
(0,
|
|
2929
|
+
(0, import_react26.useEffect)(() => {
|
|
2876
2930
|
if (model3DNativeRef.current) {
|
|
2877
2931
|
model3DNativeRef.current.setOpacity(opacity);
|
|
2878
2932
|
}
|
|
2879
2933
|
}, [model3DNativeRef.current, opacity]);
|
|
2880
|
-
const onSuccess = (0,
|
|
2934
|
+
const onSuccess = (0, import_react26.useCallback)(() => {
|
|
2881
2935
|
;
|
|
2882
2936
|
modelRef.current.ready = true;
|
|
2883
2937
|
if (onLoad) {
|
|
@@ -2886,7 +2940,7 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2886
2940
|
});
|
|
2887
2941
|
}
|
|
2888
2942
|
}, [onLoad]);
|
|
2889
|
-
const onFailure = (0,
|
|
2943
|
+
const onFailure = (0, import_react26.useCallback)(
|
|
2890
2944
|
(_2) => {
|
|
2891
2945
|
const modelElement = modelRef.current;
|
|
2892
2946
|
modelElement.ready = false;
|
|
@@ -2898,14 +2952,14 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2898
2952
|
},
|
|
2899
2953
|
[onLoad]
|
|
2900
2954
|
);
|
|
2901
|
-
(0,
|
|
2955
|
+
(0, import_react26.useEffect)(() => {
|
|
2902
2956
|
if (phase === "failure") {
|
|
2903
2957
|
onFailure(failureReason);
|
|
2904
2958
|
} else if (phase === "success") {
|
|
2905
2959
|
onSuccess();
|
|
2906
2960
|
}
|
|
2907
2961
|
}, [phase]);
|
|
2908
|
-
(0,
|
|
2962
|
+
(0, import_react26.useEffect)(() => {
|
|
2909
2963
|
return () => {
|
|
2910
2964
|
const modelElement = modelRef.current;
|
|
2911
2965
|
if (modelElement) {
|
|
@@ -2916,7 +2970,7 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2916
2970
|
}, [modelUrl]);
|
|
2917
2971
|
const needRenderPlaceHolder = inheritedPortalStyle.position !== "absolute";
|
|
2918
2972
|
if (!needRenderPlaceHolder && phase !== "failure") {
|
|
2919
|
-
return /* @__PURE__ */ (0,
|
|
2973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, {});
|
|
2920
2974
|
} else {
|
|
2921
2975
|
const extraStyle = {
|
|
2922
2976
|
visibility: "visible",
|
|
@@ -2936,7 +2990,7 @@ function renderModel3DPortalInstance(spatialId, props) {
|
|
|
2936
2990
|
...inheritedPortalStyle,
|
|
2937
2991
|
...extraStyle
|
|
2938
2992
|
};
|
|
2939
|
-
return /* @__PURE__ */ (0,
|
|
2993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2940
2994
|
"div",
|
|
2941
2995
|
{
|
|
2942
2996
|
"data-model3d-spatialid": spatialId,
|
|
@@ -2951,12 +3005,12 @@ __name(renderModel3DPortalInstance, "renderModel3DPortalInstance");
|
|
|
2951
3005
|
|
|
2952
3006
|
// src/spatial-react-components/Model3D/Model3D.tsx
|
|
2953
3007
|
function Model3DBase(props, refIn) {
|
|
2954
|
-
const parentSpatialReactContextObject = (0,
|
|
3008
|
+
const parentSpatialReactContextObject = (0, import_react27.useContext)(SpatialReactContext);
|
|
2955
3009
|
const isInSpatialDiv = !!parentSpatialReactContextObject;
|
|
2956
3010
|
if (isInSpatialDiv) {
|
|
2957
|
-
const layer = (0,
|
|
2958
|
-
const isInStandardInstance = !!(0,
|
|
2959
|
-
const spatialId = (0,
|
|
3011
|
+
const layer = (0, import_react27.useContext)(SpatialLayerContext) + 1;
|
|
3012
|
+
const isInStandardInstance = !!(0, import_react27.useContext)(SpatialIsStandardInstanceContext);
|
|
3013
|
+
const spatialId = (0, import_react27.useMemo)(() => {
|
|
2960
3014
|
return parentSpatialReactContextObject.getSpatialID(
|
|
2961
3015
|
layer,
|
|
2962
3016
|
isInStandardInstance,
|
|
@@ -2973,14 +3027,14 @@ function Model3DBase(props, refIn) {
|
|
|
2973
3027
|
}
|
|
2974
3028
|
}
|
|
2975
3029
|
__name(Model3DBase, "Model3DBase");
|
|
2976
|
-
var Model3D = (0,
|
|
3030
|
+
var Model3D = (0, import_react27.forwardRef)(Model3DBase);
|
|
2977
3031
|
Model3D.displayName = "Model3D";
|
|
2978
3032
|
|
|
2979
3033
|
// src/spatial-react-components/Model3D/CSSModel3D.tsx
|
|
2980
|
-
var
|
|
3034
|
+
var import_react30 = require("react");
|
|
2981
3035
|
|
|
2982
3036
|
// src/spatial-react-components/Model3D/CSSModel3DNotInSpatialDiv.tsx
|
|
2983
|
-
var
|
|
3037
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2984
3038
|
function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
|
|
2985
3039
|
const { className, style = {}, ...props } = inProps;
|
|
2986
3040
|
const cssParserDomStyle = {
|
|
@@ -3003,8 +3057,8 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
|
|
|
3003
3057
|
...style,
|
|
3004
3058
|
transform: "none"
|
|
3005
3059
|
};
|
|
3006
|
-
return /* @__PURE__ */ (0,
|
|
3007
|
-
ready && /* @__PURE__ */ (0,
|
|
3060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
3061
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3008
3062
|
Model3D,
|
|
3009
3063
|
{
|
|
3010
3064
|
className,
|
|
@@ -3015,7 +3069,7 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
|
|
|
3015
3069
|
...props
|
|
3016
3070
|
}
|
|
3017
3071
|
),
|
|
3018
|
-
/* @__PURE__ */ (0,
|
|
3072
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3019
3073
|
"div",
|
|
3020
3074
|
{
|
|
3021
3075
|
className,
|
|
@@ -3028,8 +3082,8 @@ function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
|
|
|
3028
3082
|
__name(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
|
|
3029
3083
|
|
|
3030
3084
|
// src/spatial-react-components/Model3D/CSSModel3DStandardInstance.tsx
|
|
3031
|
-
var
|
|
3032
|
-
var
|
|
3085
|
+
var import_react28 = require("react");
|
|
3086
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3033
3087
|
function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
|
|
3034
3088
|
const { style: inStyle = {}, ...props } = inProps;
|
|
3035
3089
|
const style = {
|
|
@@ -3037,13 +3091,13 @@ function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
|
|
|
3037
3091
|
transform: "none",
|
|
3038
3092
|
visibility: "hidden"
|
|
3039
3093
|
};
|
|
3040
|
-
var cssParserRef = (0,
|
|
3094
|
+
var cssParserRef = (0, import_react28.useRef)(null);
|
|
3041
3095
|
const ref = useHijackSpatialDivRef(
|
|
3042
3096
|
refIn,
|
|
3043
3097
|
cssParserRef
|
|
3044
3098
|
);
|
|
3045
|
-
const rootSpatialReactContextObject = (0,
|
|
3046
|
-
(0,
|
|
3099
|
+
const rootSpatialReactContextObject = (0, import_react28.useContext)(SpatialReactContext);
|
|
3100
|
+
(0, import_react28.useEffect)(() => {
|
|
3047
3101
|
const onSubEvent = /* @__PURE__ */ __name((dom) => {
|
|
3048
3102
|
cssParserRef.current = dom;
|
|
3049
3103
|
}, "onSubEvent");
|
|
@@ -3052,16 +3106,16 @@ function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
|
|
|
3052
3106
|
rootSpatialReactContextObject.offSubDivEvent(spatialId);
|
|
3053
3107
|
};
|
|
3054
3108
|
}, []);
|
|
3055
|
-
return /* @__PURE__ */ (0,
|
|
3109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Model3D, { style, ...props, ref, visible: true });
|
|
3056
3110
|
}
|
|
3057
3111
|
__name(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
|
|
3058
3112
|
|
|
3059
3113
|
// src/spatial-react-components/Model3D/CSSModel3DPortalInstance.tsx
|
|
3060
|
-
var
|
|
3061
|
-
var
|
|
3114
|
+
var import_react29 = require("react");
|
|
3115
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3062
3116
|
function renderCSSModel3DPortalInstance(spatialId, inProps) {
|
|
3063
3117
|
const { className, style = {}, ...props } = inProps;
|
|
3064
|
-
const rootSpatialReactContextObject = (0,
|
|
3118
|
+
const rootSpatialReactContextObject = (0, import_react29.useContext)(SpatialReactContext);
|
|
3065
3119
|
const { ref, spatialStyle, ready } = useSpatialStyle();
|
|
3066
3120
|
const spatialTransform = {
|
|
3067
3121
|
position: spatialStyle.position,
|
|
@@ -3069,7 +3123,7 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
|
|
|
3069
3123
|
scale: spatialStyle.scale
|
|
3070
3124
|
};
|
|
3071
3125
|
const visible = spatialStyle.visible;
|
|
3072
|
-
(0,
|
|
3126
|
+
(0, import_react29.useEffect)(() => {
|
|
3073
3127
|
rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current);
|
|
3074
3128
|
}, [ref.current]);
|
|
3075
3129
|
const cssParserDomStyle = {
|
|
@@ -3081,8 +3135,8 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
|
|
|
3081
3135
|
...style,
|
|
3082
3136
|
transform: "none"
|
|
3083
3137
|
};
|
|
3084
|
-
return /* @__PURE__ */ (0,
|
|
3085
|
-
ready && /* @__PURE__ */ (0,
|
|
3138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3139
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3086
3140
|
Model3D,
|
|
3087
3141
|
{
|
|
3088
3142
|
className,
|
|
@@ -3092,19 +3146,19 @@ function renderCSSModel3DPortalInstance(spatialId, inProps) {
|
|
|
3092
3146
|
...props
|
|
3093
3147
|
}
|
|
3094
3148
|
),
|
|
3095
|
-
/* @__PURE__ */ (0,
|
|
3149
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className, style: cssParserDomStyle, ref })
|
|
3096
3150
|
] });
|
|
3097
3151
|
}
|
|
3098
3152
|
__name(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
|
|
3099
3153
|
|
|
3100
3154
|
// src/spatial-react-components/Model3D/CSSModel3D.tsx
|
|
3101
3155
|
function CSSModel3DBase(props, refIn) {
|
|
3102
|
-
const rootSpatialReactContextObject = (0,
|
|
3156
|
+
const rootSpatialReactContextObject = (0, import_react30.useContext)(SpatialReactContext);
|
|
3103
3157
|
const isInSpatialDiv = !!rootSpatialReactContextObject;
|
|
3104
3158
|
if (isInSpatialDiv) {
|
|
3105
|
-
const layer = (0,
|
|
3106
|
-
const isInStandardInstance = !!(0,
|
|
3107
|
-
const spatialId = (0,
|
|
3159
|
+
const layer = (0, import_react30.useContext)(SpatialLayerContext) + 1;
|
|
3160
|
+
const isInStandardInstance = !!(0, import_react30.useContext)(SpatialIsStandardInstanceContext);
|
|
3161
|
+
const spatialId = (0, import_react30.useMemo)(() => {
|
|
3108
3162
|
return rootSpatialReactContextObject.getSubDivSpatialID(
|
|
3109
3163
|
layer,
|
|
3110
3164
|
isInStandardInstance,
|
|
@@ -3121,64 +3175,10 @@ function CSSModel3DBase(props, refIn) {
|
|
|
3121
3175
|
}
|
|
3122
3176
|
}
|
|
3123
3177
|
__name(CSSModel3DBase, "CSSModel3DBase");
|
|
3124
|
-
var CSSModel3D = (0,
|
|
3178
|
+
var CSSModel3D = (0, import_react30.forwardRef)(CSSModel3DBase);
|
|
3125
3179
|
CSSModel3D.displayName = "CSSModel3D";
|
|
3126
3180
|
|
|
3127
|
-
// src/spatial-react-components/SpatialView.tsx
|
|
3128
|
-
var import_react30 = require("react");
|
|
3129
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3130
|
-
var runAsync = /* @__PURE__ */ __name((fn) => {
|
|
3131
|
-
return fn();
|
|
3132
|
-
}, "runAsync");
|
|
3133
|
-
var SpatialViewEl = (0, import_react30.forwardRef)(
|
|
3134
|
-
(props, ref) => {
|
|
3135
|
-
const divRef = (0, import_react30.useRef)(null);
|
|
3136
|
-
const spatialEntity = (0, import_react30.useRef)(null);
|
|
3137
|
-
const activePromise = (0, import_react30.useRef)(null);
|
|
3138
|
-
(0, import_react30.useImperativeHandle)(ref, () => ({
|
|
3139
|
-
...divRef.current,
|
|
3140
|
-
getViewEntity: /* @__PURE__ */ __name(async () => {
|
|
3141
|
-
if (activePromise.current) {
|
|
3142
|
-
await activePromise.current;
|
|
3143
|
-
}
|
|
3144
|
-
return spatialEntity.current;
|
|
3145
|
-
}, "getViewEntity")
|
|
3146
|
-
}));
|
|
3147
|
-
if (getSession() == null) {
|
|
3148
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
|
|
3149
|
-
}
|
|
3150
|
-
(0, import_react30.useEffect)(() => {
|
|
3151
|
-
if (true) return;
|
|
3152
|
-
activePromise.current = runAsync(async () => {
|
|
3153
|
-
if (activePromise.current) {
|
|
3154
|
-
await activePromise.current;
|
|
3155
|
-
}
|
|
3156
|
-
let sh = new SpatialHelper(getSession());
|
|
3157
|
-
let x = await sh.dom.attachSpatialView(divRef.current);
|
|
3158
|
-
spatialEntity.current = x.entity;
|
|
3159
|
-
if (props.onViewLoad) {
|
|
3160
|
-
props.onViewLoad(x.entity);
|
|
3161
|
-
}
|
|
3162
|
-
});
|
|
3163
|
-
return () => {
|
|
3164
|
-
if (true) return;
|
|
3165
|
-
runAsync(async () => {
|
|
3166
|
-
await activePromise.current;
|
|
3167
|
-
spatialEntity.current?.destroy();
|
|
3168
|
-
if (props.onViewUnload) {
|
|
3169
|
-
props.onViewUnload();
|
|
3170
|
-
}
|
|
3171
|
-
});
|
|
3172
|
-
};
|
|
3173
|
-
}, []);
|
|
3174
|
-
const { onViewLoad, onViewUnload, ...divProps } = props;
|
|
3175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...divProps });
|
|
3176
|
-
}
|
|
3177
|
-
);
|
|
3178
|
-
var SpatialView = SpatialViewEl;
|
|
3179
|
-
|
|
3180
3181
|
// src/spatial-react-components/Model/index.tsx
|
|
3181
|
-
var import_react31 = require("react");
|
|
3182
3182
|
var import_model_viewer = require("@google/model-viewer");
|
|
3183
3183
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3184
3184
|
function renderInModel3D(inProps, ref, modelUrl, placeHolder) {
|