@mlightcad/mtext-renderer 0.12.13 → 0.13.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/README.md +8 -4
- package/dist/index.js +3918 -5200
- package/dist/index.umd.cjs +8 -9
- package/dist/mtext-renderer-worker.js +6462 -6518
- package/lib/font/meshGlyphGeometry.d.ts +5 -5
- package/lib/font/textGeometryBuilder.d.ts +17 -0
- package/lib/index.d.ts +0 -1
- package/lib/renderer/mtextProcessor.d.ts +10 -3
- package/package.json +3 -2
|
@@ -2,9 +2,9 @@ import type * as THREE from 'three';
|
|
|
2
2
|
/**
|
|
3
3
|
* `userData` flag marking BufferGeometry produced for mesh (TTF/OTF) glyphs.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* stroke geometry
|
|
5
|
+
* Cached glyphs are baked to position and index buffers, so callers must not
|
|
6
|
+
* rely on `instanceof ShapeGeometry` to distinguish mesh glyphs from SHX
|
|
7
|
+
* stroke geometry.
|
|
8
8
|
*/
|
|
9
9
|
export declare const MESH_GLYPH_USER_DATA_KEY = "isMeshGlyph";
|
|
10
10
|
/**
|
|
@@ -13,8 +13,8 @@ export declare const MESH_GLYPH_USER_DATA_KEY = "isMeshGlyph";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const MESH_GLYPH_CACHE_SIZE = 1;
|
|
15
15
|
/**
|
|
16
|
-
* Returns true when `geometry` is a mesh-font glyph (filled
|
|
17
|
-
* including geometries
|
|
16
|
+
* Returns true when `geometry` is a mesh-font glyph (filled outline),
|
|
17
|
+
* including geometries baked down to a plain {@link THREE.BufferGeometry}.
|
|
18
18
|
*/
|
|
19
19
|
export declare function isMeshGlyphGeometry(geometry: THREE.BufferGeometry): boolean;
|
|
20
20
|
/**
|
|
@@ -44,4 +44,21 @@ export declare class TextGeometryBuilder {
|
|
|
44
44
|
* @returns The next write offset after all segments have been written.
|
|
45
45
|
*/
|
|
46
46
|
private static writeTransformedLineSegments;
|
|
47
|
+
/**
|
|
48
|
+
* Merges indexed mesh glyphs into one indexed triangle geometry, applying each
|
|
49
|
+
* glyph matrix while copying vertices.
|
|
50
|
+
*
|
|
51
|
+
* One write pass replaces per-glyph `clone` + `applyMatrix4` followed by a
|
|
52
|
+
* second copy inside `mergeGeometries`.
|
|
53
|
+
*
|
|
54
|
+
* @param entries Cached glyph geometries paired with their placement matrices.
|
|
55
|
+
* @returns A single indexed mesh geometry. Empty when `entries` is empty.
|
|
56
|
+
*/
|
|
57
|
+
static mergeMeshGeometries(entries: TransformedLineGeometryEntry[]): THREE.BufferGeometry;
|
|
58
|
+
/**
|
|
59
|
+
* Writes `position` transformed by `matrix` into `output` at `vertexBase`.
|
|
60
|
+
* Affine placement matrices keep `w` at 1; the perspective term matches
|
|
61
|
+
* {@link THREE.Vector3.applyMatrix4} for any other matrix.
|
|
62
|
+
*/
|
|
63
|
+
private static writeTransformedMeshPositions;
|
|
47
64
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -121,6 +121,8 @@ export declare class MTextProcessor {
|
|
|
121
121
|
private _processedCharCount;
|
|
122
122
|
/** Line glyph entries collected for batch geometry merge within a style segment. */
|
|
123
123
|
private _lineBatchEntries;
|
|
124
|
+
/** Mesh glyph entries collected for a single-pass triangle merge within a style segment. */
|
|
125
|
+
private _meshBatchEntries;
|
|
124
126
|
/** Current paragraph first-line indent in drawing units. */
|
|
125
127
|
private _currentIndent;
|
|
126
128
|
/** Current paragraph left margin in drawing units. */
|
|
@@ -415,15 +417,16 @@ export declare class MTextProcessor {
|
|
|
415
417
|
/**
|
|
416
418
|
* Appends one glyph's geometry to the active batch buffers and optional char boxes.
|
|
417
419
|
*
|
|
418
|
-
* Mesh fonts (tagged via {@link isMeshGlyphGeometry}) are
|
|
419
|
-
*
|
|
420
|
+
* Mesh fonts (tagged via {@link isMeshGlyphGeometry}) are queued in
|
|
421
|
+
* {@link _meshBatchEntries} and merged once via {@link TextGeometryBuilder.mergeMeshGeometries}.
|
|
422
|
+
* Line fonts are queued in
|
|
420
423
|
* {@link _lineBatchEntries} for later merge via {@link TextGeometryBuilder.mergeLineGeometries}.
|
|
421
424
|
*
|
|
422
425
|
* @param shape Source text shape for the glyph.
|
|
423
426
|
* @param label Character label stored on geometry and char boxes.
|
|
424
427
|
* @param canonical Untransformed glyph geometry from the font.
|
|
425
428
|
* @param matrix World transform to apply to the glyph.
|
|
426
|
-
* @param geometries
|
|
429
|
+
* @param geometries Unused. Mesh glyphs are queued on {@link _meshBatchEntries}.
|
|
427
430
|
* @param meshCharBoxes Accumulator for mesh-glyph picking boxes.
|
|
428
431
|
* @param lineCharBoxes Accumulator for line-glyph picking boxes.
|
|
429
432
|
*/
|
|
@@ -441,6 +444,10 @@ export declare class MTextProcessor {
|
|
|
441
444
|
* @returns A {@link THREE.Group} containing merged line/mesh objects and layout metadata.
|
|
442
445
|
*/
|
|
443
446
|
processText(tokens: Generator<MTextToken>): THREE.Group<THREE.Object3DEventMap>;
|
|
447
|
+
/**
|
|
448
|
+
* True when the current style segment still has mesh glyphs, line glyphs, or decorations to flush.
|
|
449
|
+
*/
|
|
450
|
+
private hasPendingDrawables;
|
|
444
451
|
/**
|
|
445
452
|
* Flushes pending geometry and char boxes into a styled THREE.js object on `group`.
|
|
446
453
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/mtext-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "AutoCAD MText renderer based on Three.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "MLight Lee <mlight.lee@outlook.com>",
|
|
@@ -43,18 +43,19 @@
|
|
|
43
43
|
"3d-text"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@mlightcad/mtext-parser": "^1.5.1",
|
|
47
46
|
"@mlightcad/shx-parser": "^1.4.5",
|
|
48
47
|
"iconv-lite": "^0.7.0",
|
|
49
48
|
"idb": "^8.0.3",
|
|
50
49
|
"opentype.js": "^2.0.0"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
52
|
+
"@mlightcad/mtext-parser": "^1.5.3",
|
|
53
53
|
"@types/opentype.js": "^1.3.10",
|
|
54
54
|
"@types/three": "^0.172.0",
|
|
55
55
|
"vitest": "^3.2.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
+
"@mlightcad/mtext-parser": "^1.5.3",
|
|
58
59
|
"three": "^0.172.0"
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|