123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import { Observable } from "../Misc/observable";
- import type { Nullable } from "../types";
- import type { Scene } from "../scene";
- import { Vector2 } from "../Maths/math.vector";
- import { Color4 } from "../Maths/math.color";
- import type { BaseTexture } from "../Materials/Textures/baseTexture";
- import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
- import "../Shaders/layer.fragment";
- import "../Shaders/layer.vertex";
- /**
- * This represents a full screen 2d layer.
- * This can be useful to display a picture in the background of your scene for instance.
- * @see https://www.babylonjs-playground.com/#08A2BS#1
- */
- export declare class Layer {
- /**
- * Define the name of the layer.
- */
- name: string;
- /**
- * Define the texture the layer should display.
- */
- texture: Nullable<BaseTexture>;
- /**
- * Is the layer in background or foreground.
- */
- isBackground: boolean;
- private _applyPostProcess;
- /**
- * Determines if the layer is drawn before (true) or after (false) post-processing.
- * If the layer is background, it is always before.
- */
- set applyPostProcess(value: boolean);
- get applyPostProcess(): boolean;
- /**
- * Define the color of the layer (instead of texture).
- */
- color: Color4;
- /**
- * Define the scale of the layer in order to zoom in out of the texture.
- */
- scale: Vector2;
- /**
- * Define an offset for the layer in order to shift the texture.
- */
- offset: Vector2;
- /**
- * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
- */
- alphaBlendingMode: number;
- /**
- * Define if the layer should alpha test or alpha blend with the rest of the scene.
- * Alpha test will not mix with the background color in case of transparency.
- * It will either use the texture color or the background depending on the alpha value of the current pixel.
- */
- alphaTest: boolean;
- /**
- * Define a mask to restrict the layer to only some of the scene cameras.
- */
- layerMask: number;
- /**
- * Define the list of render target the layer is visible into.
- */
- renderTargetTextures: RenderTargetTexture[];
- /**
- * Define if the layer is only used in renderTarget or if it also
- * renders in the main frame buffer of the canvas.
- */
- renderOnlyInRenderTargetTextures: boolean;
- /**
- * Define if the layer is enabled (ie. should be displayed). Default: true
- */
- isEnabled: boolean;
- private _scene;
- private _vertexBuffers;
- private _indexBuffer;
- private _drawWrapper;
- private _previousDefines;
- /**
- * An event triggered when the layer is disposed.
- */
- onDisposeObservable: Observable<Layer>;
- private _onDisposeObserver;
- /**
- * Back compatibility with callback before the onDisposeObservable existed.
- * The set callback will be triggered when the layer has been disposed.
- */
- set onDispose(callback: () => void);
- /**
- * An event triggered before rendering the scene
- */
- onBeforeRenderObservable: Observable<Layer>;
- private _onBeforeRenderObserver;
- /**
- * Back compatibility with callback before the onBeforeRenderObservable existed.
- * The set callback will be triggered just before rendering the layer.
- */
- set onBeforeRender(callback: () => void);
- /**
- * An event triggered after rendering the scene
- */
- onAfterRenderObservable: Observable<Layer>;
- private _onAfterRenderObserver;
- /**
- * Back compatibility with callback before the onAfterRenderObservable existed.
- * The set callback will be triggered just after rendering the layer.
- */
- set onAfterRender(callback: () => void);
- /**
- * Instantiates a new layer.
- * This represents a full screen 2d layer.
- * This can be useful to display a picture in the background of your scene for instance.
- * @see https://www.babylonjs-playground.com/#08A2BS#1
- * @param name Define the name of the layer in the scene
- * @param imgUrl Define the url of the texture to display in the layer
- * @param scene Define the scene the layer belongs to
- * @param isBackground Defines whether the layer is displayed in front or behind the scene
- * @param color Defines a color for the layer
- */
- constructor(
- /**
- * Define the name of the layer.
- */
- name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
- private _createIndexBuffer;
- /** @internal */
- _rebuild(): void;
- /**
- * Checks if the layer is ready to be rendered
- * @returns true if the layer is ready. False otherwise.
- */
- isReady(): boolean | undefined;
- /**
- * Renders the layer in the scene.
- */
- render(): void;
- /**
- * Disposes and releases the associated resources.
- */
- dispose(): void;
- }
|