@mlightcad/mtext-renderer 0.4.7 → 0.4.8
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/LICENSE +21 -0
- package/dist/index.js +862 -865
- package/dist/index.umd.cjs +2 -2
- package/dist/mtext-renderer-worker.js +18460 -0
- package/lib/cache/fontCacheManager.d.ts +0 -1
- package/lib/cache/schema.d.ts +0 -1
- package/lib/font/baseFont.d.ts +0 -1
- package/lib/font/defaultFontLoader.d.ts +0 -1
- package/lib/font/fontFactory.d.ts +0 -1
- package/lib/font/fontManager.d.ts +2 -3
- package/lib/font/meshFont.d.ts +0 -1
- package/lib/font/meshFontParser.d.ts +0 -1
- package/lib/font/shxFont.d.ts +0 -1
- package/lib/font/shxTextShape.d.ts +0 -1
- package/lib/renderer/mtext.d.ts +1 -1
- package/lib/renderer/mtextProcessor.d.ts +0 -1
- package/lib/worker/baseRenderer.d.ts +1 -1
- package/lib/worker/mainThreadRenderer.d.ts +1 -2
- package/lib/worker/unifiedRenderer.d.ts +5 -3
- package/lib/worker/webWorkerRenderer.d.ts +17 -3
- package/package.json +18 -23
- package/README.md +0 -504
- package/dist/assets/mtextWorker-BlkfNPdt.js +0 -7
- package/lib/worker/base-renderer.d.ts +0 -50
- package/lib/worker/main-thread-renderer.d.ts +0 -30
- package/lib/worker/mtext-worker.d.ts +0 -1
- package/lib/worker/unified-renderer.d.ts +0 -41
- package/lib/worker/web-worker-renderer.d.ts +0 -115
- package/lib/worker/worker-manager.d.ts +0 -113
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,113 +0,0 @@
|
|
|
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 {};
|