@mlightcad/mtext-renderer 0.10.4 → 0.10.5
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 +48 -13
- package/dist/index.js +2046 -2013
- package/dist/index.umd.cjs +6 -6
- package/dist/mtext-renderer-worker.js +28025 -27976
- package/lib/renderer/colorUtils.d.ts +2 -0
- package/lib/renderer/defaultStyleManager.d.ts +4 -4
- package/lib/renderer/index.d.ts +1 -0
- package/lib/renderer/mtextProcessor.d.ts +5 -2
- package/lib/renderer/styleManager.d.ts +3 -3
- package/lib/renderer/types.d.ts +18 -24
- package/lib/worker/unifiedRenderer.d.ts +2 -0
- package/lib/worker/webWorkerRenderer.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleManager } from './styleManager';
|
|
2
|
-
import {
|
|
2
|
+
import { ColorSettings } from './types';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
/**
|
|
5
5
|
* Class to manage basic text style
|
|
@@ -8,11 +8,11 @@ export declare class DefaultStyleManager implements StyleManager {
|
|
|
8
8
|
private lineBasicMaterials;
|
|
9
9
|
private meshBasicMaterials;
|
|
10
10
|
unsupportedTextStyles: Record<string, number>;
|
|
11
|
-
getMeshBasicMaterial(
|
|
12
|
-
getLineBasicMaterial(
|
|
11
|
+
getMeshBasicMaterial(colorSettings: ColorSettings): THREE.Material;
|
|
12
|
+
getLineBasicMaterial(colorSettings: ColorSettings): THREE.Material;
|
|
13
13
|
/**
|
|
14
14
|
* Builds a stable material key from traits.
|
|
15
15
|
* Key differs for shader vs basic, ByLayer vs ByEntity.
|
|
16
16
|
*/
|
|
17
|
-
protected buildKey(
|
|
17
|
+
protected buildKey(colorSettings: ColorSettings): string;
|
|
18
18
|
}
|
package/lib/renderer/index.d.ts
CHANGED
|
@@ -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 { LineLayout, MTextFlowDirection, TextStyle } from './types';
|
|
4
|
+
import { ColorSettings, LineLayout, MTextFlowDirection, TextStyle } from './types';
|
|
5
5
|
import * as THREE from 'three';
|
|
6
6
|
export interface MTextFormatOptions {
|
|
7
7
|
/**
|
|
@@ -50,6 +50,7 @@ export interface MTextFormatOptions {
|
|
|
50
50
|
*/
|
|
51
51
|
export declare class MTextProcessor {
|
|
52
52
|
private _style;
|
|
53
|
+
private _colorSettings;
|
|
53
54
|
private _styleManager;
|
|
54
55
|
private _fontManager;
|
|
55
56
|
private _options;
|
|
@@ -87,7 +88,7 @@ export declare class MTextProcessor {
|
|
|
87
88
|
* @param fontManager Input font manager instance
|
|
88
89
|
* @param options Input formating options
|
|
89
90
|
*/
|
|
90
|
-
constructor(style: TextStyle, styleManager: StyleManager, fontManager: FontManager, options: MTextFormatOptions);
|
|
91
|
+
constructor(style: TextStyle, colorSettings: ColorSettings, styleManager: StyleManager, fontManager: FontManager, options: MTextFormatOptions);
|
|
91
92
|
get fontManager(): FontManager;
|
|
92
93
|
get styleManager(): StyleManager;
|
|
93
94
|
get textStyle(): TextStyle;
|
|
@@ -300,4 +301,6 @@ export declare class MTextProcessor {
|
|
|
300
301
|
private toThreeObject;
|
|
301
302
|
private changeFontSizeScaleFactor;
|
|
302
303
|
private changeFontHeight;
|
|
304
|
+
private resolveBaseColor;
|
|
305
|
+
private getMaterialColorSettings;
|
|
303
306
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorSettings } from './types';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
/**
|
|
4
4
|
* Class to manage materials used by texts
|
|
@@ -10,11 +10,11 @@ export interface StyleManager {
|
|
|
10
10
|
* @param traits - Traits to define one mesh basic material
|
|
11
11
|
* @returns - One reusable material for mesh type font.
|
|
12
12
|
*/
|
|
13
|
-
getMeshBasicMaterial(
|
|
13
|
+
getMeshBasicMaterial(colorSettings: ColorSettings): THREE.Material;
|
|
14
14
|
/**
|
|
15
15
|
* Gets one reusable material for line type font. If not found in cache, just create one.
|
|
16
16
|
* @param traits - Traits to define one line basic material
|
|
17
17
|
* @returns - One reusable material for line type font.
|
|
18
18
|
*/
|
|
19
|
-
getLineBasicMaterial(
|
|
19
|
+
getLineBasicMaterial(colorSettings: ColorSettings): THREE.Material;
|
|
20
20
|
}
|
package/lib/renderer/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MTextColor } from '@mlightcad/mtext-parser';
|
|
1
2
|
import * as THREE from 'three';
|
|
2
3
|
/**
|
|
3
4
|
* A 3D point in drawing coordinates.
|
|
@@ -115,22 +116,26 @@ export declare enum CharBoxType {
|
|
|
115
116
|
* Sentinel character used internally to represent a stack divider line.
|
|
116
117
|
*/
|
|
117
118
|
export declare const STACK_DIVIDER_CHAR = "\uE000";
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Defines color settings for text rendering, including layer/material resolution
|
|
121
|
+
* and ByLayer/ByBlock fallback colors.
|
|
122
|
+
*/
|
|
123
|
+
export interface ColorSettings {
|
|
124
|
+
/** The color value to use when text is set to "by layer" color mode */
|
|
125
|
+
byLayerColor: number;
|
|
126
|
+
/** The color value to use when text is set to "by block" color mode */
|
|
127
|
+
byBlockColor: number;
|
|
128
|
+
/** Optional layer name used when resolving materials */
|
|
123
129
|
layer?: string;
|
|
124
130
|
/**
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
color: number;
|
|
128
|
-
/**
|
|
129
|
-
* One flag to indicate whether the color is by layer. If it is true, it means that the
|
|
130
|
-
* material become invalid once layer color changed.
|
|
131
|
+
* Default text color. Use `MTextColor.aci === 256` to indicate ByLayer.
|
|
131
132
|
*/
|
|
132
|
-
|
|
133
|
+
color: MTextColor;
|
|
133
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Create default color settings (ByLayer + white fallback).
|
|
137
|
+
*/
|
|
138
|
+
export declare const createDefaultColorSettings: () => ColorSettings;
|
|
134
139
|
/**
|
|
135
140
|
* Represents the data structure for multiline text (MText) entities.
|
|
136
141
|
* Contains all necessary properties to define the appearance and positioning of text.
|
|
@@ -164,7 +169,7 @@ export interface MTextData {
|
|
|
164
169
|
* This interface contains properties that control various aspects of text rendering including font,
|
|
165
170
|
* dimensions, and display characteristics.
|
|
166
171
|
*/
|
|
167
|
-
export interface TextStyle
|
|
172
|
+
export interface TextStyle {
|
|
168
173
|
/** The unique name identifier for this text style */
|
|
169
174
|
name: string;
|
|
170
175
|
/** Flag indicating standard text style settings. Controls various text generation behaviors */
|
|
@@ -186,14 +191,3 @@ export interface TextStyle extends StyleTraits {
|
|
|
186
191
|
/** Optional extended font settings or alternative font specification */
|
|
187
192
|
extendedFont?: string;
|
|
188
193
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Defines the default color settings for special color modes in text rendering.
|
|
191
|
-
* These settings are used to resolve color values when text uses layer-dependent
|
|
192
|
-
* or block-dependent coloring.
|
|
193
|
-
*/
|
|
194
|
-
export interface ColorSettings {
|
|
195
|
-
/** The color value to use when text is set to "by layer" color mode */
|
|
196
|
-
byLayerColor: number;
|
|
197
|
-
/** The color value to use when text is set to "by block" color mode */
|
|
198
|
-
byBlockColor: number;
|
|
199
|
-
}
|
|
@@ -40,12 +40,14 @@ export declare class UnifiedRenderer {
|
|
|
40
40
|
getDefaultMode(): RenderMode;
|
|
41
41
|
/**
|
|
42
42
|
* Render MText using the current mode asynchronously.
|
|
43
|
+
* @param colorSettings - Optional color context (ByLayer, ByBlock colors).
|
|
43
44
|
* @param mode - Rendering mode used. If undefined, the default rendering mode is used.
|
|
44
45
|
*/
|
|
45
46
|
asyncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings, mode?: RenderMode): Promise<MTextObject>;
|
|
46
47
|
/**
|
|
47
48
|
* Render MText using the current mode synchronously. Main thread render is always used
|
|
48
49
|
* for this function because web worker renderer doesn't support rendering synchronously.
|
|
50
|
+
* @param colorSettings - Optional color context (ByLayer, ByBlock colors).
|
|
49
51
|
*/
|
|
50
52
|
syncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
|
|
51
53
|
/**
|
|
@@ -178,7 +178,8 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
178
178
|
/**
|
|
179
179
|
* Reconstruct MText object from JSON serialized data
|
|
180
180
|
*/
|
|
181
|
-
reconstructMText(serializedData: SerializedMText,
|
|
181
|
+
reconstructMText(serializedData: SerializedMText, colorSettings: ColorSettings): MTextObject;
|
|
182
|
+
private buildMaterialColorSettings;
|
|
182
183
|
private deserializeCharBoxes;
|
|
183
184
|
private collectLayout;
|
|
184
185
|
/**
|