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,130 @@
1
+ /**
2
+ * MeshWriter UMD Entry Point
3
+ * Bundles fonts and attaches to window.MeshWriter and BABYLON.MeshWriter
4
+ */
5
+
6
+ import {
7
+ createMeshWriter,
8
+ createMeshWriterAsync,
9
+ isCSGReady,
10
+ getCSGVersion,
11
+ setCSGInitializer,
12
+ setCSGReadyCheck,
13
+ onCSGReady,
14
+ markCSGReady,
15
+ initCSGModule
16
+ } from './meshwriter.js';
17
+
18
+ import {
19
+ registerFont,
20
+ registerFontAliases,
21
+ getFont,
22
+ isFontRegistered,
23
+ codeList,
24
+ decodeList
25
+ } from './fontRegistry.js';
26
+
27
+ // Import all fonts for UMD bundle
28
+ import helvetica from '../fonts/helvetica.js';
29
+ import comicSans from '../fonts/comic-sans.js';
30
+ import jura from '../fonts/jura.js';
31
+ import hirukoPro from '../fonts/hiruko-pro.js';
32
+ import webglDings from '../fonts/webgl-dings.js';
33
+
34
+ // Register fonts with standard names
35
+ registerFont('HelveticaNeue-Medium', helvetica);
36
+ registerFont('Helvetica', helvetica);
37
+ registerFont('Arial', helvetica);
38
+ registerFont('sans-serif', helvetica);
39
+ registerFont('HirukoPro-Book', hirukoPro);
40
+ registerFont('Comic', comicSans);
41
+ registerFont('comic', comicSans);
42
+ registerFont('ComicSans', comicSans);
43
+ registerFont('Jura', jura);
44
+ registerFont('jura', jura);
45
+ registerFont('WebGL-Dings', webglDings);
46
+ registerFont('Web-dings', webglDings);
47
+
48
+ /**
49
+ * Get the BABYLON global if available
50
+ * @returns {any}
51
+ */
52
+ function getBabylonGlobal() {
53
+ if (typeof globalThis !== 'undefined' && globalThis.BABYLON) {
54
+ return globalThis.BABYLON;
55
+ }
56
+ return undefined;
57
+ }
58
+
59
+ /**
60
+ * Legacy MeshWriter factory function
61
+ * Matches the old API: var Writer = BABYLON.MeshWriter(scene, prefs)
62
+ * @param {any} scene
63
+ * @param {any} preferences
64
+ */
65
+ function MeshWriterFactory(scene, preferences) {
66
+ // Initialize CSG from BABYLON global
67
+ const babylon = getBabylonGlobal();
68
+ if (babylon) {
69
+ initCSGModule(babylon);
70
+ }
71
+ return createMeshWriter(scene, preferences);
72
+ }
73
+
74
+ // Attach static methods to factory
75
+ /** @type {any} */
76
+ const factory = MeshWriterFactory;
77
+
78
+ factory.createAsync = async function(scene, preferences = {}) {
79
+ // Initialize CSG from BABYLON global
80
+ const babylon = getBabylonGlobal();
81
+ if (babylon) {
82
+ initCSGModule(babylon);
83
+ }
84
+ return createMeshWriterAsync(scene, preferences);
85
+ };
86
+
87
+ // Sync create method (alias for backwards compatibility)
88
+ factory.create = function(scene, preferences = {}) {
89
+ const babylon = getBabylonGlobal();
90
+ if (babylon) {
91
+ initCSGModule(babylon);
92
+ }
93
+ return createMeshWriter(scene, preferences);
94
+ };
95
+
96
+ factory.isReady = isCSGReady;
97
+ factory.getCSGVersion = getCSGVersion;
98
+ factory.setCSGInitializer = setCSGInitializer;
99
+ factory.setCSGReadyCheck = setCSGReadyCheck;
100
+ factory.onCSGReady = onCSGReady;
101
+ factory.markCSGReady = markCSGReady;
102
+ factory.registerFont = registerFont;
103
+ factory.getFont = getFont;
104
+ factory.isFontRegistered = isFontRegistered;
105
+ factory.codeList = codeList;
106
+ factory.decodeList = decodeList;
107
+
108
+ // Attach to globals for browser usage
109
+ if (typeof window !== 'undefined') {
110
+ /** @type {any} */
111
+ const win = window;
112
+ win.MeshWriter = factory;
113
+ win.TYPE = factory; // Legacy name
114
+ }
115
+
116
+ if (typeof globalThis !== 'undefined') {
117
+ /** @type {any} */
118
+ const gt = globalThis;
119
+ if (gt.global) {
120
+ gt.global.MeshWriter = factory;
121
+ }
122
+ }
123
+
124
+ // Attach to BABYLON namespace if available
125
+ const babylon = getBabylonGlobal();
126
+ if (babylon) {
127
+ babylon.MeshWriter = factory;
128
+ }
129
+
130
+ export default factory;
package/src/utils.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * MeshWriter Utility Functions
3
+ * Pure helper functions with no external dependencies
4
+ */
5
+
6
+ const floor = Math.floor;
7
+
8
+ // Type checking functions
9
+ export function isPositiveNumber(mn) {
10
+ return typeof mn === "number" && !isNaN(mn) ? 0 < mn : false;
11
+ }
12
+
13
+ export function isNumber(mn) {
14
+ return typeof mn === "number";
15
+ }
16
+
17
+ export function isBoolean(mn) {
18
+ return typeof mn === "boolean";
19
+ }
20
+
21
+ export function isAmplitude(ma) {
22
+ return typeof ma === "number" && !isNaN(ma) ? 0 <= ma && ma <= 1 : false;
23
+ }
24
+
25
+ export function isObject(mo) {
26
+ return mo != null && typeof mo === "object" || typeof mo === "function";
27
+ }
28
+
29
+ export function isPromiseLike(mo) {
30
+ return isObject(mo) && typeof mo.then === "function";
31
+ }
32
+
33
+ export function isArray(ma) {
34
+ return ma != null && typeof ma === "object" && ma.constructor === Array;
35
+ }
36
+
37
+ export function isString(ms) {
38
+ return typeof ms === "string" ? ms.length > 0 : false;
39
+ }
40
+
41
+ export function isRelativeLength(l) {
42
+ return l === 3 || l === 5 || l === 7;
43
+ }
44
+
45
+ // Math utilities
46
+ export function round(n) {
47
+ return floor(0.3 + n * 1000000) / 1000000;
48
+ }
49
+
50
+ export function weeid() {
51
+ return Math.floor(Math.random() * 1000000);
52
+ }
53
+
54
+ // Option handling
55
+ export function setOption(opts, field, tst, defalt) {
56
+ return tst(opts[field]) ? opts[field] : defalt;
57
+ }