@reearth/core 0.0.7-alpha.10 → 0.0.7-alpha.11
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 +7 -7
- package/dist/core.umd.cjs +2 -2
- package/package.json +1 -1
- package/src/engines/Cesium/Feature/utils.tsx +12 -2
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
GroundPrimitive,
|
|
18
18
|
} from "cesium";
|
|
19
19
|
import md5 from "js-md5";
|
|
20
|
-
import { pick } from "lodash-es";
|
|
20
|
+
import { isEqual, pick } from "lodash-es";
|
|
21
21
|
import {
|
|
22
22
|
ComponentProps,
|
|
23
23
|
ComponentType,
|
|
@@ -87,8 +87,17 @@ function EntityExtComponent(
|
|
|
87
87
|
ref: ForwardedRef<CesiumComponentRef<CesiumEntity>>,
|
|
88
88
|
) {
|
|
89
89
|
const r = useRef<CesiumComponentRef<CesiumEntity>>(null);
|
|
90
|
+
const entityRef = useRef<CesiumEntity | undefined>(r?.current?.cesiumElement);
|
|
90
91
|
|
|
91
92
|
useLayoutEffect(() => {
|
|
93
|
+
// Note: Sketch feature's tag cannot be attached properly when first load
|
|
94
|
+
// The cesiumElement is undefined when attach, and doesn't have a chance to attach again.
|
|
95
|
+
// Root cause is still not clear.
|
|
96
|
+
// Here we add r.current as a dependency and check cesiumElement instead.
|
|
97
|
+
if (entityRef.current !== undefined && isEqual(entityRef.current, r.current?.cesiumElement))
|
|
98
|
+
return;
|
|
99
|
+
entityRef.current = r.current?.cesiumElement;
|
|
100
|
+
|
|
92
101
|
attachTag(r.current?.cesiumElement, {
|
|
93
102
|
layerId: layerId || props.id,
|
|
94
103
|
featureId,
|
|
@@ -97,6 +106,7 @@ function EntityExtComponent(
|
|
|
97
106
|
legacyLocationPropertyKey,
|
|
98
107
|
hideIndicator,
|
|
99
108
|
});
|
|
109
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
110
|
}, [
|
|
101
111
|
draggable,
|
|
102
112
|
featureId,
|
|
@@ -105,7 +115,7 @@ function EntityExtComponent(
|
|
|
105
115
|
props.id,
|
|
106
116
|
unselectable,
|
|
107
117
|
hideIndicator,
|
|
108
|
-
r.current
|
|
118
|
+
r.current,
|
|
109
119
|
]);
|
|
110
120
|
|
|
111
121
|
return <Entity ref={composeRefs(ref, r)} {...props} />;
|