@mlightcad/mtext-renderer 0.4.5 → 0.4.7
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 +249 -0
- package/dist/assets/mtextWorker-BlkfNPdt.js +7 -0
- package/dist/index.js +1621 -1335
- package/dist/index.umd.cjs +3 -3
- package/{dist → lib}/index.d.ts +1 -0
- package/lib/worker/base-renderer.d.ts +50 -0
- package/lib/worker/baseRenderer.d.ts +64 -0
- package/lib/worker/index.d.ts +5 -0
- package/lib/worker/main-thread-renderer.d.ts +30 -0
- package/lib/worker/mainThreadRenderer.d.ts +32 -0
- package/lib/worker/mtext-worker.d.ts +1 -0
- package/lib/worker/mtextWorker.d.ts +1 -0
- package/lib/worker/unified-renderer.d.ts +41 -0
- package/lib/worker/unifiedRenderer.d.ts +44 -0
- package/lib/worker/web-worker-renderer.d.ts +115 -0
- package/lib/worker/webWorkerRenderer.d.ts +124 -0
- package/lib/worker/worker-manager.d.ts +113 -0
- package/package.json +3 -2
- /package/{dist → lib}/cache/fontCacheManager.d.ts +0 -0
- /package/{dist → lib}/cache/index.d.ts +0 -0
- /package/{dist → lib}/cache/schema.d.ts +0 -0
- /package/{dist → lib}/common/eventManager.d.ts +0 -0
- /package/{dist → lib}/common/index.d.ts +0 -0
- /package/{dist → lib}/common/utils.d.ts +0 -0
- /package/{dist → lib}/font/baseFont.d.ts +0 -0
- /package/{dist → lib}/font/baseTextShape.d.ts +0 -0
- /package/{dist → lib}/font/charGeometryCache.d.ts +0 -0
- /package/{dist → lib}/font/defaultFontLoader.d.ts +0 -0
- /package/{dist → lib}/font/font.d.ts +0 -0
- /package/{dist → lib}/font/fontFactory.d.ts +0 -0
- /package/{dist → lib}/font/fontLoader.d.ts +0 -0
- /package/{dist → lib}/font/fontManager.d.ts +0 -0
- /package/{dist → lib}/font/index.d.ts +0 -0
- /package/{dist → lib}/font/meshFont.d.ts +0 -0
- /package/{dist → lib}/font/meshFontParser.d.ts +0 -0
- /package/{dist → lib}/font/meshTextShape.d.ts +0 -0
- /package/{dist → lib}/font/normalComputationToggle.d.ts +0 -0
- /package/{dist → lib}/font/shxFont.d.ts +0 -0
- /package/{dist → lib}/font/shxTextShape.d.ts +0 -0
- /package/{dist → lib}/renderer/index.d.ts +0 -0
- /package/{dist → lib}/renderer/mtext.d.ts +0 -0
- /package/{dist → lib}/renderer/mtextProcessor.d.ts +0 -0
- /package/{dist → lib}/renderer/styleManager.d.ts +0 -0
- /package/{dist → lib}/renderer/types.d.ts +0 -0
package/{dist → lib}/index.d.ts
RENAMED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
/**
|
|
4
|
+
* Defines the common rendering contract for producing Three.js objects from MText content.
|
|
5
|
+
*
|
|
6
|
+
* Implementations may render on the main thread or delegate work to a Web Worker,
|
|
7
|
+
* but they must expose the same high-level API so callers can switch strategies
|
|
8
|
+
* without changing usage.
|
|
9
|
+
*/
|
|
10
|
+
export interface MTextBaseRenderer {
|
|
11
|
+
/**
|
|
12
|
+
* Render the provided MText content into a Three.js object hierarchy.
|
|
13
|
+
*
|
|
14
|
+
* The returned root object contains meshes/lines for glyphs and exposes a
|
|
15
|
+
* bounding box on `object.box` if available.
|
|
16
|
+
*
|
|
17
|
+
* @param mtextContent Structured MText input (text, height, width, position).
|
|
18
|
+
* @param textStyle Text style to apply (font, width factor, oblique, etc.).
|
|
19
|
+
* @param colorSettings Optional color context (ByLayer, ByBlock colors).
|
|
20
|
+
* @returns A Promise resolving to a populated `THREE.Object3D` ready to add to a scene.
|
|
21
|
+
*/
|
|
22
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<THREE.Object3D>;
|
|
23
|
+
/**
|
|
24
|
+
* Ensure the specified fonts are available to the renderer.
|
|
25
|
+
*
|
|
26
|
+
* Implementations should load and cache missing fonts; repeated calls should be cheap.
|
|
27
|
+
*
|
|
28
|
+
* @param fonts Font names to load (without extension for built-ins).
|
|
29
|
+
* @returns A Promise with the list of fonts that were processed.
|
|
30
|
+
*/
|
|
31
|
+
loadFonts(fonts: string[]): Promise<{
|
|
32
|
+
loaded: string[];
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve the list of fonts that can be used by the renderer.
|
|
36
|
+
*
|
|
37
|
+
* The shape of each font entry is implementation-defined but should include a displayable name.
|
|
38
|
+
*
|
|
39
|
+
* @returns A Promise with available font metadata.
|
|
40
|
+
*/
|
|
41
|
+
getAvailableFonts(): Promise<{
|
|
42
|
+
fonts: any[];
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Release any resources owned by the renderer (e.g., terminate Web Workers).
|
|
46
|
+
*
|
|
47
|
+
* Safe to call multiple times.
|
|
48
|
+
*/
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a rendered MText object that extends THREE.Object3D with additional MText-specific properties.
|
|
5
|
+
* This interface defines the contract for objects returned by MText renderers.
|
|
6
|
+
*/
|
|
7
|
+
export interface MTextObject extends THREE.Object3D {
|
|
8
|
+
/**
|
|
9
|
+
* The bounding box of the MText object in local coordinates.
|
|
10
|
+
* This box represents the bounds of the text content without considering transformations.
|
|
11
|
+
* To get the world-space bounding box, apply the object's world matrix to this box.
|
|
12
|
+
*/
|
|
13
|
+
box: THREE.Box3;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Defines the common rendering contract for producing Three.js objects from MText content.
|
|
17
|
+
*
|
|
18
|
+
* Implementations may render on the main thread or delegate work to a Web Worker,
|
|
19
|
+
* but they must expose the same high-level API so callers can switch strategies
|
|
20
|
+
* without changing usage.
|
|
21
|
+
*/
|
|
22
|
+
export interface MTextBaseRenderer {
|
|
23
|
+
/**
|
|
24
|
+
* Render the provided MText content into a Three.js object hierarchy.
|
|
25
|
+
*
|
|
26
|
+
* The returned root object contains meshes/lines for glyphs and exposes a
|
|
27
|
+
* bounding box on `object.box`.
|
|
28
|
+
*
|
|
29
|
+
* @param mtextContent Structured MText input (text, height, width, position).
|
|
30
|
+
* @param textStyle Text style to apply (font, width factor, oblique, etc.).
|
|
31
|
+
* @param colorSettings Optional color context (ByLayer, ByBlock colors).
|
|
32
|
+
* @returns A Promise resolving to a populated `MTextObject` ready to add to a scene.
|
|
33
|
+
*/
|
|
34
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
35
|
+
/**
|
|
36
|
+
* Ensure the specified fonts are available to the renderer.
|
|
37
|
+
*
|
|
38
|
+
* Implementations should load and cache missing fonts; repeated calls should be cheap.
|
|
39
|
+
*
|
|
40
|
+
* @param fonts Font names to load (without extension for built-ins).
|
|
41
|
+
* @returns A Promise with the list of fonts that were processed.
|
|
42
|
+
*/
|
|
43
|
+
loadFonts(fonts: string[]): Promise<{
|
|
44
|
+
loaded: string[];
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieve the list of fonts that can be used by the renderer.
|
|
48
|
+
*
|
|
49
|
+
* The shape of each font entry is implementation-defined but should include a displayable name.
|
|
50
|
+
*
|
|
51
|
+
* @returns A Promise with available font metadata.
|
|
52
|
+
*/
|
|
53
|
+
getAvailableFonts(): Promise<{
|
|
54
|
+
fonts: Array<{
|
|
55
|
+
name: string[];
|
|
56
|
+
}>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Release any resources owned by the renderer (e.g., terminate Web Workers).
|
|
60
|
+
*
|
|
61
|
+
* Safe to call multiple times.
|
|
62
|
+
*/
|
|
63
|
+
destroy(): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import { MTextBaseRenderer } from './base-renderer';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
/**
|
|
5
|
+
* Main thread renderer for MText objects
|
|
6
|
+
* This provides the same interface as the worker but runs in the main thread
|
|
7
|
+
*/
|
|
8
|
+
export declare class MainThreadRenderer implements MTextBaseRenderer {
|
|
9
|
+
private fontManager;
|
|
10
|
+
private styleManager;
|
|
11
|
+
private fontLoader;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Render MText directly in the main thread
|
|
15
|
+
*/
|
|
16
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<THREE.Object3D>;
|
|
17
|
+
/**
|
|
18
|
+
* Load fonts in the main thread
|
|
19
|
+
*/
|
|
20
|
+
loadFonts(fonts: string[]): Promise<{
|
|
21
|
+
loaded: string[];
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Get available fonts from the main thread
|
|
25
|
+
*/
|
|
26
|
+
getAvailableFonts(): Promise<{
|
|
27
|
+
fonts: any[];
|
|
28
|
+
}>;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import { MTextBaseRenderer, MTextObject } from './baseRenderer';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main thread renderer for MText objects
|
|
6
|
+
* This provides the same interface as the worker but runs in the main thread
|
|
7
|
+
*/
|
|
8
|
+
export declare class MainThreadRenderer implements MTextBaseRenderer {
|
|
9
|
+
private fontManager;
|
|
10
|
+
private styleManager;
|
|
11
|
+
private fontLoader;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Render MText directly in the main thread
|
|
15
|
+
*/
|
|
16
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
17
|
+
/**
|
|
18
|
+
* Load fonts in the main thread
|
|
19
|
+
*/
|
|
20
|
+
loadFonts(fonts: string[]): Promise<{
|
|
21
|
+
loaded: string[];
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Get available fonts from the main thread
|
|
25
|
+
*/
|
|
26
|
+
getAvailableFonts(): Promise<{
|
|
27
|
+
fonts: Array<{
|
|
28
|
+
name: string[];
|
|
29
|
+
}>;
|
|
30
|
+
}>;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
export type RenderMode = 'main' | 'worker';
|
|
4
|
+
/**
|
|
5
|
+
* Unified renderer that can work in both main thread and web worker modes
|
|
6
|
+
*/
|
|
7
|
+
export declare class UnifiedRenderer {
|
|
8
|
+
private workerManager;
|
|
9
|
+
private mainThreadRenderer;
|
|
10
|
+
private adapter;
|
|
11
|
+
private currentMode;
|
|
12
|
+
constructor(mode?: RenderMode);
|
|
13
|
+
/**
|
|
14
|
+
* Switch between main thread and worker rendering modes
|
|
15
|
+
*/
|
|
16
|
+
switchMode(mode: RenderMode): void;
|
|
17
|
+
/**
|
|
18
|
+
* Get current rendering mode
|
|
19
|
+
*/
|
|
20
|
+
getMode(): RenderMode;
|
|
21
|
+
/**
|
|
22
|
+
* Render MText using the current mode
|
|
23
|
+
*/
|
|
24
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<THREE.Object3D>;
|
|
25
|
+
/**
|
|
26
|
+
* Load fonts using the current mode
|
|
27
|
+
*/
|
|
28
|
+
loadFonts(fonts: string[]): Promise<{
|
|
29
|
+
loaded: string[];
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Get available fonts using the current mode
|
|
33
|
+
*/
|
|
34
|
+
getAvailableFonts(): Promise<{
|
|
35
|
+
fonts: any[];
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Clean up resources
|
|
39
|
+
*/
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import { MTextObject } from './baseRenderer';
|
|
3
|
+
|
|
4
|
+
export type RenderMode = 'main' | 'worker';
|
|
5
|
+
/**
|
|
6
|
+
* Unified renderer that can work in both main thread and web worker modes
|
|
7
|
+
*/
|
|
8
|
+
export declare class UnifiedRenderer {
|
|
9
|
+
private workerManager;
|
|
10
|
+
private mainThreadRenderer;
|
|
11
|
+
private adapter;
|
|
12
|
+
private currentMode;
|
|
13
|
+
constructor(mode?: RenderMode);
|
|
14
|
+
/**
|
|
15
|
+
* Switch between main thread and worker rendering modes
|
|
16
|
+
*/
|
|
17
|
+
switchMode(mode: RenderMode): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get current rendering mode
|
|
20
|
+
*/
|
|
21
|
+
getMode(): RenderMode;
|
|
22
|
+
/**
|
|
23
|
+
* Render MText using the current mode
|
|
24
|
+
*/
|
|
25
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
26
|
+
/**
|
|
27
|
+
* Load fonts using the current mode
|
|
28
|
+
*/
|
|
29
|
+
loadFonts(fonts: string[]): Promise<{
|
|
30
|
+
loaded: string[];
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Get available fonts using the current mode
|
|
34
|
+
*/
|
|
35
|
+
getAvailableFonts(): Promise<{
|
|
36
|
+
fonts: Array<{
|
|
37
|
+
name: string[];
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Clean up resources
|
|
42
|
+
*/
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import { MTextBaseRenderer } from './base-renderer';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
interface SerializedMText {
|
|
5
|
+
type: string;
|
|
6
|
+
position: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
z: number;
|
|
10
|
+
};
|
|
11
|
+
rotation: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
w: number;
|
|
16
|
+
};
|
|
17
|
+
scale: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
z: number;
|
|
21
|
+
};
|
|
22
|
+
box: {
|
|
23
|
+
min: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
z: number;
|
|
27
|
+
};
|
|
28
|
+
max: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
z: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
children: SerializedChild[];
|
|
35
|
+
}
|
|
36
|
+
interface SerializedChild {
|
|
37
|
+
type: 'mesh' | 'line';
|
|
38
|
+
position: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
z: number;
|
|
42
|
+
};
|
|
43
|
+
rotation: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
z: number;
|
|
47
|
+
w: number;
|
|
48
|
+
};
|
|
49
|
+
scale: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
z: number;
|
|
53
|
+
};
|
|
54
|
+
geometry: {
|
|
55
|
+
attributes: {
|
|
56
|
+
[key: string]: {
|
|
57
|
+
arrayBuffer: ArrayBuffer;
|
|
58
|
+
byteOffset: number;
|
|
59
|
+
length: number;
|
|
60
|
+
itemSize: number;
|
|
61
|
+
normalized: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
index: {
|
|
65
|
+
arrayBuffer: ArrayBuffer;
|
|
66
|
+
byteOffset: number;
|
|
67
|
+
length: number;
|
|
68
|
+
} | null;
|
|
69
|
+
};
|
|
70
|
+
material: {
|
|
71
|
+
type: string;
|
|
72
|
+
color: number;
|
|
73
|
+
transparent: boolean;
|
|
74
|
+
opacity: number;
|
|
75
|
+
side?: number;
|
|
76
|
+
linewidth?: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Manages communication with the MText web worker
|
|
81
|
+
*/
|
|
82
|
+
export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
83
|
+
private worker;
|
|
84
|
+
private pendingRequests;
|
|
85
|
+
private requestId;
|
|
86
|
+
constructor();
|
|
87
|
+
private handleWorkerMessage;
|
|
88
|
+
private sendMessage;
|
|
89
|
+
/**
|
|
90
|
+
* Render MText in the worker and return serialized data
|
|
91
|
+
*/
|
|
92
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<THREE.Object3D>;
|
|
93
|
+
/**
|
|
94
|
+
* Load fonts in the worker
|
|
95
|
+
*/
|
|
96
|
+
loadFonts(fonts: string[]): Promise<{
|
|
97
|
+
loaded: string[];
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Get available fonts from the worker
|
|
101
|
+
*/
|
|
102
|
+
getAvailableFonts(): Promise<{
|
|
103
|
+
fonts: any[];
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Reconstruct MText object from JSON serialized data
|
|
107
|
+
*/
|
|
108
|
+
reconstructMText(serializedData: SerializedMText): THREE.Object3D;
|
|
109
|
+
/**
|
|
110
|
+
* Terminate the worker
|
|
111
|
+
*/
|
|
112
|
+
terminate(): void;
|
|
113
|
+
destroy(): void;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import { MTextBaseRenderer, MTextObject } from './baseRenderer';
|
|
3
|
+
|
|
4
|
+
interface SerializedMText {
|
|
5
|
+
type: string;
|
|
6
|
+
position: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
z: number;
|
|
10
|
+
};
|
|
11
|
+
rotation: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
w: number;
|
|
16
|
+
};
|
|
17
|
+
scale: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
z: number;
|
|
21
|
+
};
|
|
22
|
+
box: {
|
|
23
|
+
min: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
z: number;
|
|
27
|
+
};
|
|
28
|
+
max: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
z: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
children: SerializedChild[];
|
|
35
|
+
}
|
|
36
|
+
interface SerializedChild {
|
|
37
|
+
type: 'mesh' | 'line';
|
|
38
|
+
position: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
z: number;
|
|
42
|
+
};
|
|
43
|
+
rotation: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
z: number;
|
|
47
|
+
w: number;
|
|
48
|
+
};
|
|
49
|
+
scale: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
z: number;
|
|
53
|
+
};
|
|
54
|
+
geometry: {
|
|
55
|
+
attributes: {
|
|
56
|
+
[key: string]: {
|
|
57
|
+
arrayBuffer: ArrayBuffer;
|
|
58
|
+
byteOffset: number;
|
|
59
|
+
length: number;
|
|
60
|
+
itemSize: number;
|
|
61
|
+
normalized: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
index: {
|
|
65
|
+
arrayBuffer: ArrayBuffer;
|
|
66
|
+
byteOffset: number;
|
|
67
|
+
length: number;
|
|
68
|
+
componentType?: 'uint16' | 'uint32';
|
|
69
|
+
} | null;
|
|
70
|
+
};
|
|
71
|
+
material: {
|
|
72
|
+
type: string;
|
|
73
|
+
color: number;
|
|
74
|
+
transparent: boolean;
|
|
75
|
+
opacity: number;
|
|
76
|
+
side?: number;
|
|
77
|
+
linewidth?: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Manages communication with the MText web worker
|
|
82
|
+
*/
|
|
83
|
+
export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
84
|
+
private workers;
|
|
85
|
+
private inFlightPerWorker;
|
|
86
|
+
private pendingRequests;
|
|
87
|
+
private requestId;
|
|
88
|
+
private poolSize;
|
|
89
|
+
private readyPromise;
|
|
90
|
+
constructor(poolSize?: number);
|
|
91
|
+
private handleWorkerMessage;
|
|
92
|
+
private attachWorkerHandlers;
|
|
93
|
+
private pickLeastLoadedWorker;
|
|
94
|
+
private sendMessage;
|
|
95
|
+
private ensureInitialized;
|
|
96
|
+
/**
|
|
97
|
+
* Render MText in the worker and return serialized data
|
|
98
|
+
*/
|
|
99
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
100
|
+
/**
|
|
101
|
+
* Load fonts in the worker
|
|
102
|
+
*/
|
|
103
|
+
loadFonts(fonts: string[]): Promise<{
|
|
104
|
+
loaded: string[];
|
|
105
|
+
}>;
|
|
106
|
+
/**
|
|
107
|
+
* Get available fonts from the worker
|
|
108
|
+
*/
|
|
109
|
+
getAvailableFonts(): Promise<{
|
|
110
|
+
fonts: Array<{
|
|
111
|
+
name: string[];
|
|
112
|
+
}>;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Reconstruct MText object from JSON serialized data
|
|
116
|
+
*/
|
|
117
|
+
reconstructMText(serializedData: SerializedMText): MTextObject;
|
|
118
|
+
/**
|
|
119
|
+
* Terminate the worker
|
|
120
|
+
*/
|
|
121
|
+
terminate(): void;
|
|
122
|
+
destroy(): void;
|
|
123
|
+
}
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { MTextData, TextStyle, ColorSettings } from '../renderer/types';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
interface SerializedMText {
|
|
4
|
+
type: string;
|
|
5
|
+
position: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
z: number;
|
|
9
|
+
};
|
|
10
|
+
rotation: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
w: number;
|
|
15
|
+
};
|
|
16
|
+
scale: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
z: number;
|
|
20
|
+
};
|
|
21
|
+
box: {
|
|
22
|
+
min: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
z: number;
|
|
26
|
+
};
|
|
27
|
+
max: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
z: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
children: SerializedChild[];
|
|
34
|
+
}
|
|
35
|
+
interface SerializedChild {
|
|
36
|
+
type: 'mesh' | 'line';
|
|
37
|
+
position: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
z: number;
|
|
41
|
+
};
|
|
42
|
+
rotation: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
z: number;
|
|
46
|
+
w: number;
|
|
47
|
+
};
|
|
48
|
+
scale: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
z: number;
|
|
52
|
+
};
|
|
53
|
+
geometry: {
|
|
54
|
+
attributes: {
|
|
55
|
+
[key: string]: {
|
|
56
|
+
arrayBuffer: ArrayBuffer;
|
|
57
|
+
byteOffset: number;
|
|
58
|
+
length: number;
|
|
59
|
+
itemSize: number;
|
|
60
|
+
normalized: boolean;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
index: {
|
|
64
|
+
arrayBuffer: ArrayBuffer;
|
|
65
|
+
byteOffset: number;
|
|
66
|
+
length: number;
|
|
67
|
+
} | null;
|
|
68
|
+
};
|
|
69
|
+
material: {
|
|
70
|
+
type: string;
|
|
71
|
+
color: number;
|
|
72
|
+
transparent: boolean;
|
|
73
|
+
opacity: number;
|
|
74
|
+
side?: number;
|
|
75
|
+
linewidth?: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Manages communication with the MText web worker
|
|
80
|
+
*/
|
|
81
|
+
export declare class MTextWorkerManager {
|
|
82
|
+
private worker;
|
|
83
|
+
private pendingRequests;
|
|
84
|
+
private requestId;
|
|
85
|
+
constructor();
|
|
86
|
+
private handleWorkerMessage;
|
|
87
|
+
private sendMessage;
|
|
88
|
+
/**
|
|
89
|
+
* Render MText in the worker and return serialized data
|
|
90
|
+
*/
|
|
91
|
+
renderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<SerializedMText>;
|
|
92
|
+
/**
|
|
93
|
+
* Load fonts in the worker
|
|
94
|
+
*/
|
|
95
|
+
loadFonts(fonts: string[]): Promise<{
|
|
96
|
+
loaded: string[];
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Get available fonts from the worker
|
|
100
|
+
*/
|
|
101
|
+
getAvailableFonts(): Promise<{
|
|
102
|
+
fonts: any[];
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Reconstruct MText object from JSON serialized data
|
|
106
|
+
*/
|
|
107
|
+
reconstructMText(serializedData: SerializedMText): THREE.Object3D;
|
|
108
|
+
/**
|
|
109
|
+
* Terminate the worker
|
|
110
|
+
*/
|
|
111
|
+
terminate(): void;
|
|
112
|
+
}
|
|
113
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/mtext-renderer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "AutoCAD MText renderer based on Three.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
-
"types": "
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
+
"lib",
|
|
10
11
|
"README.md",
|
|
11
12
|
"package.json"
|
|
12
13
|
],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|