@babylonjs/addons 8.8.3 → 8.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/msdfText/textRenderer.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Constants } from "@babylonjs/core/Engines/constants.js";
|
|
|
3
3
|
import { DrawWrapper } from "@babylonjs/core/Materials/drawWrapper.js";
|
|
4
4
|
import { SdfTextParagraph } from "./sdf/paragraph.js";
|
|
5
5
|
import { ThinMatrix } from "@babylonjs/core/Maths/ThinMaths/thinMath.matrix.js";
|
|
6
|
-
import { CopyMatrixToArray, IdentityMatrixToRef, InvertMatrixToRef, MultiplyMatricesToRef, ScalingMatrixToRef, TranslationMatrixToRef, } from "@babylonjs/core/Maths/ThinMaths/thinMath.matrix.functions.js";
|
|
6
|
+
import { CopyMatrixToArray, CopyMatrixToRef, IdentityMatrixToRef, InvertMatrixToRef, MultiplyMatricesToRef, ScalingMatrixToRef, TranslationMatrixToRef, } from "@babylonjs/core/Maths/ThinMaths/thinMath.matrix.functions.js";
|
|
7
7
|
/**
|
|
8
8
|
* Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
|
|
9
9
|
* Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
|
|
@@ -180,7 +180,7 @@ export class TextRenderer {
|
|
|
180
180
|
baseM[12] = 0;
|
|
181
181
|
baseM[13] = 0;
|
|
182
182
|
baseM[14] = 0;
|
|
183
|
-
InvertMatrixToRef(this._baseMatrix, this._parentWorldMatrix
|
|
183
|
+
InvertMatrixToRef(this._baseMatrix, this._parentWorldMatrix);
|
|
184
184
|
// Restore translation
|
|
185
185
|
const pwm = this._parentWorldMatrix.asArray();
|
|
186
186
|
pwm[12] = this._storedTranslation.x;
|
|
@@ -189,7 +189,7 @@ export class TextRenderer {
|
|
|
189
189
|
}
|
|
190
190
|
else {
|
|
191
191
|
if (this._parent) {
|
|
192
|
-
|
|
192
|
+
CopyMatrixToRef(this._parent.getWorldMatrix(), this._parentWorldMatrix);
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
195
|
IdentityMatrixToRef(this._parentWorldMatrix);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textRenderer.js","sourceRoot":"","sources":["../../../../dev/addons/src/msdfText/textRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,0CAA4B;AAE7C,OAAO,EAAE,SAAS,EAAE,6CAA+B;AAEnD,OAAO,EAAE,WAAW,EAAE,iDAAmC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,2DAA6C;AAClE,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,GACzB,qEAAuD;AAUxD;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IA0CrB;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAA0B;QACxC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB,CAAC;IAOD;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,EAAE,CAAC;IAC1C,CAAC;IAED,YAAoB,MAAsB,EAAE,4CAAoD,EAAE,IAAe;QAhEhG,YAAO,GAAY,KAAK,CAAC;QAGlC,mBAAc,GAAoC,EAAE,CAAC;QAOrD,kBAAa,GAAG,IAAI,KAAK,EAAU,CAAC;QACpC,aAAQ,GAAG,IAAI,KAAK,EAAU,CAAC;QAC/B,aAAQ,GAAG,IAAI,CAAC;QAChB,cAAS,GAAG,CAAC,CAAC;QAEtB,QAAQ;QACA,mBAAc,GAAG,IAAI,UAAU,EAAE,CAAC;QAClC,qBAAgB,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,kBA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E,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAE3C,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import type { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Buffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { ThinEngine } from \"core/Engines/thinEngine\";\r\nimport { DrawWrapper } from \"core/Materials/drawWrapper\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { IDisposable } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { SdfTextParagraph } from \"./sdf/paragraph\";\r\nimport type { FontAsset } from \"./fontAsset\";\r\nimport type { ParagraphOptions } from \"./paragraphOptions\";\r\nimport { ThinMatrix } from \"core/Maths/ThinMaths/thinMath.matrix\";\r\nimport {\r\n CopyMatrixToArray,\r\n IdentityMatrixToRef,\r\n InvertMatrixToRef,\r\n MultiplyMatricesToRef,\r\n ScalingMatrixToRef,\r\n TranslationMatrixToRef,\r\n} from \"core/Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { IColor4Like, IMatrixLike, IVector3Like } from \"core/Maths\";\r\n\r\n/**\r\n * Abstract Node class from Babylon.js\r\n */\r\nexport interface INodeLike {\r\n getWorldMatrix(): ThinMatrix;\r\n}\r\n\r\n/**\r\n * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique\r\n * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js\r\n * #6RLCWP#16\r\n * Star wars scroller: #6RLCWP#29\r\n * With metrics: #6RLCWP#35\r\n * Thickness: #IABMEZ#3\r\n * Solar system: #9YCDYC#9\r\n */\r\nexport class TextRenderer implements IDisposable {\r\n private readonly _useVAO: boolean = false;\r\n private _engine: AbstractEngine;\r\n private _shaderLanguage: ShaderLanguage;\r\n private _vertexBuffers: { [key: string]: VertexBuffer } = {};\r\n private _spriteBuffer: Nullable<Buffer>;\r\n private _worldBuffer: Nullable<Buffer>;\r\n private _uvBuffer: Nullable<Buffer>;\r\n private _drawWrapperBase: DrawWrapper;\r\n private _vertexArrayObject: WebGLVertexArrayObject;\r\n private _font: FontAsset;\r\n private _charMatrices = new Array<number>();\r\n private _charUvs = new Array<number>();\r\n private _isDirty = true;\r\n private _baseLine = 0;\r\n\r\n // Cache\r\n private _scalingMatrix = new ThinMatrix();\r\n private _fontScaleMatrix = new ThinMatrix();\r\n private _offsetMatrix = new ThinMatrix();\r\n private _translationMatrix = new ThinMatrix();\r\n private _baseMatrix = new ThinMatrix();\r\n private _scaledMatrix = new ThinMatrix();\r\n private _localMatrix = new ThinMatrix();\r\n private _finalMatrix = new ThinMatrix();\r\n private _lineMatrix = new ThinMatrix();\r\n private _parentWorldMatrix = new ThinMatrix();\r\n private _storedTranslation: IVector3Like = { x: 0, y: 0, z: 0 };\r\n\r\n /**\r\n * Gets or sets the color of the text\r\n */\r\n public color: IColor4Like = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\r\n\r\n /**\r\n * Gets or sets the thickness of the text (0 means as defined in the font)\r\n * Value must be between -0.5 and 0.5\r\n */\r\n public thicknessControl = 0;\r\n\r\n private _parent: Nullable<INodeLike> = null;\r\n\r\n /**\r\n * Gets or sets the parent of the text renderer\r\n */\r\n public get parent(): Nullable<INodeLike> {\r\n return this._parent;\r\n }\r\n\r\n public set parent(value: Nullable<INodeLike>) {\r\n this._parent = value;\r\n }\r\n\r\n /**\r\n * Gets or sets if the text is billboarded\r\n */\r\n public isBillboard = false;\r\n\r\n /**\r\n * Gets the number of characters in the text renderer\r\n */\r\n public get characterCount(): number {\r\n return this._charMatrices.length / 16;\r\n }\r\n\r\n private constructor(engine: AbstractEngine, shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL, font: FontAsset) {\r\n this._engine = engine;\r\n this._shaderLanguage = shaderLanguage;\r\n this._font = font;\r\n this._baseLine = font._font.common.lineHeight * font.scale;\r\n\r\n this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;\r\n\r\n // Main vertex buffer\r\n const spriteData = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);\r\n this._spriteBuffer = new Buffer(engine, spriteData, false, 2);\r\n this._vertexBuffers[\"offsets\"] = this._spriteBuffer.createVertexBuffer(\"offsets\", 0, 2);\r\n\r\n // Instances\r\n this._resizeBuffers(128);\r\n }\r\n\r\n private _resizeBuffers(capacity: number) {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n this._worldBuffer = new Buffer(this._engine, new Float32Array(capacity * 16), true, 16);\r\n this._vertexBuffers[\"world0\"] = this._worldBuffer.createVertexBuffer(\"world0\", 0, 4, 16, true);\r\n this._vertexBuffers[\"world1\"] = this._worldBuffer.createVertexBuffer(\"world1\", 4, 4, 16, true);\r\n this._vertexBuffers[\"world2\"] = this._worldBuffer.createVertexBuffer(\"world2\", 8, 4, 16, true);\r\n this._vertexBuffers[\"world3\"] = this._worldBuffer.createVertexBuffer(\"world3\", 12, 4, 16, true);\r\n\r\n this._uvBuffer = new Buffer(this._engine, new Float32Array(capacity * 4), true, 4);\r\n this._vertexBuffers[\"uvs\"] = this._uvBuffer.createVertexBuffer(\"uvs\", 0, 4, 4, true);\r\n }\r\n\r\n private _setShaders(vertex: string, fragment: string) {\r\n this._drawWrapperBase?.dispose();\r\n\r\n this._drawWrapperBase = new DrawWrapper(this._engine);\r\n\r\n if (this._drawWrapperBase.drawContext) {\r\n this._drawWrapperBase.drawContext.useInstancing = true;\r\n }\r\n\r\n const defines = \"\";\r\n\r\n this._drawWrapperBase.effect = this._engine.createEffect(\r\n {\r\n vertexSource: vertex,\r\n fragmentSource: fragment,\r\n },\r\n [\"offsets\", \"world0\", \"world1\", \"world2\", \"world3\", \"uvs\"],\r\n [\"parentWorld\", \"view\", \"projection\", \"uColor\", \"unitRange\", \"texelSize\", \"thickness\"],\r\n [\"fontAtlas\"],\r\n defines,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._shaderLanguage\r\n );\r\n\r\n this._drawWrapperBase.effect._refCount++;\r\n }\r\n\r\n /**\r\n * Add a paragraph of text to the renderer\r\n * @param text define the text to add\r\n * @param options define the options to use for the paragraph (optional)\r\n * @param worldMatrix define the world matrix to use for the paragraph (optional)\r\n */\r\n public addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: IMatrixLike) {\r\n const paragraph = new SdfTextParagraph(text, this._font, options);\r\n\r\n const fontScale = this._font.scale;\r\n\r\n const texWidth = this._font._font.common.scaleW;\r\n const texHeight = this._font._font.common.scaleH;\r\n const glyphs = paragraph.glyphs.filter((g) => g.char.page >= 0);\r\n\r\n let worldMatrixToUse = worldMatrix;\r\n\r\n if (!worldMatrixToUse) {\r\n const lineHeight = paragraph.lineHeight * fontScale;\r\n const lineOffset = (paragraph.lines.length * lineHeight) / 2;\r\n TranslationMatrixToRef(0, this._baseLine - lineOffset, 0, this._lineMatrix);\r\n worldMatrixToUse = this._lineMatrix;\r\n }\r\n\r\n ScalingMatrixToRef(fontScale, fontScale, 1.0, this._fontScaleMatrix);\r\n TranslationMatrixToRef(0.5, -0.5, 0, this._offsetMatrix);\r\n\r\n const charsUvsBase = this._charUvs.length;\r\n const matricesBase = this._charMatrices.length;\r\n glyphs.forEach((g, i) => {\r\n this._charUvs[charsUvsBase + i * 4 + 0] = g.char.x / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 1] = g.char.y / texHeight;\r\n this._charUvs[charsUvsBase + i * 4 + 2] = g.char.width / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 3] = g.char.height / texHeight;\r\n\r\n const x = g.x;\r\n const y = -g.y;\r\n\r\n ScalingMatrixToRef(g.char.width, g.char.height, 1.0, this._scalingMatrix);\r\n MultiplyMatricesToRef(this._offsetMatrix, this._scalingMatrix, this._baseMatrix);\r\n\r\n TranslationMatrixToRef(x * fontScale, y * fontScale, 0.0, this._translationMatrix);\r\n MultiplyMatricesToRef(this._baseMatrix, this._fontScaleMatrix, this._scaledMatrix);\r\n MultiplyMatricesToRef(this._scaledMatrix, this._translationMatrix, this._localMatrix);\r\n\r\n MultiplyMatricesToRef(this._localMatrix, worldMatrixToUse, this._finalMatrix);\r\n CopyMatrixToArray(this._finalMatrix, this._charMatrices, matricesBase + i * 16);\r\n });\r\n\r\n this._isDirty = true;\r\n\r\n this._baseLine -= paragraph.lineHeight * fontScale * paragraph.lines.length;\r\n }\r\n\r\n /**\r\n * Render the text using the provided view and projection matrices\r\n * @param viewMatrix define the view matrix to use\r\n * @param projectionMatrix define the projection matrix to use\r\n */\r\n public render(viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike): void {\r\n const drawWrapper = this._drawWrapperBase;\r\n\r\n const effect = drawWrapper.effect!;\r\n\r\n // Check\r\n if (!effect.isReady()) {\r\n return;\r\n }\r\n const engine = this._engine;\r\n\r\n engine.setState(false);\r\n engine.enableEffect(drawWrapper);\r\n\r\n if (this.isBillboard) {\r\n // We will only consider translation for parent to simplify computation\r\n // Save parent translation\r\n if (this._parent) {\r\n const pwm = this._parent.getWorldMatrix().asArray();\r\n this._storedTranslation.x = pwm[12];\r\n this._storedTranslation.y = pwm[13];\r\n this._storedTranslation.z = pwm[14];\r\n } else {\r\n this._storedTranslation.x = 0;\r\n this._storedTranslation.y = 0;\r\n this._storedTranslation.z = 0;\r\n }\r\n // Cancel camera rotation\r\n const baseM = this._baseMatrix.asArray();\r\n CopyMatrixToArray(viewMatrix, baseM);\r\n baseM[12] = 0;\r\n baseM[13] = 0;\r\n baseM[14] = 0;\r\n InvertMatrixToRef(this._baseMatrix, this._parentWorldMatrix.asArray());\r\n\r\n // Restore translation\r\n const pwm = this._parentWorldMatrix.asArray();\r\n pwm[12] = this._storedTranslation.x;\r\n pwm[13] = this._storedTranslation.y;\r\n pwm[14] = this._storedTranslation.z;\r\n } else {\r\n if (this._parent) {\r\n CopyMatrixToArray(this._parent.getWorldMatrix(), this._parentWorldMatrix.asArray());\r\n } else {\r\n IdentityMatrixToRef(this._parentWorldMatrix);\r\n }\r\n }\r\n\r\n effect.setMatrix(\"parentWorld\", this._parentWorldMatrix);\r\n effect.setMatrix(\"view\", viewMatrix);\r\n effect.setMatrix(\"projection\", projectionMatrix);\r\n\r\n // Texture\r\n const textureWidth = this._font._font.common.scaleW;\r\n const textureHeight = this._font._font.common.scaleW;\r\n const distanceRange = this._font._font.distanceField.distanceRange;\r\n\r\n effect.setTexture(\"fontAtlas\", this._font.textures[0]);\r\n effect.setFloat2(\"unitRange\", distanceRange / textureWidth, distanceRange / textureHeight);\r\n effect.setFloat2(\"texelSize\", 1.0 / textureWidth, 1.0 / textureHeight);\r\n effect.setDirectColor4(\"uColor\", this.color);\r\n effect.setFloat(\"thickness\", this.thicknessControl * 0.9);\r\n\r\n const instanceCount = this._charMatrices.length / 16;\r\n\r\n // Need update?\r\n if (this._isDirty) {\r\n this._isDirty = false;\r\n\r\n if (this._worldBuffer!.getBuffer()!.capacity / 4 < instanceCount * 16) {\r\n this._resizeBuffers(instanceCount);\r\n }\r\n\r\n this._worldBuffer!.update(this._charMatrices);\r\n this._uvBuffer!.update(this._charUvs);\r\n }\r\n\r\n if (this._useVAO) {\r\n if (!this._vertexArrayObject) {\r\n this._vertexArrayObject = (engine as ThinEngine).recordVertexArrayObject(this._vertexBuffers, null, effect);\r\n }\r\n (engine as ThinEngine).bindVertexArrayObject(this._vertexArrayObject, null);\r\n } else {\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, null, effect);\r\n }\r\n\r\n engine.setAlphaMode(Constants.ALPHA_COMBINE);\r\n\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, instanceCount);\r\n\r\n engine.unbindInstanceAttributes();\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n if (this._spriteBuffer) {\r\n this._spriteBuffer.dispose();\r\n this._spriteBuffer = null;\r\n }\r\n\r\n if (this._vertexArrayObject) {\r\n (this._engine as ThinEngine).releaseVertexArrayObject(this._vertexArrayObject);\r\n (<any>this._vertexArrayObject) = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new TextRenderer instance asynchronously\r\n * @param font define the font asset to use\r\n * @param engine define the engine to use\r\n * @returns a promise that resolves to the created TextRenderer instance\r\n */\r\n public static async CreateTextRendererAsync(font: FontAsset, engine: AbstractEngine) {\r\n if (!engine.getCaps().instancedArrays || !engine._features.supportSpriteInstancing) {\r\n throw new Error(\"Instanced arrays are required for MSDF text rendering.\");\r\n }\r\n\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n let vertex: string = \"\";\r\n let fragment: string = \"\";\r\n if (engine.isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n vertex = (await import(\"./webgpu/vertex\")).msdfVertexShader.shader;\r\n fragment = (await import(\"./webgpu/fragment\")).msdfFragmentShader.shader;\r\n } else {\r\n vertex = (await import(\"./webgl/vertex\")).msdfVertexShader.shader;\r\n fragment = (await import(\"./webgl/fragment\")).msdfFragmentShader.shader;\r\n }\r\n\r\n const textRenderer = new TextRenderer(engine, shaderLanguage, font);\r\n textRenderer._setShaders(vertex, fragment);\r\n\r\n return textRenderer;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"textRenderer.js","sourceRoot":"","sources":["../../../../dev/addons/src/msdfText/textRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,0CAA4B;AAE7C,OAAO,EAAE,SAAS,EAAE,6CAA+B;AAEnD,OAAO,EAAE,WAAW,EAAE,iDAAmC;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AsB;QAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,eAAe,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,uBAAuB,EAAE,CAAC;YACjF,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,cAAc,8BAAsB,CAAC;QACzC,IAAI,MAAM,GAAW,EAAE,CAAC;QACxB,IAAI,QAAQ,GAAW,EAAE,CAAC;QAC1B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAClB,cAAc,8BAAsB,CAAC;YACrC,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;YACnE,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;QAC7E,CAAC;aAAM,CAAC;YACJ,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAClE,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;QAC5E,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;QACpE,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAE3C,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import type { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Buffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { ThinEngine } from \"core/Engines/thinEngine\";\r\nimport { DrawWrapper } from \"core/Materials/drawWrapper\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { IDisposable } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { SdfTextParagraph } from \"./sdf/paragraph\";\r\nimport type { FontAsset } from \"./fontAsset\";\r\nimport type { ParagraphOptions } from \"./paragraphOptions\";\r\nimport { ThinMatrix } from \"core/Maths/ThinMaths/thinMath.matrix\";\r\nimport {\r\n CopyMatrixToArray,\r\n CopyMatrixToRef,\r\n IdentityMatrixToRef,\r\n InvertMatrixToRef,\r\n MultiplyMatricesToRef,\r\n ScalingMatrixToRef,\r\n TranslationMatrixToRef,\r\n} from \"core/Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { IColor4Like, IMatrixLike, IVector3Like } from \"core/Maths\";\r\n\r\n/**\r\n * Abstract Node class from Babylon.js\r\n */\r\nexport interface INodeLike {\r\n getWorldMatrix(): ThinMatrix;\r\n}\r\n\r\n/**\r\n * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique\r\n * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js\r\n * #6RLCWP#16\r\n * Star wars scroller: #6RLCWP#29\r\n * With metrics: #6RLCWP#35\r\n * Thickness: #IABMEZ#3\r\n * Solar system: #9YCDYC#9\r\n */\r\nexport class TextRenderer implements IDisposable {\r\n private readonly _useVAO: boolean = false;\r\n private _engine: AbstractEngine;\r\n private _shaderLanguage: ShaderLanguage;\r\n private _vertexBuffers: { [key: string]: VertexBuffer } = {};\r\n private _spriteBuffer: Nullable<Buffer>;\r\n private _worldBuffer: Nullable<Buffer>;\r\n private _uvBuffer: Nullable<Buffer>;\r\n private _drawWrapperBase: DrawWrapper;\r\n private _vertexArrayObject: WebGLVertexArrayObject;\r\n private _font: FontAsset;\r\n private _charMatrices = new Array<number>();\r\n private _charUvs = new Array<number>();\r\n private _isDirty = true;\r\n private _baseLine = 0;\r\n\r\n // Cache\r\n private _scalingMatrix = new ThinMatrix();\r\n private _fontScaleMatrix = new ThinMatrix();\r\n private _offsetMatrix = new ThinMatrix();\r\n private _translationMatrix = new ThinMatrix();\r\n private _baseMatrix = new ThinMatrix();\r\n private _scaledMatrix = new ThinMatrix();\r\n private _localMatrix = new ThinMatrix();\r\n private _finalMatrix = new ThinMatrix();\r\n private _lineMatrix = new ThinMatrix();\r\n private _parentWorldMatrix = new ThinMatrix();\r\n private _storedTranslation: IVector3Like = { x: 0, y: 0, z: 0 };\r\n\r\n /**\r\n * Gets or sets the color of the text\r\n */\r\n public color: IColor4Like = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\r\n\r\n /**\r\n * Gets or sets the thickness of the text (0 means as defined in the font)\r\n * Value must be between -0.5 and 0.5\r\n */\r\n public thicknessControl = 0;\r\n\r\n private _parent: Nullable<INodeLike> = null;\r\n\r\n /**\r\n * Gets or sets the parent of the text renderer\r\n */\r\n public get parent(): Nullable<INodeLike> {\r\n return this._parent;\r\n }\r\n\r\n public set parent(value: Nullable<INodeLike>) {\r\n this._parent = value;\r\n }\r\n\r\n /**\r\n * Gets or sets if the text is billboarded\r\n */\r\n public isBillboard = false;\r\n\r\n /**\r\n * Gets the number of characters in the text renderer\r\n */\r\n public get characterCount(): number {\r\n return this._charMatrices.length / 16;\r\n }\r\n\r\n private constructor(engine: AbstractEngine, shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL, font: FontAsset) {\r\n this._engine = engine;\r\n this._shaderLanguage = shaderLanguage;\r\n this._font = font;\r\n this._baseLine = font._font.common.lineHeight * font.scale;\r\n\r\n this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;\r\n\r\n // Main vertex buffer\r\n const spriteData = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);\r\n this._spriteBuffer = new Buffer(engine, spriteData, false, 2);\r\n this._vertexBuffers[\"offsets\"] = this._spriteBuffer.createVertexBuffer(\"offsets\", 0, 2);\r\n\r\n // Instances\r\n this._resizeBuffers(128);\r\n }\r\n\r\n private _resizeBuffers(capacity: number) {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n this._worldBuffer = new Buffer(this._engine, new Float32Array(capacity * 16), true, 16);\r\n this._vertexBuffers[\"world0\"] = this._worldBuffer.createVertexBuffer(\"world0\", 0, 4, 16, true);\r\n this._vertexBuffers[\"world1\"] = this._worldBuffer.createVertexBuffer(\"world1\", 4, 4, 16, true);\r\n this._vertexBuffers[\"world2\"] = this._worldBuffer.createVertexBuffer(\"world2\", 8, 4, 16, true);\r\n this._vertexBuffers[\"world3\"] = this._worldBuffer.createVertexBuffer(\"world3\", 12, 4, 16, true);\r\n\r\n this._uvBuffer = new Buffer(this._engine, new Float32Array(capacity * 4), true, 4);\r\n this._vertexBuffers[\"uvs\"] = this._uvBuffer.createVertexBuffer(\"uvs\", 0, 4, 4, true);\r\n }\r\n\r\n private _setShaders(vertex: string, fragment: string) {\r\n this._drawWrapperBase?.dispose();\r\n\r\n this._drawWrapperBase = new DrawWrapper(this._engine);\r\n\r\n if (this._drawWrapperBase.drawContext) {\r\n this._drawWrapperBase.drawContext.useInstancing = true;\r\n }\r\n\r\n const defines = \"\";\r\n\r\n this._drawWrapperBase.effect = this._engine.createEffect(\r\n {\r\n vertexSource: vertex,\r\n fragmentSource: fragment,\r\n },\r\n [\"offsets\", \"world0\", \"world1\", \"world2\", \"world3\", \"uvs\"],\r\n [\"parentWorld\", \"view\", \"projection\", \"uColor\", \"unitRange\", \"texelSize\", \"thickness\"],\r\n [\"fontAtlas\"],\r\n defines,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._shaderLanguage\r\n );\r\n\r\n this._drawWrapperBase.effect._refCount++;\r\n }\r\n\r\n /**\r\n * Add a paragraph of text to the renderer\r\n * @param text define the text to add\r\n * @param options define the options to use for the paragraph (optional)\r\n * @param worldMatrix define the world matrix to use for the paragraph (optional)\r\n */\r\n public addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: IMatrixLike) {\r\n const paragraph = new SdfTextParagraph(text, this._font, options);\r\n\r\n const fontScale = this._font.scale;\r\n\r\n const texWidth = this._font._font.common.scaleW;\r\n const texHeight = this._font._font.common.scaleH;\r\n const glyphs = paragraph.glyphs.filter((g) => g.char.page >= 0);\r\n\r\n let worldMatrixToUse = worldMatrix;\r\n\r\n if (!worldMatrixToUse) {\r\n const lineHeight = paragraph.lineHeight * fontScale;\r\n const lineOffset = (paragraph.lines.length * lineHeight) / 2;\r\n TranslationMatrixToRef(0, this._baseLine - lineOffset, 0, this._lineMatrix);\r\n worldMatrixToUse = this._lineMatrix;\r\n }\r\n\r\n ScalingMatrixToRef(fontScale, fontScale, 1.0, this._fontScaleMatrix);\r\n TranslationMatrixToRef(0.5, -0.5, 0, this._offsetMatrix);\r\n\r\n const charsUvsBase = this._charUvs.length;\r\n const matricesBase = this._charMatrices.length;\r\n glyphs.forEach((g, i) => {\r\n this._charUvs[charsUvsBase + i * 4 + 0] = g.char.x / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 1] = g.char.y / texHeight;\r\n this._charUvs[charsUvsBase + i * 4 + 2] = g.char.width / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 3] = g.char.height / texHeight;\r\n\r\n const x = g.x;\r\n const y = -g.y;\r\n\r\n ScalingMatrixToRef(g.char.width, g.char.height, 1.0, this._scalingMatrix);\r\n MultiplyMatricesToRef(this._offsetMatrix, this._scalingMatrix, this._baseMatrix);\r\n\r\n TranslationMatrixToRef(x * fontScale, y * fontScale, 0.0, this._translationMatrix);\r\n MultiplyMatricesToRef(this._baseMatrix, this._fontScaleMatrix, this._scaledMatrix);\r\n MultiplyMatricesToRef(this._scaledMatrix, this._translationMatrix, this._localMatrix);\r\n\r\n MultiplyMatricesToRef(this._localMatrix, worldMatrixToUse, this._finalMatrix);\r\n CopyMatrixToArray(this._finalMatrix, this._charMatrices, matricesBase + i * 16);\r\n });\r\n\r\n this._isDirty = true;\r\n\r\n this._baseLine -= paragraph.lineHeight * fontScale * paragraph.lines.length;\r\n }\r\n\r\n /**\r\n * Render the text using the provided view and projection matrices\r\n * @param viewMatrix define the view matrix to use\r\n * @param projectionMatrix define the projection matrix to use\r\n */\r\n public render(viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike): void {\r\n const drawWrapper = this._drawWrapperBase;\r\n\r\n const effect = drawWrapper.effect!;\r\n\r\n // Check\r\n if (!effect.isReady()) {\r\n return;\r\n }\r\n const engine = this._engine;\r\n\r\n engine.setState(false);\r\n engine.enableEffect(drawWrapper);\r\n\r\n if (this.isBillboard) {\r\n // We will only consider translation for parent to simplify computation\r\n // Save parent translation\r\n if (this._parent) {\r\n const pwm = this._parent.getWorldMatrix().asArray();\r\n this._storedTranslation.x = pwm[12];\r\n this._storedTranslation.y = pwm[13];\r\n this._storedTranslation.z = pwm[14];\r\n } else {\r\n this._storedTranslation.x = 0;\r\n this._storedTranslation.y = 0;\r\n this._storedTranslation.z = 0;\r\n }\r\n // Cancel camera rotation\r\n const baseM = this._baseMatrix.asArray();\r\n CopyMatrixToArray(viewMatrix, baseM);\r\n baseM[12] = 0;\r\n baseM[13] = 0;\r\n baseM[14] = 0;\r\n InvertMatrixToRef(this._baseMatrix, this._parentWorldMatrix);\r\n\r\n // Restore translation\r\n const pwm = this._parentWorldMatrix.asArray();\r\n pwm[12] = this._storedTranslation.x;\r\n pwm[13] = this._storedTranslation.y;\r\n pwm[14] = this._storedTranslation.z;\r\n } else {\r\n if (this._parent) {\r\n CopyMatrixToRef(this._parent.getWorldMatrix(), this._parentWorldMatrix);\r\n } else {\r\n IdentityMatrixToRef(this._parentWorldMatrix);\r\n }\r\n }\r\n\r\n effect.setMatrix(\"parentWorld\", this._parentWorldMatrix);\r\n effect.setMatrix(\"view\", viewMatrix);\r\n effect.setMatrix(\"projection\", projectionMatrix);\r\n\r\n // Texture\r\n const textureWidth = this._font._font.common.scaleW;\r\n const textureHeight = this._font._font.common.scaleW;\r\n const distanceRange = this._font._font.distanceField.distanceRange;\r\n\r\n effect.setTexture(\"fontAtlas\", this._font.textures[0]);\r\n effect.setFloat2(\"unitRange\", distanceRange / textureWidth, distanceRange / textureHeight);\r\n effect.setFloat2(\"texelSize\", 1.0 / textureWidth, 1.0 / textureHeight);\r\n effect.setDirectColor4(\"uColor\", this.color);\r\n effect.setFloat(\"thickness\", this.thicknessControl * 0.9);\r\n\r\n const instanceCount = this._charMatrices.length / 16;\r\n\r\n // Need update?\r\n if (this._isDirty) {\r\n this._isDirty = false;\r\n\r\n if (this._worldBuffer!.getBuffer()!.capacity / 4 < instanceCount * 16) {\r\n this._resizeBuffers(instanceCount);\r\n }\r\n\r\n this._worldBuffer!.update(this._charMatrices);\r\n this._uvBuffer!.update(this._charUvs);\r\n }\r\n\r\n if (this._useVAO) {\r\n if (!this._vertexArrayObject) {\r\n this._vertexArrayObject = (engine as ThinEngine).recordVertexArrayObject(this._vertexBuffers, null, effect);\r\n }\r\n (engine as ThinEngine).bindVertexArrayObject(this._vertexArrayObject, null);\r\n } else {\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, null, effect);\r\n }\r\n\r\n engine.setAlphaMode(Constants.ALPHA_COMBINE);\r\n\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, instanceCount);\r\n\r\n engine.unbindInstanceAttributes();\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n if (this._spriteBuffer) {\r\n this._spriteBuffer.dispose();\r\n this._spriteBuffer = null;\r\n }\r\n\r\n if (this._vertexArrayObject) {\r\n (this._engine as ThinEngine).releaseVertexArrayObject(this._vertexArrayObject);\r\n (<any>this._vertexArrayObject) = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new TextRenderer instance asynchronously\r\n * @param font define the font asset to use\r\n * @param engine define the engine to use\r\n * @returns a promise that resolves to the created TextRenderer instance\r\n */\r\n public static async CreateTextRendererAsync(font: FontAsset, engine: AbstractEngine) {\r\n if (!engine.getCaps().instancedArrays || !engine._features.supportSpriteInstancing) {\r\n throw new Error(\"Instanced arrays are required for MSDF text rendering.\");\r\n }\r\n\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n let vertex: string = \"\";\r\n let fragment: string = \"\";\r\n if (engine.isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n vertex = (await import(\"./webgpu/vertex\")).msdfVertexShader.shader;\r\n fragment = (await import(\"./webgpu/fragment\")).msdfFragmentShader.shader;\r\n } else {\r\n vertex = (await import(\"./webgl/vertex\")).msdfVertexShader.shader;\r\n fragment = (await import(\"./webgl/fragment\")).msdfFragmentShader.shader;\r\n }\r\n\r\n const textRenderer = new TextRenderer(engine, shaderLanguage, font);\r\n textRenderer._setShaders(vertex, fragment);\r\n\r\n return textRenderer;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/addons",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@babylonjs/core": "^8.8.
|
|
21
|
+
"@babylonjs/core": "^8.8.5",
|
|
22
22
|
"@dev/addons": "^1.0.0",
|
|
23
23
|
"@dev/build-tools": "^1.0.0"
|
|
24
24
|
},
|