meshwriter-cudu 3.0.0

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.
Files changed (81) hide show
  1. package/LICENSE.md +11 -0
  2. package/README.md +349 -0
  3. package/dist/fonts/comic-sans.d.ts +1105 -0
  4. package/dist/fonts/helvetica.d.ts +1208 -0
  5. package/dist/fonts/hiruko-pro.d.ts +658 -0
  6. package/dist/fonts/jura.d.ts +750 -0
  7. package/dist/fonts/webgl-dings.d.ts +109 -0
  8. package/dist/index.d.ts +295 -0
  9. package/dist/meshwriter.cjs.js +2645 -0
  10. package/dist/meshwriter.cjs.js.map +1 -0
  11. package/dist/meshwriter.esm.js +2606 -0
  12. package/dist/meshwriter.esm.js.map +1 -0
  13. package/dist/meshwriter.min.js +2 -0
  14. package/dist/meshwriter.min.js.map +1 -0
  15. package/dist/meshwriter.umd.js +7146 -0
  16. package/dist/meshwriter.umd.js.map +1 -0
  17. package/dist/src/babylonImports.d.ts +11 -0
  18. package/dist/src/bakedFontLoader.d.ts +43 -0
  19. package/dist/src/colorContrast.d.ts +117 -0
  20. package/dist/src/csg.d.ts +55 -0
  21. package/dist/src/curves.d.ts +20 -0
  22. package/dist/src/fogPlugin.d.ts +32 -0
  23. package/dist/src/fontCompression.d.ts +12 -0
  24. package/dist/src/fontRegistry.d.ts +54 -0
  25. package/dist/src/index.d.ts +47 -0
  26. package/dist/src/letterMesh.d.ts +46 -0
  27. package/dist/src/material.d.ts +34 -0
  28. package/dist/src/meshSplitter.d.ts +10 -0
  29. package/dist/src/meshwriter.d.ts +46 -0
  30. package/dist/src/sps.d.ts +27 -0
  31. package/dist/src/umd-entry.d.ts +3 -0
  32. package/dist/src/utils.d.ts +12 -0
  33. package/dist/src/variableFontCache.d.ts +56 -0
  34. package/dist/src/variableFontConverter.d.ts +21 -0
  35. package/dist/src/variableFontLoader.d.ts +99 -0
  36. package/fonts/Figure1.png +0 -0
  37. package/fonts/LICENSE-OFL.txt +93 -0
  38. package/fonts/README.md +174 -0
  39. package/fonts/atkinson-hyperlegible-next.d.ts +8 -0
  40. package/fonts/atkinson-hyperlegible-next.js +6576 -0
  41. package/fonts/atkinson-hyperlegible.js +3668 -0
  42. package/fonts/baked/atkinson-hyperlegible-next-200.json +1 -0
  43. package/fonts/baked/atkinson-hyperlegible-next-250.json +1 -0
  44. package/fonts/baked/atkinson-hyperlegible-next-300.json +1 -0
  45. package/fonts/baked/atkinson-hyperlegible-next-350.json +1 -0
  46. package/fonts/baked/atkinson-hyperlegible-next-400.json +1 -0
  47. package/fonts/baked/atkinson-hyperlegible-next-450.json +1 -0
  48. package/fonts/baked/atkinson-hyperlegible-next-500.json +1 -0
  49. package/fonts/baked/atkinson-hyperlegible-next-550.json +1 -0
  50. package/fonts/baked/atkinson-hyperlegible-next-600.json +1 -0
  51. package/fonts/baked/atkinson-hyperlegible-next-650.json +1 -0
  52. package/fonts/baked/atkinson-hyperlegible-next-700.json +1 -0
  53. package/fonts/baked/atkinson-hyperlegible-next-750.json +1 -0
  54. package/fonts/baked/atkinson-hyperlegible-next-800.json +1 -0
  55. package/fonts/baked/manifest.json +41 -0
  56. package/fonts/comic-sans.js +1532 -0
  57. package/fonts/helvetica.js +1695 -0
  58. package/fonts/hiruko-pro.js +838 -0
  59. package/fonts/index.js +16 -0
  60. package/fonts/jura.js +994 -0
  61. package/fonts/variable/atkinson-hyperlegible-next-variable.ttf +0 -0
  62. package/fonts/webgl-dings.js +113 -0
  63. package/package.json +76 -0
  64. package/src/babylonImports.js +29 -0
  65. package/src/bakedFontLoader.js +125 -0
  66. package/src/colorContrast.js +528 -0
  67. package/src/csg.js +220 -0
  68. package/src/curves.js +67 -0
  69. package/src/fogPlugin.js +98 -0
  70. package/src/fontCompression.js +141 -0
  71. package/src/fontRegistry.js +98 -0
  72. package/src/globals.d.ts +20 -0
  73. package/src/index.js +136 -0
  74. package/src/letterMesh.js +417 -0
  75. package/src/material.js +103 -0
  76. package/src/meshSplitter.js +337 -0
  77. package/src/meshwriter.js +303 -0
  78. package/src/sps.js +106 -0
  79. package/src/types.d.ts +551 -0
  80. package/src/umd-entry.js +130 -0
  81. package/src/utils.js +57 -0
@@ -0,0 +1,11 @@
1
+ export { Color3 } from "@babylonjs/core/Maths/math.color";
2
+ export { Mesh } from "@babylonjs/core/Meshes/mesh";
3
+ export { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData";
4
+ export { PolygonMeshBuilder } from "@babylonjs/core/Meshes/polygonMesh";
5
+ export { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial";
6
+ export { MaterialPluginBase } from "@babylonjs/core/Materials/materialPluginBase";
7
+ export { SolidParticleSystem } from "@babylonjs/core/Particles/solidParticleSystem";
8
+ export { CSG } from "@babylonjs/core/Meshes/csg";
9
+ export { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
10
+ export { Path2, Curve3 } from "@babylonjs/core/Maths/math.path";
11
+ export { CSG2, InitializeCSG2Async, IsCSG2Ready } from "@babylonjs/core/Meshes/csg2";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * MeshWriter Baked Font Loader
3
+ * Loads pre-baked FontSpec JSON files at runtime.
4
+ * Zero dependencies - just fetch and use.
5
+ */
6
+ /**
7
+ * Load a pre-baked font from a JSON file
8
+ * @param {string} url - URL to the baked FontSpec JSON file
9
+ * @returns {Promise<object>} - FontSpec object ready for use with MeshWriter
10
+ *
11
+ * @example
12
+ * const fontSpec = await loadBakedFont('/fonts/baked/atkinson-hyperlegible-next-400.json');
13
+ * registerFont('Atkinson400', fontSpec);
14
+ */
15
+ export function loadBakedFont(url: string): Promise<object>;
16
+ /**
17
+ * Load multiple pre-baked weights from a manifest
18
+ * @param {string} manifestUrl - URL to the manifest.json file
19
+ * @param {number[]} [weights] - Specific weights to load (loads all if omitted)
20
+ * @returns {Promise<Map<number, object>>} - Map of weight -> FontSpec
21
+ *
22
+ * @example
23
+ * const fonts = await loadBakedFontsFromManifest('/fonts/baked/manifest.json', [400, 450]);
24
+ * const fontSpec = fonts.get(400);
25
+ */
26
+ export function loadBakedFontsFromManifest(manifestUrl: string, weights?: number[]): Promise<Map<number, object>>;
27
+ /**
28
+ * Find the nearest available weight from a set of baked weights
29
+ * @param {number} targetWeight - Desired weight
30
+ * @param {number[]} availableWeights - Array of available weights
31
+ * @returns {number} - Nearest available weight
32
+ *
33
+ * @example
34
+ * const nearest = findNearestWeight(425, [400, 450, 500]);
35
+ * // Returns 450 (closest to 425)
36
+ */
37
+ export function findNearestWeight(targetWeight: number, availableWeights: number[]): number;
38
+ /**
39
+ * Get manifest info without loading fonts
40
+ * @param {string} manifestUrl - URL to the manifest.json file
41
+ * @returns {Promise<object>} - Manifest object with fontName, weights, etc.
42
+ */
43
+ export function getBakedFontManifest(manifestUrl: string): Promise<object>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Color Contrast Utilities for WCAG Compliance
3
+ * Provides color manipulation for dyslexia accessibility
4
+ */
5
+ /**
6
+ * Convert hex color string to RGB object (0-1 range)
7
+ * @param {string} hex - Hex color string (e.g., "#FF0000" or "FF0000")
8
+ * @returns {{r: number, g: number, b: number}}
9
+ */
10
+ export function hexToRgb(hex: string): {
11
+ r: number;
12
+ g: number;
13
+ b: number;
14
+ };
15
+ /**
16
+ * Convert RGB object (0-1 range) to hex color string
17
+ * @param {{r: number, g: number, b: number}} rgb
18
+ * @returns {string}
19
+ */
20
+ export function rgbToHex(rgb: {
21
+ r: number;
22
+ g: number;
23
+ b: number;
24
+ }): string;
25
+ /**
26
+ * Convert RGB to HSL
27
+ * @param {number} r - Red (0-1)
28
+ * @param {number} g - Green (0-1)
29
+ * @param {number} b - Blue (0-1)
30
+ * @returns {{h: number, s: number, l: number}} - h in degrees (0-360), s and l in 0-1
31
+ */
32
+ export function rgbToHsl(r: number, g: number, b: number): {
33
+ h: number;
34
+ s: number;
35
+ l: number;
36
+ };
37
+ /**
38
+ * Convert HSL to RGB
39
+ * @param {number} h - Hue in degrees (0-360)
40
+ * @param {number} s - Saturation (0-1)
41
+ * @param {number} l - Lightness (0-1)
42
+ * @returns {{r: number, g: number, b: number}}
43
+ */
44
+ export function hslToRgb(h: number, s: number, l: number): {
45
+ r: number;
46
+ g: number;
47
+ b: number;
48
+ };
49
+ /**
50
+ * Calculate relative luminance per WCAG 2.1
51
+ * @param {number} r - Red (0-1)
52
+ * @param {number} g - Green (0-1)
53
+ * @param {number} b - Blue (0-1)
54
+ * @returns {number} - Relative luminance (0-1)
55
+ */
56
+ export function relativeLuminance(r: number, g: number, b: number): number;
57
+ /**
58
+ * Calculate WCAG contrast ratio between two luminance values
59
+ * @param {number} L1 - Luminance of first color (0-1)
60
+ * @param {number} L2 - Luminance of second color (0-1)
61
+ * @returns {number} - Contrast ratio (1-21)
62
+ */
63
+ export function contrastRatio(L1: number, L2: number): number;
64
+ /**
65
+ * Auto-derive edge colors (diffuse/ambient) from emissive color
66
+ * Creates high-contrast edges for text legibility
67
+ *
68
+ * INVERTED APPROACH: Since emissive adds to all surfaces equally,
69
+ * we flip the strategy - put bright color in diffuse (shows on lit surfaces)
70
+ * and dark color in emissive (base for unlit surfaces).
71
+ * Returns modified emissive along with diffuse/ambient.
72
+ *
73
+ * @param {string} emissiveHex - Hex color string for desired face color
74
+ * @param {number} [targetContrast=4.5] - Target WCAG contrast ratio
75
+ * @returns {{diffuse: string, ambient: string, emissive: string}}
76
+ */
77
+ export function deriveEdgeColors(emissiveHex: string, targetContrast?: number): {
78
+ diffuse: string;
79
+ ambient: string;
80
+ emissive: string;
81
+ };
82
+ /**
83
+ * Adjust colors to achieve WCAG contrast while preserving user intent
84
+ * Priority: prefer edge modifications over face modifications
85
+ *
86
+ * @param {object} colors - User-provided colors
87
+ * @param {string} colors.emissive - Face color (hex)
88
+ * @param {string} colors.diffuse - Edge lit color (hex)
89
+ * @param {string} [colors.ambient] - Edge shadow color (hex)
90
+ * @param {object} [options]
91
+ * @param {number} [options.targetContrast=4.5] - Target contrast ratio
92
+ * @param {number} [options.edgeRange=0.4] - Max edge modification (0-1)
93
+ * @param {number} [options.faceRange=0.1] - Max face modification (0-1)
94
+ * @param {boolean} [options.allowHueShift=true] - Allow hue modifications
95
+ * @returns {{emissive: string, diffuse: string, ambient: string, achieved: number}}
96
+ */
97
+ export function adjustForContrast(colors: {
98
+ emissive: string;
99
+ diffuse: string;
100
+ ambient?: string;
101
+ }, options?: {
102
+ targetContrast?: number;
103
+ edgeRange?: number;
104
+ faceRange?: number;
105
+ allowHueShift?: boolean;
106
+ }): {
107
+ emissive: string;
108
+ diffuse: string;
109
+ ambient: string;
110
+ achieved: number;
111
+ };
112
+ export namespace CONTRAST_LEVELS {
113
+ let AA_NORMAL: number;
114
+ let AA_LARGE: number;
115
+ let AAA_NORMAL: number;
116
+ let AAA_LARGE: number;
117
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Initialize CSG module with Babylon.js CSG classes
3
+ * Must be called before using any CSG functionality
4
+ * @param {Object} babylon - Object containing CSG, CSG2, InitializeCSG2Async, IsCSG2Ready
5
+ */
6
+ export function initCSGModule(babylon: any): void;
7
+ /**
8
+ * Detect which CSG implementation is available
9
+ * @returns {'CSG2'|'CSG'|null}
10
+ */
11
+ export function detectCSGVersion(): "CSG2" | "CSG" | null;
12
+ /**
13
+ * Mark CSG as ready and notify all listeners
14
+ */
15
+ export function markCSGInitialized(): void;
16
+ /**
17
+ * Check if CSG is ready for use
18
+ * @returns {boolean}
19
+ */
20
+ export function isCSGReady(): boolean;
21
+ /**
22
+ * Initialize CSG2 asynchronously
23
+ * @returns {Promise<void>}
24
+ */
25
+ export function initializeCSG2(): Promise<void>;
26
+ /**
27
+ * Get the current CSG version being used
28
+ * @returns {'CSG2'|'CSG'|null}
29
+ */
30
+ export function getCSGVersion(): "CSG2" | "CSG" | null;
31
+ /**
32
+ * Set an external CSG2 initializer function
33
+ * @param {Function} fn - Async function that initializes CSG2
34
+ */
35
+ export function setCSGInitializer(fn: Function): void;
36
+ /**
37
+ * Set an external CSG2 ready check function
38
+ * @param {Function} fn - Function that returns true when CSG2 is ready
39
+ */
40
+ export function setCSGReadyCheck(fn: Function): void;
41
+ /**
42
+ * Register a callback to be called when CSG is ready
43
+ * If CSG is already ready, callback is called immediately
44
+ * @param {Function} listener
45
+ */
46
+ export function onCSGReady(listener: Function): void;
47
+ /**
48
+ * Get the CSG library to use for operations
49
+ * @returns {Object} - CSG or CSG2 class
50
+ */
51
+ export function getCSGLib(): any;
52
+ export let CSG: typeof BabylonCSG;
53
+ export let CSG2: typeof BabylonCSG2;
54
+ import { CSG as BabylonCSG } from './babylonImports.js';
55
+ import { CSG2 as BabylonCSG2 } from './babylonImports.js';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Install optimized curve methods on Path2 prototype
3
+ * Must be called after Babylon.js is loaded
4
+ */
5
+ export function installCurveExtensions(): void;
6
+ /**
7
+ * Extended Path2 interface with MeshWriter curve methods
8
+ * @typedef {Object} Path2Extensions
9
+ * @property {(redX: number, redY: number, blueX: number, blueY: number) => Path2} addQuadraticCurveTo
10
+ * @property {(redX: number, redY: number, greenX: number, greenY: number, blueX: number, blueY: number) => Path2} addCubicCurveTo
11
+ */
12
+ export const curveSampleSize: 6;
13
+ /**
14
+ * Extended Path2 interface with MeshWriter curve methods
15
+ */
16
+ export type Path2Extensions = {
17
+ addQuadraticCurveTo: (redX: number, redY: number, blueX: number, blueY: number) => Path2;
18
+ addCubicCurveTo: (redX: number, redY: number, greenX: number, greenY: number, blueX: number, blueY: number) => Path2;
19
+ };
20
+ import { Path2 } from './babylonImports.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Plugin that applies scene fog to text materials by modifying
3
+ * the final fragment color before output.
4
+ */
5
+ export class TextFogPlugin extends MaterialPluginBase {
6
+ /**
7
+ * @param {import('@babylonjs/core/Materials/material').Material} material
8
+ */
9
+ constructor(material: import("@babylonjs/core/Materials/material").Material);
10
+ /**
11
+ * Set the define based on whether scene fog is enabled
12
+ * @param {object} defines
13
+ * @param {import('@babylonjs/core/scene').Scene} scene
14
+ * @param {import('@babylonjs/core/Meshes/mesh').Mesh} mesh
15
+ */
16
+ prepareDefines(defines: object, scene: import("@babylonjs/core/scene").Scene, mesh: import("@babylonjs/core/Meshes/mesh").Mesh): void;
17
+ getUniforms(): {
18
+ ubo: any[];
19
+ };
20
+ /**
21
+ * Clean up the plugin
22
+ */
23
+ dispose(): void;
24
+ /**
25
+ * Inject shader code to apply fog to emissive color
26
+ * @param {string} shaderType - 'vertex' or 'fragment'
27
+ */
28
+ getCustomCode(shaderType: string): {
29
+ CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: string;
30
+ };
31
+ }
32
+ import { MaterialPluginBase } from './babylonImports.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Decode a compressed command list string
3
+ * @param {string} str - Compressed string (space-separated encoded commands)
4
+ * @returns {Array} - Array of decoded command arrays
5
+ */
6
+ export function decodeList(str: string): any[];
7
+ /**
8
+ * Encode a command list to compressed string
9
+ * @param {Array} list - Array of command arrays
10
+ * @returns {string} - Compressed string
11
+ */
12
+ export function codeList(list: any[]): string;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Register a font for use with MeshWriter
3
+ * @param {string} name - Font name (case-sensitive, used in "font-family" option)
4
+ * @param {Function|Object} fontData - Font factory function or pre-initialized font object
5
+ *
6
+ * @example
7
+ * // Register a font factory (receives codeList for encoding)
8
+ * import helvetica from 'meshwriter/fonts/helvetica';
9
+ * registerFont('Helvetica', helvetica);
10
+ *
11
+ * // Register with aliases
12
+ * registerFont('Arial', helvetica);
13
+ * registerFont('sans-serif', helvetica);
14
+ */
15
+ export function registerFont(name: string, fontData: Function | any): void;
16
+ /**
17
+ * Register multiple font aliases pointing to the same font
18
+ * @param {string} targetName - Name of already-registered font
19
+ * @param {...string} aliases - Alias names to register
20
+ *
21
+ * @example
22
+ * registerFont('Helvetica', helveticaData);
23
+ * registerFontAliases('Helvetica', 'Arial', 'sans-serif');
24
+ */
25
+ export function registerFontAliases(targetName: string, ...aliases: string[]): void;
26
+ /**
27
+ * Get a registered font by name
28
+ * @param {string} name - Font name
29
+ * @returns {Object|undefined} - Font object or undefined if not found
30
+ */
31
+ export function getFont(name: string): any | undefined;
32
+ /**
33
+ * Check if a font is registered
34
+ * @param {string} name - Font name
35
+ * @returns {boolean}
36
+ */
37
+ export function isFontRegistered(name: string): boolean;
38
+ /**
39
+ * Get list of all registered font names
40
+ * @returns {string[]}
41
+ */
42
+ export function getRegisteredFonts(): string[];
43
+ /**
44
+ * Unregister a font (mainly for testing)
45
+ * @param {string} name - Font name to remove
46
+ */
47
+ export function unregisterFont(name: string): void;
48
+ /**
49
+ * Clear all registered fonts (mainly for testing)
50
+ */
51
+ export function clearFonts(): void;
52
+ import { codeList } from './fontCompression.js';
53
+ import { decodeList } from './fontCompression.js';
54
+ export { codeList, decodeList };
@@ -0,0 +1,47 @@
1
+ export { TextFogPlugin } from "./fogPlugin.js";
2
+ export namespace MeshWriter {
3
+ export { createMeshWriterAsync as createAsync };
4
+ export { createMeshWriter as create };
5
+ export { isCSGReady as isReady };
6
+ export { getCSGVersion };
7
+ export { setCSGInitializer };
8
+ export { setCSGReadyCheck };
9
+ export { onCSGReady };
10
+ export { markCSGReady };
11
+ export { initCSGModule };
12
+ export { registerFont };
13
+ export { registerFontAliases };
14
+ export { getFont };
15
+ export { isFontRegistered };
16
+ export { codeList };
17
+ export { decodeList };
18
+ export { loadBakedFont };
19
+ export { loadBakedFontsFromManifest };
20
+ export { findNearestWeight };
21
+ export { getBakedFontManifest };
22
+ }
23
+ export default MeshWriter;
24
+ import { createMeshWriterAsync } from './meshwriter.js';
25
+ import { createMeshWriter } from './meshwriter.js';
26
+ import { isCSGReady } from './meshwriter.js';
27
+ import { getCSGVersion } from './meshwriter.js';
28
+ import { setCSGInitializer } from './meshwriter.js';
29
+ import { setCSGReadyCheck } from './meshwriter.js';
30
+ import { onCSGReady } from './meshwriter.js';
31
+ import { markCSGReady } from './meshwriter.js';
32
+ import { initCSGModule } from './meshwriter.js';
33
+ import { registerFont } from './fontRegistry.js';
34
+ import { registerFontAliases } from './fontRegistry.js';
35
+ import { getFont } from './fontRegistry.js';
36
+ import { isFontRegistered } from './fontRegistry.js';
37
+ import { codeList } from './fontCompression.js';
38
+ import { decodeList } from './fontCompression.js';
39
+ import { loadBakedFont } from './bakedFontLoader.js';
40
+ import { loadBakedFontsFromManifest } from './bakedFontLoader.js';
41
+ import { findNearestWeight } from './bakedFontLoader.js';
42
+ import { getBakedFontManifest } from './bakedFontLoader.js';
43
+ export { createMeshWriter, createMeshWriterAsync, isCSGReady, getCSGVersion, setCSGInitializer, setCSGReadyCheck, onCSGReady, markCSGReady, initCSGModule } from "./meshwriter.js";
44
+ export { registerFont, registerFontAliases, getFont, isFontRegistered, getRegisteredFonts, unregisterFont, clearFonts, codeList, decodeList } from "./fontRegistry.js";
45
+ export { loadBakedFont, loadBakedFontsFromManifest, findNearestWeight, getBakedFontManifest } from "./bakedFontLoader.js";
46
+ export { codeList as encodeFontData, decodeList as decodeFontData } from "./fontCompression.js";
47
+ export { deriveEdgeColors, adjustForContrast, relativeLuminance, contrastRatio, hexToRgb, rgbToHex, rgbToHsl, hslToRgb, CONTRAST_LEVELS } from "./colorContrast.js";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @typedef {Object} LetterPolygonsResult
3
+ * @property {number} xWidth - Total width of all letters
4
+ * @property {number} count - Number of valid letter meshes
5
+ */
6
+ /**
7
+ * @typedef {(any[] & LetterPolygonsResult) & { faceMeshes: Mesh[] }} LetterPolygonsCollection
8
+ */
9
+ /**
10
+ * Construct meshes for all letters in a string
11
+ * @param {string} letters - Text string
12
+ * @param {Object} fontSpec - Font specification
13
+ * @param {number} xOffset - X offset
14
+ * @param {number} yOffset - Y offset (unused, kept for API compatibility)
15
+ * @param {number} zOffset - Z offset
16
+ * @param {number} letterScale - Scale factor for letters
17
+ * @param {number} thickness - Letter thickness (depth)
18
+ * @param {Material} material - Material (unused in this function)
19
+ * @param {string} meshOrigin - "letterCenter" or "fontOrigin"
20
+ * @param {Scene} scene - Babylon scene
21
+ * @param {Object} [spacingOpts] - Optional spacing options
22
+ * @param {number} [spacingOpts.letterSpacing=0] - Extra spacing between letters (world units, added after kerning)
23
+ * @param {number} [spacingOpts.wordSpacing=0] - Extra spacing for spaces (world units, added to space width)
24
+ * @returns {any[] & LetterPolygonsResult} - [meshes, boxes, origins] with xWidth and count properties
25
+ */
26
+ export function constructLetterPolygons(letters: string, fontSpec: any, xOffset: number, yOffset: number, zOffset: number, letterScale: number, thickness: number, material: Material, meshOrigin: string, scene: Scene, spacingOpts?: {
27
+ letterSpacing?: number;
28
+ wordSpacing?: number;
29
+ }): any[] & LetterPolygonsResult;
30
+ export type LetterPolygonsResult = {
31
+ /**
32
+ * - Total width of all letters
33
+ */
34
+ xWidth: number;
35
+ /**
36
+ * - Number of valid letter meshes
37
+ */
38
+ count: number;
39
+ };
40
+ export type LetterPolygonsCollection = (any[] & LetterPolygonsResult) & {
41
+ faceMeshes: Mesh[];
42
+ };
43
+ export type Scene = import("@babylonjs/core/scene").Scene;
44
+ export type Material = import("@babylonjs/core/Materials/material").Material;
45
+ export const naturalLetterHeight: 1000;
46
+ import { Mesh } from './babylonImports.js';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Convert hex color string to Babylon Color3
3
+ * @param {string} rgb - Hex color string (e.g., "#FF0000" or "FF0000")
4
+ * @returns {Color3}
5
+ */
6
+ export function rgb2Color3(rgb: string): Color3;
7
+ /**
8
+ * Create a StandardMaterial for text
9
+ * @param {Scene} scene - Babylon scene
10
+ * @param {string} letters - Text string (used for material naming)
11
+ * @param {string} emissive - Hex color for emissive
12
+ * @param {string} ambient - Hex color for ambient
13
+ * @param {string} specular - Hex color for specular
14
+ * @param {string} diffuse - Hex color for diffuse
15
+ * @param {number} opac - Opacity (0-1)
16
+ * @param {boolean} [emissiveOnly=false] - If true, disables lighting (only emissive color shows)
17
+ * @param {boolean} [fogEnabled=true] - If true, the material is affected by scene fog
18
+ * @returns {StandardMaterial}
19
+ */
20
+ export function makeMaterial(scene: Scene, letters: string, emissive: string, ambient: string, specular: string, diffuse: string, opac: number, emissiveOnly?: boolean, fogEnabled?: boolean): StandardMaterial;
21
+ /**
22
+ * Create a dedicated emissive material for front faces.
23
+ * This keeps the face self-lit while still respecting fog settings.
24
+ * @param {Scene} scene
25
+ * @param {string} letters
26
+ * @param {string} emissive
27
+ * @param {number} opac
28
+ * @param {boolean} fogEnabled
29
+ * @returns {StandardMaterial}
30
+ */
31
+ export function makeFaceMaterial(scene: Scene, letters: string, emissive: string, opac: number, fogEnabled?: boolean): StandardMaterial;
32
+ export type Scene = import("@babylonjs/core/scene").Scene;
33
+ import { Color3 } from './babylonImports.js';
34
+ import { StandardMaterial } from './babylonImports.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Split a mesh into two meshes: emissive face geometry and lit rim geometry.
3
+ * @param {import('@babylonjs/core').Mesh} mesh
4
+ * @param {import('@babylonjs/core').Scene} scene
5
+ * @returns {{ rimMesh: import('@babylonjs/core').Mesh, faceMesh: import('@babylonjs/core').Mesh | null }}
6
+ */
7
+ export function splitMeshByFaceNormals(mesh: import("@babylonjs/core").Mesh, scene: import("@babylonjs/core").Scene): {
8
+ rimMesh: import("@babylonjs/core").Mesh;
9
+ faceMesh: import("@babylonjs/core").Mesh | null;
10
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Create a MeshWriter factory configured for a scene
3
+ * @param {Scene} scene - Babylon.js scene
4
+ * @param {MeshWriterPreferences} [preferences={}] - Configuration options
5
+ * @returns {Function} - MeshWriter constructor
6
+ */
7
+ export function createMeshWriter(scene: Scene, preferences?: MeshWriterPreferences): Function;
8
+ /**
9
+ * Async factory for Babylon 8+ with CSG2
10
+ * Handles CSG2 initialization automatically
11
+ * @param {Scene} scene - Babylon.js scene
12
+ * @param {MeshWriterPreferences} [preferences={}] - Configuration options
13
+ * @returns {Promise<Function>} - MeshWriter constructor
14
+ */
15
+ export function createMeshWriterAsync(scene: Scene, preferences?: MeshWriterPreferences): Promise<Function>;
16
+ export type Scene = import("@babylonjs/core/scene").Scene;
17
+ export type MeshWriterPreferences = {
18
+ /**
19
+ * - Default font family
20
+ */
21
+ defaultFont?: string;
22
+ /**
23
+ * - Scale factor
24
+ */
25
+ scale?: number;
26
+ /**
27
+ * - "letterCenter" or "fontOrigin"
28
+ */
29
+ meshOrigin?: string;
30
+ /**
31
+ * - Enable debug logging
32
+ */
33
+ debug?: boolean;
34
+ /**
35
+ * - Babylon.js namespace object with CSG classes (for ES module builds)
36
+ */
37
+ babylon?: any;
38
+ };
39
+ import { isCSGReady } from './csg.js';
40
+ import { getCSGVersion } from './csg.js';
41
+ import { setCSGInitializer } from './csg.js';
42
+ import { setCSGReadyCheck } from './csg.js';
43
+ import { onCSGReady } from './csg.js';
44
+ import { markCSGInitialized } from './csg.js';
45
+ import { initCSGModule } from './csg.js';
46
+ export { isCSGReady, getCSGVersion, setCSGInitializer, setCSGReadyCheck, onCSGReady, markCSGInitialized as markCSGReady, initCSGModule };
@@ -0,0 +1,27 @@
1
+ /** @typedef {import('@babylonjs/core/scene').Scene} Scene */
2
+ /** @typedef {import('@babylonjs/core/Materials/material').Material} Material */
3
+ /** @typedef {import('@babylonjs/core/Meshes/mesh').Mesh} BabylonMesh */
4
+ /** @typedef {(any[] & { faceMeshes?: BabylonMesh[] })} MeshCollection */
5
+ /**
6
+ * @typedef {[SolidParticleSystem | undefined, BabylonMesh | undefined] & {
7
+ * face: [SolidParticleSystem | undefined, BabylonMesh | undefined];
8
+ * }} SPSCombo
9
+ */
10
+ /**
11
+ * Create an SPS from letter meshes
12
+ * @param {Scene} scene - Babylon scene
13
+ * @param {MeshCollection} meshesAndBoxes - [meshes, boxes, origins] with optional face geometry
14
+ * @param {Material} material - Material to apply to SPS mesh
15
+ * @returns {SPSCombo} - Combined SPS + emissive face SPS
16
+ */
17
+ export function makeSPS(scene: Scene, meshesAndBoxes: MeshCollection, material: Material): SPSCombo;
18
+ export type Scene = import("@babylonjs/core/scene").Scene;
19
+ export type Material = import("@babylonjs/core/Materials/material").Material;
20
+ export type BabylonMesh = import("@babylonjs/core/Meshes/mesh").Mesh;
21
+ export type MeshCollection = (any[] & {
22
+ faceMeshes?: BabylonMesh[];
23
+ });
24
+ export type SPSCombo = [SolidParticleSystem | undefined, BabylonMesh | undefined] & {
25
+ face: [SolidParticleSystem | undefined, BabylonMesh | undefined];
26
+ };
27
+ import { SolidParticleSystem } from './babylonImports.js';
@@ -0,0 +1,3 @@
1
+ export default factory;
2
+ /** @type {any} */
3
+ declare const factory: any;
@@ -0,0 +1,12 @@
1
+ export function isPositiveNumber(mn: any): boolean;
2
+ export function isNumber(mn: any): mn is number;
3
+ export function isBoolean(mn: any): mn is boolean;
4
+ export function isAmplitude(ma: any): boolean;
5
+ export function isObject(mo: any): boolean;
6
+ export function isPromiseLike(mo: any): boolean;
7
+ export function isArray(ma: any): boolean;
8
+ export function isString(ms: any): boolean;
9
+ export function isRelativeLength(l: any): boolean;
10
+ export function round(n: any): number;
11
+ export function weeid(): number;
12
+ export function setOption(opts: any, field: any, tst: any, defalt: any): any;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Create a cache key for a glyph at a specific weight
3
+ * @param {number} weight - Font weight value
4
+ * @param {string} char - Character
5
+ * @returns {string} - Cache key
6
+ */
7
+ export function createGlyphCacheKey(weight: number, char: string): string;
8
+ /**
9
+ * MeshWriter Variable Font Cache
10
+ * LRU cache for variable font glyphs to prevent memory bloat
11
+ */
12
+ /**
13
+ * LRU Cache for glyph specifications
14
+ * Prevents memory bloat when using many weight variations
15
+ */
16
+ export class GlyphCache {
17
+ /**
18
+ * Create a new glyph cache
19
+ * @param {number} [maxSize=5000] - Maximum number of cached entries
20
+ */
21
+ constructor(maxSize?: number);
22
+ _maxSize: number;
23
+ _cache: Map<any, any>;
24
+ /**
25
+ * Get a cached value (moves it to most recently used)
26
+ * @param {string} key - Cache key
27
+ * @returns {*} - Cached value or undefined
28
+ */
29
+ get(key: string): any;
30
+ /**
31
+ * Set a cache value (evicts oldest if at capacity)
32
+ * @param {string} key - Cache key
33
+ * @param {*} value - Value to cache
34
+ */
35
+ set(key: string, value: any): void;
36
+ /**
37
+ * Check if key exists in cache
38
+ * @param {string} key - Cache key
39
+ * @returns {boolean}
40
+ */
41
+ has(key: string): boolean;
42
+ /**
43
+ * Clear all cached entries
44
+ */
45
+ clear(): void;
46
+ /**
47
+ * Get current cache size
48
+ * @returns {number}
49
+ */
50
+ get size(): number;
51
+ /**
52
+ * Get maximum cache size
53
+ * @returns {number}
54
+ */
55
+ get maxSize(): number;
56
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * MeshWriter Variable Font Converter
3
+ * Converts fontkit glyph paths to MeshWriter FontSpec format at runtime
4
+ */
5
+ /**
6
+ * Convert fontkit glyph to MeshWriter GlyphSpec
7
+ * @param {object} glyph - fontkit glyph object
8
+ * @param {number} [scale=1] - Scale factor
9
+ * @returns {object|null} - GlyphSpec with shapeCmds/holeCmds, or null if empty
10
+ */
11
+ export function convertFontkitGlyphToSpec(glyph: object, scale?: number): object | null;
12
+ /**
13
+ * Extract kerning pairs from fontkit font for given character set
14
+ * @param {object} font - fontkit font object
15
+ * @param {string} charset - Characters to extract kerning for
16
+ * @param {number} [scale=1] - Scale factor
17
+ * @returns {object} - Kerning table mapping "char1,char2" to adjustment value
18
+ */
19
+ export function extractFontkitKerningPairs(font: object, charset: string, scale?: number): object;
20
+ export function convertGlyphToSpec(glyph: any, scale?: number): any;
21
+ export function extractKerningPairs(font: any, charset: any, scale?: number): any;