import { type AbstractEngine } from "@babylonjs/core/Engines/abstractEngine.js"; import { type IDisposable } from "@babylonjs/core/scene.js"; import { type Nullable } from "@babylonjs/core/types.js"; import { type FontAsset } from "./fontAsset.js"; import { type ParagraphOptions } from "./paragraphOptions.js"; import { type IColor4Like, type IMatrixLike } from "@babylonjs/core/Maths/math.like.js"; /** * Abstract Node class from Babylon.js */ export interface INodeLike { getWorldMatrix(): IMatrixLike; } /** * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js * #6RLCWP#16 * Star wars scroller: #6RLCWP#29 * With metrics: #6RLCWP#35 * Thickness: #IABMEZ#3 * Solar system: #9YCDYC#9 * Stroke: #6RLCWP#37 */ export declare class TextRenderer implements IDisposable { private readonly _useVAO; private _engine; private _shaderLanguage; private _vertexBuffers; private _spriteBuffer; private _worldBuffer; private _uvBuffer; private _drawWrapperBase; private _vertexArrayObject; private _font; private _charMatrices; private _charUvs; private _isDirty; private _baseLine; private _scalingMatrix; private _fontScaleMatrix; private _offsetMatrix; private _translationMatrix; private _baseMatrix; private _scaledMatrix; private _localMatrix; private _finalMatrix; private _lineMatrix; private _parentWorldMatrix; /** * Gets or sets the color of the text */ color: IColor4Like; /** * Gets or sets the color of the stroke around the text */ strokeColor: IColor4Like; /** * Gets or sets the width of the stroke around the text (inset) */ strokeInsetWidth: number; /** * Gets or sets the width of the stroke around the text (outset) */ strokeOutsetWidth: number; /** * Gets or sets the thickness of the text (0 means as defined in the font) * Value must be between -0.5 and 0.5 */ thicknessControl: number; private _parent; /** * Gets or sets the parent of the text renderer */ get parent(): Nullable; set parent(value: Nullable); private _transformMatrix; /** * Gets or sets the transform matrix of the text renderer * It will be applied in that order: * parent x transform x paragraph world */ get transformMatrix(): IMatrixLike; set transformMatrix(value: IMatrixLike); /** * Gets or sets if the text is billboarded */ isBillboard: boolean; /** * Gets or sets if the text is screen projected * This will work only if the text is billboarded */ isBillboardScreenProjected: boolean; /** * Gets the number of characters in the text renderer */ get characterCount(): number; /** * Gets or sets if the text renderer should ignore the depth buffer * Default is false */ ignoreDepthBuffer: boolean; /** * Gets or sets if the text renderer should write to the depth buffer (default is false). * When enabled, transparent pixels are discarded so that separate text renderers (and other meshes) * occlude each other according to their position in the 3D scene instead of their render order. * On multisampled framebuffers, alpha-to-coverage is used to preserve anti-aliased edges. * This has no effect when ignoreDepthBuffer is true. */ writeToDepthBuffer: boolean; private constructor(); private _resizeBuffers; private _setShaders; /** * Add a paragraph of text to the renderer * @param text define the text to add * @param options define the options to use for the paragraph (optional) * @param worldMatrix define the world matrix to use for the paragraph (optional) */ addParagraph(text: string, options?: Partial, worldMatrix?: IMatrixLike): void; /** * Clear all paragraphs from the renderer to allow adding new ones from scratch */ clearParagraphs(): void; /** * Render the text using the provided view and projection matrices * @param viewMatrix define the view matrix to use * @param projectionMatrix define the projection matrix to use */ render(viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike): void; /** * Release associated resources */ dispose(): void; /** * Creates a new TextRenderer instance asynchronously * @param font define the font asset to use * @param engine define the engine to use * @returns a promise that resolves to the created TextRenderer instance */ static CreateTextRendererAsync(font: FontAsset, engine: AbstractEngine): Promise; }