Skip to content

usePostProcessStage

Reactively add PostProcessStage instances to Cesium's post-process stage collection. The previous stage is removed automatically when the input changes.

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,
});

Overloads

  • Pass a single stage to receive a ComputedRef<T | undefined>.
  • Pass an array of stages to receive a ComputedRef<T[] | undefined>.

Options

  • collection sets the target PostProcessStageCollection.
  • isActive controls whether the stage is currently applied.
  • evaluating receives the async loading state.

Notes

  • The default collection is viewer.scene.postProcessStages.
  • The input can be a value, getter, ref, or async 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