vesium 1.0.1-beta.51 → 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 +160 -698
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -568
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +96 -568
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +910 -1452
- 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 +134 -644
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
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
|
/**
|
|
@@ -34,6 +39,8 @@ const CREATE_VIEWER_INJECTION_KEY = Symbol("CREATE_VIEWER_INJECTION_KEY");
|
|
|
34
39
|
* @internal
|
|
35
40
|
*/
|
|
36
41
|
const CREATE_VIEWER_COLLECTION = /* @__PURE__ */ new WeakMap();
|
|
42
|
+
/**
|
|
43
|
+
*/
|
|
37
44
|
function createViewer(...args) {
|
|
38
45
|
const viewer = (0, vue.shallowRef)();
|
|
39
46
|
const readonlyViewer = (0, vue.shallowReadonly)(viewer);
|
|
@@ -52,9 +59,7 @@ function createViewer(...args) {
|
|
|
52
59
|
const value = (0, vue.toRaw)((0, vue.toValue)(arg1));
|
|
53
60
|
if (value instanceof cesium.Viewer) viewer.value = (0, vue.markRaw)(value);
|
|
54
61
|
else if (value) {
|
|
55
|
-
|
|
56
|
-
const options = arg2;
|
|
57
|
-
viewer.value = new cesium.Viewer(element, options);
|
|
62
|
+
viewer.value = new cesium.Viewer(value, arg2);
|
|
58
63
|
onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
|
|
59
64
|
} else viewer.value = void 0;
|
|
60
65
|
});
|
|
@@ -66,530 +71,6 @@ function createViewer(...args) {
|
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region utils/arrayDiff.ts
|
|
71
|
-
/**
|
|
72
|
-
* 计算两个数组的差异,返回新增和删除的元素
|
|
73
|
-
*/
|
|
74
|
-
function arrayDiff(list, oldList) {
|
|
75
|
-
const oldListSet = new Set(oldList);
|
|
76
|
-
const added = list.filter((obj) => !oldListSet.has(obj));
|
|
77
|
-
const newListSet = new Set(list);
|
|
78
|
-
const removed = oldList?.filter((obj) => !newListSet.has(obj)) ?? [];
|
|
79
|
-
return {
|
|
80
|
-
added,
|
|
81
|
-
removed
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region utils/canvasCoordToCartesian.ts
|
|
87
|
-
/**
|
|
88
|
-
* Convert canvas coordinates to Cartesian coordinates
|
|
89
|
-
*
|
|
90
|
-
* @param canvasCoord Canvas coordinates
|
|
91
|
-
* @param scene Cesium.Scene instance
|
|
92
|
-
* @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'
|
|
93
|
-
*
|
|
94
|
-
* `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.
|
|
95
|
-
* However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur
|
|
96
|
-
*
|
|
97
|
-
* `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,
|
|
98
|
-
* but can be used for picking terrain. If terrain does not exist, the picked elevation is 0
|
|
99
|
-
*
|
|
100
|
-
* `auto`: Automatically determine which picking content to return
|
|
101
|
-
*
|
|
102
|
-
* Calculation speed comparison: globePick > auto >= pickPosition
|
|
103
|
-
*/
|
|
104
|
-
function canvasCoordToCartesian(canvasCoord, scene, mode = "auto") {
|
|
105
|
-
if (mode === "pickPosition") return scene.pickPosition(canvasCoord);
|
|
106
|
-
else if (mode === "globePick") {
|
|
107
|
-
const ray = scene.camera.getPickRay(canvasCoord);
|
|
108
|
-
return ray && scene.globe.pick(ray, scene);
|
|
109
|
-
} else {
|
|
110
|
-
if (scene.globe.depthTestAgainstTerrain) return scene.pickPosition(canvasCoord);
|
|
111
|
-
const position1 = scene.pickPosition(canvasCoord);
|
|
112
|
-
const ray = scene.camera.getPickRay(canvasCoord);
|
|
113
|
-
const position2 = ray && scene.globe.pick(ray, scene);
|
|
114
|
-
if (!position1) return position2;
|
|
115
|
-
const height1 = (position1 && cesium.Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;
|
|
116
|
-
const height2 = (position2 && cesium.Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;
|
|
117
|
-
return height1 < height2 ? position1 : position2;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region utils/cartesianToCanvasCoord.ts
|
|
123
|
-
/**
|
|
124
|
-
* Convert Cartesian coordinates to canvas coordinates
|
|
125
|
-
*
|
|
126
|
-
* @param position Cartesian coordinates
|
|
127
|
-
* @param scene Cesium.Scene instance
|
|
128
|
-
*/
|
|
129
|
-
function cartesianToCanvasCoord(position, scene) {
|
|
130
|
-
return scene.cartesianToCanvasCoordinates(position);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region utils/is.ts
|
|
135
|
-
const toString = Object.prototype.toString;
|
|
136
|
-
function isDef(val) {
|
|
137
|
-
return typeof val !== "undefined";
|
|
138
|
-
}
|
|
139
|
-
function isBoolean(val) {
|
|
140
|
-
return typeof val === "boolean";
|
|
141
|
-
}
|
|
142
|
-
function isFunction(val) {
|
|
143
|
-
return typeof val === "function";
|
|
144
|
-
}
|
|
145
|
-
function isNumber(val) {
|
|
146
|
-
return typeof val === "number";
|
|
147
|
-
}
|
|
148
|
-
function isString(val) {
|
|
149
|
-
return typeof val === "string";
|
|
150
|
-
}
|
|
151
|
-
function isObject(val) {
|
|
152
|
-
return toString.call(val) === "[object Object]";
|
|
153
|
-
}
|
|
154
|
-
function isWindow(val) {
|
|
155
|
-
return typeof window !== "undefined" && toString.call(val) === "[object Window]";
|
|
156
|
-
}
|
|
157
|
-
function isPromise(val) {
|
|
158
|
-
return !!val && (typeof val === "object" || typeof val === "function") && typeof val.then === "function";
|
|
159
|
-
}
|
|
160
|
-
function isElement(val) {
|
|
161
|
-
return !!(val && val.nodeName && val.nodeType === 1);
|
|
162
|
-
}
|
|
163
|
-
const isArray = Array.isArray;
|
|
164
|
-
function isBase64(val) {
|
|
165
|
-
const reg = /^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i;
|
|
166
|
-
return reg.test(val);
|
|
167
|
-
}
|
|
168
|
-
function assertError(condition, error) {
|
|
169
|
-
if (condition) throw new Error(error);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region utils/cesiumEquals.ts
|
|
174
|
-
/**
|
|
175
|
-
* Determines if two Cesium objects are equal.
|
|
176
|
-
*
|
|
177
|
-
* This function not only judges whether the instances are equal,
|
|
178
|
-
* but also judges the equals method in the example.
|
|
179
|
-
*
|
|
180
|
-
* @param left The first Cesium object
|
|
181
|
-
* @param right The second Cesium object
|
|
182
|
-
* @returns Returns true if the two Cesium objects are equal, otherwise false
|
|
183
|
-
*/
|
|
184
|
-
function cesiumEquals(left, right) {
|
|
185
|
-
return left === right || isFunction(left?.equals) && left.equals(right) || isFunction(right?.equals) && right.equals(left);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region utils/toCoord.ts
|
|
190
|
-
/**
|
|
191
|
-
* Converts coordinates to an array or object in the specified format.
|
|
192
|
-
*
|
|
193
|
-
* @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.
|
|
194
|
-
* @param options Conversion options, including conversion type and whether to include altitude information.
|
|
195
|
-
* @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.
|
|
196
|
-
*
|
|
197
|
-
* @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.
|
|
198
|
-
* @template Alt Whether to include altitude information, default is false
|
|
199
|
-
*/
|
|
200
|
-
function toCoord(position, options = {}) {
|
|
201
|
-
if (!position) return void 0;
|
|
202
|
-
const { type = "Array", alt = false } = options;
|
|
203
|
-
let longitude, latitude, height;
|
|
204
|
-
if (position instanceof cesium.Cartesian3) {
|
|
205
|
-
const cartographic = cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
206
|
-
longitude = cesium.Math.toDegrees(cartographic.longitude);
|
|
207
|
-
latitude = cesium.Math.toDegrees(cartographic.latitude);
|
|
208
|
-
height = cartographic.height;
|
|
209
|
-
} else if (position instanceof cesium.Cartographic) {
|
|
210
|
-
const cartographic = position;
|
|
211
|
-
longitude = cesium.Math.toDegrees(cartographic.longitude);
|
|
212
|
-
latitude = cesium.Math.toDegrees(cartographic.latitude);
|
|
213
|
-
height = cartographic.height;
|
|
214
|
-
} else if (Array.isArray(position)) {
|
|
215
|
-
longitude = cesium.Math.toDegrees(position[0]);
|
|
216
|
-
latitude = cesium.Math.toDegrees(position[1]);
|
|
217
|
-
height = position[2];
|
|
218
|
-
} else {
|
|
219
|
-
longitude = position.longitude;
|
|
220
|
-
latitude = position.latitude;
|
|
221
|
-
height = position.height;
|
|
222
|
-
}
|
|
223
|
-
if (type === "Array") return alt ? [
|
|
224
|
-
longitude,
|
|
225
|
-
latitude,
|
|
226
|
-
height
|
|
227
|
-
] : [longitude, latitude];
|
|
228
|
-
else return alt ? {
|
|
229
|
-
longitude,
|
|
230
|
-
latitude,
|
|
231
|
-
height
|
|
232
|
-
} : {
|
|
233
|
-
longitude,
|
|
234
|
-
latitude
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region utils/convertDMS.ts
|
|
240
|
-
/**
|
|
241
|
-
* Convert degrees to DMS (Degrees Minutes Seconds) format string
|
|
242
|
-
*
|
|
243
|
-
* @param degrees The angle value
|
|
244
|
-
* @param precision The number of decimal places to retain for the seconds, defaults to 3
|
|
245
|
-
* @returns A DMS formatted string in the format: degrees° minutes′ seconds″
|
|
246
|
-
*/
|
|
247
|
-
function dmsEncode(degrees, precision = 3) {
|
|
248
|
-
const str = `${degrees}`;
|
|
249
|
-
let i = str.indexOf(".");
|
|
250
|
-
const d = i < 0 ? str : str.slice(0, Math.max(0, i));
|
|
251
|
-
let m = "0";
|
|
252
|
-
let s = "0";
|
|
253
|
-
if (i > 0) {
|
|
254
|
-
m = `0${str.slice(Math.max(0, i))}`;
|
|
255
|
-
m = `${+m * 60}`;
|
|
256
|
-
i = m.indexOf(".");
|
|
257
|
-
if (i > 0) {
|
|
258
|
-
s = `0${m.slice(Math.max(0, i))}`;
|
|
259
|
-
m = m.slice(0, Math.max(0, i));
|
|
260
|
-
s = `${+s * 60}`;
|
|
261
|
-
i = s.indexOf(".");
|
|
262
|
-
s = s.slice(0, Math.max(0, i + 4));
|
|
263
|
-
s = (+s).toFixed(precision);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return `${Math.abs(+d)}°${+m}′${+s}″`;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value
|
|
270
|
-
*
|
|
271
|
-
* @param dmsCode DMS formatted string, e.g. "120°30′45″N"
|
|
272
|
-
* @returns The decoded decimal angle value, or 0 if decoding fails
|
|
273
|
-
*/
|
|
274
|
-
function dmsDecode(dmsCode) {
|
|
275
|
-
const [dd, msStr] = dmsCode.split("°") ?? [];
|
|
276
|
-
const [mm, sStr] = msStr?.split("′") ?? [];
|
|
277
|
-
const ss = sStr?.split("″")[0];
|
|
278
|
-
const d = Number(dd) || 0;
|
|
279
|
-
const m = (Number(mm) || 0) / 60;
|
|
280
|
-
const s = (Number(ss) || 0) / 60 / 60;
|
|
281
|
-
const degrees = d + m + s;
|
|
282
|
-
if (degrees === 0) return 0;
|
|
283
|
-
else {
|
|
284
|
-
let res = degrees;
|
|
285
|
-
if ([
|
|
286
|
-
"W",
|
|
287
|
-
"w",
|
|
288
|
-
"S",
|
|
289
|
-
"s"
|
|
290
|
-
].includes(dmsCode[dmsCode.length - 1])) res = -res;
|
|
291
|
-
return res;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Convert latitude and longitude coordinates to degrees-minutes-seconds format
|
|
296
|
-
*
|
|
297
|
-
* @param position The latitude and longitude coordinates
|
|
298
|
-
* @param precision The number of decimal places to retain for 'seconds', default is 3
|
|
299
|
-
* @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails
|
|
300
|
-
*/
|
|
301
|
-
function degreesToDms(position, precision = 3) {
|
|
302
|
-
const coord = toCoord(position, { alt: true });
|
|
303
|
-
if (!coord) return;
|
|
304
|
-
const [longitude, latitude, height] = coord;
|
|
305
|
-
const x = dmsEncode(longitude, precision);
|
|
306
|
-
const y = dmsEncode(latitude, precision);
|
|
307
|
-
return [
|
|
308
|
-
`${x}${longitude > 0 ? "E" : "W"}`,
|
|
309
|
-
`${y}${latitude > 0 ? "N" : "S"}`,
|
|
310
|
-
height
|
|
311
|
-
];
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates
|
|
315
|
-
*
|
|
316
|
-
* @param dms The latitude or longitude coordinate in DMS format
|
|
317
|
-
* @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails
|
|
318
|
-
*/
|
|
319
|
-
function dmsToDegrees(dms) {
|
|
320
|
-
const [x, y, height] = dms;
|
|
321
|
-
const longitude = dmsDecode(x);
|
|
322
|
-
const latitude = dmsDecode(y);
|
|
323
|
-
return [
|
|
324
|
-
longitude,
|
|
325
|
-
latitude,
|
|
326
|
-
Number(height) || 0
|
|
327
|
-
];
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
//#endregion
|
|
331
|
-
//#region utils/isCesiumConstant.ts
|
|
332
|
-
/**
|
|
333
|
-
* Determines if the Cesium property is a constant.
|
|
334
|
-
*
|
|
335
|
-
* @param value Cesium property
|
|
336
|
-
*/
|
|
337
|
-
function isCesiumConstant(value) {
|
|
338
|
-
return !(0, cesium.defined)(value) || !!value.isConstant;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region utils/material.ts
|
|
343
|
-
/**
|
|
344
|
-
* Only as a type fix for `Cesium.Material`
|
|
345
|
-
*/
|
|
346
|
-
var CesiumMaterial = class extends cesium.Material {
|
|
347
|
-
constructor(options) {
|
|
348
|
-
super(options);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* Get material from cache, alias of `Material._materialCache.getMaterial`
|
|
353
|
-
*/
|
|
354
|
-
function getMaterialCache(type) {
|
|
355
|
-
return cesium.Material._materialCache.getMaterial(type);
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`
|
|
359
|
-
*/
|
|
360
|
-
function addMaterialCache(type, material) {
|
|
361
|
-
return cesium.Material._materialCache.addMaterial(type, material);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
//#endregion
|
|
365
|
-
//#region utils/pick.ts
|
|
366
|
-
/**
|
|
367
|
-
* Analyze the result of Cesium's `scene.pick` and convert it to an array format
|
|
368
|
-
*/
|
|
369
|
-
function resolvePick(pick = {}) {
|
|
370
|
-
const { primitive, id, primitiveCollection, collection } = pick;
|
|
371
|
-
const entityCollection = id && id.entityCollection || null;
|
|
372
|
-
const dataSource = entityCollection && entityCollection.owner || null;
|
|
373
|
-
const ids = Array.isArray(id) ? id : [id].filter(Boolean);
|
|
374
|
-
return [
|
|
375
|
-
...ids,
|
|
376
|
-
primitive,
|
|
377
|
-
primitiveCollection,
|
|
378
|
-
collection,
|
|
379
|
-
entityCollection,
|
|
380
|
-
dataSource
|
|
381
|
-
].filter((e) => !!e);
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Determine if the given array of graphics is hit by Cesium's `scene.pick`
|
|
385
|
-
*
|
|
386
|
-
* @param pick The `scene.pick` object used for matching
|
|
387
|
-
* @param graphic An array of graphics to check for hits
|
|
388
|
-
*/
|
|
389
|
-
function pickHitGraphic(pick, graphic) {
|
|
390
|
-
if (!Array.isArray(graphic) || !graphic.length) return false;
|
|
391
|
-
const elements = resolvePick(pick);
|
|
392
|
-
if (!elements.length) return false;
|
|
393
|
-
return elements.some((element) => graphic.includes(element));
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region utils/property.ts
|
|
398
|
-
/**
|
|
399
|
-
* Is Cesium.Property
|
|
400
|
-
* @param value - The target object
|
|
401
|
-
*/
|
|
402
|
-
function isProperty(value) {
|
|
403
|
-
return value && isFunction(value.getValue);
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation
|
|
407
|
-
* ```typescript
|
|
408
|
-
* toPropertyValue('val') //=> 'val'
|
|
409
|
-
* toPropertyValue(new ConstantProperty('val')) //=> 'val'
|
|
410
|
-
* toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'
|
|
411
|
-
* ```
|
|
412
|
-
*
|
|
413
|
-
* @param value - The value to convert
|
|
414
|
-
*/
|
|
415
|
-
function toPropertyValue(value, time) {
|
|
416
|
-
return isProperty(value) ? value.getValue(time) : value;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation
|
|
420
|
-
*
|
|
421
|
-
* @param value - The property value or getter to convert, can be undefined or null
|
|
422
|
-
* @param isConstant - The second parameter for converting to CallbackProperty
|
|
423
|
-
* @returns Returns the converted Property object, if value is undefined or null, returns undefined
|
|
424
|
-
*/
|
|
425
|
-
function toProperty(value, isConstant = false) {
|
|
426
|
-
return isProperty(value) ? value : isFunction(value) ? new cesium.CallbackProperty(value, isConstant) : new cesium.ConstantProperty(value);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Create a Cesium property key
|
|
430
|
-
*
|
|
431
|
-
* @param scope The host object
|
|
432
|
-
* @param field The property name
|
|
433
|
-
* @param maybeProperty Optional property or getter
|
|
434
|
-
* @param readonly Whether the property is read-only
|
|
435
|
-
*/
|
|
436
|
-
function createPropertyField(scope, field, maybeProperty, readonly$2) {
|
|
437
|
-
let removeOwnerListener;
|
|
438
|
-
const ownerBinding = (value) => {
|
|
439
|
-
removeOwnerListener?.();
|
|
440
|
-
if ((0, cesium.defined)(value?.definitionChanged)) removeOwnerListener = value?.definitionChanged?.addEventListener(() => {
|
|
441
|
-
scope.definitionChanged.raiseEvent(scope, field, value, value);
|
|
442
|
-
});
|
|
443
|
-
};
|
|
444
|
-
const privateField = `_${field}`;
|
|
445
|
-
const property = toProperty(maybeProperty);
|
|
446
|
-
scope[privateField] = property;
|
|
447
|
-
ownerBinding(property);
|
|
448
|
-
if (readonly$2) Object.defineProperty(scope, field, { get() {
|
|
449
|
-
return scope[privateField];
|
|
450
|
-
} });
|
|
451
|
-
else Object.defineProperty(scope, field, {
|
|
452
|
-
get() {
|
|
453
|
-
return scope[privateField];
|
|
454
|
-
},
|
|
455
|
-
set(value) {
|
|
456
|
-
const previous = scope[privateField];
|
|
457
|
-
if (scope[privateField] !== value) {
|
|
458
|
-
scope[privateField] = value;
|
|
459
|
-
ownerBinding(value);
|
|
460
|
-
if ((0, cesium.defined)(scope.definitionChanged)) scope.definitionChanged.raiseEvent(scope, field, value, previous);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
function createCesiumAttribute(scope, key, value, options = {}) {
|
|
466
|
-
const allowToProperty = !!options.toProperty;
|
|
467
|
-
const shallowClone = !!options.shallowClone;
|
|
468
|
-
const changedEventKey = options.changedEventKey || "definitionChanged";
|
|
469
|
-
const changedEvent = Reflect.get(scope, changedEventKey);
|
|
470
|
-
const privateKey = `_${String(key)}`;
|
|
471
|
-
const attribute = allowToProperty ? toProperty(value) : value;
|
|
472
|
-
Reflect.set(scope, privateKey, attribute);
|
|
473
|
-
const obj = { get() {
|
|
474
|
-
const value$1 = Reflect.get(scope, privateKey);
|
|
475
|
-
if (shallowClone) return Array.isArray(value$1) ? [...value$1] : { ...value$1 };
|
|
476
|
-
else return value$1;
|
|
477
|
-
} };
|
|
478
|
-
let previousListener;
|
|
479
|
-
const serial = (property, previous) => {
|
|
480
|
-
previousListener?.();
|
|
481
|
-
previousListener = property?.definitionChanged?.addEventListener(() => {
|
|
482
|
-
changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);
|
|
483
|
-
});
|
|
484
|
-
};
|
|
485
|
-
if (!options.readonly) {
|
|
486
|
-
if (allowToProperty && isProperty(value)) serial(value);
|
|
487
|
-
obj.set = (value$1) => {
|
|
488
|
-
if (allowToProperty && !isProperty(value$1)) throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);
|
|
489
|
-
const previous = Reflect.get(scope, privateKey);
|
|
490
|
-
if (previous !== value$1) {
|
|
491
|
-
Reflect.set(scope, privateKey, value$1);
|
|
492
|
-
changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value$1, previous);
|
|
493
|
-
if (allowToProperty) serial(value$1);
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
Object.defineProperty(scope, key, obj);
|
|
498
|
-
}
|
|
499
|
-
function createCesiumProperty(scope, key, value, options = {}) {
|
|
500
|
-
return createCesiumAttribute(scope, key, value, {
|
|
501
|
-
...options,
|
|
502
|
-
toProperty: true
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
//#endregion
|
|
507
|
-
//#region utils/throttle.ts
|
|
508
|
-
/**
|
|
509
|
-
* Throttle function, which limits the frequency of execution of the function
|
|
510
|
-
*
|
|
511
|
-
* @param callback raw function
|
|
512
|
-
* @param delay Throttled delay duration (ms)
|
|
513
|
-
* @param trailing Trigger callback function after last call @default true
|
|
514
|
-
* @param leading Trigger the callback function immediately on the first call @default false
|
|
515
|
-
* @returns Throttle function
|
|
516
|
-
*/
|
|
517
|
-
function throttle(callback, delay = 100, trailing = true, leading = false) {
|
|
518
|
-
const restList = [];
|
|
519
|
-
let tracked = false;
|
|
520
|
-
const trigger = async () => {
|
|
521
|
-
await (0, __vueuse_core.promiseTimeout)(delay);
|
|
522
|
-
tracked = false;
|
|
523
|
-
if (leading) try {
|
|
524
|
-
callback(...restList[0]);
|
|
525
|
-
} catch (error) {
|
|
526
|
-
console.error(error);
|
|
527
|
-
}
|
|
528
|
-
if (trailing && (!leading || restList.length > 1)) try {
|
|
529
|
-
callback(...restList[restList.length - 1]);
|
|
530
|
-
} catch (error) {
|
|
531
|
-
console.error(error);
|
|
532
|
-
}
|
|
533
|
-
restList.length = 0;
|
|
534
|
-
};
|
|
535
|
-
return (...rest) => {
|
|
536
|
-
if (restList.length < 2) restList.push(rest);
|
|
537
|
-
else restList[1] = rest;
|
|
538
|
-
if (!tracked) {
|
|
539
|
-
tracked = true;
|
|
540
|
-
trigger();
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region utils/toCartesian3.ts
|
|
547
|
-
/**
|
|
548
|
-
* Converts position to a coordinate point in the Cartesian coordinate system
|
|
549
|
-
*
|
|
550
|
-
* @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
|
|
551
|
-
* @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned
|
|
552
|
-
*/
|
|
553
|
-
function toCartesian3(position) {
|
|
554
|
-
if (!position) return void 0;
|
|
555
|
-
if (position instanceof cesium.Cartesian3) return position.clone();
|
|
556
|
-
else if (position instanceof cesium.Cartographic) return cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
|
|
557
|
-
else if (Array.isArray(position)) return cesium.Cartesian3.fromDegrees(position[0], position[1], position[2]);
|
|
558
|
-
else return cesium.Cartesian3.fromDegrees(position.longitude, position.latitude, position.height);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region utils/toCartographic.ts
|
|
563
|
-
/**
|
|
564
|
-
* Converts a position to a Cartographic coordinate point
|
|
565
|
-
*
|
|
566
|
-
* @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
|
|
567
|
-
* @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid
|
|
568
|
-
*/
|
|
569
|
-
function toCartographic(position) {
|
|
570
|
-
if (!position) return void 0;
|
|
571
|
-
if (position instanceof cesium.Cartesian3) return cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
572
|
-
else if (position instanceof cesium.Cartographic) return position.clone();
|
|
573
|
-
else if (Array.isArray(position)) return cesium.Cartographic.fromDegrees(position[0], position[1], position[2]);
|
|
574
|
-
else return cesium.Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
//#endregion
|
|
578
|
-
//#region utils/tryRun.ts
|
|
579
|
-
/**
|
|
580
|
-
* Safely execute the provided function without throwing errors,
|
|
581
|
-
* essentially a simple wrapper around a `try...catch...` block
|
|
582
|
-
*/
|
|
583
|
-
function tryRun(fn) {
|
|
584
|
-
return (...args) => {
|
|
585
|
-
try {
|
|
586
|
-
return fn?.(...args);
|
|
587
|
-
} catch (error) {
|
|
588
|
-
console.error(error);
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
|
|
593
74
|
//#endregion
|
|
594
75
|
//#region toPromiseValue/index.ts
|
|
595
76
|
/**
|
|
@@ -599,6 +80,7 @@ function tryRun(fn) {
|
|
|
599
80
|
*
|
|
600
81
|
* @param source The source value, which can be a reactive reference or an asynchronous getter.
|
|
601
82
|
* @param options Conversion options
|
|
83
|
+
* @returns The converted value.
|
|
602
84
|
*
|
|
603
85
|
* @example
|
|
604
86
|
* ```ts
|
|
@@ -613,10 +95,10 @@ async function toPromiseValue(source, options = {}) {
|
|
|
613
95
|
try {
|
|
614
96
|
const { raw = true } = options;
|
|
615
97
|
let value;
|
|
616
|
-
if (isFunction(source)) value = await source();
|
|
98
|
+
if ((0, __vesium_shared.isFunction)(source)) value = await source();
|
|
617
99
|
else {
|
|
618
100
|
const result = (0, vue.toValue)(source);
|
|
619
|
-
value = isPromise(result) ? await result : result;
|
|
101
|
+
value = (0, __vesium_shared.isPromise)(result) ? await result : result;
|
|
620
102
|
}
|
|
621
103
|
return raw ? (0, vue.toRaw)(value) : value;
|
|
622
104
|
} catch (error) {
|
|
@@ -631,6 +113,11 @@ async function toPromiseValue(source, options = {}) {
|
|
|
631
113
|
* Easily use the `addEventListener` in `Cesium.Event` instances,
|
|
632
114
|
* when the dependent data changes or the component is unmounted,
|
|
633
115
|
* the listener function will automatically reload or destroy.
|
|
116
|
+
*
|
|
117
|
+
* @param event The Cesium.Event instance
|
|
118
|
+
* @param listener The listener function
|
|
119
|
+
* @param options additional options
|
|
120
|
+
* @returns A function that can be called to remove the event listener
|
|
634
121
|
*/
|
|
635
122
|
function useCesiumEventListener(event, listener, options = {}) {
|
|
636
123
|
const isActive = (0, vue.toRef)(options.isActive ?? true);
|
|
@@ -675,6 +162,8 @@ function useViewer() {
|
|
|
675
162
|
//#region useCameraState/index.ts
|
|
676
163
|
/**
|
|
677
164
|
* Reactive Cesium Camera state
|
|
165
|
+
* @param options options
|
|
166
|
+
* @returns Reactive camera states
|
|
678
167
|
*/
|
|
679
168
|
function useCameraState(options = {}) {
|
|
680
169
|
let getCamera = options.camera;
|
|
@@ -726,6 +215,8 @@ function computeLevel(height) {
|
|
|
726
215
|
//#region useCesiumFps/index.ts
|
|
727
216
|
/**
|
|
728
217
|
* Reactive get the frame rate of Cesium
|
|
218
|
+
* @param options options
|
|
219
|
+
* @returns Reactive fps states
|
|
729
220
|
*/
|
|
730
221
|
function useCesiumFps(options = {}) {
|
|
731
222
|
const { delay = 100 } = options;
|
|
@@ -750,15 +241,14 @@ function useCesiumFps(options = {}) {
|
|
|
750
241
|
/**
|
|
751
242
|
* Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.
|
|
752
243
|
* - note: This is a basic function that is intended to be called by other lower-level function
|
|
753
|
-
* @
|
|
754
|
-
* @param removeFn - Clean SideEffect function. eg.`entities.remove`
|
|
755
|
-
* @param removeScopeArgs - The parameters to pass for `removeScope` triggered when the component is unmounted
|
|
244
|
+
* @returns Contains side effect addition and removal functions
|
|
756
245
|
*/
|
|
757
|
-
function useCollectionScope(
|
|
246
|
+
function useCollectionScope(options) {
|
|
247
|
+
const { addEffect, removeEffect, removeScopeArgs } = options;
|
|
758
248
|
const scope = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
759
249
|
const add = (instance, ...args) => {
|
|
760
|
-
const result =
|
|
761
|
-
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) => {
|
|
762
252
|
result.then((i) => {
|
|
763
253
|
scope.add(i);
|
|
764
254
|
resolve(i);
|
|
@@ -771,7 +261,7 @@ function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
|
771
261
|
};
|
|
772
262
|
const remove = (instance, ...args) => {
|
|
773
263
|
scope.delete(instance);
|
|
774
|
-
return
|
|
264
|
+
return removeEffect(instance, ...args);
|
|
775
265
|
};
|
|
776
266
|
const removeWhere = (predicate, ...args) => {
|
|
777
267
|
scope.forEach((instance) => {
|
|
@@ -800,8 +290,7 @@ function useDataSource(dataSources, options = {}) {
|
|
|
800
290
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
|
|
801
291
|
const viewer = useViewer();
|
|
802
292
|
(0, vue.watchEffect)((onCleanup) => {
|
|
803
|
-
|
|
804
|
-
if (_isActive) {
|
|
293
|
+
if ((0, vue.toValue)(isActive)) {
|
|
805
294
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
806
295
|
const _collection = collection ?? viewer.value?.dataSources;
|
|
807
296
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -817,7 +306,7 @@ function useDataSource(dataSources, options = {}) {
|
|
|
817
306
|
//#endregion
|
|
818
307
|
//#region useDataSourceScope/index.ts
|
|
819
308
|
/**
|
|
820
|
-
*
|
|
309
|
+
* Scope the SideEffects of `DataSourceCollection` operations and automatically remove them when unmounted
|
|
821
310
|
*/
|
|
822
311
|
function useDataSourceScope(options = {}) {
|
|
823
312
|
const { collection: _collection, destroyOnRemove } = options;
|
|
@@ -825,21 +314,25 @@ function useDataSourceScope(options = {}) {
|
|
|
825
314
|
const collection = (0, vue.computed)(() => {
|
|
826
315
|
return (0, vue.toValue)(_collection) ?? viewer.value?.dataSources;
|
|
827
316
|
});
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
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
|
+
});
|
|
843
336
|
}
|
|
844
337
|
|
|
845
338
|
//#endregion
|
|
@@ -852,15 +345,15 @@ function useElementOverlay(target, position, options = {}) {
|
|
|
852
345
|
x: 0,
|
|
853
346
|
y: 0
|
|
854
347
|
} } = options;
|
|
855
|
-
const cartesian3 = (0, vue.computed)(() => toCartesian3((0, vue.toValue)(position)));
|
|
348
|
+
const cartesian3 = (0, vue.computed)(() => (0, __vesium_shared.toCartesian3)((0, vue.toValue)(position)));
|
|
856
349
|
const viewer = useViewer();
|
|
857
350
|
const coord = (0, vue.shallowRef)();
|
|
858
351
|
useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
|
|
859
352
|
if (!viewer.value?.scene) return;
|
|
860
353
|
if (!cartesian3.value) coord.value = void 0;
|
|
861
354
|
else {
|
|
862
|
-
const
|
|
863
|
-
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;
|
|
864
357
|
}
|
|
865
358
|
});
|
|
866
359
|
const canvasBounding = (0, __vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
|
|
@@ -921,8 +414,7 @@ function useEntity(data, options = {}) {
|
|
|
921
414
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
922
415
|
const viewer = useViewer();
|
|
923
416
|
(0, vue.watchEffect)((onCleanup) => {
|
|
924
|
-
|
|
925
|
-
if (_isActive) {
|
|
417
|
+
if ((0, vue.toValue)(isActive)) {
|
|
926
418
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
927
419
|
const _collection = collection ?? viewer.value?.entities;
|
|
928
420
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -946,22 +438,25 @@ function useEntityScope(options = {}) {
|
|
|
946
438
|
const collection = (0, vue.computed)(() => {
|
|
947
439
|
return (0, vue.toValue)(_collection) ?? viewer.value?.entities;
|
|
948
440
|
});
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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
|
+
});
|
|
965
460
|
}
|
|
966
461
|
|
|
967
462
|
//#endregion
|
|
@@ -1017,7 +512,7 @@ function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
|
1017
512
|
const modifierValue = (0, vue.toValue)(modifier);
|
|
1018
513
|
const handlerValue = (0, vue.toValue)(handler);
|
|
1019
514
|
if (!handlerValue || !isActive.value || !inputAction) return;
|
|
1020
|
-
if (isDef(typeValue)) {
|
|
515
|
+
if ((0, __vesium_shared.isDef)(typeValue)) {
|
|
1021
516
|
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
1022
517
|
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
1023
518
|
}
|
|
@@ -1066,7 +561,7 @@ function useDrag(listener) {
|
|
|
1066
561
|
dragging.value = true;
|
|
1067
562
|
position.value = event.position.clone();
|
|
1068
563
|
});
|
|
1069
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, throttle(({ startPosition, endPosition }) => {
|
|
564
|
+
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0, __vesium_shared.throttle)(({ startPosition, endPosition }) => {
|
|
1070
565
|
motionEvent.value = {
|
|
1071
566
|
startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
|
|
1072
567
|
endPosition: endPosition.clone()
|
|
@@ -1184,7 +679,7 @@ function useGraphicEvent() {
|
|
|
1184
679
|
const collection = /* @__PURE__ */ new WeakMap();
|
|
1185
680
|
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1186
681
|
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1187
|
-
const
|
|
682
|
+
const remove = (graphic, type, listener) => {
|
|
1188
683
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1189
684
|
collection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1190
685
|
cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
|
|
@@ -1197,30 +692,29 @@ function useGraphicEvent() {
|
|
|
1197
692
|
if (dragCursorCollection?.get(_graphic)?.get(type)?.size === 0) dragCursorCollection?.get(_graphic)?.delete(type);
|
|
1198
693
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1199
694
|
};
|
|
1200
|
-
const
|
|
695
|
+
const add = (graphic, type, listener, options = {}) => {
|
|
1201
696
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1202
697
|
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1203
698
|
const eventTypeMap = collection.get(_graphic);
|
|
1204
699
|
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
1205
|
-
|
|
1206
|
-
listeners.add(listener);
|
|
700
|
+
eventTypeMap.get(type).add(listener);
|
|
1207
701
|
let { cursor = "pointer", dragCursor } = options;
|
|
1208
|
-
if (isDef(cursor)) {
|
|
1209
|
-
const _cursor = isFunction(cursor) ? cursor : () => cursor;
|
|
702
|
+
if ((0, __vesium_shared.isDef)(cursor)) {
|
|
703
|
+
const _cursor = (0, __vesium_shared.isFunction)(cursor) ? cursor : () => cursor;
|
|
1210
704
|
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1211
705
|
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1212
706
|
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
1213
707
|
}
|
|
1214
|
-
if (type === "DRAG") dragCursor ??= (event) => event?.dragging ? "crosshair" : void 0;
|
|
1215
|
-
if (isDef(dragCursor)) {
|
|
1216
|
-
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;
|
|
1217
711
|
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1218
712
|
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1219
713
|
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
1220
714
|
}
|
|
1221
|
-
return () =>
|
|
715
|
+
return () => remove(graphic, type, listener);
|
|
1222
716
|
};
|
|
1223
|
-
const
|
|
717
|
+
const clear = (graphic, type) => {
|
|
1224
718
|
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1225
719
|
if (type === "all") {
|
|
1226
720
|
collection.delete(_graphic);
|
|
@@ -1236,42 +730,40 @@ function useGraphicEvent() {
|
|
|
1236
730
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1237
731
|
};
|
|
1238
732
|
for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
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));
|
|
1242
735
|
});
|
|
1243
736
|
});
|
|
1244
737
|
const dragging = (0, vue.ref)(false);
|
|
1245
738
|
const viewer = useViewer();
|
|
1246
739
|
useHover((event) => {
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
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));
|
|
1250
742
|
if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
|
|
1251
743
|
map.forEach((fn) => {
|
|
1252
|
-
const cursor = event.hovering ? tryRun(fn)(event) : "";
|
|
744
|
+
const cursor = event.hovering ? (0, __vesium_shared.tryRun)(fn)(event) : "";
|
|
1253
745
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1254
746
|
});
|
|
1255
747
|
});
|
|
1256
748
|
});
|
|
1257
749
|
});
|
|
1258
750
|
useDrag((event) => {
|
|
1259
|
-
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
751
|
+
const graphics = (0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
1260
752
|
dragging.value = event.dragging;
|
|
1261
753
|
graphics.forEach((graphic) => {
|
|
1262
|
-
collection.get(graphic)?.get("DRAG")?.forEach((fn) => tryRun(fn)(event));
|
|
754
|
+
collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)(event));
|
|
1263
755
|
dragCursorCollection.get(graphic)?.forEach((map) => {
|
|
1264
756
|
map.forEach((fn) => {
|
|
1265
|
-
const cursor = event.dragging ? tryRun(fn)(event) : "";
|
|
757
|
+
const cursor = event.dragging ? (0, __vesium_shared.tryRun)(fn)(event) : "";
|
|
1266
758
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1267
759
|
});
|
|
1268
760
|
});
|
|
1269
761
|
});
|
|
1270
762
|
});
|
|
1271
763
|
return {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
764
|
+
add,
|
|
765
|
+
remove,
|
|
766
|
+
clear
|
|
1275
767
|
};
|
|
1276
768
|
}
|
|
1277
769
|
|
|
@@ -1282,8 +774,7 @@ function useImageryLayer(data, options = {}) {
|
|
|
1282
774
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
1283
775
|
const viewer = useViewer();
|
|
1284
776
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1285
|
-
|
|
1286
|
-
if (_isActive) {
|
|
777
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1287
778
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1288
779
|
const _collection = collection ?? viewer.value?.imageryLayers;
|
|
1289
780
|
if (collection?.isDestroyed()) return;
|
|
@@ -1319,22 +810,25 @@ function useImageryLayerScope(options = {}) {
|
|
|
1319
810
|
const collection = (0, vue.computed)(() => {
|
|
1320
811
|
return (0, vue.toValue)(_collection) ?? viewer.value?.imageryLayers;
|
|
1321
812
|
});
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
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
|
+
});
|
|
1338
832
|
}
|
|
1339
833
|
|
|
1340
834
|
//#endregion
|
|
@@ -1345,8 +839,7 @@ function usePostProcessStage(data, options = {}) {
|
|
|
1345
839
|
const viewer = useViewer();
|
|
1346
840
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1347
841
|
if (!viewer.value) return;
|
|
1348
|
-
|
|
1349
|
-
if (_isActive) {
|
|
842
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1350
843
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1351
844
|
const _collection = collection ?? viewer.value.scene.postProcessStages;
|
|
1352
845
|
list.forEach((item) => item && _collection.add(item));
|
|
@@ -1370,21 +863,22 @@ function usePostProcessStageScope(options = {}) {
|
|
|
1370
863
|
const collection = (0, vue.computed)(() => {
|
|
1371
864
|
return (0, vue.toValue)(_collection) ?? viewer.value?.postProcessStages;
|
|
1372
865
|
});
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
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
|
+
});
|
|
1388
882
|
}
|
|
1389
883
|
|
|
1390
884
|
//#endregion
|
|
@@ -1394,8 +888,7 @@ function usePrimitive(data, options = {}) {
|
|
|
1394
888
|
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
1395
889
|
const viewer = useViewer();
|
|
1396
890
|
(0, vue.watchEffect)((onCleanup) => {
|
|
1397
|
-
|
|
1398
|
-
if (_isActive) {
|
|
891
|
+
if ((0, vue.toValue)(isActive)) {
|
|
1399
892
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1400
893
|
const _collection = collection === "ground" ? viewer.value?.scene.groundPrimitives : collection ?? viewer.value?.scene.primitives;
|
|
1401
894
|
list.forEach((item) => item && _collection?.add(item));
|
|
@@ -1417,16 +910,22 @@ function usePrimitiveScope(options = {}) {
|
|
|
1417
910
|
const { collection: _collection } = options;
|
|
1418
911
|
const viewer = useViewer();
|
|
1419
912
|
const collection = (0, vue.computed)(() => {
|
|
1420
|
-
|
|
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: []
|
|
1421
928
|
});
|
|
1422
|
-
const addFn = (primitive) => {
|
|
1423
|
-
if (!collection.value) throw new Error("collection is not defined");
|
|
1424
|
-
return collection.value.add(primitive);
|
|
1425
|
-
};
|
|
1426
|
-
const removeFn = (primitive) => {
|
|
1427
|
-
return !!collection.value?.remove(primitive);
|
|
1428
|
-
};
|
|
1429
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
1430
929
|
return {
|
|
1431
930
|
scope,
|
|
1432
931
|
add,
|
|
@@ -1495,21 +994,15 @@ function useScaleBar(options = {}) {
|
|
|
1495
994
|
const leftPosition = scene.globe.pick(left, scene);
|
|
1496
995
|
const rightPosition = scene.globe.pick(right, scene);
|
|
1497
996
|
if (!leftPosition || !rightPosition) return;
|
|
1498
|
-
|
|
1499
|
-
const rightCartographic = scene.globe.ellipsoid.cartesianToCartographic(rightPosition);
|
|
1500
|
-
const geodesic = new cesium.EllipsoidGeodesic(leftCartographic, rightCartographic);
|
|
1501
|
-
pixelDistance.value = geodesic.surfaceDistance;
|
|
997
|
+
pixelDistance.value = new cesium.EllipsoidGeodesic(scene.globe.ellipsoid.cartesianToCartographic(leftPosition), scene.globe.ellipsoid.cartesianToCartographic(rightPosition)).surfaceDistance;
|
|
1502
998
|
};
|
|
1503
999
|
(0, __vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
|
|
1504
|
-
useCesiumEventListener(() => viewer.value?.camera.changed, throttle(setPixelDistance, delay));
|
|
1000
|
+
useCesiumEventListener(() => viewer.value?.camera.changed, (0, __vesium_shared.throttle)(setPixelDistance, delay));
|
|
1505
1001
|
const distance = (0, vue.computed)(() => {
|
|
1506
1002
|
if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
|
|
1507
1003
|
});
|
|
1508
1004
|
const width = (0, vue.computed)(() => {
|
|
1509
|
-
if (distance.value && pixelDistance.value)
|
|
1510
|
-
const value = distance.value / pixelDistance.value;
|
|
1511
|
-
return value;
|
|
1512
|
-
}
|
|
1005
|
+
if (distance.value && pixelDistance.value) return distance.value / pixelDistance.value;
|
|
1513
1006
|
return 0;
|
|
1514
1007
|
});
|
|
1515
1008
|
const distanceText = (0, vue.computed)(() => {
|
|
@@ -1535,54 +1028,16 @@ function useSceneDrillPick(windowPosition, options = {}) {
|
|
|
1535
1028
|
const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
|
|
1536
1029
|
const viewer = useViewer();
|
|
1537
1030
|
const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
|
|
1538
|
-
|
|
1031
|
+
return (0, vue.computed)(() => {
|
|
1539
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));
|
|
1540
1033
|
});
|
|
1541
|
-
return pick;
|
|
1542
1034
|
}
|
|
1543
1035
|
|
|
1544
1036
|
//#endregion
|
|
1545
1037
|
exports.CREATE_VIEWER_COLLECTION = CREATE_VIEWER_COLLECTION;
|
|
1546
1038
|
exports.CREATE_VIEWER_INJECTION_KEY = CREATE_VIEWER_INJECTION_KEY;
|
|
1547
|
-
exports.CesiumMaterial = CesiumMaterial;
|
|
1548
|
-
exports.addMaterialCache = addMaterialCache;
|
|
1549
|
-
exports.arrayDiff = arrayDiff;
|
|
1550
|
-
exports.assertError = assertError;
|
|
1551
|
-
exports.canvasCoordToCartesian = canvasCoordToCartesian;
|
|
1552
|
-
exports.cartesianToCanvasCoord = cartesianToCanvasCoord;
|
|
1553
|
-
exports.cesiumEquals = cesiumEquals;
|
|
1554
|
-
exports.createCesiumAttribute = createCesiumAttribute;
|
|
1555
|
-
exports.createCesiumProperty = createCesiumProperty;
|
|
1556
|
-
exports.createPropertyField = createPropertyField;
|
|
1557
1039
|
exports.createViewer = createViewer;
|
|
1558
|
-
exports.degreesToDms = degreesToDms;
|
|
1559
|
-
exports.dmsDecode = dmsDecode;
|
|
1560
|
-
exports.dmsEncode = dmsEncode;
|
|
1561
|
-
exports.dmsToDegrees = dmsToDegrees;
|
|
1562
|
-
exports.getMaterialCache = getMaterialCache;
|
|
1563
|
-
exports.isArray = isArray;
|
|
1564
|
-
exports.isBase64 = isBase64;
|
|
1565
|
-
exports.isBoolean = isBoolean;
|
|
1566
|
-
exports.isCesiumConstant = isCesiumConstant;
|
|
1567
|
-
exports.isDef = isDef;
|
|
1568
|
-
exports.isElement = isElement;
|
|
1569
|
-
exports.isFunction = isFunction;
|
|
1570
|
-
exports.isNumber = isNumber;
|
|
1571
|
-
exports.isObject = isObject;
|
|
1572
|
-
exports.isPromise = isPromise;
|
|
1573
|
-
exports.isProperty = isProperty;
|
|
1574
|
-
exports.isString = isString;
|
|
1575
|
-
exports.isWindow = isWindow;
|
|
1576
|
-
exports.pickHitGraphic = pickHitGraphic;
|
|
1577
|
-
exports.resolvePick = resolvePick;
|
|
1578
|
-
exports.throttle = throttle;
|
|
1579
|
-
exports.toCartesian3 = toCartesian3;
|
|
1580
|
-
exports.toCartographic = toCartographic;
|
|
1581
|
-
exports.toCoord = toCoord;
|
|
1582
1040
|
exports.toPromiseValue = toPromiseValue;
|
|
1583
|
-
exports.toProperty = toProperty;
|
|
1584
|
-
exports.toPropertyValue = toPropertyValue;
|
|
1585
|
-
exports.tryRun = tryRun;
|
|
1586
1041
|
exports.useCameraState = useCameraState;
|
|
1587
1042
|
exports.useCesiumEventListener = useCesiumEventListener;
|
|
1588
1043
|
exports.useCesiumFps = useCesiumFps;
|
|
@@ -1604,4 +1059,11 @@ exports.useSceneDrillPick = useSceneDrillPick;
|
|
|
1604
1059
|
exports.useScenePick = useScenePick;
|
|
1605
1060
|
exports.useScreenSpaceEventHandler = useScreenSpaceEventHandler;
|
|
1606
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
|
+
|
|
1607
1069
|
//# sourceMappingURL=index.cjs.map
|