@mlightcad/mtext-renderer 0.10.13 → 0.10.14
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/dist/index.js +1305 -1185
- package/dist/index.umd.cjs +6 -6
- package/dist/mtext-renderer-worker.js +782 -662
- package/lib/renderer/mtext.d.ts +82 -9
- package/package.json +1 -1
package/lib/renderer/mtext.d.ts
CHANGED
|
@@ -109,20 +109,86 @@ export declare class MText extends THREE.Object3D {
|
|
|
109
109
|
*/
|
|
110
110
|
private createMTextGroup;
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
112
|
+
* Measures the logical text frame used by attachment-point anchoring.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Line-layout boxes include inter-line leading that is useful for hit testing, but
|
|
116
|
+
* that leading must not become extra padding above the first rendered line when
|
|
117
|
+
* aligning to top/middle/bottom attachment points. This method therefore prefers the
|
|
118
|
+
* visible geometry height from `geometryBox` when it is non-empty, and only falls
|
|
119
|
+
* back to `layoutHeight` when there are no measurable glyphs (e.g. empty or
|
|
120
|
+
* whitespace-only runs).
|
|
121
|
+
*
|
|
122
|
+
* @param object - Root group produced by layout; traversed for {@link LineLayout}
|
|
123
|
+
* metadata to locate the first line baseline.
|
|
124
|
+
* @param width - Column width used for horizontal anchoring when finite and
|
|
125
|
+
* positive; if not, horizontal extents are taken from `geometryBox`.
|
|
126
|
+
* @param layoutHeight - Total laid-out height from {@link MTextProcessor} when
|
|
127
|
+
* geometry height is unavailable or zero.
|
|
128
|
+
* @param geometryBox - Axis-aligned bounds of rendered primitives under `object`,
|
|
129
|
+
* typically from {@link THREE.Box3.setFromObject}.
|
|
130
|
+
* @param flowDirection - Optional flow; when {@link MTextFlowDirection.BOTTOM_TO_TOP},
|
|
131
|
+
* the vertical frame is anchored from the geometry minimum upward.
|
|
132
|
+
* @returns Metrics consumed by {@link MText.calculateAnchorPoint}.
|
|
133
|
+
*/
|
|
134
|
+
private measureAnchorMetrics;
|
|
135
|
+
/**
|
|
136
|
+
* Computes the 2D translation that maps the logical frame described by `metrics`
|
|
137
|
+
* so that the chosen AutoCAD-style attachment point coincides with the insertion
|
|
138
|
+
* origin (before rotation/insertion-point transforms applied later in
|
|
139
|
+
* {@link MText.loadMText}).
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* The returned vector is **added** to vertex positions and char-box metadata via
|
|
143
|
+
* `geometry.translate` / `CharBox.box.translate` / line `y` offsets. For `undefined`
|
|
144
|
+
* attachment, behavior matches {@link MTextAttachmentPoint.TopLeft}.
|
|
145
|
+
*
|
|
146
|
+
* @param metrics - Pre-anchoring frame from {@link MText.measureAnchorMetrics}.
|
|
147
|
+
* @param attachmentPoint - DWG attachment constant; determines which corner, edge
|
|
148
|
+
* center, or baseline of the frame is pinned to `(0,0)` in anchored space.
|
|
149
|
+
* @returns Translation `(x, y)` in drawing units applied uniformly to the laid-out
|
|
150
|
+
* group and its layout sidecars.
|
|
118
151
|
*/
|
|
119
152
|
private calculateAnchorPoint;
|
|
120
153
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
154
|
+
* Walks a laid-out MText subgraph and accumulates world-space character hit boxes and
|
|
155
|
+
* soft line rectangles for {@link MText.createLayoutData} (raycasting, cursors, debug).
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
* - When `userData.layout.chars` is present, entries are transformed with
|
|
159
|
+
* {@link buildCharBoxesFromObject} and appended to `chars`, then recursion stops
|
|
160
|
+
* for that branch (char metadata is authoritative).
|
|
161
|
+
* - When only mesh/line geometry exists, a single synthetic {@link CharBox} wrapping
|
|
162
|
+
* the geometry AABB may be emitted.
|
|
163
|
+
* - `userData.lineLayouts` rows are converted to world-space center `y` and height.
|
|
164
|
+
*
|
|
165
|
+
* @param object - Node to traverse (typically the root group from {@link MText.loadMText}).
|
|
166
|
+
* @param chars - Output collection; receives merged {@link CharBox} entries in world space.
|
|
167
|
+
* @param lines - Output collection; receives {@link LineLayout} summaries per line break.
|
|
124
168
|
*/
|
|
125
169
|
private getLayout;
|
|
170
|
+
/**
|
|
171
|
+
* Depth-first union of this MText’s {@link MText.box} from layout metadata and mesh
|
|
172
|
+
* geometry, while optionally tracking coarse line AABB in `lineBounds`.
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
* Priority order per node:
|
|
176
|
+
* 1. If `userData.logicalBounds` exists (set in {@link MText.loadMText}), union that
|
|
177
|
+
* axis-aligned rectangle transformed by `matrixWorld` — this reflects anchored
|
|
178
|
+
* logical extents even when individual glyphs are expensive to union.
|
|
179
|
+
* 2. Else if `userData.lineLayouts` exists, expand `lineBounds` from the world-space
|
|
180
|
+
* top/bottom of each line strip (used as a fallback when no logical bounds were
|
|
181
|
+
* written, e.g. legacy paths).
|
|
182
|
+
* 3. Else if `userData.layout.chars` exists, union each transformed char AABB.
|
|
183
|
+
* 4. Else for mesh/line primitives, union non-decoration geometry bounds.
|
|
184
|
+
* 5. Always recurse into children.
|
|
185
|
+
*
|
|
186
|
+
* @param object - Current scene graph node.
|
|
187
|
+
* @param lineBounds - Mutable accumulator: `hasLine`/`min*`/`max*` track the union of
|
|
188
|
+
* line-layout strips in world space; `hasLogicalBounds` flips true when any child
|
|
189
|
+
* contributed `logicalBounds` so {@link MText.syncDraw} can avoid double-counting
|
|
190
|
+
* vertical extent from line strips alone.
|
|
191
|
+
*/
|
|
126
192
|
private updateBoxFromObject;
|
|
127
193
|
/**
|
|
128
194
|
* Remove the specified object from its parent and release geometry and material resource used
|
|
@@ -130,5 +196,12 @@ export declare class MText extends THREE.Object3D {
|
|
|
130
196
|
* @param obj - Input object to dispose
|
|
131
197
|
*/
|
|
132
198
|
private disposeThreeObject;
|
|
199
|
+
/**
|
|
200
|
+
* Normalizes a font file reference to the lowercase stem used by
|
|
201
|
+
* {@link FontManager.loadFontsByNames} (strip extension).
|
|
202
|
+
*
|
|
203
|
+
* @param fontFileName - Style font path such as `arial.ttf` or extension-less name.
|
|
204
|
+
* @returns Lowercase name without the last extension segment, or `undefined` if empty.
|
|
205
|
+
*/
|
|
133
206
|
private getFontName;
|
|
134
207
|
}
|