vesium 1.0.1-beta.52 → 1.0.1-beta.54
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 +147 -699
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -555
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +50 -555
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +910 -1466
- 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 +121 -645
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -21,9 +21,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let __vueuse_core = require("@vueuse/core");
|
|
25
|
+
__vueuse_core = __toESM(__vueuse_core);
|
|
26
|
+
let cesium = require("cesium");
|
|
27
|
+
cesium = __toESM(cesium);
|
|
28
|
+
let vue = require("vue");
|
|
29
|
+
vue = __toESM(vue);
|
|
30
|
+
let __vesium_shared = require("@vesium/shared");
|
|
31
|
+
__vesium_shared = __toESM(__vesium_shared);
|
|
27
32
|
|
|
28
33
|
//#region createViewer/index.ts
|
|
29
34
|
/**
|
|
@@ -54,9 +59,7 @@ function createViewer(...args) {
|
|
|
54
59
|
const value = (0, vue.toRaw)((0, vue.toValue)(arg1));
|
|
55
60
|
if (value instanceof cesium.Viewer) viewer.value = (0, vue.markRaw)(value);
|
|
56
61
|
else if (value) {
|
|
57
|
-
|
|
58
|
-
const options = arg2;
|
|
59
|
-
viewer.value = new cesium.Viewer(element, options);
|
|
62
|
+
viewer.value = new cesium.Viewer(value, arg2);
|
|
60
63
|
onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
|
|
61
64
|
} else viewer.value = void 0;
|
|
62
65
|
});
|
|
@@ -68,530 +71,6 @@ function createViewer(...args) {
|
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
73
|
|
|
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
74
|
//#endregion
|
|
596
75
|
//#region toPromiseValue/index.ts
|
|
597
76
|
/**
|
|
@@ -616,10 +95,10 @@ async function toPromiseValue(source, options = {}) {
|
|
|
616
95
|
try {
|
|
617
96
|
const { raw = true } = options;
|
|
618
97
|
let value;
|
|
619
|
-
if (isFunction(source)) value = await source();
|
|
98
|
+
if ((0, __vesium_shared.isFunction)(source)) value = await source();
|
|
620
99
|
else {
|
|
621
100
|
const result = (0, vue.toValue)(source);
|
|
622
|
-
value = isPromise(result) ? await result : result;
|
|
101
|
+
value = (0, __vesium_shared.isPromise)(result) ? await result : result;
|
|
623
102
|
}
|
|
624
103
|
return raw ? (0, vue.toRaw)(value) : value;
|
|
625
104
|
} catch (error) {
|
|
@@ -762,17 +241,14 @@ function useCesiumFps(options = {}) {
|
|
|
762
241
|
/**
|
|
763
242
|
* Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.
|
|
764
243
|
* - 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
244
|
* @returns Contains side effect addition and removal functions
|
|
770
245
|
*/
|
|
771
|
-
function useCollectionScope(
|
|
246
|
+
function useCollectionScope(options) {
|
|
247
|
+
const { addEffect, removeEffect, removeScopeArgs } = options;
|
|
772
248
|
const scope = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
773
249
|
const add = (instance, ...args) => {
|
|
774
|
-
const result =
|
|
775
|
-
if (isPromise(result)) return new Promise((resolve, reject) => {
|
|
250
|
+
const result = addEffect(instance, ...args);
|
|
251
|
+
if ((0, __vesium_shared.isPromise)(result)) return new Promise((resolve, reject) => {
|
|
776
252
|
result.then((i) => {
|
|
777
253
|
scope.add(i);
|
|
778
254
|
resolve(i);
|
|
@@ -785,7 +261,7 @@ function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
|
785
261
|
};
|
|
786
262
|
const remove = (instance, ...args) => {
|
|
787
263
|
scope.delete(instance);
|
|
788
|
-
return
|
|
264
|
+
return removeEffect(instance, ...args);
|
|
789
265
|
};
|
|
790
266
|
const removeWhere = (predicate, ...args) => {
|
|
791
267
|
scope.forEach((instance) => {
|
|
@@ -814,8 +290,7 @@ function useDataSource(dataSources, options = {}) {
|
|
|
814
290
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
|
|
815
291
|
const viewer = useViewer();
|
|
816
292
|
(0, vue.watchEffect)((onCleanup) => {
|
|
817
|
-
|
|
818
|
-
if (_isActive) {
|
|
293
|
+
if ((0, vue.toValue)(isActive)) {
|
|
819
294
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
820
295
|
const _collection = collection ?? viewer.value?.dataSources;
|
|
821
296
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -831,7 +306,7 @@ function useDataSource(dataSources, options = {}) {
|
|
|
831
306
|
//#endregion
|
|
832
307
|
//#region useDataSourceScope/index.ts
|
|
833
308
|
/**
|
|
834
|
-
*
|
|
309
|
+
* Scope the SideEffects of `DataSourceCollection` operations and automatically remove them when unmounted
|
|
835
310
|
*/
|
|
836
311
|
function useDataSourceScope(options = {}) {
|
|
837
312
|
const { collection: _collection, destroyOnRemove } = options;
|
|
@@ -839,21 +314,25 @@ function useDataSourceScope(options = {}) {
|
|
|
839
314
|
const collection = (0, vue.computed)(() => {
|
|
840
315
|
return (0, vue.toValue)(_collection) ?? viewer.value?.dataSources;
|
|
841
316
|
});
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
317
|
+
return useCollectionScope({
|
|
318
|
+
addEffect(instance) {
|
|
319
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
320
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
321
|
+
instance.then((i) => {
|
|
322
|
+
collection.value.add(i);
|
|
323
|
+
resolve(i);
|
|
324
|
+
}).catch((error) => reject(error));
|
|
325
|
+
});
|
|
326
|
+
else {
|
|
327
|
+
collection.value.add(instance);
|
|
328
|
+
return instance;
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
removeEffect(instance, destroy) {
|
|
332
|
+
return !!collection.value?.remove(instance, destroy);
|
|
333
|
+
},
|
|
334
|
+
removeScopeArgs: [destroyOnRemove]
|
|
335
|
+
});
|
|
857
336
|
}
|
|
858
337
|
|
|
859
338
|
//#endregion
|
|
@@ -866,15 +345,15 @@ function useElementOverlay(target, position, options = {}) {
|
|
|
866
345
|
x: 0,
|
|
867
346
|
y: 0
|
|
868
347
|
} } = options;
|
|
869
|
-
const cartesian3 = (0, vue.computed)(() => toCartesian3((0, vue.toValue)(position)));
|
|
348
|
+
const cartesian3 = (0, vue.computed)(() => (0, __vesium_shared.toCartesian3)((0, vue.toValue)(position)));
|
|
870
349
|
const viewer = useViewer();
|
|
871
350
|
const coord = (0, vue.shallowRef)();
|
|
872
351
|
useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
|
|
873
352
|
if (!viewer.value?.scene) return;
|
|
874
353
|
if (!cartesian3.value) coord.value = void 0;
|
|
875
354
|
else {
|
|
876
|
-
const
|
|
877
|
-
coord.value = !cesium.Cartesian2.equals(
|
|
355
|
+
const result = (0, __vesium_shared.cartesianToCanvasCoord)(cartesian3.value, viewer.value.scene);
|
|
356
|
+
coord.value = !cesium.Cartesian2.equals(result, coord.value) ? result : coord.value;
|
|
878
357
|
}
|
|
879
358
|
});
|
|
880
359
|
const canvasBounding = (0, __vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
|
|
@@ -935,8 +414,7 @@ function useEntity(data, options = {}) {
|
|
|
935
414
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
936
415
|
const viewer = useViewer();
|
|
937
416
|
(0, vue.watchEffect)((onCleanup) => {
|
|
938
|
-
|
|
939
|
-
if (_isActive) {
|
|
417
|
+
if ((0, vue.toValue)(isActive)) {
|
|
940
418
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
941
419
|
const _collection = collection ?? viewer.value?.entities;
|
|
942
420
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -960,22 +438,25 @@ function useEntityScope(options = {}) {
|
|
|
960
438
|
const collection = (0, vue.computed)(() => {
|
|
961
439
|
return (0, vue.toValue)(_collection) ?? viewer.value?.entities;
|
|
962
440
|
});
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
441
|
+
return useCollectionScope({
|
|
442
|
+
addEffect(instance) {
|
|
443
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
444
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
445
|
+
instance.then((i) => {
|
|
446
|
+
collection.value.add(i);
|
|
447
|
+
resolve(i);
|
|
448
|
+
}).catch((error) => reject(error));
|
|
449
|
+
});
|
|
450
|
+
else {
|
|
451
|
+
collection.value.add(instance);
|
|
452
|
+
return instance;
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
removeEffect(instance) {
|
|
456
|
+
return !!collection.value?.remove(instance);
|
|
457
|
+
},
|
|
458
|
+
removeScopeArgs: []
|
|
459
|
+
});
|
|
979
460
|
}
|
|
980
461
|
|
|
981
462
|
//#endregion
|
|
@@ -1031,7 +512,7 @@ function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
|
1031
512
|
const modifierValue = (0, vue.toValue)(modifier);
|
|
1032
513
|
const handlerValue = (0, vue.toValue)(handler);
|
|
1033
514
|
if (!handlerValue || !isActive.value || !inputAction) return;
|
|
1034
|
-
if (isDef(typeValue)) {
|
|
515
|
+
if ((0, __vesium_shared.isDef)(typeValue)) {
|
|
1035
516
|
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
1036
517
|
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
1037
518
|
}
|
|
@@ -1080,7 +561,7 @@ function useDrag(listener) {
|
|
|
1080
561
|
dragging.value = true;
|
|
1081
562
|
position.value = event.position.clone();
|
|
1082
563
|
});
|
|
1083
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, throttle(({ startPosition, endPosition }) => {
|
|
564
|
+
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0, __vesium_shared.throttle)(({ startPosition, endPosition }) => {
|
|
1084
565
|
motionEvent.value = {
|
|
1085
566
|
startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
|
|
1086
567
|
endPosition: endPosition.clone()
|
|
@@ -1198,7 +679,7 @@ function useGraphicEvent() {
|
|
|
1198
679
|
const collection = /* @__PURE__ */ new WeakMap();
|
|
1199
680
|
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1200
681
|
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1201
|
-
const
|
|
682
|
+
const remove = (graphic, type, listener) => {
|
|
1202
683
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1203
684
|
collection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1204
685
|
cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
|
|
@@ -1211,30 +692,29 @@ function useGraphicEvent() {
|
|
|
1211
692
|
if (dragCursorCollection?.get(_graphic)?.get(type)?.size === 0) dragCursorCollection?.get(_graphic)?.delete(type);
|
|
1212
693
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1213
694
|
};
|
|
1214
|
-
const
|
|
695
|
+
const add = (graphic, type, listener, options = {}) => {
|
|
1215
696
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1216
697
|
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1217
698
|
const eventTypeMap = collection.get(_graphic);
|
|
1218
699
|
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
1219
|
-
|
|
1220
|
-
listeners.add(listener);
|
|
700
|
+
eventTypeMap.get(type).add(listener);
|
|
1221
701
|
let { cursor = "pointer", dragCursor } = options;
|
|
1222
|
-
if (isDef(cursor)) {
|
|
1223
|
-
const _cursor = isFunction(cursor) ? cursor : () => cursor;
|
|
702
|
+
if ((0, __vesium_shared.isDef)(cursor)) {
|
|
703
|
+
const _cursor = (0, __vesium_shared.isFunction)(cursor) ? cursor : () => cursor;
|
|
1224
704
|
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1225
705
|
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1226
706
|
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
1227
707
|
}
|
|
1228
|
-
if (type === "DRAG") dragCursor ??= (event) => event?.dragging ? "crosshair" : void 0;
|
|
1229
|
-
if (isDef(dragCursor)) {
|
|
1230
|
-
const _dragCursor = isFunction(dragCursor) ? dragCursor : () => dragCursor;
|
|
708
|
+
if (type === "DRAG") dragCursor ??= ((event) => event?.dragging ? "crosshair" : void 0);
|
|
709
|
+
if ((0, __vesium_shared.isDef)(dragCursor)) {
|
|
710
|
+
const _dragCursor = (0, __vesium_shared.isFunction)(dragCursor) ? dragCursor : () => dragCursor;
|
|
1231
711
|
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1232
712
|
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1233
713
|
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
1234
714
|
}
|
|
1235
|
-
return () =>
|
|
715
|
+
return () => remove(graphic, type, listener);
|
|
1236
716
|
};
|
|
1237
|
-
const
|
|
717
|
+
const clear = (graphic, type) => {
|
|
1238
718
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1239
719
|
if (type === "all") {
|
|
1240
720
|
collection.delete(_graphic);
|
|
@@ -1250,42 +730,40 @@ function useGraphicEvent() {
|
|
|
1250
730
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1251
731
|
};
|
|
1252
732
|
for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
collection.get(graphic)?.get(type)?.forEach((fn) => tryRun(fn)?.(event));
|
|
733
|
+
(0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
734
|
+
collection.get(graphic)?.get(type)?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)?.(event));
|
|
1256
735
|
});
|
|
1257
736
|
});
|
|
1258
737
|
const dragging = (0, vue.ref)(false);
|
|
1259
738
|
const viewer = useViewer();
|
|
1260
739
|
useHover((event) => {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
collection.get(graphic)?.get("HOVER")?.forEach((fn) => tryRun(fn)?.(event));
|
|
740
|
+
(0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
741
|
+
collection.get(graphic)?.get("HOVER")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)?.(event));
|
|
1264
742
|
if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
|
|
1265
743
|
map.forEach((fn) => {
|
|
1266
|
-
const cursor = event.hovering ? tryRun(fn)(event) : "";
|
|
744
|
+
const cursor = event.hovering ? (0, __vesium_shared.tryRun)(fn)(event) : "";
|
|
1267
745
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1268
746
|
});
|
|
1269
747
|
});
|
|
1270
748
|
});
|
|
1271
749
|
});
|
|
1272
750
|
useDrag((event) => {
|
|
1273
|
-
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
751
|
+
const graphics = (0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
1274
752
|
dragging.value = event.dragging;
|
|
1275
753
|
graphics.forEach((graphic) => {
|
|
1276
|
-
collection.get(graphic)?.get("DRAG")?.forEach((fn) => tryRun(fn)(event));
|
|
754
|
+
collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)(event));
|
|
1277
755
|
dragCursorCollection.get(graphic)?.forEach((map) => {
|
|
1278
756
|
map.forEach((fn) => {
|
|
1279
|
-
const cursor = event.dragging ? tryRun(fn)(event) : "";
|
|
757
|
+
const cursor = event.dragging ? (0, __vesium_shared.tryRun)(fn)(event) : "";
|
|
1280
758
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1281
759
|
});
|
|
1282
760
|
});
|
|
1283
761
|
});
|
|
1284
762
|
});
|
|
1285
763
|
return {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
764
|
+
add,
|
|
765
|
+
remove,
|
|
766
|
+
clear
|
|
1289
767
|
};
|
|
1290
768
|
}
|
|
1291
769
|
|
|
@@ -1296,8 +774,7 @@ function useImageryLayer(data, options = {}) {
|
|
|
1296
774
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
1297
775
|
const viewer = useViewer();
|
|
1298
776
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1299
|
-
|
|
1300
|
-
if (_isActive) {
|
|
777
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1301
778
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1302
779
|
const _collection = collection ?? viewer.value?.imageryLayers;
|
|
1303
780
|
if (collection?.isDestroyed()) return;
|
|
@@ -1333,22 +810,25 @@ function useImageryLayerScope(options = {}) {
|
|
|
1333
810
|
const collection = (0, vue.computed)(() => {
|
|
1334
811
|
return (0, vue.toValue)(_collection) ?? viewer.value?.imageryLayers;
|
|
1335
812
|
});
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
813
|
+
return useCollectionScope({
|
|
814
|
+
addEffect(instance, index) {
|
|
815
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
816
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
817
|
+
instance.then((i) => {
|
|
818
|
+
collection.value.add(i, index);
|
|
819
|
+
resolve(i);
|
|
820
|
+
}).catch((error) => reject(error));
|
|
821
|
+
});
|
|
822
|
+
else {
|
|
823
|
+
collection.value.add(instance, index);
|
|
824
|
+
return instance;
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
removeEffect(instance, destroy) {
|
|
828
|
+
return !!collection.value?.remove(instance, destroy);
|
|
829
|
+
},
|
|
830
|
+
removeScopeArgs: [destroyOnRemove]
|
|
831
|
+
});
|
|
1352
832
|
}
|
|
1353
833
|
|
|
1354
834
|
//#endregion
|
|
@@ -1359,8 +839,7 @@ function usePostProcessStage(data, options = {}) {
|
|
|
1359
839
|
const viewer = useViewer();
|
|
1360
840
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1361
841
|
if (!viewer.value) return;
|
|
1362
|
-
|
|
1363
|
-
if (_isActive) {
|
|
842
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1364
843
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1365
844
|
const _collection = collection ?? viewer.value.scene.postProcessStages;
|
|
1366
845
|
list.forEach((item) => item && _collection.add(item));
|
|
@@ -1384,21 +863,22 @@ function usePostProcessStageScope(options = {}) {
|
|
|
1384
863
|
const collection = (0, vue.computed)(() => {
|
|
1385
864
|
return (0, vue.toValue)(_collection) ?? viewer.value?.postProcessStages;
|
|
1386
865
|
});
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
866
|
+
return useCollectionScope({
|
|
867
|
+
addEffect(instance) {
|
|
868
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
869
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
870
|
+
instance.then((instance$1) => {
|
|
871
|
+
collection.value.add(instance$1);
|
|
872
|
+
resolve(instance$1);
|
|
873
|
+
}).catch((error) => reject(error));
|
|
874
|
+
});
|
|
875
|
+
else return collection.value.add(instance);
|
|
876
|
+
},
|
|
877
|
+
removeEffect(instance, ...args) {
|
|
878
|
+
return !!collection.value?.remove(instance, ...args);
|
|
879
|
+
},
|
|
880
|
+
removeScopeArgs: []
|
|
881
|
+
});
|
|
1402
882
|
}
|
|
1403
883
|
|
|
1404
884
|
//#endregion
|
|
@@ -1408,8 +888,7 @@ function usePrimitive(data, options = {}) {
|
|
|
1408
888
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
1409
889
|
const viewer = useViewer();
|
|
1410
890
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1411
|
-
|
|
1412
|
-
if (_isActive) {
|
|
891
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1413
892
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1414
893
|
const _collection = collection === "ground" ? viewer.value?.scene.groundPrimitives : collection ?? viewer.value?.scene.primitives;
|
|
1415
894
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -1431,16 +910,22 @@ function usePrimitiveScope(options = {}) {
|
|
|
1431
910
|
const { collection: _collection } = options;
|
|
1432
911
|
const viewer = useViewer();
|
|
1433
912
|
const collection = (0, vue.computed)(() => {
|
|
1434
|
-
|
|
913
|
+
const value = (0, vue.toValue)(_collection);
|
|
914
|
+
return value === "ground" ? viewer.value?.scene?.groundPrimitives : value || viewer.value?.scene.primitives;
|
|
915
|
+
});
|
|
916
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope({
|
|
917
|
+
addEffect(instance, ...args) {
|
|
918
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
919
|
+
if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
920
|
+
instance.then((instance$1) => resolve(collection.value.add(instance$1, ...args))).catch((error) => reject(error));
|
|
921
|
+
});
|
|
922
|
+
else return collection.value.add(instance, ...args);
|
|
923
|
+
},
|
|
924
|
+
removeEffect(instance) {
|
|
925
|
+
return !!collection.value?.remove(instance);
|
|
926
|
+
},
|
|
927
|
+
removeScopeArgs: []
|
|
1435
928
|
});
|
|
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
929
|
return {
|
|
1445
930
|
scope,
|
|
1446
931
|
add,
|
|
@@ -1509,21 +994,15 @@ function useScaleBar(options = {}) {
|
|
|
1509
994
|
const leftPosition = scene.globe.pick(left, scene);
|
|
1510
995
|
const rightPosition = scene.globe.pick(right, scene);
|
|
1511
996
|
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;
|
|
997
|
+
pixelDistance.value = new cesium.EllipsoidGeodesic(scene.globe.ellipsoid.cartesianToCartographic(leftPosition), scene.globe.ellipsoid.cartesianToCartographic(rightPosition)).surfaceDistance;
|
|
1516
998
|
};
|
|
1517
999
|
(0, __vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
|
|
1518
|
-
useCesiumEventListener(() => viewer.value?.camera.changed, throttle(setPixelDistance, delay));
|
|
1000
|
+
useCesiumEventListener(() => viewer.value?.camera.changed, (0, __vesium_shared.throttle)(setPixelDistance, delay));
|
|
1519
1001
|
const distance = (0, vue.computed)(() => {
|
|
1520
1002
|
if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
|
|
1521
1003
|
});
|
|
1522
1004
|
const width = (0, vue.computed)(() => {
|
|
1523
|
-
if (distance.value && pixelDistance.value)
|
|
1524
|
-
const value = distance.value / pixelDistance.value;
|
|
1525
|
-
return value;
|
|
1526
|
-
}
|
|
1005
|
+
if (distance.value && pixelDistance.value) return distance.value / pixelDistance.value;
|
|
1527
1006
|
return 0;
|
|
1528
1007
|
});
|
|
1529
1008
|
const distanceText = (0, vue.computed)(() => {
|
|
@@ -1549,54 +1028,16 @@ function useSceneDrillPick(windowPosition, options = {}) {
|
|
|
1549
1028
|
const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
|
|
1550
1029
|
const viewer = useViewer();
|
|
1551
1030
|
const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
|
|
1552
|
-
|
|
1031
|
+
return (0, vue.computed)(() => {
|
|
1553
1032
|
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
1033
|
});
|
|
1555
|
-
return pick;
|
|
1556
1034
|
}
|
|
1557
1035
|
|
|
1558
1036
|
//#endregion
|
|
1559
1037
|
exports.CREATE_VIEWER_COLLECTION = CREATE_VIEWER_COLLECTION;
|
|
1560
1038
|
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
1039
|
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
1040
|
exports.toPromiseValue = toPromiseValue;
|
|
1597
|
-
exports.toProperty = toProperty;
|
|
1598
|
-
exports.toPropertyValue = toPropertyValue;
|
|
1599
|
-
exports.tryRun = tryRun;
|
|
1600
1041
|
exports.useCameraState = useCameraState;
|
|
1601
1042
|
exports.useCesiumEventListener = useCesiumEventListener;
|
|
1602
1043
|
exports.useCesiumFps = useCesiumFps;
|
|
@@ -1618,4 +1059,11 @@ exports.useSceneDrillPick = useSceneDrillPick;
|
|
|
1618
1059
|
exports.useScenePick = useScenePick;
|
|
1619
1060
|
exports.useScreenSpaceEventHandler = useScreenSpaceEventHandler;
|
|
1620
1061
|
exports.useViewer = useViewer;
|
|
1062
|
+
Object.keys(__vesium_shared).forEach(function (k) {
|
|
1063
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1064
|
+
enumerable: true,
|
|
1065
|
+
get: function () { return __vesium_shared[k]; }
|
|
1066
|
+
});
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1621
1069
|
//# sourceMappingURL=index.cjs.map
|