@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.
225 lines (224 loc) • 8.62 kB
TypeScript
import type { Nullable } from "../types.js";
import { Scene } from "../scene.js";
import type { SubMesh } from "../Meshes/subMesh.js";
import type { AbstractMesh } from "../Meshes/abstractMesh.js";
import type { Mesh } from "../Meshes/mesh.js";
import { Texture } from "../Materials/Textures/texture.js";
import type { Effect } from "../Materials/effect.js";
import type { Material } from "../Materials/material.js";
import type { IThinGlowLayerOptions } from "./thinGlowLayer.js";
import { EffectLayer } from "./effectLayer.js";
import type { Color4 } from "../Maths/math.color.js";
import "../Layers/effectLayerSceneComponent.js";
import { ThinGlowLayer } from "./thinGlowLayer.js";
declare module "../scene.js" {
interface Scene {
/**
* Return the first glow layer of the scene with a given name.
* @param name The name of the glow layer to look for.
* @returns The glow layer if found otherwise null.
*/
getGlowLayerByName(name: string): Nullable<GlowLayer>;
}
}
/**
* Glow layer options. This helps customizing the behaviour
* of the glow layer.
*/
export interface IGlowLayerOptions extends IThinGlowLayerOptions {
/**
* Enable MSAA by choosing the number of samples. Default: 1
*/
mainTextureSamples?: number;
/**
* Whether or not to generate a stencil buffer. Default: false
*/
generateStencilBuffer?: boolean;
}
/**
* The glow layer Helps adding a glow effect around the emissive parts of a mesh.
*
* Once instantiated in a scene, by default, all the emissive meshes will glow.
*
* Documentation: https://doc.babylonjs.com/features/featuresDeepDive/mesh/glowLayer
*/
export declare class GlowLayer extends EffectLayer {
/**
* Effect Name of the layer.
*/
static get EffectName(): string;
/**
* The default blur kernel size used for the glow.
*/
static DefaultBlurKernelSize: number;
/**
* The default texture size ratio used for the glow.
*/
static DefaultTextureRatio: number;
/**
* Sets the kernel size of the blur.
*/
set blurKernelSize(value: number);
/**
* Gets the kernel size of the blur.
*/
get blurKernelSize(): number;
/**
* Sets the glow intensity.
*/
set intensity(value: number);
/**
* Gets the glow intensity.
*/
get intensity(): number;
protected _options: IGlowLayerOptions;
protected readonly _thinEffectLayer: ThinGlowLayer;
private _horizontalBlurPostprocess1;
private _verticalBlurPostprocess1;
private _horizontalBlurPostprocess2;
private _verticalBlurPostprocess2;
private _blurTexture1;
private _blurTexture2;
private _postProcesses1;
private _postProcesses2;
/**
* Callback used to let the user override the color selection on a per mesh basis
*/
get customEmissiveColorSelector(): (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
set customEmissiveColorSelector(value: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void);
/**
* Callback used to let the user override the texture selection on a per mesh basis
*/
get customEmissiveTextureSelector(): (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
set customEmissiveTextureSelector(value: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture);
/**
* Instantiates a new glow Layer and references it to the scene.
* @param name The name of the layer
* @param scene The scene to use the layer in
* @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
*/
constructor(name: string, scene?: Scene, options?: Partial<IGlowLayerOptions>);
/**
* Get the effect name of the layer.
* @returns The effect name
*/
getEffectName(): string;
/**
* @internal
* Create the merge effect. This is the shader use to blit the information back
* to the main canvas at the end of the scene rendering.
*/
protected _createMergeEffect(): Effect;
/**
* Creates the render target textures and post processes used in the glow layer.
*/
protected _createTextureAndPostProcesses(): void;
/**
* Checks for the readiness of the element composing the layer.
* @param subMesh the mesh to check for
* @param useInstances specify whether or not to use instances to render the mesh
* @returns true if ready otherwise, false
*/
isReady(subMesh: SubMesh, useInstances: boolean): boolean;
/**
* @returns whether or not the layer needs stencil enabled during the mesh rendering.
*/
needStencil(): boolean;
/**
* Returns true if the mesh can be rendered, otherwise false.
* @param mesh The mesh to render
* @param material The material used on the mesh
* @returns true if it can be rendered otherwise false
*/
protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
/**
* Implementation specific of rendering the generating effect on the main canvas.
* @param effect The effect used to render through
*/
protected _internalRender(effect: Effect): void;
/**
* Sets the required values for both the emissive texture and and the main color.
* @param mesh
* @param subMesh
* @param material
*/
protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
/**
* Returns true if the mesh should render, otherwise false.
* @param mesh The mesh to render
* @returns true if it should render otherwise false
*/
protected _shouldRenderMesh(mesh: Mesh): boolean;
/**
* Adds specific effects defines.
* @param defines The defines to add specifics to.
*/
protected _addCustomEffectDefines(defines: string[]): void;
/**
* Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
* @param mesh The mesh to exclude from the glow layer
*/
addExcludedMesh(mesh: Mesh): void;
/**
* Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
* @param mesh The mesh to remove
*/
removeExcludedMesh(mesh: Mesh): void;
/**
* Add a mesh in the inclusion list to impact or being impacted by the glow layer.
* @param mesh The mesh to include in the glow layer
*/
addIncludedOnlyMesh(mesh: Mesh): void;
/**
* Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
* @param mesh The mesh to remove
*/
removeIncludedOnlyMesh(mesh: Mesh): void;
/**
* Determine if a given mesh will be used in the glow layer
* @param mesh The mesh to test
* @returns true if the mesh will be highlighted by the current glow layer
*/
hasMesh(mesh: AbstractMesh): boolean;
/**
* Defines whether the current material of the mesh should be use to render the effect.
* @param mesh defines the current mesh to render
* @returns true if the material of the mesh should be use to render the effect
*/
protected _useMeshMaterial(mesh: AbstractMesh): boolean;
/**
* Add a mesh to be rendered through its own material and not with emissive only.
* @param mesh The mesh for which we need to use its material
*/
referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
/**
* Remove a mesh from being rendered through its own material and not with emissive only.
* @param mesh The mesh for which we need to not use its material
*/
unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
/**
* Free any resources and references associated to a mesh.
* Internal use
* @param mesh The mesh to free.
* @internal
*/
_disposeMesh(mesh: Mesh): void;
/**
* Gets the class name of the effect layer
* @returns the string with the class name of the effect layer
*/
getClassName(): string;
/**
* Serializes this glow layer
* @returns a serialized glow layer object
*/
serialize(): any;
/**
* Creates a Glow Layer from parsed glow layer data
* @param parsedGlowLayer defines glow layer data
* @param scene defines the current scene
* @param rootUrl defines the root URL containing the glow layer information
* @returns a parsed Glow Layer
*/
static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
}