@reearth/core 0.0.4 → 0.0.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/core.js +1221 -1227
- package/dist/core.umd.cjs +35 -35
- package/package.json +8 -4
- package/src/engines/Cesium/hooks.ts +53 -56
- package/src/.DS_Store +0 -0
- package/src/engines/Cesium/.DS_Store +0 -0
- package/src/engines/Cesium/Feature/.DS_Store +0 -0
- package/src/engines/Cesium/core/.DS_Store +0 -0
- package/src/utils/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reearth/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-beta.0",
|
|
4
4
|
"author": "Re:Earth contributors <community@reearth.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "A library that abstracts a map engine as one common API.",
|
|
@@ -13,20 +13,23 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
-
"dev": "vite",
|
|
16
|
+
"dev": "vite -c vite.config.example.ts",
|
|
17
17
|
"build": "tsc && vite build",
|
|
18
18
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives",
|
|
19
19
|
"preview": "vite preview",
|
|
20
20
|
"test": "vitest",
|
|
21
21
|
"storybook": "storybook dev -p 6007",
|
|
22
|
-
"build-storybook": "storybook build"
|
|
22
|
+
"build-storybook": "storybook build",
|
|
23
|
+
"preversion": "yarn test run",
|
|
24
|
+
"version": "yarn build"
|
|
23
25
|
},
|
|
24
26
|
"engines": {
|
|
25
27
|
"node": ">=20"
|
|
26
28
|
},
|
|
27
29
|
"peerDependencies": {
|
|
28
30
|
"react": "^18.2.0",
|
|
29
|
-
"react-dom": "^18.2.0"
|
|
31
|
+
"react-dom": "^18.2.0",
|
|
32
|
+
"cesium": "1.x"
|
|
30
33
|
},
|
|
31
34
|
"dependencies": {
|
|
32
35
|
"@reearth/cesium-mvt-imagery-provider": "1.5.4",
|
|
@@ -108,6 +111,7 @@
|
|
|
108
111
|
"vite-plugin-cesium": "1.2.22",
|
|
109
112
|
"vite-plugin-dts": "3.8.1",
|
|
110
113
|
"vite-plugin-svgr": "4.2.0",
|
|
114
|
+
"vite-tsconfig-paths": "^4.3.2",
|
|
111
115
|
"vitest": "1.0.4",
|
|
112
116
|
"web-streams-polyfill": "3.2.1"
|
|
113
117
|
},
|
|
@@ -372,11 +372,15 @@ export default ({
|
|
|
372
372
|
| GroundPrimitive
|
|
373
373
|
| ImageryLayer
|
|
374
374
|
>();
|
|
375
|
+
const prevSelectedImageryFeatureId = useRef<string | undefined>();
|
|
376
|
+
|
|
375
377
|
// manage layer selection
|
|
376
378
|
useEffect(() => {
|
|
377
379
|
const viewer = cesium.current?.cesiumElement;
|
|
378
380
|
if (!viewer || viewer.isDestroyed()) return;
|
|
379
381
|
|
|
382
|
+
if (prevSelectedImageryFeatureId.current === selectedLayerId?.featureId) return;
|
|
383
|
+
|
|
380
384
|
const prevTag = getTag(prevSelectedEntity.current);
|
|
381
385
|
if (
|
|
382
386
|
(!prevTag?.featureId &&
|
|
@@ -571,11 +575,7 @@ export default ({
|
|
|
571
575
|
const viewer = cesium.current?.cesiumElement;
|
|
572
576
|
if (!viewer || viewer.isDestroyed()) return;
|
|
573
577
|
|
|
574
|
-
|
|
575
|
-
viewer.selectedEntity = undefined;
|
|
576
|
-
onLayerSelect?.();
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
578
|
+
prevSelectedImageryFeatureId.current = undefined;
|
|
579
579
|
|
|
580
580
|
const entity =
|
|
581
581
|
findEntity(viewer, undefined, selectedLayerId?.featureId) ||
|
|
@@ -685,63 +685,60 @@ export default ({
|
|
|
685
685
|
const l = await scene.imageryLayers.pickImageryLayerFeatures(pickRay, scene);
|
|
686
686
|
|
|
687
687
|
// NOTE: For now we only send the first selected feature to onLayerSelect instead of sending all of them: @pyshx
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
const f = l?.[0];
|
|
689
|
+
|
|
690
|
+
const appearanceType = f?.data?.appearanceType;
|
|
691
|
+
|
|
692
|
+
if (appearanceType && f?.data?.feature?.[appearanceType]?.show !== false) {
|
|
693
|
+
const tag = getTag(f.imageryLayer);
|
|
694
|
+
|
|
695
|
+
const pos = f.position;
|
|
696
|
+
if (pos) {
|
|
697
|
+
// NOTE: Instantiate temporal Cesium.Entity to display indicator.
|
|
698
|
+
// Although we want to use `viewer.selectionIndicator.viewModel.position` and `animateAppear`, Cesium reset selection position if `viewer.selectedEntity` is not set.
|
|
699
|
+
// ref: https://github.com/CesiumGS/cesium/blob/9295450e64c3077d96ad579012068ea05f97842c/packages/widgets/Source/Viewer/Viewer.js#L1843-L1876
|
|
700
|
+
// issue: https://github.com/CesiumGS/cesium/issues/7965
|
|
701
|
+
requestAnimationFrame(() => {
|
|
702
|
+
if (!tag?.hideIndicator) {
|
|
703
|
+
viewer.selectedEntity = new Entity({
|
|
704
|
+
position: Cartographic.toCartesian(pos),
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
690
709
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
710
|
+
const layer = tag?.layerId
|
|
711
|
+
? layersRef?.current?.overriddenLayers().find(l => l.id === tag.layerId) ??
|
|
712
|
+
layersRef?.current?.findById(tag.layerId)
|
|
713
|
+
: undefined;
|
|
714
|
+
const content = getEntityContent(
|
|
715
|
+
f.data.feature ?? f,
|
|
716
|
+
viewer.clock.currentTime ?? new JulianDate(),
|
|
717
|
+
tag?.layerId ? layer?.infobox?.property?.defaultContent : undefined,
|
|
718
|
+
);
|
|
719
|
+
prevSelectedImageryFeatureId.current = f.data.featureId;
|
|
720
|
+
onLayerSelect?.(
|
|
721
|
+
f.data.layerId,
|
|
722
|
+
f.data.featureId,
|
|
723
|
+
content.value.length
|
|
724
|
+
? {
|
|
725
|
+
defaultInfobox: {
|
|
726
|
+
title: layer?.title ?? f.name,
|
|
727
|
+
content,
|
|
728
|
+
},
|
|
729
|
+
}
|
|
730
|
+
: undefined,
|
|
731
|
+
{
|
|
732
|
+
feature: f.data.feature,
|
|
733
|
+
},
|
|
734
|
+
);
|
|
695
735
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const pos = f.position;
|
|
699
|
-
if (pos) {
|
|
700
|
-
// NOTE: Instantiate temporal Cesium.Entity to display indicator.
|
|
701
|
-
// Although we want to use `viewer.selectionIndicator.viewModel.position` and `animateAppear`, Cesium reset selection position if `viewer.selectedEntity` is not set.
|
|
702
|
-
// ref: https://github.com/CesiumGS/cesium/blob/9295450e64c3077d96ad579012068ea05f97842c/packages/widgets/Source/Viewer/Viewer.js#L1843-L1876
|
|
703
|
-
// issue: https://github.com/CesiumGS/cesium/issues/7965
|
|
704
|
-
requestAnimationFrame(() => {
|
|
705
|
-
if (!tag?.hideIndicator) {
|
|
706
|
-
viewer.selectedEntity = new Entity({
|
|
707
|
-
position: Cartographic.toCartesian(pos),
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
});
|
|
736
|
+
return;
|
|
711
737
|
}
|
|
712
|
-
|
|
713
|
-
const layer = tag?.layerId
|
|
714
|
-
? layersRef?.current?.overriddenLayers().find(l => l.id === tag.layerId) ??
|
|
715
|
-
layersRef?.current?.findById(tag.layerId)
|
|
716
|
-
: undefined;
|
|
717
|
-
const content = getEntityContent(
|
|
718
|
-
f.data.feature ?? f,
|
|
719
|
-
viewer.clock.currentTime ?? new JulianDate(),
|
|
720
|
-
tag?.layerId ? layer?.infobox?.property?.defaultContent : undefined,
|
|
721
|
-
);
|
|
722
|
-
onLayerSelect?.(
|
|
723
|
-
f.data.layerId,
|
|
724
|
-
f.data.featureId,
|
|
725
|
-
content.value.length
|
|
726
|
-
? {
|
|
727
|
-
defaultInfobox: {
|
|
728
|
-
title: layer?.title ?? f.name,
|
|
729
|
-
content,
|
|
730
|
-
},
|
|
731
|
-
}
|
|
732
|
-
: undefined,
|
|
733
|
-
{
|
|
734
|
-
feature: f.data.feature,
|
|
735
|
-
},
|
|
736
|
-
);
|
|
737
|
-
|
|
738
|
-
return;
|
|
739
738
|
}
|
|
740
739
|
}
|
|
741
740
|
|
|
742
|
-
|
|
743
|
-
viewer.selectedEntity = undefined;
|
|
744
|
-
}
|
|
741
|
+
viewer.selectedEntity = undefined;
|
|
745
742
|
onLayerSelect?.();
|
|
746
743
|
},
|
|
747
744
|
[
|
package/src/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/utils/.DS_Store
DELETED
|
Binary file
|