usePostProcessStage
将 PostProcessStage 响应式添加到 Cesium 的后置处理集合中。输入变化时,上一份后置处理会自动移除。
Usage
ts
import { PostProcessStage } from 'cesium';
import { usePostProcessStage } from 'vesium';
import { ref } from 'vue';
const enabled = ref(true);
const stage = usePostProcessStage(() => new PostProcessStage({
fragmentShader: `
uniform sampler2D colorTexture;
varying vec2 v_textureCoordinates;
void main() {
gl_FragColor = texture2D(colorTexture, v_textureCoordinates);
}
`,
}), {
isActive: enabled,
});重载
- 传入单个 stage 时,返回
ComputedRef<T | undefined>。 - 传入 stage 数组时,返回
ComputedRef<T[] | undefined>。
配置项
collection用于指定目标PostProcessStageCollection。isActive控制当前是否生效。evaluating用于接收异步解析状态。
说明
- 默认集合为
viewer.scene.postProcessStages。 - 输入值可以是普通值、getter、ref 或异步 getter。
Type Definitions
typescript
import type { PostProcessStage, PostProcessStageCollection } from 'cesium';
import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
import type { MaybeRefOrAsyncGetter } from '../toPromiseValue';
export interface UsePostProcessStageOptions {
/**
* The collection of PostProcessStage to be added
* @default useViewer().scene.postProcessStages
*/
collection?: PostProcessStageCollection;
/**
* 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.
*/
export 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.
*/
export declare function usePostProcessStage<T extends PostProcessStage = PostProcessStage>(stages?: MaybeRefOrAsyncGetter<Array<T | undefined> | undefined>, options?: UsePostProcessStageOptions): ComputedRef<T[] | undefined>;
//# sourceMappingURL=index.d.ts.map