@mlightcad/mtext-renderer 0.12.0 → 0.12.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.
@@ -1,10 +1,30 @@
1
+ import { MTextColor } from '@mlightcad/mtext-parser';
1
2
  import { ColorSettings } from './types';
2
3
  export declare function resolveMTextColor(colorSettings: ColorSettings): number;
4
+ /** Wire-format for an `MTextColor` carried on worker glyph payloads. */
5
+ export interface SerializedMTextColor {
6
+ aci?: number | null;
7
+ rgbValue?: number | null;
8
+ }
9
+ /**
10
+ * Serializes an `MTextColor` for worker → main-thread transfer.
11
+ *
12
+ * Prefer this over baking only the resolved RGB: ACI 7 (canvas foreground) and
13
+ * ACI 255 (literal white) both resolve to `0xffffff` on a dark canvas, but only
14
+ * ACI 7 must invert when the background flips.
15
+ */
16
+ export declare function serializeMTextColor(color: MTextColor): SerializedMTextColor;
17
+ /** Revives a wire-format color into a real `MTextColor` instance. */
18
+ export declare function deserializeMTextColor(serialized?: SerializedMTextColor | null): MTextColor | undefined;
3
19
  /**
4
20
  * Rebuild ColorSettings for a worker-deserialized glyph material.
5
21
  *
6
- * Worker meshes already carry the final resolved RGB in their serialized
7
- * material. When the entity base color is ByLayer, preserve that semantic only
8
- * for glyphs that match the layer fallback color.
22
+ * Prefer {@link serializedColor} when the worker attached the original segment
23
+ * color (ACI / RGB). Falling back to resolved RGB alone cannot distinguish
24
+ * ACI 7 from ACI 255.
25
+ *
26
+ * Without a serialized color, preserve ByLayer / ByBlock / entity ACI when the
27
+ * glyph RGB still matches the entity base resolution; otherwise bake RGB for
28
+ * true inline overrides.
9
29
  */
10
- export declare function buildWorkerMaterialColorSettings(base: ColorSettings, resolvedColor: number, baseByLayer: boolean): ColorSettings;
30
+ export declare function buildWorkerMaterialColorSettings(base: ColorSettings, resolvedColor: number, baseByLayer: boolean, serializedColor?: SerializedMTextColor | null): ColorSettings;
@@ -113,6 +113,11 @@ interface SerializedChild {
113
113
  opacity: number;
114
114
  side?: number;
115
115
  linewidth?: number;
116
+ /** Original segment colour when the worker preserved ACI/RGB semantics. */
117
+ mtextColor?: {
118
+ aci?: number | null;
119
+ rgbValue?: number | null;
120
+ };
116
121
  };
117
122
  charBoxType?: CharBox['type'];
118
123
  lineLayouts?: Array<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",