@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
|
@@ -65,11 +65,9 @@ var require_web = __commonJS({
|
|
|
65
65
|
var __toCommonJS2 = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
66
66
|
var src_exports = {};
|
|
67
67
|
__export2(src_exports, {
|
|
68
|
-
CSSModel3D: /* @__PURE__ */ __name(() => CSSModel3D, "CSSModel3D"),
|
|
69
68
|
CSSSpatialDiv: /* @__PURE__ */ __name(() => CSSSpatialDiv, "CSSSpatialDiv"),
|
|
70
69
|
CSSSpatialPrimitive: /* @__PURE__ */ __name(() => CSSSpatialPrimitive, "CSSSpatialPrimitive"),
|
|
71
70
|
Model: /* @__PURE__ */ __name(() => Model, "Model"),
|
|
72
|
-
Model3D: /* @__PURE__ */ __name(() => Model3D, "Model3D"),
|
|
73
71
|
SpatialDiv: /* @__PURE__ */ __name(() => SpatialDiv, "SpatialDiv"),
|
|
74
72
|
SpatialMonitor: /* @__PURE__ */ __name(() => SpatialMonitor, "SpatialMonitor"),
|
|
75
73
|
SpatialPrimitive: /* @__PURE__ */ __name(() => SpatialPrimitive, "SpatialPrimitive"),
|
|
@@ -2074,11 +2072,63 @@ var require_web = __commonJS({
|
|
|
2074
2072
|
});
|
|
2075
2073
|
}, "createSpatialPrimitive2"), "createSpatialPrimitive"))(CSSSpatialPrimitive);
|
|
2076
2074
|
var CSSSpatialDiv = CSSSpatialPrimitive.div;
|
|
2077
|
-
var import_react26 = require("react");
|
|
2078
2075
|
var import_react21 = require("react");
|
|
2076
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2077
|
+
var runAsync = /* @__PURE__ */ __name2((fn) => {
|
|
2078
|
+
return fn();
|
|
2079
|
+
}, "runAsync");
|
|
2080
|
+
var SpatialViewEl = (0, import_react21.forwardRef)(
|
|
2081
|
+
(props, ref) => {
|
|
2082
|
+
const divRef = (0, import_react21.useRef)(null);
|
|
2083
|
+
const spatialEntity = (0, import_react21.useRef)(null);
|
|
2084
|
+
const activePromise = (0, import_react21.useRef)(null);
|
|
2085
|
+
(0, import_react21.useImperativeHandle)(ref, () => ({
|
|
2086
|
+
...divRef.current,
|
|
2087
|
+
getViewEntity: /* @__PURE__ */ __name2(async () => {
|
|
2088
|
+
if (activePromise.current) {
|
|
2089
|
+
await activePromise.current;
|
|
2090
|
+
}
|
|
2091
|
+
return spatialEntity.current;
|
|
2092
|
+
}, "getViewEntity")
|
|
2093
|
+
}));
|
|
2094
|
+
if (getSession3() == null) {
|
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
|
|
2096
|
+
}
|
|
2097
|
+
(0, import_react21.useEffect)(() => {
|
|
2098
|
+
if (true) return;
|
|
2099
|
+
activePromise.current = runAsync(async () => {
|
|
2100
|
+
if (activePromise.current) {
|
|
2101
|
+
await activePromise.current;
|
|
2102
|
+
}
|
|
2103
|
+
let sh = new SpatialHelper(getSession3());
|
|
2104
|
+
let x = await sh.dom.attachSpatialView(divRef.current);
|
|
2105
|
+
spatialEntity.current = x.entity;
|
|
2106
|
+
if (props.onViewLoad) {
|
|
2107
|
+
props.onViewLoad(x.entity);
|
|
2108
|
+
}
|
|
2109
|
+
});
|
|
2110
|
+
return () => {
|
|
2111
|
+
if (true) return;
|
|
2112
|
+
runAsync(async () => {
|
|
2113
|
+
await activePromise.current;
|
|
2114
|
+
spatialEntity.current?.destroy();
|
|
2115
|
+
if (props.onViewUnload) {
|
|
2116
|
+
props.onViewUnload();
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
};
|
|
2120
|
+
}, []);
|
|
2121
|
+
const { onViewLoad, onViewUnload, ...divProps } = props;
|
|
2122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...divProps });
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2125
|
+
var SpatialView = SpatialViewEl;
|
|
2126
|
+
var import_react31 = require("react");
|
|
2127
|
+
var import_react27 = require("react");
|
|
2128
|
+
var import_react22 = require("react");
|
|
2079
2129
|
function useDetectLayoutDomUpdated(onDomUpdated) {
|
|
2080
|
-
const ref = (0,
|
|
2081
|
-
(0,
|
|
2130
|
+
const ref = (0, import_react22.useRef)(null);
|
|
2131
|
+
(0, import_react22.useEffect)(() => {
|
|
2082
2132
|
if (!ref.current) {
|
|
2083
2133
|
console.warn("Ref is not attached to the DOM");
|
|
2084
2134
|
return;
|
|
@@ -2091,7 +2141,7 @@ var require_web = __commonJS({
|
|
|
2091
2141
|
ro.disconnect();
|
|
2092
2142
|
};
|
|
2093
2143
|
}, []);
|
|
2094
|
-
(0,
|
|
2144
|
+
(0, import_react22.useEffect)(() => {
|
|
2095
2145
|
if (!ref.current) {
|
|
2096
2146
|
console.warn("Ref is not attached to the DOM");
|
|
2097
2147
|
return;
|
|
@@ -2112,7 +2162,7 @@ var require_web = __commonJS({
|
|
|
2112
2162
|
}
|
|
2113
2163
|
__name(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
|
|
2114
2164
|
__name2(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
|
|
2115
|
-
var
|
|
2165
|
+
var import_react23 = require("react");
|
|
2116
2166
|
function PopulatePartialSpatialTransformType(spatialTransform = {}) {
|
|
2117
2167
|
const {
|
|
2118
2168
|
position = { x: 0, y: 0, z: 0 },
|
|
@@ -2339,12 +2389,12 @@ var require_web = __commonJS({
|
|
|
2339
2389
|
}
|
|
2340
2390
|
};
|
|
2341
2391
|
function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DNativeReadyCb) {
|
|
2342
|
-
let model3DNativeRef = (0,
|
|
2343
|
-
const [phase, setPhase] = (0,
|
|
2392
|
+
let model3DNativeRef = (0, import_react23.useRef)(null);
|
|
2393
|
+
const [phase, setPhase] = (0, import_react23.useState)(
|
|
2344
2394
|
"loading"
|
|
2345
2395
|
);
|
|
2346
|
-
const [failureReason, setFailureReason] = (0,
|
|
2347
|
-
(0,
|
|
2396
|
+
const [failureReason, setFailureReason] = (0, import_react23.useState)("");
|
|
2397
|
+
(0, import_react23.useEffect)(() => {
|
|
2348
2398
|
let isDestroyed = false;
|
|
2349
2399
|
const model3DContainer = new Model3DNative(parentEntity);
|
|
2350
2400
|
model3DContainer.init(
|
|
@@ -2371,32 +2421,32 @@ var require_web = __commonJS({
|
|
|
2371
2421
|
setPhase("loading");
|
|
2372
2422
|
};
|
|
2373
2423
|
}, [modelUrl]);
|
|
2374
|
-
(0,
|
|
2424
|
+
(0, import_react23.useEffect)(() => {
|
|
2375
2425
|
if (model3DNativeRef.current) {
|
|
2376
2426
|
model3DNativeRef.current.onDragStart = eventHandlers.onDragStart;
|
|
2377
2427
|
}
|
|
2378
2428
|
}, [model3DNativeRef.current, eventHandlers.onDragStart]);
|
|
2379
|
-
(0,
|
|
2429
|
+
(0, import_react23.useEffect)(() => {
|
|
2380
2430
|
if (model3DNativeRef.current) {
|
|
2381
2431
|
model3DNativeRef.current.onDrag = eventHandlers.onDrag;
|
|
2382
2432
|
}
|
|
2383
2433
|
}, [model3DNativeRef.current, eventHandlers.onDrag]);
|
|
2384
|
-
(0,
|
|
2434
|
+
(0, import_react23.useEffect)(() => {
|
|
2385
2435
|
if (model3DNativeRef.current) {
|
|
2386
2436
|
model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd;
|
|
2387
2437
|
}
|
|
2388
2438
|
});
|
|
2389
|
-
(0,
|
|
2439
|
+
(0, import_react23.useEffect)(() => {
|
|
2390
2440
|
if (model3DNativeRef.current) {
|
|
2391
2441
|
model3DNativeRef.current.onTap = eventHandlers.onTap;
|
|
2392
2442
|
}
|
|
2393
2443
|
}, [model3DNativeRef.current, eventHandlers.onTap]);
|
|
2394
|
-
(0,
|
|
2444
|
+
(0, import_react23.useEffect)(() => {
|
|
2395
2445
|
if (model3DNativeRef.current) {
|
|
2396
2446
|
model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap;
|
|
2397
2447
|
}
|
|
2398
2448
|
}, [model3DNativeRef.current, eventHandlers.onDoubleTap]);
|
|
2399
|
-
(0,
|
|
2449
|
+
(0, import_react23.useEffect)(() => {
|
|
2400
2450
|
if (model3DNativeRef.current) {
|
|
2401
2451
|
model3DNativeRef.current.onLongPress = eventHandlers.onLongPress;
|
|
2402
2452
|
}
|
|
@@ -2405,8 +2455,8 @@ var require_web = __commonJS({
|
|
|
2405
2455
|
}
|
|
2406
2456
|
__name(useModel3DNative, "useModel3DNative");
|
|
2407
2457
|
__name2(useModel3DNative, "useModel3DNative");
|
|
2408
|
-
var
|
|
2409
|
-
var
|
|
2458
|
+
var import_react24 = require("react");
|
|
2459
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2410
2460
|
function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
2411
2461
|
const {
|
|
2412
2462
|
className,
|
|
@@ -2427,7 +2477,7 @@ var require_web = __commonJS({
|
|
|
2427
2477
|
onLongPress
|
|
2428
2478
|
} = props;
|
|
2429
2479
|
const theSpatialTransform = PopulatePartialSpatialTransformType(spatialTransform);
|
|
2430
|
-
const onDomUpdated = (0,
|
|
2480
|
+
const onDomUpdated = (0, import_react24.useCallback)(() => {
|
|
2431
2481
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
2432
2482
|
const model3DNative = model3DNativeRef.current;
|
|
2433
2483
|
model3DNative.updateByDom(layoutInstanceRef.current, {
|
|
@@ -2446,7 +2496,7 @@ var require_web = __commonJS({
|
|
|
2446
2496
|
theSpatialTransform.scale.y,
|
|
2447
2497
|
theSpatialTransform.scale.z
|
|
2448
2498
|
]);
|
|
2449
|
-
const onModel3DContainerReadyCb = (0,
|
|
2499
|
+
const onModel3DContainerReadyCb = (0, import_react24.useCallback)(() => {
|
|
2450
2500
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
2451
2501
|
model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
|
|
2452
2502
|
spatialTransform: theSpatialTransform
|
|
@@ -2464,7 +2514,7 @@ var require_web = __commonJS({
|
|
|
2464
2514
|
theSpatialTransform.scale.y,
|
|
2465
2515
|
theSpatialTransform.scale.z
|
|
2466
2516
|
]);
|
|
2467
|
-
const onDragStartCb = (0,
|
|
2517
|
+
const onDragStartCb = (0, import_react24.useCallback)(
|
|
2468
2518
|
(spatialDragEvent) => {
|
|
2469
2519
|
if (onDragStart) {
|
|
2470
2520
|
const dragEvent = {
|
|
@@ -2476,7 +2526,7 @@ var require_web = __commonJS({
|
|
|
2476
2526
|
},
|
|
2477
2527
|
[onDragStart]
|
|
2478
2528
|
);
|
|
2479
|
-
const onDragCb = (0,
|
|
2529
|
+
const onDragCb = (0, import_react24.useCallback)(
|
|
2480
2530
|
(spatialDragEvent) => {
|
|
2481
2531
|
if (onDrag) {
|
|
2482
2532
|
const dragEvent = {
|
|
@@ -2488,7 +2538,7 @@ var require_web = __commonJS({
|
|
|
2488
2538
|
},
|
|
2489
2539
|
[onDrag]
|
|
2490
2540
|
);
|
|
2491
|
-
const onDragEndCb = (0,
|
|
2541
|
+
const onDragEndCb = (0, import_react24.useCallback)(
|
|
2492
2542
|
(spatialDragEvent) => {
|
|
2493
2543
|
if (onDragEnd) {
|
|
2494
2544
|
const dragEvent = {
|
|
@@ -2500,7 +2550,7 @@ var require_web = __commonJS({
|
|
|
2500
2550
|
},
|
|
2501
2551
|
[onDragEnd]
|
|
2502
2552
|
);
|
|
2503
|
-
const onTapCb = (0,
|
|
2553
|
+
const onTapCb = (0, import_react24.useCallback)(() => {
|
|
2504
2554
|
if (onTap) {
|
|
2505
2555
|
const event = {
|
|
2506
2556
|
target: layoutInstanceRef.current
|
|
@@ -2508,7 +2558,7 @@ var require_web = __commonJS({
|
|
|
2508
2558
|
onTap(event);
|
|
2509
2559
|
}
|
|
2510
2560
|
}, [onTap]);
|
|
2511
|
-
const onDoubleTapCb = (0,
|
|
2561
|
+
const onDoubleTapCb = (0, import_react24.useCallback)(() => {
|
|
2512
2562
|
if (onDoubleTap) {
|
|
2513
2563
|
const event = {
|
|
2514
2564
|
target: layoutInstanceRef.current
|
|
@@ -2516,7 +2566,7 @@ var require_web = __commonJS({
|
|
|
2516
2566
|
onDoubleTap(event);
|
|
2517
2567
|
}
|
|
2518
2568
|
}, [onDoubleTap]);
|
|
2519
|
-
const onLongPressCb = (0,
|
|
2569
|
+
const onLongPressCb = (0, import_react24.useCallback)(() => {
|
|
2520
2570
|
if (onLongPress) {
|
|
2521
2571
|
const event = {
|
|
2522
2572
|
target: layoutInstanceRef.current
|
|
@@ -2538,7 +2588,7 @@ var require_web = __commonJS({
|
|
|
2538
2588
|
},
|
|
2539
2589
|
onModel3DContainerReadyCb
|
|
2540
2590
|
);
|
|
2541
|
-
const onSuccess = (0,
|
|
2591
|
+
const onSuccess = (0, import_react24.useCallback)(() => {
|
|
2542
2592
|
;
|
|
2543
2593
|
layoutInstanceRef.current.ready = true;
|
|
2544
2594
|
if (onLoad) {
|
|
@@ -2547,7 +2597,7 @@ var require_web = __commonJS({
|
|
|
2547
2597
|
});
|
|
2548
2598
|
}
|
|
2549
2599
|
}, [onLoad]);
|
|
2550
|
-
const onFailure = (0,
|
|
2600
|
+
const onFailure = (0, import_react24.useCallback)(
|
|
2551
2601
|
(_) => {
|
|
2552
2602
|
const modelElement = layoutInstanceRef.current;
|
|
2553
2603
|
modelElement.ready = false;
|
|
@@ -2559,19 +2609,19 @@ var require_web = __commonJS({
|
|
|
2559
2609
|
},
|
|
2560
2610
|
[onLoad]
|
|
2561
2611
|
);
|
|
2562
|
-
(0,
|
|
2612
|
+
(0, import_react24.useEffect)(() => {
|
|
2563
2613
|
if (phase === "failure") {
|
|
2564
2614
|
onFailure(failureReason);
|
|
2565
2615
|
} else if (phase === "success") {
|
|
2566
2616
|
onSuccess();
|
|
2567
2617
|
}
|
|
2568
2618
|
}, [phase]);
|
|
2569
|
-
(0,
|
|
2619
|
+
(0, import_react24.useEffect)(() => {
|
|
2570
2620
|
if (model3DNativeRef.current) {
|
|
2571
2621
|
model3DNativeRef.current.setVisible(visible);
|
|
2572
2622
|
}
|
|
2573
2623
|
}, [model3DNativeRef.current, visible]);
|
|
2574
|
-
(0,
|
|
2624
|
+
(0, import_react24.useEffect)(() => {
|
|
2575
2625
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
2576
2626
|
model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
|
|
2577
2627
|
spatialTransform: theSpatialTransform
|
|
@@ -2589,17 +2639,17 @@ var require_web = __commonJS({
|
|
|
2589
2639
|
theSpatialTransform.scale.y,
|
|
2590
2640
|
theSpatialTransform.scale.z
|
|
2591
2641
|
]);
|
|
2592
|
-
(0,
|
|
2642
|
+
(0, import_react24.useEffect)(() => {
|
|
2593
2643
|
if (model3DNativeRef.current) {
|
|
2594
2644
|
model3DNativeRef.current.setContentMode(contentMode);
|
|
2595
2645
|
}
|
|
2596
2646
|
}, [model3DNativeRef.current, contentMode]);
|
|
2597
|
-
(0,
|
|
2647
|
+
(0, import_react24.useEffect)(() => {
|
|
2598
2648
|
if (model3DNativeRef.current) {
|
|
2599
2649
|
model3DNativeRef.current.setResizable(resizable);
|
|
2600
2650
|
}
|
|
2601
2651
|
}, [model3DNativeRef.current, resizable]);
|
|
2602
|
-
(0,
|
|
2652
|
+
(0, import_react24.useEffect)(() => {
|
|
2603
2653
|
if (model3DNativeRef.current) {
|
|
2604
2654
|
model3DNativeRef.current.setAspectRatio(aspectRatio);
|
|
2605
2655
|
}
|
|
@@ -2609,7 +2659,7 @@ var require_web = __commonJS({
|
|
|
2609
2659
|
visibility: phase === "failure" ? "visible" : "hidden",
|
|
2610
2660
|
transform: ""
|
|
2611
2661
|
};
|
|
2612
|
-
const proxyRef = (0,
|
|
2662
|
+
const proxyRef = (0, import_react24.useMemo)(
|
|
2613
2663
|
() => new Proxy(layoutInstanceRef, {
|
|
2614
2664
|
get(target, prop, receiver) {
|
|
2615
2665
|
return Reflect.get(target, prop, receiver);
|
|
@@ -2634,7 +2684,7 @@ var require_web = __commonJS({
|
|
|
2634
2684
|
}),
|
|
2635
2685
|
[layoutInstanceRef, refIn]
|
|
2636
2686
|
);
|
|
2637
|
-
(0,
|
|
2687
|
+
(0, import_react24.useEffect)(() => {
|
|
2638
2688
|
return () => {
|
|
2639
2689
|
if (layoutInstanceRef.current) {
|
|
2640
2690
|
const modelElement = layoutInstanceRef.current;
|
|
@@ -2643,17 +2693,17 @@ var require_web = __commonJS({
|
|
|
2643
2693
|
}
|
|
2644
2694
|
};
|
|
2645
2695
|
}, [modelUrl]);
|
|
2646
|
-
return /* @__PURE__ */ (0,
|
|
2696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style: layoutDomStyle, ref: proxyRef, children: phase === "failure" && children });
|
|
2647
2697
|
}
|
|
2648
2698
|
__name(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
|
|
2649
2699
|
__name2(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
|
|
2650
|
-
var
|
|
2700
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2651
2701
|
function renderModel3DStandardInstance(spatialId, props, refIn) {
|
|
2652
2702
|
const { className, style } = props;
|
|
2653
2703
|
const extraProps = {
|
|
2654
2704
|
[SpatialID]: spatialId
|
|
2655
2705
|
};
|
|
2656
|
-
return /* @__PURE__ */ (0,
|
|
2706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2657
2707
|
"div",
|
|
2658
2708
|
{
|
|
2659
2709
|
"data-model3d-spatialid": spatialId,
|
|
@@ -2666,26 +2716,26 @@ var require_web = __commonJS({
|
|
|
2666
2716
|
}
|
|
2667
2717
|
__name(renderModel3DStandardInstance, "renderModel3DStandardInstance");
|
|
2668
2718
|
__name2(renderModel3DStandardInstance, "renderModel3DStandardInstance");
|
|
2719
|
+
var import_react26 = require("react");
|
|
2669
2720
|
var import_react25 = require("react");
|
|
2670
|
-
var import_react24 = require("react");
|
|
2671
2721
|
function useSyncDomInfoFromStandardInstance(spatialId) {
|
|
2672
|
-
const [domRect, setDomRect] = (0,
|
|
2722
|
+
const [domRect, setDomRect] = (0, import_react25.useState)({
|
|
2673
2723
|
x: 0,
|
|
2674
2724
|
y: 0,
|
|
2675
2725
|
width: 0,
|
|
2676
2726
|
height: 0
|
|
2677
2727
|
});
|
|
2678
|
-
const inheritedPortalStyleRef = (0,
|
|
2679
|
-
const anchorRef = (0,
|
|
2728
|
+
const inheritedPortalStyleRef = (0, import_react25.useRef)({});
|
|
2729
|
+
const anchorRef = (0, import_react25.useRef)({
|
|
2680
2730
|
x: 0.5,
|
|
2681
2731
|
y: 0.5,
|
|
2682
2732
|
z: 0.5
|
|
2683
2733
|
});
|
|
2684
|
-
const opacityRef = (0,
|
|
2685
|
-
const spatialReactContextObject = (0,
|
|
2686
|
-
const inheritedPortalClassNameRef = (0,
|
|
2687
|
-
const modelRef = (0,
|
|
2688
|
-
(0,
|
|
2734
|
+
const opacityRef = (0, import_react25.useRef)(1);
|
|
2735
|
+
const spatialReactContextObject = (0, import_react25.useContext)(SpatialReactContext);
|
|
2736
|
+
const inheritedPortalClassNameRef = (0, import_react25.useRef)("");
|
|
2737
|
+
const modelRef = (0, import_react25.useRef)(null);
|
|
2738
|
+
(0, import_react25.useEffect)(() => {
|
|
2689
2739
|
const syncDomRect = /* @__PURE__ */ __name2(() => {
|
|
2690
2740
|
const dom = spatialReactContextObject?.querySpatialDom(spatialId);
|
|
2691
2741
|
if (!dom) {
|
|
@@ -2726,7 +2776,7 @@ var require_web = __commonJS({
|
|
|
2726
2776
|
}
|
|
2727
2777
|
__name(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
|
|
2728
2778
|
__name2(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
|
|
2729
|
-
var
|
|
2779
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2730
2780
|
function useModelEvents(props, modelRef) {
|
|
2731
2781
|
const {
|
|
2732
2782
|
onDragStart,
|
|
@@ -2736,7 +2786,7 @@ var require_web = __commonJS({
|
|
|
2736
2786
|
onDoubleTap,
|
|
2737
2787
|
onLongPress
|
|
2738
2788
|
} = props;
|
|
2739
|
-
const onDragStartCb = (0,
|
|
2789
|
+
const onDragStartCb = (0, import_react26.useCallback)(
|
|
2740
2790
|
(spatialDragEvent) => {
|
|
2741
2791
|
if (onDragStart) {
|
|
2742
2792
|
const dragEvent = {
|
|
@@ -2748,7 +2798,7 @@ var require_web = __commonJS({
|
|
|
2748
2798
|
},
|
|
2749
2799
|
[onDragStart]
|
|
2750
2800
|
);
|
|
2751
|
-
const onDragCb = (0,
|
|
2801
|
+
const onDragCb = (0, import_react26.useCallback)(
|
|
2752
2802
|
(spatialDragEvent) => {
|
|
2753
2803
|
if (onDrag) {
|
|
2754
2804
|
const dragEvent = {
|
|
@@ -2760,7 +2810,7 @@ var require_web = __commonJS({
|
|
|
2760
2810
|
},
|
|
2761
2811
|
[onDrag]
|
|
2762
2812
|
);
|
|
2763
|
-
const onDragEndCb = (0,
|
|
2813
|
+
const onDragEndCb = (0, import_react26.useCallback)(
|
|
2764
2814
|
(spatialDragEvent) => {
|
|
2765
2815
|
if (onDragEnd) {
|
|
2766
2816
|
const dragEvent = {
|
|
@@ -2772,7 +2822,7 @@ var require_web = __commonJS({
|
|
|
2772
2822
|
},
|
|
2773
2823
|
[onDragEnd]
|
|
2774
2824
|
);
|
|
2775
|
-
const onTapCb = (0,
|
|
2825
|
+
const onTapCb = (0, import_react26.useCallback)(() => {
|
|
2776
2826
|
if (onTap) {
|
|
2777
2827
|
const event = {
|
|
2778
2828
|
target: modelRef.current
|
|
@@ -2780,7 +2830,7 @@ var require_web = __commonJS({
|
|
|
2780
2830
|
onTap(event);
|
|
2781
2831
|
}
|
|
2782
2832
|
}, [onTap]);
|
|
2783
|
-
const onDoubleTapCb = (0,
|
|
2833
|
+
const onDoubleTapCb = (0, import_react26.useCallback)(() => {
|
|
2784
2834
|
if (onDoubleTap) {
|
|
2785
2835
|
const event = {
|
|
2786
2836
|
target: modelRef.current
|
|
@@ -2788,7 +2838,7 @@ var require_web = __commonJS({
|
|
|
2788
2838
|
onDoubleTap(event);
|
|
2789
2839
|
}
|
|
2790
2840
|
}, [onDoubleTap]);
|
|
2791
|
-
const onLongPressCb = (0,
|
|
2841
|
+
const onLongPressCb = (0, import_react26.useCallback)(() => {
|
|
2792
2842
|
if (onLongPress) {
|
|
2793
2843
|
const event = {
|
|
2794
2844
|
target: modelRef.current
|
|
@@ -2819,7 +2869,7 @@ var require_web = __commonJS({
|
|
|
2819
2869
|
onLoad,
|
|
2820
2870
|
children
|
|
2821
2871
|
} = props;
|
|
2822
|
-
const theSpatialTransform = (0,
|
|
2872
|
+
const theSpatialTransform = (0, import_react26.useMemo)(() => {
|
|
2823
2873
|
return PopulatePartialSpatialTransformType(spatialTransform);
|
|
2824
2874
|
}, [spatialTransform]);
|
|
2825
2875
|
const {
|
|
@@ -2830,7 +2880,7 @@ var require_web = __commonJS({
|
|
|
2830
2880
|
opacity,
|
|
2831
2881
|
className
|
|
2832
2882
|
} = useSyncDomInfoFromStandardInstance(spatialId);
|
|
2833
|
-
const parentSpatialWindowManager = (0,
|
|
2883
|
+
const parentSpatialWindowManager = (0, import_react26.useContext)(SpatialWindowManagerContext);
|
|
2834
2884
|
const eventHandlers = useModelEvents(
|
|
2835
2885
|
props,
|
|
2836
2886
|
modelRef
|
|
@@ -2840,7 +2890,7 @@ var require_web = __commonJS({
|
|
|
2840
2890
|
parentSpatialWindowManager.entity,
|
|
2841
2891
|
eventHandlers
|
|
2842
2892
|
);
|
|
2843
|
-
(0,
|
|
2893
|
+
(0, import_react26.useEffect)(() => {
|
|
2844
2894
|
if (model3DNativeRef.current) {
|
|
2845
2895
|
model3DNativeRef.current.updateRectAndTransform(
|
|
2846
2896
|
domRect,
|
|
@@ -2848,37 +2898,37 @@ var require_web = __commonJS({
|
|
|
2848
2898
|
);
|
|
2849
2899
|
}
|
|
2850
2900
|
}, [model3DNativeRef.current, domRect, theSpatialTransform]);
|
|
2851
|
-
(0,
|
|
2901
|
+
(0, import_react26.useEffect)(() => {
|
|
2852
2902
|
if (model3DNativeRef.current) {
|
|
2853
2903
|
model3DNativeRef.current.setRotationAnchor(anchor);
|
|
2854
2904
|
}
|
|
2855
2905
|
}, [model3DNativeRef.current, anchor]);
|
|
2856
|
-
(0,
|
|
2906
|
+
(0, import_react26.useEffect)(() => {
|
|
2857
2907
|
if (model3DNativeRef.current) {
|
|
2858
2908
|
model3DNativeRef.current.setVisible(visible);
|
|
2859
2909
|
}
|
|
2860
2910
|
}, [model3DNativeRef.current, visible]);
|
|
2861
|
-
(0,
|
|
2911
|
+
(0, import_react26.useEffect)(() => {
|
|
2862
2912
|
if (model3DNativeRef.current) {
|
|
2863
2913
|
model3DNativeRef.current.setContentMode(contentMode);
|
|
2864
2914
|
}
|
|
2865
2915
|
}, [model3DNativeRef.current, contentMode]);
|
|
2866
|
-
(0,
|
|
2916
|
+
(0, import_react26.useEffect)(() => {
|
|
2867
2917
|
if (model3DNativeRef.current) {
|
|
2868
2918
|
model3DNativeRef.current.setResizable(resizable);
|
|
2869
2919
|
}
|
|
2870
2920
|
}, [model3DNativeRef.current, resizable]);
|
|
2871
|
-
(0,
|
|
2921
|
+
(0, import_react26.useEffect)(() => {
|
|
2872
2922
|
if (model3DNativeRef.current) {
|
|
2873
2923
|
model3DNativeRef.current.setAspectRatio(aspectRatio);
|
|
2874
2924
|
}
|
|
2875
2925
|
}, [model3DNativeRef.current, aspectRatio]);
|
|
2876
|
-
(0,
|
|
2926
|
+
(0, import_react26.useEffect)(() => {
|
|
2877
2927
|
if (model3DNativeRef.current) {
|
|
2878
2928
|
model3DNativeRef.current.setOpacity(opacity);
|
|
2879
2929
|
}
|
|
2880
2930
|
}, [model3DNativeRef.current, opacity]);
|
|
2881
|
-
const onSuccess = (0,
|
|
2931
|
+
const onSuccess = (0, import_react26.useCallback)(() => {
|
|
2882
2932
|
;
|
|
2883
2933
|
modelRef.current.ready = true;
|
|
2884
2934
|
if (onLoad) {
|
|
@@ -2887,7 +2937,7 @@ var require_web = __commonJS({
|
|
|
2887
2937
|
});
|
|
2888
2938
|
}
|
|
2889
2939
|
}, [onLoad]);
|
|
2890
|
-
const onFailure = (0,
|
|
2940
|
+
const onFailure = (0, import_react26.useCallback)(
|
|
2891
2941
|
(_2) => {
|
|
2892
2942
|
const modelElement = modelRef.current;
|
|
2893
2943
|
modelElement.ready = false;
|
|
@@ -2899,14 +2949,14 @@ var require_web = __commonJS({
|
|
|
2899
2949
|
},
|
|
2900
2950
|
[onLoad]
|
|
2901
2951
|
);
|
|
2902
|
-
(0,
|
|
2952
|
+
(0, import_react26.useEffect)(() => {
|
|
2903
2953
|
if (phase === "failure") {
|
|
2904
2954
|
onFailure(failureReason);
|
|
2905
2955
|
} else if (phase === "success") {
|
|
2906
2956
|
onSuccess();
|
|
2907
2957
|
}
|
|
2908
2958
|
}, [phase]);
|
|
2909
|
-
(0,
|
|
2959
|
+
(0, import_react26.useEffect)(() => {
|
|
2910
2960
|
return () => {
|
|
2911
2961
|
const modelElement = modelRef.current;
|
|
2912
2962
|
if (modelElement) {
|
|
@@ -2917,7 +2967,7 @@ var require_web = __commonJS({
|
|
|
2917
2967
|
}, [modelUrl]);
|
|
2918
2968
|
const needRenderPlaceHolder = inheritedPortalStyle.position !== "absolute";
|
|
2919
2969
|
if (!needRenderPlaceHolder && phase !== "failure") {
|
|
2920
|
-
return /* @__PURE__ */ (0,
|
|
2970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, {});
|
|
2921
2971
|
} else {
|
|
2922
2972
|
const extraStyle = {
|
|
2923
2973
|
visibility: "visible",
|
|
@@ -2937,7 +2987,7 @@ var require_web = __commonJS({
|
|
|
2937
2987
|
...inheritedPortalStyle,
|
|
2938
2988
|
...extraStyle
|
|
2939
2989
|
};
|
|
2940
|
-
return /* @__PURE__ */ (0,
|
|
2990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2941
2991
|
"div",
|
|
2942
2992
|
{
|
|
2943
2993
|
"data-model3d-spatialid": spatialId,
|
|
@@ -2951,12 +3001,12 @@ var require_web = __commonJS({
|
|
|
2951
3001
|
__name(renderModel3DPortalInstance, "renderModel3DPortalInstance");
|
|
2952
3002
|
__name2(renderModel3DPortalInstance, "renderModel3DPortalInstance");
|
|
2953
3003
|
function Model3DBase(props, refIn) {
|
|
2954
|
-
const parentSpatialReactContextObject = (0,
|
|
3004
|
+
const parentSpatialReactContextObject = (0, import_react27.useContext)(SpatialReactContext);
|
|
2955
3005
|
const isInSpatialDiv = !!parentSpatialReactContextObject;
|
|
2956
3006
|
if (isInSpatialDiv) {
|
|
2957
|
-
const layer = (0,
|
|
2958
|
-
const isInStandardInstance = !!(0,
|
|
2959
|
-
const spatialId = (0,
|
|
3007
|
+
const layer = (0, import_react27.useContext)(SpatialLayerContext) + 1;
|
|
3008
|
+
const isInStandardInstance = !!(0, import_react27.useContext)(SpatialIsStandardInstanceContext);
|
|
3009
|
+
const spatialId = (0, import_react27.useMemo)(() => {
|
|
2960
3010
|
return parentSpatialReactContextObject.getSpatialID(
|
|
2961
3011
|
layer,
|
|
2962
3012
|
isInStandardInstance,
|
|
@@ -2974,10 +3024,10 @@ var require_web = __commonJS({
|
|
|
2974
3024
|
}
|
|
2975
3025
|
__name(Model3DBase, "Model3DBase");
|
|
2976
3026
|
__name2(Model3DBase, "Model3DBase");
|
|
2977
|
-
var Model3D = (0,
|
|
3027
|
+
var Model3D = (0, import_react27.forwardRef)(Model3DBase);
|
|
2978
3028
|
Model3D.displayName = "Model3D";
|
|
2979
|
-
var
|
|
2980
|
-
var
|
|
3029
|
+
var import_react30 = require("react");
|
|
3030
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2981
3031
|
function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
|
|
2982
3032
|
const { className, style = {}, ...props } = inProps;
|
|
2983
3033
|
const cssParserDomStyle = {
|
|
@@ -3000,8 +3050,8 @@ var require_web = __commonJS({
|
|
|
3000
3050
|
...style,
|
|
3001
3051
|
transform: "none"
|
|
3002
3052
|
};
|
|
3003
|
-
return /* @__PURE__ */ (0,
|
|
3004
|
-
ready && /* @__PURE__ */ (0,
|
|
3053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
3054
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3005
3055
|
Model3D,
|
|
3006
3056
|
{
|
|
3007
3057
|
className,
|
|
@@ -3012,7 +3062,7 @@ var require_web = __commonJS({
|
|
|
3012
3062
|
...props
|
|
3013
3063
|
}
|
|
3014
3064
|
),
|
|
3015
|
-
/* @__PURE__ */ (0,
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3016
3066
|
"div",
|
|
3017
3067
|
{
|
|
3018
3068
|
className,
|
|
@@ -3024,8 +3074,8 @@ var require_web = __commonJS({
|
|
|
3024
3074
|
}
|
|
3025
3075
|
__name(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
|
|
3026
3076
|
__name2(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
|
|
3027
|
-
var
|
|
3028
|
-
var
|
|
3077
|
+
var import_react28 = require("react");
|
|
3078
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3029
3079
|
function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
|
|
3030
3080
|
const { style: inStyle = {}, ...props } = inProps;
|
|
3031
3081
|
const style = {
|
|
@@ -3033,13 +3083,13 @@ var require_web = __commonJS({
|
|
|
3033
3083
|
transform: "none",
|
|
3034
3084
|
visibility: "hidden"
|
|
3035
3085
|
};
|
|
3036
|
-
var cssParserRef = (0,
|
|
3086
|
+
var cssParserRef = (0, import_react28.useRef)(null);
|
|
3037
3087
|
const ref = useHijackSpatialDivRef(
|
|
3038
3088
|
refIn,
|
|
3039
3089
|
cssParserRef
|
|
3040
3090
|
);
|
|
3041
|
-
const rootSpatialReactContextObject = (0,
|
|
3042
|
-
(0,
|
|
3091
|
+
const rootSpatialReactContextObject = (0, import_react28.useContext)(SpatialReactContext);
|
|
3092
|
+
(0, import_react28.useEffect)(() => {
|
|
3043
3093
|
const onSubEvent = /* @__PURE__ */ __name2((dom) => {
|
|
3044
3094
|
cssParserRef.current = dom;
|
|
3045
3095
|
}, "onSubEvent");
|
|
@@ -3048,15 +3098,15 @@ var require_web = __commonJS({
|
|
|
3048
3098
|
rootSpatialReactContextObject.offSubDivEvent(spatialId);
|
|
3049
3099
|
};
|
|
3050
3100
|
}, []);
|
|
3051
|
-
return /* @__PURE__ */ (0,
|
|
3101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Model3D, { style, ...props, ref, visible: true });
|
|
3052
3102
|
}
|
|
3053
3103
|
__name(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
|
|
3054
3104
|
__name2(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
|
|
3055
|
-
var
|
|
3056
|
-
var
|
|
3105
|
+
var import_react29 = require("react");
|
|
3106
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3057
3107
|
function renderCSSModel3DPortalInstance(spatialId, inProps) {
|
|
3058
3108
|
const { className, style = {}, ...props } = inProps;
|
|
3059
|
-
const rootSpatialReactContextObject = (0,
|
|
3109
|
+
const rootSpatialReactContextObject = (0, import_react29.useContext)(SpatialReactContext);
|
|
3060
3110
|
const { ref, spatialStyle, ready } = useSpatialStyle();
|
|
3061
3111
|
const spatialTransform = {
|
|
3062
3112
|
position: spatialStyle.position,
|
|
@@ -3064,7 +3114,7 @@ var require_web = __commonJS({
|
|
|
3064
3114
|
scale: spatialStyle.scale
|
|
3065
3115
|
};
|
|
3066
3116
|
const visible = spatialStyle.visible;
|
|
3067
|
-
(0,
|
|
3117
|
+
(0, import_react29.useEffect)(() => {
|
|
3068
3118
|
rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current);
|
|
3069
3119
|
}, [ref.current]);
|
|
3070
3120
|
const cssParserDomStyle = {
|
|
@@ -3076,8 +3126,8 @@ var require_web = __commonJS({
|
|
|
3076
3126
|
...style,
|
|
3077
3127
|
transform: "none"
|
|
3078
3128
|
};
|
|
3079
|
-
return /* @__PURE__ */ (0,
|
|
3080
|
-
ready && /* @__PURE__ */ (0,
|
|
3129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3130
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3081
3131
|
Model3D,
|
|
3082
3132
|
{
|
|
3083
3133
|
className,
|
|
@@ -3087,18 +3137,18 @@ var require_web = __commonJS({
|
|
|
3087
3137
|
...props
|
|
3088
3138
|
}
|
|
3089
3139
|
),
|
|
3090
|
-
/* @__PURE__ */ (0,
|
|
3140
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className, style: cssParserDomStyle, ref })
|
|
3091
3141
|
] });
|
|
3092
3142
|
}
|
|
3093
3143
|
__name(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
|
|
3094
3144
|
__name2(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
|
|
3095
3145
|
function CSSModel3DBase(props, refIn) {
|
|
3096
|
-
const rootSpatialReactContextObject = (0,
|
|
3146
|
+
const rootSpatialReactContextObject = (0, import_react30.useContext)(SpatialReactContext);
|
|
3097
3147
|
const isInSpatialDiv = !!rootSpatialReactContextObject;
|
|
3098
3148
|
if (isInSpatialDiv) {
|
|
3099
|
-
const layer = (0,
|
|
3100
|
-
const isInStandardInstance = !!(0,
|
|
3101
|
-
const spatialId = (0,
|
|
3149
|
+
const layer = (0, import_react30.useContext)(SpatialLayerContext) + 1;
|
|
3150
|
+
const isInStandardInstance = !!(0, import_react30.useContext)(SpatialIsStandardInstanceContext);
|
|
3151
|
+
const spatialId = (0, import_react30.useMemo)(() => {
|
|
3102
3152
|
return rootSpatialReactContextObject.getSubDivSpatialID(
|
|
3103
3153
|
layer,
|
|
3104
3154
|
isInStandardInstance,
|
|
@@ -3116,60 +3166,8 @@ var require_web = __commonJS({
|
|
|
3116
3166
|
}
|
|
3117
3167
|
__name(CSSModel3DBase, "CSSModel3DBase");
|
|
3118
3168
|
__name2(CSSModel3DBase, "CSSModel3DBase");
|
|
3119
|
-
var CSSModel3D = (0,
|
|
3169
|
+
var CSSModel3D = (0, import_react30.forwardRef)(CSSModel3DBase);
|
|
3120
3170
|
CSSModel3D.displayName = "CSSModel3D";
|
|
3121
|
-
var import_react30 = require("react");
|
|
3122
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3123
|
-
var runAsync = /* @__PURE__ */ __name2((fn) => {
|
|
3124
|
-
return fn();
|
|
3125
|
-
}, "runAsync");
|
|
3126
|
-
var SpatialViewEl = (0, import_react30.forwardRef)(
|
|
3127
|
-
(props, ref) => {
|
|
3128
|
-
const divRef = (0, import_react30.useRef)(null);
|
|
3129
|
-
const spatialEntity = (0, import_react30.useRef)(null);
|
|
3130
|
-
const activePromise = (0, import_react30.useRef)(null);
|
|
3131
|
-
(0, import_react30.useImperativeHandle)(ref, () => ({
|
|
3132
|
-
...divRef.current,
|
|
3133
|
-
getViewEntity: /* @__PURE__ */ __name2(async () => {
|
|
3134
|
-
if (activePromise.current) {
|
|
3135
|
-
await activePromise.current;
|
|
3136
|
-
}
|
|
3137
|
-
return spatialEntity.current;
|
|
3138
|
-
}, "getViewEntity")
|
|
3139
|
-
}));
|
|
3140
|
-
if (getSession3() == null) {
|
|
3141
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
|
|
3142
|
-
}
|
|
3143
|
-
(0, import_react30.useEffect)(() => {
|
|
3144
|
-
if (true) return;
|
|
3145
|
-
activePromise.current = runAsync(async () => {
|
|
3146
|
-
if (activePromise.current) {
|
|
3147
|
-
await activePromise.current;
|
|
3148
|
-
}
|
|
3149
|
-
let sh = new SpatialHelper(getSession3());
|
|
3150
|
-
let x = await sh.dom.attachSpatialView(divRef.current);
|
|
3151
|
-
spatialEntity.current = x.entity;
|
|
3152
|
-
if (props.onViewLoad) {
|
|
3153
|
-
props.onViewLoad(x.entity);
|
|
3154
|
-
}
|
|
3155
|
-
});
|
|
3156
|
-
return () => {
|
|
3157
|
-
if (true) return;
|
|
3158
|
-
runAsync(async () => {
|
|
3159
|
-
await activePromise.current;
|
|
3160
|
-
spatialEntity.current?.destroy();
|
|
3161
|
-
if (props.onViewUnload) {
|
|
3162
|
-
props.onViewUnload();
|
|
3163
|
-
}
|
|
3164
|
-
});
|
|
3165
|
-
};
|
|
3166
|
-
}, []);
|
|
3167
|
-
const { onViewLoad, onViewUnload, ...divProps } = props;
|
|
3168
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...divProps });
|
|
3169
|
-
}
|
|
3170
|
-
);
|
|
3171
|
-
var SpatialView = SpatialViewEl;
|
|
3172
|
-
var import_react31 = require("react");
|
|
3173
3171
|
var import_model_viewer = require("@google/model-viewer");
|
|
3174
3172
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3175
3173
|
function renderInModel3D(inProps, ref, modelUrl, placeHolder) {
|
|
@@ -3462,11 +3460,9 @@ var require_default = __commonJS({
|
|
|
3462
3460
|
var __toCommonJS2 = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
3463
3461
|
var src_exports = {};
|
|
3464
3462
|
__export2(src_exports, {
|
|
3465
|
-
CSSModel3D: /* @__PURE__ */ __name(() => CSSModel3D, "CSSModel3D"),
|
|
3466
3463
|
CSSSpatialDiv: /* @__PURE__ */ __name(() => CSSSpatialDiv, "CSSSpatialDiv"),
|
|
3467
3464
|
CSSSpatialPrimitive: /* @__PURE__ */ __name(() => CSSSpatialPrimitive, "CSSSpatialPrimitive"),
|
|
3468
3465
|
Model: /* @__PURE__ */ __name(() => Model, "Model"),
|
|
3469
|
-
Model3D: /* @__PURE__ */ __name(() => Model3D, "Model3D"),
|
|
3470
3466
|
SpatialDiv: /* @__PURE__ */ __name(() => SpatialDiv, "SpatialDiv"),
|
|
3471
3467
|
SpatialMonitor: /* @__PURE__ */ __name(() => SpatialMonitor, "SpatialMonitor"),
|
|
3472
3468
|
SpatialPrimitive: /* @__PURE__ */ __name(() => SpatialPrimitive, "SpatialPrimitive"),
|
|
@@ -5470,11 +5466,64 @@ var require_default = __commonJS({
|
|
|
5470
5466
|
});
|
|
5471
5467
|
}, "createSpatialPrimitive2"), "createSpatialPrimitive"))(CSSSpatialPrimitive);
|
|
5472
5468
|
var CSSSpatialDiv = CSSSpatialPrimitive.div;
|
|
5473
|
-
var
|
|
5469
|
+
var import_core_sdk2 = require("@webspatial/core-sdk");
|
|
5474
5470
|
var import_react21 = require("react");
|
|
5471
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
5472
|
+
var runAsync = /* @__PURE__ */ __name2((fn) => {
|
|
5473
|
+
return fn();
|
|
5474
|
+
}, "runAsync");
|
|
5475
|
+
var SpatialViewEl = (0, import_react21.forwardRef)(
|
|
5476
|
+
(props, ref) => {
|
|
5477
|
+
const divRef = (0, import_react21.useRef)(null);
|
|
5478
|
+
const spatialEntity = (0, import_react21.useRef)(null);
|
|
5479
|
+
const activePromise = (0, import_react21.useRef)(null);
|
|
5480
|
+
(0, import_react21.useImperativeHandle)(ref, () => ({
|
|
5481
|
+
...divRef.current,
|
|
5482
|
+
getViewEntity: /* @__PURE__ */ __name2(async () => {
|
|
5483
|
+
if (activePromise.current) {
|
|
5484
|
+
await activePromise.current;
|
|
5485
|
+
}
|
|
5486
|
+
return spatialEntity.current;
|
|
5487
|
+
}, "getViewEntity")
|
|
5488
|
+
}));
|
|
5489
|
+
if (getSession3() == null) {
|
|
5490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
|
|
5491
|
+
}
|
|
5492
|
+
(0, import_react21.useEffect)(() => {
|
|
5493
|
+
if (false) return;
|
|
5494
|
+
activePromise.current = runAsync(async () => {
|
|
5495
|
+
if (activePromise.current) {
|
|
5496
|
+
await activePromise.current;
|
|
5497
|
+
}
|
|
5498
|
+
let sh = new import_core_sdk2.SpatialHelper(getSession3());
|
|
5499
|
+
let x = await sh.dom.attachSpatialView(divRef.current);
|
|
5500
|
+
spatialEntity.current = x.entity;
|
|
5501
|
+
if (props.onViewLoad) {
|
|
5502
|
+
props.onViewLoad(x.entity);
|
|
5503
|
+
}
|
|
5504
|
+
});
|
|
5505
|
+
return () => {
|
|
5506
|
+
if (false) return;
|
|
5507
|
+
runAsync(async () => {
|
|
5508
|
+
await activePromise.current;
|
|
5509
|
+
spatialEntity.current?.destroy();
|
|
5510
|
+
if (props.onViewUnload) {
|
|
5511
|
+
props.onViewUnload();
|
|
5512
|
+
}
|
|
5513
|
+
});
|
|
5514
|
+
};
|
|
5515
|
+
}, []);
|
|
5516
|
+
const { onViewLoad, onViewUnload, ...divProps } = props;
|
|
5517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: divRef, ...divProps });
|
|
5518
|
+
}
|
|
5519
|
+
);
|
|
5520
|
+
var SpatialView = SpatialViewEl;
|
|
5521
|
+
var import_react31 = require("react");
|
|
5522
|
+
var import_react27 = require("react");
|
|
5523
|
+
var import_react22 = require("react");
|
|
5475
5524
|
function useDetectLayoutDomUpdated(onDomUpdated) {
|
|
5476
|
-
const ref = (0,
|
|
5477
|
-
(0,
|
|
5525
|
+
const ref = (0, import_react22.useRef)(null);
|
|
5526
|
+
(0, import_react22.useEffect)(() => {
|
|
5478
5527
|
if (!ref.current) {
|
|
5479
5528
|
console.warn("Ref is not attached to the DOM");
|
|
5480
5529
|
return;
|
|
@@ -5487,7 +5536,7 @@ var require_default = __commonJS({
|
|
|
5487
5536
|
ro.disconnect();
|
|
5488
5537
|
};
|
|
5489
5538
|
}, []);
|
|
5490
|
-
(0,
|
|
5539
|
+
(0, import_react22.useEffect)(() => {
|
|
5491
5540
|
if (!ref.current) {
|
|
5492
5541
|
console.warn("Ref is not attached to the DOM");
|
|
5493
5542
|
return;
|
|
@@ -5508,7 +5557,7 @@ var require_default = __commonJS({
|
|
|
5508
5557
|
}
|
|
5509
5558
|
__name(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
|
|
5510
5559
|
__name2(useDetectLayoutDomUpdated, "useDetectLayoutDomUpdated");
|
|
5511
|
-
var
|
|
5560
|
+
var import_react23 = require("react");
|
|
5512
5561
|
function PopulatePartialSpatialTransformType(spatialTransform = {}) {
|
|
5513
5562
|
const {
|
|
5514
5563
|
position = { x: 0, y: 0, z: 0 },
|
|
@@ -5735,12 +5784,12 @@ var require_default = __commonJS({
|
|
|
5735
5784
|
}
|
|
5736
5785
|
};
|
|
5737
5786
|
function useModel3DNative(modelUrl, parentEntity, eventHandlers = {}, onModel3DNativeReadyCb) {
|
|
5738
|
-
let model3DNativeRef = (0,
|
|
5739
|
-
const [phase, setPhase] = (0,
|
|
5787
|
+
let model3DNativeRef = (0, import_react23.useRef)(null);
|
|
5788
|
+
const [phase, setPhase] = (0, import_react23.useState)(
|
|
5740
5789
|
"loading"
|
|
5741
5790
|
);
|
|
5742
|
-
const [failureReason, setFailureReason] = (0,
|
|
5743
|
-
(0,
|
|
5791
|
+
const [failureReason, setFailureReason] = (0, import_react23.useState)("");
|
|
5792
|
+
(0, import_react23.useEffect)(() => {
|
|
5744
5793
|
let isDestroyed = false;
|
|
5745
5794
|
const model3DContainer = new Model3DNative(parentEntity);
|
|
5746
5795
|
model3DContainer.init(
|
|
@@ -5767,32 +5816,32 @@ var require_default = __commonJS({
|
|
|
5767
5816
|
setPhase("loading");
|
|
5768
5817
|
};
|
|
5769
5818
|
}, [modelUrl]);
|
|
5770
|
-
(0,
|
|
5819
|
+
(0, import_react23.useEffect)(() => {
|
|
5771
5820
|
if (model3DNativeRef.current) {
|
|
5772
5821
|
model3DNativeRef.current.onDragStart = eventHandlers.onDragStart;
|
|
5773
5822
|
}
|
|
5774
5823
|
}, [model3DNativeRef.current, eventHandlers.onDragStart]);
|
|
5775
|
-
(0,
|
|
5824
|
+
(0, import_react23.useEffect)(() => {
|
|
5776
5825
|
if (model3DNativeRef.current) {
|
|
5777
5826
|
model3DNativeRef.current.onDrag = eventHandlers.onDrag;
|
|
5778
5827
|
}
|
|
5779
5828
|
}, [model3DNativeRef.current, eventHandlers.onDrag]);
|
|
5780
|
-
(0,
|
|
5829
|
+
(0, import_react23.useEffect)(() => {
|
|
5781
5830
|
if (model3DNativeRef.current) {
|
|
5782
5831
|
model3DNativeRef.current.onDragEnd = eventHandlers.onDragEnd;
|
|
5783
5832
|
}
|
|
5784
5833
|
});
|
|
5785
|
-
(0,
|
|
5834
|
+
(0, import_react23.useEffect)(() => {
|
|
5786
5835
|
if (model3DNativeRef.current) {
|
|
5787
5836
|
model3DNativeRef.current.onTap = eventHandlers.onTap;
|
|
5788
5837
|
}
|
|
5789
5838
|
}, [model3DNativeRef.current, eventHandlers.onTap]);
|
|
5790
|
-
(0,
|
|
5839
|
+
(0, import_react23.useEffect)(() => {
|
|
5791
5840
|
if (model3DNativeRef.current) {
|
|
5792
5841
|
model3DNativeRef.current.onDoubleTap = eventHandlers.onDoubleTap;
|
|
5793
5842
|
}
|
|
5794
5843
|
}, [model3DNativeRef.current, eventHandlers.onDoubleTap]);
|
|
5795
|
-
(0,
|
|
5844
|
+
(0, import_react23.useEffect)(() => {
|
|
5796
5845
|
if (model3DNativeRef.current) {
|
|
5797
5846
|
model3DNativeRef.current.onLongPress = eventHandlers.onLongPress;
|
|
5798
5847
|
}
|
|
@@ -5801,8 +5850,8 @@ var require_default = __commonJS({
|
|
|
5801
5850
|
}
|
|
5802
5851
|
__name(useModel3DNative, "useModel3DNative");
|
|
5803
5852
|
__name2(useModel3DNative, "useModel3DNative");
|
|
5804
|
-
var
|
|
5805
|
-
var
|
|
5853
|
+
var import_react24 = require("react");
|
|
5854
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
5806
5855
|
function renderModel3DNotInSpatialDiv(props, refIn) {
|
|
5807
5856
|
const {
|
|
5808
5857
|
className,
|
|
@@ -5823,7 +5872,7 @@ var require_default = __commonJS({
|
|
|
5823
5872
|
onLongPress
|
|
5824
5873
|
} = props;
|
|
5825
5874
|
const theSpatialTransform = PopulatePartialSpatialTransformType(spatialTransform);
|
|
5826
|
-
const onDomUpdated = (0,
|
|
5875
|
+
const onDomUpdated = (0, import_react24.useCallback)(() => {
|
|
5827
5876
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
5828
5877
|
const model3DNative = model3DNativeRef.current;
|
|
5829
5878
|
model3DNative.updateByDom(layoutInstanceRef.current, {
|
|
@@ -5842,7 +5891,7 @@ var require_default = __commonJS({
|
|
|
5842
5891
|
theSpatialTransform.scale.y,
|
|
5843
5892
|
theSpatialTransform.scale.z
|
|
5844
5893
|
]);
|
|
5845
|
-
const onModel3DContainerReadyCb = (0,
|
|
5894
|
+
const onModel3DContainerReadyCb = (0, import_react24.useCallback)(() => {
|
|
5846
5895
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
5847
5896
|
model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
|
|
5848
5897
|
spatialTransform: theSpatialTransform
|
|
@@ -5860,7 +5909,7 @@ var require_default = __commonJS({
|
|
|
5860
5909
|
theSpatialTransform.scale.y,
|
|
5861
5910
|
theSpatialTransform.scale.z
|
|
5862
5911
|
]);
|
|
5863
|
-
const onDragStartCb = (0,
|
|
5912
|
+
const onDragStartCb = (0, import_react24.useCallback)(
|
|
5864
5913
|
(spatialDragEvent) => {
|
|
5865
5914
|
if (onDragStart) {
|
|
5866
5915
|
const dragEvent = {
|
|
@@ -5872,7 +5921,7 @@ var require_default = __commonJS({
|
|
|
5872
5921
|
},
|
|
5873
5922
|
[onDragStart]
|
|
5874
5923
|
);
|
|
5875
|
-
const onDragCb = (0,
|
|
5924
|
+
const onDragCb = (0, import_react24.useCallback)(
|
|
5876
5925
|
(spatialDragEvent) => {
|
|
5877
5926
|
if (onDrag) {
|
|
5878
5927
|
const dragEvent = {
|
|
@@ -5884,7 +5933,7 @@ var require_default = __commonJS({
|
|
|
5884
5933
|
},
|
|
5885
5934
|
[onDrag]
|
|
5886
5935
|
);
|
|
5887
|
-
const onDragEndCb = (0,
|
|
5936
|
+
const onDragEndCb = (0, import_react24.useCallback)(
|
|
5888
5937
|
(spatialDragEvent) => {
|
|
5889
5938
|
if (onDragEnd) {
|
|
5890
5939
|
const dragEvent = {
|
|
@@ -5896,7 +5945,7 @@ var require_default = __commonJS({
|
|
|
5896
5945
|
},
|
|
5897
5946
|
[onDragEnd]
|
|
5898
5947
|
);
|
|
5899
|
-
const onTapCb = (0,
|
|
5948
|
+
const onTapCb = (0, import_react24.useCallback)(() => {
|
|
5900
5949
|
if (onTap) {
|
|
5901
5950
|
const event = {
|
|
5902
5951
|
target: layoutInstanceRef.current
|
|
@@ -5904,7 +5953,7 @@ var require_default = __commonJS({
|
|
|
5904
5953
|
onTap(event);
|
|
5905
5954
|
}
|
|
5906
5955
|
}, [onTap]);
|
|
5907
|
-
const onDoubleTapCb = (0,
|
|
5956
|
+
const onDoubleTapCb = (0, import_react24.useCallback)(() => {
|
|
5908
5957
|
if (onDoubleTap) {
|
|
5909
5958
|
const event = {
|
|
5910
5959
|
target: layoutInstanceRef.current
|
|
@@ -5912,7 +5961,7 @@ var require_default = __commonJS({
|
|
|
5912
5961
|
onDoubleTap(event);
|
|
5913
5962
|
}
|
|
5914
5963
|
}, [onDoubleTap]);
|
|
5915
|
-
const onLongPressCb = (0,
|
|
5964
|
+
const onLongPressCb = (0, import_react24.useCallback)(() => {
|
|
5916
5965
|
if (onLongPress) {
|
|
5917
5966
|
const event = {
|
|
5918
5967
|
target: layoutInstanceRef.current
|
|
@@ -5934,7 +5983,7 @@ var require_default = __commonJS({
|
|
|
5934
5983
|
},
|
|
5935
5984
|
onModel3DContainerReadyCb
|
|
5936
5985
|
);
|
|
5937
|
-
const onSuccess = (0,
|
|
5986
|
+
const onSuccess = (0, import_react24.useCallback)(() => {
|
|
5938
5987
|
;
|
|
5939
5988
|
layoutInstanceRef.current.ready = true;
|
|
5940
5989
|
if (onLoad) {
|
|
@@ -5943,7 +5992,7 @@ var require_default = __commonJS({
|
|
|
5943
5992
|
});
|
|
5944
5993
|
}
|
|
5945
5994
|
}, [onLoad]);
|
|
5946
|
-
const onFailure = (0,
|
|
5995
|
+
const onFailure = (0, import_react24.useCallback)(
|
|
5947
5996
|
(_) => {
|
|
5948
5997
|
const modelElement = layoutInstanceRef.current;
|
|
5949
5998
|
modelElement.ready = false;
|
|
@@ -5955,19 +6004,19 @@ var require_default = __commonJS({
|
|
|
5955
6004
|
},
|
|
5956
6005
|
[onLoad]
|
|
5957
6006
|
);
|
|
5958
|
-
(0,
|
|
6007
|
+
(0, import_react24.useEffect)(() => {
|
|
5959
6008
|
if (phase === "failure") {
|
|
5960
6009
|
onFailure(failureReason);
|
|
5961
6010
|
} else if (phase === "success") {
|
|
5962
6011
|
onSuccess();
|
|
5963
6012
|
}
|
|
5964
6013
|
}, [phase]);
|
|
5965
|
-
(0,
|
|
6014
|
+
(0, import_react24.useEffect)(() => {
|
|
5966
6015
|
if (model3DNativeRef.current) {
|
|
5967
6016
|
model3DNativeRef.current.setVisible(visible);
|
|
5968
6017
|
}
|
|
5969
6018
|
}, [model3DNativeRef.current, visible]);
|
|
5970
|
-
(0,
|
|
6019
|
+
(0, import_react24.useEffect)(() => {
|
|
5971
6020
|
if (model3DNativeRef.current && layoutInstanceRef.current) {
|
|
5972
6021
|
model3DNativeRef.current.updateByDom(layoutInstanceRef.current, {
|
|
5973
6022
|
spatialTransform: theSpatialTransform
|
|
@@ -5985,17 +6034,17 @@ var require_default = __commonJS({
|
|
|
5985
6034
|
theSpatialTransform.scale.y,
|
|
5986
6035
|
theSpatialTransform.scale.z
|
|
5987
6036
|
]);
|
|
5988
|
-
(0,
|
|
6037
|
+
(0, import_react24.useEffect)(() => {
|
|
5989
6038
|
if (model3DNativeRef.current) {
|
|
5990
6039
|
model3DNativeRef.current.setContentMode(contentMode);
|
|
5991
6040
|
}
|
|
5992
6041
|
}, [model3DNativeRef.current, contentMode]);
|
|
5993
|
-
(0,
|
|
6042
|
+
(0, import_react24.useEffect)(() => {
|
|
5994
6043
|
if (model3DNativeRef.current) {
|
|
5995
6044
|
model3DNativeRef.current.setResizable(resizable);
|
|
5996
6045
|
}
|
|
5997
6046
|
}, [model3DNativeRef.current, resizable]);
|
|
5998
|
-
(0,
|
|
6047
|
+
(0, import_react24.useEffect)(() => {
|
|
5999
6048
|
if (model3DNativeRef.current) {
|
|
6000
6049
|
model3DNativeRef.current.setAspectRatio(aspectRatio);
|
|
6001
6050
|
}
|
|
@@ -6005,7 +6054,7 @@ var require_default = __commonJS({
|
|
|
6005
6054
|
visibility: phase === "failure" ? "visible" : "hidden",
|
|
6006
6055
|
transform: ""
|
|
6007
6056
|
};
|
|
6008
|
-
const proxyRef = (0,
|
|
6057
|
+
const proxyRef = (0, import_react24.useMemo)(
|
|
6009
6058
|
() => new Proxy(layoutInstanceRef, {
|
|
6010
6059
|
get(target, prop, receiver) {
|
|
6011
6060
|
return Reflect.get(target, prop, receiver);
|
|
@@ -6030,7 +6079,7 @@ var require_default = __commonJS({
|
|
|
6030
6079
|
}),
|
|
6031
6080
|
[layoutInstanceRef, refIn]
|
|
6032
6081
|
);
|
|
6033
|
-
(0,
|
|
6082
|
+
(0, import_react24.useEffect)(() => {
|
|
6034
6083
|
return () => {
|
|
6035
6084
|
if (layoutInstanceRef.current) {
|
|
6036
6085
|
const modelElement = layoutInstanceRef.current;
|
|
@@ -6039,17 +6088,17 @@ var require_default = __commonJS({
|
|
|
6039
6088
|
}
|
|
6040
6089
|
};
|
|
6041
6090
|
}, [modelUrl]);
|
|
6042
|
-
return /* @__PURE__ */ (0,
|
|
6091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style: layoutDomStyle, ref: proxyRef, children: phase === "failure" && children });
|
|
6043
6092
|
}
|
|
6044
6093
|
__name(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
|
|
6045
6094
|
__name2(renderModel3DNotInSpatialDiv, "renderModel3DNotInSpatialDiv");
|
|
6046
|
-
var
|
|
6095
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
6047
6096
|
function renderModel3DStandardInstance(spatialId, props, refIn) {
|
|
6048
6097
|
const { className, style } = props;
|
|
6049
6098
|
const extraProps = {
|
|
6050
6099
|
[SpatialID]: spatialId
|
|
6051
6100
|
};
|
|
6052
|
-
return /* @__PURE__ */ (0,
|
|
6101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6053
6102
|
"div",
|
|
6054
6103
|
{
|
|
6055
6104
|
"data-model3d-spatialid": spatialId,
|
|
@@ -6062,26 +6111,26 @@ var require_default = __commonJS({
|
|
|
6062
6111
|
}
|
|
6063
6112
|
__name(renderModel3DStandardInstance, "renderModel3DStandardInstance");
|
|
6064
6113
|
__name2(renderModel3DStandardInstance, "renderModel3DStandardInstance");
|
|
6114
|
+
var import_react26 = require("react");
|
|
6065
6115
|
var import_react25 = require("react");
|
|
6066
|
-
var import_react24 = require("react");
|
|
6067
6116
|
function useSyncDomInfoFromStandardInstance(spatialId) {
|
|
6068
|
-
const [domRect, setDomRect] = (0,
|
|
6117
|
+
const [domRect, setDomRect] = (0, import_react25.useState)({
|
|
6069
6118
|
x: 0,
|
|
6070
6119
|
y: 0,
|
|
6071
6120
|
width: 0,
|
|
6072
6121
|
height: 0
|
|
6073
6122
|
});
|
|
6074
|
-
const inheritedPortalStyleRef = (0,
|
|
6075
|
-
const anchorRef = (0,
|
|
6123
|
+
const inheritedPortalStyleRef = (0, import_react25.useRef)({});
|
|
6124
|
+
const anchorRef = (0, import_react25.useRef)({
|
|
6076
6125
|
x: 0.5,
|
|
6077
6126
|
y: 0.5,
|
|
6078
6127
|
z: 0.5
|
|
6079
6128
|
});
|
|
6080
|
-
const opacityRef = (0,
|
|
6081
|
-
const spatialReactContextObject = (0,
|
|
6082
|
-
const inheritedPortalClassNameRef = (0,
|
|
6083
|
-
const modelRef = (0,
|
|
6084
|
-
(0,
|
|
6129
|
+
const opacityRef = (0, import_react25.useRef)(1);
|
|
6130
|
+
const spatialReactContextObject = (0, import_react25.useContext)(SpatialReactContext);
|
|
6131
|
+
const inheritedPortalClassNameRef = (0, import_react25.useRef)("");
|
|
6132
|
+
const modelRef = (0, import_react25.useRef)(null);
|
|
6133
|
+
(0, import_react25.useEffect)(() => {
|
|
6085
6134
|
const syncDomRect = /* @__PURE__ */ __name2(() => {
|
|
6086
6135
|
const dom = spatialReactContextObject?.querySpatialDom(spatialId);
|
|
6087
6136
|
if (!dom) {
|
|
@@ -6122,7 +6171,7 @@ var require_default = __commonJS({
|
|
|
6122
6171
|
}
|
|
6123
6172
|
__name(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
|
|
6124
6173
|
__name2(useSyncDomInfoFromStandardInstance, "useSyncDomInfoFromStandardInstance");
|
|
6125
|
-
var
|
|
6174
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
6126
6175
|
function useModelEvents(props, modelRef) {
|
|
6127
6176
|
const {
|
|
6128
6177
|
onDragStart,
|
|
@@ -6132,7 +6181,7 @@ var require_default = __commonJS({
|
|
|
6132
6181
|
onDoubleTap,
|
|
6133
6182
|
onLongPress
|
|
6134
6183
|
} = props;
|
|
6135
|
-
const onDragStartCb = (0,
|
|
6184
|
+
const onDragStartCb = (0, import_react26.useCallback)(
|
|
6136
6185
|
(spatialDragEvent) => {
|
|
6137
6186
|
if (onDragStart) {
|
|
6138
6187
|
const dragEvent = {
|
|
@@ -6144,7 +6193,7 @@ var require_default = __commonJS({
|
|
|
6144
6193
|
},
|
|
6145
6194
|
[onDragStart]
|
|
6146
6195
|
);
|
|
6147
|
-
const onDragCb = (0,
|
|
6196
|
+
const onDragCb = (0, import_react26.useCallback)(
|
|
6148
6197
|
(spatialDragEvent) => {
|
|
6149
6198
|
if (onDrag) {
|
|
6150
6199
|
const dragEvent = {
|
|
@@ -6156,7 +6205,7 @@ var require_default = __commonJS({
|
|
|
6156
6205
|
},
|
|
6157
6206
|
[onDrag]
|
|
6158
6207
|
);
|
|
6159
|
-
const onDragEndCb = (0,
|
|
6208
|
+
const onDragEndCb = (0, import_react26.useCallback)(
|
|
6160
6209
|
(spatialDragEvent) => {
|
|
6161
6210
|
if (onDragEnd) {
|
|
6162
6211
|
const dragEvent = {
|
|
@@ -6168,7 +6217,7 @@ var require_default = __commonJS({
|
|
|
6168
6217
|
},
|
|
6169
6218
|
[onDragEnd]
|
|
6170
6219
|
);
|
|
6171
|
-
const onTapCb = (0,
|
|
6220
|
+
const onTapCb = (0, import_react26.useCallback)(() => {
|
|
6172
6221
|
if (onTap) {
|
|
6173
6222
|
const event = {
|
|
6174
6223
|
target: modelRef.current
|
|
@@ -6176,7 +6225,7 @@ var require_default = __commonJS({
|
|
|
6176
6225
|
onTap(event);
|
|
6177
6226
|
}
|
|
6178
6227
|
}, [onTap]);
|
|
6179
|
-
const onDoubleTapCb = (0,
|
|
6228
|
+
const onDoubleTapCb = (0, import_react26.useCallback)(() => {
|
|
6180
6229
|
if (onDoubleTap) {
|
|
6181
6230
|
const event = {
|
|
6182
6231
|
target: modelRef.current
|
|
@@ -6184,7 +6233,7 @@ var require_default = __commonJS({
|
|
|
6184
6233
|
onDoubleTap(event);
|
|
6185
6234
|
}
|
|
6186
6235
|
}, [onDoubleTap]);
|
|
6187
|
-
const onLongPressCb = (0,
|
|
6236
|
+
const onLongPressCb = (0, import_react26.useCallback)(() => {
|
|
6188
6237
|
if (onLongPress) {
|
|
6189
6238
|
const event = {
|
|
6190
6239
|
target: modelRef.current
|
|
@@ -6215,7 +6264,7 @@ var require_default = __commonJS({
|
|
|
6215
6264
|
onLoad,
|
|
6216
6265
|
children
|
|
6217
6266
|
} = props;
|
|
6218
|
-
const theSpatialTransform = (0,
|
|
6267
|
+
const theSpatialTransform = (0, import_react26.useMemo)(() => {
|
|
6219
6268
|
return PopulatePartialSpatialTransformType(spatialTransform);
|
|
6220
6269
|
}, [spatialTransform]);
|
|
6221
6270
|
const {
|
|
@@ -6226,7 +6275,7 @@ var require_default = __commonJS({
|
|
|
6226
6275
|
opacity,
|
|
6227
6276
|
className
|
|
6228
6277
|
} = useSyncDomInfoFromStandardInstance(spatialId);
|
|
6229
|
-
const parentSpatialWindowManager = (0,
|
|
6278
|
+
const parentSpatialWindowManager = (0, import_react26.useContext)(SpatialWindowManagerContext);
|
|
6230
6279
|
const eventHandlers = useModelEvents(
|
|
6231
6280
|
props,
|
|
6232
6281
|
modelRef
|
|
@@ -6236,7 +6285,7 @@ var require_default = __commonJS({
|
|
|
6236
6285
|
parentSpatialWindowManager.entity,
|
|
6237
6286
|
eventHandlers
|
|
6238
6287
|
);
|
|
6239
|
-
(0,
|
|
6288
|
+
(0, import_react26.useEffect)(() => {
|
|
6240
6289
|
if (model3DNativeRef.current) {
|
|
6241
6290
|
model3DNativeRef.current.updateRectAndTransform(
|
|
6242
6291
|
domRect,
|
|
@@ -6244,37 +6293,37 @@ var require_default = __commonJS({
|
|
|
6244
6293
|
);
|
|
6245
6294
|
}
|
|
6246
6295
|
}, [model3DNativeRef.current, domRect, theSpatialTransform]);
|
|
6247
|
-
(0,
|
|
6296
|
+
(0, import_react26.useEffect)(() => {
|
|
6248
6297
|
if (model3DNativeRef.current) {
|
|
6249
6298
|
model3DNativeRef.current.setRotationAnchor(anchor);
|
|
6250
6299
|
}
|
|
6251
6300
|
}, [model3DNativeRef.current, anchor]);
|
|
6252
|
-
(0,
|
|
6301
|
+
(0, import_react26.useEffect)(() => {
|
|
6253
6302
|
if (model3DNativeRef.current) {
|
|
6254
6303
|
model3DNativeRef.current.setVisible(visible);
|
|
6255
6304
|
}
|
|
6256
6305
|
}, [model3DNativeRef.current, visible]);
|
|
6257
|
-
(0,
|
|
6306
|
+
(0, import_react26.useEffect)(() => {
|
|
6258
6307
|
if (model3DNativeRef.current) {
|
|
6259
6308
|
model3DNativeRef.current.setContentMode(contentMode);
|
|
6260
6309
|
}
|
|
6261
6310
|
}, [model3DNativeRef.current, contentMode]);
|
|
6262
|
-
(0,
|
|
6311
|
+
(0, import_react26.useEffect)(() => {
|
|
6263
6312
|
if (model3DNativeRef.current) {
|
|
6264
6313
|
model3DNativeRef.current.setResizable(resizable);
|
|
6265
6314
|
}
|
|
6266
6315
|
}, [model3DNativeRef.current, resizable]);
|
|
6267
|
-
(0,
|
|
6316
|
+
(0, import_react26.useEffect)(() => {
|
|
6268
6317
|
if (model3DNativeRef.current) {
|
|
6269
6318
|
model3DNativeRef.current.setAspectRatio(aspectRatio);
|
|
6270
6319
|
}
|
|
6271
6320
|
}, [model3DNativeRef.current, aspectRatio]);
|
|
6272
|
-
(0,
|
|
6321
|
+
(0, import_react26.useEffect)(() => {
|
|
6273
6322
|
if (model3DNativeRef.current) {
|
|
6274
6323
|
model3DNativeRef.current.setOpacity(opacity);
|
|
6275
6324
|
}
|
|
6276
6325
|
}, [model3DNativeRef.current, opacity]);
|
|
6277
|
-
const onSuccess = (0,
|
|
6326
|
+
const onSuccess = (0, import_react26.useCallback)(() => {
|
|
6278
6327
|
;
|
|
6279
6328
|
modelRef.current.ready = true;
|
|
6280
6329
|
if (onLoad) {
|
|
@@ -6283,7 +6332,7 @@ var require_default = __commonJS({
|
|
|
6283
6332
|
});
|
|
6284
6333
|
}
|
|
6285
6334
|
}, [onLoad]);
|
|
6286
|
-
const onFailure = (0,
|
|
6335
|
+
const onFailure = (0, import_react26.useCallback)(
|
|
6287
6336
|
(_2) => {
|
|
6288
6337
|
const modelElement = modelRef.current;
|
|
6289
6338
|
modelElement.ready = false;
|
|
@@ -6295,14 +6344,14 @@ var require_default = __commonJS({
|
|
|
6295
6344
|
},
|
|
6296
6345
|
[onLoad]
|
|
6297
6346
|
);
|
|
6298
|
-
(0,
|
|
6347
|
+
(0, import_react26.useEffect)(() => {
|
|
6299
6348
|
if (phase === "failure") {
|
|
6300
6349
|
onFailure(failureReason);
|
|
6301
6350
|
} else if (phase === "success") {
|
|
6302
6351
|
onSuccess();
|
|
6303
6352
|
}
|
|
6304
6353
|
}, [phase]);
|
|
6305
|
-
(0,
|
|
6354
|
+
(0, import_react26.useEffect)(() => {
|
|
6306
6355
|
return () => {
|
|
6307
6356
|
const modelElement = modelRef.current;
|
|
6308
6357
|
if (modelElement) {
|
|
@@ -6313,7 +6362,7 @@ var require_default = __commonJS({
|
|
|
6313
6362
|
}, [modelUrl]);
|
|
6314
6363
|
const needRenderPlaceHolder = inheritedPortalStyle.position !== "absolute";
|
|
6315
6364
|
if (!needRenderPlaceHolder && phase !== "failure") {
|
|
6316
|
-
return /* @__PURE__ */ (0,
|
|
6365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, {});
|
|
6317
6366
|
} else {
|
|
6318
6367
|
const extraStyle = {
|
|
6319
6368
|
visibility: "visible",
|
|
@@ -6333,7 +6382,7 @@ var require_default = __commonJS({
|
|
|
6333
6382
|
...inheritedPortalStyle,
|
|
6334
6383
|
...extraStyle
|
|
6335
6384
|
};
|
|
6336
|
-
return /* @__PURE__ */ (0,
|
|
6385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6337
6386
|
"div",
|
|
6338
6387
|
{
|
|
6339
6388
|
"data-model3d-spatialid": spatialId,
|
|
@@ -6347,12 +6396,12 @@ var require_default = __commonJS({
|
|
|
6347
6396
|
__name(renderModel3DPortalInstance, "renderModel3DPortalInstance");
|
|
6348
6397
|
__name2(renderModel3DPortalInstance, "renderModel3DPortalInstance");
|
|
6349
6398
|
function Model3DBase(props, refIn) {
|
|
6350
|
-
const parentSpatialReactContextObject = (0,
|
|
6399
|
+
const parentSpatialReactContextObject = (0, import_react27.useContext)(SpatialReactContext);
|
|
6351
6400
|
const isInSpatialDiv = !!parentSpatialReactContextObject;
|
|
6352
6401
|
if (isInSpatialDiv) {
|
|
6353
|
-
const layer = (0,
|
|
6354
|
-
const isInStandardInstance = !!(0,
|
|
6355
|
-
const spatialId = (0,
|
|
6402
|
+
const layer = (0, import_react27.useContext)(SpatialLayerContext) + 1;
|
|
6403
|
+
const isInStandardInstance = !!(0, import_react27.useContext)(SpatialIsStandardInstanceContext);
|
|
6404
|
+
const spatialId = (0, import_react27.useMemo)(() => {
|
|
6356
6405
|
return parentSpatialReactContextObject.getSpatialID(
|
|
6357
6406
|
layer,
|
|
6358
6407
|
isInStandardInstance,
|
|
@@ -6370,10 +6419,10 @@ var require_default = __commonJS({
|
|
|
6370
6419
|
}
|
|
6371
6420
|
__name(Model3DBase, "Model3DBase");
|
|
6372
6421
|
__name2(Model3DBase, "Model3DBase");
|
|
6373
|
-
var Model3D = (0,
|
|
6422
|
+
var Model3D = (0, import_react27.forwardRef)(Model3DBase);
|
|
6374
6423
|
Model3D.displayName = "Model3D";
|
|
6375
|
-
var
|
|
6376
|
-
var
|
|
6424
|
+
var import_react30 = require("react");
|
|
6425
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
6377
6426
|
function renderCSSModel3DNotInSpatialDiv(inProps, refIn) {
|
|
6378
6427
|
const { className, style = {}, ...props } = inProps;
|
|
6379
6428
|
const cssParserDomStyle = {
|
|
@@ -6396,8 +6445,8 @@ var require_default = __commonJS({
|
|
|
6396
6445
|
...style,
|
|
6397
6446
|
transform: "none"
|
|
6398
6447
|
};
|
|
6399
|
-
return /* @__PURE__ */ (0,
|
|
6400
|
-
ready && /* @__PURE__ */ (0,
|
|
6448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
6449
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6401
6450
|
Model3D,
|
|
6402
6451
|
{
|
|
6403
6452
|
className,
|
|
@@ -6408,7 +6457,7 @@ var require_default = __commonJS({
|
|
|
6408
6457
|
...props
|
|
6409
6458
|
}
|
|
6410
6459
|
),
|
|
6411
|
-
/* @__PURE__ */ (0,
|
|
6460
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
6412
6461
|
"div",
|
|
6413
6462
|
{
|
|
6414
6463
|
className,
|
|
@@ -6420,8 +6469,8 @@ var require_default = __commonJS({
|
|
|
6420
6469
|
}
|
|
6421
6470
|
__name(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
|
|
6422
6471
|
__name2(renderCSSModel3DNotInSpatialDiv, "renderCSSModel3DNotInSpatialDiv");
|
|
6423
|
-
var
|
|
6424
|
-
var
|
|
6472
|
+
var import_react28 = require("react");
|
|
6473
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
6425
6474
|
function renderCSSModel3DStandardInstance(spatialId, inProps, refIn) {
|
|
6426
6475
|
const { style: inStyle = {}, ...props } = inProps;
|
|
6427
6476
|
const style = {
|
|
@@ -6429,13 +6478,13 @@ var require_default = __commonJS({
|
|
|
6429
6478
|
transform: "none",
|
|
6430
6479
|
visibility: "hidden"
|
|
6431
6480
|
};
|
|
6432
|
-
var cssParserRef = (0,
|
|
6481
|
+
var cssParserRef = (0, import_react28.useRef)(null);
|
|
6433
6482
|
const ref = useHijackSpatialDivRef(
|
|
6434
6483
|
refIn,
|
|
6435
6484
|
cssParserRef
|
|
6436
6485
|
);
|
|
6437
|
-
const rootSpatialReactContextObject = (0,
|
|
6438
|
-
(0,
|
|
6486
|
+
const rootSpatialReactContextObject = (0, import_react28.useContext)(SpatialReactContext);
|
|
6487
|
+
(0, import_react28.useEffect)(() => {
|
|
6439
6488
|
const onSubEvent = /* @__PURE__ */ __name2((dom) => {
|
|
6440
6489
|
cssParserRef.current = dom;
|
|
6441
6490
|
}, "onSubEvent");
|
|
@@ -6444,15 +6493,15 @@ var require_default = __commonJS({
|
|
|
6444
6493
|
rootSpatialReactContextObject.offSubDivEvent(spatialId);
|
|
6445
6494
|
};
|
|
6446
6495
|
}, []);
|
|
6447
|
-
return /* @__PURE__ */ (0,
|
|
6496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Model3D, { style, ...props, ref, visible: true });
|
|
6448
6497
|
}
|
|
6449
6498
|
__name(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
|
|
6450
6499
|
__name2(renderCSSModel3DStandardInstance, "renderCSSModel3DStandardInstance");
|
|
6451
|
-
var
|
|
6452
|
-
var
|
|
6500
|
+
var import_react29 = require("react");
|
|
6501
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
6453
6502
|
function renderCSSModel3DPortalInstance(spatialId, inProps) {
|
|
6454
6503
|
const { className, style = {}, ...props } = inProps;
|
|
6455
|
-
const rootSpatialReactContextObject = (0,
|
|
6504
|
+
const rootSpatialReactContextObject = (0, import_react29.useContext)(SpatialReactContext);
|
|
6456
6505
|
const { ref, spatialStyle, ready } = useSpatialStyle();
|
|
6457
6506
|
const spatialTransform = {
|
|
6458
6507
|
position: spatialStyle.position,
|
|
@@ -6460,7 +6509,7 @@ var require_default = __commonJS({
|
|
|
6460
6509
|
scale: spatialStyle.scale
|
|
6461
6510
|
};
|
|
6462
6511
|
const visible = spatialStyle.visible;
|
|
6463
|
-
(0,
|
|
6512
|
+
(0, import_react29.useEffect)(() => {
|
|
6464
6513
|
rootSpatialReactContextObject.notifySubDivEvent(spatialId, ref.current);
|
|
6465
6514
|
}, [ref.current]);
|
|
6466
6515
|
const cssParserDomStyle = {
|
|
@@ -6472,8 +6521,8 @@ var require_default = __commonJS({
|
|
|
6472
6521
|
...style,
|
|
6473
6522
|
transform: "none"
|
|
6474
6523
|
};
|
|
6475
|
-
return /* @__PURE__ */ (0,
|
|
6476
|
-
ready && /* @__PURE__ */ (0,
|
|
6524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
6525
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
6477
6526
|
Model3D,
|
|
6478
6527
|
{
|
|
6479
6528
|
className,
|
|
@@ -6483,18 +6532,18 @@ var require_default = __commonJS({
|
|
|
6483
6532
|
...props
|
|
6484
6533
|
}
|
|
6485
6534
|
),
|
|
6486
|
-
/* @__PURE__ */ (0,
|
|
6535
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className, style: cssParserDomStyle, ref })
|
|
6487
6536
|
] });
|
|
6488
6537
|
}
|
|
6489
6538
|
__name(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
|
|
6490
6539
|
__name2(renderCSSModel3DPortalInstance, "renderCSSModel3DPortalInstance");
|
|
6491
6540
|
function CSSModel3DBase(props, refIn) {
|
|
6492
|
-
const rootSpatialReactContextObject = (0,
|
|
6541
|
+
const rootSpatialReactContextObject = (0, import_react30.useContext)(SpatialReactContext);
|
|
6493
6542
|
const isInSpatialDiv = !!rootSpatialReactContextObject;
|
|
6494
6543
|
if (isInSpatialDiv) {
|
|
6495
|
-
const layer = (0,
|
|
6496
|
-
const isInStandardInstance = !!(0,
|
|
6497
|
-
const spatialId = (0,
|
|
6544
|
+
const layer = (0, import_react30.useContext)(SpatialLayerContext) + 1;
|
|
6545
|
+
const isInStandardInstance = !!(0, import_react30.useContext)(SpatialIsStandardInstanceContext);
|
|
6546
|
+
const spatialId = (0, import_react30.useMemo)(() => {
|
|
6498
6547
|
return rootSpatialReactContextObject.getSubDivSpatialID(
|
|
6499
6548
|
layer,
|
|
6500
6549
|
isInStandardInstance,
|
|
@@ -6512,61 +6561,8 @@ var require_default = __commonJS({
|
|
|
6512
6561
|
}
|
|
6513
6562
|
__name(CSSModel3DBase, "CSSModel3DBase");
|
|
6514
6563
|
__name2(CSSModel3DBase, "CSSModel3DBase");
|
|
6515
|
-
var CSSModel3D = (0,
|
|
6564
|
+
var CSSModel3D = (0, import_react30.forwardRef)(CSSModel3DBase);
|
|
6516
6565
|
CSSModel3D.displayName = "CSSModel3D";
|
|
6517
|
-
var import_core_sdk2 = require("@webspatial/core-sdk");
|
|
6518
|
-
var import_react30 = require("react");
|
|
6519
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
6520
|
-
var runAsync = /* @__PURE__ */ __name2((fn) => {
|
|
6521
|
-
return fn();
|
|
6522
|
-
}, "runAsync");
|
|
6523
|
-
var SpatialViewEl = (0, import_react30.forwardRef)(
|
|
6524
|
-
(props, ref) => {
|
|
6525
|
-
const divRef = (0, import_react30.useRef)(null);
|
|
6526
|
-
const spatialEntity = (0, import_react30.useRef)(null);
|
|
6527
|
-
const activePromise = (0, import_react30.useRef)(null);
|
|
6528
|
-
(0, import_react30.useImperativeHandle)(ref, () => ({
|
|
6529
|
-
...divRef.current,
|
|
6530
|
-
getViewEntity: /* @__PURE__ */ __name2(async () => {
|
|
6531
|
-
if (activePromise.current) {
|
|
6532
|
-
await activePromise.current;
|
|
6533
|
-
}
|
|
6534
|
-
return spatialEntity.current;
|
|
6535
|
-
}, "getViewEntity")
|
|
6536
|
-
}));
|
|
6537
|
-
if (getSession3() == null) {
|
|
6538
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...props, children: "WebSpatial is not supported in this browser" });
|
|
6539
|
-
}
|
|
6540
|
-
(0, import_react30.useEffect)(() => {
|
|
6541
|
-
if (false) return;
|
|
6542
|
-
activePromise.current = runAsync(async () => {
|
|
6543
|
-
if (activePromise.current) {
|
|
6544
|
-
await activePromise.current;
|
|
6545
|
-
}
|
|
6546
|
-
let sh = new import_core_sdk2.SpatialHelper(getSession3());
|
|
6547
|
-
let x = await sh.dom.attachSpatialView(divRef.current);
|
|
6548
|
-
spatialEntity.current = x.entity;
|
|
6549
|
-
if (props.onViewLoad) {
|
|
6550
|
-
props.onViewLoad(x.entity);
|
|
6551
|
-
}
|
|
6552
|
-
});
|
|
6553
|
-
return () => {
|
|
6554
|
-
if (false) return;
|
|
6555
|
-
runAsync(async () => {
|
|
6556
|
-
await activePromise.current;
|
|
6557
|
-
spatialEntity.current?.destroy();
|
|
6558
|
-
if (props.onViewUnload) {
|
|
6559
|
-
props.onViewUnload();
|
|
6560
|
-
}
|
|
6561
|
-
});
|
|
6562
|
-
};
|
|
6563
|
-
}, []);
|
|
6564
|
-
const { onViewLoad, onViewUnload, ...divProps } = props;
|
|
6565
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: divRef, ...divProps });
|
|
6566
|
-
}
|
|
6567
|
-
);
|
|
6568
|
-
var SpatialView = SpatialViewEl;
|
|
6569
|
-
var import_react31 = require("react");
|
|
6570
6566
|
var import_model_viewer = require("@google/model-viewer");
|
|
6571
6567
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
6572
6568
|
function renderInModel3D(inProps, ref, modelUrl, placeHolder) {
|