@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.
84 lines (83 loc) • 3.4 kB
TypeScript
import type { EffectComposer } from "postprocessing";
import type { EffectComposer as ThreeEffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
import type { Context } from "../engine_context.js";
import type { IPostProcessingEffect, IPostProcessingHandler } from "./types.js";
/**
* Core postprocessing stack accessible via `context.postprocessing`.
* Manages the effect pipeline independently of any specific component.
*
* Volumes and individual PostProcessingEffect components add/remove effects
* to this stack. The stack builds the EffectComposer pipeline when dirty.
*
* @example Add an effect directly
* ```ts
* const bloom = new BloomEffect({ intensity: 3 });
* this.context.postprocessing.addEffect(bloom);
* ```
*
* @example Remove an effect
* ```ts
* this.context.postprocessing.removeEffect(bloom);
* ```
*/
export declare class PostProcessing {
private readonly _context;
private _handler;
private readonly _effects;
private _isDirty;
/** Currently active postprocessing effects in the stack */
get effects(): readonly IPostProcessingEffect[];
get dirty(): boolean;
set dirty(value: boolean);
/** The internal PostProcessingHandler that manages the EffectComposer pipeline */
get handler(): IPostProcessingHandler | null;
/**
* The effect composer used to render postprocessing effects.
* This is set internally by the PostProcessingHandler when effects are applied.
*/
get composer(): EffectComposer | ThreeEffectComposer | null;
set composer(value: EffectComposer | ThreeEffectComposer | null);
private _composer;
/**
* Set multisampling to "auto" to automatically adjust the multisampling level based on performance.
* Set to a number to manually set the multisampling level.
* @default "auto"
*/
multisampling: "auto" | number;
/** When enabled, the device pixel ratio will be gradually reduced when FPS is low
* and restored when performance recovers.
* @default true
*/
adaptiveResolution: boolean;
constructor(context: Context);
/**
* Add a post processing effect to the stack.
* The effect stack will be rebuilt on the next update.
*/
addEffect(effect: IPostProcessingEffect): void;
/**
* Remove a post processing effect from the stack.
* The effect stack will be rebuilt on the next update.
*/
removeEffect(effect: IPostProcessingEffect): void;
/** Mark the stack as dirty so the effects are rebuilt on the next update */
markDirty(): void;
private _enabledTime;
private _multisampleAutoChangeTime;
private _multisampleAutoDecreaseTime;
/** @internal Called from the context render loop to update the postprocessing pipeline */
update(): void;
private _lastApplyTime?;
private _rapidApplyCount;
/** When true, tonemapping is applied directly to the renderer (no full pipeline) */
private _tonemappingOnlyActive;
private _previousToneMapping?;
private _previousToneMappingExposure?;
private apply;
/** Restore renderer tonemapping to previous values when leaving tonemapping-only mode */
private restoreTonemapping;
/** Lazily creates the PostProcessingHandler to avoid loading the postprocessing library until actually needed */
private ensureHandler;
/** @internal */
dispose(): void;
}