跳至内容

usePrimitiveScope

将“PrimitiveCollection”操作的副作用范围化,并在卸载时自动删除

Usage

ts
TODO;

Type Definitions

typescript
import type { PrimitiveCollection } from 'cesium';
import type { MaybeRefOrGetter, ShallowReactive } from 'vue';
import type { EffcetRemovePredicate } from '../useCollectionScope';
export interface UsePrimitiveScopeOptions {
    /**
     * The collection of Primitive to be added
     * @default useViewer().value.scene.primitives
     */
    collection?: MaybeRefOrGetter<PrimitiveCollection>;
}
export interface UsePrimitiveScopeRetrun {
    /**
     * A `Set` for storing SideEffect instance,
     * which is encapsulated using `ShallowReactive` to provide Vue's reactive functionality
     */
    scope: Readonly<ShallowReactive<Set<any>>>;
    /**
     * Add SideEffect instance
     */
    add: <T>(primitive: T) => T;
    /**
     * Remove specified SideEffect instance
     */
    remove: (primitive: any, destroy?: boolean) => boolean;
    /**
     * Remove all SideEffect instance that meets the specified criteria
     */
    removeWhere: (predicate: EffcetRemovePredicate<any>, destroy?: boolean) => void;
    /**
     * Remove all SideEffect instance within current scope
     */
    removeScope: (destroy?: boolean) => void;
}
/**
 * Make `add` and `remove` operations of `PrimitiveCollection` scoped,
 * automatically remove `Primitive` instance when component is unmounted.
 */
export declare function usePrimitiveScope(options?: UsePrimitiveScopeOptions): UsePrimitiveScopeRetrun;