babylonjs-addons 8.6.2 → 8.7.1

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/138.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";(("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS=("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS||[]).push([[138],{138:(e,n,t)=>{t.r(n),t.d(n,{msdfFragmentShader:()=>f});var f={name:"msdfFragmentShader",shader:"\nvar fontAtlas: texture_2d<f32>;\nvar fontAtlasSampler: sampler;\nuniform unitRange: vec2f;\nuniform texelSize: vec2f;\nuniform uColor: vec4f;\nuniform thickness: f32;\n\nvarying atlasUV: vec2f;\n\nfn median(msdf: vec3<f32>) -> f32 {\n let a = min(msdf.r, msdf.g);\n let b = max(msdf.r, msdf.g);\n return max(a, min(b, msdf.b));\n}\n\n@fragment\nfn main(input: FragmentInputs) -> FragmentOutputs {\n let uv = input.atlasUV;\n\n // Sample center and neighbors\n let sdfCenter = textureSample(fontAtlas, fontAtlasSampler, uv).rgb;\n let sdfLeft = textureSample(fontAtlas, fontAtlasSampler, uv - vec2<f32>(uniforms.texelSize.x, 0.0)).rgb;\n let sdfRight = textureSample(fontAtlas, fontAtlasSampler, uv + vec2<f32>(uniforms.texelSize.x, 0.0)).rgb;\n let sdfTop = textureSample(fontAtlas, fontAtlasSampler, uv - vec2<f32>(0.0, uniforms.texelSize.y)).rgb;\n let sdfBottom = textureSample(fontAtlas, fontAtlasSampler, uv + vec2<f32>(0.0, uniforms.texelSize.y)).rgb;\n\n let sdf = (sdfCenter + sdfLeft + sdfRight + sdfTop + sdfBottom) / 5.0;\n\n let dist = median(sdfCenter);\n\n // Estimate pixel range in screen space\n let dx = dpdx(uv);\n let dy = dpdy(uv);\n let screenTexSize = vec2<f32>(1.0) / vec2<f32>(length(dx), length(dy));\n let pxRange = max(0.5 * dot(uniforms.unitRange, screenTexSize), 1.0);\n\n let pxDist = pxRange * (dist - 0.5 + uniforms.thickness);\n let alpha = clamp(pxDist / length(dpdx(pxDist)) + 0.5, 0.0, 1.0);\n\n fragmentOutputs.color = vec4<f32>(uniforms.uColor.rgb, alpha * uniforms.uColor.a);\n}"}}}]);
2
+ //# sourceMappingURL=138.js.map
package/138.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"138.js","mappings":"2QACA,IA6CaA,EAAqB,CAAEC,KA7CvB,qBA6C6BC,OA5C3B,qjD","sources":["webpack://ADDONS/../../../dev/addons/src/msdfText/webgpu/fragment.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nconst name = \"msdfFragmentShader\";\r\nconst shader = `\r\nvar fontAtlas: texture_2d<f32>;\r\nvar fontAtlasSampler: sampler;\r\nuniform unitRange: vec2f;\r\nuniform texelSize: vec2f;\r\nuniform uColor: vec4f;\r\nuniform thickness: f32;\r\n\r\nvarying atlasUV: vec2f;\r\n\r\nfn median(msdf: vec3<f32>) -> f32 {\r\n let a = min(msdf.r, msdf.g);\r\n let b = max(msdf.r, msdf.g);\r\n return max(a, min(b, msdf.b));\r\n}\r\n\r\n@fragment\r\nfn main(input: FragmentInputs) -> FragmentOutputs {\r\n let uv = input.atlasUV;\r\n\r\n // Sample center and neighbors\r\n let sdfCenter = textureSample(fontAtlas, fontAtlasSampler, uv).rgb;\r\n let sdfLeft = textureSample(fontAtlas, fontAtlasSampler, uv - vec2<f32>(uniforms.texelSize.x, 0.0)).rgb;\r\n let sdfRight = textureSample(fontAtlas, fontAtlasSampler, uv + vec2<f32>(uniforms.texelSize.x, 0.0)).rgb;\r\n let sdfTop = textureSample(fontAtlas, fontAtlasSampler, uv - vec2<f32>(0.0, uniforms.texelSize.y)).rgb;\r\n let sdfBottom = textureSample(fontAtlas, fontAtlasSampler, uv + vec2<f32>(0.0, uniforms.texelSize.y)).rgb;\r\n\r\n let sdf = (sdfCenter + sdfLeft + sdfRight + sdfTop + sdfBottom) / 5.0;\r\n\r\n let dist = median(sdfCenter);\r\n\r\n // Estimate pixel range in screen space\r\n let dx = dpdx(uv);\r\n let dy = dpdy(uv);\r\n let screenTexSize = vec2<f32>(1.0) / vec2<f32>(length(dx), length(dy));\r\n let pxRange = max(0.5 * dot(uniforms.unitRange, screenTexSize), 1.0);\r\n\r\n let pxDist = pxRange * (dist - 0.5 + uniforms.thickness);\r\n let alpha = clamp(pxDist / length(dpdx(pxDist)) + 0.5, 0.0, 1.0);\r\n\r\n fragmentOutputs.color = vec4<f32>(uniforms.uColor.rgb, alpha * uniforms.uColor.a);\r\n}`;\r\n\r\n/** @internal */\r\nexport const msdfFragmentShader = { name, shader };\r\n"],"names":["msdfFragmentShader","name","shader"],"sourceRoot":""}
package/205.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";(("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS=("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS||[]).push([[205],{205:(e,n,t)=>{t.r(n),t.d(n,{msdfFragmentShader:()=>a});var a={name:"msdfFragmentShader",shader:"\n#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n\nuniform sampler2D fontAtlas;\nuniform vec2 unitRange;\nuniform vec2 texelSize;\nuniform vec4 uColor;\nuniform float thickness;\n\nvarying vec2 atlasUV;\n\nfloat median(vec3 msdf) {\n return max(min(msdf.r, msdf.g), min(max(msdf.r, msdf.g), msdf.b));\n}\n \nfloat screenPxRange(sampler2D tex) {\n vec2 screenTexSize = vec2(1.0) / fwidth(atlasUV);\n return max(0.5 * dot(unitRange, screenTexSize), 1.0);\n}\n\nvoid main(void)\n{\n vec3 sdfCenter = texture2D(fontAtlas, atlasUV).rgb;\n vec3 sdfLeft = texture2D(fontAtlas, atlasUV - vec2(texelSize.x, 0.0)).rgb;\n vec3 sdfRight = texture2D(fontAtlas, atlasUV + vec2(texelSize.x, 0.0)).rgb;\n vec3 sdfTop = texture2D(fontAtlas, atlasUV - vec2(0.0, texelSize.y)).rgb;\n vec3 sdfBottom = texture2D(fontAtlas, atlasUV + vec2(0.0, texelSize.y)).rgb;\n\n vec3 sdf = (sdfCenter + sdfLeft + sdfRight + sdfTop + sdfBottom) / 5.0;\n\n float dist = median(sdfCenter);\n\n float pxRange = screenPxRange(fontAtlas);\n float pxDist = pxRange * (dist - 0.5 + thickness);\n float alpha = clamp(pxDist / fwidth(pxDist) + 0.5, 0.0, 1.0);\n\n gl_FragColor = vec4(uColor.rgb, alpha * uColor.a);\n}"}}}]);
2
+ //# sourceMappingURL=205.js.map
package/205.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"205.js","mappings":"2QACA,IA2CaA,EAAqB,CAAEC,KA3CvB,qBA2C6BC,OA1C3B,guC","sources":["webpack://ADDONS/../../../dev/addons/src/msdfText/webgl/fragment.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nconst name = \"msdfFragmentShader\";\r\nconst shader = `\r\n#extension GL_OES_standard_derivatives : enable\r\n\r\nprecision highp float;\r\n\r\nuniform sampler2D fontAtlas;\r\nuniform vec2 unitRange;\r\nuniform vec2 texelSize;\r\nuniform vec4 uColor;\r\nuniform float thickness;\r\n\r\nvarying vec2 atlasUV;\r\n\r\nfloat median(vec3 msdf) {\r\n return max(min(msdf.r, msdf.g), min(max(msdf.r, msdf.g), msdf.b));\r\n}\r\n \r\nfloat screenPxRange(sampler2D tex) {\r\n vec2 screenTexSize = vec2(1.0) / fwidth(atlasUV);\r\n return max(0.5 * dot(unitRange, screenTexSize), 1.0);\r\n}\r\n\r\nvoid main(void)\r\n{\r\n vec3 sdfCenter = texture2D(fontAtlas, atlasUV).rgb;\r\n vec3 sdfLeft = texture2D(fontAtlas, atlasUV - vec2(texelSize.x, 0.0)).rgb;\r\n vec3 sdfRight = texture2D(fontAtlas, atlasUV + vec2(texelSize.x, 0.0)).rgb;\r\n vec3 sdfTop = texture2D(fontAtlas, atlasUV - vec2(0.0, texelSize.y)).rgb;\r\n vec3 sdfBottom = texture2D(fontAtlas, atlasUV + vec2(0.0, texelSize.y)).rgb;\r\n\r\n vec3 sdf = (sdfCenter + sdfLeft + sdfRight + sdfTop + sdfBottom) / 5.0;\r\n\r\n float dist = median(sdfCenter);\r\n\r\n float pxRange = screenPxRange(fontAtlas);\r\n float pxDist = pxRange * (dist - 0.5 + thickness);\r\n float alpha = clamp(pxDist / fwidth(pxDist) + 0.5, 0.0, 1.0);\r\n\r\n gl_FragColor = vec4(uColor.rgb, alpha * uColor.a);\r\n}`;\r\n\r\n/** @internal */\r\nexport const msdfFragmentShader = { name, shader };\r\n"],"names":["msdfFragmentShader","name","shader"],"sourceRoot":""}
package/315.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";(("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS=("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS||[]).push([[315],{315:(e,t,n)=>{n.r(t),n.d(t,{msdfVertexShader:()=>o});var o={name:"msdfVertexShader",shader:"\nattribute vec2 offsets;\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\nattribute vec4 uvs;\n\nuniform mat4 parentWorld;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 atlasUV;\n\nvoid main(void) {\n mat4 world = mat4(world0, world1, world2, world3);\n vec3 viewPos = (view * parentWorld * world * vec4(offsets.xy - vec2(0.5, 0.5), 0., 1.0)).xyz; \n gl_Position = projection * vec4(viewPos,1.0); \n atlasUV = vec2(uvs.x + offsets.x * uvs.z, uvs.y + (1.0 - offsets.y) * uvs.w);\n}"}}}]);
2
+ //# sourceMappingURL=315.js.map
package/315.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"315.js","mappings":"yQACA,IAuBaA,EAAmB,CAAEC,KAvBrB,mBAuB2BC,OAtBzB,ijB","sources":["webpack://ADDONS/../../../dev/addons/src/msdfText/webgl/vertex.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nconst name = \"msdfVertexShader\";\r\nconst shader = `\r\nattribute vec2 offsets;\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\nattribute vec4 uvs;\r\n\r\nuniform mat4 parentWorld;\r\nuniform mat4 view;\r\nuniform mat4 projection;\r\n\r\nvarying vec2 atlasUV;\r\n\r\nvoid main(void) {\r\n mat4 world = mat4(world0, world1, world2, world3);\r\n vec3 viewPos = (view * parentWorld * world * vec4(offsets.xy - vec2(0.5, 0.5), 0., 1.0)).xyz; \r\n gl_Position = projection * vec4(viewPos,1.0); \r\n atlasUV = vec2(uvs.x + offsets.x * uvs.z, uvs.y + (1.0 - offsets.y) * uvs.w);\r\n}`;\r\n\r\n/** @internal */\r\nexport const msdfVertexShader = { name, shader };\r\n"],"names":["msdfVertexShader","name","shader"],"sourceRoot":""}
package/372.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";(("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS=("undefined"!=typeof self?self:"undefined"!=typeof global?global:this).webpackChunkADDONS||[]).push([[372],{372:(t,e,n)=>{n.r(e),n.d(e,{msdfVertexShader:()=>f});var f={name:"msdfVertexShader",shader:"\nattribute offsets: vec2f;\nattribute world0: vec4f;\nattribute world1: vec4f;\nattribute world2: vec4f;\nattribute world3: vec4f;\nattribute uvs: vec4f;\n\nuniform parentWorld: mat4x4f;\nuniform view: mat4x4f;\nuniform projection: mat4x4f;\n\nvarying atlasUV: vec2f;\n\n@vertex\nfn main(input: VertexInputs) -> FragmentInputs {\n let world = mat4x4<f32>(input.world0, input.world1, input.world2, input.world3);\n let localOffset = vec4<f32>(input.offsets - vec2<f32>(0.5, 0.5), 0.0, 1.0);\n let viewPos = (uniforms.view * uniforms.parentWorld * world * localOffset).xyz;\n vertexOutputs.position = uniforms.projection * vec4<f32>(viewPos, 1.0);\n\n vertexOutputs.atlasUV = vec2<f32>(\n input.uvs.x + input.offsets.x * input.uvs.z,\n input.uvs.y + (1.0 - input.offsets.y) * input.uvs.w\n );\n}"}}}]);
2
+ //# sourceMappingURL=372.js.map
package/372.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"372.js","mappings":"yQACA,IA6BaA,EAAmB,CAAEC,KA7BrB,mBA6B2BC,OA5BzB,6zB","sources":["webpack://ADDONS/../../../dev/addons/src/msdfText/webgpu/vertex.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nconst name = \"msdfVertexShader\";\r\nconst shader = `\r\nattribute offsets: vec2f;\r\nattribute world0: vec4f;\r\nattribute world1: vec4f;\r\nattribute world2: vec4f;\r\nattribute world3: vec4f;\r\nattribute uvs: vec4f;\r\n\r\nuniform parentWorld: mat4x4f;\r\nuniform view: mat4x4f;\r\nuniform projection: mat4x4f;\r\n\r\nvarying atlasUV: vec2f;\r\n\r\n@vertex\r\nfn main(input: VertexInputs) -> FragmentInputs {\r\n let world = mat4x4<f32>(input.world0, input.world1, input.world2, input.world3);\r\n let localOffset = vec4<f32>(input.offsets - vec2<f32>(0.5, 0.5), 0.0, 1.0);\r\n let viewPos = (uniforms.view * uniforms.parentWorld * world * localOffset).xyz;\r\n vertexOutputs.position = uniforms.projection * vec4<f32>(viewPos, 1.0);\r\n\r\n vertexOutputs.atlasUV = vec2<f32>(\r\n input.uvs.x + input.offsets.x * input.uvs.z,\r\n input.uvs.y + (1.0 - input.offsets.y) * input.uvs.w\r\n );\r\n}`;\r\n\r\n/** @internal */\r\nexport const msdfVertexShader = { name, shader };\r\n"],"names":["msdfVertexShader","name","shader"],"sourceRoot":""}
@@ -2,6 +2,358 @@
2
2
  declare module ADDONS {
3
3
 
4
4
 
5
+ /**
6
+ * Abstract Node class from Babylon.js
7
+ */
8
+ export interface INodeLike {
9
+ getWorldMatrix(): BABYLON.ThinMatrix;
10
+ }
11
+ /**
12
+ * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
13
+ * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
14
+ * #6RLCWP#16
15
+ * Star wars scroller: #6RLCWP#29
16
+ * With metrics: #6RLCWP#35
17
+ * Thickness: #IABMEZ#3
18
+ * Solar system: #9YCDYC#9
19
+ */
20
+ export class TextRenderer implements BABYLON.IDisposable {
21
+ private readonly _useVAO;
22
+ private _engine;
23
+ private _shaderLanguage;
24
+ private _vertexBuffers;
25
+ private _spriteBuffer;
26
+ private _worldBuffer;
27
+ private _uvBuffer;
28
+ private _drawWrapperBase;
29
+ private _vertexArrayObject;
30
+ private _font;
31
+ private _charMatrices;
32
+ private _charUvs;
33
+ private _isDirty;
34
+ private _baseLine;
35
+ private _scalingMatrix;
36
+ private _fontScaleMatrix;
37
+ private _offsetMatrix;
38
+ private _translationMatrix;
39
+ private _baseMatrix;
40
+ private _scaledMatrix;
41
+ private _localMatrix;
42
+ private _finalMatrix;
43
+ private _lineMatrix;
44
+ private _parentWorldMatrix;
45
+ private _storedTranslation;
46
+ /**
47
+ * Gets or sets the color of the text
48
+ */
49
+ color: BABYLON.IColor4Like;
50
+ /**
51
+ * Gets or sets the thickness of the text (0 means as defined in the font)
52
+ * Value must be between -0.5 and 0.5
53
+ */
54
+ thicknessControl: number;
55
+ private _parent;
56
+ /**
57
+ * Gets or sets the parent of the text renderer
58
+ */
59
+ get parent(): BABYLON.Nullable<INodeLike>;
60
+ set parent(value: BABYLON.Nullable<INodeLike>);
61
+ /**
62
+ * Gets or sets if the text is billboarded
63
+ */
64
+ isBillboard: boolean;
65
+ /**
66
+ * Gets the number of characters in the text renderer
67
+ */
68
+ get characterCount(): number;
69
+ private constructor();
70
+ private _resizeBuffers;
71
+ private _setShaders;
72
+ /**
73
+ * Add a paragraph of text to the renderer
74
+ * @param text define the text to add
75
+ * @param options define the options to use for the paragraph (optional)
76
+ * @param worldMatrix define the world matrix to use for the paragraph (optional)
77
+ */
78
+ addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: BABYLON.IMatrixLike): void;
79
+ /**
80
+ * Render the text using the provided view and projection matrices
81
+ * @param viewMatrix define the view matrix to use
82
+ * @param projectionMatrix define the projection matrix to use
83
+ */
84
+ render(viewMatrix: BABYLON.IMatrixLike, projectionMatrix: BABYLON.IMatrixLike): void;
85
+ /**
86
+ * Release associated resources
87
+ */
88
+ dispose(): void;
89
+ /**
90
+ * Creates a new TextRenderer instance asynchronously
91
+ * @param font define the font asset to use
92
+ * @param engine define the engine to use
93
+ * @returns a promise that resolves to the created TextRenderer instance
94
+ */
95
+ static CreateTextRendererAsync(font: FontAsset, engine: BABYLON.AbstractEngine): Promise<TextRenderer>;
96
+ }
97
+
98
+
99
+ /** @internal */
100
+ export type ParagraphOptions = {
101
+ maxWidth: number;
102
+ lineHeight: number;
103
+ letterSpacing: number;
104
+ tabSize: number;
105
+ whiteSpace: "pre-line";
106
+ textAlign: "left" | "right" | "center";
107
+ translate: BABYLON.Vector2 | undefined;
108
+ };
109
+ /** @internal */
110
+ export var DefaultParagraphOptions: ParagraphOptions;
111
+
112
+
113
+
114
+
115
+ /**
116
+ * Class representing a font asset for SDF (Signed Distance Field) rendering.
117
+ */
118
+ export class FontAsset {
119
+ private readonly _chars;
120
+ private readonly _charsRegex;
121
+ private readonly _kernings;
122
+ /** @internal */
123
+ readonly _font: SdfFont;
124
+ /**
125
+ * Gets the font scale value
126
+ */
127
+ readonly scale: number;
128
+ /**
129
+ * Gets the list of used textures
130
+ */
131
+ readonly textures: BABYLON.Texture[];
132
+ /**
133
+ * Creates a new FontAsset instance.
134
+ * @param definitionData defines the font data in JSON format.
135
+ * @param textureUrl defines the url of the texture to use for the font.
136
+ */
137
+ constructor(definitionData: string, textureUrl: string);
138
+ private _updateFallbacks;
139
+ /** @internal */
140
+ _getChar(charCode: number): BMFontChar;
141
+ /** @internal */
142
+ _getKerning(first: number, second: number): number;
143
+ /** @internal */
144
+ _unsupportedChars(text: string): string;
145
+ }
146
+
147
+
148
+ /** @internal */
149
+ export var msdfVertexShader: {
150
+ name: string;
151
+ shader: string;
152
+ };
153
+
154
+
155
+ /** @internal */
156
+ export var msdfFragmentShader: {
157
+ name: string;
158
+ shader: string;
159
+ };
160
+
161
+
162
+ /** @internal */
163
+ export var msdfVertexShader: {
164
+ name: string;
165
+ shader: string;
166
+ };
167
+
168
+
169
+ /** @internal */
170
+ export var msdfFragmentShader: {
171
+ name: string;
172
+ shader: string;
173
+ };
174
+
175
+
176
+ /** @internal */
177
+ export class SdfTextParagraph {
178
+ readonly text: string;
179
+ readonly fontAsset: FontAsset;
180
+ readonly options: ParagraphOptions;
181
+ get lineHeight(): number;
182
+ readonly paragraph: string;
183
+ readonly lines: SdfTextLine[];
184
+ readonly width: number;
185
+ readonly height: number;
186
+ readonly glyphs: SdfGlyph[];
187
+ constructor(text: string, fontAsset: FontAsset, options?: Partial<ParagraphOptions>);
188
+ private _computeMetrics;
189
+ private _breakLines;
190
+ private _collapse;
191
+ private _wrap;
192
+ }
193
+
194
+
195
+ /** @internal */
196
+ export type SdfTextLine = {
197
+ text: string;
198
+ glyphs: SdfGlyph[];
199
+ start: number;
200
+ end: number;
201
+ width: number;
202
+ };
203
+
204
+
205
+ /** @internal */
206
+ export type SdfGlyph = {
207
+ char: BMFontChar;
208
+ /** index of the line */
209
+ line: number;
210
+ /** position within the line */
211
+ position: number;
212
+ x: number;
213
+ y: number;
214
+ };
215
+
216
+
217
+ export type SdfFontDistanceField = {
218
+ fieldType: "sdf" | "msdf";
219
+ distanceRange: number;
220
+ };
221
+ export type SdfFont = BMFont & {
222
+ distanceField: SdfFontDistanceField;
223
+ };
224
+
225
+
226
+ /**
227
+ * Holds information on how the font was generated.
228
+ */
229
+ export type BMFontInfo = {
230
+ /** The name of the font */
231
+ face: string;
232
+ /** The size of the font */
233
+ size: number;
234
+ /** The font is bold */
235
+ bold: number;
236
+ /** The font is italic */
237
+ italic: number;
238
+ /** The charset of the font */
239
+ charset: string[];
240
+ /** The charset is unicode */
241
+ unicode: number;
242
+ /** The font height stretch in percentage. 100% means no stretch. */
243
+ stretchH: number;
244
+ /** Set to 1 if smoothing was turned on. */
245
+ smooth: number;
246
+ /** The supersampling level used. 1 means no supersampling was used. */
247
+ aa: number;
248
+ /** The padding for each character (up, right, down, left). */
249
+ padding: [number, number, number, number];
250
+ /** The spacing for each character (horizontal, vertical). */
251
+ spacing: [number, number];
252
+ /**
253
+ * The outline thickness for the characters.
254
+ *
255
+ * @remark missing in msdf-bmfont-xml
256
+ */
257
+ outline?: number;
258
+ };
259
+ /**
260
+ * Holds information common to all characters.
261
+ */
262
+ export type BMFontCommon = {
263
+ /** Distance in pixels between each line of text */
264
+ lineHeight: number;
265
+ /** The number of pixels from the absolute top of the line to the base of the characters */
266
+ base: number;
267
+ /** The width of the texture, normally used to scale the x pos of the character image */
268
+ scaleW: number;
269
+ /** The height of the texture, normally used to scale the y pos of the character image */
270
+ scaleH: number;
271
+ /** The number of pages in the font */
272
+ pages: number;
273
+ /** Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel. */
274
+ packed: number;
275
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
276
+ alphaChnl: number;
277
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
278
+ redChnl: number;
279
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
280
+ greenChnl: number;
281
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
282
+ blueChnl: number;
283
+ };
284
+ /** Name of a texture file. There is one for each page in the font. */
285
+ export type BMFontPages = {
286
+ [id: number]: string;
287
+ } & Array<string>;
288
+ /**
289
+ * Describes a single character in the font
290
+ */
291
+ export type BMFontChar = {
292
+ /** Character id (charCode) */
293
+ id: number;
294
+ /** Left position of the character image in the texture. */
295
+ x: number;
296
+ /** Right position of the character image in the texture */
297
+ y: number;
298
+ /** Width of the chracter image in the texture */
299
+ width: number;
300
+ /** Height of the chracter image in the texture */
301
+ height: number;
302
+ /** Horizontal offset to be applied on screen */
303
+ xoffset: number;
304
+ /** Vertical offset to be applied on screen */
305
+ yoffset: number;
306
+ /** Horizontal advance after the character */
307
+ xadvance: number;
308
+ /** Page index where the character image is found */
309
+ page: number;
310
+ /** Texture channel where the chracter image is found
311
+ * - 1 = blue
312
+ * - 2 = green
313
+ * - 3 = red
314
+ * - 8 = alpha
315
+ * - 15 = all channels
316
+ */
317
+ chnl: number;
318
+ } & BMFontCharExtra;
319
+ /**
320
+ * additional context from msdf-bmfont-xml
321
+ */
322
+ export type BMFontCharExtra = {
323
+ /** index of opentype.js glyph */
324
+ index: number;
325
+ /** actual character*/
326
+ char: string;
327
+ };
328
+ /**
329
+ * The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.
330
+ */
331
+ export type BMFontKerning = {
332
+ /** The first character id. */
333
+ first: number;
334
+ /** The second character id. */
335
+ second: number;
336
+ /** How much the x position should be adjusted when drawing the second character immediately following the first. */
337
+ amount: number;
338
+ };
339
+ /**
340
+ * Compatible with [msdf-bmfont-xml](https://github.com/soimy/msdf-bmfont-xml)
341
+ * @see https://www.angelcode.com/products/bmfont/doc/file_format.html
342
+ */
343
+ export type BMFont = {
344
+ /** {@inheritDoc BMFontInfo} */
345
+ info: BMFontInfo;
346
+ /** {@inheritDoc BMFontCommon} */
347
+ common: BMFontCommon;
348
+ /** {@inheritDoc BMFontPages} */
349
+ pages: BMFontPages;
350
+ /** {@inheritDoc BMFontChar} */
351
+ chars: BMFontChar[];
352
+ /** {@inheritDoc BMFontKerning} */
353
+ kernings: BMFontKerning[];
354
+ };
355
+
356
+
5
357
  /**
6
358
  * BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
7
359
  * and receive pointer events directly. It will register the capture triggers and negotiate the capture and