vesium 1.0.1-beta.52 → 1.0.1-beta.57
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/README.md +1 -1
- package/dist/index.cjs +151 -723
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -555
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +54 -555
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +896 -1472
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +130 -647
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const __vueuse_core = __toESM(require("@vueuse/core"));
|
|
25
|
-
const cesium = __toESM(require("cesium"));
|
|
26
|
-
const vue = __toESM(require("vue"));
|
|
1
|
+
let __vueuse_core = require("@vueuse/core");
|
|
2
|
+
let cesium = require("cesium");
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
let __vesium_shared = require("@vesium/shared");
|
|
27
5
|
|
|
28
6
|
//#region createViewer/index.ts
|
|
29
7
|
/**
|
|
@@ -54,9 +32,7 @@ function createViewer(...args) {
|
|
|
54
32
|
const value = (0, vue.toRaw)((0, vue.toValue)(arg1));
|
|
55
33
|
if (value instanceof cesium.Viewer) viewer.value = (0, vue.markRaw)(value);
|
|
56
34
|
else if (value) {
|
|
57
|
-
|
|
58
|
-
const options = arg2;
|
|
59
|
-
viewer.value = new cesium.Viewer(element, options);
|
|
35
|
+
viewer.value = new cesium.Viewer(value, arg2);
|
|
60
36
|
onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
|
|
61
37
|
} else viewer.value = void 0;
|
|
62
38
|
});
|
|
@@ -68,530 +44,6 @@ function createViewer(...args) {
|
|
|
68
44
|
});
|
|
69
45
|
}
|
|
70
46
|
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region utils/arrayDiff.ts
|
|
73
|
-
/**
|
|
74
|
-
* 计算两个数组的差异,返回新增和删除的元素
|
|
75
|
-
*/
|
|
76
|
-
function arrayDiff(list, oldList) {
|
|
77
|
-
const oldListSet = new Set(oldList);
|
|
78
|
-
const added = list.filter((obj) => !oldListSet.has(obj));
|
|
79
|
-
const newListSet = new Set(list);
|
|
80
|
-
const removed = oldList?.filter((obj) => !newListSet.has(obj)) ?? [];
|
|
81
|
-
return {
|
|
82
|
-
added,
|
|
83
|
-
removed
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region utils/canvasCoordToCartesian.ts
|
|
89
|
-
/**
|
|
90
|
-
* Convert canvas coordinates to Cartesian coordinates
|
|
91
|
-
*
|
|
92
|
-
* @param canvasCoord Canvas coordinates
|
|
93
|
-
* @param scene Cesium.Scene instance
|
|
94
|
-
* @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'
|
|
95
|
-
*
|
|
96
|
-
* `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.
|
|
97
|
-
* However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur
|
|
98
|
-
*
|
|
99
|
-
* `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,
|
|
100
|
-
* but can be used for picking terrain. If terrain does not exist, the picked elevation is 0
|
|
101
|
-
*
|
|
102
|
-
* `auto`: Automatically determine which picking content to return
|
|
103
|
-
*
|
|
104
|
-
* Calculation speed comparison: globePick > auto >= pickPosition
|
|
105
|
-
*/
|
|
106
|
-
function canvasCoordToCartesian(canvasCoord, scene, mode = "auto") {
|
|
107
|
-
if (mode === "pickPosition") return scene.pickPosition(canvasCoord);
|
|
108
|
-
else if (mode === "globePick") {
|
|
109
|
-
const ray = scene.camera.getPickRay(canvasCoord);
|
|
110
|
-
return ray && scene.globe.pick(ray, scene);
|
|
111
|
-
} else {
|
|
112
|
-
if (scene.globe.depthTestAgainstTerrain) return scene.pickPosition(canvasCoord);
|
|
113
|
-
const position1 = scene.pickPosition(canvasCoord);
|
|
114
|
-
const ray = scene.camera.getPickRay(canvasCoord);
|
|
115
|
-
const position2 = ray && scene.globe.pick(ray, scene);
|
|
116
|
-
if (!position1) return position2;
|
|
117
|
-
const height1 = (position1 && cesium.Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;
|
|
118
|
-
const height2 = (position2 && cesium.Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;
|
|
119
|
-
return height1 < height2 ? position1 : position2;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region utils/cartesianToCanvasCoord.ts
|
|
125
|
-
/**
|
|
126
|
-
* Convert Cartesian coordinates to canvas coordinates
|
|
127
|
-
*
|
|
128
|
-
* @param position Cartesian coordinates
|
|
129
|
-
* @param scene Cesium.Scene instance
|
|
130
|
-
*/
|
|
131
|
-
function cartesianToCanvasCoord(position, scene) {
|
|
132
|
-
return scene.cartesianToCanvasCoordinates(position);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region utils/is.ts
|
|
137
|
-
const toString = Object.prototype.toString;
|
|
138
|
-
function isDef(val) {
|
|
139
|
-
return typeof val !== "undefined";
|
|
140
|
-
}
|
|
141
|
-
function isBoolean(val) {
|
|
142
|
-
return typeof val === "boolean";
|
|
143
|
-
}
|
|
144
|
-
function isFunction(val) {
|
|
145
|
-
return typeof val === "function";
|
|
146
|
-
}
|
|
147
|
-
function isNumber(val) {
|
|
148
|
-
return typeof val === "number";
|
|
149
|
-
}
|
|
150
|
-
function isString(val) {
|
|
151
|
-
return typeof val === "string";
|
|
152
|
-
}
|
|
153
|
-
function isObject(val) {
|
|
154
|
-
return toString.call(val) === "[object Object]";
|
|
155
|
-
}
|
|
156
|
-
function isWindow(val) {
|
|
157
|
-
return typeof window !== "undefined" && toString.call(val) === "[object Window]";
|
|
158
|
-
}
|
|
159
|
-
function isPromise(val) {
|
|
160
|
-
return !!val && (typeof val === "object" || typeof val === "function") && typeof val.then === "function";
|
|
161
|
-
}
|
|
162
|
-
function isElement(val) {
|
|
163
|
-
return !!(val && val.nodeName && val.nodeType === 1);
|
|
164
|
-
}
|
|
165
|
-
const isArray = Array.isArray;
|
|
166
|
-
function isBase64(val) {
|
|
167
|
-
const reg = /^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i;
|
|
168
|
-
return reg.test(val);
|
|
169
|
-
}
|
|
170
|
-
function assertError(condition, error) {
|
|
171
|
-
if (condition) throw new Error(error);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region utils/cesiumEquals.ts
|
|
176
|
-
/**
|
|
177
|
-
* Determines if two Cesium objects are equal.
|
|
178
|
-
*
|
|
179
|
-
* This function not only judges whether the instances are equal,
|
|
180
|
-
* but also judges the equals method in the example.
|
|
181
|
-
*
|
|
182
|
-
* @param left The first Cesium object
|
|
183
|
-
* @param right The second Cesium object
|
|
184
|
-
* @returns Returns true if the two Cesium objects are equal, otherwise false
|
|
185
|
-
*/
|
|
186
|
-
function cesiumEquals(left, right) {
|
|
187
|
-
return left === right || isFunction(left?.equals) && left.equals(right) || isFunction(right?.equals) && right.equals(left);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
//#endregion
|
|
191
|
-
//#region utils/toCoord.ts
|
|
192
|
-
/**
|
|
193
|
-
* Converts coordinates to an array or object in the specified format.
|
|
194
|
-
*
|
|
195
|
-
* @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.
|
|
196
|
-
* @param options Conversion options, including conversion type and whether to include altitude information.
|
|
197
|
-
* @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.
|
|
198
|
-
*
|
|
199
|
-
* @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.
|
|
200
|
-
* @template Alt Whether to include altitude information, default is false
|
|
201
|
-
*/
|
|
202
|
-
function toCoord(position, options = {}) {
|
|
203
|
-
if (!position) return void 0;
|
|
204
|
-
const { type = "Array", alt = false } = options;
|
|
205
|
-
let longitude, latitude, height;
|
|
206
|
-
if (position instanceof cesium.Cartesian3) {
|
|
207
|
-
const cartographic = cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
208
|
-
longitude = cesium.Math.toDegrees(cartographic.longitude);
|
|
209
|
-
latitude = cesium.Math.toDegrees(cartographic.latitude);
|
|
210
|
-
height = cartographic.height;
|
|
211
|
-
} else if (position instanceof cesium.Cartographic) {
|
|
212
|
-
const cartographic = position;
|
|
213
|
-
longitude = cesium.Math.toDegrees(cartographic.longitude);
|
|
214
|
-
latitude = cesium.Math.toDegrees(cartographic.latitude);
|
|
215
|
-
height = cartographic.height;
|
|
216
|
-
} else if (Array.isArray(position)) {
|
|
217
|
-
longitude = cesium.Math.toDegrees(position[0]);
|
|
218
|
-
latitude = cesium.Math.toDegrees(position[1]);
|
|
219
|
-
height = position[2];
|
|
220
|
-
} else {
|
|
221
|
-
longitude = position.longitude;
|
|
222
|
-
latitude = position.latitude;
|
|
223
|
-
height = position.height;
|
|
224
|
-
}
|
|
225
|
-
if (type === "Array") return alt ? [
|
|
226
|
-
longitude,
|
|
227
|
-
latitude,
|
|
228
|
-
height
|
|
229
|
-
] : [longitude, latitude];
|
|
230
|
-
else return alt ? {
|
|
231
|
-
longitude,
|
|
232
|
-
latitude,
|
|
233
|
-
height
|
|
234
|
-
} : {
|
|
235
|
-
longitude,
|
|
236
|
-
latitude
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region utils/convertDMS.ts
|
|
242
|
-
/**
|
|
243
|
-
* Convert degrees to DMS (Degrees Minutes Seconds) format string
|
|
244
|
-
*
|
|
245
|
-
* @param degrees The angle value
|
|
246
|
-
* @param precision The number of decimal places to retain for the seconds, defaults to 3
|
|
247
|
-
* @returns A DMS formatted string in the format: degrees° minutes′ seconds″
|
|
248
|
-
*/
|
|
249
|
-
function dmsEncode(degrees, precision = 3) {
|
|
250
|
-
const str = `${degrees}`;
|
|
251
|
-
let i = str.indexOf(".");
|
|
252
|
-
const d = i < 0 ? str : str.slice(0, Math.max(0, i));
|
|
253
|
-
let m = "0";
|
|
254
|
-
let s = "0";
|
|
255
|
-
if (i > 0) {
|
|
256
|
-
m = `0${str.slice(Math.max(0, i))}`;
|
|
257
|
-
m = `${+m * 60}`;
|
|
258
|
-
i = m.indexOf(".");
|
|
259
|
-
if (i > 0) {
|
|
260
|
-
s = `0${m.slice(Math.max(0, i))}`;
|
|
261
|
-
m = m.slice(0, Math.max(0, i));
|
|
262
|
-
s = `${+s * 60}`;
|
|
263
|
-
i = s.indexOf(".");
|
|
264
|
-
s = s.slice(0, Math.max(0, i + 4));
|
|
265
|
-
s = (+s).toFixed(precision);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return `${Math.abs(+d)}°${+m}′${+s}″`;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value
|
|
272
|
-
*
|
|
273
|
-
* @param dmsCode DMS formatted string, e.g. "120°30′45″N"
|
|
274
|
-
* @returns The decoded decimal angle value, or 0 if decoding fails
|
|
275
|
-
*/
|
|
276
|
-
function dmsDecode(dmsCode) {
|
|
277
|
-
const [dd, msStr] = dmsCode.split("°") ?? [];
|
|
278
|
-
const [mm, sStr] = msStr?.split("′") ?? [];
|
|
279
|
-
const ss = sStr?.split("″")[0];
|
|
280
|
-
const d = Number(dd) || 0;
|
|
281
|
-
const m = (Number(mm) || 0) / 60;
|
|
282
|
-
const s = (Number(ss) || 0) / 60 / 60;
|
|
283
|
-
const degrees = d + m + s;
|
|
284
|
-
if (degrees === 0) return 0;
|
|
285
|
-
else {
|
|
286
|
-
let res = degrees;
|
|
287
|
-
if ([
|
|
288
|
-
"W",
|
|
289
|
-
"w",
|
|
290
|
-
"S",
|
|
291
|
-
"s"
|
|
292
|
-
].includes(dmsCode[dmsCode.length - 1])) res = -res;
|
|
293
|
-
return res;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Convert latitude and longitude coordinates to degrees-minutes-seconds format
|
|
298
|
-
*
|
|
299
|
-
* @param position The latitude and longitude coordinates
|
|
300
|
-
* @param precision The number of decimal places to retain for 'seconds', default is 3
|
|
301
|
-
* @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails
|
|
302
|
-
*/
|
|
303
|
-
function degreesToDms(position, precision = 3) {
|
|
304
|
-
const coord = toCoord(position, { alt: true });
|
|
305
|
-
if (!coord) return;
|
|
306
|
-
const [longitude, latitude, height] = coord;
|
|
307
|
-
const x = dmsEncode(longitude, precision);
|
|
308
|
-
const y = dmsEncode(latitude, precision);
|
|
309
|
-
return [
|
|
310
|
-
`${x}${longitude > 0 ? "E" : "W"}`,
|
|
311
|
-
`${y}${latitude > 0 ? "N" : "S"}`,
|
|
312
|
-
height
|
|
313
|
-
];
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates
|
|
317
|
-
*
|
|
318
|
-
* @param dms The latitude or longitude coordinate in DMS format
|
|
319
|
-
* @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails
|
|
320
|
-
*/
|
|
321
|
-
function dmsToDegrees(dms) {
|
|
322
|
-
const [x, y, height] = dms;
|
|
323
|
-
const longitude = dmsDecode(x);
|
|
324
|
-
const latitude = dmsDecode(y);
|
|
325
|
-
return [
|
|
326
|
-
longitude,
|
|
327
|
-
latitude,
|
|
328
|
-
Number(height) || 0
|
|
329
|
-
];
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region utils/isCesiumConstant.ts
|
|
334
|
-
/**
|
|
335
|
-
* Determines if the Cesium property is a constant.
|
|
336
|
-
*
|
|
337
|
-
* @param value Cesium property
|
|
338
|
-
*/
|
|
339
|
-
function isCesiumConstant(value) {
|
|
340
|
-
return !(0, cesium.defined)(value) || !!value.isConstant;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
//#endregion
|
|
344
|
-
//#region utils/material.ts
|
|
345
|
-
/**
|
|
346
|
-
* Only as a type fix for `Cesium.Material`
|
|
347
|
-
*/
|
|
348
|
-
var CesiumMaterial = class extends cesium.Material {
|
|
349
|
-
constructor(options) {
|
|
350
|
-
super(options);
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* Get material from cache, alias of `Material._materialCache.getMaterial`
|
|
355
|
-
*/
|
|
356
|
-
function getMaterialCache(type) {
|
|
357
|
-
return cesium.Material._materialCache.getMaterial(type);
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`
|
|
361
|
-
*/
|
|
362
|
-
function addMaterialCache(type, material) {
|
|
363
|
-
return cesium.Material._materialCache.addMaterial(type, material);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region utils/pick.ts
|
|
368
|
-
/**
|
|
369
|
-
* Analyze the result of Cesium's `scene.pick` and convert it to an array format
|
|
370
|
-
*/
|
|
371
|
-
function resolvePick(pick = {}) {
|
|
372
|
-
const { primitive, id, primitiveCollection, collection } = pick;
|
|
373
|
-
const entityCollection = id && id.entityCollection || null;
|
|
374
|
-
const dataSource = entityCollection && entityCollection.owner || null;
|
|
375
|
-
const ids = Array.isArray(id) ? id : [id].filter(Boolean);
|
|
376
|
-
return [
|
|
377
|
-
...ids,
|
|
378
|
-
primitive,
|
|
379
|
-
primitiveCollection,
|
|
380
|
-
collection,
|
|
381
|
-
entityCollection,
|
|
382
|
-
dataSource
|
|
383
|
-
].filter((e) => !!e);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Determine if the given array of graphics is hit by Cesium's `scene.pick`
|
|
387
|
-
*
|
|
388
|
-
* @param pick The `scene.pick` object used for matching
|
|
389
|
-
* @param graphic An array of graphics to check for hits
|
|
390
|
-
*/
|
|
391
|
-
function pickHitGraphic(pick, graphic) {
|
|
392
|
-
if (!Array.isArray(graphic) || !graphic.length) return false;
|
|
393
|
-
const elements = resolvePick(pick);
|
|
394
|
-
if (!elements.length) return false;
|
|
395
|
-
return elements.some((element) => graphic.includes(element));
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
//#endregion
|
|
399
|
-
//#region utils/property.ts
|
|
400
|
-
/**
|
|
401
|
-
* Is Cesium.Property
|
|
402
|
-
* @param value - The target object
|
|
403
|
-
*/
|
|
404
|
-
function isProperty(value) {
|
|
405
|
-
return value && isFunction(value.getValue);
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation
|
|
409
|
-
* ```typescript
|
|
410
|
-
* toPropertyValue('val') //=> 'val'
|
|
411
|
-
* toPropertyValue(new ConstantProperty('val')) //=> 'val'
|
|
412
|
-
* toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'
|
|
413
|
-
* ```
|
|
414
|
-
*
|
|
415
|
-
* @param value - The value to convert
|
|
416
|
-
*/
|
|
417
|
-
function toPropertyValue(value, time) {
|
|
418
|
-
return isProperty(value) ? value.getValue(time) : value;
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation
|
|
422
|
-
*
|
|
423
|
-
* @param value - The property value or getter to convert, can be undefined or null
|
|
424
|
-
* @param isConstant - The second parameter for converting to CallbackProperty
|
|
425
|
-
* @returns Returns the converted Property object, if value is undefined or null, returns undefined
|
|
426
|
-
*/
|
|
427
|
-
function toProperty(value, isConstant = false) {
|
|
428
|
-
return isProperty(value) ? value : isFunction(value) ? new cesium.CallbackProperty(value, isConstant) : new cesium.ConstantProperty(value);
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Create a Cesium property key
|
|
432
|
-
*
|
|
433
|
-
* @param scope The host object
|
|
434
|
-
* @param field The property name
|
|
435
|
-
* @param maybeProperty Optional property or getter
|
|
436
|
-
* @param readonly Whether the property is read-only
|
|
437
|
-
*/
|
|
438
|
-
function createPropertyField(scope, field, maybeProperty, readonly$2) {
|
|
439
|
-
let removeOwnerListener;
|
|
440
|
-
const ownerBinding = (value) => {
|
|
441
|
-
removeOwnerListener?.();
|
|
442
|
-
if ((0, cesium.defined)(value?.definitionChanged)) removeOwnerListener = value?.definitionChanged?.addEventListener(() => {
|
|
443
|
-
scope.definitionChanged.raiseEvent(scope, field, value, value);
|
|
444
|
-
});
|
|
445
|
-
};
|
|
446
|
-
const privateField = `_${field}`;
|
|
447
|
-
const property = toProperty(maybeProperty);
|
|
448
|
-
scope[privateField] = property;
|
|
449
|
-
ownerBinding(property);
|
|
450
|
-
if (readonly$2) Object.defineProperty(scope, field, { get() {
|
|
451
|
-
return scope[privateField];
|
|
452
|
-
} });
|
|
453
|
-
else Object.defineProperty(scope, field, {
|
|
454
|
-
get() {
|
|
455
|
-
return scope[privateField];
|
|
456
|
-
},
|
|
457
|
-
set(value) {
|
|
458
|
-
const previous = scope[privateField];
|
|
459
|
-
if (scope[privateField] !== value) {
|
|
460
|
-
scope[privateField] = value;
|
|
461
|
-
ownerBinding(value);
|
|
462
|
-
if ((0, cesium.defined)(scope.definitionChanged)) scope.definitionChanged.raiseEvent(scope, field, value, previous);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
function createCesiumAttribute(scope, key, value, options = {}) {
|
|
468
|
-
const allowToProperty = !!options.toProperty;
|
|
469
|
-
const shallowClone = !!options.shallowClone;
|
|
470
|
-
const changedEventKey = options.changedEventKey || "definitionChanged";
|
|
471
|
-
const changedEvent = Reflect.get(scope, changedEventKey);
|
|
472
|
-
const privateKey = `_${String(key)}`;
|
|
473
|
-
const attribute = allowToProperty ? toProperty(value) : value;
|
|
474
|
-
Reflect.set(scope, privateKey, attribute);
|
|
475
|
-
const obj = { get() {
|
|
476
|
-
const value$1 = Reflect.get(scope, privateKey);
|
|
477
|
-
if (shallowClone) return Array.isArray(value$1) ? [...value$1] : { ...value$1 };
|
|
478
|
-
else return value$1;
|
|
479
|
-
} };
|
|
480
|
-
let previousListener;
|
|
481
|
-
const serial = (property, previous) => {
|
|
482
|
-
previousListener?.();
|
|
483
|
-
previousListener = property?.definitionChanged?.addEventListener(() => {
|
|
484
|
-
changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);
|
|
485
|
-
});
|
|
486
|
-
};
|
|
487
|
-
if (!options.readonly) {
|
|
488
|
-
if (allowToProperty && isProperty(value)) serial(value);
|
|
489
|
-
obj.set = (value$1) => {
|
|
490
|
-
if (allowToProperty && !isProperty(value$1)) throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);
|
|
491
|
-
const previous = Reflect.get(scope, privateKey);
|
|
492
|
-
if (previous !== value$1) {
|
|
493
|
-
Reflect.set(scope, privateKey, value$1);
|
|
494
|
-
changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value$1, previous);
|
|
495
|
-
if (allowToProperty) serial(value$1);
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
Object.defineProperty(scope, key, obj);
|
|
500
|
-
}
|
|
501
|
-
function createCesiumProperty(scope, key, value, options = {}) {
|
|
502
|
-
return createCesiumAttribute(scope, key, value, {
|
|
503
|
-
...options,
|
|
504
|
-
toProperty: true
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
//#endregion
|
|
509
|
-
//#region utils/throttle.ts
|
|
510
|
-
/**
|
|
511
|
-
* Throttle function, which limits the frequency of execution of the function
|
|
512
|
-
*
|
|
513
|
-
* @param callback raw function
|
|
514
|
-
* @param delay Throttled delay duration (ms)
|
|
515
|
-
* @param trailing Trigger callback function after last call @default true
|
|
516
|
-
* @param leading Trigger the callback function immediately on the first call @default false
|
|
517
|
-
* @returns Throttle function
|
|
518
|
-
*/
|
|
519
|
-
function throttle(callback, delay = 100, trailing = true, leading = false) {
|
|
520
|
-
const restList = [];
|
|
521
|
-
let tracked = false;
|
|
522
|
-
const trigger = async () => {
|
|
523
|
-
await (0, __vueuse_core.promiseTimeout)(delay);
|
|
524
|
-
tracked = false;
|
|
525
|
-
if (leading) try {
|
|
526
|
-
callback(...restList[0]);
|
|
527
|
-
} catch (error) {
|
|
528
|
-
console.error(error);
|
|
529
|
-
}
|
|
530
|
-
if (trailing && (!leading || restList.length > 1)) try {
|
|
531
|
-
callback(...restList[restList.length - 1]);
|
|
532
|
-
} catch (error) {
|
|
533
|
-
console.error(error);
|
|
534
|
-
}
|
|
535
|
-
restList.length = 0;
|
|
536
|
-
};
|
|
537
|
-
return (...rest) => {
|
|
538
|
-
if (restList.length < 2) restList.push(rest);
|
|
539
|
-
else restList[1] = rest;
|
|
540
|
-
if (!tracked) {
|
|
541
|
-
tracked = true;
|
|
542
|
-
trigger();
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
//#endregion
|
|
548
|
-
//#region utils/toCartesian3.ts
|
|
549
|
-
/**
|
|
550
|
-
* Converts position to a coordinate point in the Cartesian coordinate system
|
|
551
|
-
*
|
|
552
|
-
* @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
|
|
553
|
-
* @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned
|
|
554
|
-
*/
|
|
555
|
-
function toCartesian3(position) {
|
|
556
|
-
if (!position) return void 0;
|
|
557
|
-
if (position instanceof cesium.Cartesian3) return position.clone();
|
|
558
|
-
else if (position instanceof cesium.Cartographic) return cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
|
|
559
|
-
else if (Array.isArray(position)) return cesium.Cartesian3.fromDegrees(position[0], position[1], position[2]);
|
|
560
|
-
else return cesium.Cartesian3.fromDegrees(position.longitude, position.latitude, position.height);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
//#endregion
|
|
564
|
-
//#region utils/toCartographic.ts
|
|
565
|
-
/**
|
|
566
|
-
* Converts a position to a Cartographic coordinate point
|
|
567
|
-
*
|
|
568
|
-
* @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
|
|
569
|
-
* @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid
|
|
570
|
-
*/
|
|
571
|
-
function toCartographic(position) {
|
|
572
|
-
if (!position) return void 0;
|
|
573
|
-
if (position instanceof cesium.Cartesian3) return cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
574
|
-
else if (position instanceof cesium.Cartographic) return position.clone();
|
|
575
|
-
else if (Array.isArray(position)) return cesium.Cartographic.fromDegrees(position[0], position[1], position[2]);
|
|
576
|
-
else return cesium.Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
//#endregion
|
|
580
|
-
//#region utils/tryRun.ts
|
|
581
|
-
/**
|
|
582
|
-
* Safely execute the provided function without throwing errors,
|
|
583
|
-
* essentially a simple wrapper around a `try...catch...` block
|
|
584
|
-
*/
|
|
585
|
-
function tryRun(fn) {
|
|
586
|
-
return (...args) => {
|
|
587
|
-
try {
|
|
588
|
-
return fn?.(...args);
|
|
589
|
-
} catch (error) {
|
|
590
|
-
console.error(error);
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
47
|
//#endregion
|
|
596
48
|
//#region toPromiseValue/index.ts
|
|
597
49
|
/**
|
|
@@ -616,10 +68,10 @@ async function toPromiseValue(source, options = {}) {
|
|
|
616
68
|
try {
|
|
617
69
|
const { raw = true } = options;
|
|
618
70
|
let value;
|
|
619
|
-
if (isFunction(source)) value = await source();
|
|
71
|
+
if ((0, __vesium_shared.isFunction)(source)) value = await source();
|
|
620
72
|
else {
|
|
621
73
|
const result = (0, vue.toValue)(source);
|
|
622
|
-
value = isPromise(result) ? await result : result;
|
|
74
|
+
value = (0, __vesium_shared.isPromise)(result) ? await result : result;
|
|
623
75
|
}
|
|
624
76
|
return raw ? (0, vue.toRaw)(value) : value;
|
|
625
77
|
} catch (error) {
|
|
@@ -762,17 +214,14 @@ function useCesiumFps(options = {}) {
|
|
|
762
214
|
/**
|
|
763
215
|
* Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.
|
|
764
216
|
* - note: This is a basic function that is intended to be called by other lower-level function
|
|
765
|
-
* @param addFn - add SideEffect function. eg.`entites.add`
|
|
766
|
-
* @param removeFn - Clean SideEffect function. eg.`entities.remove`
|
|
767
|
-
* @param removeScopeArgs - The parameters to pass for `removeScope` triggered when the component is unmounted
|
|
768
|
-
*
|
|
769
217
|
* @returns Contains side effect addition and removal functions
|
|
770
218
|
*/
|
|
771
|
-
function useCollectionScope(
|
|
219
|
+
function useCollectionScope(options) {
|
|
220
|
+
const { addEffect, removeEffect, removeScopeArgs } = options;
|
|
772
221
|
const scope = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
773
222
|
const add = (instance, ...args) => {
|
|
774
|
-
const result =
|
|
775
|
-
if (isPromise(result)) return new Promise((resolve, reject) => {
|
|
223
|
+
const result = addEffect(instance, ...args);
|
|
224
|
+
if ((0, __vesium_shared.isPromise)(result)) return new Promise((resolve, reject) => {
|
|
776
225
|
result.then((i) => {
|
|
777
226
|
scope.add(i);
|
|
778
227
|
resolve(i);
|
|
@@ -785,7 +234,7 @@ function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
|
785
234
|
};
|
|
786
235
|
const remove = (instance, ...args) => {
|
|
787
236
|
scope.delete(instance);
|
|
788
|
-
return
|
|
237
|
+
return removeEffect(instance, ...args);
|
|
789
238
|
};
|
|
790
239
|
const removeWhere = (predicate, ...args) => {
|
|
791
240
|
scope.forEach((instance) => {
|
|
@@ -814,8 +263,7 @@ function useDataSource(dataSources, options = {}) {
|
|
|
814
263
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
|
|
815
264
|
const viewer = useViewer();
|
|
816
265
|
(0, vue.watchEffect)((onCleanup) => {
|
|
817
|
-
|
|
818
|
-
if (_isActive) {
|
|
266
|
+
if ((0, vue.toValue)(isActive)) {
|
|
819
267
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
820
268
|
const _collection = collection ?? viewer.value?.dataSources;
|
|
821
269
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -831,7 +279,7 @@ function useDataSource(dataSources, options = {}) {
|
|
|
831
279
|
//#endregion
|
|
832
280
|
//#region useDataSourceScope/index.ts
|
|
833
281
|
/**
|
|
834
|
-
*
|
|
282
|
+
* Scope the SideEffects of `DataSourceCollection` operations and automatically remove them when unmounted
|
|
835
283
|
*/
|
|
836
284
|
function useDataSourceScope(options = {}) {
|
|
837
285
|
const { collection: _collection, destroyOnRemove } = options;
|
|
@@ -839,21 +287,25 @@ function useDataSourceScope(options = {}) {
|
|
|
839
287
|
const collection = (0, vue.computed)(() => {
|
|
840
288
|
return (0, vue.toValue)(_collection) ?? viewer.value?.dataSources;
|
|
841
289
|
});
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
290
|
+
return useCollectionScope({
|
|
291
|
+
addEffect(instance) {
|
|
292
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
293
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
294
|
+
instance.then((i) => {
|
|
295
|
+
collection.value.add(i);
|
|
296
|
+
resolve(i);
|
|
297
|
+
}).catch((error) => reject(error));
|
|
298
|
+
});
|
|
299
|
+
else {
|
|
300
|
+
collection.value.add(instance);
|
|
301
|
+
return instance;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
removeEffect(instance, destroy) {
|
|
305
|
+
return !!collection.value?.remove(instance, destroy);
|
|
306
|
+
},
|
|
307
|
+
removeScopeArgs: [destroyOnRemove]
|
|
308
|
+
});
|
|
857
309
|
}
|
|
858
310
|
|
|
859
311
|
//#endregion
|
|
@@ -862,19 +314,26 @@ function useDataSourceScope(options = {}) {
|
|
|
862
314
|
* Cesium HtmlElement Overlay
|
|
863
315
|
*/
|
|
864
316
|
function useElementOverlay(target, position, options = {}) {
|
|
865
|
-
const { referenceWindow, horizontal = "center", vertical = "bottom", offset = {
|
|
317
|
+
const { referenceWindow, horizontal = "center", vertical = "bottom", clampToGround, offset = {
|
|
866
318
|
x: 0,
|
|
867
319
|
y: 0
|
|
868
320
|
} } = options;
|
|
869
|
-
const cartesian3 = (0, vue.computed)(() => toCartesian3((0, vue.toValue)(position)));
|
|
870
321
|
const viewer = useViewer();
|
|
322
|
+
const cartesian3 = (0, vue.computed)(() => {
|
|
323
|
+
if (!(0, vue.toValue)(clampToGround)) return (0, __vesium_shared.toCartesian3)((0, vue.toValue)(position));
|
|
324
|
+
else {
|
|
325
|
+
const cartographic = (0, __vesium_shared.toCartographic)((0, vue.toValue)(position));
|
|
326
|
+
cartographic.height = +(viewer.value?.scene.globe.getHeight(cartographic) || 0).toFixed(2);
|
|
327
|
+
return (0, __vesium_shared.toCartesian3)(cartographic);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
871
330
|
const coord = (0, vue.shallowRef)();
|
|
872
331
|
useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
|
|
873
332
|
if (!viewer.value?.scene) return;
|
|
874
333
|
if (!cartesian3.value) coord.value = void 0;
|
|
875
334
|
else {
|
|
876
|
-
const
|
|
877
|
-
coord.value = !cesium.Cartesian2.equals(
|
|
335
|
+
const result = (0, __vesium_shared.cartesianToCanvasCoord)(cartesian3.value, viewer.value.scene);
|
|
336
|
+
coord.value = !cesium.Cartesian2.equals(result, coord.value) ? result : coord.value;
|
|
878
337
|
}
|
|
879
338
|
});
|
|
880
339
|
const canvasBounding = (0, __vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
|
|
@@ -935,8 +394,7 @@ function useEntity(data, options = {}) {
|
|
|
935
394
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
936
395
|
const viewer = useViewer();
|
|
937
396
|
(0, vue.watchEffect)((onCleanup) => {
|
|
938
|
-
|
|
939
|
-
if (_isActive) {
|
|
397
|
+
if ((0, vue.toValue)(isActive)) {
|
|
940
398
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
941
399
|
const _collection = collection ?? viewer.value?.entities;
|
|
942
400
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -960,22 +418,25 @@ function useEntityScope(options = {}) {
|
|
|
960
418
|
const collection = (0, vue.computed)(() => {
|
|
961
419
|
return (0, vue.toValue)(_collection) ?? viewer.value?.entities;
|
|
962
420
|
});
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
421
|
+
return useCollectionScope({
|
|
422
|
+
addEffect(instance) {
|
|
423
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
424
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
425
|
+
instance.then((i) => {
|
|
426
|
+
collection.value.add(i);
|
|
427
|
+
resolve(i);
|
|
428
|
+
}).catch((error) => reject(error));
|
|
429
|
+
});
|
|
430
|
+
else {
|
|
431
|
+
collection.value.add(instance);
|
|
432
|
+
return instance;
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
removeEffect(instance) {
|
|
436
|
+
return !!collection.value?.remove(instance);
|
|
437
|
+
},
|
|
438
|
+
removeScopeArgs: []
|
|
439
|
+
});
|
|
979
440
|
}
|
|
980
441
|
|
|
981
442
|
//#endregion
|
|
@@ -1031,7 +492,7 @@ function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
|
1031
492
|
const modifierValue = (0, vue.toValue)(modifier);
|
|
1032
493
|
const handlerValue = (0, vue.toValue)(handler);
|
|
1033
494
|
if (!handlerValue || !isActive.value || !inputAction) return;
|
|
1034
|
-
if (isDef(typeValue)) {
|
|
495
|
+
if ((0, __vesium_shared.isDef)(typeValue)) {
|
|
1035
496
|
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
1036
497
|
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
1037
498
|
}
|
|
@@ -1080,7 +541,7 @@ function useDrag(listener) {
|
|
|
1080
541
|
dragging.value = true;
|
|
1081
542
|
position.value = event.position.clone();
|
|
1082
543
|
});
|
|
1083
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, throttle(({ startPosition, endPosition }) => {
|
|
544
|
+
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0, __vesium_shared.throttle)(({ startPosition, endPosition }) => {
|
|
1084
545
|
motionEvent.value = {
|
|
1085
546
|
startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
|
|
1086
547
|
endPosition: endPosition.clone()
|
|
@@ -1198,7 +659,7 @@ function useGraphicEvent() {
|
|
|
1198
659
|
const collection = /* @__PURE__ */ new WeakMap();
|
|
1199
660
|
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1200
661
|
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1201
|
-
const
|
|
662
|
+
const remove = (graphic, type, listener) => {
|
|
1202
663
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1203
664
|
collection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1204
665
|
cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
|
|
@@ -1211,30 +672,29 @@ function useGraphicEvent() {
|
|
|
1211
672
|
if (dragCursorCollection?.get(_graphic)?.get(type)?.size === 0) dragCursorCollection?.get(_graphic)?.delete(type);
|
|
1212
673
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1213
674
|
};
|
|
1214
|
-
const
|
|
675
|
+
const add = (graphic, type, listener, options = {}) => {
|
|
1215
676
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1216
677
|
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1217
678
|
const eventTypeMap = collection.get(_graphic);
|
|
1218
679
|
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
1219
|
-
|
|
1220
|
-
listeners.add(listener);
|
|
680
|
+
eventTypeMap.get(type).add(listener);
|
|
1221
681
|
let { cursor = "pointer", dragCursor } = options;
|
|
1222
|
-
if (isDef(cursor)) {
|
|
1223
|
-
const _cursor = isFunction(cursor) ? cursor : () => cursor;
|
|
682
|
+
if ((0, __vesium_shared.isDef)(cursor)) {
|
|
683
|
+
const _cursor = (0, __vesium_shared.isFunction)(cursor) ? cursor : () => cursor;
|
|
1224
684
|
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1225
685
|
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1226
686
|
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
1227
687
|
}
|
|
1228
|
-
if (type === "DRAG") dragCursor ??= (event) => event?.dragging ? "crosshair" : void 0;
|
|
1229
|
-
if (isDef(dragCursor)) {
|
|
1230
|
-
const _dragCursor = isFunction(dragCursor) ? dragCursor : () => dragCursor;
|
|
688
|
+
if (type === "DRAG") dragCursor ??= ((event) => event?.dragging ? "crosshair" : void 0);
|
|
689
|
+
if ((0, __vesium_shared.isDef)(dragCursor)) {
|
|
690
|
+
const _dragCursor = (0, __vesium_shared.isFunction)(dragCursor) ? dragCursor : () => dragCursor;
|
|
1231
691
|
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1232
692
|
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1233
693
|
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
1234
694
|
}
|
|
1235
|
-
return () =>
|
|
695
|
+
return () => remove(graphic, type, listener);
|
|
1236
696
|
};
|
|
1237
|
-
const
|
|
697
|
+
const clear = (graphic, type) => {
|
|
1238
698
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1239
699
|
if (type === "all") {
|
|
1240
700
|
collection.delete(_graphic);
|
|
@@ -1250,42 +710,40 @@ function useGraphicEvent() {
|
|
|
1250
710
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1251
711
|
};
|
|
1252
712
|
for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
collection.get(graphic)?.get(type)?.forEach((fn) => tryRun(fn)?.(event));
|
|
713
|
+
(0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
714
|
+
collection.get(graphic)?.get(type)?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)?.(event));
|
|
1256
715
|
});
|
|
1257
716
|
});
|
|
1258
717
|
const dragging = (0, vue.ref)(false);
|
|
1259
718
|
const viewer = useViewer();
|
|
1260
719
|
useHover((event) => {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
collection.get(graphic)?.get("HOVER")?.forEach((fn) => tryRun(fn)?.(event));
|
|
720
|
+
(0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
721
|
+
collection.get(graphic)?.get("HOVER")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)?.(event));
|
|
1264
722
|
if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
|
|
1265
723
|
map.forEach((fn) => {
|
|
1266
|
-
const cursor = event.hovering ? tryRun(fn)(event) : "";
|
|
724
|
+
const cursor = event.hovering ? (0, __vesium_shared.tryRun)(fn)(event) : "";
|
|
1267
725
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1268
726
|
});
|
|
1269
727
|
});
|
|
1270
728
|
});
|
|
1271
729
|
});
|
|
1272
730
|
useDrag((event) => {
|
|
1273
|
-
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
731
|
+
const graphics = (0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
1274
732
|
dragging.value = event.dragging;
|
|
1275
733
|
graphics.forEach((graphic) => {
|
|
1276
|
-
collection.get(graphic)?.get("DRAG")?.forEach((fn) => tryRun(fn)(event));
|
|
734
|
+
collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)(event));
|
|
1277
735
|
dragCursorCollection.get(graphic)?.forEach((map) => {
|
|
1278
736
|
map.forEach((fn) => {
|
|
1279
|
-
const cursor = event.dragging ? tryRun(fn)(event) : "";
|
|
737
|
+
const cursor = event.dragging ? (0, __vesium_shared.tryRun)(fn)(event) : "";
|
|
1280
738
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1281
739
|
});
|
|
1282
740
|
});
|
|
1283
741
|
});
|
|
1284
742
|
});
|
|
1285
743
|
return {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
744
|
+
add,
|
|
745
|
+
remove,
|
|
746
|
+
clear
|
|
1289
747
|
};
|
|
1290
748
|
}
|
|
1291
749
|
|
|
@@ -1296,8 +754,7 @@ function useImageryLayer(data, options = {}) {
|
|
|
1296
754
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
1297
755
|
const viewer = useViewer();
|
|
1298
756
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1299
|
-
|
|
1300
|
-
if (_isActive) {
|
|
757
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1301
758
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1302
759
|
const _collection = collection ?? viewer.value?.imageryLayers;
|
|
1303
760
|
if (collection?.isDestroyed()) return;
|
|
@@ -1333,22 +790,25 @@ function useImageryLayerScope(options = {}) {
|
|
|
1333
790
|
const collection = (0, vue.computed)(() => {
|
|
1334
791
|
return (0, vue.toValue)(_collection) ?? viewer.value?.imageryLayers;
|
|
1335
792
|
});
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
793
|
+
return useCollectionScope({
|
|
794
|
+
addEffect(instance, index) {
|
|
795
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
796
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
797
|
+
instance.then((i) => {
|
|
798
|
+
collection.value.add(i, index);
|
|
799
|
+
resolve(i);
|
|
800
|
+
}).catch((error) => reject(error));
|
|
801
|
+
});
|
|
802
|
+
else {
|
|
803
|
+
collection.value.add(instance, index);
|
|
804
|
+
return instance;
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
removeEffect(instance, destroy) {
|
|
808
|
+
return !!collection.value?.remove(instance, destroy);
|
|
809
|
+
},
|
|
810
|
+
removeScopeArgs: [destroyOnRemove]
|
|
811
|
+
});
|
|
1352
812
|
}
|
|
1353
813
|
|
|
1354
814
|
//#endregion
|
|
@@ -1359,8 +819,7 @@ function usePostProcessStage(data, options = {}) {
|
|
|
1359
819
|
const viewer = useViewer();
|
|
1360
820
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1361
821
|
if (!viewer.value) return;
|
|
1362
|
-
|
|
1363
|
-
if (_isActive) {
|
|
822
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1364
823
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1365
824
|
const _collection = collection ?? viewer.value.scene.postProcessStages;
|
|
1366
825
|
list.forEach((item) => item && _collection.add(item));
|
|
@@ -1384,21 +843,22 @@ function usePostProcessStageScope(options = {}) {
|
|
|
1384
843
|
const collection = (0, vue.computed)(() => {
|
|
1385
844
|
return (0, vue.toValue)(_collection) ?? viewer.value?.postProcessStages;
|
|
1386
845
|
});
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
846
|
+
return useCollectionScope({
|
|
847
|
+
addEffect(instance) {
|
|
848
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
849
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
850
|
+
instance.then((instance$1) => {
|
|
851
|
+
collection.value.add(instance$1);
|
|
852
|
+
resolve(instance$1);
|
|
853
|
+
}).catch((error) => reject(error));
|
|
854
|
+
});
|
|
855
|
+
else return collection.value.add(instance);
|
|
856
|
+
},
|
|
857
|
+
removeEffect(instance, ...args) {
|
|
858
|
+
return !!collection.value?.remove(instance, ...args);
|
|
859
|
+
},
|
|
860
|
+
removeScopeArgs: []
|
|
861
|
+
});
|
|
1402
862
|
}
|
|
1403
863
|
|
|
1404
864
|
//#endregion
|
|
@@ -1408,8 +868,7 @@ function usePrimitive(data, options = {}) {
|
|
|
1408
868
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
1409
869
|
const viewer = useViewer();
|
|
1410
870
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1411
|
-
|
|
1412
|
-
if (_isActive) {
|
|
871
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1413
872
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1414
873
|
const _collection = collection === "ground" ? viewer.value?.scene.groundPrimitives : collection ?? viewer.value?.scene.primitives;
|
|
1415
874
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -1431,16 +890,22 @@ function usePrimitiveScope(options = {}) {
|
|
|
1431
890
|
const { collection: _collection } = options;
|
|
1432
891
|
const viewer = useViewer();
|
|
1433
892
|
const collection = (0, vue.computed)(() => {
|
|
1434
|
-
|
|
893
|
+
const value = (0, vue.toValue)(_collection);
|
|
894
|
+
return value === "ground" ? viewer.value?.scene?.groundPrimitives : value || viewer.value?.scene.primitives;
|
|
895
|
+
});
|
|
896
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope({
|
|
897
|
+
addEffect(instance, ...args) {
|
|
898
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
899
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
900
|
+
instance.then((instance$1) => resolve(collection.value.add(instance$1, ...args))).catch((error) => reject(error));
|
|
901
|
+
});
|
|
902
|
+
else return collection.value.add(instance, ...args);
|
|
903
|
+
},
|
|
904
|
+
removeEffect(instance) {
|
|
905
|
+
return !!collection.value?.remove(instance);
|
|
906
|
+
},
|
|
907
|
+
removeScopeArgs: []
|
|
1435
908
|
});
|
|
1436
|
-
const addFn = (primitive) => {
|
|
1437
|
-
if (!collection.value) throw new Error("collection is not defined");
|
|
1438
|
-
return collection.value.add(primitive);
|
|
1439
|
-
};
|
|
1440
|
-
const removeFn = (primitive) => {
|
|
1441
|
-
return !!collection.value?.remove(primitive);
|
|
1442
|
-
};
|
|
1443
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
1444
909
|
return {
|
|
1445
910
|
scope,
|
|
1446
911
|
add,
|
|
@@ -1509,21 +974,15 @@ function useScaleBar(options = {}) {
|
|
|
1509
974
|
const leftPosition = scene.globe.pick(left, scene);
|
|
1510
975
|
const rightPosition = scene.globe.pick(right, scene);
|
|
1511
976
|
if (!leftPosition || !rightPosition) return;
|
|
1512
|
-
|
|
1513
|
-
const rightCartographic = scene.globe.ellipsoid.cartesianToCartographic(rightPosition);
|
|
1514
|
-
const geodesic = new cesium.EllipsoidGeodesic(leftCartographic, rightCartographic);
|
|
1515
|
-
pixelDistance.value = geodesic.surfaceDistance;
|
|
977
|
+
pixelDistance.value = new cesium.EllipsoidGeodesic(scene.globe.ellipsoid.cartesianToCartographic(leftPosition), scene.globe.ellipsoid.cartesianToCartographic(rightPosition)).surfaceDistance;
|
|
1516
978
|
};
|
|
1517
979
|
(0, __vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
|
|
1518
|
-
useCesiumEventListener(() => viewer.value?.camera.changed, throttle(setPixelDistance, delay));
|
|
980
|
+
useCesiumEventListener(() => viewer.value?.camera.changed, (0, __vesium_shared.throttle)(setPixelDistance, delay));
|
|
1519
981
|
const distance = (0, vue.computed)(() => {
|
|
1520
982
|
if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
|
|
1521
983
|
});
|
|
1522
984
|
const width = (0, vue.computed)(() => {
|
|
1523
|
-
if (distance.value && pixelDistance.value)
|
|
1524
|
-
const value = distance.value / pixelDistance.value;
|
|
1525
|
-
return value;
|
|
1526
|
-
}
|
|
985
|
+
if (distance.value && pixelDistance.value) return distance.value / pixelDistance.value;
|
|
1527
986
|
return 0;
|
|
1528
987
|
});
|
|
1529
988
|
const distanceText = (0, vue.computed)(() => {
|
|
@@ -1549,54 +1008,16 @@ function useSceneDrillPick(windowPosition, options = {}) {
|
|
|
1549
1008
|
const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
|
|
1550
1009
|
const viewer = useViewer();
|
|
1551
1010
|
const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
|
|
1552
|
-
|
|
1011
|
+
return (0, vue.computed)(() => {
|
|
1553
1012
|
if (position.value && (0, vue.toValue)(isActive)) return viewer.value?.scene.drillPick(position.value, (0, vue.toValue)(limit), (0, vue.toValue)(width), (0, vue.toValue)(height));
|
|
1554
1013
|
});
|
|
1555
|
-
return pick;
|
|
1556
1014
|
}
|
|
1557
1015
|
|
|
1558
1016
|
//#endregion
|
|
1559
1017
|
exports.CREATE_VIEWER_COLLECTION = CREATE_VIEWER_COLLECTION;
|
|
1560
1018
|
exports.CREATE_VIEWER_INJECTION_KEY = CREATE_VIEWER_INJECTION_KEY;
|
|
1561
|
-
exports.CesiumMaterial = CesiumMaterial;
|
|
1562
|
-
exports.addMaterialCache = addMaterialCache;
|
|
1563
|
-
exports.arrayDiff = arrayDiff;
|
|
1564
|
-
exports.assertError = assertError;
|
|
1565
|
-
exports.canvasCoordToCartesian = canvasCoordToCartesian;
|
|
1566
|
-
exports.cartesianToCanvasCoord = cartesianToCanvasCoord;
|
|
1567
|
-
exports.cesiumEquals = cesiumEquals;
|
|
1568
|
-
exports.createCesiumAttribute = createCesiumAttribute;
|
|
1569
|
-
exports.createCesiumProperty = createCesiumProperty;
|
|
1570
|
-
exports.createPropertyField = createPropertyField;
|
|
1571
1019
|
exports.createViewer = createViewer;
|
|
1572
|
-
exports.degreesToDms = degreesToDms;
|
|
1573
|
-
exports.dmsDecode = dmsDecode;
|
|
1574
|
-
exports.dmsEncode = dmsEncode;
|
|
1575
|
-
exports.dmsToDegrees = dmsToDegrees;
|
|
1576
|
-
exports.getMaterialCache = getMaterialCache;
|
|
1577
|
-
exports.isArray = isArray;
|
|
1578
|
-
exports.isBase64 = isBase64;
|
|
1579
|
-
exports.isBoolean = isBoolean;
|
|
1580
|
-
exports.isCesiumConstant = isCesiumConstant;
|
|
1581
|
-
exports.isDef = isDef;
|
|
1582
|
-
exports.isElement = isElement;
|
|
1583
|
-
exports.isFunction = isFunction;
|
|
1584
|
-
exports.isNumber = isNumber;
|
|
1585
|
-
exports.isObject = isObject;
|
|
1586
|
-
exports.isPromise = isPromise;
|
|
1587
|
-
exports.isProperty = isProperty;
|
|
1588
|
-
exports.isString = isString;
|
|
1589
|
-
exports.isWindow = isWindow;
|
|
1590
|
-
exports.pickHitGraphic = pickHitGraphic;
|
|
1591
|
-
exports.resolvePick = resolvePick;
|
|
1592
|
-
exports.throttle = throttle;
|
|
1593
|
-
exports.toCartesian3 = toCartesian3;
|
|
1594
|
-
exports.toCartographic = toCartographic;
|
|
1595
|
-
exports.toCoord = toCoord;
|
|
1596
1020
|
exports.toPromiseValue = toPromiseValue;
|
|
1597
|
-
exports.toProperty = toProperty;
|
|
1598
|
-
exports.toPropertyValue = toPropertyValue;
|
|
1599
|
-
exports.tryRun = tryRun;
|
|
1600
1021
|
exports.useCameraState = useCameraState;
|
|
1601
1022
|
exports.useCesiumEventListener = useCesiumEventListener;
|
|
1602
1023
|
exports.useCesiumFps = useCesiumFps;
|
|
@@ -1618,4 +1039,11 @@ exports.useSceneDrillPick = useSceneDrillPick;
|
|
|
1618
1039
|
exports.useScenePick = useScenePick;
|
|
1619
1040
|
exports.useScreenSpaceEventHandler = useScreenSpaceEventHandler;
|
|
1620
1041
|
exports.useViewer = useViewer;
|
|
1042
|
+
Object.keys(__vesium_shared).forEach(function (k) {
|
|
1043
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1044
|
+
enumerable: true,
|
|
1045
|
+
get: function () { return __vesium_shared[k]; }
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1621
1049
|
//# sourceMappingURL=index.cjs.map
|