usePostProcessStageScope
Scope PostProcessStageCollection mutations so created stages are removed automatically when the component unmounts.
WARNING
This is a low-level helper used by usePostProcessStage. Prefer usePostProcessStage unless you need custom collection management.
Usage
ts
import { PostProcessStage } from 'cesium';
import { usePostProcessStageScope } from 'vesium';
const { add, remove } = usePostProcessStageScope();
const stage = add(new PostProcessStage({
fragmentShader: `
uniform sampler2D colorTexture;
varying vec2 v_textureCoordinates;
void main() {
gl_FragColor = texture2D(colorTexture, v_textureCoordinates);
}
`,
}));
// Async creation is also supported.
add(Promise.resolve(new PostProcessStage({
fragmentShader: `
uniform sampler2D colorTexture;
varying vec2 v_textureCoordinates;
void main() {
gl_FragColor = texture2D(colorTexture, v_textureCoordinates);
}
`,
})));Notes
- The target collection defaults to
useViewer().value.scene.postProcessStages. addaccepts bothPostProcessStageandPostProcessStageComposite.- Use
removewhen you need manual cleanup before unmounting.
Type Definitions
typescript
import type { PostProcessStage, PostProcessStageCollection, PostProcessStageComposite } from 'cesium';
import type { MaybeRefOrGetter } from 'vue';
export interface UsePostProcessStageScopeOptions {
/**
* The collection of PostProcessStage to be added
* @default useViewer().value.postProcessStages
*/
collection?: MaybeRefOrGetter<PostProcessStageCollection | undefined>;
}
/**
* Make `add` and `remove` operations of `PostProcessStageCollection` scoped,
* automatically remove `PostProcessStage` instance when component is unmounted.
*/
export declare function usePostProcessStageScope(options?: UsePostProcessStageScopeOptions): import("..").UseCollectionScopeReturn<PostProcessStage | PostProcessStageComposite, any[], any[], any>;
//# sourceMappingURL=index.d.ts.map