@reearth/core 0.0.7-alpha.1 → 0.0.7-alpha.3
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 +10109 -10119
- package/dist/core.umd.cjs +74 -74
- package/dist/index.d.ts +44 -39
- package/package.json +4 -4
- package/src/Map/Sketch/hooks.ts +46 -66
- package/src/Map/Sketch/index.tsx +2 -24
- package/src/Map/Sketch/preset.ts +2 -0
- package/src/Map/Sketch/types.ts +31 -0
- package/src/Map/ref.ts +3 -7
- package/src/Map/types/index.ts +29 -34
- package/src/Map/types/viewerProperty.ts +3 -4
- package/src/Map/useTimelineManager.ts +3 -1
- package/src/Visualizer/useCoreAPI.ts +2 -2
- package/src/engines/Cesium/Feature/Tileset/useClippingBox.ts +10 -1
- package/src/engines/Cesium/core/Globe.tsx +7 -7
- package/src/engines/Cesium/hooks/useCamera.ts +4 -13
- package/src/engines/Cesium/hooks/useEngineRef.test.tsx +24 -24
- package/src/engines/Cesium/hooks/useEngineRef.ts +26 -24
- package/src/engines/Cesium/hooks/useOverrideGlobeShader/useOverrideGlobeShader.ts +1 -1
- package/src/engines/Cesium/hooks.ts +14 -15
- package/src/engines/Cesium/index.tsx +12 -12
- package/src/mantle/compat/types.ts +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ declare type Array_2 = any[];
|
|
|
54
54
|
export { Array_2 as Array }
|
|
55
55
|
|
|
56
56
|
export declare type AssetsCesiumProperty = {
|
|
57
|
-
|
|
57
|
+
terrain?: {
|
|
58
58
|
ionAccessToken?: string;
|
|
59
59
|
ionAsset?: string;
|
|
60
60
|
ionUrl?: string;
|
|
@@ -137,25 +137,24 @@ export declare type CameraOptions = {
|
|
|
137
137
|
/** Represents the camera position and state */
|
|
138
138
|
export declare type CameraPosition = {
|
|
139
139
|
/** degrees */
|
|
140
|
-
lat
|
|
140
|
+
lat?: number;
|
|
141
141
|
/** degrees */
|
|
142
|
-
lng
|
|
142
|
+
lng?: number;
|
|
143
143
|
/** meters */
|
|
144
|
-
height
|
|
144
|
+
height?: number;
|
|
145
145
|
/** radians */
|
|
146
|
-
heading
|
|
146
|
+
heading?: number;
|
|
147
147
|
/** radians */
|
|
148
|
-
pitch
|
|
148
|
+
pitch?: number;
|
|
149
149
|
/** radians */
|
|
150
|
-
roll
|
|
150
|
+
roll?: number;
|
|
151
151
|
/** Field of view expressed in radians */
|
|
152
|
-
fov
|
|
152
|
+
fov?: number;
|
|
153
153
|
/** Aspect ratio of frustum */
|
|
154
154
|
aspectRatio?: number;
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
export declare type CameraProperty = {
|
|
158
|
-
camera?: Camera;
|
|
159
158
|
allowEnterGround?: boolean;
|
|
160
159
|
limiter?: CameraLimiterProperty;
|
|
161
160
|
};
|
|
@@ -422,6 +421,14 @@ export declare type DefaultInfobox = {
|
|
|
422
421
|
};
|
|
423
422
|
};
|
|
424
423
|
|
|
424
|
+
export declare type ElevationHeatMapProperty = {
|
|
425
|
+
type?: "custom";
|
|
426
|
+
colorLUT?: LUT;
|
|
427
|
+
minHeight?: number;
|
|
428
|
+
maxHeight?: number;
|
|
429
|
+
logarithmic?: boolean;
|
|
430
|
+
};
|
|
431
|
+
|
|
425
432
|
export declare type EllipseAppearance = {
|
|
426
433
|
show?: boolean;
|
|
427
434
|
heightReference?: "none" | "clamp" | "relative";
|
|
@@ -513,7 +520,7 @@ export declare type EngineRef = {
|
|
|
513
520
|
getLocationFromScreen: (x: number, y: number, withTerrain?: boolean) => LatLngHeight | undefined;
|
|
514
521
|
sampleTerrainHeight: (lng: number, lat: number) => Promise<number | undefined>;
|
|
515
522
|
computeGlobeHeight: (lng: number, lat: number, height?: number) => number | undefined;
|
|
516
|
-
getGlobeHeight: () =>
|
|
523
|
+
getGlobeHeight: () => number | undefined;
|
|
517
524
|
toXYZ: (lng: number, lat: number, height: number, options?: {
|
|
518
525
|
useGlobeEllipsoid?: boolean;
|
|
519
526
|
}) => [x: number, y: number, z: number] | undefined;
|
|
@@ -797,14 +804,6 @@ export declare type HeatMapAppearance = {
|
|
|
797
804
|
logarithmic?: boolean;
|
|
798
805
|
};
|
|
799
806
|
|
|
800
|
-
export declare type HeightMapProperty = {
|
|
801
|
-
type?: "custom";
|
|
802
|
-
colorLUT?: LUT;
|
|
803
|
-
minHeight?: number;
|
|
804
|
-
maxHeight?: number;
|
|
805
|
-
logarithmic?: boolean;
|
|
806
|
-
};
|
|
807
|
-
|
|
808
807
|
export declare type ImageBasedLighting = {
|
|
809
808
|
enabled?: boolean;
|
|
810
809
|
intensity?: number;
|
|
@@ -1177,18 +1176,18 @@ export declare type MouseEventCallbacks = {
|
|
|
1177
1176
|
|
|
1178
1177
|
export declare type MouseEventHandles = {
|
|
1179
1178
|
onClick: (fn: MouseEvents["click"]) => void;
|
|
1180
|
-
onDoubleClick: (fn: MouseEvents["
|
|
1181
|
-
onMouseDown: (fn: MouseEvents["
|
|
1182
|
-
onMouseUp: (fn: MouseEvents["
|
|
1183
|
-
onRightClick: (fn: MouseEvents["
|
|
1184
|
-
onRightDown: (fn: MouseEvents["
|
|
1185
|
-
onRightUp: (fn: MouseEvents["
|
|
1186
|
-
onMiddleClick: (fn: MouseEvents["
|
|
1187
|
-
onMiddleDown: (fn: MouseEvents["
|
|
1188
|
-
onMiddleUp: (fn: MouseEvents["
|
|
1189
|
-
onMouseMove: (fn: MouseEvents["
|
|
1190
|
-
onMouseEnter: (fn: MouseEvents["
|
|
1191
|
-
onMouseLeave: (fn: MouseEvents["
|
|
1179
|
+
onDoubleClick: (fn: MouseEvents["doubleClick"]) => void;
|
|
1180
|
+
onMouseDown: (fn: MouseEvents["mouseDown"]) => void;
|
|
1181
|
+
onMouseUp: (fn: MouseEvents["mouseUp"]) => void;
|
|
1182
|
+
onRightClick: (fn: MouseEvents["rightClick"]) => void;
|
|
1183
|
+
onRightDown: (fn: MouseEvents["rightDown"]) => void;
|
|
1184
|
+
onRightUp: (fn: MouseEvents["rightUp"]) => void;
|
|
1185
|
+
onMiddleClick: (fn: MouseEvents["middleClick"]) => void;
|
|
1186
|
+
onMiddleDown: (fn: MouseEvents["middleDown"]) => void;
|
|
1187
|
+
onMiddleUp: (fn: MouseEvents["middleUp"]) => void;
|
|
1188
|
+
onMouseMove: (fn: MouseEvents["mouseMove"]) => void;
|
|
1189
|
+
onMouseEnter: (fn: MouseEvents["mouseEnter"]) => void;
|
|
1190
|
+
onMouseLeave: (fn: MouseEvents["mouseLeave"]) => void;
|
|
1192
1191
|
onWheel: (fn: MouseEvents["wheel"]) => void;
|
|
1193
1192
|
};
|
|
1194
1193
|
|
|
@@ -1208,7 +1207,7 @@ export declare type MouseEvents = {
|
|
|
1208
1207
|
wheel: MouseWheelEventCallback;
|
|
1209
1208
|
};
|
|
1210
1209
|
|
|
1211
|
-
export declare type MouseEventTypes = "click" | "
|
|
1210
|
+
export declare type MouseEventTypes = "click" | "doubleClick" | "mouseDown" | "mouseUp" | "rightClick" | "rightDown" | "rightUp" | "middleClick" | "middleDown" | "middleUp" | "mouseMove" | "mouseEnter" | "mouseLeave" | "wheel";
|
|
1212
1211
|
|
|
1213
1212
|
export declare type MouseWheelEventCallback = (props: MouseEventProps) => void;
|
|
1214
1213
|
|
|
@@ -1485,6 +1484,16 @@ export declare type SketchFeature = Feature_2<Polygon_2 | MultiPolygon | Point |
|
|
|
1485
1484
|
extrudedHeight: number;
|
|
1486
1485
|
}>;
|
|
1487
1486
|
|
|
1487
|
+
export declare type SketchOptions = {
|
|
1488
|
+
color?: string;
|
|
1489
|
+
appearance?: SketchAppearance;
|
|
1490
|
+
dataOnly?: boolean;
|
|
1491
|
+
disableShadow?: boolean;
|
|
1492
|
+
enableRelativeHeight?: boolean;
|
|
1493
|
+
rightClickToAbort?: boolean;
|
|
1494
|
+
autoResetInteractionMode?: boolean;
|
|
1495
|
+
};
|
|
1496
|
+
|
|
1488
1497
|
export declare type SketchProps = {
|
|
1489
1498
|
layersRef: RefObject<LayersRef>;
|
|
1490
1499
|
engineRef: RefObject<EngineRef>;
|
|
@@ -1499,14 +1508,10 @@ export declare type SketchProps = {
|
|
|
1499
1508
|
};
|
|
1500
1509
|
|
|
1501
1510
|
export declare type SketchRef = {
|
|
1511
|
+
getType: () => SketchType | undefined;
|
|
1502
1512
|
setType: (type: SketchType | undefined, from?: "editor" | "plugin") => void;
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
disableShadow: (disable: boolean) => void;
|
|
1506
|
-
enableRelativeHeight: (enable: boolean) => void;
|
|
1507
|
-
createDataOnly: (dataOnly: boolean) => void;
|
|
1508
|
-
allowRightClickToAbort: (allow: boolean) => void;
|
|
1509
|
-
allowAutoResetInteractionMode: (allow: boolean) => void;
|
|
1513
|
+
getOptions: () => SketchOptions;
|
|
1514
|
+
overrideOptions: (options: SketchOptions) => void;
|
|
1510
1515
|
};
|
|
1511
1516
|
|
|
1512
1517
|
export declare type SketchType = "marker" | "polyline" | "circle" | "rectangle" | "polygon" | "extrudedCircle" | "extrudedRectangle" | "extrudedPolygon";
|
|
@@ -1554,7 +1559,7 @@ export declare type TerrainProperty = {
|
|
|
1554
1559
|
type?: "cesium" | "arcgis" | "cesiumion";
|
|
1555
1560
|
url?: string;
|
|
1556
1561
|
normal?: boolean;
|
|
1557
|
-
|
|
1562
|
+
elevationHeatMap?: ElevationHeatMapProperty;
|
|
1558
1563
|
};
|
|
1559
1564
|
|
|
1560
1565
|
export declare type TickEvent = (cb: TickEventCallback) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reearth/core",
|
|
3
|
-
"version": "0.0.7-alpha.
|
|
3
|
+
"version": "0.0.7-alpha.3",
|
|
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",
|
|
30
31
|
"react": "^18.2.0",
|
|
31
|
-
"react-dom": "^18.2.0"
|
|
32
|
-
"cesium": "1.x"
|
|
32
|
+
"react-dom": "^18.2.0"
|
|
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": "1.
|
|
64
|
+
"resium": "^1.18.0",
|
|
65
65
|
"suspend-react": "0.1.3",
|
|
66
66
|
"tiny-invariant": "1.3.3",
|
|
67
67
|
"use-callback-ref": "1.3.2",
|
package/src/Map/Sketch/hooks.ts
CHANGED
|
@@ -24,15 +24,16 @@ import {
|
|
|
24
24
|
MouseEventProps,
|
|
25
25
|
SketchRef,
|
|
26
26
|
} from "../types";
|
|
27
|
+
import { useGet } from "../utils";
|
|
27
28
|
|
|
28
|
-
import { PRESET_APPEARANCE } from "./preset";
|
|
29
|
+
import { PRESET_APPEARANCE, PRESET_COLOR } from "./preset";
|
|
29
30
|
import { Position3d, createSketchMachine } from "./sketchMachine";
|
|
30
31
|
import {
|
|
31
32
|
GeometryOptionsXYZ,
|
|
32
33
|
SketchType,
|
|
33
34
|
SketchFeature,
|
|
34
|
-
SketchAppearance,
|
|
35
35
|
SketchEventProps,
|
|
36
|
+
SketchOptions,
|
|
36
37
|
} from "./types";
|
|
37
38
|
import { useWindowEvent } from "./utils";
|
|
38
39
|
|
|
@@ -73,16 +74,25 @@ export default function useHooks({
|
|
|
73
74
|
const [state, send] = useMachine(sketchMachine);
|
|
74
75
|
const [type, updateType] = useState<SketchType | undefined>();
|
|
75
76
|
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);
|
|
79
77
|
const [disableInteraction, setDisableInteraction] = useState(false);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
|
|
79
|
+
const [sketchOptions, setSketchOptions] = useState<SketchOptions>({
|
|
80
|
+
color: PRESET_COLOR,
|
|
81
|
+
appearance: PRESET_APPEARANCE,
|
|
82
|
+
dataOnly: false,
|
|
83
|
+
disableShadow: false,
|
|
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
|
+
}, []);
|
|
86
96
|
|
|
87
97
|
const [geometryOptions, setGeometryOptions] = useState<GeometryOptionsXYZ | null>(null);
|
|
88
98
|
const [extrudedHeight, setExtrudedHeight] = useState(0);
|
|
@@ -94,34 +104,6 @@ export default function useHooks({
|
|
|
94
104
|
updateFrom(from ?? "editor");
|
|
95
105
|
}, []);
|
|
96
106
|
|
|
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
|
-
|
|
125
107
|
const createFeature = useCallback(() => {
|
|
126
108
|
const geoOptions = type === "marker" ? markerGeometryRef.current : geometryOptions;
|
|
127
109
|
if (geoOptions == null) {
|
|
@@ -169,11 +151,11 @@ export default function useHooks({
|
|
|
169
151
|
features: [{ ...feature, id: feature.properties.id }],
|
|
170
152
|
},
|
|
171
153
|
},
|
|
172
|
-
...
|
|
154
|
+
...sketchOptions.appearance,
|
|
173
155
|
});
|
|
174
156
|
return { layerId: newLayer?.id, featureId: feature.properties.id };
|
|
175
157
|
},
|
|
176
|
-
[layersRef,
|
|
158
|
+
[layersRef, sketchOptions.appearance],
|
|
177
159
|
);
|
|
178
160
|
|
|
179
161
|
const pluginSketchLayerFeatureAdd = useCallback(
|
|
@@ -226,7 +208,7 @@ export default function useHooks({
|
|
|
226
208
|
return;
|
|
227
209
|
}
|
|
228
210
|
|
|
229
|
-
if (!
|
|
211
|
+
if (!sketchOptions.dataOnly) {
|
|
230
212
|
const selectedLayer = layersRef.current?.selectedLayer();
|
|
231
213
|
const { layerId, featureId } =
|
|
232
214
|
selectedLayer?.id?.length !== PLUGIN_LAYER_ID_LENGTH ||
|
|
@@ -262,6 +244,7 @@ export default function useHooks({
|
|
|
262
244
|
[
|
|
263
245
|
layersRef,
|
|
264
246
|
from,
|
|
247
|
+
sketchOptions.dataOnly,
|
|
265
248
|
pluginSketchLayerCreate,
|
|
266
249
|
pluginSketchLayerFeatureAdd,
|
|
267
250
|
onSketchFeatureCreate,
|
|
@@ -481,7 +464,7 @@ export default function useHooks({
|
|
|
481
464
|
);
|
|
482
465
|
|
|
483
466
|
const handleRightClick = useCallback(() => {
|
|
484
|
-
if (!
|
|
467
|
+
if (!sketchOptions.rightClickToAbort) {
|
|
485
468
|
return;
|
|
486
469
|
}
|
|
487
470
|
if (type !== undefined) {
|
|
@@ -490,7 +473,7 @@ export default function useHooks({
|
|
|
490
473
|
if (state.matches("idle")) return;
|
|
491
474
|
send({ type: "ABORT" });
|
|
492
475
|
updateGeometryOptions(undefined);
|
|
493
|
-
}, [type, state, send, updateGeometryOptions]);
|
|
476
|
+
}, [type, state, sketchOptions.rightClickToAbort, send, updateGeometryOptions]);
|
|
494
477
|
|
|
495
478
|
const mouseDownEventRef = useRef<MouseEventCallback>(handleLeftDown);
|
|
496
479
|
mouseDownEventRef.current = handleLeftDown;
|
|
@@ -586,44 +569,41 @@ export default function useHooks({
|
|
|
586
569
|
useEffect(() => {
|
|
587
570
|
if (type) {
|
|
588
571
|
overrideInteractionMode?.("sketch");
|
|
589
|
-
} else if (
|
|
572
|
+
} else if (sketchOptions.autoResetInteractionMode) {
|
|
590
573
|
overrideInteractionMode?.("default");
|
|
591
574
|
}
|
|
592
575
|
|
|
593
576
|
onSketchTypeChange?.(type, from);
|
|
594
|
-
}, [
|
|
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);
|
|
595
588
|
|
|
596
589
|
useImperativeHandle(
|
|
597
590
|
ref,
|
|
598
591
|
() => ({
|
|
592
|
+
getType,
|
|
599
593
|
setType,
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
createDataOnly,
|
|
603
|
-
disableShadow: setDisableShadow,
|
|
604
|
-
enableRelativeHeight: setEnableRelativeHeight,
|
|
605
|
-
allowRightClickToAbort,
|
|
606
|
-
allowAutoResetInteractionMode,
|
|
594
|
+
getOptions,
|
|
595
|
+
overrideOptions,
|
|
607
596
|
}),
|
|
608
|
-
[
|
|
609
|
-
setType,
|
|
610
|
-
setColor,
|
|
611
|
-
setDisableShadow,
|
|
612
|
-
setEnableRelativeHeight,
|
|
613
|
-
setDefaultAppearance,
|
|
614
|
-
createDataOnly,
|
|
615
|
-
allowRightClickToAbort,
|
|
616
|
-
allowAutoResetInteractionMode,
|
|
617
|
-
],
|
|
597
|
+
[getType, setType, getOptions, overrideOptions],
|
|
618
598
|
);
|
|
619
599
|
|
|
620
600
|
return {
|
|
621
601
|
state,
|
|
622
602
|
extrudedHeight,
|
|
623
603
|
geometryOptions,
|
|
624
|
-
color,
|
|
625
|
-
disableShadow,
|
|
626
|
-
enableRelativeHeight,
|
|
604
|
+
color: sketchOptions.color,
|
|
605
|
+
disableShadow: sketchOptions.disableShadow,
|
|
606
|
+
enableRelativeHeight: sketchOptions.enableRelativeHeight,
|
|
627
607
|
} as any;
|
|
628
608
|
}
|
|
629
609
|
|
package/src/Map/Sketch/index.tsx
CHANGED
|
@@ -1,38 +1,16 @@
|
|
|
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 {
|
|
4
|
-
import { ComponentType, ForwardRefRenderFunction, RefObject, forwardRef } from "react";
|
|
5
|
-
import { RequireExactlyOne } from "type-fest";
|
|
3
|
+
import { ForwardRefRenderFunction, RefObject, forwardRef } from "react";
|
|
6
4
|
|
|
7
5
|
import { ComputedLayer, SelectedFeatureInfo } from "../../mantle";
|
|
8
|
-
import { Position3d } from "../../types";
|
|
9
6
|
import { InteractionModeType } from "../../Visualizer/interactionMode";
|
|
10
7
|
import { EngineRef, Feature, LayerSelectionReason, LayersRef, SketchRef } from "../types";
|
|
11
8
|
|
|
12
9
|
import useHooks from "./hooks";
|
|
13
|
-
import { SketchEventProps, SketchFeature, SketchType } from "./types";
|
|
10
|
+
import { SketchComponentType, SketchEventProps, SketchFeature, SketchType } from "./types";
|
|
14
11
|
|
|
15
12
|
export * from "./types";
|
|
16
13
|
|
|
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
|
-
|
|
36
14
|
export type OnLayerSelectType = (
|
|
37
15
|
layerId: string | undefined,
|
|
38
16
|
featureId: string | undefined,
|
package/src/Map/Sketch/preset.ts
CHANGED
package/src/Map/Sketch/types.ts
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import { Feature as GeojsonFeature, MultiPolygon, Polygon, Point, LineString } from "geojson";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
import { RequireExactlyOne } from "type-fest";
|
|
2
4
|
|
|
3
5
|
import { LayerAppearanceTypes } from "../../mantle";
|
|
4
6
|
import { Position3d } from "../../types";
|
|
5
7
|
|
|
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
|
+
|
|
6
27
|
export type SketchType =
|
|
7
28
|
| "marker"
|
|
8
29
|
| "polyline"
|
|
@@ -13,6 +34,16 @@ export type SketchType =
|
|
|
13
34
|
| "extrudedRectangle"
|
|
14
35
|
| "extrudedPolygon";
|
|
15
36
|
|
|
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
|
+
|
|
16
47
|
export type GeometryOptionsXYZ = {
|
|
17
48
|
type: SketchType;
|
|
18
49
|
controlPoints: Position3d[];
|
package/src/Map/ref.ts
CHANGED
|
@@ -117,14 +117,10 @@ const layersRefKeys: FunctionKeys<LayersRef> = {
|
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const sketchRefKeys: FunctionKeys<SketchRef> = {
|
|
120
|
+
getType: 1,
|
|
120
121
|
setType: 1,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
createDataOnly: 1,
|
|
124
|
-
disableShadow: 1,
|
|
125
|
-
enableRelativeHeight: 1,
|
|
126
|
-
allowRightClickToAbort: 1,
|
|
127
|
-
allowAutoResetInteractionMode: 1,
|
|
122
|
+
getOptions: 1,
|
|
123
|
+
overrideOptions: 1,
|
|
128
124
|
};
|
|
129
125
|
|
|
130
126
|
export function mapRef({
|
package/src/Map/types/index.ts
CHANGED
|
@@ -38,8 +38,7 @@ import type {
|
|
|
38
38
|
LayerSelectionReason,
|
|
39
39
|
Ref as LayersRef,
|
|
40
40
|
} from "../Layers";
|
|
41
|
-
import { SketchComponentType } from "../Sketch";
|
|
42
|
-
import { SketchAppearance, SketchType } from "../Sketch/types";
|
|
41
|
+
import { SketchType, SketchOptions, SketchComponentType } from "../Sketch/types";
|
|
43
42
|
import type { TimelineManagerRef } from "../useTimelineManager";
|
|
44
43
|
|
|
45
44
|
import type { SceneMode, ViewerProperty } from "./viewerProperty";
|
|
@@ -89,7 +88,7 @@ export type EngineRef = {
|
|
|
89
88
|
getLocationFromScreen: (x: number, y: number, withTerrain?: boolean) => LatLngHeight | undefined;
|
|
90
89
|
sampleTerrainHeight: (lng: number, lat: number) => Promise<number | undefined>;
|
|
91
90
|
computeGlobeHeight: (lng: number, lat: number, height?: number) => number | undefined;
|
|
92
|
-
getGlobeHeight: () =>
|
|
91
|
+
getGlobeHeight: () => number | undefined;
|
|
93
92
|
toXYZ: (
|
|
94
93
|
lng: number,
|
|
95
94
|
lat: number,
|
|
@@ -300,18 +299,18 @@ export type MouseEventCallback = (props: MouseEventProps) => void;
|
|
|
300
299
|
export type MouseWheelEventCallback = (props: MouseEventProps) => void;
|
|
301
300
|
export type MouseEventTypes =
|
|
302
301
|
| "click"
|
|
303
|
-
| "
|
|
304
|
-
| "
|
|
305
|
-
| "
|
|
306
|
-
| "
|
|
307
|
-
| "
|
|
308
|
-
| "
|
|
309
|
-
| "
|
|
310
|
-
| "
|
|
311
|
-
| "
|
|
312
|
-
| "
|
|
313
|
-
| "
|
|
314
|
-
| "
|
|
302
|
+
| "doubleClick"
|
|
303
|
+
| "mouseDown"
|
|
304
|
+
| "mouseUp"
|
|
305
|
+
| "rightClick"
|
|
306
|
+
| "rightDown"
|
|
307
|
+
| "rightUp"
|
|
308
|
+
| "middleClick"
|
|
309
|
+
| "middleDown"
|
|
310
|
+
| "middleUp"
|
|
311
|
+
| "mouseMove"
|
|
312
|
+
| "mouseEnter"
|
|
313
|
+
| "mouseLeave"
|
|
315
314
|
| "wheel";
|
|
316
315
|
|
|
317
316
|
export type MouseEvents = {
|
|
@@ -322,18 +321,18 @@ export type MouseEvents = {
|
|
|
322
321
|
|
|
323
322
|
export type MouseEventHandles = {
|
|
324
323
|
onClick: (fn: MouseEvents["click"]) => void;
|
|
325
|
-
onDoubleClick: (fn: MouseEvents["
|
|
326
|
-
onMouseDown: (fn: MouseEvents["
|
|
327
|
-
onMouseUp: (fn: MouseEvents["
|
|
328
|
-
onRightClick: (fn: MouseEvents["
|
|
329
|
-
onRightDown: (fn: MouseEvents["
|
|
330
|
-
onRightUp: (fn: MouseEvents["
|
|
331
|
-
onMiddleClick: (fn: MouseEvents["
|
|
332
|
-
onMiddleDown: (fn: MouseEvents["
|
|
333
|
-
onMiddleUp: (fn: MouseEvents["
|
|
334
|
-
onMouseMove: (fn: MouseEvents["
|
|
335
|
-
onMouseEnter: (fn: MouseEvents["
|
|
336
|
-
onMouseLeave: (fn: MouseEvents["
|
|
324
|
+
onDoubleClick: (fn: MouseEvents["doubleClick"]) => void;
|
|
325
|
+
onMouseDown: (fn: MouseEvents["mouseDown"]) => void;
|
|
326
|
+
onMouseUp: (fn: MouseEvents["mouseUp"]) => void;
|
|
327
|
+
onRightClick: (fn: MouseEvents["rightClick"]) => void;
|
|
328
|
+
onRightDown: (fn: MouseEvents["rightDown"]) => void;
|
|
329
|
+
onRightUp: (fn: MouseEvents["rightUp"]) => void;
|
|
330
|
+
onMiddleClick: (fn: MouseEvents["middleClick"]) => void;
|
|
331
|
+
onMiddleDown: (fn: MouseEvents["middleDown"]) => void;
|
|
332
|
+
onMiddleUp: (fn: MouseEvents["middleUp"]) => void;
|
|
333
|
+
onMouseMove: (fn: MouseEvents["mouseMove"]) => void;
|
|
334
|
+
onMouseEnter: (fn: MouseEvents["mouseEnter"]) => void;
|
|
335
|
+
onMouseLeave: (fn: MouseEvents["mouseLeave"]) => void;
|
|
337
336
|
onWheel: (fn: MouseEvents["wheel"]) => void;
|
|
338
337
|
};
|
|
339
338
|
|
|
@@ -357,12 +356,8 @@ export type Engine = {
|
|
|
357
356
|
export type RequestingRenderMode = -1 | 0 | 1; // -1: force render on every postUpdate, 0: no request to render, 1: request one frame
|
|
358
357
|
|
|
359
358
|
export type SketchRef = {
|
|
359
|
+
getType: () => SketchType | undefined;
|
|
360
360
|
setType: (type: SketchType | undefined, from?: "editor" | "plugin") => void;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
disableShadow: (disable: boolean) => void;
|
|
364
|
-
enableRelativeHeight: (enable: boolean) => void;
|
|
365
|
-
createDataOnly: (dataOnly: boolean) => void;
|
|
366
|
-
allowRightClickToAbort: (allow: boolean) => void;
|
|
367
|
-
allowAutoResetInteractionMode: (allow: boolean) => void;
|
|
361
|
+
getOptions: () => SketchOptions;
|
|
362
|
+
overrideOptions: (options: SketchOptions) => void;
|
|
368
363
|
};
|
|
@@ -69,10 +69,10 @@ export type TerrainProperty = {
|
|
|
69
69
|
type?: "cesium" | "arcgis" | "cesiumion";
|
|
70
70
|
url?: string;
|
|
71
71
|
normal?: boolean;
|
|
72
|
-
|
|
72
|
+
elevationHeatMap?: ElevationHeatMapProperty;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
export type
|
|
75
|
+
export type ElevationHeatMapProperty = {
|
|
76
76
|
type?: "custom";
|
|
77
77
|
colorLUT?: LUT;
|
|
78
78
|
minHeight?: number;
|
|
@@ -167,7 +167,6 @@ export type SkyAtmosphereProperty = {
|
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
export type CameraProperty = {
|
|
170
|
-
camera?: Camera;
|
|
171
170
|
allowEnterGround?: boolean;
|
|
172
171
|
limiter?: CameraLimiterProperty;
|
|
173
172
|
};
|
|
@@ -203,7 +202,7 @@ export type AssetsProperty = {
|
|
|
203
202
|
};
|
|
204
203
|
|
|
205
204
|
export type AssetsCesiumProperty = {
|
|
206
|
-
|
|
205
|
+
terrain?: {
|
|
207
206
|
ionAccessToken?: string;
|
|
208
207
|
ionAsset?: string;
|
|
209
208
|
ionUrl?: string;
|
|
@@ -5,7 +5,7 @@ import { ViewerProperty } from "../engines";
|
|
|
5
5
|
|
|
6
6
|
interface CoreAPI {
|
|
7
7
|
readonly version: string;
|
|
8
|
-
readonly
|
|
8
|
+
readonly viewerProperty?: ViewerProperty;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export default ({ viewerProperty }: { viewerProperty?: ViewerProperty }) => {
|
|
@@ -17,7 +17,7 @@ export default ({ viewerProperty }: { viewerProperty?: ViewerProperty }) => {
|
|
|
17
17
|
get version() {
|
|
18
18
|
return version;
|
|
19
19
|
},
|
|
20
|
-
get
|
|
20
|
+
get viewerProperty() {
|
|
21
21
|
return viewerPropertyRef.current;
|
|
22
22
|
},
|
|
23
23
|
}),
|