vesium 1.0.1-beta.57 → 1.0.1-beta.59

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.
@@ -1,4 +1,4 @@
1
- (function(exports, __vueuse_core, cesium, vue, __vesium_shared) {
1
+ (function(exports, _vueuse_core, cesium, vue, _vesium_shared) {
2
2
 
3
3
 
4
4
  //#region createViewer/index.ts
@@ -19,7 +19,7 @@
19
19
  const scope = (0, vue.getCurrentScope)();
20
20
  if (scope) CREATE_VIEWER_COLLECTION.set(scope, readonlyViewer);
21
21
  const canvas = (0, vue.computed)(() => viewer.value?.canvas);
22
- (0, __vueuse_core.useMutationObserver)(document?.body, () => {
22
+ (0, _vueuse_core.useMutationObserver)(document?.body, () => {
23
23
  if (canvas.value && !document?.body.contains(canvas.value)) viewer.value = void 0;
24
24
  }, {
25
25
  childList: true,
@@ -34,7 +34,7 @@
34
34
  onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
35
35
  } else viewer.value = void 0;
36
36
  });
37
- (0, __vueuse_core.tryOnScopeDispose)(() => {
37
+ (0, _vueuse_core.tryOnScopeDispose)(() => {
38
38
  viewer.value = void 0;
39
39
  });
40
40
  return (0, vue.computed)(() => {
@@ -66,10 +66,10 @@
66
66
  try {
67
67
  const { raw = true } = options;
68
68
  let value;
69
- if ((0, __vesium_shared.isFunction)(source)) value = await source();
69
+ if ((0, _vesium_shared.isFunction)(source)) value = await source();
70
70
  else {
71
71
  const result = (0, vue.toValue)(source);
72
- value = (0, __vesium_shared.isPromise)(result) ? await result : result;
72
+ value = (0, _vesium_shared.isPromise)(result) ? await result : result;
73
73
  }
74
74
  return raw ? (0, vue.toRaw)(value) : value;
75
75
  } catch (error) {
@@ -105,7 +105,7 @@
105
105
  }
106
106
  }
107
107
  });
108
- (0, __vueuse_core.tryOnScopeDispose)(cleanup.stop);
108
+ (0, _vueuse_core.tryOnScopeDispose)(cleanup.stop);
109
109
  return cleanup.stop;
110
110
  }
111
111
 
@@ -147,7 +147,7 @@
147
147
  const eventField = (0, vue.toValue)(options.event) || "changed";
148
148
  return camera.value?.[eventField];
149
149
  });
150
- const changedSymbol = (0, __vueuse_core.refThrottled)((0, vue.shallowRef)(Symbol("camera change")), options.delay ?? 8, true, false);
150
+ const changedSymbol = (0, _vueuse_core.refThrottled)((0, vue.shallowRef)(Symbol("camera change")), options.delay ?? 8, true, false);
151
151
  const setChangedSymbol = () => {
152
152
  changedSymbol.value = Symbol("camera change");
153
153
  };
@@ -195,7 +195,7 @@
195
195
  const p = (0, vue.shallowRef)(performance.now());
196
196
  useCesiumEventListener(() => viewer.value?.scene.postRender, () => p.value = performance.now());
197
197
  const interval = (0, vue.ref)(0);
198
- (0, __vueuse_core.watchThrottled)(p, (value, oldValue) => {
198
+ (0, _vueuse_core.watchThrottled)(p, (value, oldValue) => {
199
199
  interval.value = value - oldValue;
200
200
  }, { throttle: delay });
201
201
  const fps = (0, vue.computed)(() => {
@@ -219,7 +219,7 @@
219
219
  const scope = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
220
220
  const add = (instance, ...args) => {
221
221
  const result = addEffect(instance, ...args);
222
- if ((0, __vesium_shared.isPromise)(result)) return new Promise((resolve, reject) => {
222
+ if ((0, _vesium_shared.isPromise)(result)) return new Promise((resolve, reject) => {
223
223
  result.then((i) => {
224
224
  scope.add(i);
225
225
  resolve(i);
@@ -244,7 +244,7 @@
244
244
  remove(instance, ...args);
245
245
  });
246
246
  };
247
- (0, __vueuse_core.tryOnScopeDispose)(() => removeScope(...removeScopeArgs));
247
+ (0, _vueuse_core.tryOnScopeDispose)(() => removeScope(...removeScopeArgs));
248
248
  return {
249
249
  scope: (0, vue.shallowReadonly)(scope),
250
250
  add,
@@ -258,7 +258,7 @@
258
258
  //#region useDataSource/index.ts
259
259
  function useDataSource(dataSources, options = {}) {
260
260
  const { destroyOnRemove, collection, isActive = true, evaluating } = options;
261
- const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
261
+ const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
262
262
  const viewer = useViewer();
263
263
  (0, vue.watchEffect)((onCleanup) => {
264
264
  if ((0, vue.toValue)(isActive)) {
@@ -288,7 +288,7 @@
288
288
  return useCollectionScope({
289
289
  addEffect(instance) {
290
290
  if (!collection.value) throw new Error("collection is not defined");
291
- if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
291
+ if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
292
292
  instance.then((i) => {
293
293
  collection.value.add(i);
294
294
  resolve(i);
@@ -318,11 +318,13 @@
318
318
  } } = options;
319
319
  const viewer = useViewer();
320
320
  const cartesian3 = (0, vue.computed)(() => {
321
- if (!(0, vue.toValue)(clampToGround)) return (0, __vesium_shared.toCartesian3)((0, vue.toValue)(position));
321
+ const positionValue = (0, vue.toValue)(position);
322
+ if (!positionValue) return;
323
+ else if (!(0, vue.toValue)(clampToGround)) return (0, _vesium_shared.toCartesian3)(positionValue);
322
324
  else {
323
- const cartographic = (0, __vesium_shared.toCartographic)((0, vue.toValue)(position));
325
+ const cartographic = (0, _vesium_shared.toCartographic)((0, vue.toValue)(positionValue));
324
326
  cartographic.height = +(viewer.value?.scene.globe.getHeight(cartographic) || 0).toFixed(2);
325
- return (0, __vesium_shared.toCartesian3)(cartographic);
327
+ return (0, _vesium_shared.toCartesian3)(cartographic);
326
328
  }
327
329
  });
328
330
  const coord = (0, vue.shallowRef)();
@@ -330,12 +332,12 @@
330
332
  if (!viewer.value?.scene) return;
331
333
  if (!cartesian3.value) coord.value = void 0;
332
334
  else {
333
- const result = (0, __vesium_shared.cartesianToCanvasCoord)(cartesian3.value, viewer.value.scene);
335
+ const result = (0, _vesium_shared.cartesianToCanvasCoord)(cartesian3.value, viewer.value.scene);
334
336
  coord.value = !cesium.Cartesian2.equals(result, coord.value) ? result : coord.value;
335
337
  }
336
338
  });
337
- const canvasBounding = (0, __vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
338
- const targetBounding = (0, __vueuse_core.useElementBounding)(target);
339
+ const canvasBounding = (0, _vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
340
+ const targetBounding = (0, _vueuse_core.useElementBounding)(target);
339
341
  const finalOffset = (0, vue.computed)(() => {
340
342
  const _offset = (0, vue.toValue)(offset);
341
343
  let x$1 = _offset?.x ?? 0;
@@ -389,7 +391,7 @@
389
391
  //#region useEntity/index.ts
390
392
  function useEntity(data, options = {}) {
391
393
  const { collection, isActive = true, evaluating } = options;
392
- const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
394
+ const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
393
395
  const viewer = useViewer();
394
396
  (0, vue.watchEffect)((onCleanup) => {
395
397
  if ((0, vue.toValue)(isActive)) {
@@ -419,7 +421,7 @@
419
421
  return useCollectionScope({
420
422
  addEffect(instance) {
421
423
  if (!collection.value) throw new Error("collection is not defined");
422
- if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
424
+ if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
423
425
  instance.then((i) => {
424
426
  collection.value.add(i);
425
427
  resolve(i);
@@ -450,7 +452,7 @@
450
452
  const { width = 3, height = 3, throttled = 8 } = options;
451
453
  const isActive = (0, vue.toRef)(options.isActive ?? true);
452
454
  const viewer = useViewer();
453
- const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)?.clone()), throttled, false, true);
455
+ const position = (0, _vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)?.clone()), throttled, false, true);
454
456
  const pick = (0, vue.shallowRef)();
455
457
  (0, vue.watchEffect)(() => {
456
458
  if (viewer.value && position.value && isActive.value) {
@@ -490,7 +492,7 @@
490
492
  const modifierValue = (0, vue.toValue)(modifier);
491
493
  const handlerValue = (0, vue.toValue)(handler);
492
494
  if (!handlerValue || !isActive.value || !inputAction) return;
493
- if ((0, __vesium_shared.isDef)(typeValue)) {
495
+ if ((0, _vesium_shared.isDef)(typeValue)) {
494
496
  handlerValue.setInputAction(inputAction, typeValue, modifierValue);
495
497
  onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
496
498
  }
@@ -499,7 +501,7 @@
499
501
  cleanup1();
500
502
  cleanup2();
501
503
  };
502
- (0, __vueuse_core.tryOnScopeDispose)(stop);
504
+ (0, _vueuse_core.tryOnScopeDispose)(stop);
503
505
  return stop;
504
506
  }
505
507
 
@@ -539,7 +541,7 @@
539
541
  dragging.value = true;
540
542
  position.value = event.position.clone();
541
543
  });
542
- const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0, __vesium_shared.throttle)(({ startPosition, endPosition }) => {
544
+ const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0, _vesium_shared.throttle)(({ startPosition, endPosition }) => {
543
545
  motionEvent.value = {
544
546
  startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
545
547
  endPosition: endPosition.clone()
@@ -562,7 +564,7 @@
562
564
  stopMouseMoveWatch();
563
565
  stopLeftUpWatch();
564
566
  };
565
- (0, __vueuse_core.tryOnScopeDispose)(stop);
567
+ (0, _vueuse_core.tryOnScopeDispose)(stop);
566
568
  return stop;
567
569
  }
568
570
 
@@ -677,15 +679,15 @@
677
679
  eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
678
680
  eventTypeMap.get(type).add(listener);
679
681
  let { cursor = "pointer", dragCursor } = options;
680
- if ((0, __vesium_shared.isDef)(cursor)) {
681
- const _cursor = (0, __vesium_shared.isFunction)(cursor) ? cursor : () => cursor;
682
+ if ((0, _vesium_shared.isDef)(cursor)) {
683
+ const _cursor = (0, _vesium_shared.isFunction)(cursor) ? cursor : () => cursor;
682
684
  cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
683
685
  cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
684
686
  cursorCollection.get(_graphic).get(type).set(listener, _cursor);
685
687
  }
686
688
  if (type === "DRAG") dragCursor ??= ((event) => event?.dragging ? "crosshair" : void 0);
687
- if ((0, __vesium_shared.isDef)(dragCursor)) {
688
- const _dragCursor = (0, __vesium_shared.isFunction)(dragCursor) ? dragCursor : () => dragCursor;
689
+ if ((0, _vesium_shared.isDef)(dragCursor)) {
690
+ const _dragCursor = (0, _vesium_shared.isFunction)(dragCursor) ? dragCursor : () => dragCursor;
689
691
  dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
690
692
  dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
691
693
  dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
@@ -708,31 +710,31 @@
708
710
  if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
709
711
  };
710
712
  for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
711
- (0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
712
- collection.get(graphic)?.get(type)?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)?.(event));
713
+ (0, _vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
714
+ collection.get(graphic)?.get(type)?.forEach((fn) => (0, _vesium_shared.tryRun)(fn)?.(event));
713
715
  });
714
716
  });
715
717
  const dragging = (0, vue.ref)(false);
716
718
  const viewer = useViewer();
717
719
  useHover((event) => {
718
- (0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
719
- collection.get(graphic)?.get("HOVER")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)?.(event));
720
+ (0, _vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
721
+ collection.get(graphic)?.get("HOVER")?.forEach((fn) => (0, _vesium_shared.tryRun)(fn)?.(event));
720
722
  if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
721
723
  map.forEach((fn) => {
722
- const cursor = event.hovering ? (0, __vesium_shared.tryRun)(fn)(event) : "";
724
+ const cursor = event.hovering ? (0, _vesium_shared.tryRun)(fn)(event) : "";
723
725
  viewer.value?.canvas.style?.setProperty("cursor", cursor);
724
726
  });
725
727
  });
726
728
  });
727
729
  });
728
730
  useDrag((event) => {
729
- const graphics = (0, __vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
731
+ const graphics = (0, _vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
730
732
  dragging.value = event.dragging;
731
733
  graphics.forEach((graphic) => {
732
- collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0, __vesium_shared.tryRun)(fn)(event));
734
+ collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0, _vesium_shared.tryRun)(fn)(event));
733
735
  dragCursorCollection.get(graphic)?.forEach((map) => {
734
736
  map.forEach((fn) => {
735
- const cursor = event.dragging ? (0, __vesium_shared.tryRun)(fn)(event) : "";
737
+ const cursor = event.dragging ? (0, _vesium_shared.tryRun)(fn)(event) : "";
736
738
  viewer.value?.canvas.style?.setProperty("cursor", cursor);
737
739
  });
738
740
  });
@@ -749,7 +751,7 @@
749
751
  //#region useImageryLayer/index.ts
750
752
  function useImageryLayer(data, options = {}) {
751
753
  const { destroyOnRemove, collection, isActive = true, evaluating } = options;
752
- const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
754
+ const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
753
755
  const viewer = useViewer();
754
756
  (0, vue.watchEffect)((onCleanup) => {
755
757
  if ((0, vue.toValue)(isActive)) {
@@ -791,7 +793,7 @@
791
793
  return useCollectionScope({
792
794
  addEffect(instance, index) {
793
795
  if (!collection.value) throw new Error("collection is not defined");
794
- if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
796
+ if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
795
797
  instance.then((i) => {
796
798
  collection.value.add(i, index);
797
799
  resolve(i);
@@ -813,7 +815,7 @@
813
815
  //#region usePostProcessStage/index.ts
814
816
  function usePostProcessStage(data, options = {}) {
815
817
  const { collection, isActive = true, evaluating } = options;
816
- const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
818
+ const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
817
819
  const viewer = useViewer();
818
820
  (0, vue.watchEffect)((onCleanup) => {
819
821
  if (!viewer.value) return;
@@ -844,7 +846,7 @@
844
846
  return useCollectionScope({
845
847
  addEffect(instance) {
846
848
  if (!collection.value) throw new Error("collection is not defined");
847
- if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
849
+ if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
848
850
  instance.then((instance$1) => {
849
851
  collection.value.add(instance$1);
850
852
  resolve(instance$1);
@@ -863,7 +865,7 @@
863
865
  //#region usePrimitive/index.ts
864
866
  function usePrimitive(data, options = {}) {
865
867
  const { collection, isActive = true, evaluating } = options;
866
- const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
868
+ const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
867
869
  const viewer = useViewer();
868
870
  (0, vue.watchEffect)((onCleanup) => {
869
871
  if ((0, vue.toValue)(isActive)) {
@@ -894,7 +896,7 @@
894
896
  const { scope, add, remove, removeWhere, removeScope } = useCollectionScope({
895
897
  addEffect(instance, ...args) {
896
898
  if (!collection.value) throw new Error("collection is not defined");
897
- if ((0, __vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
899
+ if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
898
900
  instance.then((instance$1) => resolve(collection.value.add(instance$1, ...args))).catch((error) => reject(error));
899
901
  });
900
902
  else return collection.value.add(instance, ...args);
@@ -960,7 +962,7 @@
960
962
  const { maxPixel = 80, delay = 8 } = options;
961
963
  const maxPixelRef = (0, vue.computed)(() => (0, vue.toValue)(maxPixel));
962
964
  const viewer = useViewer();
963
- const canvasSize = (0, __vueuse_core.useElementSize)(() => viewer.value?.canvas);
965
+ const canvasSize = (0, _vueuse_core.useElementSize)(() => viewer.value?.canvas);
964
966
  const pixelDistance = (0, vue.ref)();
965
967
  const setPixelDistance = async () => {
966
968
  await (0, vue.nextTick)();
@@ -974,8 +976,8 @@
974
976
  if (!leftPosition || !rightPosition) return;
975
977
  pixelDistance.value = new cesium.EllipsoidGeodesic(scene.globe.ellipsoid.cartesianToCartographic(leftPosition), scene.globe.ellipsoid.cartesianToCartographic(rightPosition)).surfaceDistance;
976
978
  };
977
- (0, __vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
978
- useCesiumEventListener(() => viewer.value?.camera.changed, (0, __vesium_shared.throttle)(setPixelDistance, delay));
979
+ (0, _vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
980
+ useCesiumEventListener(() => viewer.value?.camera.changed, (0, _vesium_shared.throttle)(setPixelDistance, delay));
979
981
  const distance = (0, vue.computed)(() => {
980
982
  if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
981
983
  });
@@ -1005,7 +1007,7 @@
1005
1007
  function useSceneDrillPick(windowPosition, options = {}) {
1006
1008
  const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
1007
1009
  const viewer = useViewer();
1008
- const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
1010
+ const position = (0, _vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
1009
1011
  return (0, vue.computed)(() => {
1010
1012
  if (position.value && (0, vue.toValue)(isActive)) return viewer.value?.scene.drillPick(position.value, (0, vue.toValue)(limit), (0, vue.toValue)(width), (0, vue.toValue)(height));
1011
1013
  });
@@ -1037,10 +1039,10 @@ exports.useSceneDrillPick = useSceneDrillPick;
1037
1039
  exports.useScenePick = useScenePick;
1038
1040
  exports.useScreenSpaceEventHandler = useScreenSpaceEventHandler;
1039
1041
  exports.useViewer = useViewer;
1040
- Object.keys(__vesium_shared).forEach(function (k) {
1042
+ Object.keys(_vesium_shared).forEach(function (k) {
1041
1043
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1042
1044
  enumerable: true,
1043
- get: function () { return __vesium_shared[k]; }
1045
+ get: function () { return _vesium_shared[k]; }
1044
1046
  });
1045
1047
  });
1046
1048