UNPKG

vesium

Version:

Vue component and composition-api library for Cesium.

1 lines 135 kB
{"version":3,"file":"index.cjs","names":["CREATE_VIEWER_INJECTION_KEY: InjectionKey<Readonly<ShallowRef<Viewer | undefined>>>","Viewer","list: T[]","oldList: T[] | undefined","added: T[]","canvasCoord: Cartesian2","scene: Scene","mode: 'pickPosition' | 'globePick' | 'auto'","position: Cartesian3","scene: Scene","val?: T","val: any","val: unknown","val: string","condition: boolean","error: any","left: any","right: any","position?: CommonCoord","options: ToCoordOptions<T, Alt>","longitude: number","latitude: number","height: number | undefined","Cartesian3","Cartographic","degrees: number","dmsCode: string","position: CommonCoord","dms: DMSCoord","value: MaybeProperty","Material","options: CesiumMaterialConstructorOptions<U>","type: string","material: CesiumMaterialConstructorOptions<any>","pick: any","graphic: any | any[]","value: any","value: MaybeProperty<T>","time?: JulianDate","value?: MaybePropertyOrGetter<T>","CallbackProperty","ConstantProperty","scope: any","field: string","maybeProperty?: MaybePropertyOrGetter<T>","readonly?: boolean","removeOwnerListener: VoidFunction | undefined","readonly","scope: Scope","key: keyof Scope","options: CreateCesiumAttributeOptions","obj: any","value","previousListener: VoidFunction | undefined","property: Property","previous?: any","options: CreateCesiumPropertyOptions","callback: ThrottleCallback<T>","restList: T[]","position?: CommonCoord","Cartesian3","Cartographic","position?: CommonCoord","Cartesian3","Cartographic","fn: T","source: MaybeRefOrAsyncGetter<T>","options: ToPromiseValueOptions","value: T","event: Arrayable<Event<FN> | undefined> | Arrayable<MaybeRefOrGetter<Event<FN> | undefined>> | MaybeRefOrGetter<Arrayable<Event<FN> | undefined>>","listener: FN","options: UseCesiumEventListenerOptions","event","options: UseCameraStateOptions","height: number","options: UseCesiumFpsOptions","addFn: (i: T, ...args: AddArgs) => isPromise extends true ? Promise<T> : T","removeFn: (i: T, ...args: RemoveArgs) => RemoveReturn","removeScopeArgs: RemoveArgs","add: any","instance: T","predicate: EffcetRemovePredicate<T>","dataSources?: MaybeRefOrAsyncGetter<Arrayable<T | undefined>>","options: UseDataSourceOptions","options: UseDataSourceScopeOptions","dataSource: T","dataSource: CesiumDataSource","destroy?: boolean","target?: MaybeComputedElementRef","position?: MaybeRefOrGetter<CommonCoord | undefined>","options: UseElementOverlayOptions","x","y","data?: MaybeRefOrAsyncGetter<Arrayable<T | undefined>>","options: UseEntityOptions","options: UseEntityScopeOptions","entity: T","entity: Entity","windowPosition: MaybeRefOrGetter<Cartesian2 | undefined>","options: UseScenePickOptions","type?: MaybeRefOrGetter<T | undefined>","inputAction?: (event: ScreenSpaceEvent<T>) => any","options: UseScreenSpaceEventHandlerOptions","ScreenSpaceEventHandler","listener: (params: GraphicDragEvent) => void","cameraLocked","pick: unknown","startPosition: Cartesian2","endPosition: Cartesian2","ScreenSpaceEventType","pick","motionEvent","listener: (params: GraphicHoverEvent) => void","pick: unknown","startPosition: Cartesian2","endPosition: Cartesian2","hovering: boolean","ScreenSpaceEventType","pick","motionEvent","EVENT_TYPE_RECORD: Record<PositionedEventType, PositiondScreenSpaceEventType>","ScreenSpaceEventType","type: PositionedEventType","listener: (params: GraphicPositionedEvent) => void","GLOBAL_GRAPHIC_SYMBOL: GlobalGraphicSymbol","POSITIONED_EVENT_TYPES: PositionedEventType[]","graphic: CesiumGraphic | 'global'","type: GraphicEventType","listener: AnyFn","_graphic: CesiumGraphic | GlobalGraphicSymbol","options: AddGraphicEventOptions","event: GraphicDragEvent","type: GraphicEventType | 'all'","data?: MaybeRefOrAsyncGetter<Arrayable<T | undefined>>","options: UseImageryLayerOptions","options: UseImageryLayerScopeOptions","imageryLayer: T","index?: number","imageryLayer: ImageryLayer","destroy?: boolean","data?: MaybeRefOrAsyncGetter<Arrayable<T | undefined>>","options: UsePostProcessStageOptions","options: UsePostProcessStageScopeOptions","postProcessStage: T","postProcessStage: PostProcessStage","data?: MaybeRefOrAsyncGetter<Arrayable<T | undefined>>","options: UsePrimitiveOptions","options: UsePrimitiveScopeOptions","primitive: T","primitive: any","options: UseScaleBarOptions","Cartesian2","EllipsoidGeodesic","windowPosition: MaybeRefOrGetter<Cartesian2 | undefined>","options: UseSceneDrillPickOptions"],"sources":["../createViewer/index.ts","../utils/arrayDiff.ts","../utils/canvasCoordToCartesian.ts","../utils/cartesianToCanvasCoord.ts","../utils/is.ts","../utils/cesiumEquals.ts","../utils/toCoord.ts","../utils/convertDMS.ts","../utils/isCesiumConstant.ts","../utils/material.ts","../utils/pick.ts","../utils/property.ts","../utils/throttle.ts","../utils/toCartesian3.ts","../utils/toCartographic.ts","../utils/tryRun.ts","../toPromiseValue/index.ts","../useCesiumEventListener/index.ts","../useViewer/index.ts","../useCameraState/index.ts","../useCesiumFps/index.ts","../useCollectionScope/index.ts","../useDataSource/index.ts","../useDataSourceScope/index.ts","../useElementOverlay/index.ts","../useEntity/index.ts","../useEntityScope/index.ts","../useScenePick/index.ts","../useScreenSpaceEventHandler/index.ts","../useGraphicEvent/useDrag.ts","../useGraphicEvent/useHover.ts","../useGraphicEvent/usePositioned.ts","../useGraphicEvent/index.ts","../useImageryLayer/index.ts","../useImageryLayerScope/index.ts","../usePostProcessStage/index.ts","../usePostProcessStageScope/index.ts","../usePrimitive/index.ts","../usePrimitiveScope/index.ts","../useScaleBar/index.ts","../useSceneDrillPick/index.ts"],"sourcesContent":["import type { MaybeComputedElementRef } from '@vueuse/core';\nimport type { EffectScope, InjectionKey, MaybeRef, ShallowRef } from 'vue';\nimport { tryOnScopeDispose, useMutationObserver } from '@vueuse/core';\nimport { Viewer } from 'cesium';\nimport { computed, getCurrentScope, markRaw, provide, shallowReadonly, shallowRef, toRaw, toValue, watchEffect } from 'vue';\n\n/**\n * @internal\n */\nexport const CREATE_VIEWER_INJECTION_KEY: InjectionKey<Readonly<ShallowRef<Viewer | undefined>>> = Symbol('CREATE_VIEWER_INJECTION_KEY');\n\n/**\n * @internal\n */\nexport const CREATE_VIEWER_COLLECTION = new WeakMap<EffectScope, Readonly<ShallowRef<Viewer | undefined>>>();\n\n/**\n * Pass in an existing Viewer instance,\n * which can be accessed by the current component and its descendant components using {@link useViewer}\n *\n * When the Viewer instance referenced by this overloaded function becomes invalid, it will not trigger destruction.\n */\nexport function createViewer(\n viewer: MaybeRef<Viewer | undefined>,\n): Readonly<ShallowRef<Viewer | undefined>>;\n\n/**\n * Initialize a Viewer instance, which can be accessed by the\n * current component and its descendant components using {@link useViewer}.\n *\n * The Viewer instance created by this overloaded function will automatically be destroyed when it becomes invalid.\n *\n * @param element - The DOM element or ID that will contain the widget\n * @param options - @see {Viewer.ConstructorOptions}\n */\nexport function createViewer(\n element?: MaybeComputedElementRef,\n options?: Viewer.ConstructorOptions,\n): Readonly<ShallowRef<Viewer | undefined>>;\n\nexport function createViewer(...args: any) {\n const viewer = shallowRef<Viewer>();\n const readonlyViewer = shallowReadonly(viewer);\n\n provide(CREATE_VIEWER_INJECTION_KEY, readonlyViewer);\n\n const scope = getCurrentScope();\n if (scope) {\n CREATE_VIEWER_COLLECTION.set(scope, readonlyViewer);\n }\n\n const canvas = computed(() => viewer.value?.canvas);\n\n // Watch for the canvas being removed from the DOM\n useMutationObserver(document?.body, () => {\n if (canvas.value && !document?.body.contains(canvas.value)) {\n viewer.value = undefined;\n }\n }, {\n childList: true,\n subtree: true,\n });\n\n watchEffect((onCleanup) => {\n const [arg1, arg2] = args;\n const value = toRaw(toValue(arg1));\n if (value instanceof Viewer) {\n viewer.value = markRaw(value);\n }\n else if (value) {\n const element = value;\n const options = arg2;\n viewer.value = new Viewer(element, options);\n onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());\n }\n else {\n viewer.value = undefined;\n }\n });\n\n tryOnScopeDispose(() => {\n viewer.value = undefined;\n });\n\n return computed(() => {\n return viewer.value?.isDestroyed() ? undefined : viewer.value;\n });\n}\n","export interface ArrayDiffRetrun<T> {\n added: T[];\n removed: T[];\n}\n\n/**\n * 计算两个数组的差异,返回新增和删除的元素\n */\nexport function arrayDiff<T>(\n list: T[],\n oldList: T[] | undefined,\n): ArrayDiffRetrun<T> {\n const oldListSet = new Set(oldList);\n const added: T[] = list.filter(obj => !oldListSet.has(obj));\n const newListSet = new Set(list);\n const removed = oldList?.filter(obj => !newListSet.has(obj)) ?? [];\n return { added, removed };\n}\n","import type { Cartesian2, Cartesian3, Scene } from 'cesium';\nimport { Ellipsoid } from 'cesium';\n\n/**\n * Convert canvas coordinates to Cartesian coordinates\n *\n * @param canvasCoord Canvas coordinates\n * @param scene Cesium.Scene instance\n * @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'\n *\n * `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.\n * However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur\n *\n * `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,\n * but can be used for picking terrain. If terrain does not exist, the picked elevation is 0\n *\n * `auto`: Automatically determine which picking content to return\n *\n * Calculation speed comparison: globePick > auto >= pickPosition\n */\nexport function canvasCoordToCartesian(\n canvasCoord: Cartesian2,\n scene: Scene,\n mode: 'pickPosition' | 'globePick' | 'auto' = 'auto',\n): Cartesian3 | undefined {\n if (mode === 'pickPosition') {\n return scene.pickPosition(canvasCoord);\n }\n else if (mode === 'globePick') {\n const ray = scene.camera.getPickRay(canvasCoord);\n return ray && scene.globe.pick(ray, scene);\n }\n else {\n // depth test\n if (scene.globe.depthTestAgainstTerrain) {\n return scene.pickPosition(canvasCoord);\n }\n const position1 = scene.pickPosition(canvasCoord);\n const ray = scene.camera.getPickRay(canvasCoord);\n const position2 = ray && scene.globe.pick(ray, scene);\n if (!position1) {\n return position2;\n }\n const height1 = (position1 && Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;\n const height2 = (position2 && Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;\n return height1 < height2 ? position1 : position2;\n }\n}\n","import type { Cartesian2, Cartesian3, Scene } from 'cesium';\n\n/**\n * Convert Cartesian coordinates to canvas coordinates\n *\n * @param position Cartesian coordinates\n * @param scene Cesium.Scene instance\n */\nexport function cartesianToCanvasCoord(position: Cartesian3, scene: Scene): Cartesian2 {\n return scene.cartesianToCanvasCoordinates(position);\n}\n","import type { AnyFn } from './types';\n\nconst toString = Object.prototype.toString;\n\nexport function isDef<T = any>(val?: T): val is T {\n return typeof val !== 'undefined';\n}\n\nexport function isBoolean(val: any): val is boolean {\n return typeof val === 'boolean';\n}\n\nexport function isFunction<T extends AnyFn>(val: any): val is T {\n return typeof val === 'function';\n}\n\nexport function isNumber(val: any): val is number {\n return typeof val === 'number';\n}\n\nexport function isString(val: unknown): val is string {\n return typeof val === 'string';\n}\n\nexport function isObject(val: any): val is object {\n return toString.call(val) === '[object Object]';\n}\n\nexport function isWindow(val: any): val is Window {\n return typeof window !== 'undefined' && toString.call(val) === '[object Window]';\n}\n\nexport function isPromise<T extends Promise<any>>(val: any): val is T {\n return !!val && (typeof val === 'object' || typeof val === 'function') && typeof (val as any).then === 'function';\n}\n\nexport function isElement<T extends Element>(val: any): val is T {\n return !!(val && val.nodeName && val.nodeType === 1);\n}\n\nexport const isArray = Array.isArray;\n\nexport function isBase64(val: string): boolean {\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking\n const reg = /^\\s*data:([a-z]+\\/[\\d+.a-z-]+(;[a-z-]+=[\\da-z-]+)?)?(;base64)?,([\\s\\w!$%&'()*+,./:;=?@~-]*?)\\s*$/i;\n return reg.test(val);\n}\n\nexport function assertError(condition: boolean, error: any) {\n if (condition) {\n throw new Error(error);\n }\n}\n","import { isFunction } from './is';\n\n/**\n * Determines if two Cesium objects are equal.\n *\n * This function not only judges whether the instances are equal,\n * but also judges the equals method in the example.\n *\n * @param left The first Cesium object\n * @param right The second Cesium object\n * @returns Returns true if the two Cesium objects are equal, otherwise false\n */\nexport function cesiumEquals(left: any, right: any): boolean {\n return left === right || (isFunction(left?.equals) && left.equals(right)) || (isFunction(right?.equals) && right.equals(left));\n}\n","import type { CommonCoord, CoordArray, CoordArray_ALT, CoordObject, CoordObject_ALT } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid, Math } from 'cesium';\n\ninterface ToCoordOptions<T extends 'Array' | 'Object', Alt extends boolean> {\n /**\n * Return type\n * @default 'Array'\n */\n type?: T;\n\n /**\n * Whether to return altitude information\n */\n alt?: Alt;\n\n}\n\nexport type ToCoordReturn<T extends 'Array' | 'Object', Alt extends boolean>\n = T extends 'Array'\n ? Alt extends true\n ? CoordArray_ALT\n : CoordArray\n : Alt extends true\n ? CoordObject_ALT\n : CoordObject;\n\n/**\n * Converts coordinates to an array or object in the specified format.\n *\n * @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.\n * @param options Conversion options, including conversion type and whether to include altitude information.\n * @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.\n *\n * @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.\n * @template Alt Whether to include altitude information, default is false\n */\nexport function toCoord<T extends 'Array' | 'Object' = 'Array', Alt extends boolean = false>(\n position?: CommonCoord,\n options: ToCoordOptions<T, Alt> = {},\n): ToCoordReturn<T, Alt> | undefined {\n if (!position) {\n return undefined;\n }\n\n const { type = 'Array', alt = false } = options;\n\n let longitude: number, latitude: number, height: number | undefined;\n\n if (position instanceof Cartesian3) {\n const cartographic = Ellipsoid.WGS84.cartesianToCartographic(position);\n longitude = Math.toDegrees(cartographic.longitude);\n latitude = Math.toDegrees(cartographic.latitude);\n height = cartographic.height;\n }\n else if (position instanceof Cartographic) {\n const cartographic = position;\n longitude = Math.toDegrees(cartographic.longitude);\n latitude = Math.toDegrees(cartographic.latitude);\n height = cartographic.height;\n }\n else if (Array.isArray(position)) {\n longitude = Math.toDegrees(position[0]);\n latitude = Math.toDegrees(position[1]);\n height = position[2];\n }\n else {\n longitude = (position.longitude);\n latitude = (position.latitude);\n height = (position as any).height;\n }\n\n if (type === 'Array') {\n return alt ? [longitude, latitude, height] as any : [longitude, latitude] as any;\n }\n else {\n return alt ? { longitude, latitude, height } as any : { longitude, latitude } as any;\n }\n}\n","import type { CommonCoord, CoordArray_ALT } from './types';\nimport { toCoord } from './toCoord';\n\nexport type DMSCoord = [longitude: string, latitude: string, height?: number];\n\n/**\n * Convert degrees to DMS (Degrees Minutes Seconds) format string\n *\n * @param degrees The angle value\n * @param precision The number of decimal places to retain for the seconds, defaults to 3\n * @returns A DMS formatted string in the format: degrees° minutes′ seconds″\n */\nexport function dmsEncode(degrees: number, precision = 3): string {\n const str = `${degrees}`;\n let i = str.indexOf('.');\n const d = i < 0 ? str : str.slice(0, Math.max(0, i));\n let m = '0';\n let s = '0';\n if (i > 0) {\n m = `0${str.slice(Math.max(0, i))}`;\n m = `${+m * 60}`;\n i = m.indexOf('.');\n if (i > 0) {\n s = `0${m.slice(Math.max(0, i))}`;\n m = m.slice(0, Math.max(0, i));\n s = `${+s * 60}`;\n i = s.indexOf('.');\n s = s.slice(0, Math.max(0, i + 4));\n s = (+s).toFixed(precision);\n }\n }\n return `${Math.abs(+d)}°${+m}′${+s}″`;\n}\n\n/**\n * Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value\n *\n * @param dmsCode DMS formatted string, e.g. \"120°30′45″N\"\n * @returns The decoded decimal angle value, or 0 if decoding fails\n */\nexport function dmsDecode(dmsCode: string) {\n const [dd, msStr] = dmsCode.split('°') ?? [];\n const [mm, sStr] = msStr?.split('′') ?? [];\n const ss = sStr?.split('″')[0];\n\n const d = Number(dd) || 0;\n const m = (Number(mm) || 0) / 60;\n const s = (Number(ss) || 0) / 60 / 60;\n const degrees = d + m + s;\n if (degrees === 0) {\n return 0;\n }\n else {\n let res = degrees;\n // South, West are negative numbers\n if (['W', 'w', 'S', 's'].includes(dmsCode[dmsCode.length - 1]!)) {\n res = -res;\n }\n return res;\n }\n}\n\n/**\n * Convert latitude and longitude coordinates to degrees-minutes-seconds format\n *\n * @param position The latitude and longitude coordinates\n * @param precision The number of decimal places to retain for 'seconds', default is 3\n * @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails\n */\nexport function degreesToDms(position: CommonCoord, precision = 3): DMSCoord | undefined {\n const coord = toCoord(position, { alt: true });\n if (!coord) {\n return;\n }\n const [longitude, latitude, height] = coord;\n const x = dmsEncode(longitude, precision);\n const y = dmsEncode(latitude, precision);\n return [`${x}${longitude > 0 ? 'E' : 'W'}`, `${y}${latitude > 0 ? 'N' : 'S'}`, height];\n}\n\n/**\n * Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates\n *\n * @param dms The latitude or longitude coordinate in DMS format\n * @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails\n */\nexport function dmsToDegrees(dms: DMSCoord): CoordArray_ALT | undefined {\n const [x, y, height] = dms;\n const longitude = dmsDecode(x);\n const latitude = dmsDecode(y);\n return [longitude, latitude, (Number(height)) || 0];\n}\n","import type { MaybeProperty } from './property';\nimport { defined } from 'cesium';\n\n/**\n * Determines if the Cesium property is a constant.\n *\n * @param value Cesium property\n */\nexport function isCesiumConstant(value: MaybeProperty): boolean {\n return !defined(value) || !!value.isConstant;\n}\n","import type { Event, JulianDate, MaterialProperty, TextureMagnificationFilter, TextureMinificationFilter } from 'cesium';\n\nimport { Material } from 'cesium';\n\n/**\n * Cesium.Material.fabric parameters\n */\nexport interface CesiumMaterialFabricOptions<U> {\n /**\n * Used to declare what material the fabric object will ultimately generate. If it's an official built-in one, use the official built-in one directly; otherwise, create a custom material and cache it.\n */\n type: string;\n /**\n * Can nest another level of child fabric to form a composite material\n */\n materials?: Material;\n /**\n * glsl code\n */\n source?: string;\n components?: {\n diffuse?: string;\n alpha?: string;\n };\n /**\n * Pass variables to glsl code\n */\n uniforms?: U & Record<string, any>;\n}\n\n/**\n * Cesium.Material parameters\n */\nexport interface CesiumMaterialConstructorOptions<U> {\n /**\n * Strict mode\n */\n strict?: boolean;\n /**\n * translucent\n */\n translucent?: boolean | ((...params: any[]) => any);\n /**\n * Minification filter\n */\n minificationFilter?: TextureMinificationFilter;\n /**\n * Magnification filter\n */\n magnificationFilter?: TextureMagnificationFilter;\n /**\n * Matrix configuration\n */\n fabric: CesiumMaterialFabricOptions<U>;\n}\n\n/**\n * Only as a type fix for `Cesium.Material`\n */\nexport class CesiumMaterial<U> extends Material {\n constructor(options: CesiumMaterialConstructorOptions<U>) {\n super(options);\n }\n\n /**\n * Matrix configuration\n */\n declare fabric: CesiumMaterialFabricOptions<U>;\n}\n\n/**\n * Only as a type fix for `Cesium.MaterialProperty`\n */\nexport interface CesiumMaterialProperty<V> extends MaterialProperty {\n get isConstant(): boolean;\n\n get definitionChanged(): Event<(scope: this, field: string, value: any, previous: any) => void>;\n\n getType: (time: JulianDate) => string;\n\n getValue: (time: JulianDate, result?: V) => V;\n\n equals: (other?: any) => boolean;\n}\n\n/**\n * Get material from cache, alias of `Material._materialCache.getMaterial`\n */\nexport function getMaterialCache<T extends Material = CesiumMaterial<any>>(type: string): T | undefined {\n return (Material as any)._materialCache.getMaterial(type);\n}\n\n/**\n * Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`\n */\nexport function addMaterialCache(type: string, material: CesiumMaterialConstructorOptions<any>): void {\n return (Material as any)._materialCache.addMaterial(type, material);\n}\n","/**\n * Analyze the result of Cesium's `scene.pick` and convert it to an array format\n */\nexport function resolvePick(pick: any = {}): any[] {\n const { primitive, id, primitiveCollection, collection } = pick;\n const entityCollection = (id && id.entityCollection) || null;\n const dataSource = (entityCollection && entityCollection.owner) || null;\n const ids = Array.isArray(id) ? id : [id].filter(Boolean); // When aggregating entities, ensure id is an array and filter out falsy values\n return [\n ...ids,\n primitive,\n primitiveCollection,\n collection,\n entityCollection,\n dataSource,\n ].filter(e => !!e);\n}\n\n/**\n * Determine if the given array of graphics is hit by Cesium's `scene.pick`\n *\n * @param pick The `scene.pick` object used for matching\n * @param graphic An array of graphics to check for hits\n */\nexport function pickHitGraphic(pick: any, graphic: any | any[]): boolean {\n if (!Array.isArray(graphic) || !graphic.length) {\n return false;\n }\n const elements = resolvePick(pick);\n if (!elements.length) {\n return false;\n }\n return elements.some(element => graphic.includes(element));\n}\n","import type { Event, JulianDate, Property } from 'cesium';\nimport { CallbackProperty, ConstantProperty, defined } from 'cesium';\nimport { isFunction } from './is';\n\nexport type MaybeProperty<T = any> = T | { getValue: (time?: JulianDate) => T };\n\nexport type MaybePropertyOrGetter<T = any> = MaybeProperty<T> | (() => T);\n\n/**\n * Is Cesium.Property\n * @param value - The target object\n */\nexport function isProperty(value: any): value is Property {\n return value && isFunction(value.getValue);\n}\n\n/**\n * Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation\n * ```typescript\n * toPropertyValue('val') //=> 'val'\n * toPropertyValue(new ConstantProperty('val')) //=> 'val'\n * toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'\n * ```\n *\n * @param value - The value to convert\n */\nexport function toPropertyValue<T = unknown>(value: MaybeProperty<T>, time?: JulianDate): T {\n return isProperty(value) ? value.getValue(time as any) : value as any;\n}\n\nexport type PropertyCallback<T = any> = (time: JulianDate, result?: T) => T;\n\n/**\n * Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation\n *\n * @param value - The property value or getter to convert, can be undefined or null\n * @param isConstant - The second parameter for converting to CallbackProperty\n * @returns Returns the converted Property object, if value is undefined or null, returns undefined\n */\nexport function toProperty<T>(value?: MaybePropertyOrGetter<T>, isConstant = false): Property {\n return isProperty(value)\n ? value\n : isFunction(value)\n ? (new CallbackProperty(value, isConstant) as any)\n : new ConstantProperty(value);\n}\n\n/**\n * Create a Cesium property key\n *\n * @param scope The host object\n * @param field The property name\n * @param maybeProperty Optional property or getter\n * @param readonly Whether the property is read-only\n */\nexport function createPropertyField<T>(\n scope: any,\n field: string,\n maybeProperty?: MaybePropertyOrGetter<T>,\n readonly?: boolean,\n) {\n let removeOwnerListener: VoidFunction | undefined;\n // 自身内部变化时也触发载体的`definitionChanged`\n // Trigger the carrier's `definitionChanged` when its own internal state changes\n const ownerBinding = (value: any) => {\n removeOwnerListener?.();\n if (defined(value?.definitionChanged)) {\n removeOwnerListener = value?.definitionChanged?.addEventListener(() => {\n scope.definitionChanged.raiseEvent(scope, field, value, value);\n });\n }\n };\n\n const privateField = `_${field}`;\n const property = toProperty(maybeProperty);\n scope[privateField] = property;\n ownerBinding(property);\n\n if (readonly) {\n Object.defineProperty(scope, field, {\n get() {\n return scope[privateField];\n },\n });\n }\n else {\n Object.defineProperty(scope, field, {\n get() {\n return scope[privateField];\n },\n set(value) {\n const previous = scope[privateField];\n if (scope[privateField] !== value) {\n scope[privateField] = value;\n ownerBinding(value);\n if (defined(scope.definitionChanged)) {\n scope.definitionChanged.raiseEvent(scope, field, value, previous);\n }\n }\n },\n });\n }\n}\n\nexport interface CreateCesiumAttributeOptions {\n readonly?: boolean;\n toProperty?: boolean;\n /**\n * The event name that triggers the change\n * @default 'definitionChanged'\n */\n changedEventKey?: string;\n\n shallowClone?: boolean;\n}\n\nexport function createCesiumAttribute<Scope extends object>(\n scope: Scope,\n key: keyof Scope,\n value: any,\n options: CreateCesiumAttributeOptions = {},\n) {\n const allowToProperty = !!options.toProperty;\n const shallowClone = !!options.shallowClone;\n const changedEventKey = options.changedEventKey || 'definitionChanged';\n const changedEvent = Reflect.get(scope, changedEventKey) as Event;\n const privateKey = `_${String(key)}`;\n const attribute = allowToProperty ? toProperty(value) : value;\n Reflect.set(scope, privateKey, attribute);\n\n const obj: any = {\n get() {\n const value = Reflect.get(scope, privateKey);\n if (shallowClone) {\n return Array.isArray(value) ? [...value] : { ...value };\n }\n else {\n return value;\n }\n },\n };\n\n let previousListener: VoidFunction | undefined;\n\n const serial = (property: Property, previous?: any) => {\n previousListener?.();\n previousListener = property?.definitionChanged?.addEventListener(() => {\n changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);\n });\n };\n\n if (!options.readonly) {\n // 初始化是父子级绑定监听\n if (allowToProperty && isProperty(value)) {\n serial(value);\n }\n\n obj.set = (value: any) => {\n if (allowToProperty && !isProperty(value)) {\n throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);\n }\n const previous = Reflect.get(scope, privateKey);\n\n if (previous !== value) {\n Reflect.set(scope, privateKey, value);\n changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value, previous);\n if (allowToProperty) {\n // 重新绑定监听\n serial(value);\n }\n }\n };\n }\n\n Object.defineProperty(scope, key, obj);\n}\n\nexport interface CreateCesiumPropertyOptions {\n readonly?: boolean;\n /**\n * The event name that triggers the change\n * @default 'definitionChanged'\n */\n changedEventKey?: string;\n}\nexport function createCesiumProperty<Scope extends object>(\n scope: Scope,\n key: keyof Scope,\n value: any,\n options: CreateCesiumPropertyOptions = {},\n) {\n return createCesiumAttribute(scope, key, value, { ...options, toProperty: true });\n}\n","import { promiseTimeout } from '@vueuse/core';\n\nexport type ThrottleCallback<T extends any[]> = (...rest: T) => void;\n\n/**\n * Throttle function, which limits the frequency of execution of the function\n *\n * @param callback raw function\n * @param delay Throttled delay duration (ms)\n * @param trailing Trigger callback function after last call @default true\n * @param leading Trigger the callback function immediately on the first call @default false\n * @returns Throttle function\n */\nexport function throttle<T extends any[]>(\n callback: ThrottleCallback<T>,\n delay = 100,\n trailing = true,\n leading = false,\n): ThrottleCallback<T> {\n const restList: T[] = [];\n let tracked = false;\n const trigger = async () => {\n await promiseTimeout(delay);\n tracked = false;\n if (leading) {\n try {\n callback(...restList[0]);\n }\n catch (error) {\n console.error(error);\n }\n }\n if (trailing && (!leading || restList.length > 1)) {\n try {\n callback(...restList[restList.length - 1]!);\n }\n catch (error) {\n console.error(error);\n }\n }\n restList.length = 0;\n };\n\n return (...rest: T) => {\n if (restList.length < 2) {\n restList.push(rest);\n }\n else {\n restList[1] = rest;\n }\n\n if (!tracked) {\n tracked = true;\n trigger();\n }\n };\n}\n","import type { CommonCoord } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid } from 'cesium';\n\n/**\n * Converts position to a coordinate point in the Cartesian coordinate system\n *\n * @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\n * @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned\n */\nexport function toCartesian3(position?: CommonCoord): Cartesian3 | undefined {\n if (!position) {\n return undefined;\n }\n if (position instanceof Cartesian3) {\n return position.clone();\n }\n else if (position instanceof Cartographic) {\n return Ellipsoid.WGS84.cartographicToCartesian(position);\n }\n else if (Array.isArray(position)) {\n return Cartesian3.fromDegrees(position[0], position[1], position[2]);\n }\n else {\n return Cartesian3.fromDegrees(position.longitude, position.latitude, (position as any).height);\n }\n}\n","import type { CommonCoord } from './types';\nimport { Cartesian3, Cartographic, Ellipsoid } from 'cesium';\n\n/**\n * Converts a position to a Cartographic coordinate point\n *\n * @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\n * @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid\n */\nexport function toCartographic(position?: CommonCoord): Cartographic | undefined {\n if (!position) {\n return undefined;\n }\n if (position instanceof Cartesian3) {\n return Ellipsoid.WGS84.cartesianToCartographic(position);\n }\n else if (position instanceof Cartographic) {\n return position.clone();\n }\n else if (Array.isArray(position)) {\n return Cartographic.fromDegrees(position[0], position[1], position[2]);\n }\n else {\n return Cartographic.fromDegrees(position.longitude, position.latitude, (position as any).height);\n }\n}\n","import type { AnyFn } from './types';\n\n/**\n * Safely execute the provided function without throwing errors,\n * essentially a simple wrapper around a `try...catch...` block\n */\nexport function tryRun<T extends AnyFn>(fn: T): T {\n return ((...args: any[]) => {\n try {\n return fn?.(...args);\n }\n catch (error) {\n console.error(error);\n }\n }) as T;\n}\n","import type { MaybeRef } from 'vue';\nimport { toRaw, toValue } from 'vue';\nimport { isFunction, isPromise } from '../utils';\n\nexport type OnAsyncGetterCancel = (onCancel: () => void) => void;\n\nexport type MaybeAsyncGetter<T> = () => (Promise<T> | T);\nexport type MaybeRefOrAsyncGetter<T> = MaybeRef<T> | MaybeAsyncGetter<T>;\n\nexport interface ToPromiseValueOptions {\n /**\n * Determines whether the source should be unwrapped to its raw value.\n * @default true\n */\n raw?: boolean;\n}\n\n/**\n * Similar to Vue's built-in `toValue`, but capable of handling asynchronous functions, thus returning a `await value`.\n *\n * Used in conjunction with VueUse's `computedAsync`.\n *\n * @param source The source value, which can be a reactive reference or an asynchronous getter.\n * @param options Conversion options\n *\n * @example\n * ```ts\n *\n * const data = computedAsync(async ()=> {\n * return await toPromiseValue(promiseRef)\n * })\n *\n * ```\n */\nexport async function toPromiseValue<T>(source: MaybeRefOrAsyncGetter<T>, options: ToPromiseValueOptions = {}): Promise<T> {\n try {\n const { raw = true } = options;\n let value: T;\n\n if (isFunction(source)) {\n value = await source();\n }\n else {\n const result = toValue(source);\n value = isPromise(result) ? await result : result;\n }\n return raw ? toRaw(value) : value;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n}\n","import type { Arrayable, FunctionArgs } from '@vueuse/core';\nimport type { Event } from 'cesium';\nimport type { MaybeRefOrGetter, WatchStopHandle } from 'vue';\nimport { tryOnScopeDispose } from '@vueuse/core';\nimport { toRef, toValue, watchEffect } from 'vue';\n\nexport interface UseCesiumEventListenerOptions {\n /**\n * Whether to active the event listener.\n * @default true\n */\n isActive?: MaybeRefOrGetter<boolean>;\n}\n\n/**\n * Easily use the `addEventListener` in `Cesium.Event` instances,\n * when the dependent data changes or the component is unmounted,\n * the listener function will automatically reload or destroy.\n */\nexport function useCesiumEventListener<FN extends FunctionArgs<any[]>>(\n event: Arrayable<Event<FN> | undefined> | Arrayable<MaybeRefOrGetter<Event<FN> | undefined>> | MaybeRefOrGetter<Arrayable<Event<FN> | undefined>>,\n listener: FN,\n options: UseCesiumEventListenerOptions = {},\n): WatchStopHandle {\n const isActive = toRef(options.isActive ?? true);\n\n const cleanup = watchEffect((onCleanup) => {\n const _event = toValue(event);\n const events = Array.isArray(_event) ? _event : [_event];\n if (events) {\n if (events.length && isActive.value) {\n const stopFns = events.map((event) => {\n const e = toValue(event);\n return e?.addEventListener(listener, e);\n });\n onCleanup(() => stopFns.forEach(stop => stop?.()));\n }\n }\n });\n\n tryOnScopeDispose(cleanup.stop);\n return cleanup.stop;\n}\n","import type { Viewer } from 'cesium';\nimport type { ShallowRef } from 'vue';\nimport { getCurrentScope, inject } from 'vue';\nimport { CREATE_VIEWER_COLLECTION, CREATE_VIEWER_INJECTION_KEY } from '../createViewer';\n\n/**\n * Obtain the `Viewer` instance injected through `createViewer` in the current component or its ancestor components.\n *\n * note:\n * - If `createViewer` and `useViewer` are called in the same component, the `Viewer` instance injected by `createViewer` will be used preferentially.\n * - When calling `createViewer` and `useViewer` in the same component, `createViewer` should be called before `useViewer`.\n */\nexport function useViewer(): Readonly<ShallowRef<Viewer | undefined>> {\n const scope = getCurrentScope();\n const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : undefined;\n if (instanceViewer) {\n return instanceViewer;\n }\n else {\n const injectViewer = inject(CREATE_VIEWER_INJECTION_KEY);\n if (!injectViewer) {\n throw new Error(\n 'The `Viewer` instance injected by `createViewer` '\n + 'was not found in the current component or its '\n + 'ancestor components. Have you called `createViewer`?',\n );\n }\n return injectViewer;\n }\n}\n","import type { Camera, Cartesian3, Cartographic, Rectangle } from 'cesium';\nimport type { ComputedRef, MaybeRefOrGetter } from 'vue';\nimport { refThrottled } from '@vueuse/core';\nimport { computed, shallowRef, toValue, watch } from 'vue';\nimport { useCesiumEventListener } from '../useCesiumEventListener';\nimport { useViewer } from '../useViewer';\n\nexport interface UseCameraStateOptions {\n /**\n * The camera to use\n * @default useViewer().value.scene.camera\n */\n camera?: MaybeRefOrGetter<Camera | undefined>;\n\n /**\n * Camera event type to watch\n * @default `changed`\n */\n event?: MaybeRefOrGetter<'changed' | 'moveStart' | 'moveEnd'>;\n\n /**\n * Throttled delay duration (ms)\n * @default 8\n */\n delay?: number;\n}\n\nexport interface UseCameraStateRetrun {\n camera: ComputedRef<Camera | undefined>;\n\n /**\n * The position of the camera.\n */\n position: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * The view direction of the camera.\n */\n direction: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * The up direction of the camera.\n */\n up: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * The right direction of the camera.\n */\n right: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * Gets the {@link Cartographic} position of the camera, with longitude and latitude\n * expressed in radians and height in meters. In 2D and Columbus View, it is possible\n * for the returned longitude and latitude to be outside the range of valid longitudes\n * and latitudes when the camera is outside the map.\n */\n positionCartographic: ComputedRef<Cartographic | undefined>;\n\n /**\n * Gets the position of the camera in world coordinates.\n */\n positionWC: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * Gets the view direction of the camera in world coordinates.\n */\n directionWC: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * Gets the up direction of the camera in world coordinates.\n */\n upWC: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * Gets the right direction of the camera in world coordinates.\n */\n rightWC: ComputedRef<Cartesian3 | undefined>;\n\n /**\n * Computes the approximate visible rectangle on the ellipsoid.\n */\n viewRectangle: ComputedRef<Rectangle | undefined>;\n\n /**\n * Gets the camera heading in radians.\n */\n heading: ComputedRef<number | undefined>;\n\n /**\n * Gets the camera pitch in radians.\n */\n pitch: ComputedRef<number | undefined>;\n\n /**\n * Gets the camera roll in radians.\n */\n roll: ComputedRef<number | undefined>;\n\n /**\n * Gets the camera center hierarchy level\n */\n level: ComputedRef<number | undefined>;\n\n}\n\n/**\n * Reactive Cesium Camera state\n */\nexport function useCameraState(options: UseCameraStateOptions = {}): UseCameraStateRetrun {\n let getCamera = options.camera;\n if (!getCamera) {\n const viewer = useViewer();\n getCamera = () => viewer.value?.scene.camera;\n }\n\n const camera = computed(() => toValue(getCamera));\n\n const event = computed(() => {\n const eventField = toValue(options.event) || 'changed';\n return camera.value?.[eventField];\n });\n\n const changedSymbol = refThrottled(\n shallowRef(Symbol('camera change')),\n options.delay ?? 8,\n true,\n false,\n );\n\n const setChangedSymbol = () => {\n changedSymbol.value = Symbol('camera change');\n };\n\n watch(camera, () => setChangedSymbol());\n useCesiumEventListener(event, () => setChangedSymbol());\n\n return {\n camera,\n position: computed(() => changedSymbol.value ? camera.value?.position?.clone() : undefined),\n direction: computed(() => changedSymbol.value ? camera.value?.direction?.clone() : undefined),\n up: computed(() => changedSymbol.value ? camera.value?.up?.clone() : undefined),\n right: computed(() => changedSymbol.value ? camera.value?.right?.clone() : undefined),\n positionCartographic: computed(() => changedSymbol.value ? camera.value?.positionCartographic?.clone() : undefined),\n positionWC: computed(() => changedSymbol.value ? camera.value?.positionWC?.clone() : undefined),\n directionWC: computed(() => changedSymbol.value ? camera.value?.directionWC?.clone() : undefined),\n upWC: computed(() => changedSymbol.value ? camera.value?.directionWC?.clone() : undefined),\n rightWC: computed(() => changedSymbol.value ? camera.value?.directionWC?.clone() : undefined),\n viewRectangle: computed(() => changedSymbol.value ? camera.value?.computeViewRectangle() : undefined),\n heading: computed(() => changedSymbol.value ? camera.value?.heading : undefined),\n pitch: computed(() => changedSymbol.value ? camera.value?.pitch : undefined),\n roll: computed(() => changedSymbol.value ? camera.value?.roll : undefined),\n level: computed(() =>\n (changedSymbol.value && camera.value?.positionCartographic?.height)\n ? computeLevel(camera.value.positionCartographic.height)\n : undefined),\n };\n}\n\nconst A = 40487.57;\nconst B = 0.00007096758;\nconst C = 91610.74;\nconst D = -40467.74;\n\n/**\n * Compute the camera level at a given height.\n */\nfunction computeLevel(height: number): number {\n return D + (A - D) / (1 + (height! / C) ** B);\n}\n","import type { Ref } from 'vue';\nimport { watchThrottled } from '@vueuse/core';\nimport { computed, readonly, ref, shallowRef } from 'vue';\nimport { useCesiumEventListener } from '../useCesiumEventListener';\nimport { useViewer } from '../useViewer';\n\nexport interface UseCesiumFpsOptions {\n /**\n * Throttled sampling (ms)\n * @default 100\n */\n delay?: number;\n}\n\nexport interface UseCesiumFpsRetrun {\n /**\n * Inter-frame Interval (ms)\n */\n interval: Readonly<Ref<number>>;\n\n /**\n * Frames Per Second\n */\n fps: Readonly<Ref<number>>;\n}\n\n/**\n * Reactive get the frame rate of Cesium\n */\nexport function useCesiumFps(options: UseCesiumFpsOptions = {}): UseCesiumFpsRetrun {\n const { delay = 100 } = options;\n\n const viewer = useViewer();\n const p = shallowRef(performance.now());\n\n useCesiumEventListener(\n () => viewer.value?.scene.postRender,\n () => p.value = performance.now(),\n );\n\n const interval = ref(0);\n\n watchThrottled(p, (value, oldValue) => {\n interval.value = value - oldValue;\n }, {\n throttle: delay,\n });\n\n const fps = computed(() => {\n return 1000 / interval.value;\n });\n\n return {\n interval: readonly(interval),\n fps,\n };\n}\n","import type { ShallowReactive } from 'vue';\nimport { tryOnScopeDispose } from '@vueuse/core';\nimport { shallowReactive, shallowReadonly } from 'vue';\nimport { isPromise } from '../utils';\n\nexport type EffcetRemovePredicate<T> = (instance: T) => boolean;\n\nexport interface UseCollectionScopeReturn<\n isPromise extends boolean,\n T,\n AddArgs extends any[],\n RemoveArgs extends any[],\n RemoveReturn = any,\n> {\n /**\n * A `Set` for storing SideEffect instance,\n * which is encapsulated using `ShallowReactive` to provide Vue's reactive functionality\n */\n scope: Readonly<ShallowReactive<Set<T>>>;\n\n /**\n * Add SideEffect instance\n */\n add: (i: T, ...args: AddArgs) => isPromise extends true ? Promise<T> : T;\n\n /**\n * Remove specified SideEffect instance\n */\n remove: (i: T, ...args: RemoveArgs) => RemoveReturn;\n\n /**\n * Remove all SideEffect instance that meets the specified criteria\n */\n removeWhere: (predicate: EffcetRemovePredicate<T>, ...args: RemoveArgs) => void;\n\n /**\n * Remove all SideEffect instance within current scope\n */\n removeScope: (...args: RemoveArgs) => void;\n}\n\n/**\n * Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.\n * - note: This is a basic function that is intended to be called by other lower-level function\n * @param addFn - add SideEffect function. eg.`entites.add`\n * @param removeFn - Clean SideEffect function. eg.`entities.remove`\n * @param removeScopeArgs - The parameters to pass for `removeScope` triggered when the component is unmounted\n */\nexport function useCollectionScope<\n isPromise extends boolean,\n T = any,\n AddArgs extends any[] = any[],\n RemoveArgs extends any[] = any[],\n RemoveReturn = any,\n>(\n addFn: (i: T, ...args: AddArgs) => isPromise extends true ? Promise<T> : T,\n removeFn: (i: T, ...args: RemoveArgs) => RemoveReturn,\n removeScopeArgs: RemoveArgs,\n): UseCollectionScopeReturn<isPromise, T, AddArgs, RemoveArgs, RemoveReturn> {\n const scope = shallowReactive(new Set<T>());\n\n const add: any = (instance: T, ...args: AddArgs) => {\n const result = addFn(instance, ...args);\n // 可能为promise 如dataSource\n if (isPromise(result)) {\n return new Promise<T>((resolve, reject) => {\n result.then((i) => {\n scope.add(i);\n resolve(i);\n }).catch(error => reject(error));\n });\n }\n else {\n scope.add(result as T);\n return result;\n }\n };\n\n const remove = (instance: T, ...args: RemoveArgs) => {\n scope.delete(instance);\n return removeFn(instance, ...args);\n };\n\n const removeWhere = (predicate: EffcetRemovePredicate<T>, ...args: RemoveArgs) => {\n scope.forEach((instance) => {\n if (predicate(instance)) {\n remove(instance, ...args);\n }\n });\n };\n\n const removeScope = (...args: RemoveArgs) => {\n scope.forEach((instance) => {\n remove(instance, ...args);\n });\n };\n\n tryOnScopeDispose(() => removeScope(...removeScopeArgs));\n\n return {\n scope: shallowReadonly(scope),\n add,\n remove,\n removeWhere,\n removeScope,\n };\n}\n","import type { Arrayable } from '@vueuse/core';\nimport type { DataSourceCollection } from 'cesium';\nimport type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';\nimport type { MaybeRefOrAsyncGetter } from '../toPromiseValue';\nimport type { CesiumDataSource } from '../utils';\nimport { computedAsync } from '@vueuse/core';\nimport { toValue, watchEffect } from 'vue';\nimport { toPromiseValue } from '../toPromiseValue';\nimport { useViewer } from '../useViewer';\n\nexport interface UseDataSourceOptions {\n /**\n * The collection of DataSource to be added\n * @default useViewer().value.dataSources\n */\n collection?: DataSourceCollection;\n\n /**\n * default value of `isActive`\n * @default true\n */\n isActive?: MaybeRefOrGetter<boolean>;\n\n /**\n * Ref passed to receive the updated of async evaluation\n */\n evaluating?: Ref<boolean>;\n\n /**\n * The second parameter passed to the `remove` function\n *\n * `dataSources.remove(dataSource,destroyOnRemove)`\n */\n destroyOnRemove?: MaybeRefOrGetter<boolean>;\n\n}\n\n/**\n * Add `DataSource` to the `DataSourceCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `DataSource`.\n *\n * overLoaded1: Parameter supports passing in a single value.\n */\nexport function useDataSource<T extends CesiumDataSource = CesiumDataSource>(\n dataSource?: MaybeRefOrAsyncGetter<T | undefined>,\n options?: UseDataSourceOptions\n): ComputedRef<T | undefined>;\n\n/**\n * Add `DataSource` to the `DataSourceCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `DataSource`.\n *\n * overLoaded2: Parameter supports passing in an array.\n */\nexport function useDataSource<T extends CesiumDataSource = CesiumDataSource>(\n dataSources?: MaybeRefOrAsyncGetter<T[] | undefined>,\n options?: UseDataSourceOptions\n): ComputedRef<T[] | undefined>;\n\nexport function useDataSource<T extends CesiumDataSource>(\n dataSources?: MaybeRefOrAsyncGetter<Arrayable<T | undefined>>,\n options: UseDataSourceOptions = {},\n) {\n const {\n destroyOnRemove,\n collection,\n isActive = true,\n evaluating,\n } = options;\n\n const result = computedAsync(\n () => toPromiseValue(dataSources),\n undefined,\n {\n evaluating,\n },\n );\n\n const viewer = useViewer();\n\n watchEffect((onCleanup) => {\n const _isActive = toValue(isActive);\n if (_isActive) {\n const list = Array.isArray(result.value) ? [...result.value] : [result.value];\n const _collection = collection ?? viewer.value?.dataSources;\n list.f