vesium 1.0.1-beta.49 → 1.0.1-beta.51

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.mjs CHANGED
@@ -1,1519 +1,1523 @@
1
- import { useMutationObserver, tryOnScopeDispose, promiseTimeout, refThrottled, watchThrottled, computedAsync, useElementBounding, useElementSize, watchImmediate } from "@vueuse/core";
2
- import { Viewer, Ellipsoid, Cartesian3, Math as Math$1, Cartographic, defined, Material, CallbackProperty, ConstantProperty, Cartesian2, ScreenSpaceEventHandler, ScreenSpaceEventType, EllipsoidGeodesic } from "cesium";
3
- import { shallowRef, shallowReadonly, provide, getCurrentScope, computed, watchEffect, toRaw, toValue, markRaw, toRef, inject, watch, ref, readonly, shallowReactive, nextTick } from "vue";
1
+ import { computedAsync, promiseTimeout, refThrottled, tryOnScopeDispose, useElementBounding, useElementSize, useMutationObserver, watchImmediate, watchThrottled } from "@vueuse/core";
2
+ import { CallbackProperty, Cartesian2, Cartesian3, Cartographic, ConstantProperty, Ellipsoid, EllipsoidGeodesic, Material, Math as Math$1, ScreenSpaceEventHandler, ScreenSpaceEventType, Viewer, defined } from "cesium";
3
+ import { computed, getCurrentScope, inject, markRaw, nextTick, provide, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toValue, watch, watchEffect } from "vue";
4
+
5
+ //#region createViewer/index.ts
6
+ /**
7
+ * @internal
8
+ */
4
9
  const CREATE_VIEWER_INJECTION_KEY = Symbol("CREATE_VIEWER_INJECTION_KEY");
10
+ /**
11
+ * @internal
12
+ */
5
13
  const CREATE_VIEWER_COLLECTION = /* @__PURE__ */ new WeakMap();
6
14
  function createViewer(...args) {
7
- const viewer = shallowRef();
8
- const readonlyViewer = shallowReadonly(viewer);
9
- provide(CREATE_VIEWER_INJECTION_KEY, readonlyViewer);
10
- const scope = getCurrentScope();
11
- if (scope) {
12
- CREATE_VIEWER_COLLECTION.set(scope, readonlyViewer);
13
- }
14
- const canvas = computed(() => {
15
- var _a;
16
- return (_a = viewer.value) == null ? void 0 : _a.canvas;
17
- });
18
- useMutationObserver(document == null ? void 0 : document.body, () => {
19
- if (canvas.value && !(document == null ? void 0 : document.body.contains(canvas.value))) {
20
- viewer.value = void 0;
21
- }
22
- }, {
23
- childList: true,
24
- subtree: true
25
- });
26
- watchEffect((onCleanup) => {
27
- const [arg1, arg2] = args;
28
- const value = toRaw(toValue(arg1));
29
- if (value instanceof Viewer) {
30
- viewer.value = markRaw(value);
31
- } else if (value) {
32
- const element = value;
33
- const options = arg2;
34
- viewer.value = new Viewer(element, options);
35
- onCleanup(() => {
36
- var _a, _b;
37
- return !((_a = viewer.value) == null ? void 0 : _a.isDestroyed()) && ((_b = viewer.value) == null ? void 0 : _b.destroy());
38
- });
39
- } else {
40
- viewer.value = void 0;
41
- }
42
- });
43
- tryOnScopeDispose(() => {
44
- viewer.value = void 0;
45
- });
46
- return computed(() => {
47
- var _a;
48
- return ((_a = viewer.value) == null ? void 0 : _a.isDestroyed()) ? void 0 : viewer.value;
49
- });
15
+ const viewer = shallowRef();
16
+ const readonlyViewer = shallowReadonly(viewer);
17
+ provide(CREATE_VIEWER_INJECTION_KEY, readonlyViewer);
18
+ const scope = getCurrentScope();
19
+ if (scope) CREATE_VIEWER_COLLECTION.set(scope, readonlyViewer);
20
+ const canvas = computed(() => viewer.value?.canvas);
21
+ useMutationObserver(document?.body, () => {
22
+ if (canvas.value && !document?.body.contains(canvas.value)) viewer.value = void 0;
23
+ }, {
24
+ childList: true,
25
+ subtree: true
26
+ });
27
+ watchEffect((onCleanup) => {
28
+ const [arg1, arg2] = args;
29
+ const value = toRaw(toValue(arg1));
30
+ if (value instanceof Viewer) viewer.value = markRaw(value);
31
+ else if (value) {
32
+ const element = value;
33
+ const options = arg2;
34
+ viewer.value = new Viewer(element, options);
35
+ onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
36
+ } else viewer.value = void 0;
37
+ });
38
+ tryOnScopeDispose(() => {
39
+ viewer.value = void 0;
40
+ });
41
+ return computed(() => {
42
+ return viewer.value?.isDestroyed() ? void 0 : viewer.value;
43
+ });
50
44
  }
45
+
46
+ //#endregion
47
+ //#region utils/arrayDiff.ts
48
+ /**
49
+ * 计算两个数组的差异,返回新增和删除的元素
50
+ */
51
51
  function arrayDiff(list, oldList) {
52
- const oldListSet = new Set(oldList);
53
- const added = list.filter((obj) => !oldListSet.has(obj));
54
- const newListSet = new Set(list);
55
- const removed = (oldList == null ? void 0 : oldList.filter((obj) => !newListSet.has(obj))) ?? [];
56
- return { added, removed };
52
+ const oldListSet = new Set(oldList);
53
+ const added = list.filter((obj) => !oldListSet.has(obj));
54
+ const newListSet = new Set(list);
55
+ const removed = oldList?.filter((obj) => !newListSet.has(obj)) ?? [];
56
+ return {
57
+ added,
58
+ removed
59
+ };
57
60
  }
61
+
62
+ //#endregion
63
+ //#region utils/canvasCoordToCartesian.ts
64
+ /**
65
+ * Convert canvas coordinates to Cartesian coordinates
66
+ *
67
+ * @param canvasCoord Canvas coordinates
68
+ * @param scene Cesium.Scene instance
69
+ * @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'
70
+ *
71
+ * `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.
72
+ * However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur
73
+ *
74
+ * `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,
75
+ * but can be used for picking terrain. If terrain does not exist, the picked elevation is 0
76
+ *
77
+ * `auto`: Automatically determine which picking content to return
78
+ *
79
+ * Calculation speed comparison: globePick > auto >= pickPosition
80
+ */
58
81
  function canvasCoordToCartesian(canvasCoord, scene, mode = "auto") {
59
- if (mode === "pickPosition") {
60
- return scene.pickPosition(canvasCoord);
61
- } else if (mode === "globePick") {
62
- const ray = scene.camera.getPickRay(canvasCoord);
63
- return ray && scene.globe.pick(ray, scene);
64
- } else {
65
- if (scene.globe.depthTestAgainstTerrain) {
66
- return scene.pickPosition(canvasCoord);
67
- }
68
- const position1 = scene.pickPosition(canvasCoord);
69
- const ray = scene.camera.getPickRay(canvasCoord);
70
- const position2 = ray && scene.globe.pick(ray, scene);
71
- if (!position1) {
72
- return position2;
73
- }
74
- const height1 = (position1 && Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;
75
- const height2 = (position2 && Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;
76
- return height1 < height2 ? position1 : position2;
77
- }
82
+ if (mode === "pickPosition") return scene.pickPosition(canvasCoord);
83
+ else if (mode === "globePick") {
84
+ const ray = scene.camera.getPickRay(canvasCoord);
85
+ return ray && scene.globe.pick(ray, scene);
86
+ } else {
87
+ if (scene.globe.depthTestAgainstTerrain) return scene.pickPosition(canvasCoord);
88
+ const position1 = scene.pickPosition(canvasCoord);
89
+ const ray = scene.camera.getPickRay(canvasCoord);
90
+ const position2 = ray && scene.globe.pick(ray, scene);
91
+ if (!position1) return position2;
92
+ const height1 = (position1 && Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;
93
+ const height2 = (position2 && Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;
94
+ return height1 < height2 ? position1 : position2;
95
+ }
78
96
  }
97
+
98
+ //#endregion
99
+ //#region utils/cartesianToCanvasCoord.ts
100
+ /**
101
+ * Convert Cartesian coordinates to canvas coordinates
102
+ *
103
+ * @param position Cartesian coordinates
104
+ * @param scene Cesium.Scene instance
105
+ */
79
106
  function cartesianToCanvasCoord(position, scene) {
80
- return scene.cartesianToCanvasCoordinates(position);
107
+ return scene.cartesianToCanvasCoordinates(position);
81
108
  }
109
+
110
+ //#endregion
111
+ //#region utils/is.ts
82
112
  const toString = Object.prototype.toString;
83
113
  function isDef(val) {
84
- return typeof val !== "undefined";
114
+ return typeof val !== "undefined";
85
115
  }
86
116
  function isBoolean(val) {
87
- return typeof val === "boolean";
117
+ return typeof val === "boolean";
88
118
  }
89
119
  function isFunction(val) {
90
- return typeof val === "function";
120
+ return typeof val === "function";
91
121
  }
92
122
  function isNumber(val) {
93
- return typeof val === "number";
123
+ return typeof val === "number";
94
124
  }
95
125
  function isString(val) {
96
- return typeof val === "string";
126
+ return typeof val === "string";
97
127
  }
98
128
  function isObject(val) {
99
- return toString.call(val) === "[object Object]";
129
+ return toString.call(val) === "[object Object]";
100
130
  }
101
131
  function isWindow(val) {
102
- return typeof window !== "undefined" && toString.call(val) === "[object Window]";
132
+ return typeof window !== "undefined" && toString.call(val) === "[object Window]";
103
133
  }
104
134
  function isPromise(val) {
105
- return !!val && (typeof val === "object" || typeof val === "function") && typeof val.then === "function";
135
+ return !!val && (typeof val === "object" || typeof val === "function") && typeof val.then === "function";
106
136
  }
107
137
  function isElement(val) {
108
- return !!(val && val.nodeName && val.nodeType === 1);
138
+ return !!(val && val.nodeName && val.nodeType === 1);
109
139
  }
110
140
  const isArray = Array.isArray;
111
141
  function isBase64(val) {
112
- const reg = /^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i;
113
- return reg.test(val);
142
+ const reg = /^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i;
143
+ return reg.test(val);
114
144
  }
115
145
  function assertError(condition, error) {
116
- if (condition) {
117
- throw new Error(error);
118
- }
146
+ if (condition) throw new Error(error);
119
147
  }
148
+
149
+ //#endregion
150
+ //#region utils/cesiumEquals.ts
151
+ /**
152
+ * Determines if two Cesium objects are equal.
153
+ *
154
+ * This function not only judges whether the instances are equal,
155
+ * but also judges the equals method in the example.
156
+ *
157
+ * @param left The first Cesium object
158
+ * @param right The second Cesium object
159
+ * @returns Returns true if the two Cesium objects are equal, otherwise false
160
+ */
120
161
  function cesiumEquals(left, right) {
121
- return left === right || isFunction(left == null ? void 0 : left.equals) && left.equals(right) || isFunction(right == null ? void 0 : right.equals) && right.equals(left);
162
+ return left === right || isFunction(left?.equals) && left.equals(right) || isFunction(right?.equals) && right.equals(left);
122
163
  }
164
+
165
+ //#endregion
166
+ //#region utils/toCoord.ts
167
+ /**
168
+ * Converts coordinates to an array or object in the specified format.
169
+ *
170
+ * @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.
171
+ * @param options Conversion options, including conversion type and whether to include altitude information.
172
+ * @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.
173
+ *
174
+ * @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.
175
+ * @template Alt Whether to include altitude information, default is false
176
+ */
123
177
  function toCoord(position, options = {}) {
124
- if (!position) {
125
- return void 0;
126
- }
127
- const { type = "Array", alt = false } = options;
128
- let longitude, latitude, height;
129
- if (position instanceof Cartesian3) {
130
- const cartographic = Ellipsoid.WGS84.cartesianToCartographic(position);
131
- longitude = Math$1.toDegrees(cartographic.longitude);
132
- latitude = Math$1.toDegrees(cartographic.latitude);
133
- height = cartographic.height;
134
- } else if (position instanceof Cartographic) {
135
- const cartographic = position;
136
- longitude = Math$1.toDegrees(cartographic.longitude);
137
- latitude = Math$1.toDegrees(cartographic.latitude);
138
- height = cartographic.height;
139
- } else if (Array.isArray(position)) {
140
- longitude = Math$1.toDegrees(position[0]);
141
- latitude = Math$1.toDegrees(position[1]);
142
- height = position[2];
143
- } else {
144
- longitude = position.longitude;
145
- latitude = position.latitude;
146
- height = position.height;
147
- }
148
- if (type === "Array") {
149
- return alt ? [longitude, latitude, height] : [longitude, latitude];
150
- } else {
151
- return alt ? { longitude, latitude, height } : { longitude, latitude };
152
- }
178
+ if (!position) return void 0;
179
+ const { type = "Array", alt = false } = options;
180
+ let longitude, latitude, height;
181
+ if (position instanceof Cartesian3) {
182
+ const cartographic = Ellipsoid.WGS84.cartesianToCartographic(position);
183
+ longitude = Math$1.toDegrees(cartographic.longitude);
184
+ latitude = Math$1.toDegrees(cartographic.latitude);
185
+ height = cartographic.height;
186
+ } else if (position instanceof Cartographic) {
187
+ const cartographic = position;
188
+ longitude = Math$1.toDegrees(cartographic.longitude);
189
+ latitude = Math$1.toDegrees(cartographic.latitude);
190
+ height = cartographic.height;
191
+ } else if (Array.isArray(position)) {
192
+ longitude = Math$1.toDegrees(position[0]);
193
+ latitude = Math$1.toDegrees(position[1]);
194
+ height = position[2];
195
+ } else {
196
+ longitude = position.longitude;
197
+ latitude = position.latitude;
198
+ height = position.height;
199
+ }
200
+ if (type === "Array") return alt ? [
201
+ longitude,
202
+ latitude,
203
+ height
204
+ ] : [longitude, latitude];
205
+ else return alt ? {
206
+ longitude,
207
+ latitude,
208
+ height
209
+ } : {
210
+ longitude,
211
+ latitude
212
+ };
153
213
  }
214
+
215
+ //#endregion
216
+ //#region utils/convertDMS.ts
217
+ /**
218
+ * Convert degrees to DMS (Degrees Minutes Seconds) format string
219
+ *
220
+ * @param degrees The angle value
221
+ * @param precision The number of decimal places to retain for the seconds, defaults to 3
222
+ * @returns A DMS formatted string in the format: degrees° minutes′ seconds″
223
+ */
154
224
  function dmsEncode(degrees, precision = 3) {
155
- const str = `${degrees}`;
156
- let i = str.indexOf(".");
157
- const d = i < 0 ? str : str.slice(0, Math.max(0, i));
158
- let m = "0";
159
- let s = "0";
160
- if (i > 0) {
161
- m = `0${str.slice(Math.max(0, i))}`;
162
- m = `${+m * 60}`;
163
- i = m.indexOf(".");
164
- if (i > 0) {
165
- s = `0${m.slice(Math.max(0, i))}`;
166
- m = m.slice(0, Math.max(0, i));
167
- s = `${+s * 60}`;
168
- i = s.indexOf(".");
169
- s = s.slice(0, Math.max(0, i + 4));
170
- s = (+s).toFixed(precision);
171
- }
172
- }
173
- return `${Math.abs(+d)}°${+m}′${+s}″`;
225
+ const str = `${degrees}`;
226
+ let i = str.indexOf(".");
227
+ const d = i < 0 ? str : str.slice(0, Math.max(0, i));
228
+ let m = "0";
229
+ let s = "0";
230
+ if (i > 0) {
231
+ m = `0${str.slice(Math.max(0, i))}`;
232
+ m = `${+m * 60}`;
233
+ i = m.indexOf(".");
234
+ if (i > 0) {
235
+ s = `0${m.slice(Math.max(0, i))}`;
236
+ m = m.slice(0, Math.max(0, i));
237
+ s = `${+s * 60}`;
238
+ i = s.indexOf(".");
239
+ s = s.slice(0, Math.max(0, i + 4));
240
+ s = (+s).toFixed(precision);
241
+ }
242
+ }
243
+ return `${Math.abs(+d)}°${+m}′${+s}″`;
174
244
  }
245
+ /**
246
+ * Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value
247
+ *
248
+ * @param dmsCode DMS formatted string, e.g. "120°30′45″N"
249
+ * @returns The decoded decimal angle value, or 0 if decoding fails
250
+ */
175
251
  function dmsDecode(dmsCode) {
176
- const [dd, msStr] = dmsCode.split("°") ?? [];
177
- const [mm, sStr] = (msStr == null ? void 0 : msStr.split("′")) ?? [];
178
- const ss = sStr == null ? void 0 : sStr.split("″")[0];
179
- const d = Number(dd) || 0;
180
- const m = (Number(mm) || 0) / 60;
181
- const s = (Number(ss) || 0) / 60 / 60;
182
- const degrees = d + m + s;
183
- if (degrees === 0) {
184
- return 0;
185
- } else {
186
- let res = degrees;
187
- if (["W", "w", "S", "s"].includes(dmsCode[dmsCode.length - 1])) {
188
- res = -res;
189
- }
190
- return res;
191
- }
252
+ const [dd, msStr] = dmsCode.split("°") ?? [];
253
+ const [mm, sStr] = msStr?.split("′") ?? [];
254
+ const ss = sStr?.split("″")[0];
255
+ const d = Number(dd) || 0;
256
+ const m = (Number(mm) || 0) / 60;
257
+ const s = (Number(ss) || 0) / 60 / 60;
258
+ const degrees = d + m + s;
259
+ if (degrees === 0) return 0;
260
+ else {
261
+ let res = degrees;
262
+ if ([
263
+ "W",
264
+ "w",
265
+ "S",
266
+ "s"
267
+ ].includes(dmsCode[dmsCode.length - 1])) res = -res;
268
+ return res;
269
+ }
192
270
  }
271
+ /**
272
+ * Convert latitude and longitude coordinates to degrees-minutes-seconds format
273
+ *
274
+ * @param position The latitude and longitude coordinates
275
+ * @param precision The number of decimal places to retain for 'seconds', default is 3
276
+ * @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails
277
+ */
193
278
  function degreesToDms(position, precision = 3) {
194
- const coord = toCoord(position, { alt: true });
195
- if (!coord) {
196
- return;
197
- }
198
- const [longitude, latitude, height] = coord;
199
- const x = dmsEncode(longitude, precision);
200
- const y = dmsEncode(latitude, precision);
201
- return [`${x}${longitude > 0 ? "E" : "W"}`, `${y}${latitude > 0 ? "N" : "S"}`, height];
279
+ const coord = toCoord(position, { alt: true });
280
+ if (!coord) return;
281
+ const [longitude, latitude, height] = coord;
282
+ const x = dmsEncode(longitude, precision);
283
+ const y = dmsEncode(latitude, precision);
284
+ return [
285
+ `${x}${longitude > 0 ? "E" : "W"}`,
286
+ `${y}${latitude > 0 ? "N" : "S"}`,
287
+ height
288
+ ];
202
289
  }
290
+ /**
291
+ * Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates
292
+ *
293
+ * @param dms The latitude or longitude coordinate in DMS format
294
+ * @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails
295
+ */
203
296
  function dmsToDegrees(dms) {
204
- const [x, y, height] = dms;
205
- const longitude = dmsDecode(x);
206
- const latitude = dmsDecode(y);
207
- return [longitude, latitude, Number(height) || 0];
297
+ const [x, y, height] = dms;
298
+ const longitude = dmsDecode(x);
299
+ const latitude = dmsDecode(y);
300
+ return [
301
+ longitude,
302
+ latitude,
303
+ Number(height) || 0
304
+ ];
208
305
  }
306
+
307
+ //#endregion
308
+ //#region utils/isCesiumConstant.ts
309
+ /**
310
+ * Determines if the Cesium property is a constant.
311
+ *
312
+ * @param value Cesium property
313
+ */
209
314
  function isCesiumConstant(value) {
210
- return !defined(value) || !!value.isConstant;
211
- }
212
- class CesiumMaterial extends Material {
213
- constructor(options) {
214
- super(options);
215
- }
315
+ return !defined(value) || !!value.isConstant;
216
316
  }
317
+
318
+ //#endregion
319
+ //#region utils/material.ts
320
+ /**
321
+ * Only as a type fix for `Cesium.Material`
322
+ */
323
+ var CesiumMaterial = class extends Material {
324
+ constructor(options) {
325
+ super(options);
326
+ }
327
+ };
328
+ /**
329
+ * Get material from cache, alias of `Material._materialCache.getMaterial`
330
+ */
217
331
  function getMaterialCache(type) {
218
- return Material._materialCache.getMaterial(type);
332
+ return Material._materialCache.getMaterial(type);
219
333
  }
334
+ /**
335
+ * Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`
336
+ */
220
337
  function addMaterialCache(type, material) {
221
- return Material._materialCache.addMaterial(type, material);
338
+ return Material._materialCache.addMaterial(type, material);
222
339
  }
340
+
341
+ //#endregion
342
+ //#region utils/pick.ts
343
+ /**
344
+ * Analyze the result of Cesium's `scene.pick` and convert it to an array format
345
+ */
223
346
  function resolvePick(pick = {}) {
224
- const { primitive, id, primitiveCollection, collection } = pick;
225
- const entityCollection = id && id.entityCollection || null;
226
- const dataSource = entityCollection && entityCollection.owner || null;
227
- const ids = Array.isArray(id) ? id : [id].filter(Boolean);
228
- return [
229
- ...ids,
230
- primitive,
231
- primitiveCollection,
232
- collection,
233
- entityCollection,
234
- dataSource
235
- ].filter((e) => !!e);
347
+ const { primitive, id, primitiveCollection, collection } = pick;
348
+ const entityCollection = id && id.entityCollection || null;
349
+ const dataSource = entityCollection && entityCollection.owner || null;
350
+ const ids = Array.isArray(id) ? id : [id].filter(Boolean);
351
+ return [
352
+ ...ids,
353
+ primitive,
354
+ primitiveCollection,
355
+ collection,
356
+ entityCollection,
357
+ dataSource
358
+ ].filter((e) => !!e);
236
359
  }
360
+ /**
361
+ * Determine if the given array of graphics is hit by Cesium's `scene.pick`
362
+ *
363
+ * @param pick The `scene.pick` object used for matching
364
+ * @param graphic An array of graphics to check for hits
365
+ */
237
366
  function pickHitGraphic(pick, graphic) {
238
- if (!Array.isArray(graphic) || !graphic.length) {
239
- return false;
240
- }
241
- const elements = resolvePick(pick);
242
- if (!elements.length) {
243
- return false;
244
- }
245
- return elements.some((element) => graphic.includes(element));
367
+ if (!Array.isArray(graphic) || !graphic.length) return false;
368
+ const elements = resolvePick(pick);
369
+ if (!elements.length) return false;
370
+ return elements.some((element) => graphic.includes(element));
246
371
  }
372
+
373
+ //#endregion
374
+ //#region utils/property.ts
375
+ /**
376
+ * Is Cesium.Property
377
+ * @param value - The target object
378
+ */
247
379
  function isProperty(value) {
248
- return value && isFunction(value.getValue);
380
+ return value && isFunction(value.getValue);
249
381
  }
382
+ /**
383
+ * Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation
384
+ * ```typescript
385
+ * toPropertyValue('val') //=> 'val'
386
+ * toPropertyValue(new ConstantProperty('val')) //=> 'val'
387
+ * toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'
388
+ * ```
389
+ *
390
+ * @param value - The value to convert
391
+ */
250
392
  function toPropertyValue(value, time) {
251
- return isProperty(value) ? value.getValue(time) : value;
393
+ return isProperty(value) ? value.getValue(time) : value;
252
394
  }
395
+ /**
396
+ * Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation
397
+ *
398
+ * @param value - The property value or getter to convert, can be undefined or null
399
+ * @param isConstant - The second parameter for converting to CallbackProperty
400
+ * @returns Returns the converted Property object, if value is undefined or null, returns undefined
401
+ */
253
402
  function toProperty(value, isConstant = false) {
254
- return isProperty(value) ? value : isFunction(value) ? new CallbackProperty(value, isConstant) : new ConstantProperty(value);
403
+ return isProperty(value) ? value : isFunction(value) ? new CallbackProperty(value, isConstant) : new ConstantProperty(value);
255
404
  }
256
- function createPropertyField(scope, field, maybeProperty, readonly2) {
257
- let removeOwnerListener;
258
- const ownerBinding = (value) => {
259
- var _a;
260
- removeOwnerListener == null ? void 0 : removeOwnerListener();
261
- if (defined(value == null ? void 0 : value.definitionChanged)) {
262
- removeOwnerListener = (_a = value == null ? void 0 : value.definitionChanged) == null ? void 0 : _a.addEventListener(() => {
263
- scope.definitionChanged.raiseEvent(scope, field, value, value);
264
- });
265
- }
266
- };
267
- const privateField = `_${field}`;
268
- const property = toProperty(maybeProperty);
269
- scope[privateField] = property;
270
- ownerBinding(property);
271
- if (readonly2) {
272
- Object.defineProperty(scope, field, {
273
- get() {
274
- return scope[privateField];
275
- }
276
- });
277
- } else {
278
- Object.defineProperty(scope, field, {
279
- get() {
280
- return scope[privateField];
281
- },
282
- set(value) {
283
- const previous = scope[privateField];
284
- if (scope[privateField] !== value) {
285
- scope[privateField] = value;
286
- ownerBinding(value);
287
- if (defined(scope.definitionChanged)) {
288
- scope.definitionChanged.raiseEvent(scope, field, value, previous);
289
- }
290
- }
291
- }
292
- });
293
- }
405
+ /**
406
+ * Create a Cesium property key
407
+ *
408
+ * @param scope The host object
409
+ * @param field The property name
410
+ * @param maybeProperty Optional property or getter
411
+ * @param readonly Whether the property is read-only
412
+ */
413
+ function createPropertyField(scope, field, maybeProperty, readonly$1) {
414
+ let removeOwnerListener;
415
+ const ownerBinding = (value) => {
416
+ removeOwnerListener?.();
417
+ if (defined(value?.definitionChanged)) removeOwnerListener = value?.definitionChanged?.addEventListener(() => {
418
+ scope.definitionChanged.raiseEvent(scope, field, value, value);
419
+ });
420
+ };
421
+ const privateField = `_${field}`;
422
+ const property = toProperty(maybeProperty);
423
+ scope[privateField] = property;
424
+ ownerBinding(property);
425
+ if (readonly$1) Object.defineProperty(scope, field, { get() {
426
+ return scope[privateField];
427
+ } });
428
+ else Object.defineProperty(scope, field, {
429
+ get() {
430
+ return scope[privateField];
431
+ },
432
+ set(value) {
433
+ const previous = scope[privateField];
434
+ if (scope[privateField] !== value) {
435
+ scope[privateField] = value;
436
+ ownerBinding(value);
437
+ if (defined(scope.definitionChanged)) scope.definitionChanged.raiseEvent(scope, field, value, previous);
438
+ }
439
+ }
440
+ });
294
441
  }
295
442
  function createCesiumAttribute(scope, key, value, options = {}) {
296
- const allowToProperty = !!options.toProperty;
297
- const shallowClone = !!options.shallowClone;
298
- const changedEventKey = options.changedEventKey || "definitionChanged";
299
- const changedEvent = Reflect.get(scope, changedEventKey);
300
- const privateKey = `_${String(key)}`;
301
- const attribute = allowToProperty ? toProperty(value) : value;
302
- Reflect.set(scope, privateKey, attribute);
303
- const obj = {
304
- get() {
305
- const value2 = Reflect.get(scope, privateKey);
306
- if (shallowClone) {
307
- return Array.isArray(value2) ? [...value2] : { ...value2 };
308
- } else {
309
- return value2;
310
- }
311
- }
312
- };
313
- let previousListener;
314
- const serial = (property, previous) => {
315
- var _a;
316
- previousListener == null ? void 0 : previousListener();
317
- previousListener = (_a = property == null ? void 0 : property.definitionChanged) == null ? void 0 : _a.addEventListener(() => {
318
- changedEvent == null ? void 0 : changedEvent.raiseEvent.bind(changedEvent)(scope, key, property, previous);
319
- });
320
- };
321
- if (!options.readonly) {
322
- if (allowToProperty && isProperty(value)) {
323
- serial(value);
324
- }
325
- obj.set = (value2) => {
326
- if (allowToProperty && !isProperty(value2)) {
327
- throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);
328
- }
329
- const previous = Reflect.get(scope, privateKey);
330
- if (previous !== value2) {
331
- Reflect.set(scope, privateKey, value2);
332
- changedEvent == null ? void 0 : changedEvent.raiseEvent.bind(changedEvent)(scope, key, value2, previous);
333
- if (allowToProperty) {
334
- serial(value2);
335
- }
336
- }
337
- };
338
- }
339
- Object.defineProperty(scope, key, obj);
443
+ const allowToProperty = !!options.toProperty;
444
+ const shallowClone = !!options.shallowClone;
445
+ const changedEventKey = options.changedEventKey || "definitionChanged";
446
+ const changedEvent = Reflect.get(scope, changedEventKey);
447
+ const privateKey = `_${String(key)}`;
448
+ const attribute = allowToProperty ? toProperty(value) : value;
449
+ Reflect.set(scope, privateKey, attribute);
450
+ const obj = { get() {
451
+ const value$1 = Reflect.get(scope, privateKey);
452
+ if (shallowClone) return Array.isArray(value$1) ? [...value$1] : { ...value$1 };
453
+ else return value$1;
454
+ } };
455
+ let previousListener;
456
+ const serial = (property, previous) => {
457
+ previousListener?.();
458
+ previousListener = property?.definitionChanged?.addEventListener(() => {
459
+ changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);
460
+ });
461
+ };
462
+ if (!options.readonly) {
463
+ if (allowToProperty && isProperty(value)) serial(value);
464
+ obj.set = (value$1) => {
465
+ if (allowToProperty && !isProperty(value$1)) throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);
466
+ const previous = Reflect.get(scope, privateKey);
467
+ if (previous !== value$1) {
468
+ Reflect.set(scope, privateKey, value$1);
469
+ changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value$1, previous);
470
+ if (allowToProperty) serial(value$1);
471
+ }
472
+ };
473
+ }
474
+ Object.defineProperty(scope, key, obj);
340
475
  }
341
476
  function createCesiumProperty(scope, key, value, options = {}) {
342
- return createCesiumAttribute(scope, key, value, { ...options, toProperty: true });
477
+ return createCesiumAttribute(scope, key, value, {
478
+ ...options,
479
+ toProperty: true
480
+ });
343
481
  }
482
+
483
+ //#endregion
484
+ //#region utils/throttle.ts
485
+ /**
486
+ * Throttle function, which limits the frequency of execution of the function
487
+ *
488
+ * @param callback raw function
489
+ * @param delay Throttled delay duration (ms)
490
+ * @param trailing Trigger callback function after last call @default true
491
+ * @param leading Trigger the callback function immediately on the first call @default false
492
+ * @returns Throttle function
493
+ */
344
494
  function throttle(callback, delay = 100, trailing = true, leading = false) {
345
- const restList = [];
346
- let tracked = false;
347
- const trigger = async () => {
348
- await promiseTimeout(delay);
349
- tracked = false;
350
- if (leading) {
351
- try {
352
- callback(...restList[0]);
353
- } catch (error) {
354
- console.error(error);
355
- }
356
- }
357
- if (trailing && (!leading || restList.length > 1)) {
358
- try {
359
- callback(...restList[restList.length - 1]);
360
- } catch (error) {
361
- console.error(error);
362
- }
363
- }
364
- restList.length = 0;
365
- };
366
- return (...rest) => {
367
- if (restList.length < 2) {
368
- restList.push(rest);
369
- } else {
370
- restList[1] = rest;
371
- }
372
- if (!tracked) {
373
- tracked = true;
374
- trigger();
375
- }
376
- };
495
+ const restList = [];
496
+ let tracked = false;
497
+ const trigger = async () => {
498
+ await promiseTimeout(delay);
499
+ tracked = false;
500
+ if (leading) try {
501
+ callback(...restList[0]);
502
+ } catch (error) {
503
+ console.error(error);
504
+ }
505
+ if (trailing && (!leading || restList.length > 1)) try {
506
+ callback(...restList[restList.length - 1]);
507
+ } catch (error) {
508
+ console.error(error);
509
+ }
510
+ restList.length = 0;
511
+ };
512
+ return (...rest) => {
513
+ if (restList.length < 2) restList.push(rest);
514
+ else restList[1] = rest;
515
+ if (!tracked) {
516
+ tracked = true;
517
+ trigger();
518
+ }
519
+ };
377
520
  }
521
+
522
+ //#endregion
523
+ //#region utils/toCartesian3.ts
524
+ /**
525
+ * Converts position to a coordinate point in the Cartesian coordinate system
526
+ *
527
+ * @param position Position information, which can be a Cartesian coordinate point (Cartesian3), a geographic coordinate point (Cartographic), an array, or an object containing WGS84 latitude, longitude, and height information
528
+ * @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned
529
+ */
378
530
  function toCartesian3(position) {
379
- if (!position) {
380
- return void 0;
381
- }
382
- if (position instanceof Cartesian3) {
383
- return position.clone();
384
- } else if (position instanceof Cartographic) {
385
- return Ellipsoid.WGS84.cartographicToCartesian(position);
386
- } else if (Array.isArray(position)) {
387
- return Cartesian3.fromDegrees(position[0], position[1], position[2]);
388
- } else {
389
- return Cartesian3.fromDegrees(position.longitude, position.latitude, position.height);
390
- }
531
+ if (!position) return void 0;
532
+ if (position instanceof Cartesian3) return position.clone();
533
+ else if (position instanceof Cartographic) return Ellipsoid.WGS84.cartographicToCartesian(position);
534
+ else if (Array.isArray(position)) return Cartesian3.fromDegrees(position[0], position[1], position[2]);
535
+ else return Cartesian3.fromDegrees(position.longitude, position.latitude, position.height);
391
536
  }
537
+
538
+ //#endregion
539
+ //#region utils/toCartographic.ts
540
+ /**
541
+ * Converts a position to a Cartographic coordinate point
542
+ *
543
+ * @param position Position information, which can be a Cartesian3 coordinate point, a Cartographic coordinate point, an array, or an object containing WGS84 longitude, latitude, and height information
544
+ * @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid
545
+ */
392
546
  function toCartographic(position) {
393
- if (!position) {
394
- return void 0;
395
- }
396
- if (position instanceof Cartesian3) {
397
- return Ellipsoid.WGS84.cartesianToCartographic(position);
398
- } else if (position instanceof Cartographic) {
399
- return position.clone();
400
- } else if (Array.isArray(position)) {
401
- return Cartographic.fromDegrees(position[0], position[1], position[2]);
402
- } else {
403
- return Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
404
- }
547
+ if (!position) return void 0;
548
+ if (position instanceof Cartesian3) return Ellipsoid.WGS84.cartesianToCartographic(position);
549
+ else if (position instanceof Cartographic) return position.clone();
550
+ else if (Array.isArray(position)) return Cartographic.fromDegrees(position[0], position[1], position[2]);
551
+ else return Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
405
552
  }
553
+
554
+ //#endregion
555
+ //#region utils/tryRun.ts
556
+ /**
557
+ * Safely execute the provided function without throwing errors,
558
+ * essentially a simple wrapper around a `try...catch...` block
559
+ */
406
560
  function tryRun(fn) {
407
- return (...args) => {
408
- try {
409
- return fn == null ? void 0 : fn(...args);
410
- } catch (error) {
411
- console.error(error);
412
- }
413
- };
561
+ return (...args) => {
562
+ try {
563
+ return fn?.(...args);
564
+ } catch (error) {
565
+ console.error(error);
566
+ }
567
+ };
414
568
  }
569
+
570
+ //#endregion
571
+ //#region toPromiseValue/index.ts
572
+ /**
573
+ * Similar to Vue's built-in `toValue`, but capable of handling asynchronous functions, thus returning a `await value`.
574
+ *
575
+ * Used in conjunction with VueUse's `computedAsync`.
576
+ *
577
+ * @param source The source value, which can be a reactive reference or an asynchronous getter.
578
+ * @param options Conversion options
579
+ *
580
+ * @example
581
+ * ```ts
582
+ *
583
+ * const data = computedAsync(async ()=> {
584
+ * return await toPromiseValue(promiseRef)
585
+ * })
586
+ *
587
+ * ```
588
+ */
415
589
  async function toPromiseValue(source, options = {}) {
416
- try {
417
- const { raw = true } = options;
418
- let value;
419
- if (isFunction(source)) {
420
- value = await source();
421
- } else {
422
- const result = toValue(source);
423
- value = isPromise(result) ? await result : result;
424
- }
425
- return raw ? toRaw(value) : value;
426
- } catch (error) {
427
- console.error(error);
428
- throw error;
429
- }
590
+ try {
591
+ const { raw = true } = options;
592
+ let value;
593
+ if (isFunction(source)) value = await source();
594
+ else {
595
+ const result = toValue(source);
596
+ value = isPromise(result) ? await result : result;
597
+ }
598
+ return raw ? toRaw(value) : value;
599
+ } catch (error) {
600
+ console.error(error);
601
+ throw error;
602
+ }
430
603
  }
604
+
605
+ //#endregion
606
+ //#region useCesiumEventListener/index.ts
607
+ /**
608
+ * Easily use the `addEventListener` in `Cesium.Event` instances,
609
+ * when the dependent data changes or the component is unmounted,
610
+ * the listener function will automatically reload or destroy.
611
+ */
431
612
  function useCesiumEventListener(event, listener, options = {}) {
432
- const isActive = toRef(options.isActive ?? true);
433
- const cleanup = watchEffect((onCleanup) => {
434
- const _event = toValue(event);
435
- const events = Array.isArray(_event) ? _event : [_event];
436
- if (events) {
437
- if (events.length && isActive.value) {
438
- const stopFns = events.map((event2) => {
439
- const e = toValue(event2);
440
- return e == null ? void 0 : e.addEventListener(listener, e);
441
- });
442
- onCleanup(() => stopFns.forEach((stop) => stop == null ? void 0 : stop()));
443
- }
444
- }
445
- });
446
- tryOnScopeDispose(cleanup.stop);
447
- return cleanup.stop;
613
+ const isActive = toRef(options.isActive ?? true);
614
+ const cleanup = watchEffect((onCleanup) => {
615
+ const _event = toValue(event);
616
+ const events = Array.isArray(_event) ? _event : [_event];
617
+ if (events) {
618
+ if (events.length && isActive.value) {
619
+ const stopFns = events.map((event$1) => {
620
+ const e = toValue(event$1);
621
+ return e?.addEventListener(listener, e);
622
+ });
623
+ onCleanup(() => stopFns.forEach((stop) => stop?.()));
624
+ }
625
+ }
626
+ });
627
+ tryOnScopeDispose(cleanup.stop);
628
+ return cleanup.stop;
448
629
  }
630
+
631
+ //#endregion
632
+ //#region useViewer/index.ts
633
+ /**
634
+ * Obtain the `Viewer` instance injected through `createViewer` in the current component or its ancestor components.
635
+ *
636
+ * note:
637
+ * - If `createViewer` and `useViewer` are called in the same component, the `Viewer` instance injected by `createViewer` will be used preferentially.
638
+ * - When calling `createViewer` and `useViewer` in the same component, `createViewer` should be called before `useViewer`.
639
+ */
449
640
  function useViewer() {
450
- const scope = getCurrentScope();
451
- const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : void 0;
452
- if (instanceViewer) {
453
- return instanceViewer;
454
- } else {
455
- const injectViewer = inject(CREATE_VIEWER_INJECTION_KEY);
456
- if (!injectViewer) {
457
- throw new Error(
458
- "The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?"
459
- );
460
- }
461
- return injectViewer;
462
- }
641
+ const scope = getCurrentScope();
642
+ const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : void 0;
643
+ if (instanceViewer) return instanceViewer;
644
+ else {
645
+ const injectViewer = inject(CREATE_VIEWER_INJECTION_KEY);
646
+ if (!injectViewer) throw new Error("The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?");
647
+ return injectViewer;
648
+ }
463
649
  }
650
+
651
+ //#endregion
652
+ //#region useCameraState/index.ts
653
+ /**
654
+ * Reactive Cesium Camera state
655
+ */
464
656
  function useCameraState(options = {}) {
465
- let getCamera = options.camera;
466
- if (!getCamera) {
467
- const viewer = useViewer();
468
- getCamera = () => {
469
- var _a;
470
- return (_a = viewer.value) == null ? void 0 : _a.scene.camera;
471
- };
472
- }
473
- const camera = computed(() => toValue(getCamera));
474
- const event = computed(() => {
475
- var _a;
476
- const eventField = toValue(options.event) || "changed";
477
- return (_a = camera.value) == null ? void 0 : _a[eventField];
478
- });
479
- const changedSymbol = refThrottled(
480
- shallowRef(Symbol("camera change")),
481
- options.delay ?? 8,
482
- true,
483
- false
484
- );
485
- const setChangedSymbol = () => {
486
- changedSymbol.value = Symbol("camera change");
487
- };
488
- watch(camera, () => setChangedSymbol());
489
- useCesiumEventListener(event, () => setChangedSymbol());
490
- return {
491
- camera,
492
- position: computed(() => {
493
- var _a, _b;
494
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.position) == null ? void 0 : _b.clone() : void 0;
495
- }),
496
- direction: computed(() => {
497
- var _a, _b;
498
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.direction) == null ? void 0 : _b.clone() : void 0;
499
- }),
500
- up: computed(() => {
501
- var _a, _b;
502
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.up) == null ? void 0 : _b.clone() : void 0;
503
- }),
504
- right: computed(() => {
505
- var _a, _b;
506
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.right) == null ? void 0 : _b.clone() : void 0;
507
- }),
508
- positionCartographic: computed(() => {
509
- var _a, _b;
510
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.positionCartographic) == null ? void 0 : _b.clone() : void 0;
511
- }),
512
- positionWC: computed(() => {
513
- var _a, _b;
514
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.positionWC) == null ? void 0 : _b.clone() : void 0;
515
- }),
516
- directionWC: computed(() => {
517
- var _a, _b;
518
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.directionWC) == null ? void 0 : _b.clone() : void 0;
519
- }),
520
- upWC: computed(() => {
521
- var _a, _b;
522
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.directionWC) == null ? void 0 : _b.clone() : void 0;
523
- }),
524
- rightWC: computed(() => {
525
- var _a, _b;
526
- return changedSymbol.value ? (_b = (_a = camera.value) == null ? void 0 : _a.directionWC) == null ? void 0 : _b.clone() : void 0;
527
- }),
528
- viewRectangle: computed(() => {
529
- var _a;
530
- return changedSymbol.value ? (_a = camera.value) == null ? void 0 : _a.computeViewRectangle() : void 0;
531
- }),
532
- heading: computed(() => {
533
- var _a;
534
- return changedSymbol.value ? (_a = camera.value) == null ? void 0 : _a.heading : void 0;
535
- }),
536
- pitch: computed(() => {
537
- var _a;
538
- return changedSymbol.value ? (_a = camera.value) == null ? void 0 : _a.pitch : void 0;
539
- }),
540
- roll: computed(() => {
541
- var _a;
542
- return changedSymbol.value ? (_a = camera.value) == null ? void 0 : _a.roll : void 0;
543
- }),
544
- level: computed(() => {
545
- var _a, _b;
546
- return changedSymbol.value && ((_b = (_a = camera.value) == null ? void 0 : _a.positionCartographic) == null ? void 0 : _b.height) ? computeLevel(camera.value.positionCartographic.height) : void 0;
547
- })
548
- };
657
+ let getCamera = options.camera;
658
+ if (!getCamera) {
659
+ const viewer = useViewer();
660
+ getCamera = () => viewer.value?.scene.camera;
661
+ }
662
+ const camera = computed(() => toValue(getCamera));
663
+ const event = computed(() => {
664
+ const eventField = toValue(options.event) || "changed";
665
+ return camera.value?.[eventField];
666
+ });
667
+ const changedSymbol = refThrottled(shallowRef(Symbol("camera change")), options.delay ?? 8, true, false);
668
+ const setChangedSymbol = () => {
669
+ changedSymbol.value = Symbol("camera change");
670
+ };
671
+ watch(camera, () => setChangedSymbol());
672
+ useCesiumEventListener(event, () => setChangedSymbol());
673
+ return {
674
+ camera,
675
+ position: computed(() => changedSymbol.value ? camera.value?.position?.clone() : void 0),
676
+ direction: computed(() => changedSymbol.value ? camera.value?.direction?.clone() : void 0),
677
+ up: computed(() => changedSymbol.value ? camera.value?.up?.clone() : void 0),
678
+ right: computed(() => changedSymbol.value ? camera.value?.right?.clone() : void 0),
679
+ positionCartographic: computed(() => changedSymbol.value ? camera.value?.positionCartographic?.clone() : void 0),
680
+ positionWC: computed(() => changedSymbol.value ? camera.value?.positionWC?.clone() : void 0),
681
+ directionWC: computed(() => changedSymbol.value ? camera.value?.directionWC?.clone() : void 0),
682
+ upWC: computed(() => changedSymbol.value ? camera.value?.directionWC?.clone() : void 0),
683
+ rightWC: computed(() => changedSymbol.value ? camera.value?.directionWC?.clone() : void 0),
684
+ viewRectangle: computed(() => changedSymbol.value ? camera.value?.computeViewRectangle() : void 0),
685
+ heading: computed(() => changedSymbol.value ? camera.value?.heading : void 0),
686
+ pitch: computed(() => changedSymbol.value ? camera.value?.pitch : void 0),
687
+ roll: computed(() => changedSymbol.value ? camera.value?.roll : void 0),
688
+ level: computed(() => changedSymbol.value && camera.value?.positionCartographic?.height ? computeLevel(camera.value.positionCartographic.height) : void 0)
689
+ };
549
690
  }
550
691
  const A = 40487.57;
551
692
  const B = 7096758e-11;
552
693
  const C = 91610.74;
553
694
  const D = -40467.74;
695
+ /**
696
+ * Compute the camera level at a given height.
697
+ */
554
698
  function computeLevel(height) {
555
- return D + (A - D) / (1 + (height / C) ** B);
699
+ return D + (A - D) / (1 + (height / C) ** B);
556
700
  }
701
+
702
+ //#endregion
703
+ //#region useCesiumFps/index.ts
704
+ /**
705
+ * Reactive get the frame rate of Cesium
706
+ */
557
707
  function useCesiumFps(options = {}) {
558
- const { delay = 100 } = options;
559
- const viewer = useViewer();
560
- const p = shallowRef(performance.now());
561
- useCesiumEventListener(
562
- () => {
563
- var _a;
564
- return (_a = viewer.value) == null ? void 0 : _a.scene.postRender;
565
- },
566
- () => p.value = performance.now()
567
- );
568
- const interval = ref(0);
569
- watchThrottled(p, (value, oldValue) => {
570
- interval.value = value - oldValue;
571
- }, {
572
- throttle: delay
573
- });
574
- const fps = computed(() => {
575
- return 1e3 / interval.value;
576
- });
577
- return {
578
- interval: readonly(interval),
579
- fps
580
- };
708
+ const { delay = 100 } = options;
709
+ const viewer = useViewer();
710
+ const p = shallowRef(performance.now());
711
+ useCesiumEventListener(() => viewer.value?.scene.postRender, () => p.value = performance.now());
712
+ const interval = ref(0);
713
+ watchThrottled(p, (value, oldValue) => {
714
+ interval.value = value - oldValue;
715
+ }, { throttle: delay });
716
+ const fps = computed(() => {
717
+ return 1e3 / interval.value;
718
+ });
719
+ return {
720
+ interval: readonly(interval),
721
+ fps
722
+ };
581
723
  }
724
+
725
+ //#endregion
726
+ //#region useCollectionScope/index.ts
727
+ /**
728
+ * Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.
729
+ * - note: This is a basic function that is intended to be called by other lower-level function
730
+ * @param addFn - add SideEffect function. eg.`entites.add`
731
+ * @param removeFn - Clean SideEffect function. eg.`entities.remove`
732
+ * @param removeScopeArgs - The parameters to pass for `removeScope` triggered when the component is unmounted
733
+ */
582
734
  function useCollectionScope(addFn, removeFn, removeScopeArgs) {
583
- const scope = shallowReactive(/* @__PURE__ */ new Set());
584
- const add = (instance, ...args) => {
585
- const result = addFn(instance, ...args);
586
- if (isPromise(result)) {
587
- return new Promise((resolve, reject) => {
588
- result.then((i) => {
589
- scope.add(i);
590
- resolve(i);
591
- }).catch((error) => reject(error));
592
- });
593
- } else {
594
- scope.add(result);
595
- return result;
596
- }
597
- };
598
- const remove = (instance, ...args) => {
599
- scope.delete(instance);
600
- return removeFn(instance, ...args);
601
- };
602
- const removeWhere = (predicate, ...args) => {
603
- scope.forEach((instance) => {
604
- if (predicate(instance)) {
605
- remove(instance, ...args);
606
- }
607
- });
608
- };
609
- const removeScope = (...args) => {
610
- scope.forEach((instance) => {
611
- remove(instance, ...args);
612
- });
613
- };
614
- tryOnScopeDispose(() => removeScope(...removeScopeArgs));
615
- return {
616
- scope: shallowReadonly(scope),
617
- add,
618
- remove,
619
- removeWhere,
620
- removeScope
621
- };
735
+ const scope = shallowReactive(/* @__PURE__ */ new Set());
736
+ const add = (instance, ...args) => {
737
+ const result = addFn(instance, ...args);
738
+ if (isPromise(result)) return new Promise((resolve, reject) => {
739
+ result.then((i) => {
740
+ scope.add(i);
741
+ resolve(i);
742
+ }).catch((error) => reject(error));
743
+ });
744
+ else {
745
+ scope.add(result);
746
+ return result;
747
+ }
748
+ };
749
+ const remove = (instance, ...args) => {
750
+ scope.delete(instance);
751
+ return removeFn(instance, ...args);
752
+ };
753
+ const removeWhere = (predicate, ...args) => {
754
+ scope.forEach((instance) => {
755
+ if (predicate(instance)) remove(instance, ...args);
756
+ });
757
+ };
758
+ const removeScope = (...args) => {
759
+ scope.forEach((instance) => {
760
+ remove(instance, ...args);
761
+ });
762
+ };
763
+ tryOnScopeDispose(() => removeScope(...removeScopeArgs));
764
+ return {
765
+ scope: shallowReadonly(scope),
766
+ add,
767
+ remove,
768
+ removeWhere,
769
+ removeScope
770
+ };
622
771
  }
772
+
773
+ //#endregion
774
+ //#region useDataSource/index.ts
623
775
  function useDataSource(dataSources, options = {}) {
624
- const {
625
- destroyOnRemove,
626
- collection,
627
- isActive = true,
628
- evaluating
629
- } = options;
630
- const result = computedAsync(
631
- () => toPromiseValue(dataSources),
632
- void 0,
633
- {
634
- evaluating
635
- }
636
- );
637
- const viewer = useViewer();
638
- watchEffect((onCleanup) => {
639
- var _a;
640
- const _isActive = toValue(isActive);
641
- if (_isActive) {
642
- const list = Array.isArray(result.value) ? [...result.value] : [result.value];
643
- const _collection = collection ?? ((_a = viewer.value) == null ? void 0 : _a.dataSources);
644
- list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
645
- onCleanup(() => {
646
- const destroy = toValue(destroyOnRemove);
647
- !(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((dataSource) => dataSource && (_collection == null ? void 0 : _collection.remove(dataSource, destroy)));
648
- });
649
- }
650
- });
651
- return result;
776
+ const { destroyOnRemove, collection, isActive = true, evaluating } = options;
777
+ const result = computedAsync(() => toPromiseValue(dataSources), void 0, { evaluating });
778
+ const viewer = useViewer();
779
+ watchEffect((onCleanup) => {
780
+ const _isActive = toValue(isActive);
781
+ if (_isActive) {
782
+ const list = Array.isArray(result.value) ? [...result.value] : [result.value];
783
+ const _collection = collection ?? viewer.value?.dataSources;
784
+ list.forEach((item) => item && _collection?.add(item));
785
+ onCleanup(() => {
786
+ const destroy = toValue(destroyOnRemove);
787
+ !_collection?.isDestroyed() && list.forEach((dataSource) => dataSource && _collection?.remove(dataSource, destroy));
788
+ });
789
+ }
790
+ });
791
+ return result;
652
792
  }
793
+
794
+ //#endregion
795
+ //#region useDataSourceScope/index.ts
796
+ /**
797
+ * // Scope the SideEffects of `DataSourceCollection` operations and automatically remove them when unmounted
798
+ */
653
799
  function useDataSourceScope(options = {}) {
654
- const { collection: _collection, destroyOnRemove } = options;
655
- const viewer = useViewer();
656
- const collection = computed(() => {
657
- var _a;
658
- return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.dataSources);
659
- });
660
- const addFn = (dataSource) => {
661
- if (!collection.value) {
662
- throw new Error("collection is not defined");
663
- }
664
- return collection.value.add(dataSource);
665
- };
666
- const removeFn = (dataSource, destroy) => {
667
- var _a;
668
- return !!((_a = collection.value) == null ? void 0 : _a.remove(dataSource, destroy));
669
- };
670
- const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, [destroyOnRemove]);
671
- return {
672
- scope,
673
- add,
674
- remove,
675
- removeWhere,
676
- removeScope
677
- };
800
+ const { collection: _collection, destroyOnRemove } = options;
801
+ const viewer = useViewer();
802
+ const collection = computed(() => {
803
+ return toValue(_collection) ?? viewer.value?.dataSources;
804
+ });
805
+ const addFn = (dataSource) => {
806
+ if (!collection.value) throw new Error("collection is not defined");
807
+ return collection.value.add(dataSource);
808
+ };
809
+ const removeFn = (dataSource, destroy) => {
810
+ return !!collection.value?.remove(dataSource, destroy);
811
+ };
812
+ const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, [destroyOnRemove]);
813
+ return {
814
+ scope,
815
+ add,
816
+ remove,
817
+ removeWhere,
818
+ removeScope
819
+ };
678
820
  }
821
+
822
+ //#endregion
823
+ //#region useElementOverlay/index.ts
824
+ /**
825
+ * Cesium HtmlElement Overlay
826
+ */
679
827
  function useElementOverlay(target, position, options = {}) {
680
- const {
681
- referenceWindow,
682
- horizontal = "center",
683
- vertical = "bottom",
684
- offset = { x: 0, y: 0 }
685
- } = options;
686
- const cartesian3 = computed(() => toCartesian3(toValue(position)));
687
- const viewer = useViewer();
688
- const coord = shallowRef();
689
- useCesiumEventListener(
690
- () => {
691
- var _a;
692
- return (_a = viewer.value) == null ? void 0 : _a.scene.postRender;
693
- },
694
- () => {
695
- var _a;
696
- if (!((_a = viewer.value) == null ? void 0 : _a.scene)) {
697
- return;
698
- }
699
- if (!cartesian3.value) {
700
- coord.value = void 0;
701
- } else {
702
- const reslut = cartesianToCanvasCoord(cartesian3.value, viewer.value.scene);
703
- coord.value = !Cartesian2.equals(reslut, coord.value) ? reslut : coord.value;
704
- }
705
- }
706
- );
707
- const canvasBounding = useElementBounding(() => {
708
- var _a;
709
- return (_a = viewer.value) == null ? void 0 : _a.canvas.parentElement;
710
- });
711
- const targetBounding = useElementBounding(target);
712
- const finalOffset = computed(() => {
713
- const _offset = toValue(offset);
714
- let x2 = (_offset == null ? void 0 : _offset.x) ?? 0;
715
- const _horizontal = toValue(horizontal);
716
- if (_horizontal === "center") {
717
- x2 -= targetBounding.width.value / 2;
718
- } else if (_horizontal === "right") {
719
- x2 -= targetBounding.width.value;
720
- }
721
- let y2 = (_offset == null ? void 0 : _offset.y) ?? 0;
722
- const _vertical = toValue(vertical);
723
- if (_vertical === "center") {
724
- y2 -= targetBounding.height.value / 2;
725
- } else if (_vertical === "bottom") {
726
- y2 -= targetBounding.height.value;
727
- }
728
- return {
729
- x: x2,
730
- y: y2
731
- };
732
- });
733
- const location = computed(() => {
734
- var _a, _b;
735
- const data = {
736
- x: ((_a = coord.value) == null ? void 0 : _a.x) ?? 0,
737
- y: ((_b = coord.value) == null ? void 0 : _b.y) ?? 0
738
- };
739
- if (toValue(referenceWindow)) {
740
- data.x += canvasBounding.x.value;
741
- data.y += canvasBounding.y.value;
742
- }
743
- return {
744
- x: finalOffset.value.x + data.x,
745
- y: finalOffset.value.y + data.y
746
- };
747
- });
748
- const x = computed(() => location.value.x);
749
- const y = computed(() => location.value.y);
750
- const style = computed(() => {
751
- var _a, _b;
752
- return { left: `${(_a = x.value) == null ? void 0 : _a.toFixed(2)}px`, top: `${(_b = y.value) == null ? void 0 : _b.toFixed(2)}px` };
753
- });
754
- watchEffect(() => {
755
- var _a, _b, _c, _d;
756
- const element = toValue(target);
757
- if (element && toValue(options.applyStyle ?? true)) {
758
- (_b = (_a = element.style) == null ? void 0 : _a.setProperty) == null ? void 0 : _b.call(_a, "left", style.value.left);
759
- (_d = (_c = element.style) == null ? void 0 : _c.setProperty) == null ? void 0 : _d.call(_c, "top", style.value.top);
760
- }
761
- });
762
- return {
763
- x,
764
- y,
765
- style
766
- };
828
+ const { referenceWindow, horizontal = "center", vertical = "bottom", offset = {
829
+ x: 0,
830
+ y: 0
831
+ } } = options;
832
+ const cartesian3 = computed(() => toCartesian3(toValue(position)));
833
+ const viewer = useViewer();
834
+ const coord = shallowRef();
835
+ useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
836
+ if (!viewer.value?.scene) return;
837
+ if (!cartesian3.value) coord.value = void 0;
838
+ else {
839
+ const reslut = cartesianToCanvasCoord(cartesian3.value, viewer.value.scene);
840
+ coord.value = !Cartesian2.equals(reslut, coord.value) ? reslut : coord.value;
841
+ }
842
+ });
843
+ const canvasBounding = useElementBounding(() => viewer.value?.canvas.parentElement);
844
+ const targetBounding = useElementBounding(target);
845
+ const finalOffset = computed(() => {
846
+ const _offset = toValue(offset);
847
+ let x$1 = _offset?.x ?? 0;
848
+ const _horizontal = toValue(horizontal);
849
+ if (_horizontal === "center") x$1 -= targetBounding.width.value / 2;
850
+ else if (_horizontal === "right") x$1 -= targetBounding.width.value;
851
+ let y$1 = _offset?.y ?? 0;
852
+ const _vertical = toValue(vertical);
853
+ if (_vertical === "center") y$1 -= targetBounding.height.value / 2;
854
+ else if (_vertical === "bottom") y$1 -= targetBounding.height.value;
855
+ return {
856
+ x: x$1,
857
+ y: y$1
858
+ };
859
+ });
860
+ const location = computed(() => {
861
+ const data = {
862
+ x: coord.value?.x ?? 0,
863
+ y: coord.value?.y ?? 0
864
+ };
865
+ if (toValue(referenceWindow)) {
866
+ data.x += canvasBounding.x.value;
867
+ data.y += canvasBounding.y.value;
868
+ }
869
+ return {
870
+ x: finalOffset.value.x + data.x,
871
+ y: finalOffset.value.y + data.y
872
+ };
873
+ });
874
+ const x = computed(() => location.value.x);
875
+ const y = computed(() => location.value.y);
876
+ const style = computed(() => ({
877
+ left: `${x.value?.toFixed(2)}px`,
878
+ top: `${y.value?.toFixed(2)}px`
879
+ }));
880
+ watchEffect(() => {
881
+ const element = toValue(target);
882
+ if (element && toValue(options.applyStyle ?? true)) {
883
+ element.style?.setProperty?.("left", style.value.left);
884
+ element.style?.setProperty?.("top", style.value.top);
885
+ }
886
+ });
887
+ return {
888
+ x,
889
+ y,
890
+ style
891
+ };
767
892
  }
893
+
894
+ //#endregion
895
+ //#region useEntity/index.ts
768
896
  function useEntity(data, options = {}) {
769
- const { collection, isActive = true, evaluating } = options;
770
- const result = computedAsync(
771
- () => toPromiseValue(data),
772
- [],
773
- {
774
- evaluating
775
- }
776
- );
777
- const viewer = useViewer();
778
- watchEffect((onCleanup) => {
779
- var _a;
780
- const _isActive = toValue(isActive);
781
- if (_isActive) {
782
- const list = Array.isArray(result.value) ? [...result.value] : [result.value];
783
- const _collection = collection ?? ((_a = viewer.value) == null ? void 0 : _a.entities);
784
- list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
785
- onCleanup(() => {
786
- list.forEach((item) => item && (_collection == null ? void 0 : _collection.remove(item)));
787
- });
788
- }
789
- });
790
- return result;
897
+ const { collection, isActive = true, evaluating } = options;
898
+ const result = computedAsync(() => toPromiseValue(data), [], { evaluating });
899
+ const viewer = useViewer();
900
+ watchEffect((onCleanup) => {
901
+ const _isActive = toValue(isActive);
902
+ if (_isActive) {
903
+ const list = Array.isArray(result.value) ? [...result.value] : [result.value];
904
+ const _collection = collection ?? viewer.value?.entities;
905
+ list.forEach((item) => item && _collection?.add(item));
906
+ onCleanup(() => {
907
+ list.forEach((item) => item && _collection?.remove(item));
908
+ });
909
+ }
910
+ });
911
+ return result;
791
912
  }
913
+
914
+ //#endregion
915
+ //#region useEntityScope/index.ts
916
+ /**
917
+ * Make `add` and `remove` operations of `EntityCollection` scoped,
918
+ * automatically remove `Entity` instance when component is unmounted.
919
+ */
792
920
  function useEntityScope(options = {}) {
793
- const { collection: _collection } = options;
794
- const viewer = useViewer();
795
- const collection = computed(() => {
796
- var _a;
797
- return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.entities);
798
- });
799
- const addFn = (entity) => {
800
- if (!collection.value) {
801
- throw new Error("collection is not defined");
802
- }
803
- if (!collection.value.contains(entity)) {
804
- collection.value.add(entity);
805
- }
806
- return entity;
807
- };
808
- const removeFn = (entity) => {
809
- var _a;
810
- return !!((_a = collection.value) == null ? void 0 : _a.remove(entity));
811
- };
812
- const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
813
- return {
814
- scope,
815
- add,
816
- remove,
817
- removeWhere,
818
- removeScope
819
- };
921
+ const { collection: _collection } = options;
922
+ const viewer = useViewer();
923
+ const collection = computed(() => {
924
+ return toValue(_collection) ?? viewer.value?.entities;
925
+ });
926
+ const addFn = (entity) => {
927
+ if (!collection.value) throw new Error("collection is not defined");
928
+ if (!collection.value.contains(entity)) collection.value.add(entity);
929
+ return entity;
930
+ };
931
+ const removeFn = (entity) => {
932
+ return !!collection.value?.remove(entity);
933
+ };
934
+ const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
935
+ return {
936
+ scope,
937
+ add,
938
+ remove,
939
+ removeWhere,
940
+ removeScope
941
+ };
820
942
  }
943
+
944
+ //#endregion
945
+ //#region useScenePick/index.ts
821
946
  const pickCache = /* @__PURE__ */ new WeakMap();
947
+ /**
948
+ * Uses the `scene.pick` function in Cesium's Scene object to perform screen point picking,
949
+ * return a computed property containing the pick result, or undefined if no object is picked.
950
+ *
951
+ * @param windowPosition The screen coordinates of the pick point.
952
+ */
822
953
  function useScenePick(windowPosition, options = {}) {
823
- const { width = 3, height = 3, throttled = 8 } = options;
824
- const isActive = toRef(options.isActive ?? true);
825
- const viewer = useViewer();
826
- const position = refThrottled(computed(() => {
827
- var _a;
828
- return (_a = toValue(windowPosition)) == null ? void 0 : _a.clone();
829
- }), throttled, false, true);
830
- const pick = shallowRef();
831
- watchEffect(() => {
832
- var _a;
833
- if (viewer.value && position.value && isActive.value) {
834
- const cache = pickCache.get(viewer.value);
835
- if (cache && cache[0].equals(position.value)) {
836
- pick.value = cache[1];
837
- } else {
838
- pickCache.set(viewer.value, [position.value.clone(), pick.value]);
839
- pick.value = (_a = viewer.value) == null ? void 0 : _a.scene.pick(
840
- position.value,
841
- toValue(width),
842
- toValue(height)
843
- );
844
- }
845
- }
846
- });
847
- return pick;
954
+ const { width = 3, height = 3, throttled = 8 } = options;
955
+ const isActive = toRef(options.isActive ?? true);
956
+ const viewer = useViewer();
957
+ const position = refThrottled(computed(() => toValue(windowPosition)?.clone()), throttled, false, true);
958
+ const pick = shallowRef();
959
+ watchEffect(() => {
960
+ if (viewer.value && position.value && isActive.value) {
961
+ const cache = pickCache.get(viewer.value);
962
+ if (cache && cache[0].equals(position.value)) pick.value = cache[1];
963
+ else {
964
+ pickCache.set(viewer.value, [position.value.clone(), pick.value]);
965
+ pick.value = viewer.value?.scene.pick(position.value, toValue(width), toValue(height));
966
+ }
967
+ }
968
+ });
969
+ return pick;
848
970
  }
971
+
972
+ //#endregion
973
+ //#region useScreenSpaceEventHandler/index.ts
974
+ /**
975
+ * Easily use the `ScreenSpaceEventHandler`,
976
+ * when the dependent data changes or the component is unmounted,
977
+ * the listener function will automatically reload or destroy.
978
+ *
979
+ * @param type Types of mouse event
980
+ * @param inputAction Callback function for listening
981
+ */
849
982
  function useScreenSpaceEventHandler(type, inputAction, options = {}) {
850
- const { modifier } = options;
851
- const viewer = useViewer();
852
- const isActive = toRef(options.isActive ?? true);
853
- const handler = computed(() => {
854
- var _a, _b;
855
- if ((_b = (_a = viewer.value) == null ? void 0 : _a.cesiumWidget) == null ? void 0 : _b.canvas) {
856
- return new ScreenSpaceEventHandler(viewer.value.cesiumWidget.canvas);
857
- }
858
- });
859
- const cleanup1 = watch(handler, (_value, previous) => {
860
- var _a;
861
- ((_a = viewer.value) == null ? void 0 : _a.cesiumWidget) && (previous == null ? void 0 : previous.destroy());
862
- });
863
- const cleanup2 = watchEffect((onCleanup) => {
864
- const typeValue = toValue(type);
865
- const modifierValue = toValue(modifier);
866
- const handlerValue = toValue(handler);
867
- if (!handlerValue || !isActive.value || !inputAction) {
868
- return;
869
- }
870
- if (isDef(typeValue)) {
871
- handlerValue.setInputAction(inputAction, typeValue, modifierValue);
872
- onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
873
- }
874
- });
875
- const stop = () => {
876
- cleanup1();
877
- cleanup2();
878
- };
879
- tryOnScopeDispose(stop);
880
- return stop;
983
+ const { modifier } = options;
984
+ const viewer = useViewer();
985
+ const isActive = toRef(options.isActive ?? true);
986
+ const handler = computed(() => {
987
+ if (viewer.value?.cesiumWidget?.canvas) return new ScreenSpaceEventHandler(viewer.value.cesiumWidget.canvas);
988
+ });
989
+ const cleanup1 = watch(handler, (_value, previous) => {
990
+ viewer.value?.cesiumWidget && previous?.destroy();
991
+ });
992
+ const cleanup2 = watchEffect((onCleanup) => {
993
+ const typeValue = toValue(type);
994
+ const modifierValue = toValue(modifier);
995
+ const handlerValue = toValue(handler);
996
+ if (!handlerValue || !isActive.value || !inputAction) return;
997
+ if (isDef(typeValue)) {
998
+ handlerValue.setInputAction(inputAction, typeValue, modifierValue);
999
+ onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
1000
+ }
1001
+ });
1002
+ const stop = () => {
1003
+ cleanup1();
1004
+ cleanup2();
1005
+ };
1006
+ tryOnScopeDispose(stop);
1007
+ return stop;
881
1008
  }
1009
+
1010
+ //#endregion
1011
+ //#region useGraphicEvent/useDrag.ts
1012
+ /**
1013
+ * Use graphic drag events with ease, and remove listener automatically on unmounted.
1014
+ */
882
1015
  function useDrag(listener) {
883
- const position = shallowRef();
884
- const pick = useScenePick(position);
885
- const motionEvent = shallowRef();
886
- const dragging = ref(false);
887
- const viewer = useViewer();
888
- const cameraLocked = ref(false);
889
- watch(cameraLocked, (cameraLocked2) => {
890
- viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked2);
891
- });
892
- const lockCamera = () => {
893
- cameraLocked.value = true;
894
- };
895
- const execute = (pick2, startPosition, endPosition) => {
896
- listener({
897
- event: {
898
- startPosition: startPosition.clone(),
899
- endPosition: endPosition.clone()
900
- },
901
- pick: pick2,
902
- dragging: dragging.value,
903
- lockCamera
904
- });
905
- nextTick(() => {
906
- if (!dragging.value && cameraLocked.value) {
907
- cameraLocked.value = false;
908
- }
909
- });
910
- };
911
- const stopLeftDownWatch = useScreenSpaceEventHandler(
912
- ScreenSpaceEventType.LEFT_DOWN,
913
- (event) => {
914
- dragging.value = true;
915
- position.value = event.position.clone();
916
- }
917
- );
918
- const stopMouseMoveWatch = useScreenSpaceEventHandler(
919
- ScreenSpaceEventType.MOUSE_MOVE,
920
- throttle(({ startPosition, endPosition }) => {
921
- var _a;
922
- motionEvent.value = {
923
- startPosition: ((_a = motionEvent.value) == null ? void 0 : _a.endPosition.clone()) || startPosition.clone(),
924
- endPosition: endPosition.clone()
925
- };
926
- }, 8, false, true)
927
- );
928
- watch([pick, motionEvent], ([pick2, motionEvent2]) => {
929
- if (pick2 && motionEvent2) {
930
- const { startPosition, endPosition } = motionEvent2;
931
- dragging.value && execute(pick2, startPosition, endPosition);
932
- }
933
- });
934
- const stopLeftUpWatch = useScreenSpaceEventHandler(
935
- ScreenSpaceEventType.LEFT_UP,
936
- (event) => {
937
- dragging.value = false;
938
- if (pick.value && motionEvent.value) {
939
- execute(pick.value, motionEvent.value.endPosition, event.position);
940
- }
941
- position.value = void 0;
942
- motionEvent.value = void 0;
943
- }
944
- );
945
- const stop = () => {
946
- stopLeftDownWatch();
947
- stopMouseMoveWatch();
948
- stopLeftUpWatch();
949
- };
950
- tryOnScopeDispose(stop);
951
- return stop;
1016
+ const position = shallowRef();
1017
+ const pick = useScenePick(position);
1018
+ const motionEvent = shallowRef();
1019
+ const dragging = ref(false);
1020
+ const viewer = useViewer();
1021
+ const cameraLocked = ref(false);
1022
+ watch(cameraLocked, (cameraLocked$1) => {
1023
+ viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked$1);
1024
+ });
1025
+ const lockCamera = () => {
1026
+ cameraLocked.value = true;
1027
+ };
1028
+ const execute = (pick$1, startPosition, endPosition) => {
1029
+ listener({
1030
+ event: {
1031
+ startPosition: startPosition.clone(),
1032
+ endPosition: endPosition.clone()
1033
+ },
1034
+ pick: pick$1,
1035
+ dragging: dragging.value,
1036
+ lockCamera
1037
+ });
1038
+ nextTick(() => {
1039
+ if (!dragging.value && cameraLocked.value) cameraLocked.value = false;
1040
+ });
1041
+ };
1042
+ const stopLeftDownWatch = useScreenSpaceEventHandler(ScreenSpaceEventType.LEFT_DOWN, (event) => {
1043
+ dragging.value = true;
1044
+ position.value = event.position.clone();
1045
+ });
1046
+ const stopMouseMoveWatch = useScreenSpaceEventHandler(ScreenSpaceEventType.MOUSE_MOVE, throttle(({ startPosition, endPosition }) => {
1047
+ motionEvent.value = {
1048
+ startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
1049
+ endPosition: endPosition.clone()
1050
+ };
1051
+ }, 8, false, true));
1052
+ watch([pick, motionEvent], ([pick$1, motionEvent$1]) => {
1053
+ if (pick$1 && motionEvent$1) {
1054
+ const { startPosition, endPosition } = motionEvent$1;
1055
+ dragging.value && execute(pick$1, startPosition, endPosition);
1056
+ }
1057
+ });
1058
+ const stopLeftUpWatch = useScreenSpaceEventHandler(ScreenSpaceEventType.LEFT_UP, (event) => {
1059
+ dragging.value = false;
1060
+ if (pick.value && motionEvent.value) execute(pick.value, motionEvent.value.endPosition, event.position);
1061
+ position.value = void 0;
1062
+ motionEvent.value = void 0;
1063
+ });
1064
+ const stop = () => {
1065
+ stopLeftDownWatch();
1066
+ stopMouseMoveWatch();
1067
+ stopLeftUpWatch();
1068
+ };
1069
+ tryOnScopeDispose(stop);
1070
+ return stop;
952
1071
  }
1072
+
1073
+ //#endregion
1074
+ //#region useGraphicEvent/useHover.ts
1075
+ /**
1076
+ * Use graphic hover events with ease, and remove listener automatically on unmounted.
1077
+ */
953
1078
  function useHover(listener) {
954
- const motionEvent = shallowRef();
955
- const pick = useScenePick(() => {
956
- var _a;
957
- return (_a = motionEvent.value) == null ? void 0 : _a.endPosition;
958
- });
959
- const execute = (pick2, startPosition, endPosition, hovering) => {
960
- listener({
961
- event: {
962
- startPosition: startPosition.clone(),
963
- endPosition: endPosition.clone()
964
- },
965
- pick: pick2,
966
- hovering
967
- });
968
- };
969
- useScreenSpaceEventHandler(
970
- ScreenSpaceEventType.MOUSE_MOVE,
971
- ({ startPosition, endPosition }) => {
972
- var _a, _b;
973
- if (!startPosition.equals((_a = motionEvent.value) == null ? void 0 : _a.startPosition) || !endPosition.equals((_b = motionEvent.value) == null ? void 0 : _b.endPosition)) {
974
- motionEvent.value = { startPosition: startPosition.clone(), endPosition: endPosition.clone() };
975
- }
976
- }
977
- );
978
- watch([pick, motionEvent], ([pick2, motionEvent2]) => {
979
- if (pick2 && motionEvent2) {
980
- const { startPosition, endPosition } = motionEvent2;
981
- execute(pick2, startPosition, endPosition, true);
982
- }
983
- });
984
- watch(pick, (pick2, prevPick) => {
985
- if (prevPick && motionEvent.value) {
986
- const { startPosition, endPosition } = motionEvent.value;
987
- execute(prevPick, startPosition, endPosition, false);
988
- }
989
- });
1079
+ const motionEvent = shallowRef();
1080
+ const pick = useScenePick(() => motionEvent.value?.endPosition);
1081
+ const execute = (pick$1, startPosition, endPosition, hovering) => {
1082
+ listener({
1083
+ event: {
1084
+ startPosition: startPosition.clone(),
1085
+ endPosition: endPosition.clone()
1086
+ },
1087
+ pick: pick$1,
1088
+ hovering
1089
+ });
1090
+ };
1091
+ useScreenSpaceEventHandler(ScreenSpaceEventType.MOUSE_MOVE, ({ startPosition, endPosition }) => {
1092
+ if (!startPosition.equals(motionEvent.value?.startPosition) || !endPosition.equals(motionEvent.value?.endPosition)) motionEvent.value = {
1093
+ startPosition: startPosition.clone(),
1094
+ endPosition: endPosition.clone()
1095
+ };
1096
+ });
1097
+ watch([pick, motionEvent], ([pick$1, motionEvent$1]) => {
1098
+ if (pick$1 && motionEvent$1) {
1099
+ const { startPosition, endPosition } = motionEvent$1;
1100
+ execute(pick$1, startPosition, endPosition, true);
1101
+ }
1102
+ });
1103
+ watch(pick, (pick$1, prevPick) => {
1104
+ if (prevPick && motionEvent.value) {
1105
+ const { startPosition, endPosition } = motionEvent.value;
1106
+ execute(prevPick, startPosition, endPosition, false);
1107
+ }
1108
+ });
990
1109
  }
1110
+
1111
+ //#endregion
1112
+ //#region useGraphicEvent/usePositioned.ts
1113
+ /**
1114
+ * @internal
1115
+ */
991
1116
  const EVENT_TYPE_RECORD = {
992
- LEFT_DOWN: ScreenSpaceEventType.LEFT_DOWN,
993
- LEFT_UP: ScreenSpaceEventType.LEFT_UP,
994
- LEFT_CLICK: ScreenSpaceEventType.LEFT_CLICK,
995
- LEFT_DOUBLE_CLICK: ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
996
- RIGHT_DOWN: ScreenSpaceEventType.RIGHT_DOWN,
997
- RIGHT_UP: ScreenSpaceEventType.RIGHT_UP,
998
- RIGHT_CLICK: ScreenSpaceEventType.RIGHT_CLICK,
999
- MIDDLE_DOWN: ScreenSpaceEventType.MIDDLE_DOWN,
1000
- MIDDLE_UP: ScreenSpaceEventType.MIDDLE_UP,
1001
- MIDDLE_CLICK: ScreenSpaceEventType.MIDDLE_CLICK
1117
+ LEFT_DOWN: ScreenSpaceEventType.LEFT_DOWN,
1118
+ LEFT_UP: ScreenSpaceEventType.LEFT_UP,
1119
+ LEFT_CLICK: ScreenSpaceEventType.LEFT_CLICK,
1120
+ LEFT_DOUBLE_CLICK: ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
1121
+ RIGHT_DOWN: ScreenSpaceEventType.RIGHT_DOWN,
1122
+ RIGHT_UP: ScreenSpaceEventType.RIGHT_UP,
1123
+ RIGHT_CLICK: ScreenSpaceEventType.RIGHT_CLICK,
1124
+ MIDDLE_DOWN: ScreenSpaceEventType.MIDDLE_DOWN,
1125
+ MIDDLE_UP: ScreenSpaceEventType.MIDDLE_UP,
1126
+ MIDDLE_CLICK: ScreenSpaceEventType.MIDDLE_CLICK
1002
1127
  };
1003
1128
  function usePositioned(type, listener) {
1004
- const screenEvent = EVENT_TYPE_RECORD[type];
1005
- const viewer = useViewer();
1006
- useScreenSpaceEventHandler(screenEvent, (event) => {
1007
- var _a;
1008
- const position = event.position;
1009
- const pick = (_a = viewer.value) == null ? void 0 : _a.scene.pick(position);
1010
- pick && position && listener({ event: { position }, pick });
1011
- });
1129
+ const screenEvent = EVENT_TYPE_RECORD[type];
1130
+ const viewer = useViewer();
1131
+ useScreenSpaceEventHandler(screenEvent, (event) => {
1132
+ const position = event.position;
1133
+ const pick = viewer.value?.scene.pick(position);
1134
+ pick && position && listener({
1135
+ event: { position },
1136
+ pick
1137
+ });
1138
+ });
1012
1139
  }
1140
+
1141
+ //#endregion
1142
+ //#region useGraphicEvent/index.ts
1013
1143
  const GLOBAL_GRAPHIC_SYMBOL = Symbol("GLOBAL_GRAPHIC_SYMBOL");
1014
1144
  const POSITIONED_EVENT_TYPES = [
1015
- "LEFT_DOWN",
1016
- "LEFT_UP",
1017
- "LEFT_CLICK",
1018
- "LEFT_DOUBLE_CLICK",
1019
- "RIGHT_DOWN",
1020
- "RIGHT_UP",
1021
- "RIGHT_CLICK",
1022
- "MIDDLE_DOWN",
1023
- "MIDDLE_UP",
1024
- "MIDDLE_CLICK"
1145
+ "LEFT_DOWN",
1146
+ "LEFT_UP",
1147
+ "LEFT_CLICK",
1148
+ "LEFT_DOUBLE_CLICK",
1149
+ "RIGHT_DOWN",
1150
+ "RIGHT_UP",
1151
+ "RIGHT_CLICK",
1152
+ "MIDDLE_DOWN",
1153
+ "MIDDLE_UP",
1154
+ "MIDDLE_CLICK"
1025
1155
  ];
1156
+ /**
1157
+ * Handle graphic event listeners and cursor styles for Cesium graphics.
1158
+ * You don't need to overly worry about memory leaks from the function, as it automatically cleans up internally.
1159
+ */
1026
1160
  function useGraphicEvent() {
1027
- const collection = /* @__PURE__ */ new WeakMap();
1028
- const cursorCollection = /* @__PURE__ */ new WeakMap();
1029
- const dragCursorCollection = /* @__PURE__ */ new WeakMap();
1030
- const removeGraphicEvent = (graphic, type, listener) => {
1031
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1032
- const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
1033
- (_b = (_a = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.delete(listener);
1034
- (_d = (_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.get(type)) == null ? void 0 : _d.delete(listener);
1035
- if (((_f = (_e = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _e.get(type)) == null ? void 0 : _f.size) === 0) {
1036
- collection.get(_graphic).delete(type);
1037
- }
1038
- if (((_g = collection.get(_graphic)) == null ? void 0 : _g.size) === 0) {
1039
- collection.delete(_graphic);
1040
- }
1041
- (_i = (_h = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _h.get(type)) == null ? void 0 : _i.delete(listener);
1042
- if (((_k = (_j = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _j.get(type)) == null ? void 0 : _k.size) === 0) {
1043
- (_l = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _l.delete(type);
1044
- }
1045
- if (((_m = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _m.size) === 0) {
1046
- cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
1047
- }
1048
- (_o = (_n = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _n.get(type)) == null ? void 0 : _o.delete(listener);
1049
- if (((_q = (_p = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _p.get(type)) == null ? void 0 : _q.size) === 0) {
1050
- (_r = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _r.delete(type);
1051
- }
1052
- if (((_s = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _s.size) === 0) {
1053
- dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
1054
- }
1055
- };
1056
- const addGraphicEvent = (graphic, type, listener, options = {}) => {
1057
- const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
1058
- collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
1059
- const eventTypeMap = collection.get(_graphic);
1060
- eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
1061
- const listeners = eventTypeMap.get(type);
1062
- listeners.add(listener);
1063
- let { cursor = "pointer", dragCursor } = options;
1064
- if (isDef(cursor)) {
1065
- const _cursor = isFunction(cursor) ? cursor : () => cursor;
1066
- cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
1067
- cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
1068
- cursorCollection.get(_graphic).get(type).set(listener, _cursor);
1069
- }
1070
- if (type === "DRAG") {
1071
- dragCursor ?? (dragCursor = (event) => (event == null ? void 0 : event.dragging) ? "crosshair" : void 0);
1072
- }
1073
- if (isDef(dragCursor)) {
1074
- const _dragCursor = isFunction(dragCursor) ? dragCursor : () => dragCursor;
1075
- dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
1076
- dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
1077
- dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
1078
- }
1079
- return () => removeGraphicEvent(graphic, type, listener);
1080
- };
1081
- const clearGraphicEvent = (graphic, type) => {
1082
- var _a, _b, _c, _d, _e, _f;
1083
- const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
1084
- if (type === "all") {
1085
- collection.delete(_graphic);
1086
- cursorCollection.delete(_graphic);
1087
- dragCursorCollection.delete(_graphic);
1088
- return;
1089
- }
1090
- (_a = collection.get(_graphic)) == null ? void 0 : _a.delete(type);
1091
- if (((_b = collection.get(_graphic)) == null ? void 0 : _b.size) === 0) {
1092
- collection.delete(_graphic);
1093
- }
1094
- (_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.delete(type);
1095
- (_d = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _d.delete(type);
1096
- if (((_e = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _e.size) === 0) {
1097
- cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
1098
- }
1099
- if (((_f = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _f.size) === 0) {
1100
- dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
1101
- }
1102
- };
1103
- for (const type of POSITIONED_EVENT_TYPES) {
1104
- usePositioned(type, (event) => {
1105
- const graphics = resolvePick(event.pick);
1106
- graphics.concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
1107
- var _a, _b;
1108
- (_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.forEach((fn) => {
1109
- var _a2;
1110
- return (_a2 = tryRun(fn)) == null ? void 0 : _a2(event);
1111
- });
1112
- });
1113
- });
1114
- }
1115
- const dragging = ref(false);
1116
- const viewer = useViewer();
1117
- useHover((event) => {
1118
- const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
1119
- graphics.forEach((graphic) => {
1120
- var _a, _b, _c;
1121
- (_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("HOVER")) == null ? void 0 : _b.forEach((fn) => {
1122
- var _a2;
1123
- return (_a2 = tryRun(fn)) == null ? void 0 : _a2(event);
1124
- });
1125
- if (!dragging.value) {
1126
- (_c = cursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
1127
- map.forEach((fn) => {
1128
- var _a2, _b2;
1129
- const cursor = event.hovering ? tryRun(fn)(event) : "";
1130
- (_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
1131
- });
1132
- });
1133
- }
1134
- });
1135
- });
1136
- useDrag((event) => {
1137
- const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
1138
- dragging.value = event.dragging;
1139
- graphics.forEach((graphic) => {
1140
- var _a, _b, _c;
1141
- (_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("DRAG")) == null ? void 0 : _b.forEach((fn) => tryRun(fn)(event));
1142
- (_c = dragCursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
1143
- map.forEach((fn) => {
1144
- var _a2, _b2;
1145
- const cursor = event.dragging ? tryRun(fn)(event) : "";
1146
- (_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
1147
- });
1148
- });
1149
- });
1150
- });
1151
- return {
1152
- addGraphicEvent,
1153
- removeGraphicEvent,
1154
- clearGraphicEvent
1155
- };
1161
+ const collection = /* @__PURE__ */ new WeakMap();
1162
+ const cursorCollection = /* @__PURE__ */ new WeakMap();
1163
+ const dragCursorCollection = /* @__PURE__ */ new WeakMap();
1164
+ const removeGraphicEvent = (graphic, type, listener) => {
1165
+ const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
1166
+ collection?.get(_graphic)?.get(type)?.delete(listener);
1167
+ cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
1168
+ if (collection?.get(_graphic)?.get(type)?.size === 0) collection.get(_graphic).delete(type);
1169
+ if (collection.get(_graphic)?.size === 0) collection.delete(_graphic);
1170
+ cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
1171
+ if (cursorCollection?.get(_graphic)?.get(type)?.size === 0) cursorCollection?.get(_graphic)?.delete(type);
1172
+ if (cursorCollection?.get(_graphic)?.size === 0) cursorCollection?.delete(_graphic);
1173
+ dragCursorCollection?.get(_graphic)?.get(type)?.delete(listener);
1174
+ if (dragCursorCollection?.get(_graphic)?.get(type)?.size === 0) dragCursorCollection?.get(_graphic)?.delete(type);
1175
+ if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
1176
+ };
1177
+ const addGraphicEvent = (graphic, type, listener, options = {}) => {
1178
+ const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
1179
+ collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
1180
+ const eventTypeMap = collection.get(_graphic);
1181
+ eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
1182
+ const listeners = eventTypeMap.get(type);
1183
+ listeners.add(listener);
1184
+ let { cursor = "pointer", dragCursor } = options;
1185
+ if (isDef(cursor)) {
1186
+ const _cursor = isFunction(cursor) ? cursor : () => cursor;
1187
+ cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
1188
+ cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
1189
+ cursorCollection.get(_graphic).get(type).set(listener, _cursor);
1190
+ }
1191
+ if (type === "DRAG") dragCursor ??= (event) => event?.dragging ? "crosshair" : void 0;
1192
+ if (isDef(dragCursor)) {
1193
+ const _dragCursor = isFunction(dragCursor) ? dragCursor : () => dragCursor;
1194
+ dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
1195
+ dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
1196
+ dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
1197
+ }
1198
+ return () => removeGraphicEvent(graphic, type, listener);
1199
+ };
1200
+ const clearGraphicEvent = (graphic, type) => {
1201
+ const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
1202
+ if (type === "all") {
1203
+ collection.delete(_graphic);
1204
+ cursorCollection.delete(_graphic);
1205
+ dragCursorCollection.delete(_graphic);
1206
+ return;
1207
+ }
1208
+ collection.get(_graphic)?.delete(type);
1209
+ if (collection.get(_graphic)?.size === 0) collection.delete(_graphic);
1210
+ cursorCollection?.get(_graphic)?.delete(type);
1211
+ dragCursorCollection?.get(_graphic)?.delete(type);
1212
+ if (cursorCollection?.get(_graphic)?.size === 0) cursorCollection?.delete(_graphic);
1213
+ if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
1214
+ };
1215
+ for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
1216
+ const graphics = resolvePick(event.pick);
1217
+ graphics.concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
1218
+ collection.get(graphic)?.get(type)?.forEach((fn) => tryRun(fn)?.(event));
1219
+ });
1220
+ });
1221
+ const dragging = ref(false);
1222
+ const viewer = useViewer();
1223
+ useHover((event) => {
1224
+ const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
1225
+ graphics.forEach((graphic) => {
1226
+ collection.get(graphic)?.get("HOVER")?.forEach((fn) => tryRun(fn)?.(event));
1227
+ if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
1228
+ map.forEach((fn) => {
1229
+ const cursor = event.hovering ? tryRun(fn)(event) : "";
1230
+ viewer.value?.canvas.style?.setProperty("cursor", cursor);
1231
+ });
1232
+ });
1233
+ });
1234
+ });
1235
+ useDrag((event) => {
1236
+ const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
1237
+ dragging.value = event.dragging;
1238
+ graphics.forEach((graphic) => {
1239
+ collection.get(graphic)?.get("DRAG")?.forEach((fn) => tryRun(fn)(event));
1240
+ dragCursorCollection.get(graphic)?.forEach((map) => {
1241
+ map.forEach((fn) => {
1242
+ const cursor = event.dragging ? tryRun(fn)(event) : "";
1243
+ viewer.value?.canvas.style?.setProperty("cursor", cursor);
1244
+ });
1245
+ });
1246
+ });
1247
+ });
1248
+ return {
1249
+ addGraphicEvent,
1250
+ removeGraphicEvent,
1251
+ clearGraphicEvent
1252
+ };
1156
1253
  }
1254
+
1255
+ //#endregion
1256
+ //#region useImageryLayer/index.ts
1157
1257
  function useImageryLayer(data, options = {}) {
1158
- const {
1159
- destroyOnRemove,
1160
- collection,
1161
- isActive = true,
1162
- evaluating
1163
- } = options;
1164
- const result = computedAsync(
1165
- () => toPromiseValue(data),
1166
- [],
1167
- {
1168
- evaluating
1169
- }
1170
- );
1171
- const viewer = useViewer();
1172
- watchEffect((onCleanup) => {
1173
- var _a;
1174
- const _isActive = toValue(isActive);
1175
- if (_isActive) {
1176
- const list = Array.isArray(result.value) ? [...result.value] : [result.value];
1177
- const _collection = collection ?? ((_a = viewer.value) == null ? void 0 : _a.imageryLayers);
1178
- if (collection == null ? void 0 : collection.isDestroyed()) {
1179
- return;
1180
- }
1181
- list.forEach((item) => {
1182
- if (!item) {
1183
- console.warn("ImageryLayer is undefined");
1184
- return;
1185
- }
1186
- if (item == null ? void 0 : item.isDestroyed()) {
1187
- console.warn("ImageryLayer is destroyed");
1188
- return;
1189
- }
1190
- _collection == null ? void 0 : _collection.add(item);
1191
- });
1192
- onCleanup(() => {
1193
- const destroy = toValue(destroyOnRemove);
1194
- list.forEach((item) => item && (_collection == null ? void 0 : _collection.remove(item, destroy)));
1195
- });
1196
- }
1197
- });
1198
- return result;
1258
+ const { destroyOnRemove, collection, isActive = true, evaluating } = options;
1259
+ const result = computedAsync(() => toPromiseValue(data), [], { evaluating });
1260
+ const viewer = useViewer();
1261
+ watchEffect((onCleanup) => {
1262
+ const _isActive = toValue(isActive);
1263
+ if (_isActive) {
1264
+ const list = Array.isArray(result.value) ? [...result.value] : [result.value];
1265
+ const _collection = collection ?? viewer.value?.imageryLayers;
1266
+ if (collection?.isDestroyed()) return;
1267
+ list.forEach((item) => {
1268
+ if (!item) {
1269
+ console.warn("ImageryLayer is undefined");
1270
+ return;
1271
+ }
1272
+ if (item?.isDestroyed()) {
1273
+ console.warn("ImageryLayer is destroyed");
1274
+ return;
1275
+ }
1276
+ _collection?.add(item);
1277
+ });
1278
+ onCleanup(() => {
1279
+ const destroy = toValue(destroyOnRemove);
1280
+ list.forEach((item) => item && _collection?.remove(item, destroy));
1281
+ });
1282
+ }
1283
+ });
1284
+ return result;
1199
1285
  }
1286
+
1287
+ //#endregion
1288
+ //#region useImageryLayerScope/index.ts
1289
+ /**
1290
+ * Make `add` and `remove` operations of `ImageryLayerCollection` scoped,
1291
+ * automatically remove `ImageryLayer` instance when component is unmounted.
1292
+ */
1200
1293
  function useImageryLayerScope(options = {}) {
1201
- const { collection: _collection, destroyOnRemove } = options;
1202
- const viewer = useViewer();
1203
- const collection = computed(() => {
1204
- var _a;
1205
- return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.imageryLayers);
1206
- });
1207
- const addFn = (imageryLayer, index) => {
1208
- if (!collection.value) {
1209
- throw new Error("collection is not defined");
1210
- }
1211
- collection.value.add(imageryLayer, index);
1212
- return imageryLayer;
1213
- };
1214
- const removeFn = (imageryLayer, destroy) => {
1215
- var _a;
1216
- return !!((_a = collection.value) == null ? void 0 : _a.remove(imageryLayer, destroy));
1217
- };
1218
- const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, [destroyOnRemove]);
1219
- return {
1220
- scope,
1221
- add,
1222
- remove,
1223
- removeWhere,
1224
- removeScope
1225
- };
1294
+ const { collection: _collection, destroyOnRemove } = options;
1295
+ const viewer = useViewer();
1296
+ const collection = computed(() => {
1297
+ return toValue(_collection) ?? viewer.value?.imageryLayers;
1298
+ });
1299
+ const addFn = (imageryLayer, index) => {
1300
+ if (!collection.value) throw new Error("collection is not defined");
1301
+ collection.value.add(imageryLayer, index);
1302
+ return imageryLayer;
1303
+ };
1304
+ const removeFn = (imageryLayer, destroy) => {
1305
+ return !!collection.value?.remove(imageryLayer, destroy);
1306
+ };
1307
+ const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, [destroyOnRemove]);
1308
+ return {
1309
+ scope,
1310
+ add,
1311
+ remove,
1312
+ removeWhere,
1313
+ removeScope
1314
+ };
1226
1315
  }
1316
+
1317
+ //#endregion
1318
+ //#region usePostProcessStage/index.ts
1227
1319
  function usePostProcessStage(data, options = {}) {
1228
- const {
1229
- collection,
1230
- isActive = true,
1231
- evaluating
1232
- } = options;
1233
- const result = computedAsync(
1234
- () => toPromiseValue(data),
1235
- void 0,
1236
- {
1237
- evaluating
1238
- }
1239
- );
1240
- const viewer = useViewer();
1241
- watchEffect((onCleanup) => {
1242
- if (!viewer.value) {
1243
- return;
1244
- }
1245
- const _isActive = toValue(isActive);
1246
- if (_isActive) {
1247
- const list = Array.isArray(result.value) ? [...result.value] : [result.value];
1248
- const _collection = collection ?? viewer.value.scene.postProcessStages;
1249
- list.forEach((item) => item && _collection.add(item));
1250
- onCleanup(() => {
1251
- list.forEach((item) => item && _collection.remove(item));
1252
- });
1253
- }
1254
- });
1255
- return result;
1320
+ const { collection, isActive = true, evaluating } = options;
1321
+ const result = computedAsync(() => toPromiseValue(data), void 0, { evaluating });
1322
+ const viewer = useViewer();
1323
+ watchEffect((onCleanup) => {
1324
+ if (!viewer.value) return;
1325
+ const _isActive = toValue(isActive);
1326
+ if (_isActive) {
1327
+ const list = Array.isArray(result.value) ? [...result.value] : [result.value];
1328
+ const _collection = collection ?? viewer.value.scene.postProcessStages;
1329
+ list.forEach((item) => item && _collection.add(item));
1330
+ onCleanup(() => {
1331
+ list.forEach((item) => item && _collection.remove(item));
1332
+ });
1333
+ }
1334
+ });
1335
+ return result;
1256
1336
  }
1337
+
1338
+ //#endregion
1339
+ //#region usePostProcessStageScope/index.ts
1340
+ /**
1341
+ * Make `add` and `remove` operations of `PostProcessStageCollection` scoped,
1342
+ * automatically remove `PostProcessStage` instance when component is unmounted.
1343
+ */
1257
1344
  function usePostProcessStageScope(options = {}) {
1258
- const { collection: _collection } = options;
1259
- const viewer = useViewer();
1260
- const collection = computed(() => {
1261
- var _a;
1262
- return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.postProcessStages);
1263
- });
1264
- const addFn = (postProcessStage) => {
1265
- if (!collection.value) {
1266
- throw new Error("collection is not defined");
1267
- }
1268
- return collection.value.add(postProcessStage);
1269
- };
1270
- const removeFn = (postProcessStage) => {
1271
- var _a;
1272
- return !!((_a = collection.value) == null ? void 0 : _a.remove(postProcessStage));
1273
- };
1274
- const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
1275
- return {
1276
- scope,
1277
- add,
1278
- remove,
1279
- removeWhere,
1280
- removeScope
1281
- };
1345
+ const { collection: _collection } = options;
1346
+ const viewer = useViewer();
1347
+ const collection = computed(() => {
1348
+ return toValue(_collection) ?? viewer.value?.postProcessStages;
1349
+ });
1350
+ const addFn = (postProcessStage) => {
1351
+ if (!collection.value) throw new Error("collection is not defined");
1352
+ return collection.value.add(postProcessStage);
1353
+ };
1354
+ const removeFn = (postProcessStage) => {
1355
+ return !!collection.value?.remove(postProcessStage);
1356
+ };
1357
+ const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
1358
+ return {
1359
+ scope,
1360
+ add,
1361
+ remove,
1362
+ removeWhere,
1363
+ removeScope
1364
+ };
1282
1365
  }
1366
+
1367
+ //#endregion
1368
+ //#region usePrimitive/index.ts
1283
1369
  function usePrimitive(data, options = {}) {
1284
- const {
1285
- collection,
1286
- isActive = true,
1287
- evaluating
1288
- } = options;
1289
- const result = computedAsync(
1290
- () => toPromiseValue(data),
1291
- void 0,
1292
- {
1293
- evaluating
1294
- }
1295
- );
1296
- const viewer = useViewer();
1297
- watchEffect((onCleanup) => {
1298
- var _a, _b;
1299
- const _isActive = toValue(isActive);
1300
- if (_isActive) {
1301
- const list = Array.isArray(result.value) ? [...result.value] : [result.value];
1302
- const _collection = collection === "ground" ? (_a = viewer.value) == null ? void 0 : _a.scene.groundPrimitives : collection ?? ((_b = viewer.value) == null ? void 0 : _b.scene.primitives);
1303
- list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
1304
- onCleanup(() => {
1305
- !(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((item) => item && (_collection == null ? void 0 : _collection.remove(item)));
1306
- });
1307
- }
1308
- });
1309
- return result;
1370
+ const { collection, isActive = true, evaluating } = options;
1371
+ const result = computedAsync(() => toPromiseValue(data), void 0, { evaluating });
1372
+ const viewer = useViewer();
1373
+ watchEffect((onCleanup) => {
1374
+ const _isActive = toValue(isActive);
1375
+ if (_isActive) {
1376
+ const list = Array.isArray(result.value) ? [...result.value] : [result.value];
1377
+ const _collection = collection === "ground" ? viewer.value?.scene.groundPrimitives : collection ?? viewer.value?.scene.primitives;
1378
+ list.forEach((item) => item && _collection?.add(item));
1379
+ onCleanup(() => {
1380
+ !_collection?.isDestroyed() && list.forEach((item) => item && _collection?.remove(item));
1381
+ });
1382
+ }
1383
+ });
1384
+ return result;
1310
1385
  }
1386
+
1387
+ //#endregion
1388
+ //#region usePrimitiveScope/index.ts
1389
+ /**
1390
+ * Make `add` and `remove` operations of `PrimitiveCollection` scoped,
1391
+ * automatically remove `Primitive` instance when component is unmounted.
1392
+ */
1311
1393
  function usePrimitiveScope(options = {}) {
1312
- const { collection: _collection } = options;
1313
- const viewer = useViewer();
1314
- const collection = computed(() => {
1315
- var _a;
1316
- return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.scene.primitives);
1317
- });
1318
- const addFn = (primitive) => {
1319
- if (!collection.value) {
1320
- throw new Error("collection is not defined");
1321
- }
1322
- return collection.value.add(primitive);
1323
- };
1324
- const removeFn = (primitive) => {
1325
- var _a;
1326
- return !!((_a = collection.value) == null ? void 0 : _a.remove(primitive));
1327
- };
1328
- const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
1329
- return {
1330
- scope,
1331
- add,
1332
- remove,
1333
- removeWhere,
1334
- removeScope
1335
- };
1394
+ const { collection: _collection } = options;
1395
+ const viewer = useViewer();
1396
+ const collection = computed(() => {
1397
+ return toValue(_collection) ?? viewer.value?.scene.primitives;
1398
+ });
1399
+ const addFn = (primitive) => {
1400
+ if (!collection.value) throw new Error("collection is not defined");
1401
+ return collection.value.add(primitive);
1402
+ };
1403
+ const removeFn = (primitive) => {
1404
+ return !!collection.value?.remove(primitive);
1405
+ };
1406
+ const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
1407
+ return {
1408
+ scope,
1409
+ add,
1410
+ remove,
1411
+ removeWhere,
1412
+ removeScope
1413
+ };
1336
1414
  }
1415
+
1416
+ //#endregion
1417
+ //#region useScaleBar/index.ts
1337
1418
  const distances = [
1338
- 0.01,
1339
- 0.05,
1340
- 0.1,
1341
- 0.5,
1342
- 1,
1343
- 2,
1344
- 3,
1345
- 5,
1346
- 10,
1347
- 20,
1348
- 30,
1349
- 50,
1350
- 100,
1351
- 200,
1352
- 300,
1353
- 500,
1354
- 1e3,
1355
- 2e3,
1356
- 3e3,
1357
- 5e3,
1358
- 1e4,
1359
- 2e4,
1360
- 3e4,
1361
- 5e4,
1362
- 1e5,
1363
- 2e5,
1364
- 3e5,
1365
- 5e5,
1366
- 1e6,
1367
- 2e6,
1368
- 3e6,
1369
- 5e6,
1370
- 1e7,
1371
- 2e7,
1372
- 3e7,
1373
- 5e7
1419
+ .01,
1420
+ .05,
1421
+ .1,
1422
+ .5,
1423
+ 1,
1424
+ 2,
1425
+ 3,
1426
+ 5,
1427
+ 10,
1428
+ 20,
1429
+ 30,
1430
+ 50,
1431
+ 100,
1432
+ 200,
1433
+ 300,
1434
+ 500,
1435
+ 1e3,
1436
+ 2e3,
1437
+ 3e3,
1438
+ 5e3,
1439
+ 1e4,
1440
+ 2e4,
1441
+ 3e4,
1442
+ 5e4,
1443
+ 1e5,
1444
+ 2e5,
1445
+ 3e5,
1446
+ 5e5,
1447
+ 1e6,
1448
+ 2e6,
1449
+ 3e6,
1450
+ 5e6,
1451
+ 1e7,
1452
+ 2e7,
1453
+ 3e7,
1454
+ 5e7
1374
1455
  ].reverse();
1456
+ /**
1457
+ * Reactive generation of scale bars
1458
+ */
1375
1459
  function useScaleBar(options = {}) {
1376
- const { maxPixel = 80, delay = 8 } = options;
1377
- const maxPixelRef = computed(() => toValue(maxPixel));
1378
- const viewer = useViewer();
1379
- const canvasSize = useElementSize(() => {
1380
- var _a;
1381
- return (_a = viewer.value) == null ? void 0 : _a.canvas;
1382
- });
1383
- const pixelDistance = ref();
1384
- const setPixelDistance = async () => {
1385
- var _a;
1386
- await nextTick();
1387
- const scene = (_a = viewer.value) == null ? void 0 : _a.scene;
1388
- if (!scene) {
1389
- return;
1390
- }
1391
- const left = scene.camera.getPickRay(new Cartesian2(Math.floor(canvasSize.width.value / 2), canvasSize.height.value - 1));
1392
- const right = scene.camera.getPickRay(new Cartesian2(Math.floor(1 + canvasSize.width.value / 2), canvasSize.height.value - 1));
1393
- if (!left || !right) {
1394
- return;
1395
- }
1396
- const leftPosition = scene.globe.pick(left, scene);
1397
- const rightPosition = scene.globe.pick(right, scene);
1398
- if (!leftPosition || !rightPosition) {
1399
- return;
1400
- }
1401
- const leftCartographic = scene.globe.ellipsoid.cartesianToCartographic(leftPosition);
1402
- const rightCartographic = scene.globe.ellipsoid.cartesianToCartographic(rightPosition);
1403
- const geodesic = new EllipsoidGeodesic(leftCartographic, rightCartographic);
1404
- pixelDistance.value = geodesic.surfaceDistance;
1405
- };
1406
- watchImmediate(viewer, () => setPixelDistance());
1407
- useCesiumEventListener(
1408
- () => {
1409
- var _a;
1410
- return (_a = viewer.value) == null ? void 0 : _a.camera.changed;
1411
- },
1412
- throttle(setPixelDistance, delay)
1413
- );
1414
- const distance = computed(() => {
1415
- if (pixelDistance.value) {
1416
- return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
1417
- }
1418
- });
1419
- const width = computed(() => {
1420
- if (distance.value && pixelDistance.value) {
1421
- const value = distance.value / pixelDistance.value;
1422
- return value;
1423
- }
1424
- return 0;
1425
- });
1426
- const distanceText = computed(() => {
1427
- if (distance.value) {
1428
- return distance.value > 1e3 ? `${distance.value / 1e3 || 0}km` : `${distance.value || 0}m`;
1429
- }
1430
- });
1431
- return {
1432
- pixelDistance: readonly(pixelDistance),
1433
- width,
1434
- distance,
1435
- distanceText
1436
- };
1460
+ const { maxPixel = 80, delay = 8 } = options;
1461
+ const maxPixelRef = computed(() => toValue(maxPixel));
1462
+ const viewer = useViewer();
1463
+ const canvasSize = useElementSize(() => viewer.value?.canvas);
1464
+ const pixelDistance = ref();
1465
+ const setPixelDistance = async () => {
1466
+ await nextTick();
1467
+ const scene = viewer.value?.scene;
1468
+ if (!scene) return;
1469
+ const left = scene.camera.getPickRay(new Cartesian2(Math.floor(canvasSize.width.value / 2), canvasSize.height.value - 1));
1470
+ const right = scene.camera.getPickRay(new Cartesian2(Math.floor(1 + canvasSize.width.value / 2), canvasSize.height.value - 1));
1471
+ if (!left || !right) return;
1472
+ const leftPosition = scene.globe.pick(left, scene);
1473
+ const rightPosition = scene.globe.pick(right, scene);
1474
+ if (!leftPosition || !rightPosition) return;
1475
+ const leftCartographic = scene.globe.ellipsoid.cartesianToCartographic(leftPosition);
1476
+ const rightCartographic = scene.globe.ellipsoid.cartesianToCartographic(rightPosition);
1477
+ const geodesic = new EllipsoidGeodesic(leftCartographic, rightCartographic);
1478
+ pixelDistance.value = geodesic.surfaceDistance;
1479
+ };
1480
+ watchImmediate(viewer, () => setPixelDistance());
1481
+ useCesiumEventListener(() => viewer.value?.camera.changed, throttle(setPixelDistance, delay));
1482
+ const distance = computed(() => {
1483
+ if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
1484
+ });
1485
+ const width = computed(() => {
1486
+ if (distance.value && pixelDistance.value) {
1487
+ const value = distance.value / pixelDistance.value;
1488
+ return value;
1489
+ }
1490
+ return 0;
1491
+ });
1492
+ const distanceText = computed(() => {
1493
+ if (distance.value) return distance.value > 1e3 ? `${distance.value / 1e3 || 0}km` : `${distance.value || 0}m`;
1494
+ });
1495
+ return {
1496
+ pixelDistance: readonly(pixelDistance),
1497
+ width,
1498
+ distance,
1499
+ distanceText
1500
+ };
1437
1501
  }
1502
+
1503
+ //#endregion
1504
+ //#region useSceneDrillPick/index.ts
1505
+ /**
1506
+ * Uses the `scene.drillPick` function to perform screen point picking,
1507
+ * return a computed property containing the pick result, or undefined if no object is picked.
1508
+ *
1509
+ * @param windowPosition The screen coordinates of the pick point.
1510
+ */
1438
1511
  function useSceneDrillPick(windowPosition, options = {}) {
1439
- const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
1440
- const viewer = useViewer();
1441
- const position = refThrottled(computed(() => toValue(windowPosition)), throttled, false, true);
1442
- const pick = computed(() => {
1443
- var _a;
1444
- if (position.value && toValue(isActive)) {
1445
- return (_a = viewer.value) == null ? void 0 : _a.scene.drillPick(
1446
- position.value,
1447
- toValue(limit),
1448
- toValue(width),
1449
- toValue(height)
1450
- );
1451
- }
1452
- });
1453
- return pick;
1512
+ const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
1513
+ const viewer = useViewer();
1514
+ const position = refThrottled(computed(() => toValue(windowPosition)), throttled, false, true);
1515
+ const pick = computed(() => {
1516
+ if (position.value && toValue(isActive)) return viewer.value?.scene.drillPick(position.value, toValue(limit), toValue(width), toValue(height));
1517
+ });
1518
+ return pick;
1454
1519
  }
1455
- export {
1456
- CREATE_VIEWER_COLLECTION,
1457
- CREATE_VIEWER_INJECTION_KEY,
1458
- CesiumMaterial,
1459
- addMaterialCache,
1460
- arrayDiff,
1461
- assertError,
1462
- canvasCoordToCartesian,
1463
- cartesianToCanvasCoord,
1464
- cesiumEquals,
1465
- createCesiumAttribute,
1466
- createCesiumProperty,
1467
- createPropertyField,
1468
- createViewer,
1469
- degreesToDms,
1470
- dmsDecode,
1471
- dmsEncode,
1472
- dmsToDegrees,
1473
- getMaterialCache,
1474
- isArray,
1475
- isBase64,
1476
- isBoolean,
1477
- isCesiumConstant,
1478
- isDef,
1479
- isElement,
1480
- isFunction,
1481
- isNumber,
1482
- isObject,
1483
- isPromise,
1484
- isProperty,
1485
- isString,
1486
- isWindow,
1487
- pickHitGraphic,
1488
- resolvePick,
1489
- throttle,
1490
- toCartesian3,
1491
- toCartographic,
1492
- toCoord,
1493
- toPromiseValue,
1494
- toProperty,
1495
- toPropertyValue,
1496
- tryRun,
1497
- useCameraState,
1498
- useCesiumEventListener,
1499
- useCesiumFps,
1500
- useCollectionScope,
1501
- useDataSource,
1502
- useDataSourceScope,
1503
- useElementOverlay,
1504
- useEntity,
1505
- useEntityScope,
1506
- useGraphicEvent,
1507
- useImageryLayer,
1508
- useImageryLayerScope,
1509
- usePostProcessStage,
1510
- usePostProcessStageScope,
1511
- usePrimitive,
1512
- usePrimitiveScope,
1513
- useScaleBar,
1514
- useSceneDrillPick,
1515
- useScenePick,
1516
- useScreenSpaceEventHandler,
1517
- useViewer
1518
- };
1519
- //# sourceMappingURL=index.mjs.map
1520
+
1521
+ //#endregion
1522
+ export { CREATE_VIEWER_COLLECTION, CREATE_VIEWER_INJECTION_KEY, CesiumMaterial, addMaterialCache, arrayDiff, assertError, canvasCoordToCartesian, cartesianToCanvasCoord, cesiumEquals, createCesiumAttribute, createCesiumProperty, createPropertyField, createViewer, degreesToDms, dmsDecode, dmsEncode, dmsToDegrees, getMaterialCache, isArray, isBase64, isBoolean, isCesiumConstant, isDef, isElement, isFunction, isNumber, isObject, isPromise, isProperty, isString, isWindow, pickHitGraphic, resolvePick, throttle, toCartesian3, toCartographic, toCoord, toPromiseValue, toProperty, toPropertyValue, tryRun, useCameraState, useCesiumEventListener, useCesiumFps, useCollectionScope, useDataSource, useDataSourceScope, useElementOverlay, useEntity, useEntityScope, useGraphicEvent, useImageryLayer, useImageryLayerScope, usePostProcessStage, usePostProcessStageScope, usePrimitive, usePrimitiveScope, useScaleBar, useSceneDrillPick, useScenePick, useScreenSpaceEventHandler, useViewer };
1523
+ //# sourceMappingURL=index.mjs.map