@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
158 lines (157 loc) • 5.64 kB
TypeScript
import { Observable } from "../Misc/observable.js";
import type { Nullable } from "../types.js";
import type { Scene } from "../scene.js";
import { Vector2 } from "../Maths/math.vector.js";
import { Color4 } from "../Maths/math.color.js";
import type { BaseTexture } from "../Materials/Textures/baseTexture.js";
import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.js";
import { ShaderLanguage } from "../Materials/shaderLanguage.js";
/**
* 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;
/**
* Force all the layers to compile to glsl even on WebGPU engines.
* False by default. This is mostly meant for backward compatibility.
*/
static ForceGLSL: boolean;
/**
* 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 colors of the layer should be generated in linear space (default: false)
*/
convertToLinearSpace: 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);
/** Shader language used by the material */
private _shaderLanguage;
/**
* Gets the shader language used in this material.
*/
get shaderLanguage(): ShaderLanguage;
/**
* 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
* @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
*/
constructor(
/**
* Define the name of the layer.
*/
name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4, forceGLSL?: boolean);
private _shadersLoaded;
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;
/**
* Renders the layer in the scene.
*/
render(): void;
/**
* Disposes and releases the associated resources.
*/
dispose(): void;
}