vesium
Version:
Core Vue composition hooks for Cesium
849 lines (848 loc) • 32.3 kB
text/typescript
import { Arrayable, FunctionArgs, MaybeComputedElementRef } from "@vueuse/core";
import { Camera, Cartesian2, Cartesian3, Cartographic, DataSourceCollection, Entity, EntityCollection, Event, GroundPrimitive, ImageryLayer, ImageryLayerCollection, KeyboardEventModifier, PostProcessStage, PostProcessStageCollection, PostProcessStageComposite, Primitive, PrimitiveCollection, Rectangle, ScreenSpaceEventHandler, ScreenSpaceEventType, Viewer } from "cesium";
import * as _$vue from "vue";
import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, ShallowReactive, ShallowRef, WatchStopHandle } from "vue";
import { CesiumDataSource, CommonCoord, Nullable, ScenePickResult } from "@vesium/shared";
export * from "@vesium/shared";
//#region createViewer/index.d.ts
/**
* Pass in an existing Viewer instance,
* which can be accessed by the current component and its descendant components using {@link useViewer}
*
* When the Viewer instance referenced by this overloaded function becomes invalid, it will not trigger destruction.
* @param viewer - Existing viewer instance
* @returns The Viewer instance
*/
declare function createViewer(viewer: MaybeRef<Viewer | undefined>): Readonly<ShallowRef<Viewer | undefined>>;
/**
* Initialize a Viewer instance, which can be accessed by the
* current component and its descendant components using {@link useViewer}.
*
* The Viewer instance created by this overloaded function will automatically be destroyed when it becomes invalid.
*
* @param element - The DOM element or ID that will contain the widget
* @param options - see `Viewer.ConstructorOptions`
* @returns The Viewer instance
*/
declare function createViewer(element: MaybeComputedElementRef, options?: Viewer.ConstructorOptions): Readonly<ShallowRef<Viewer | undefined>>;
//#endregion
//#region toPromiseValue/index.d.ts
type OnAsyncGetterCancel = (onCancel: () => void) => void;
type MaybeAsyncGetter<T> = () => (Promise<T> | T);
type MaybeRefOrAsyncGetter<T> = MaybeRef<T> | MaybeAsyncGetter<T>;
interface ToPromiseValueOptions {
/**
* Determines whether the source should be unwrapped to its raw value.
* @default true
*/
raw?: boolean;
}
/**
* Similar to Vue's built-in `toValue`, but capable of handling asynchronous functions, thus returning a `await value`.
*
* Used in conjunction with VueUse's `computedAsync`.
*
* @param source The source value, which can be a reactive reference or an asynchronous getter.
* @param options Conversion options
* @returns The converted value.
*
* @example
* ```ts
*
* const data = computedAsync(async ()=> {
* return await toPromiseValue(promiseRef)
* })
*
* ```
*/
declare function toPromiseValue<T>(source: MaybeRefOrAsyncGetter<T>, options?: ToPromiseValueOptions): Promise<T>;
//#endregion
//#region useCameraState/index.d.ts
interface UseCameraStateOptions {
/**
* The camera to use
* @default useViewer().value.scene.camera
*/
camera?: MaybeRefOrGetter<Camera | undefined>;
/**
* Camera event type to watch
* @default `changed`
*/
event?: MaybeRefOrGetter<'changed' | 'moveStart' | 'moveEnd'>;
/**
* Throttled delay duration (ms)
* @default 8
*/
delay?: number;
}
interface UseCameraStateReturn {
/**
* The camera
*/
camera: ComputedRef<Camera | undefined>;
/**
* The position of the camera
*/
position: ComputedRef<Cartesian3 | undefined>;
/**
* The view direction of the camera
*/
direction: ComputedRef<Cartesian3 | undefined>;
/**
* The up direction of the camera
*/
up: ComputedRef<Cartesian3 | undefined>;
/**
* The right direction of the camera
*/
right: ComputedRef<Cartesian3 | undefined>;
/**
* Gets the {@link Cartographic} position of the camera, with longitude and latitude
* expressed in radians and height in meters. In 2D and Columbus View, it is possible
* for the returned longitude and latitude to be outside the range of valid longitudes
* and latitudes when the camera is outside the map.
*/
positionCartographic: ComputedRef<Cartographic | undefined>;
/**
* Gets the position of the camera in world coordinates
*/
positionWC: ComputedRef<Cartesian3 | undefined>;
/**
* Gets the view direction of the camera in world coordinates
*/
directionWC: ComputedRef<Cartesian3 | undefined>;
/**
* Gets the up direction of the camera in world coordinates
*/
upWC: ComputedRef<Cartesian3 | undefined>;
/**
* Gets the right direction of the camera in world coordinates
*/
rightWC: ComputedRef<Cartesian3 | undefined>;
/**
* Computes the approximate visible rectangle on the ellipsoid
*/
viewRectangle: ComputedRef<Rectangle | undefined>;
/**
* Gets the camera heading in radians
*/
heading: ComputedRef<number | undefined>;
/**
* Gets the camera pitch in radians
*/
pitch: ComputedRef<number | undefined>;
/**
* Gets the camera roll in radians
*/
roll: ComputedRef<number | undefined>;
/**
* Gets the camera center hierarchy level
*/
level: ComputedRef<number | undefined>;
}
/**
* Reactive Cesium Camera state
* @param options options
* @returns Reactive camera states
*/
declare function useCameraState(options?: UseCameraStateOptions): UseCameraStateReturn;
//#endregion
//#region useCesiumEventListener/index.d.ts
interface UseCesiumEventListenerOptions {
/**
* Whether to active the event listener.
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
}
/**
* Easily use the `addEventListener` in `Cesium.Event` instances,
* when the dependent data changes or the component is unmounted,
* the listener function will automatically reload or destroy.
*
* @param event The Cesium.Event instance
* @param listener The listener function
* @param options additional options
* @returns A function that can be called to remove the event listener
*/
declare function useCesiumEventListener<FN extends FunctionArgs<any[]>>(event: Arrayable<Event<FN> | undefined> | Arrayable<MaybeRefOrGetter<Event<FN> | undefined>> | MaybeRefOrGetter<Arrayable<Event<FN> | undefined>>, listener: FN, options?: UseCesiumEventListenerOptions): WatchStopHandle;
//#endregion
//#region useCesiumFps/index.d.ts
interface UseCesiumFpsOptions {
/**
* Throttled sampling (ms)
* @default 100
*/
delay?: number;
}
interface UseCesiumFpsReturn {
/**
* Inter-frame Interval (ms)
*/
interval: Readonly<Ref<number>>;
/**
* Frames Per Second
*/
fps: Readonly<Ref<number>>;
}
/**
* Reactive get the frame rate of Cesium
* @param options options
* @returns Reactive fps states
*/
declare function useCesiumFps(options?: UseCesiumFpsOptions): UseCesiumFpsReturn;
//#endregion
//#region useCollectionScope/index.d.ts
type EffcetRemovePredicate<T> = (instance: T) => boolean;
interface UseCollectionScopeOptions<T, AddArgs extends any[] = any[], RemoveArgs extends any[] = [], RemoveReturn = any> {
/**
* add SideEffect function. e.g. `entities.add`
*/
addEffect: (instance: T | Promise<T>, ...args: AddArgs) => T | Promise<T>;
/**
* Clean SideEffect function. eg.`entities.remove`
*/
removeEffect: (instance: T, ...args: RemoveArgs) => RemoveReturn;
/**
* The parameters to pass for `removeScope` triggered when the component is unmounted
*/
removeScopeArgs?: RemoveArgs;
}
interface UseCollectionScopeReturn<T, AddArgs extends any[], RemoveArgs extends any[], RemoveReturn = any> {
/**
* A `Set` for storing SideEffect instance,
* which is encapsulated using `ShallowReactive` to provide Vue's reactive functionality
*/
scope: Readonly<ShallowReactive<Set<T>>>;
/**
* Add SideEffect instance
*/
add: <R extends T | Promise<T>>(instance: R, ...args: AddArgs) => R extends Promise<infer U> ? Promise<U> : T;
/**
* Remove specified SideEffect instance
*/
remove: (instance: T, ...args: RemoveArgs) => RemoveReturn;
/**
* Remove all SideEffect instance that meets the specified criteria
*/
removeWhere: (predicate: EffcetRemovePredicate<T>, ...args: RemoveArgs) => void;
/**
* Remove all SideEffect instance within current scope
*/
removeScope: (...args: RemoveArgs) => void;
}
/**
* Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.
* - note: This is a basic function that is intended to be called by other lower-level function
* @returns Contains side effect addition and removal functions
*/
declare function useCollectionScope<T, AddArgs extends any[] = any[], RemoveArgs extends any[] = [], RemoveReturn = any>(options: UseCollectionScopeOptions<T, AddArgs, RemoveArgs, RemoveReturn>): UseCollectionScopeReturn<T, AddArgs, RemoveArgs, RemoveReturn>;
//#endregion
//#region useDataSource/index.d.ts
interface UseDataSourceOptions {
/**
* The collection of DataSource to be added
* @default useViewer().value.dataSources
*/
collection?: DataSourceCollection;
/**
* default value of `isActive`
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
/**
* Ref passed to receive the updated of async evaluation
*/
evaluating?: Ref<boolean>;
/**
* The second parameter passed to the `remove` function
*
* `dataSources.remove(dataSource,destroyOnRemove)`
*/
destroyOnRemove?: MaybeRefOrGetter<boolean>;
}
/**
* Add `DataSource` to the `DataSourceCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `DataSource`.
*
* Overload 1: Parameter supports passing in a single value.
*
* @param dataSource The `DataSource` to added
* @param options additional options
*
* @returns computedRef of the `DataSource`
*
* @overload
*/
declare function useDataSource<T extends CesiumDataSource = CesiumDataSource>(dataSource?: MaybeRefOrAsyncGetter<T | undefined>, options?: UseDataSourceOptions): ComputedRef<T | undefined>;
/**
* Add `DataSource` to the `DataSourceCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `DataSource`.
*
* Overload 2: Parameter supports passing in an array.
*
* @param dataSources The list of `DataSource` to added
* @param options additional options
*
* @returns computedRef of the `DataSource`
*
* @overload
*/
declare function useDataSource<T extends CesiumDataSource = CesiumDataSource>(dataSources?: MaybeRefOrAsyncGetter<T[] | undefined>, options?: UseDataSourceOptions): ComputedRef<T[] | undefined>;
//#endregion
//#region useDataSourceScope/index.d.ts
interface UseDataSourceScopeOptions {
/**
* The collection of DataSource to be added
* @default useViewer().value.dataSources
*/
collection?: MaybeRefOrGetter<DataSourceCollection | undefined>;
/**
* The second parameter passed to the `remove` function
*
* `dataSources.remove(dataSource,destroyOnRemove)`
*/
destroyOnRemove?: boolean;
}
/**
* Scope the SideEffects of `DataSourceCollection` operations and automatically remove them when unmounted
*/
declare function useDataSourceScope(options?: UseDataSourceScopeOptions): UseCollectionScopeReturn<CesiumDataSource, [], [destroy?: boolean], boolean>;
//#endregion
//#region useElementOverlay/index.d.ts
interface UseElementOverlayOptions {
/**
* Horizontal origin of the target element
* @default `center`
*/
horizontal?: MaybeRefOrGetter<'center' | 'left' | 'right' | undefined>;
/**
* Vertical origin of the target element
* @default `bottom`
*/
vertical?: MaybeRefOrGetter<'center' | 'bottom' | 'top' | undefined>;
/**
* Pixel offset presented by the target element
* @default {x:0,y:0}
*/
offset?: MaybeRefOrGetter<{
x?: number;
y?: number;
} | undefined>;
/**
* The reference element for calculating the position of the target element
* - `true` refer to the browser viewport
* - `false` refer to the Cesium canvas
*/
referenceWindow?: MaybeRefOrGetter<boolean>;
/**
* Whether to apply style to the target element
* @default true
*/
applyStyle?: MaybeRefOrGetter<boolean>;
/**
* The position will be clamped to the ground
*
*/
clampToGround?: MaybeRefOrGetter<boolean>;
}
interface UseElementOverlayReturn {
/**
* Calculation result of the target element's horizontal direction
*/
x: ComputedRef<number>;
/**
* Calculation result of the target element's vertical direction
*/
y: ComputedRef<number>;
/**
* Calculation `css` of the target element
*/
style: ComputedRef<string | undefined>;
}
/**
* Cesium HTMLElement Overlay
*/
declare function useElementOverlay(target?: MaybeComputedElementRef, position?: MaybeRefOrGetter<CommonCoord | undefined>, options?: UseElementOverlayOptions): UseElementOverlayReturn;
//#endregion
//#region useEntity/index.d.ts
interface UseEntityOptions {
/**
* The collection of Entity to be added
* @default useViewer().value.entities
*/
collection?: EntityCollection;
/**
* default value of `isActive`
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
/**
* Ref passed to receive the updated of async evaluation
*/
evaluating?: Ref<boolean>;
}
/**
* Add `Entity` to the `EntityCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `Entity`.
*
* Overload 1: Parameter supports passing in a single value.
*/
declare function useEntity<T extends Entity = Entity>(entity?: MaybeRefOrAsyncGetter<T | undefined>, options?: UseEntityOptions): ComputedRef<T | undefined>;
/**
* Add `Entity` to the `EntityCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `Entity`.
*
* Overload 2: Parameter supports passing in an array.
*/
declare function useEntity<T extends Entity = Entity>(entities?: MaybeRefOrAsyncGetter<Array<T | undefined> | undefined>, options?: UseEntityOptions): ComputedRef<T[] | undefined>;
//#endregion
//#region useEntityScope/index.d.ts
interface UseEntityScopeOptions {
/**
* The collection of Entity to be added
* @default useViewer().value.entities
*/
collection?: MaybeRefOrGetter<EntityCollection | undefined>;
}
/**
* Make `add` and `remove` operations of `EntityCollection` scoped,
* automatically remove `Entity` instance when component is unmounted.
*/
declare function useEntityScope(options?: UseEntityScopeOptions): UseCollectionScopeReturn<Entity, any[], [], any>;
//#endregion
//#region useGraphicEvent/useDrag.d.ts
/**
* Parameters for graphic drag events
*/
interface GraphicDragEvent {
/**
* Event of the motion event
*/
event: ScreenSpaceEventHandler.MotionEvent;
/**
* The graphic object picked by `scene.pick`
*/
pick: ScenePickResult;
/**
* Whether the graphic is currently being dragged.
*/
dragging: boolean;
/**
* Whether to lock the camera, Will automatically resume when you end dragging.
*/
lockCamera: () => void;
}
//#endregion
//#region useGraphicEvent/useHover.d.ts
/**
* Parameters for graphic hover events
*/
interface GraphicHoverEvent {
/**
* Event of the motion event
*/
event: ScreenSpaceEventHandler.MotionEvent;
/**
* The graphic object picked by `scene.pick`
*/
pick: ScenePickResult;
/**
* Whether the graphic is currently being hoverged. Returns `true` continuously while hoverging, and `false` once it ends.
*/
hovering: boolean;
}
//#endregion
//#region useGraphicEvent/usePositioned.d.ts
type PositionedEventType = 'LEFT_DOWN' | 'LEFT_UP' | 'LEFT_CLICK' | 'LEFT_DOUBLE_CLICK' | 'RIGHT_DOWN' | 'RIGHT_UP' | 'RIGHT_CLICK' | 'MIDDLE_DOWN' | 'MIDDLE_UP' | 'MIDDLE_CLICK';
/**
* Parameters for graphics click related events
*/
interface GraphicPositionedEvent {
/**
* Event of the picked area
*/
event: ScreenSpaceEventHandler.PositionedEvent;
/**
* The graphic object picked by `scene.pick`
*/
pick: ScenePickResult;
}
//#endregion
//#region useGraphicEvent/index.d.ts
type CesiumGraphic = Entity | any;
type GraphicEventType = PositionedEventType | 'HOVER' | 'DRAG';
type GraphicEventListener<T extends GraphicEventType> = T extends 'DRAG' ? (event: GraphicDragEvent) => void : T extends 'HOVER' ? (event: GraphicHoverEvent) => void : (event: GraphicPositionedEvent) => void;
type removeFn = () => void;
interface AddGraphicEventOptions {
/**
* The cursor style to use when the mouse is over the graphic.
* @default 'pointer'
*/
cursor?: Nullable<string> | ((event: GraphicHoverEvent) => Nullable<string>);
/**
* The cursor style to use when the mouse is over the graphic during a drag operation.
* @default 'crosshair'
*/
dragCursor?: Nullable<string> | ((event: GraphicHoverEvent) => Nullable<string>);
}
interface UseGraphicEventReturn {
/**
* Add a graphic event listener and return a function to remove it.
* @param graphic - The graphic object, 'global' indicates the global graphic object.
* @param type - The event type, 'all' indicates clearing all events.
* @param listener - The event listener function.
*/
add: <T extends GraphicEventType>(graphic: CesiumGraphic | 'global', type: T, listener: GraphicEventListener<T>, options?: AddGraphicEventOptions) => removeFn;
/**
* Remove a graphic event listener.
* @param graphic - The graphic object, 'global' indicates the global graphic object.
* @param type - The event type, 'all' indicates clearing all events.
* @param listener - The event listener function.
*/
remove: <T extends GraphicEventType>(graphic: CesiumGraphic | 'global', type: T, listener: GraphicEventListener<T>) => void;
/**
* Clear graphic event listeners.
* @param graphic - The graphic object.
* @param type - The event type, 'all' indicates clearing all events.
*/
clear: (graphic: CesiumGraphic | 'global', type: GraphicEventType | 'all') => void;
}
/**
* Handle graphic event listeners and cursor styles for Cesium graphics.
* You don't need to overly worry about memory leaks from the function, as it automatically cleans up internally.
*/
declare function useGraphicEvent(): UseGraphicEventReturn;
//#endregion
//#region useImageryLayer/index.d.ts
interface UseImageryLayerOptions {
/**
* The collection of ImageryLayer to be added
* @default useViewer().value.imageryLayers
*/
collection?: ImageryLayerCollection;
/**
* default value of `isActive`
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
/**
* Ref passed to receive the updated of async evaluation
*/
evaluating?: Ref<boolean>;
/**
* The second parameter passed to the `remove` function
*
* `imageryLayers.remove(layer,destroyOnRemove)`
*/
destroyOnRemove?: MaybeRefOrGetter<boolean | undefined>;
/**
* The second parameter passed to the `add` function
*
* `imageryLayers.add(layer,index)`
*/
index?: MaybeRefOrGetter<number | undefined>;
}
/**
* Add `ImageryLayer` to the `ImageryLayerCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `ImageryLayer`.
*
* Overload 1: Parameter supports passing in a single value.
*/
declare function useImageryLayer<T extends ImageryLayer = ImageryLayer>(layer?: MaybeRefOrAsyncGetter<T | undefined>, options?: UseImageryLayerOptions): ComputedRef<T | undefined>;
/**
* Add `ImageryLayer` to the `ImageryLayerCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `ImageryLayer`.
*
* Overload 2: Parameter supports passing in an array.
*/
declare function useImageryLayer<T extends ImageryLayer = ImageryLayer>(layers?: MaybeRefOrAsyncGetter<Array<T | undefined> | undefined>, options?: UseImageryLayerOptions): ComputedRef<T[] | undefined>;
//#endregion
//#region useImageryLayerScope/index.d.ts
interface UseImageryLayerScopeOptions {
/**
* The collection of ImageryLayer to be added
* @default useViewer().value.imageryLayers
*/
collection?: MaybeRefOrGetter<ImageryLayerCollection | undefined>;
/**
* The second parameter passed to the `remove` function
*
* `imageryLayers.remove(imageryLayer,destroyOnRemove)`
*/
destroyOnRemove?: boolean;
}
/**
* Make `add` and `remove` operations of `ImageryLayerCollection` scoped,
* automatically remove `ImageryLayer` instance when component is unmounted.
*/
declare function useImageryLayerScope(options?: UseImageryLayerScopeOptions): UseCollectionScopeReturn<ImageryLayer, [index?: number], [destroy?: boolean], boolean>;
//#endregion
//#region usePostProcessStage/index.d.ts
interface UsePostProcessStageOptions {
/**
* The collection of PostProcessStage to be added
* @default useViewer().scene.postProcessStages
*/
collection?: PostProcessStageCollection;
/**
* Whether to destroy the stage when removed from the collection.
* When true, the stage's GPU resources will be released.
* @default true
*/
destroyOnRemove?: boolean;
/**
* default value of `isActive`
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
/**
* Ref passed to receive the updated of async evaluation
*/
evaluating?: Ref<boolean>;
}
/**
* Add `PostProcessStage` to the `PostProcessStageCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `PostProcessStage`.
*
* Overload 1: Parameter supports passing in a single value.
*/
declare function usePostProcessStage<T extends PostProcessStage = PostProcessStage>(stage?: MaybeRefOrAsyncGetter<T | undefined>, options?: UsePostProcessStageOptions): ComputedRef<T | undefined>;
/**
* Add `PostProcessStage` to the `PostProcessStageCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `PostProcessStage`.
*
* Overload 2: Parameter supports passing in an array.
*/
declare function usePostProcessStage<T extends PostProcessStage = PostProcessStage>(stages?: MaybeRefOrAsyncGetter<Array<T | undefined> | undefined>, options?: UsePostProcessStageOptions): ComputedRef<T[] | undefined>;
//#endregion
//#region usePostProcessStageScope/index.d.ts
interface UsePostProcessStageScopeOptions {
/**
* The collection of PostProcessStage to be added
* @default useViewer().value.postProcessStages
*/
collection?: MaybeRefOrGetter<PostProcessStageCollection | undefined>;
/**
* Whether to destroy the stage when removed from the collection.
* When true, the stage's GPU resources will be released.
* @default true
*/
destroyOnRemove?: boolean;
}
/**
* Make `add` and `remove` operations of `PostProcessStageCollection` scoped,
* automatically remove `PostProcessStage` instance when component is unmounted.
*/
declare function usePostProcessStageScope(options?: UsePostProcessStageScopeOptions): UseCollectionScopeReturn<PostProcessStage | PostProcessStageComposite, any[], [], any>;
//#endregion
//#region usePrimitive/index.d.ts
interface UsePrimitiveOptions {
/**
* The collection of Primitive to be added
* - `ground` : `useViewer().scene.groundPrimitives`
* @default useViewer().scene.primitives
*/
collection?: PrimitiveCollection | 'ground';
/**
* Whether to destroy the primitive when removed from the collection.
* When true, the primitive's GPU resources will be released.
* @default true
*/
destroyOnRemove?: boolean;
/**
* default value of `isActive`
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
/**
* Ref passed to receive the updated of async evaluation
*/
evaluating?: Ref<boolean>;
}
/**
* Add `Primitive` to the `PrimitiveCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `Primitive`.
*
* Overload 1: Parameter supports passing in a single value.
*/
declare function usePrimitive<T = any>(primitive?: MaybeRefOrAsyncGetter<T | undefined>, options?: UsePrimitiveOptions): ComputedRef<T | undefined>;
/**
* Add `Primitive` to the `PrimitiveCollection`, automatically update when the data changes, and destroy the side effects caused by the previous `Primitive`.
*
* Overload 2: Parameter supports passing in an array.
*/
declare function usePrimitive<T = any>(primitives?: MaybeRefOrAsyncGetter<Array<T | undefined> | undefined>, options?: UsePrimitiveOptions): ComputedRef<T[] | undefined>;
//#endregion
//#region usePrimitiveScope/index.d.ts
interface UsePrimitiveScopeOptions {
/**
* The collection of Primitive to be added,
* 'ground' alias `useViewer().value.scene.groundPrimitives`
* @default useViewer().value.scene.primitives
*/
collection?: MaybeRefOrGetter<PrimitiveCollection | 'ground' | undefined>;
/**
* Whether to destroy the primitive when removed from the collection.
* When true, the primitive's GPU resources will be released.
* @default true
*/
destroyOnRemove?: boolean;
}
/**
* Make `add` and `remove` operations of `PrimitiveCollection` scoped,
* automatically remove `Primitive` instance when component is unmounted.
*/
declare function usePrimitiveScope(options?: UsePrimitiveScopeOptions): {
scope: Readonly<_$vue.ShallowReactive<Set<Primitive | GroundPrimitive>>>;
add: <R extends Primitive | GroundPrimitive | Promise<Primitive | GroundPrimitive>>(instance: R, ...args: any[]) => R extends Promise<infer U> ? Promise<U> : Primitive | GroundPrimitive;
remove: (instance: Primitive | GroundPrimitive) => any;
removeWhere: (predicate: EffcetRemovePredicate<Primitive | GroundPrimitive>) => void;
removeScope: () => void;
};
//#endregion
//#region useScaleBar/index.d.ts
interface UseScaleBarOptions {
/**
* The maximum width of the scale (px)
* @default 80
*/
maxPixel?: MaybeRefOrGetter<number>;
/**
* Throttled delay duration (ms)
* @default 8
*/
delay?: number;
}
interface UseScaleBarReturn {
/**
* The actual distance of a single pixel in the current canvas
*/
pixelDistance: Readonly<Ref<number | undefined>>;
/**
* The width of the scale.(px)
*/
width: Readonly<Ref<number>>;
/**
* The actual distance corresponding to the width of the scale (m)
*/
distance: Readonly<Ref<number | undefined>>;
/**
* Formatted content of distance.
* eg. 100m,100km
*/
distanceText: Readonly<Ref<string | undefined>>;
}
/**
* Reactive generation of scale bars
*/
declare function useScaleBar(options?: UseScaleBarOptions): UseScaleBarReturn;
//#endregion
//#region useSceneDrillPick/index.d.ts
interface UseSceneDrillPickOptions {
/**
* Whether to activate the pick function.
* @default true
*/
isActive?: MaybeRefOrGetter<boolean | undefined>;
/**
* Throttled sampling (ms)
* @default 8
*/
throttled?: number;
/**
* If supplied, stop drilling after collecting this many picks.
*/
limit?: MaybeRefOrGetter<number | undefined>;
/**
* The width of the pick rectangle.
* @default 3
*/
width?: MaybeRefOrGetter<number | undefined>;
/**
* The height of the pick rectangle.
* @default 3
*/
height?: MaybeRefOrGetter<number | undefined>;
}
/**
* Uses the `scene.drillPick` function to perform screen point picking,
* return a computed property containing the pick result, or undefined if no object is picked.
*
* @param windowPosition The screen coordinates of the pick point.
*/
declare function useSceneDrillPick(windowPosition: MaybeRefOrGetter<Cartesian2 | undefined>, options?: UseSceneDrillPickOptions): ComputedRef<any[] | undefined>;
//#endregion
//#region useScenePick/index.d.ts
interface UseScenePickOptions {
/**
* Whether to active the event listener.
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
/**
* Throttled sampling (ms)
* @default 8
*/
throttled?: number;
/**
* The width of the pick rectangle.
* @default 3
*/
width?: MaybeRefOrGetter<number | undefined>;
/**
* The height of the pick rectangle.
* @default 3
*/
height?: MaybeRefOrGetter<number | undefined>;
}
/**
* Uses the `scene.pick` function in Cesium's Scene object to perform screen point picking,
* return a computed property containing the pick result, or undefined if no object is picked.
*
* @param windowPosition The screen coordinates of the pick point.
*/
declare function useScenePick(windowPosition: MaybeRefOrGetter<Cartesian2 | undefined>, options?: UseScenePickOptions): Readonly<ShallowRef<ScenePickResult | undefined>>;
//#endregion
//#region useScreenSpaceEventHandler/index.d.ts
type ScreenSpaceEvent<T extends ScreenSpaceEventType> = {
[ScreenSpaceEventType.LEFT_DOWN]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.LEFT_UP]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.LEFT_CLICK]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.LEFT_DOUBLE_CLICK]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.RIGHT_DOWN]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.RIGHT_UP]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.RIGHT_CLICK]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.MIDDLE_DOWN]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.MIDDLE_UP]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.MIDDLE_CLICK]: ScreenSpaceEventHandler.PositionedEvent;
[ScreenSpaceEventType.MOUSE_MOVE]: ScreenSpaceEventHandler.MotionEvent;
[ScreenSpaceEventType.WHEEL]: number;
[ScreenSpaceEventType.PINCH_START]: ScreenSpaceEventHandler.TwoPointEvent;
[ScreenSpaceEventType.PINCH_END]: ScreenSpaceEventHandler.TwoPointEvent;
[ScreenSpaceEventType.PINCH_MOVE]: ScreenSpaceEventHandler.TwoPointMotionEvent;
}[T];
interface UseScreenSpaceEventHandlerOptions {
/**
* Modifier key forwarded to Cesium.
*/
modifier?: MaybeRefOrGetter<KeyboardEventModifier | undefined>;
/**
* Whether to activate the event listener without tearing down the composable.
* @default true
*/
isActive?: MaybeRefOrGetter<boolean>;
}
/**
* Easily use the `ScreenSpaceEventHandler`,
* when the dependent data changes or the component is unmounted,
* the listener function will automatically reload or destroy.
*
* @param type Types of mouse event
* @param inputAction Callback function for listening
*/
declare function useScreenSpaceEventHandler<T extends ScreenSpaceEventType>(type?: MaybeRefOrGetter<T | undefined>, inputAction?: (event: ScreenSpaceEvent<T>) => any, options?: UseScreenSpaceEventHandlerOptions): WatchStopHandle;
//#endregion
//#region useViewer/index.d.ts
/**
* Obtain the `Viewer` instance injected through `createViewer` in the current component or its ancestor components.
*
* note:
* - If `createViewer` and `useViewer` are called in the same component, the `Viewer` instance injected by `createViewer` will be used preferentially.
* - When calling `createViewer` and `useViewer` in the same component, `createViewer` should be called before `useViewer`.
*/
declare function useViewer(): Readonly<ShallowRef<Viewer | undefined>>;
//#endregion
export { AddGraphicEventOptions, CesiumGraphic, EffcetRemovePredicate, GraphicEventListener, GraphicEventType, MaybeAsyncGetter, MaybeRefOrAsyncGetter, OnAsyncGetterCancel, ScreenSpaceEvent, ToPromiseValueOptions, UseCameraStateOptions, UseCameraStateReturn, UseCesiumEventListenerOptions, UseCesiumFpsOptions, UseCesiumFpsReturn, UseCollectionScopeOptions, UseCollectionScopeReturn, UseDataSourceOptions, UseDataSourceScopeOptions, UseElementOverlayOptions, UseElementOverlayReturn, UseEntityOptions, UseEntityScopeOptions, UseGraphicEventReturn, UseImageryLayerOptions, UseImageryLayerScopeOptions, UsePostProcessStageOptions, UsePostProcessStageScopeOptions, UsePrimitiveOptions, UsePrimitiveScopeOptions, UseScaleBarOptions, UseScaleBarReturn, UseSceneDrillPickOptions, UseScenePickOptions, UseScreenSpaceEventHandlerOptions, createViewer, removeFn, toPromiseValue, useCameraState, useCesiumEventListener, useCesiumFps, useCollectionScope, useDataSource, useDataSourceScope, useElementOverlay, useEntity, useEntityScope, useGraphicEvent, useImageryLayer, useImageryLayerScope, usePostProcessStage, usePostProcessStageScope, usePrimitive, usePrimitiveScope, useScaleBar, useSceneDrillPick, useScenePick, useScreenSpaceEventHandler, useViewer };
//# sourceMappingURL=index.d.mts.map