@reearth/core 0.0.7-alpha.5 → 0.0.7-beta.1
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/cesium/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/dist/cesium/Widgets/I3SBuildingSceneLayerExplorer/I3SBuildingSceneLayerExplorer.css +8 -8
- package/dist/cesium/Widgets/widgets.css +8 -8
- package/dist/cesium/Workers/{chunk-SUQM3OSW.js → chunk-2YD5QWGR.js} +2 -2
- package/dist/cesium/Workers/{chunk-74N6MC2V.js → chunk-3T4KR75X.js} +2 -2
- package/dist/cesium/Workers/chunk-46KFVW24.js +26 -0
- package/dist/cesium/Workers/chunk-4EI6PP43.js +28 -0
- package/dist/cesium/Workers/{chunk-YEJWCH6C.js → chunk-4RS52VIY.js} +2 -2
- package/dist/cesium/Workers/{chunk-NPBZI5YA.js → chunk-4YLYA3DC.js} +1 -1
- package/dist/cesium/Workers/{chunk-JEWHFDAA.js → chunk-5ENAGXBI.js} +2 -2
- package/dist/cesium/Workers/{chunk-MRR3RGFO.js → chunk-5VIB3TI5.js} +2 -2
- package/dist/cesium/Workers/{chunk-JCJ24DHF.js → chunk-6NGZLDFZ.js} +2 -2
- package/dist/cesium/Workers/{chunk-7X2YQ6I4.js → chunk-6RGNWVZ2.js} +2 -2
- package/dist/cesium/Workers/{chunk-BK3HCS7I.js → chunk-7AZZVJ52.js} +2 -2
- package/dist/cesium/Workers/{chunk-UBIRX2SP.js → chunk-AMXAQQEL.js} +2 -2
- package/dist/cesium/Workers/{chunk-LDCAXLGS.js → chunk-AQW44ZPC.js} +2 -2
- package/dist/cesium/Workers/{chunk-B6TRTFAA.js → chunk-CPCMDW6Z.js} +2 -2
- package/dist/cesium/Workers/{chunk-3C74MLG3.js → chunk-DNL2WDRL.js} +1 -1
- package/dist/cesium/Workers/{chunk-FK5KFB6H.js → chunk-ERW7V247.js} +1 -1
- package/dist/cesium/Workers/{chunk-5AG2MVRM.js → chunk-EYRIA4TP.js} +2 -2
- package/dist/cesium/Workers/{chunk-6AUUBDOF.js → chunk-F7RQIJML.js} +2 -2
- package/dist/cesium/Workers/{chunk-JZLZJJQD.js → chunk-FPZMU6QP.js} +2 -2
- package/dist/cesium/Workers/{chunk-YBI55DLZ.js → chunk-FZDVQW7A.js} +2 -2
- package/dist/cesium/Workers/{chunk-2MBPFWCP.js → chunk-GAZ2U4FO.js} +2 -2
- package/dist/cesium/Workers/{chunk-CSISXEG7.js → chunk-I44IOOT4.js} +1 -1
- package/dist/cesium/Workers/{chunk-R2AN7EKC.js → chunk-IALXUAD4.js} +1 -1
- package/dist/cesium/Workers/{chunk-MDLPQIMP.js → chunk-IXBUEUZL.js} +2 -2
- package/dist/cesium/Workers/{chunk-HPBHKP5S.js → chunk-J3GCYV5K.js} +2 -2
- package/dist/cesium/Workers/{chunk-KRZBI2MU.js → chunk-KGSZTFHZ.js} +2 -2
- package/dist/cesium/Workers/{chunk-B2SKQ7LU.js → chunk-KKKPU2CI.js} +2 -2
- package/dist/cesium/Workers/{chunk-QPOPEH3M.js → chunk-KTEJE5KE.js} +2 -2
- package/dist/cesium/Workers/chunk-KYZ3DYY6.js +26 -0
- package/dist/cesium/Workers/{chunk-LOPN5R3I.js → chunk-L2QG4MRI.js} +2 -2
- package/dist/cesium/Workers/{chunk-EXBFEYPQ.js → chunk-MCE3KFYN.js} +2 -2
- package/dist/cesium/Workers/{chunk-C6DMEJQ7.js → chunk-MMLDGXML.js} +2 -2
- package/dist/cesium/Workers/{chunk-KTTUANTJ.js → chunk-MTBRPBDQ.js} +2 -2
- package/dist/cesium/Workers/{chunk-7VZHIB6P.js → chunk-OKT6VBRK.js} +2 -2
- package/dist/cesium/Workers/chunk-PHYDKLSY.js +26 -0
- package/dist/cesium/Workers/chunk-PWPX3224.js +26 -0
- package/dist/cesium/Workers/{chunk-VQZSIOZW.js → chunk-QHOVE6WG.js} +2 -2
- package/dist/cesium/Workers/{chunk-CN7UN2OZ.js → chunk-QJ6MBL22.js} +2 -2
- package/dist/cesium/Workers/{chunk-NUSW5B6A.js → chunk-QKO6VIG2.js} +2 -2
- package/dist/cesium/Workers/{chunk-4N7SRDH5.js → chunk-QVEE4QL2.js} +2 -2
- package/dist/cesium/Workers/{chunk-4T6AS6BZ.js → chunk-RXQOQZ7S.js} +2 -2
- package/dist/cesium/Workers/{chunk-RURL6ZX2.js → chunk-S3ZKQKMM.js} +2 -2
- package/dist/cesium/Workers/{chunk-ZYWD6OQH.js → chunk-SFEUMZSK.js} +2 -2
- package/dist/cesium/Workers/{chunk-BOPB43LN.js → chunk-T75MW4X3.js} +2 -2
- package/dist/cesium/Workers/chunk-TVO2A75R.js +66 -0
- package/dist/cesium/Workers/{chunk-VHNZBQTR.js → chunk-UHR36K45.js} +2 -2
- package/dist/cesium/Workers/{chunk-WZUWQMI7.js → chunk-UKJCDZOR.js} +2 -2
- package/dist/cesium/Workers/{chunk-B4TQDFIE.js → chunk-VKVIYER6.js} +2 -2
- package/dist/cesium/Workers/{chunk-OUXRUXNB.js → chunk-VPIQWTRZ.js} +2 -2
- package/dist/cesium/Workers/{chunk-2ED5WI77.js → chunk-XSX5HRFC.js} +2 -2
- package/dist/cesium/Workers/{chunk-5Z6L2FHX.js → chunk-Z5WQQHSL.js} +2 -2
- package/dist/cesium/Workers/{chunk-YPDO7SPO.js → chunk-Z7B2VEL5.js} +2 -2
- package/dist/cesium/Workers/combineGeometry.js +2 -2
- package/dist/cesium/Workers/createBoxGeometry.js +2 -2
- package/dist/cesium/Workers/createBoxOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createCircleGeometry.js +2 -2
- package/dist/cesium/Workers/createCircleOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createCoplanarPolygonGeometry.js +2 -2
- package/dist/cesium/Workers/createCoplanarPolygonOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createCorridorGeometry.js +2 -2
- package/dist/cesium/Workers/createCorridorOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createCylinderGeometry.js +2 -2
- package/dist/cesium/Workers/createCylinderOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createEllipseGeometry.js +2 -2
- package/dist/cesium/Workers/createEllipseOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createEllipsoidGeometry.js +2 -2
- package/dist/cesium/Workers/createEllipsoidOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createFrustumGeometry.js +2 -2
- package/dist/cesium/Workers/createFrustumOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createGeometry.js +2 -2
- package/dist/cesium/Workers/createGroundPolylineGeometry.js +2 -2
- package/dist/cesium/Workers/createPlaneGeometry.js +2 -2
- package/dist/cesium/Workers/createPlaneOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createPolygonGeometry.js +2 -2
- package/dist/cesium/Workers/createPolygonOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createPolylineGeometry.js +2 -2
- package/dist/cesium/Workers/createPolylineVolumeGeometry.js +2 -2
- package/dist/cesium/Workers/createPolylineVolumeOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createRectangleGeometry.js +2 -2
- package/dist/cesium/Workers/createRectangleOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createSimplePolylineGeometry.js +2 -2
- package/dist/cesium/Workers/createSphereGeometry.js +2 -2
- package/dist/cesium/Workers/createSphereOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/createTaskProcessorWorker.js +2 -2
- package/dist/cesium/Workers/createVectorTileClampedPolylines.js +2 -2
- package/dist/cesium/Workers/createVectorTileGeometries.js +2 -2
- package/dist/cesium/Workers/createVectorTilePoints.js +2 -2
- package/dist/cesium/Workers/createVectorTilePolygons.js +2 -2
- package/dist/cesium/Workers/createVectorTilePolylines.js +2 -2
- package/dist/cesium/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +2 -2
- package/dist/cesium/Workers/createVerticesFromHeightmap.js +2 -2
- package/dist/cesium/Workers/createVerticesFromQuantizedTerrainMesh.js +2 -2
- package/dist/cesium/Workers/createWallGeometry.js +2 -2
- package/dist/cesium/Workers/createWallOutlineGeometry.js +2 -2
- package/dist/cesium/Workers/decodeDraco.js +2 -2
- package/dist/cesium/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2
- package/dist/cesium/Workers/decodeI3S.js +2 -2
- package/dist/cesium/Workers/transcodeKTX2.js +10 -10
- package/dist/cesium/Workers/transferTypedArrayTest.js +1 -1
- package/dist/cesium/Workers/upsampleQuantizedTerrainMesh.js +2 -2
- package/dist/core.js +34193 -34105
- package/dist/core.umd.cjs +3866 -3820
- package/dist/index.d.ts +212 -217
- package/package.json +5 -5
- package/src/Map/ClusteredLayers/index.tsx +2 -2
- package/src/Map/Layer/index.tsx +3 -3
- package/src/Map/Layers/hooks.ts +0 -10
- package/src/Map/Layers/index.tsx +2 -2
- package/src/Map/Sketch/hooks.ts +66 -46
- package/src/Map/Sketch/index.tsx +24 -2
- package/src/Map/Sketch/preset.ts +0 -2
- package/src/Map/Sketch/types.ts +0 -31
- package/src/Map/hooks.ts +4 -0
- package/src/Map/index.tsx +5 -8
- package/src/Map/ref.ts +7 -4
- package/src/Map/types/index.ts +216 -34
- package/src/Map/useTimelineManager.ts +3 -5
- package/src/Map/utils.ts +43 -1
- package/src/Visualizer/coreContext.tsx +8 -1
- package/src/Visualizer/hooks.ts +75 -6
- package/src/Visualizer/index.stories.tsx +48 -4
- package/src/Visualizer/index.tsx +6 -8
- package/src/engines/Cesium/Feature/Ellipse/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Frustum/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Model/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Model/index.tsx +9 -10
- package/src/engines/Cesium/Feature/Polygon/index.stories.tsx +6 -8
- package/src/engines/Cesium/Feature/Raster/index.stories.tsx +2 -2
- package/src/engines/Cesium/Feature/Resource/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Tileset/hooks.ts +11 -12
- package/src/engines/Cesium/Feature/Tileset/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Tileset/index.tsx +4 -4
- package/src/engines/Cesium/Feature/Tileset/useClippingBox.ts +1 -10
- package/src/engines/Cesium/Feature/index.tsx +4 -5
- package/src/engines/Cesium/Feature/utils.tsx +2 -3
- package/src/engines/Cesium/Shaders/OverriddenShaders/GlobeFS/IBL.glsl +6 -10
- package/src/engines/Cesium/{hooks/useOverrideGlobeShader/VertexTerrainElevationMaterial.ts → VertexTerrainElevationMaterial.ts} +2 -3
- package/src/engines/Cesium/{hooks/useCameraLimiter.ts → cameraLimiter.ts} +45 -22
- package/src/engines/Cesium/core/Globe.tsx +68 -36
- package/src/engines/Cesium/core/Imagery.test.ts +9 -9
- package/src/engines/Cesium/core/Imagery.tsx +19 -17
- package/src/engines/Cesium/core/Indicator/Indicator.tsx +8 -8
- package/src/engines/Cesium/hooks.ts +365 -124
- package/src/engines/Cesium/index.stories.tsx +1 -1
- package/src/engines/Cesium/index.tsx +62 -60
- package/src/engines/Cesium/{hooks/useEngineRef.test.tsx → useEngineRef.test.tsx} +34 -38
- package/src/engines/Cesium/{hooks/useEngineRef.ts → useEngineRef.ts} +41 -43
- package/src/engines/Cesium/{hooks/useOverrideGlobeShader/useOverrideGlobeShader.ts → useOverrideGlobeShader.ts} +17 -20
- package/src/engines/index.ts +1 -1
- package/src/mantle/compat/types.ts +7 -7
- package/dist/cesium/Workers/chunk-45U7TTT3.js +0 -26
- package/dist/cesium/Workers/chunk-7VJK3KHI.js +0 -26
- package/dist/cesium/Workers/chunk-CUOR5F7T.js +0 -28
- package/dist/cesium/Workers/chunk-DGCK3LD2.js +0 -30
- package/dist/cesium/Workers/chunk-DXEZYE3K.js +0 -62
- package/dist/cesium/Workers/chunk-VAKC5J5C.js +0 -26
- package/dist/cesium/Workers/chunk-VKV642QV.js +0 -26
- package/dist/cesium/Workers/chunk-VMSXG4OA.js +0 -26
- package/src/Map/types/viewerProperty.ts +0 -215
- package/src/Visualizer/useCoreAPI.ts +0 -30
- package/src/engines/Cesium/hooks/useCamera.ts +0 -135
- package/src/engines/Cesium/hooks/useExplicitRender.ts +0 -65
- package/src/engines/Cesium/hooks/useLayerDragDrop.ts +0 -77
- package/src/engines/Cesium/hooks/useViewerProperty.ts +0 -90
- /package/src/engines/Cesium/{hooks/useOverrideGlobeShader/JapanSeaLevelEllipsoid.ts → JapanSeaLevelEllipsoid.ts} +0 -0
- /package/src/engines/Cesium/{hooks/useOverrideGlobeShader/vertexTerrainElevationMaterial.glsl → vertexTerrainElevationMaterial.glsl} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reearth/core",
|
|
3
|
-
"version": "0.0.7-
|
|
3
|
+
"version": "0.0.7-beta.1",
|
|
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.",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"node": ">=20"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"cesium": "1.x",
|
|
31
30
|
"react": "^18.2.0",
|
|
32
|
-
"react-dom": "^18.2.0"
|
|
31
|
+
"react-dom": "^18.2.0",
|
|
32
|
+
"cesium": "1.x"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@reearth/cesium-mvt-imagery-provider": "1.5.4",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"react-error-boundary": "4.0.11",
|
|
62
62
|
"react-nl2br": "1.0.4",
|
|
63
63
|
"react-use": "17.5.0",
|
|
64
|
-
"resium": "
|
|
64
|
+
"resium": "1.17.4",
|
|
65
65
|
"suspend-react": "0.1.3",
|
|
66
66
|
"tiny-invariant": "1.3.3",
|
|
67
67
|
"use-callback-ref": "1.3.2",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@typescript-eslint/eslint-plugin": "7.2.0",
|
|
96
96
|
"@typescript-eslint/parser": "7.2.0",
|
|
97
97
|
"@vitejs/plugin-react": "4.2.1",
|
|
98
|
-
"cesium": "1.
|
|
98
|
+
"cesium": "1.118.0",
|
|
99
99
|
"eslint": "8.57.0",
|
|
100
100
|
"eslint-config-reearth": "0.3.0",
|
|
101
101
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentType, useMemo, useCallback, ReactNode } from "react";
|
|
2
2
|
|
|
3
3
|
import LayerComponent, { type CommonProps, type Props as LayerProps } from "../Layer";
|
|
4
|
-
import type { Layer, Atom, Typography, DataType
|
|
4
|
+
import type { Layer, Atom, Typography, DataType } from "../types";
|
|
5
5
|
|
|
6
6
|
export type Props = {
|
|
7
7
|
layers?: Layer[];
|
|
@@ -14,7 +14,7 @@ export type Props = {
|
|
|
14
14
|
isHidden?: (id: string) => boolean;
|
|
15
15
|
clusters?: Cluster[];
|
|
16
16
|
delegatedDataTypes?: DataType[];
|
|
17
|
-
|
|
17
|
+
sceneProperty?: any;
|
|
18
18
|
clusterComponent?: ClusterComponentType;
|
|
19
19
|
Feature?: LayerProps["Feature"];
|
|
20
20
|
} & Omit<CommonProps, "isSelected" | "isHidden" | "selectedFeatureId">;
|
package/src/Map/Layer/index.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
ComputedFeature,
|
|
10
10
|
LayerSimple,
|
|
11
11
|
} from "../../mantle";
|
|
12
|
-
import {
|
|
12
|
+
import { SceneProperty } from "../types";
|
|
13
13
|
|
|
14
14
|
import useHooks, { type Atom, type EvalFeature } from "./hooks";
|
|
15
15
|
|
|
@@ -29,7 +29,7 @@ export type CommonProps = {
|
|
|
29
29
|
|
|
30
30
|
export type FeatureComponentProps = {
|
|
31
31
|
layer: ComputedLayer;
|
|
32
|
-
|
|
32
|
+
sceneProperty?: SceneProperty;
|
|
33
33
|
onFeatureRequest?: (range: DataRange) => void;
|
|
34
34
|
onLayerFetch?: (value: Partial<Pick<LayerSimple, "properties">>) => void;
|
|
35
35
|
onFeatureFetch?: (features: Feature[]) => void;
|
|
@@ -44,7 +44,7 @@ export type Props = {
|
|
|
44
44
|
atom?: Atom;
|
|
45
45
|
overrides?: Record<string, any>;
|
|
46
46
|
delegatedDataTypes?: DataType[];
|
|
47
|
-
|
|
47
|
+
sceneProperty?: any;
|
|
48
48
|
selectedFeatureId?: string;
|
|
49
49
|
/** Feature component should be injected by a map engine. */
|
|
50
50
|
Feature?: ComponentType<FeatureComponentProps>;
|
package/src/Map/Layers/hooks.ts
CHANGED
|
@@ -52,7 +52,6 @@ export type Ref = {
|
|
|
52
52
|
override: (id: string, layer?: (Partial<Layer> & { property?: any }) | null) => void;
|
|
53
53
|
deleteLayer: (...ids: string[]) => void;
|
|
54
54
|
isLayer: (obj: any) => obj is LazyLayer;
|
|
55
|
-
isComputedLayer: (obj: any) => obj is ComputedLayer;
|
|
56
55
|
layers: () => LazyLayer[];
|
|
57
56
|
walk: <T>(
|
|
58
57
|
fn: (layer: LazyLayer, index: number, parents: LazyLayer[]) => T | void,
|
|
@@ -456,13 +455,6 @@ export default function useHooks({
|
|
|
456
455
|
[lazyLayerPrototype],
|
|
457
456
|
);
|
|
458
457
|
|
|
459
|
-
const isComputedLayer = useCallback(
|
|
460
|
-
(obj: any): obj is ComputedLayer => {
|
|
461
|
-
return typeof obj === "object" && Object.getPrototypeOf(obj) === lazyComputedLayerPrototype;
|
|
462
|
-
},
|
|
463
|
-
[lazyComputedLayerPrototype],
|
|
464
|
-
);
|
|
465
|
-
|
|
466
458
|
const rootLayers = useCallback(() => {
|
|
467
459
|
return [...(layersRef() ?? []), ...tempLayersRef.current]
|
|
468
460
|
.map(l => findById(l.id))
|
|
@@ -559,7 +551,6 @@ export default function useHooks({
|
|
|
559
551
|
deleteLayer,
|
|
560
552
|
findByIds,
|
|
561
553
|
isLayer,
|
|
562
|
-
isComputedLayer,
|
|
563
554
|
layers: rootLayers,
|
|
564
555
|
walk,
|
|
565
556
|
find,
|
|
@@ -584,7 +575,6 @@ export default function useHooks({
|
|
|
584
575
|
deleteLayer,
|
|
585
576
|
findByIds,
|
|
586
577
|
isLayer,
|
|
587
|
-
isComputedLayer,
|
|
588
578
|
rootLayers,
|
|
589
579
|
walk,
|
|
590
580
|
find,
|
package/src/Map/Layers/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { forwardRef, RefObject, type ForwardRefRenderFunction, type MutableRefOb
|
|
|
2
2
|
|
|
3
3
|
import { SelectedFeatureInfo } from "../../mantle";
|
|
4
4
|
import ClusteredLayers, { type Props as ClusteredLayerProps } from "../ClusteredLayers";
|
|
5
|
-
import type { ComputedLayer, EngineRef, RequestingRenderMode
|
|
5
|
+
import type { ComputedLayer, EngineRef, RequestingRenderMode } from "../types";
|
|
6
6
|
|
|
7
7
|
import useHooks, { LayerSelectionReason, type Ref } from "./hooks";
|
|
8
8
|
|
|
@@ -36,7 +36,7 @@ export type Props = Omit<ClusteredLayerProps, "atomMap" | "isHidden" | "selected
|
|
|
36
36
|
reason?: LayerSelectionReason;
|
|
37
37
|
};
|
|
38
38
|
hiddenLayers?: string[];
|
|
39
|
-
|
|
39
|
+
sceneProperty?: any;
|
|
40
40
|
requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
|
|
41
41
|
engineRef?: RefObject<EngineRef>;
|
|
42
42
|
onLayerSelect?: (
|
package/src/Map/Sketch/hooks.ts
CHANGED
|
@@ -24,16 +24,15 @@ import {
|
|
|
24
24
|
MouseEventProps,
|
|
25
25
|
SketchRef,
|
|
26
26
|
} from "../types";
|
|
27
|
-
import { useGet } from "../utils";
|
|
28
27
|
|
|
29
|
-
import { PRESET_APPEARANCE
|
|
28
|
+
import { PRESET_APPEARANCE } from "./preset";
|
|
30
29
|
import { Position3d, createSketchMachine } from "./sketchMachine";
|
|
31
30
|
import {
|
|
32
31
|
GeometryOptionsXYZ,
|
|
33
32
|
SketchType,
|
|
34
33
|
SketchFeature,
|
|
34
|
+
SketchAppearance,
|
|
35
35
|
SketchEventProps,
|
|
36
|
-
SketchOptions,
|
|
37
36
|
} from "./types";
|
|
38
37
|
import { useWindowEvent } from "./utils";
|
|
39
38
|
|
|
@@ -74,25 +73,16 @@ export default function useHooks({
|
|
|
74
73
|
const [state, send] = useMachine(sketchMachine);
|
|
75
74
|
const [type, updateType] = useState<SketchType | undefined>();
|
|
76
75
|
const [from, updateFrom] = useState<"editor" | "plugin">("editor");
|
|
76
|
+
const [color, updateColor] = useState<string>();
|
|
77
|
+
const [disableShadow, updateDisableShadow] = useState(false);
|
|
78
|
+
const [enableRelativeHeight, updateEnableRelativeHeight] = useState(false);
|
|
77
79
|
const [disableInteraction, setDisableInteraction] = useState(false);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
enableRelativeHeight: false,
|
|
85
|
-
rightClickToAbort: true,
|
|
86
|
-
autoResetInteractionMode: true,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const overrideOptions = useCallback((options: SketchOptions) => {
|
|
90
|
-
setSketchOptions(prev => ({
|
|
91
|
-
...prev,
|
|
92
|
-
...options,
|
|
93
|
-
appearance: merge(cloneDeep(prev.appearance), options.appearance),
|
|
94
|
-
}));
|
|
95
|
-
}, []);
|
|
80
|
+
const [defaultAppearance, updateDefaultAppearance] = useState<SketchAppearance | undefined>(
|
|
81
|
+
PRESET_APPEARANCE,
|
|
82
|
+
);
|
|
83
|
+
const createDataOnlyForPluginEnabledRef = useRef(false);
|
|
84
|
+
const allowRightClickToAbortEnabledRef = useRef(true);
|
|
85
|
+
const allowAutoResetInteractionModeRef = useRef(true);
|
|
96
86
|
|
|
97
87
|
const [geometryOptions, setGeometryOptions] = useState<GeometryOptionsXYZ | null>(null);
|
|
98
88
|
const [extrudedHeight, setExtrudedHeight] = useState(0);
|
|
@@ -104,6 +94,34 @@ export default function useHooks({
|
|
|
104
94
|
updateFrom(from ?? "editor");
|
|
105
95
|
}, []);
|
|
106
96
|
|
|
97
|
+
const setColor = useCallback((color: string) => {
|
|
98
|
+
updateColor(color);
|
|
99
|
+
}, []);
|
|
100
|
+
|
|
101
|
+
const setDisableShadow = useCallback((disable: boolean) => {
|
|
102
|
+
updateDisableShadow(!!disable);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const setEnableRelativeHeight = useCallback((enable: boolean) => {
|
|
106
|
+
updateEnableRelativeHeight(!!enable);
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
const setDefaultAppearance = useCallback((appearance: SketchAppearance) => {
|
|
110
|
+
updateDefaultAppearance(merge(cloneDeep(PRESET_APPEARANCE), appearance));
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
const createDataOnly = useCallback((dataOnly: boolean) => {
|
|
114
|
+
createDataOnlyForPluginEnabledRef.current = !!dataOnly;
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
117
|
+
const allowRightClickToAbort = useCallback((allow: boolean) => {
|
|
118
|
+
allowRightClickToAbortEnabledRef.current = !!allow;
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
121
|
+
const allowAutoResetInteractionMode = useCallback((allow: boolean) => {
|
|
122
|
+
allowAutoResetInteractionModeRef.current = !!allow;
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
107
125
|
const createFeature = useCallback(() => {
|
|
108
126
|
const geoOptions = type === "marker" ? markerGeometryRef.current : geometryOptions;
|
|
109
127
|
if (geoOptions == null) {
|
|
@@ -151,11 +169,11 @@ export default function useHooks({
|
|
|
151
169
|
features: [{ ...feature, id: feature.properties.id }],
|
|
152
170
|
},
|
|
153
171
|
},
|
|
154
|
-
...
|
|
172
|
+
...defaultAppearance,
|
|
155
173
|
});
|
|
156
174
|
return { layerId: newLayer?.id, featureId: feature.properties.id };
|
|
157
175
|
},
|
|
158
|
-
[layersRef,
|
|
176
|
+
[layersRef, defaultAppearance],
|
|
159
177
|
);
|
|
160
178
|
|
|
161
179
|
const pluginSketchLayerFeatureAdd = useCallback(
|
|
@@ -208,7 +226,7 @@ export default function useHooks({
|
|
|
208
226
|
return;
|
|
209
227
|
}
|
|
210
228
|
|
|
211
|
-
if (!
|
|
229
|
+
if (!createDataOnlyForPluginEnabledRef.current) {
|
|
212
230
|
const selectedLayer = layersRef.current?.selectedLayer();
|
|
213
231
|
const { layerId, featureId } =
|
|
214
232
|
selectedLayer?.id?.length !== PLUGIN_LAYER_ID_LENGTH ||
|
|
@@ -244,7 +262,6 @@ export default function useHooks({
|
|
|
244
262
|
[
|
|
245
263
|
layersRef,
|
|
246
264
|
from,
|
|
247
|
-
sketchOptions.dataOnly,
|
|
248
265
|
pluginSketchLayerCreate,
|
|
249
266
|
pluginSketchLayerFeatureAdd,
|
|
250
267
|
onSketchFeatureCreate,
|
|
@@ -464,7 +481,7 @@ export default function useHooks({
|
|
|
464
481
|
);
|
|
465
482
|
|
|
466
483
|
const handleRightClick = useCallback(() => {
|
|
467
|
-
if (!
|
|
484
|
+
if (!allowRightClickToAbortEnabledRef.current) {
|
|
468
485
|
return;
|
|
469
486
|
}
|
|
470
487
|
if (type !== undefined) {
|
|
@@ -473,7 +490,7 @@ export default function useHooks({
|
|
|
473
490
|
if (state.matches("idle")) return;
|
|
474
491
|
send({ type: "ABORT" });
|
|
475
492
|
updateGeometryOptions(undefined);
|
|
476
|
-
}, [type, state,
|
|
493
|
+
}, [type, state, send, updateGeometryOptions]);
|
|
477
494
|
|
|
478
495
|
const mouseDownEventRef = useRef<MouseEventCallback>(handleLeftDown);
|
|
479
496
|
mouseDownEventRef.current = handleLeftDown;
|
|
@@ -569,41 +586,44 @@ export default function useHooks({
|
|
|
569
586
|
useEffect(() => {
|
|
570
587
|
if (type) {
|
|
571
588
|
overrideInteractionMode?.("sketch");
|
|
572
|
-
} else if (
|
|
589
|
+
} else if (allowAutoResetInteractionModeRef.current) {
|
|
573
590
|
overrideInteractionMode?.("default");
|
|
574
591
|
}
|
|
575
592
|
|
|
576
593
|
onSketchTypeChange?.(type, from);
|
|
577
|
-
}, [
|
|
578
|
-
type,
|
|
579
|
-
from,
|
|
580
|
-
sketchOptions.autoResetInteractionMode,
|
|
581
|
-
overrideInteractionMode,
|
|
582
|
-
onSketchTypeChange,
|
|
583
|
-
]);
|
|
584
|
-
|
|
585
|
-
// API
|
|
586
|
-
const getType = useGet(type);
|
|
587
|
-
const getOptions = useGet(sketchOptions);
|
|
594
|
+
}, [type, from, overrideInteractionMode, onSketchTypeChange]);
|
|
588
595
|
|
|
589
596
|
useImperativeHandle(
|
|
590
597
|
ref,
|
|
591
598
|
() => ({
|
|
592
|
-
getType,
|
|
593
599
|
setType,
|
|
594
|
-
|
|
595
|
-
|
|
600
|
+
setColor,
|
|
601
|
+
setDefaultAppearance,
|
|
602
|
+
createDataOnly,
|
|
603
|
+
disableShadow: setDisableShadow,
|
|
604
|
+
enableRelativeHeight: setEnableRelativeHeight,
|
|
605
|
+
allowRightClickToAbort,
|
|
606
|
+
allowAutoResetInteractionMode,
|
|
596
607
|
}),
|
|
597
|
-
[
|
|
608
|
+
[
|
|
609
|
+
setType,
|
|
610
|
+
setColor,
|
|
611
|
+
setDisableShadow,
|
|
612
|
+
setEnableRelativeHeight,
|
|
613
|
+
setDefaultAppearance,
|
|
614
|
+
createDataOnly,
|
|
615
|
+
allowRightClickToAbort,
|
|
616
|
+
allowAutoResetInteractionMode,
|
|
617
|
+
],
|
|
598
618
|
);
|
|
599
619
|
|
|
600
620
|
return {
|
|
601
621
|
state,
|
|
602
622
|
extrudedHeight,
|
|
603
623
|
geometryOptions,
|
|
604
|
-
color
|
|
605
|
-
disableShadow
|
|
606
|
-
enableRelativeHeight
|
|
624
|
+
color,
|
|
625
|
+
disableShadow,
|
|
626
|
+
enableRelativeHeight,
|
|
607
627
|
} as any;
|
|
608
628
|
}
|
|
609
629
|
|
package/src/Map/Sketch/index.tsx
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
// Reference: Sketch feature is basically referenced from https://github.com/takram-design-engineering/plateau-view/blob/main/libs/sketch/src/SketchTool.tsx
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { type LineString, type MultiPolygon, type Polygon } from "geojson";
|
|
4
|
+
import { ComponentType, ForwardRefRenderFunction, RefObject, forwardRef } from "react";
|
|
5
|
+
import { RequireExactlyOne } from "type-fest";
|
|
4
6
|
|
|
5
7
|
import { ComputedLayer, SelectedFeatureInfo } from "../../mantle";
|
|
8
|
+
import { Position3d } from "../../types";
|
|
6
9
|
import { InteractionModeType } from "../../Visualizer/interactionMode";
|
|
7
10
|
import { EngineRef, Feature, LayerSelectionReason, LayersRef, SketchRef } from "../types";
|
|
8
11
|
|
|
9
12
|
import useHooks from "./hooks";
|
|
10
|
-
import {
|
|
13
|
+
import { SketchEventProps, SketchFeature, SketchType } from "./types";
|
|
11
14
|
|
|
12
15
|
export * from "./types";
|
|
13
16
|
|
|
17
|
+
export type SketchComponentType = ComponentType<SketchComponentProps>;
|
|
18
|
+
|
|
19
|
+
type GeometryOptions = {
|
|
20
|
+
type: SketchType;
|
|
21
|
+
controlPoints: readonly Position3d[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type SketchComponentProps = RequireExactlyOne<
|
|
25
|
+
{
|
|
26
|
+
geometry?: LineString | Polygon | MultiPolygon | null;
|
|
27
|
+
geometryOptions?: GeometryOptions | null;
|
|
28
|
+
extrudedHeight?: number;
|
|
29
|
+
disableShadow?: boolean;
|
|
30
|
+
enableRelativeHeight?: boolean;
|
|
31
|
+
color?: string;
|
|
32
|
+
},
|
|
33
|
+
"geometry" | "geometryOptions"
|
|
34
|
+
>;
|
|
35
|
+
|
|
14
36
|
export type OnLayerSelectType = (
|
|
15
37
|
layerId: string | undefined,
|
|
16
38
|
featureId: string | undefined,
|
package/src/Map/Sketch/preset.ts
CHANGED
package/src/Map/Sketch/types.ts
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import { Feature as GeojsonFeature, MultiPolygon, Polygon, Point, LineString } from "geojson";
|
|
2
|
-
import { ComponentType } from "react";
|
|
3
|
-
import { RequireExactlyOne } from "type-fest";
|
|
4
2
|
|
|
5
3
|
import { LayerAppearanceTypes } from "../../mantle";
|
|
6
4
|
import { Position3d } from "../../types";
|
|
7
5
|
|
|
8
|
-
type GeometryOptions = {
|
|
9
|
-
type: SketchType;
|
|
10
|
-
controlPoints: readonly Position3d[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type SketchComponentProps = RequireExactlyOne<
|
|
14
|
-
{
|
|
15
|
-
geometry?: LineString | Polygon | MultiPolygon | null;
|
|
16
|
-
geometryOptions?: GeometryOptions | null;
|
|
17
|
-
extrudedHeight?: number;
|
|
18
|
-
disableShadow?: boolean;
|
|
19
|
-
enableRelativeHeight?: boolean;
|
|
20
|
-
color?: string;
|
|
21
|
-
},
|
|
22
|
-
"geometry" | "geometryOptions"
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
export type SketchComponentType = ComponentType<SketchComponentProps>;
|
|
26
|
-
|
|
27
6
|
export type SketchType =
|
|
28
7
|
| "marker"
|
|
29
8
|
| "polyline"
|
|
@@ -34,16 +13,6 @@ export type SketchType =
|
|
|
34
13
|
| "extrudedRectangle"
|
|
35
14
|
| "extrudedPolygon";
|
|
36
15
|
|
|
37
|
-
export type SketchOptions = {
|
|
38
|
-
color?: string;
|
|
39
|
-
appearance?: SketchAppearance;
|
|
40
|
-
dataOnly?: boolean;
|
|
41
|
-
disableShadow?: boolean;
|
|
42
|
-
enableRelativeHeight?: boolean;
|
|
43
|
-
rightClickToAbort?: boolean;
|
|
44
|
-
autoResetInteractionMode?: boolean;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
16
|
export type GeometryOptionsXYZ = {
|
|
48
17
|
type: SketchType;
|
|
49
18
|
controlPoints: Position3d[];
|
package/src/Map/hooks.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
LayerSelectionReason,
|
|
10
10
|
ComputedLayer,
|
|
11
11
|
RequestingRenderMode,
|
|
12
|
+
SceneProperty,
|
|
12
13
|
SketchRef,
|
|
13
14
|
} from "./types";
|
|
14
15
|
import useTimelineManager, { TimelineManagerRef } from "./useTimelineManager";
|
|
@@ -23,11 +24,13 @@ export const REQUEST_RENDER_ONCE = 1;
|
|
|
23
24
|
|
|
24
25
|
export default function ({
|
|
25
26
|
ref,
|
|
27
|
+
sceneProperty,
|
|
26
28
|
timelineManagerRef,
|
|
27
29
|
cursor,
|
|
28
30
|
onLayerSelect,
|
|
29
31
|
}: {
|
|
30
32
|
ref: Ref<MapRef>;
|
|
33
|
+
sceneProperty?: SceneProperty;
|
|
31
34
|
timelineManagerRef?: TimelineManagerRef;
|
|
32
35
|
cursor?: CursorType;
|
|
33
36
|
onLayerSelect?: (
|
|
@@ -101,6 +104,7 @@ export default function ({
|
|
|
101
104
|
);
|
|
102
105
|
|
|
103
106
|
useTimelineManager({
|
|
107
|
+
init: sceneProperty?.timeline,
|
|
104
108
|
engineRef,
|
|
105
109
|
timelineManagerRef,
|
|
106
110
|
});
|
package/src/Map/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import Sketch, { SketchProps } from "./Sketch";
|
|
|
8
8
|
import type { Engine, EngineProps } from "./types";
|
|
9
9
|
|
|
10
10
|
export * from "./types";
|
|
11
|
-
export { useGet, type WrappedRef, type Undefinable } from "./utils";
|
|
11
|
+
export { useGet, type WrappedRef, type Undefinable, useOverriddenProperty } from "./utils";
|
|
12
12
|
|
|
13
13
|
export type {
|
|
14
14
|
NaiveLayer,
|
|
@@ -36,12 +36,7 @@ export type Props = {
|
|
|
36
36
|
engine?: string;
|
|
37
37
|
} & Omit<
|
|
38
38
|
LayersProps,
|
|
39
|
-
| "
|
|
40
|
-
| "clusterComponent"
|
|
41
|
-
| "selectionReason"
|
|
42
|
-
| "delegatedDataTypes"
|
|
43
|
-
| "selectedLayerId"
|
|
44
|
-
| "viewerProperty"
|
|
39
|
+
"Feature" | "clusterComponent" | "selectionReason" | "delegatedDataTypes" | "selectedLayerId"
|
|
45
40
|
> &
|
|
46
41
|
Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> &
|
|
47
42
|
Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent"> & {
|
|
@@ -59,6 +54,7 @@ function MapFn(
|
|
|
59
54
|
layers,
|
|
60
55
|
overrides,
|
|
61
56
|
timelineManagerRef,
|
|
57
|
+
sceneProperty,
|
|
62
58
|
interactionMode,
|
|
63
59
|
selectedFeature,
|
|
64
60
|
cursor,
|
|
@@ -84,6 +80,7 @@ function MapFn(
|
|
|
84
80
|
handleEngineLayerSelect,
|
|
85
81
|
} = useHooks({
|
|
86
82
|
ref,
|
|
83
|
+
sceneProperty,
|
|
87
84
|
timelineManagerRef,
|
|
88
85
|
cursor,
|
|
89
86
|
onLayerSelect,
|
|
@@ -126,7 +123,7 @@ function MapFn(
|
|
|
126
123
|
clusterComponent={currentEngine?.clusterComponent}
|
|
127
124
|
delegatedDataTypes={currentEngine.delegatedDataTypes}
|
|
128
125
|
meta={props.meta}
|
|
129
|
-
|
|
126
|
+
sceneProperty={props.property}
|
|
130
127
|
requestingRenderMode={requestingRenderMode}
|
|
131
128
|
onLayerSelect={handleLayerSelect}
|
|
132
129
|
/>
|
package/src/Map/ref.ts
CHANGED
|
@@ -103,7 +103,6 @@ const layersRefKeys: FunctionKeys<LayersRef> = {
|
|
|
103
103
|
findByTags: 1,
|
|
104
104
|
hide: 1,
|
|
105
105
|
isLayer: 1,
|
|
106
|
-
isComputedLayer: 1,
|
|
107
106
|
layers: 1,
|
|
108
107
|
override: 1,
|
|
109
108
|
replace: 1,
|
|
@@ -118,10 +117,14 @@ const layersRefKeys: FunctionKeys<LayersRef> = {
|
|
|
118
117
|
};
|
|
119
118
|
|
|
120
119
|
const sketchRefKeys: FunctionKeys<SketchRef> = {
|
|
121
|
-
getType: 1,
|
|
122
120
|
setType: 1,
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
setColor: 1,
|
|
122
|
+
setDefaultAppearance: 1,
|
|
123
|
+
createDataOnly: 1,
|
|
124
|
+
disableShadow: 1,
|
|
125
|
+
enableRelativeHeight: 1,
|
|
126
|
+
allowRightClickToAbort: 1,
|
|
127
|
+
allowAutoResetInteractionMode: 1,
|
|
125
128
|
};
|
|
126
129
|
|
|
127
130
|
export function mapRef({
|