@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.
108 lines (107 loc) • 4.33 kB
TypeScript
import type { Effect } from "postprocessing";
import type { EditorModification, IEditorModification as IEditorModificationReceiver } from "../../engine/engine_editor-sync.js";
import { Behaviour } from "../Component.js";
import { PostProcessingEffect } from "./PostProcessingEffect.js";
import { IPostProcessingManager } from "./utils.js";
import { VolumeProfile } from "./VolumeProfile.js";
/** [Volume](https://engine.needle.tools/docs/api/Volume) The Volume/PostprocessingManager component is responsible for managing post processing effects.
* Add this component to any object in your scene to enable post processing effects.
*
* Effects added to this Volume (via profile or code) are pushed to `context.postprocessing` when the Volume is enabled,
* and removed when it is disabled.
*
* @example Add bloom
* ```ts
* const volume = new Volume();
* volume.addEffect(new BloomEffect({
* intensity: 3,
* luminanceThreshold: .2
* }));
* gameObject.addComponent(volume);
* ```
*
* @example Remove bloom
* ```ts
* volume.removeEffect(bloom);
* ```
*
* @example Add pixelation
* ```ts
* const pixelation = new PixelationEffect();
* pixelation.granularity.value = 10;
* volume.addEffect(pixelation);
* ```
*
* @summary Manage Post-Processing Effects
* @category Rendering
* @category Effects
* @see {@link VolumeProfile} for profile-based effect management
* @see {@link PostProcessingEffect} for creating custom effects
* @see {@link PostProcessing} for core Needle Engine postprocessing control, also accessible via `context.postprocessing`
* @group Components
*/
export declare class Volume extends Behaviour implements IEditorModificationReceiver, IPostProcessingManager {
get isPostProcessingManager(): boolean;
/** Currently active postprocessing effects managed by this Volume */
get effects(): PostProcessingEffect[];
get dirty(): boolean;
set dirty(value: boolean);
sharedProfile?: VolumeProfile;
/**
* Set multisampling to "auto" to automatically adjust the multisampling level based on performance.
* Set to a number to manually set the multisampling level.
* Pushed to `context.postprocessing.multisampling` when this Volume is active.
* @default "auto"
* @min 0
* @max renderer.capabilities.maxSamples
*/
multisampling: "auto" | number;
/** When enabled, the device pixel ratio will be gradually reduced when FPS is low
* and restored when performance recovers. This helps maintain smooth frame rates
* on devices where full retina resolution is too expensive for postprocessing.
* Pushed to `context.postprocessing.adaptiveResolution` when this Volume is active.
* Disable this if you need a fixed resolution and prefer consistent quality over frame rate.
* @default true
*/
adaptiveResolution: boolean;
/**
* Add a post processing effect to this Volume and push it to the core postprocessing stack.
*/
addEffect<T extends PostProcessingEffect | Effect>(effect: T & {
order?: number;
}): T;
/**
* Remove a post processing effect from this Volume and the core postprocessing stack.
*/
removeEffect<T extends PostProcessingEffect | Effect>(effect: T): T;
private readonly _activeEffects;
private readonly _effects;
/**
* When dirty the post processing effects will be re-applied
*/
markDirty(): void;
/** @internal */
awake(): void;
private _isDirty;
/** @internal */
onEnable(): void;
/** @internal */
onDisable(): void;
/** @internal */
onBeforeRender(): void;
/** @internal */
onDestroy(): void;
/** Collect active effects from profile + code and push them to context.postprocessing */
private pushEffectsToCore;
/** Remove all effects this Volume contributed from the core stack */
private removeEffectsFromCore;
/** Push multisampling and adaptiveResolution config to the core stack */
private syncConfigToCore;
private _applyPostQueue;
/** called from needle editor sync package if its active */
onEditorModification(modification: EditorModification): void | boolean | undefined;
private _modificationQueue?;
private _recreateId;
private scheduleRecreate;
}
export { Volume as PostProcessingManager };