@reearth/core 0.0.7-alpha.70 → 0.0.7-alpha.71
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/core.js +261 -248
- package/dist/core.umd.cjs +2 -2
- package/package.json +1 -1
- package/src/engines/Cesium/core/Globe/index.tsx +26 -2
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type Globe as CesiumGlobeType } from "cesium";
|
|
1
2
|
import { useEffect, useMemo, useRef, type JSX } from "react";
|
|
2
|
-
import { Globe as CesiumGlobe } from "resium";
|
|
3
|
+
import { Globe as CesiumGlobe, type CesiumComponentRef } from "resium";
|
|
3
4
|
|
|
4
5
|
import type { ViewerProperty } from "../../..";
|
|
5
6
|
import { toColor } from "../../common";
|
|
@@ -31,8 +32,30 @@ export default function Globe({
|
|
|
31
32
|
[property?.globe?.baseColor],
|
|
32
33
|
);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// Direct ref to the underlying Cesium Globe object.
|
|
36
|
+
// Resium's Globe.update() is skipped on initial mount when C.current=false
|
|
37
|
+
// (a Resium timing issue). This effect guarantees globe.terrainProvider is
|
|
38
|
+
// always applied once the Promise resolves, regardless of prop-change timing.
|
|
39
|
+
const cesiumGlobeRef = useRef<CesiumComponentRef<CesiumGlobeType>>(null);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
let cancelled = false;
|
|
42
|
+
providerPromise
|
|
43
|
+
.then(resolvedProvider => {
|
|
44
|
+
if (cancelled) return;
|
|
45
|
+
const cesiumGlobe = cesiumGlobeRef.current?.cesiumElement;
|
|
46
|
+
if (cesiumGlobe) {
|
|
47
|
+
cesiumGlobe.terrainProvider = resolvedProvider;
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
.catch(() => {
|
|
51
|
+
// provider errors are handled by the existing useEffect below
|
|
52
|
+
});
|
|
53
|
+
return () => {
|
|
54
|
+
cancelled = true;
|
|
55
|
+
};
|
|
56
|
+
}, [providerPromise]);
|
|
35
57
|
|
|
58
|
+
const lastResolvedProviderRef = useRef<Awaited<typeof providerPromise> | null>(null);
|
|
36
59
|
useEffect(() => {
|
|
37
60
|
let isCancelled = false;
|
|
38
61
|
|
|
@@ -55,6 +78,7 @@ export default function Globe({
|
|
|
55
78
|
|
|
56
79
|
return (
|
|
57
80
|
<CesiumGlobe
|
|
81
|
+
ref={cesiumGlobeRef}
|
|
58
82
|
baseColor={baseColor}
|
|
59
83
|
enableLighting={!!property?.globe?.enableLighting}
|
|
60
84
|
showGroundAtmosphere={property?.globe?.atmosphere?.enabled ?? true}
|