@reearth/core 0.0.7-alpha.30 → 0.0.7-alpha.31

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/index.d.ts CHANGED
@@ -374,9 +374,7 @@ export declare type Credit = {
374
374
  html?: string;
375
375
  };
376
376
 
377
- export declare type CursorType = "auto" | "grab" | "crosshair";
378
-
379
- declare type CursorType_2 = "default" | "auto" | "help" | "pointer" | "grab" | "crosshair";
377
+ declare type CursorType = "default" | "auto" | "help" | "pointer" | "grab" | "crosshair";
380
378
 
381
379
  export declare type Data = {
382
380
  type: DataType;
@@ -557,7 +555,7 @@ export declare type EngineRef = {
557
555
  type: SketchType;
558
556
  controlPoints: Position3d[];
559
557
  }) => LineString | Polygon_2 | MultiPolygon | Point | undefined;
560
- setCursor: (cursor: CursorType_2) => void;
558
+ setCursor: (cursor: CursorType) => void;
561
559
  flyTo: FlyTo;
562
560
  flyToBBox: (bbox: [number, number, number, number], options?: CameraOptions & {
563
561
  heading?: number;
@@ -1093,9 +1091,7 @@ declare const Map_2: ForwardRefExoticComponent< {
1093
1091
  engines?: Record<string, Engine> | undefined;
1094
1092
  engine?: string | undefined;
1095
1093
  onAPIReady?: (() => void) | undefined;
1096
- } & Omit<Props_2, "Feature" | "viewerProperty" | "selectionReason" | "delegatedDataTypes" | "clusterComponent" | "selectedLayerId"> & Omit<EngineProps, "onLayerSelect" | "selectedLayerId" | "layerSelectionReason"> & Omit<SketchProps, "engineRef" | "SketchComponent" | "layersRef"> & {
1097
- cursor?: CursorType | undefined;
1098
- } & RefAttributes<MapRef>>;
1094
+ } & Omit<Props_2, "Feature" | "viewerProperty" | "selectionReason" | "delegatedDataTypes" | "clusterComponent" | "selectedLayerId"> & Omit<EngineProps, "onLayerSelect" | "selectedLayerId" | "layerSelectionReason"> & Omit<SketchProps, "engineRef" | "SketchComponent" | "layersRef"> & RefAttributes<MapRef>>;
1099
1095
  export { Map_2 as Map }
1100
1096
 
1101
1097
  export declare type MapRef = {
@@ -1338,9 +1334,7 @@ export declare type Props = {
1338
1334
  engines?: Record<string, Engine>;
1339
1335
  engine?: string;
1340
1336
  onAPIReady?: () => void;
1341
- } & Omit<Props_2, "Feature" | "clusterComponent" | "selectionReason" | "delegatedDataTypes" | "selectedLayerId" | "viewerProperty"> & Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> & Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent"> & {
1342
- cursor?: CursorType;
1343
- };
1337
+ } & Omit<Props_2, "Feature" | "clusterComponent" | "selectionReason" | "delegatedDataTypes" | "selectedLayerId" | "viewerProperty"> & Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> & Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent">;
1344
1338
 
1345
1339
  declare type Props_2 = Omit<Props_3, "atomMap" | "isHidden" | "selectedLayerId"> & {
1346
1340
  selectedLayer?: {
@@ -1600,9 +1594,16 @@ export declare type Spacing = {
1600
1594
  declare type SpatialIdPickSpaceOptions = {
1601
1595
  zoom?: number;
1602
1596
  maxHeight?: number;
1603
- color?: string;
1597
+ minHeight?: number;
1604
1598
  dataOnly?: boolean;
1605
1599
  rightClickToExit?: boolean;
1600
+ color?: string;
1601
+ outlineColor?: string;
1602
+ groundIndicatorColor?: string;
1603
+ selectorColor?: string;
1604
+ selectorOutlineColor?: string;
1605
+ verticalSpaceIndicatorColor?: string;
1606
+ verticalSpaceIndicatorOutlineColor?: string;
1606
1607
  };
1607
1608
 
1608
1609
  declare type SpatialIdRef = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reearth/core",
3
- "version": "0.0.7-alpha.30",
3
+ "version": "0.0.7-alpha.31",
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.",
@@ -90,10 +90,16 @@ export default function ({
90
90
  const [type, updateType] = useState<SketchType | undefined>();
91
91
  const [from, updateFrom] = useState<"editor" | "plugin">("editor");
92
92
 
93
- const setType = useCallback((type: SketchType | undefined, from?: "editor" | "plugin") => {
94
- updateType(type);
95
- updateFrom(from ?? "editor");
96
- }, []);
93
+ const setType = useCallback(
94
+ (type: SketchType | undefined, from?: "editor" | "plugin") => {
95
+ updateType(type);
96
+ updateFrom(from ?? "editor");
97
+ if (type) {
98
+ engineRef.current?.setCursor("crosshair");
99
+ }
100
+ },
101
+ [engineRef],
102
+ );
97
103
 
98
104
  const [disableInteraction, setDisableInteraction] = useState(false);
99
105
 
@@ -611,6 +617,12 @@ export default function ({
611
617
  });
612
618
  }, [overrideInteractionMode]);
613
619
 
620
+ useEffect(() => {
621
+ if (!isEditing) {
622
+ overrideInteractionModeRef.current?.("default");
623
+ }
624
+ }, [isEditing]);
625
+
614
626
  return {
615
627
  state,
616
628
  isEditing,
@@ -0,0 +1,16 @@
1
+ import { SpatialIdPickSpaceOptions } from "./types";
2
+
3
+ export const SPATIALID_DEFAULT_OPTIONS: Required<SpatialIdPickSpaceOptions> = {
4
+ zoom: 20,
5
+ maxHeight: 4000,
6
+ minHeight: -1000,
7
+ dataOnly: false,
8
+ rightClickToExit: true,
9
+ color: "#00bebe44",
10
+ outlineColor: "#00bebe55",
11
+ groundIndicatorColor: "#00000066",
12
+ selectorColor: "#ff990099",
13
+ selectorOutlineColor: "#ff9900aa",
14
+ verticalSpaceIndicatorColor: "#ffffff33",
15
+ verticalSpaceIndicatorOutlineColor: "#ffffff55",
16
+ };
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  ForwardedRef,
3
+ RefObject,
3
4
  useCallback,
4
5
  useEffect,
5
6
  useImperativeHandle,
@@ -7,19 +8,22 @@ import {
7
8
  useRef,
8
9
  useState,
9
10
  } from "react";
10
- import { RefObject } from "use-callback-ref/dist/es5/types";
11
+ import { v4 as uuid } from "uuid";
11
12
 
12
13
  import { InteractionModeType } from "../../Visualizer";
13
14
  import { EngineRef, MouseEventProps } from "../types";
14
15
 
16
+ import { SPATIALID_DEFAULT_OPTIONS } from "./constants";
15
17
  import {
16
18
  SpatialIdRef,
17
19
  SpatialIdSpacePickingState,
18
20
  SpatialIdSpaceType,
19
21
  SpatialIdSpaceData,
20
22
  SpatialIdPickSpaceOptions,
23
+ VerticalSpaceIndicatorType,
24
+ CoordinateSelectorType,
21
25
  } from "./types";
22
- import { createSpatialIdFloorSpaces, createSpatialIdSpace, getSpaceData } from "./utils";
26
+ import { createSpatialIdSpace, getSpaceData, getVerticalLimits } from "./utils";
23
27
 
24
28
  type Props = {
25
29
  ref: ForwardedRef<SpatialIdRef>;
@@ -30,12 +34,6 @@ type Props = {
30
34
  onMount?: () => void;
31
35
  };
32
36
 
33
- export const SPATIALID_DEFAULT_ZOOM = 20;
34
- export const SPATIALID_DEFAULT_MAX_HEIGHT = 1000;
35
- export const SPATIALID_DEFAULT_COLOR = "#00bebe";
36
- export const SPATIALID_DEFAULT_DATA_ONLY = false;
37
- export const SPATIALID_DEFAULT_RIGHT_CLICK_TO_EXIT = true;
38
-
39
37
  export default ({
40
38
  ref,
41
39
  engineRef,
@@ -46,32 +44,65 @@ export default ({
46
44
  }: Props) => {
47
45
  const [state, setState] = useState<SpatialIdSpacePickingState>("idle");
48
46
 
49
- const [spatialIdSpaces, setSpatialIdSpaces] = useState<SpatialIdSpaceType[]>([]);
50
- const [floorSpaces, setFloorSpaces] = useState<SpatialIdSpaceType[]>([]);
51
- const [selectorSpace, setSelectorSpace] = useState<SpatialIdSpaceType | null>(null);
52
-
53
- const spaces = useMemo(() => {
54
- return [...spatialIdSpaces, ...floorSpaces, ...(selectorSpace ? [selectorSpace] : [])];
55
- }, [spatialIdSpaces, floorSpaces, selectorSpace]);
47
+ const [spatialIdSpaces, setSpatialIdSpaces] = useState<SpatialIdSpaceType[] | null>(null);
48
+ const [verticalSpaceIndicator, setVerticalSpaceIndicator] =
49
+ useState<VerticalSpaceIndicatorType | null>(null);
50
+ const [coordinateSelector, setCoordinateSelector] = useState<CoordinateSelectorType | null>(null);
51
+ const [spaceSelector, setSpaceSelector] = useState<SpatialIdSpaceType | null>(null);
56
52
 
57
53
  const [basePosition, setBasePosition] = useState<[number, number, number] | null>(null);
58
54
  const [baseCoordinate, setBaseCoordinate] = useState<[number, number, number] | null>(null);
59
55
 
60
- const [pickOptions, setPickOptions] = useState<Required<SpatialIdPickSpaceOptions>>({
61
- zoom: SPATIALID_DEFAULT_ZOOM,
62
- maxHeight: SPATIALID_DEFAULT_MAX_HEIGHT,
63
- color: SPATIALID_DEFAULT_COLOR,
64
- dataOnly: SPATIALID_DEFAULT_DATA_ONLY,
65
- rightClickToExit: SPATIALID_DEFAULT_RIGHT_CLICK_TO_EXIT,
66
- });
56
+ const [pickOptions, setPickOptions] =
57
+ useState<Required<SpatialIdPickSpaceOptions>>(SPATIALID_DEFAULT_OPTIONS);
58
+
59
+ const verticalLimits = useMemo(
60
+ () => getVerticalLimits(pickOptions.maxHeight, pickOptions.minHeight, pickOptions.zoom),
61
+ [pickOptions.maxHeight, pickOptions.minHeight, pickOptions.zoom],
62
+ );
63
+
64
+ const groundIndicators = useMemo(() => {
65
+ const allSpaces = [...(spatialIdSpaces ?? []), ...(spaceSelector ? [spaceSelector] : [])];
66
+
67
+ if (!allSpaces) return null;
68
+ // find unique spaces by space.space.zfxy.z, space.space.zfxy.x, space.space.zfxy.y
69
+ const uniqueSpaces = allSpaces.reduce((acc, space) => {
70
+ if (
71
+ !acc.find(
72
+ s =>
73
+ s.space.zfxy.z === space.space.zfxy.z &&
74
+ s.space.zfxy.x === space.space.zfxy.x &&
75
+ s.space.zfxy.y === space.space.zfxy.y,
76
+ )
77
+ ) {
78
+ acc.push(space);
79
+ }
80
+ return acc;
81
+ }, [] as SpatialIdSpaceType[]);
82
+
83
+ if (uniqueSpaces.length === 0) return null;
84
+
85
+ return uniqueSpaces.map(space => {
86
+ const { wsen } = space;
87
+ return {
88
+ id: uuid(),
89
+ spaceId: space.space.id,
90
+ wsen,
91
+ color: pickOptions.groundIndicatorColor,
92
+ };
93
+ });
94
+ }, [spatialIdSpaces, spaceSelector, pickOptions.groundIndicatorColor]);
67
95
 
68
96
  const pickSpace = useCallback(
69
97
  (options?: SpatialIdPickSpaceOptions) => {
70
98
  setState("coordinate");
71
99
  setPickOptions(prev => ({ ...prev, ...options }));
72
100
  overrideInteractionMode?.("spatialId");
101
+ setTimeout(() => {
102
+ engineRef.current?.setCursor("crosshair");
103
+ }, 100);
73
104
  },
74
- [overrideInteractionMode],
105
+ [engineRef, overrideInteractionMode],
75
106
  );
76
107
 
77
108
  const interactionModeRef = useRef(interactionMode);
@@ -79,26 +110,29 @@ export default ({
79
110
 
80
111
  const finishPicking = useCallback(() => {
81
112
  setState("idle");
82
- setSelectorSpace(null);
83
113
  setBasePosition(null);
84
114
  setBaseCoordinate(null);
85
- setFloorSpaces([]);
115
+ setSpaceSelector(null);
116
+ setCoordinateSelector(null);
117
+ setVerticalSpaceIndicator(null);
86
118
  overrideInteractionMode?.(
87
119
  interactionModeRef.current === "spatialId"
88
120
  ? "default"
89
121
  : interactionModeRef.current ?? "default",
90
122
  );
123
+ engineRef.current?.setCursor("default");
91
124
  engineRef.current?.requestRender();
92
125
  }, [overrideInteractionMode, engineRef]);
93
126
 
94
- // handle events
95
127
  const handleMouseUp = useCallback(
96
128
  (props: MouseEventProps) => {
97
129
  if (state === "idle") return;
98
130
  if (tempSwitchToMoveMode.current) return;
99
131
 
132
+ // handle coordinate picking
100
133
  if (state === "coordinate") {
101
- if (!selectorSpace || props.lat === undefined || props.lng === undefined) return;
134
+ if (!coordinateSelector || props.lat === undefined || props.lng === undefined) return;
135
+
102
136
  setState("floor");
103
137
  setBaseCoordinate([props.lng, props.lat, terrainEnabled ? props.height ?? 0 : 0]);
104
138
  setBasePosition(
@@ -107,27 +141,47 @@ export default ({
107
141
  }) ?? null,
108
142
  );
109
143
 
110
- setSelectorSpace(prev =>
111
- prev ? { ...prev, type: "selector", color: pickOptions.color } : null,
144
+ setCoordinateSelector(null);
145
+
146
+ const initialSpaceSelectorSpace = createSpatialIdSpace(
147
+ props.lng,
148
+ props.lat,
149
+ terrainEnabled ? props.height ?? 0 : 0,
150
+ pickOptions.zoom,
112
151
  );
152
+ setSpaceSelector({
153
+ ...initialSpaceSelectorSpace,
154
+ color: pickOptions.color,
155
+ outlineColor: pickOptions.outlineColor,
156
+ });
113
157
 
114
- const floorSpaces = createSpatialIdFloorSpaces(
115
- selectorSpace.space,
116
- pickOptions.maxHeight,
117
- pickOptions.color,
158
+ const { id, wsen } = createSpatialIdSpace(
159
+ props.lng,
160
+ props.lat,
161
+ terrainEnabled ? props.height ?? 0 : 0,
162
+ pickOptions.zoom,
118
163
  );
119
- setFloorSpaces(floorSpaces);
164
+ setVerticalSpaceIndicator({
165
+ id,
166
+ wsen,
167
+ height: verticalLimits.top,
168
+ extrudedHeight: verticalLimits.bottom,
169
+ color: pickOptions.verticalSpaceIndicatorColor,
170
+ outlineColor: pickOptions.verticalSpaceIndicatorOutlineColor,
171
+ });
172
+ engineRef.current?.requestRender();
120
173
  } else if (state === "floor") {
121
- if (!selectorSpace) return;
174
+ if (!spaceSelector) return;
122
175
 
123
176
  const confirmedSpace: SpatialIdSpaceType = {
124
- ...selectorSpace,
125
- type: "confirmed",
177
+ ...spaceSelector,
178
+ id: uuid(),
126
179
  color: pickOptions.color,
180
+ outlineColor: pickOptions.outlineColor,
127
181
  };
128
182
 
129
183
  if (!pickOptions.dataOnly) {
130
- setSpatialIdSpaces(prev => [...prev, confirmedSpace]);
184
+ setSpatialIdSpaces(prev => (prev ? [...prev, confirmedSpace] : [confirmedSpace]));
131
185
  }
132
186
 
133
187
  finishPicking();
@@ -136,7 +190,16 @@ export default ({
136
190
  onSpacePickEvents.current.forEach(cb => cb(spaceData));
137
191
  }
138
192
  },
139
- [state, terrainEnabled, engineRef, selectorSpace, pickOptions, finishPicking],
193
+ [
194
+ state,
195
+ terrainEnabled,
196
+ engineRef,
197
+ spaceSelector,
198
+ pickOptions,
199
+ verticalLimits,
200
+ coordinateSelector,
201
+ finishPicking,
202
+ ],
140
203
  );
141
204
 
142
205
  const handleMouseMove = useCallback(
@@ -154,9 +217,13 @@ export default ({
154
217
  pickOptions.zoom,
155
218
  );
156
219
 
157
- if (newSpace.space.id === selectorSpace?.space.id) return;
158
-
159
- setSelectorSpace({ ...newSpace, type: "coordinate", color: pickOptions.color });
220
+ if (newSpace.space.id === coordinateSelector?.spaceId) return;
221
+ setCoordinateSelector({
222
+ id: uuid(),
223
+ spaceId: newSpace.space.id,
224
+ wsen: newSpace.wsen,
225
+ color: pickOptions.selectorColor,
226
+ });
160
227
  } else if (state === "floor") {
161
228
  if (
162
229
  props.x === undefined ||
@@ -166,24 +233,42 @@ export default ({
166
233
  )
167
234
  return;
168
235
 
169
- const height =
236
+ const offset =
170
237
  engineRef.current?.getExtrudedHeight(basePosition, [props.x, props.y], true) ?? 0;
171
238
 
172
- if (baseCoordinate[2] + height > pickOptions.maxHeight) return;
239
+ if (
240
+ baseCoordinate[2] + offset > verticalLimits.top ||
241
+ baseCoordinate[2] + offset < verticalLimits.bottom
242
+ )
243
+ return;
173
244
 
174
245
  const newSpace = createSpatialIdSpace(
175
246
  baseCoordinate[0],
176
247
  baseCoordinate[1],
177
- baseCoordinate[2] + height,
248
+ baseCoordinate[2] + offset,
178
249
  pickOptions.zoom,
179
250
  );
180
251
 
181
- if (newSpace.space.id === selectorSpace?.space.id || newSpace.space.zfxy.f < 0) return;
252
+ if (newSpace.space.id === spaceSelector?.space.id) return;
182
253
 
183
- setSelectorSpace({ ...newSpace, type: "selector", color: pickOptions.color });
254
+ setSpaceSelector({
255
+ ...newSpace,
256
+ color: pickOptions.selectorColor,
257
+ outlineColor: pickOptions.selectorOutlineColor,
258
+ });
184
259
  }
185
260
  },
186
- [state, selectorSpace, basePosition, baseCoordinate, engineRef, terrainEnabled, pickOptions],
261
+ [
262
+ state,
263
+ spaceSelector,
264
+ basePosition,
265
+ baseCoordinate,
266
+ engineRef,
267
+ terrainEnabled,
268
+ pickOptions,
269
+ verticalLimits,
270
+ coordinateSelector?.spaceId,
271
+ ],
187
272
  );
188
273
 
189
274
  const handleMouseRightClick = useCallback(() => {
@@ -191,10 +276,10 @@ export default ({
191
276
  if (state === "coordinate" && pickOptions.rightClickToExit) {
192
277
  finishPicking();
193
278
  } else if (state === "floor") {
194
- setSelectorSpace(null);
279
+ setSpaceSelector(null);
195
280
  setBasePosition(null);
196
281
  setBaseCoordinate(null);
197
- setFloorSpaces([]);
282
+ setVerticalSpaceIndicator(null);
198
283
  setState("coordinate");
199
284
  }
200
285
  engineRef.current?.requestRender();
@@ -288,6 +373,10 @@ export default ({
288
373
  }, [onMount]);
289
374
 
290
375
  return {
291
- spaces,
376
+ spatialIdSpaces,
377
+ verticalSpaceIndicator,
378
+ coordinateSelector,
379
+ spaceSelector,
380
+ groundIndicators,
292
381
  };
293
382
  };
@@ -1,7 +1,10 @@
1
- import { forwardRef, ForwardRefRenderFunction } from "react";
2
- import { RefObject } from "use-callback-ref/dist/es5/types";
1
+ import { forwardRef, ForwardRefRenderFunction, RefObject } from "react";
3
2
 
4
- import SpatialIdSpace from "../../engines/Cesium/SpatialId";
3
+ import {
4
+ CoordinateIndicator,
5
+ SpatialIdSpace,
6
+ VerticalSpaceIndicator,
7
+ } from "../../engines/Cesium/SpatialId";
5
8
  import { InteractionModeType } from "../../Visualizer";
6
9
  import { EngineRef } from "../types";
7
10
 
@@ -20,7 +23,13 @@ const SpatialId: ForwardRefRenderFunction<SpatialIdRef, SpatialIdProps> = (
20
23
  { engineRef, terrainEnabled, interactionMode, overrideInteractionMode, onMount },
21
24
  ref,
22
25
  ) => {
23
- const { spaces } = useHooks({
26
+ const {
27
+ spatialIdSpaces,
28
+ verticalSpaceIndicator,
29
+ coordinateSelector,
30
+ spaceSelector,
31
+ groundIndicators,
32
+ } = useHooks({
24
33
  ref,
25
34
  engineRef,
26
35
  terrainEnabled,
@@ -28,9 +37,24 @@ const SpatialId: ForwardRefRenderFunction<SpatialIdRef, SpatialIdProps> = (
28
37
  overrideInteractionMode,
29
38
  onMount,
30
39
  });
31
- return spaces.length > 0
32
- ? spaces.map(space => <SpatialIdSpace key={space.id} space={space} />)
33
- : null;
40
+
41
+ return (
42
+ <>
43
+ {spatialIdSpaces &&
44
+ spatialIdSpaces.length > 0 &&
45
+ spatialIdSpaces.map(space => <SpatialIdSpace key={space.id} space={space} />)}
46
+ {groundIndicators &&
47
+ groundIndicators.length > 0 &&
48
+ groundIndicators.map(indicator => (
49
+ <CoordinateIndicator key={indicator.id} wsen={indicator.wsen} color={indicator.color} />
50
+ ))}
51
+ {verticalSpaceIndicator && <VerticalSpaceIndicator indicator={verticalSpaceIndicator} />}
52
+ {coordinateSelector && (
53
+ <CoordinateIndicator wsen={coordinateSelector.wsen} color={coordinateSelector.color} />
54
+ )}
55
+ {spaceSelector && <SpatialIdSpace space={spaceSelector} />}
56
+ </>
57
+ );
34
58
  };
35
59
 
36
60
  export default forwardRef(SpatialId);
@@ -6,16 +6,39 @@ export type SpatialIdSpaceType = {
6
6
  wsen: [number, number, number, number];
7
7
  height: number;
8
8
  extrudedHeight: number;
9
- type?: "selector" | "floor" | "coordinate" | "confirmed";
10
9
  color?: string;
10
+ outlineColor?: string;
11
+ };
12
+
13
+ export type VerticalSpaceIndicatorType = {
14
+ id: string;
15
+ wsen: [number, number, number, number];
16
+ height: number;
17
+ extrudedHeight: number;
18
+ color: string;
19
+ outlineColor: string;
20
+ };
21
+
22
+ export type CoordinateSelectorType = {
23
+ id: string;
24
+ spaceId: string;
25
+ wsen: [number, number, number, number];
26
+ color: string;
11
27
  };
12
28
 
13
29
  export type SpatialIdPickSpaceOptions = {
14
30
  zoom?: number;
15
31
  maxHeight?: number;
16
- color?: string;
32
+ minHeight?: number;
17
33
  dataOnly?: boolean;
18
34
  rightClickToExit?: boolean;
35
+ color?: string;
36
+ outlineColor?: string;
37
+ groundIndicatorColor?: string;
38
+ selectorColor?: string;
39
+ selectorOutlineColor?: string;
40
+ verticalSpaceIndicatorColor?: string;
41
+ verticalSpaceIndicatorOutlineColor?: string;
19
42
  };
20
43
 
21
44
  export type SpatialIdRef = {
@@ -1,7 +1,7 @@
1
- import { Space } from "@reearth/spatial-id-sdk";
2
1
  import { v4 as uuid } from "uuid";
3
2
 
4
- import { SPATIALID_DEFAULT_COLOR, SPATIALID_DEFAULT_MAX_HEIGHT } from "./hooks";
3
+ import { Space } from "@reearth/spatial-id-sdk";
4
+
5
5
  import { SpatialIdSpaceType, SpatialIdSpaceData } from "./types";
6
6
 
7
7
  const getRectangeParamsFromSpace = (space: Space) => {
@@ -35,34 +35,6 @@ export const createSpatialIdSpace = (
35
35
  };
36
36
  };
37
37
 
38
- export const createSpatialIdFloorSpaces = (
39
- space: Space,
40
- maxHeight = SPATIALID_DEFAULT_MAX_HEIGHT,
41
- color = SPATIALID_DEFAULT_COLOR,
42
- ) => {
43
- const floorSpaces: SpatialIdSpaceType[] = [];
44
- const { height, extrudedHeight } = getRectangeParamsFromSpace(space);
45
- const heightStep = extrudedHeight - height;
46
- for (let h = 0; h < maxHeight; h += heightStep) {
47
- const fSpace = new Space({ lat: space.center.lat, lng: space.center.lng, alt: h }, space.zoom);
48
- const {
49
- wsen: fWsen,
50
- height: fHeight,
51
- extrudedHeight: fExtrudedHeight,
52
- } = getRectangeParamsFromSpace(fSpace);
53
- floorSpaces.push({
54
- id: uuid(),
55
- space: fSpace,
56
- wsen: fWsen,
57
- height: fHeight,
58
- extrudedHeight: fExtrudedHeight,
59
- type: "floor",
60
- color,
61
- });
62
- }
63
- return floorSpaces;
64
- };
65
-
66
38
  export const getSpaceData = (space: Space): SpatialIdSpaceData => {
67
39
  return {
68
40
  id: space.id,
@@ -77,3 +49,16 @@ export const getSpaceData = (space: Space): SpatialIdSpaceData => {
77
49
  vertices: space.vertices3d(),
78
50
  };
79
51
  };
52
+
53
+ export const getVerticalLimits = (
54
+ maxHeigth: number,
55
+ minHeight: number,
56
+ zoom: number,
57
+ ): { top: number; bottom: number } => {
58
+ // lat/lng doesn't matter
59
+ const topSpace = new Space({ lat: 0, lng: 0, alt: maxHeigth }, zoom);
60
+ const bottomSpace = new Space({ lat: 0, lng: 0, alt: minHeight }, zoom);
61
+ const { height } = getRectangeParamsFromSpace(topSpace);
62
+ const { extrudedHeight } = getRectangeParamsFromSpace(bottomSpace);
63
+ return { top: height, bottom: extrudedHeight };
64
+ };
package/src/Map/hooks.ts CHANGED
@@ -14,7 +14,7 @@ import type {
14
14
  } from "./types";
15
15
  import useTimelineManager, { TimelineManagerRef } from "./useTimelineManager";
16
16
 
17
- import { CursorType, SketchEditingFeature } from ".";
17
+ import { SketchEditingFeature } from ".";
18
18
 
19
19
  export type { MapRef } from "./ref";
20
20
 
@@ -25,14 +25,12 @@ export const REQUEST_RENDER_ONCE = 1;
25
25
  export default function ({
26
26
  ref,
27
27
  timelineManagerRef,
28
- cursor,
29
28
  onLayerSelect,
30
29
  onMount,
31
30
  onAPIReady,
32
31
  }: {
33
32
  ref: Ref<MapRef>;
34
33
  timelineManagerRef?: TimelineManagerRef;
35
- cursor?: CursorType;
36
34
  onLayerSelect?: (
37
35
  layerId: string | undefined,
38
36
  featureId: string | undefined,
@@ -130,12 +128,6 @@ export default function ({
130
128
  timelineManagerRef,
131
129
  });
132
130
 
133
- useEffect(() => {
134
- if (cursor) {
135
- engineRef.current?.setCursor(cursor);
136
- }
137
- }, [cursor]);
138
-
139
131
  const [sketchEditingFeature, setSketchEditingFeature] = useState<
140
132
  SketchEditingFeature | undefined
141
133
  >();
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,