UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in

73 lines (72 loc) 3.19 kB
import type { Effect, Pass } from "postprocessing"; import type { EditorModification, IEditorModification } from "../../engine/engine_editor-sync.js"; import { Component } from "../Component.js"; import type { PostProcessingHandler } from "./PostProcessingHandler.js"; import { IPostProcessingManager } from "./utils.js"; export declare type EffectProviderResult = Effect | Pass | Array<Effect | Pass>; export declare type PostProcessingEffectContext = { handler: PostProcessingHandler; components: PostProcessingEffect[]; }; export interface IEffectProvider { apply(context: PostProcessingEffectContext): void | undefined | EffectProviderResult; unapply(): void; } /** * PostProcessingEffect is a base class for post processing effects that can be applied to the scene. * To create a custom post processing effect, extend this class and override the `onCreateEffect` method and call `registerCustomEffectType` to make it available in the editor. * @example * ```typescript * import { EdgeDetectionMode, SMAAEffect, SMAAPreset } from "postprocessing"; * export class Antialiasing extends PostProcessingEffect { * get typeName(): string { * return "Antialiasing"; * } * @serializable(VolumeParameter) * preset!: VolumeParameter = new VolumeParameter(); * onCreateEffect(): EffectProviderResult { * const effect = new SMAAEffect({ * preset: SMAAPreset.HIGH, * edgeDetectionMode: EdgeDetectionMode.DEPTH * }); * this.preset.onValueChanged = (newValue) => { * effect.applyPreset(newValue); * }; * return effect; * } * } * registerCustomEffectType("Antialiasing", Antialiasing) * ``` * * @category Effects * @group Components */ export declare abstract class PostProcessingEffect extends Component implements IEffectProvider, IEditorModification { get isPostProcessingEffect(): boolean; constructor(params?: any); abstract get typeName(): string; /** * Whether the effect is active or not. Prefer using `enabled` instead. * @deprecated */ active: boolean; private _manager; onEnable(): void; onDisable(): void; protected onEffectEnabled(manager?: IPostProcessingManager): void; /** override to initialize bindings on parameters */ init(): void; /** previously created effect (if any) */ private _result; private _postprocessingContext; protected get postprocessingContext(): PostProcessingEffectContext | null; /** Apply post settings. Make sure to call super.apply() if you also create an effect */ apply(ctx: PostProcessingEffectContext): void | undefined | EffectProviderResult; /** Reset previously set values (e.g. when adjusting settings on the renderer like Tonemapping) */ unapply(): void; /** implement to create a effect once to be cached in the base class. Make sure super.apply() is called if you also override apply */ onCreateEffect?(): EffectProviderResult | undefined; dispose(): void; private initParameters; onEditorModification(modification: EditorModification): void | boolean | undefined; }