@reearth/core 0.0.7-alpha.30 → 0.0.7-alpha.32
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 +3016 -2905
- package/dist/core.umd.cjs +69 -69
- package/dist/index.d.ts +12 -11
- package/package.json +1 -1
- package/src/Map/Sketch/hooks.ts +17 -5
- package/src/Map/SpatialId/constants.ts +16 -0
- package/src/Map/SpatialId/hooks.ts +156 -52
- package/src/Map/SpatialId/index.tsx +31 -7
- package/src/Map/SpatialId/types.ts +25 -2
- package/src/Map/SpatialId/utils.ts +15 -30
- package/src/Map/hooks.ts +1 -9
- package/src/Map/index.tsx +1 -7
- package/src/Visualizer/hooks.ts +6 -10
- package/src/Visualizer/index.tsx +0 -2
- package/src/engines/Cesium/Feature/Polygon/index.tsx +1 -1
- package/src/engines/Cesium/SpatialId/CoordinateIndicator.tsx +28 -0
- package/src/engines/Cesium/SpatialId/SpatialIdSpace.tsx +33 -0
- package/src/engines/Cesium/SpatialId/VerticalSpaceIndicator.tsx +32 -0
- package/src/engines/Cesium/SpatialId/index.ts +3 -0
- package/src/engines/Cesium/SpatialId/index.tsx +0 -42
- /package/src/{Map/Sketch/utils.ts → utils/use-window-event.ts} +0 -0
package/src/Map/index.tsx
CHANGED
|
@@ -30,8 +30,6 @@ export type { TimelineCommitter, TimelineManagerRef } from "./useTimelineManager
|
|
|
30
30
|
|
|
31
31
|
export type { MapRef } from "./hooks";
|
|
32
32
|
|
|
33
|
-
export type CursorType = "auto" | "grab" | "crosshair";
|
|
34
|
-
|
|
35
33
|
export type Props = {
|
|
36
34
|
engines?: Record<string, Engine>;
|
|
37
35
|
engine?: string;
|
|
@@ -46,9 +44,7 @@ export type Props = {
|
|
|
46
44
|
| "viewerProperty"
|
|
47
45
|
> &
|
|
48
46
|
Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> &
|
|
49
|
-
Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent"
|
|
50
|
-
cursor?: CursorType;
|
|
51
|
-
};
|
|
47
|
+
Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent">;
|
|
52
48
|
|
|
53
49
|
function MapFn(
|
|
54
50
|
{
|
|
@@ -63,7 +59,6 @@ function MapFn(
|
|
|
63
59
|
timelineManagerRef,
|
|
64
60
|
interactionMode,
|
|
65
61
|
selectedFeature,
|
|
66
|
-
cursor,
|
|
67
62
|
onLayerSelect,
|
|
68
63
|
overrideInteractionMode,
|
|
69
64
|
onSketchTypeChange,
|
|
@@ -100,7 +95,6 @@ function MapFn(
|
|
|
100
95
|
} = useHooks({
|
|
101
96
|
ref,
|
|
102
97
|
timelineManagerRef,
|
|
103
|
-
cursor,
|
|
104
98
|
onLayerSelect,
|
|
105
99
|
onMount,
|
|
106
100
|
onAPIReady,
|
package/src/Visualizer/hooks.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type {
|
|
|
7
7
|
Camera,
|
|
8
8
|
ComputedLayer,
|
|
9
9
|
LayerEditEvent,
|
|
10
|
-
CursorType,
|
|
11
10
|
LayerVisibilityEvent,
|
|
12
11
|
LayerLoadEvent,
|
|
13
12
|
LayerSelectWithRectStart,
|
|
@@ -131,21 +130,19 @@ export default function useHooks(
|
|
|
131
130
|
}, []);
|
|
132
131
|
|
|
133
132
|
// interaction mode
|
|
134
|
-
const [
|
|
135
|
-
initialInteractionMode,
|
|
133
|
+
const [interactionMode, changeInteractionMode] = useValue(
|
|
134
|
+
initialInteractionMode || "default",
|
|
136
135
|
onInteractionModeChange,
|
|
137
136
|
);
|
|
138
|
-
const interactionMode = _interactionMode || "default";
|
|
139
137
|
|
|
140
|
-
const [cursor, setCursor] = useState<CursorType>("auto");
|
|
141
138
|
useEffect(() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
if (interactionMode === "default") {
|
|
140
|
+
mapRef?.current?.engine?.setCursor("auto");
|
|
141
|
+
}
|
|
145
142
|
}, [interactionMode]);
|
|
146
143
|
|
|
147
144
|
// feature flags
|
|
148
|
-
const featureFlags = INTERACTION_MODES[interactionMode];
|
|
145
|
+
const featureFlags = INTERACTION_MODES[interactionMode ?? "default"];
|
|
149
146
|
|
|
150
147
|
// layer edit
|
|
151
148
|
const onLayerEditRef = useRef<(e: LayerEditEvent) => void>();
|
|
@@ -325,7 +322,6 @@ export default function useHooks(
|
|
|
325
322
|
featureFlags,
|
|
326
323
|
isLayerDragging,
|
|
327
324
|
timelineManagerRef,
|
|
328
|
-
cursor,
|
|
329
325
|
cameraForceHorizontalRoll,
|
|
330
326
|
coreContextValue,
|
|
331
327
|
containerStyle,
|
package/src/Visualizer/index.tsx
CHANGED
|
@@ -112,7 +112,6 @@ export const CoreVisualizer = memo(
|
|
|
112
112
|
featureFlags,
|
|
113
113
|
isLayerDragging,
|
|
114
114
|
timelineManagerRef,
|
|
115
|
-
cursor,
|
|
116
115
|
cameraForceHorizontalRoll,
|
|
117
116
|
coreContextValue,
|
|
118
117
|
containerStyle,
|
|
@@ -177,7 +176,6 @@ export const CoreVisualizer = memo(
|
|
|
177
176
|
timelineManagerRef={timelineManagerRef}
|
|
178
177
|
interactionMode={overriddenInteractionMode}
|
|
179
178
|
selectedFeature={selectedFeature}
|
|
180
|
-
cursor={cursor}
|
|
181
179
|
onCameraChange={handleCameraChange}
|
|
182
180
|
onLayerDrag={handleLayerDrag}
|
|
183
181
|
onLayerDrop={handleLayerDrop}
|
|
@@ -128,7 +128,7 @@ export default function Polygon({
|
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
const extrudedHeightProperty: { extrudedHeight: number } | undefined = useMemo(
|
|
131
|
-
() => (extrudedHeight ? { extrudedHeight } : undefined),
|
|
131
|
+
() => (extrudedHeight !== undefined ? { extrudedHeight } : undefined),
|
|
132
132
|
[extrudedHeight],
|
|
133
133
|
);
|
|
134
134
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ClassificationType, Color, Rectangle } from "cesium";
|
|
2
|
+
import { FC, memo, useMemo } from "react";
|
|
3
|
+
import { Entity } from "resium";
|
|
4
|
+
|
|
5
|
+
type SpatialIdComponentProps = {
|
|
6
|
+
wsen: [number, number, number, number];
|
|
7
|
+
color: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const CoordinateIndicator: FC<SpatialIdComponentProps> = memo(({ wsen, color }) => {
|
|
11
|
+
const options = useMemo(
|
|
12
|
+
() => ({
|
|
13
|
+
rectangle: {
|
|
14
|
+
coordinates: Rectangle.fromDegrees(...wsen),
|
|
15
|
+
clampToGround: true,
|
|
16
|
+
fill: true,
|
|
17
|
+
outline: false,
|
|
18
|
+
material: Color.fromCssColorString(color),
|
|
19
|
+
classificationType: ClassificationType.BOTH,
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
[wsen, color],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return <Entity {...options} />;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
CoordinateIndicator.displayName = "SpatialIdSpace";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ClassificationType, Color, HeightReference, Rectangle } from "cesium";
|
|
2
|
+
import { FC, memo, useMemo } from "react";
|
|
3
|
+
import { Entity } from "resium";
|
|
4
|
+
|
|
5
|
+
import { SpatialIdSpaceType } from "../../../Map/SpatialId/types";
|
|
6
|
+
|
|
7
|
+
type SpatialIdComponentProps = {
|
|
8
|
+
space: SpatialIdSpaceType;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const SpatialIdSpace: FC<SpatialIdComponentProps> = memo(({ space }) => {
|
|
12
|
+
const options = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
rectangle: {
|
|
15
|
+
coordinates: Rectangle.fromDegrees(...space.wsen),
|
|
16
|
+
height: space.height,
|
|
17
|
+
heightReference: HeightReference.NONE,
|
|
18
|
+
extrudedHeight: space.extrudedHeight,
|
|
19
|
+
clampToGround: false,
|
|
20
|
+
fill: true,
|
|
21
|
+
outline: true,
|
|
22
|
+
outlineColor: Color.fromCssColorString(space.outlineColor ?? ""),
|
|
23
|
+
material: Color.fromCssColorString(space.color ?? ""),
|
|
24
|
+
classificationType: ClassificationType.TERRAIN,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
[space],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return <Entity id={space.id} {...options} />;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
SpatialIdSpace.displayName = "SpatialIdSpace";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ClassificationType, Color, Rectangle } from "cesium";
|
|
2
|
+
import { FC, memo, useMemo } from "react";
|
|
3
|
+
import { Entity } from "resium";
|
|
4
|
+
|
|
5
|
+
import { VerticalSpaceIndicatorType } from "../../../Map/SpatialId/types";
|
|
6
|
+
|
|
7
|
+
type VerticalSpaceIndicatorProps = {
|
|
8
|
+
indicator: VerticalSpaceIndicatorType;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const VerticalSpaceIndicator: FC<VerticalSpaceIndicatorProps> = memo(({ indicator }) => {
|
|
12
|
+
const options = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
rectangle: {
|
|
15
|
+
coordinates: Rectangle.fromDegrees(...indicator.wsen),
|
|
16
|
+
height: indicator.height,
|
|
17
|
+
extrudedHeight: indicator.extrudedHeight,
|
|
18
|
+
clampToGround: false,
|
|
19
|
+
fill: true,
|
|
20
|
+
outline: true,
|
|
21
|
+
outlineColor: Color.fromCssColorString(indicator.outlineColor),
|
|
22
|
+
material: Color.fromCssColorString(indicator.color),
|
|
23
|
+
classificationType: ClassificationType.TERRAIN,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
[indicator],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return <Entity {...options} />;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
VerticalSpaceIndicator.displayName = "VerticalSpaceIndicator";
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ClassificationType, Color, HeightReference, Rectangle } from "cesium";
|
|
2
|
-
import { FC, memo, useMemo } from "react";
|
|
3
|
-
import { Entity } from "resium";
|
|
4
|
-
|
|
5
|
-
import { SpatialIdSpaceType } from "../../../Map/SpatialId/types";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_COLOR = "#00bebe";
|
|
8
|
-
|
|
9
|
-
type SpatialIdComponentProps = {
|
|
10
|
-
space: SpatialIdSpaceType;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const SpatialIdSpace: FC<SpatialIdComponentProps> = memo(({ space }) => {
|
|
14
|
-
const options = useMemo(
|
|
15
|
-
() => ({
|
|
16
|
-
rectangle: {
|
|
17
|
-
coordinates: Rectangle.fromDegrees(...space.wsen),
|
|
18
|
-
height: space.type === "coordinate" ? undefined : space.height,
|
|
19
|
-
heightReference: space.type === "coordinate" ? undefined : HeightReference.NONE,
|
|
20
|
-
extrudedHeight: space.type === "coordinate" ? undefined : space.extrudedHeight,
|
|
21
|
-
clampToGround: space.type === "coordinate",
|
|
22
|
-
fill: true,
|
|
23
|
-
outline: space.type !== "coordinate",
|
|
24
|
-
outlineColor: Color.fromCssColorString(space.color ?? DEFAULT_COLOR).withAlpha(
|
|
25
|
-
space.type === "floor" ? 0.5 : 1,
|
|
26
|
-
),
|
|
27
|
-
material: Color.fromCssColorString(space.color ?? DEFAULT_COLOR).withAlpha(
|
|
28
|
-
space.type === "floor" ? 0.05 : 0.2,
|
|
29
|
-
),
|
|
30
|
-
classificationType:
|
|
31
|
-
space.type === "coordinate" ? ClassificationType.BOTH : ClassificationType.TERRAIN,
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
[space],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return <Entity id={space.id} {...options} />;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
SpatialIdSpace.displayName = "SpatialIdSpace";
|
|
41
|
-
|
|
42
|
-
export default SpatialIdSpace;
|
|
File without changes
|