@mlightcad/mtext-renderer 0.13.4 → 0.13.6
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/README.md +1 -0
- package/dist/index.js +4140 -3861
- package/dist/index.umd.cjs +8 -8
- package/dist/mtext-renderer-worker.js +11526 -5737
- package/lib/font/fontManager.d.ts +19 -2
- package/lib/font/meshFont.d.ts +1 -1
- package/lib/font/shxTextShape.d.ts +1 -1
- package/lib/font/textGeometryBuilder.d.ts +4 -2
- package/lib/font/threeFont.d.ts +9 -43
- package/lib/memory/index.d.ts +2 -0
- package/lib/memory/textRenderProfiler.d.ts +116 -0
- package/lib/renderer/mtext.d.ts +5 -0
- package/lib/renderer/mtextProcessor.d.ts +13 -3
- package/lib/renderer/types.d.ts +25 -0
- package/lib/worker/unifiedRenderer.d.ts +10 -1
- package/lib/worker/webWorkerRenderer.d.ts +4 -0
- package/package.json +4 -3
|
@@ -89,10 +89,17 @@ export declare class FontManager {
|
|
|
89
89
|
/**
|
|
90
90
|
* Fonts whose latest {@link requestFont} failed to fetch or parse the face.
|
|
91
91
|
* Prevents per-glyph retry storms until {@link release} clears state.
|
|
92
|
-
* Catalog misses (`NotFound`) are not sticky — a later `fonts.json` refresh
|
|
93
|
-
* must still be able to resolve the name.
|
|
94
92
|
*/
|
|
95
93
|
private fontRequestFailed;
|
|
94
|
+
/**
|
|
95
|
+
* Session-sticky catalog misses (`NotFound` / empty load result).
|
|
96
|
+
* Open paths draw tens of thousands of MTEXT entities; re-entering the
|
|
97
|
+
* loader for the same absent face every draw dominates `requestFontsMs`.
|
|
98
|
+
* Cleared when the face is registered or on {@link release}. Soft misses
|
|
99
|
+
* stay recoverable via those paths — they are not retried automatically
|
|
100
|
+
* mid-open (unlike the previous per-draw NotFound retry behavior).
|
|
101
|
+
*/
|
|
102
|
+
private fontRequestAbsent;
|
|
96
103
|
/**
|
|
97
104
|
* Names already confirmed absent from IndexedDB during this session.
|
|
98
105
|
* Repeated open-time MTEXT loads must not re-enter IndexedDB for the same miss.
|
|
@@ -202,8 +209,18 @@ export declare class FontManager {
|
|
|
202
209
|
* Requests each font name via {@link requestFont} (deduped per name).
|
|
203
210
|
* Callers may ignore the returned promise for fire-and-forget loads, or
|
|
204
211
|
* await it when they need fonts before drawing.
|
|
212
|
+
*
|
|
213
|
+
* When every name is already loaded, failed, or session-absent (or the
|
|
214
|
+
* list is empty), returns a resolved promise without scheduling
|
|
215
|
+
* `Promise.all` — open-time paths call this per entity.
|
|
205
216
|
*/
|
|
206
217
|
requestFonts(fontNames: readonly string[]): Promise<FontLoadStatus[]>;
|
|
218
|
+
/**
|
|
219
|
+
* True when a face still needs an awaitable load attempt (not loaded and
|
|
220
|
+
* not session-settled as failed/absent). Used by open-time `asyncDraw` to
|
|
221
|
+
* skip `await requestFonts` once the manager has finished trying.
|
|
222
|
+
*/
|
|
223
|
+
needsFontLoad(fontName: string): boolean;
|
|
207
224
|
private normalizeFontName;
|
|
208
225
|
/**
|
|
209
226
|
* Returns raw mesh font program bytes from IndexedDB when available.
|
package/lib/font/meshFont.d.ts
CHANGED
|
@@ -128,7 +128,7 @@ export declare class MeshFont extends BaseFont {
|
|
|
128
128
|
* @param size - The size of the text
|
|
129
129
|
* @returns Indexed line-pair BufferGeometry suitable for LineSegments
|
|
130
130
|
*/
|
|
131
|
-
generateStrokeGeometry(text: string, size: number): import('three').BufferGeometry<import('three').NormalBufferAttributes>;
|
|
131
|
+
generateStrokeGeometry(text: string, size: number): import('three').BufferGeometry<import('three').NormalBufferAttributes, import('three').BufferGeometryEventMap>;
|
|
132
132
|
/**
|
|
133
133
|
* Gets the shape data for a specific character at a given size.
|
|
134
134
|
* @param char - The character to get the shape for
|
|
@@ -38,7 +38,7 @@ export declare class ShxTextShape extends BaseTextShape {
|
|
|
38
38
|
* Converts the text shape to a THREE.js geometry.
|
|
39
39
|
* @returns A BufferGeometry representing the text shape.
|
|
40
40
|
*/
|
|
41
|
-
toGeometry(): THREE.BufferGeometry<THREE.NormalBufferAttributes>;
|
|
41
|
+
toGeometry(): THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>;
|
|
42
42
|
/** @inheritdoc */
|
|
43
43
|
hasStrokeGeometry(): boolean;
|
|
44
44
|
/**
|
|
@@ -20,6 +20,7 @@ export declare class TextGeometryBuilder {
|
|
|
20
20
|
* @returns A single non-indexed line geometry containing all transformed segments.
|
|
21
21
|
*/
|
|
22
22
|
static mergeLineGeometries(entries: TransformedLineGeometryEntry[]): THREE.BufferGeometry;
|
|
23
|
+
private static mergeLineGeometriesUnprofiled;
|
|
23
24
|
/**
|
|
24
25
|
* Counts how many line segments a geometry represents.
|
|
25
26
|
* Indexed geometries use index pairs; non-indexed geometries use consecutive position pairs.
|
|
@@ -55,10 +56,11 @@ export declare class TextGeometryBuilder {
|
|
|
55
56
|
* @returns A single indexed mesh geometry. Empty when `entries` is empty.
|
|
56
57
|
*/
|
|
57
58
|
static mergeMeshGeometries(entries: TransformedLineGeometryEntry[]): THREE.BufferGeometry;
|
|
59
|
+
private static mergeMeshGeometriesUnprofiled;
|
|
58
60
|
/**
|
|
59
61
|
* Writes `position` transformed by `matrix` into `output` at `vertexBase`.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
+
* Glyph placement matrices are affine (no perspective); that path skips the
|
|
63
|
+
* per-vertex `w` divide. Non-affine matrices keep full `applyMatrix4` math.
|
|
62
64
|
*/
|
|
63
65
|
private static writeTransformedMeshPositions;
|
|
64
66
|
}
|
package/lib/font/threeFont.d.ts
CHANGED
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
import { BufferGeometry
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
2
|
import { Font } from 'three/examples/jsm/loaders/FontLoader.js';
|
|
3
3
|
type Direction = 'ltr' | 'rtl' | 'tb';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Font used for mesh glyphs.
|
|
6
|
+
*
|
|
7
|
+
* Filled outlines come from {@link Font.generateShapes}, which delegates to
|
|
8
|
+
* `ShapePath.toShapes()`. That path correctly classifies holes for fonts such
|
|
9
|
+
* as SimSun (面, 限, 用, 色, 8) starting with three.js r185 (0.185.1).
|
|
10
|
+
*
|
|
11
|
+
* Stroke geometry is still built here: it only needs sampled contours, not
|
|
12
|
+
* hole classification.
|
|
7
13
|
*/
|
|
8
14
|
export declare class ThreeFont extends Font {
|
|
9
|
-
/**
|
|
10
|
-
* Generates geometry shapes from the given text and size.
|
|
11
|
-
*
|
|
12
|
-
* Algorithm overview:
|
|
13
|
-
* 1. Split the input text into individual characters.
|
|
14
|
-
* 2. For each character:
|
|
15
|
-
* a. Retrieve the glyph data from the font.
|
|
16
|
-
* b. Convert the glyph outline commands into a ShapePath.
|
|
17
|
-
* - 'm' → moveTo
|
|
18
|
-
* - 'l' → lineTo
|
|
19
|
-
* - 'q' → quadraticCurveTo
|
|
20
|
-
* - 'b' → cubic bezierCurveTo
|
|
21
|
-
* c. Apply scaling to match the requested font size.
|
|
22
|
-
* d. Apply offsets for proper placement (supports multiple lines and directions).
|
|
23
|
-
* 3. Handle text direction:
|
|
24
|
-
* - 'ltr': left-to-right
|
|
25
|
-
* - 'rtl': right-to-left (characters reversed)
|
|
26
|
-
* - 'tb': top-to-bottom (vertical layout)
|
|
27
|
-
* 4. Collect all ShapePaths for the text.
|
|
28
|
-
* 5. Convert each ShapePath into one or more Shape objects:
|
|
29
|
-
* a. Sample points along each subPath to approximate geometry.
|
|
30
|
-
* b. Determine which subPaths are outer contours and which are holes:
|
|
31
|
-
* - For each subPath, check if it is fully contained inside another polygon.
|
|
32
|
-
* - Assign the smallest containing polygon as its parent.
|
|
33
|
-
* c. Compute the relative depth of each subPath to handle nested holes.
|
|
34
|
-
* d. Reverse curves if necessary to maintain correct clockwise/counterclockwise winding:
|
|
35
|
-
* - Outer contours: CCW
|
|
36
|
-
* - Holes: CW
|
|
37
|
-
* e. Build Shape objects with holes properly assigned.
|
|
38
|
-
* 6. Return the final array of Shape objects ready for geometry creation.
|
|
39
|
-
*
|
|
40
|
-
* This algorithm ensures that complex characters with multiple independent contours
|
|
41
|
-
* (including intersecting subpaths or holes) are rendered correctly.
|
|
42
|
-
*
|
|
43
|
-
* @param text - input string to convert to shapes
|
|
44
|
-
* @param size - font size in units (default 100)
|
|
45
|
-
* @param direction - text direction ('ltr', 'rtl', 'tb')
|
|
46
|
-
* @returns array of Shape objects with proper holes and contours
|
|
47
|
-
*/
|
|
48
|
-
generateShapes(text: string, size?: number, direction?: Direction): Shape[];
|
|
49
15
|
/**
|
|
50
16
|
* Samples glyph contours into line-segment geometry without hole detection
|
|
51
17
|
* or triangulation.
|
package/lib/memory/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { collectIsolateMemoryStats, getMaterialStatsFromStyleManager, readJsHeapStats } from './collectIsolateMemoryStats';
|
|
2
2
|
export { estimateGeometryBytes, estimateStringBytes, formatBytes, getSourceByteLength } from './estimateGeometryBytes';
|
|
3
3
|
export { formatMemoryUsageReport } from './formatMemoryUsageReport';
|
|
4
|
+
export { TextRenderProfiler } from './textRenderProfiler';
|
|
5
|
+
export type { TextRenderProfileSnapshot } from './textRenderProfiler';
|
|
4
6
|
export { emptyMaterialStats, estimateMaterialBytes, MATERIAL_ESTIMATED_BYTES, MESH_PARSED_FONT_OVERHEAD, SHX_PARSED_FONT_OVERHEAD } from './types';
|
|
5
7
|
export type { CacheBucketStats, FontMemoryStats, IndexedDbFontCacheStats, IsolateMemoryStats, MaterialMemoryStats, MemoryUsageReport } from './types';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-scoped CPU timing for MText / mesh glyph draws.
|
|
3
|
+
*
|
|
4
|
+
* Disabled by default so production paths pay only a boolean check.
|
|
5
|
+
* Enable via {@link TextRenderProfiler.setEnabled} (cad-viewer OPENPROF)
|
|
6
|
+
* or `globalThis.__MTEXTPROF__ = true`.
|
|
7
|
+
*/
|
|
8
|
+
export interface TextRenderProfileSnapshot {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
/** `asyncDraw` awaiting content/style fonts. */
|
|
11
|
+
requestFontsMs: number;
|
|
12
|
+
/**
|
|
13
|
+
* Tokenize + layout residual inside `processText` after nested glyph/merge
|
|
14
|
+
* leaf timers are subtracted.
|
|
15
|
+
*/
|
|
16
|
+
parseLayoutMs: number;
|
|
17
|
+
/** opentype path → outline string (`_loadGlyphIfNeeded`). */
|
|
18
|
+
glyphLoadMs: number;
|
|
19
|
+
/** `generateShapes` / ShapePath construction. */
|
|
20
|
+
shapeBuildMs: number;
|
|
21
|
+
/** `new ShapeGeometry(...)` triangulation. */
|
|
22
|
+
triangulateMs: number;
|
|
23
|
+
/** Contour stroke sampling (`toStrokeGeometry`). */
|
|
24
|
+
strokeSampleMs: number;
|
|
25
|
+
/** Bake position+index + cache insert. */
|
|
26
|
+
bakeCacheMs: number;
|
|
27
|
+
cacheHit: number;
|
|
28
|
+
cacheMiss: number;
|
|
29
|
+
mergeMeshMs: number;
|
|
30
|
+
mergeLineMs: number;
|
|
31
|
+
/** Number of `mergeMeshGeometries` calls. */
|
|
32
|
+
mergeMeshCalls: number;
|
|
33
|
+
/** Sum of glyph entries across all mesh merges (≈ placed mesh glyphs). */
|
|
34
|
+
mergeMeshEntries: number;
|
|
35
|
+
/** Largest single mesh-merge batch size. */
|
|
36
|
+
mergeMeshEntriesMax: number;
|
|
37
|
+
/** Merges with exactly 1 glyph entry. */
|
|
38
|
+
mergeMeshBucket1: number;
|
|
39
|
+
/** Merges with 2–8 glyph entries. */
|
|
40
|
+
mergeMeshBucket2to8: number;
|
|
41
|
+
/** Merges with 9–32 glyph entries. */
|
|
42
|
+
mergeMeshBucket9to32: number;
|
|
43
|
+
/** Merges with 33+ glyph entries. */
|
|
44
|
+
mergeMeshBucket33plus: number;
|
|
45
|
+
/** Distinct code points that missed the geometry cache. */
|
|
46
|
+
uniqueChars: number;
|
|
47
|
+
/**
|
|
48
|
+
* Code points represented by {@link uniqueChars} (present on worker deltas so
|
|
49
|
+
* the main thread can merge sets accurately).
|
|
50
|
+
*/
|
|
51
|
+
uniqueCharCodes?: number[];
|
|
52
|
+
/** Glyph placements (instances) during draws. */
|
|
53
|
+
placedChars: number;
|
|
54
|
+
vertexCount: number;
|
|
55
|
+
indexCount: number;
|
|
56
|
+
/** Worker-side `asyncDraw` wall (from worker delta). */
|
|
57
|
+
workerBuildMs: number;
|
|
58
|
+
/** Worker-side `serializeMText`. */
|
|
59
|
+
serializeMs: number;
|
|
60
|
+
/** Main-thread wait for worker render response (includes build+serialize+IPC). */
|
|
61
|
+
transferWaitMs: number;
|
|
62
|
+
/** Main-thread `reconstructMText`. */
|
|
63
|
+
reconstructMs: number;
|
|
64
|
+
/** Number of `syncDraw` / worker builds counted. */
|
|
65
|
+
drawCount: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Process-wide (per isolate) accumulator for text-render CPU buckets.
|
|
69
|
+
*/
|
|
70
|
+
export declare class TextRenderProfiler {
|
|
71
|
+
private static _explicitEnabled;
|
|
72
|
+
private static _stats;
|
|
73
|
+
/** True when profiling is active in this isolate. */
|
|
74
|
+
static get enabled(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Forces profiling on/off. Pass `null` to fall back to `globalThis.__MTEXTPROF__`.
|
|
77
|
+
*/
|
|
78
|
+
static setEnabled(enabled: boolean | null): void;
|
|
79
|
+
/** Clears all counters for a new open / benchmark run. */
|
|
80
|
+
static reset(): void;
|
|
81
|
+
/** Immutable snapshot of current counters. */
|
|
82
|
+
static snapshot(includeCodes?: boolean): TextRenderProfileSnapshot;
|
|
83
|
+
/**
|
|
84
|
+
* Snapshot suitable for `postMessage`. Used as a per-render delta from
|
|
85
|
+
* workers and merged on the main thread.
|
|
86
|
+
*/
|
|
87
|
+
static takeDelta(): TextRenderProfileSnapshot;
|
|
88
|
+
/**
|
|
89
|
+
* Merges a worker (or prior) delta into this isolate's accumulator.
|
|
90
|
+
* Does not merge `enabled`.
|
|
91
|
+
*/
|
|
92
|
+
static mergeDelta(delta: Partial<TextRenderProfileSnapshot> | null | undefined): void;
|
|
93
|
+
static addMs(key: 'requestFontsMs' | 'parseLayoutMs' | 'glyphLoadMs' | 'shapeBuildMs' | 'triangulateMs' | 'strokeSampleMs' | 'bakeCacheMs' | 'mergeMeshMs' | 'mergeLineMs' | 'workerBuildMs' | 'serializeMs' | 'transferWaitMs' | 'reconstructMs', ms: number): void;
|
|
94
|
+
static timeSync<T>(key: Parameters<typeof TextRenderProfiler.addMs>[0], fn: () => T): T;
|
|
95
|
+
static timeAsync<T>(key: Parameters<typeof TextRenderProfiler.addMs>[0], fn: () => Promise<T>): Promise<T>;
|
|
96
|
+
/** Sum of leaf geometry timers (for layout residual). */
|
|
97
|
+
static geometryLeafTotalMs(): number;
|
|
98
|
+
/**
|
|
99
|
+
* Records `processText` wall minus nested leaf geometry time as layout residual.
|
|
100
|
+
*/
|
|
101
|
+
static addProcessTextResidual(wallMs: number, leafMsBefore: number): void;
|
|
102
|
+
static noteCacheHit(): void;
|
|
103
|
+
static noteCacheMiss(code?: number): void;
|
|
104
|
+
static notePlacedChar(): void;
|
|
105
|
+
static addGeometryCounts(vertexCount: number, indexCount: number): void;
|
|
106
|
+
/**
|
|
107
|
+
* Records one `mergeMeshGeometries` batch size for distribution analysis.
|
|
108
|
+
* Cheap counters only — used to decide merge-opt vs scene-level instancing.
|
|
109
|
+
*/
|
|
110
|
+
static noteMergeMeshBatch(entryCount: number): void;
|
|
111
|
+
static noteDraw(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Formats a snapshot for OPENPROF / console (Chinese-friendly labels kept short).
|
|
114
|
+
*/
|
|
115
|
+
static formatReport(snap?: TextRenderProfileSnapshot): string[];
|
|
116
|
+
}
|
package/lib/renderer/mtext.d.ts
CHANGED
|
@@ -38,6 +38,11 @@ export declare class MText extends THREE.Object3D {
|
|
|
38
38
|
private _box;
|
|
39
39
|
/** Lazily built layout data (line geometry + char boxes). */
|
|
40
40
|
private _layoutData;
|
|
41
|
+
/**
|
|
42
|
+
* Cached result of {@link MText.getFonts} for {@link _mtextData.text}.
|
|
43
|
+
* Avoids re-parsing control codes on every {@link asyncDraw}.
|
|
44
|
+
*/
|
|
45
|
+
private _contentFontNames;
|
|
41
46
|
/** Raw mtext data to draw on demand */
|
|
42
47
|
private _mtextData;
|
|
43
48
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChangedProperties, MTextParagraphAlignment, MTextToken } from '@mlightcad/mtext-parser';
|
|
2
2
|
import { FontManager } from '../font';
|
|
3
3
|
import { StyleManager } from './styleManager';
|
|
4
|
-
import { ColorSettings, LineLayout, MeshFontRenderMode, MTextFlowDirection, MTextLineSpacingStyle, TextStyle } from './types';
|
|
4
|
+
import { ColorSettings, LineLayout, MeshFontRenderMode, MeshGlyphOutputMode, MTextFlowDirection, MTextLineSpacingStyle, TextStyle } from './types';
|
|
5
5
|
import * as THREE from 'three';
|
|
6
6
|
/**
|
|
7
7
|
* Options for formatting MText.
|
|
@@ -57,6 +57,10 @@ export interface MTextFormatOptions {
|
|
|
57
57
|
* How TrueType/OTF (mesh) glyphs are drawn. Default is `'mesh'`.
|
|
58
58
|
*/
|
|
59
59
|
meshFontRenderMode?: MeshFontRenderMode;
|
|
60
|
+
/**
|
|
61
|
+
* How filled mesh glyphs are packaged. Default `'merge'`.
|
|
62
|
+
*/
|
|
63
|
+
meshGlyphOutputMode?: MeshGlyphOutputMode;
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
62
66
|
* Converts parsed MText tokens into positioned THREE.js geometry.
|
|
@@ -670,11 +674,17 @@ export declare class MTextProcessor {
|
|
|
670
674
|
*/
|
|
671
675
|
private resolveCharBoxTarget;
|
|
672
676
|
/**
|
|
673
|
-
* Applies translation on the
|
|
677
|
+
* Applies horizontal translation on the current visual line according to
|
|
678
|
+
* paragraph alignment.
|
|
674
679
|
*
|
|
675
|
-
*
|
|
680
|
+
* Updates merged {@link THREE.BufferGeometry} vertices, {@link MeshGlyphPlacement}
|
|
681
|
+
* matrices (placement output mode), and attached char boxes.
|
|
676
682
|
*/
|
|
677
683
|
private processAlignment;
|
|
684
|
+
/** Unions axis-aligned bounds of unit glyphs transformed by placement matrices. */
|
|
685
|
+
private unionBoxFromPlacements;
|
|
686
|
+
/** Left-multiplies each placement by a translation (same as `geometry.translate`). */
|
|
687
|
+
private translateMeshGlyphPlacements;
|
|
678
688
|
/**
|
|
679
689
|
* Resolves horizontal advance for an ASCII space in the active font.
|
|
680
690
|
*
|
package/lib/renderer/types.d.ts
CHANGED
|
@@ -171,6 +171,24 @@ export declare const createDefaultColorSettings: () => ColorSettings;
|
|
|
171
171
|
* - `line`: sample glyph contours as line segments (no triangulation)
|
|
172
172
|
*/
|
|
173
173
|
export type MeshFontRenderMode = 'mesh' | 'line';
|
|
174
|
+
/**
|
|
175
|
+
* How filled mesh glyphs are packaged after layout.
|
|
176
|
+
* - `merge`: bake placements into one BufferGeometry (default)
|
|
177
|
+
* - `placement`: leave unit glyph geometries + matrices on
|
|
178
|
+
* `userData.meshGlyphPlacements` for a scene-level InstancedMesh batcher
|
|
179
|
+
* (main-thread only; skips per-entity vertex copy)
|
|
180
|
+
*/
|
|
181
|
+
export type MeshGlyphOutputMode = 'merge' | 'placement';
|
|
182
|
+
/**
|
|
183
|
+
* One unit-glyph instance emitted when {@link MeshGlyphOutputMode} is
|
|
184
|
+
* `'placement'`. `geometry` is the shared cache entry — do not dispose it
|
|
185
|
+
* with the entity.
|
|
186
|
+
*/
|
|
187
|
+
export interface MeshGlyphPlacement {
|
|
188
|
+
geometry: THREE.BufferGeometry;
|
|
189
|
+
/** Column-major 4×4 placement (same layout as {@link THREE.Matrix4.elements}). */
|
|
190
|
+
matrixElements: Float32Array;
|
|
191
|
+
}
|
|
174
192
|
/**
|
|
175
193
|
* Represents the data structure for multiline text (MText) entities.
|
|
176
194
|
* Contains all necessary properties to define the appearance and positioning of text.
|
|
@@ -213,7 +231,14 @@ export interface MTextData {
|
|
|
213
231
|
* `line` draws sampled contours only, skipping triangulation.
|
|
214
232
|
*/
|
|
215
233
|
meshFontRenderMode?: MeshFontRenderMode;
|
|
234
|
+
/**
|
|
235
|
+
* How filled mesh glyphs are packaged. Default `'merge'`.
|
|
236
|
+
* `'placement'` is for scene-level InstancedMesh batching (main thread).
|
|
237
|
+
*/
|
|
238
|
+
meshGlyphOutputMode?: MeshGlyphOutputMode;
|
|
216
239
|
}
|
|
240
|
+
/** `userData` key for {@link MeshGlyphPlacement} arrays on an MText object. */
|
|
241
|
+
export declare const MESH_GLYPH_PLACEMENTS_USERDATA = "meshGlyphPlacements";
|
|
217
242
|
/**
|
|
218
243
|
* Describes one AutoCAD SHAPE entity for rendering.
|
|
219
244
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultFontsPreset, FontLoadStatus } from '../font';
|
|
2
|
-
import { MemoryUsageReport } from '../memory';
|
|
2
|
+
import { MemoryUsageReport, TextRenderProfileSnapshot } from '../memory';
|
|
3
3
|
import { StyleManager } from '../renderer';
|
|
4
4
|
import { ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
|
|
5
5
|
import { MTextObject } from './baseRenderer';
|
|
@@ -92,6 +92,15 @@ export declare class UnifiedRenderer {
|
|
|
92
92
|
replaceMissedFonts(fonts: Record<string, number>): Promise<void>;
|
|
93
93
|
/** Clears session-scoped missed-font bookkeeping on the main thread and workers. */
|
|
94
94
|
clearMissedFonts(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Enables or disables {@link TextRenderProfiler} on the main thread and worker pool.
|
|
97
|
+
* When enabling, counters are reset for a fresh open-file session.
|
|
98
|
+
*/
|
|
99
|
+
setTextRenderProfilerEnabled(enabled: boolean): Promise<void>;
|
|
100
|
+
/** Resets main-thread text profiler counters (worker deltas merge into main). */
|
|
101
|
+
resetTextRenderProfiler(): void;
|
|
102
|
+
/** Snapshot of merged main + worker text-render timings. */
|
|
103
|
+
getTextRenderProfile(): TextRenderProfileSnapshot;
|
|
95
104
|
/**
|
|
96
105
|
* Returns font names for a predefined default-font preset.
|
|
97
106
|
*/
|
|
@@ -202,6 +202,10 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
202
202
|
* Render MText in one worker and return serialized data asynchronously.
|
|
203
203
|
*/
|
|
204
204
|
asyncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
205
|
+
/**
|
|
206
|
+
* Enables or disables {@link TextRenderProfiler} on every worker isolate.
|
|
207
|
+
*/
|
|
208
|
+
setTextRenderProfilerEnabled(enabled: boolean): Promise<void>;
|
|
205
209
|
/**
|
|
206
210
|
* Render MText synchronously.
|
|
207
211
|
* Notes: It isn't supported yet.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/mtext-renderer",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6",
|
|
4
4
|
"description": "AutoCAD MText renderer based on Three.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "MLight Lee <mlight.lee@outlook.com>",
|
|
@@ -51,12 +51,13 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@mlightcad/mtext-parser": "^1.5.5",
|
|
53
53
|
"@types/opentype.js": "^1.3.10",
|
|
54
|
-
"@types/three": "^0.
|
|
54
|
+
"@types/three": "^0.186.0",
|
|
55
|
+
"three": "^0.186.1",
|
|
55
56
|
"vitest": "^3.2.4"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
59
|
"@mlightcad/mtext-parser": "^1.5.5",
|
|
59
|
-
"three": "
|
|
60
|
+
"three": ">=0.185.1"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"build": "tsc && vite build -c vite.config.main.ts && vite build -c vite.config.worker.ts",
|