@mlightcad/mtext-renderer 0.10.3 → 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 CHANGED
@@ -332,7 +332,7 @@ classDiagram
332
332
 
333
333
  ```typescript
334
334
  import * as THREE from 'three';
335
- import { FontManager, MText, StyleManager } from '@mlightcad/mtext-renderer';
335
+ import { FontManager, MText, MTextColor, StyleManager } from '@mlightcad/mtext-renderer';
336
336
 
337
337
  // Initialize core components
338
338
  const fontManager = FontManager.instance;
@@ -349,6 +349,13 @@ const mtextContent = {
349
349
  position: new THREE.Vector3(0, 0, 0),
350
350
  };
351
351
 
352
+ const colorSettings = {
353
+ layer: '0',
354
+ color: new MTextColor(256),
355
+ byLayerColor: 0xffffff,
356
+ byBlockColor: 0xffffff,
357
+ };
358
+
352
359
  // Create MText instance with style
353
360
  const mtext = new MText(
354
361
  mtextContent,
@@ -362,10 +369,10 @@ const mtext = new MText(
362
369
  lastHeight: 0.1,
363
370
  font: 'Standard',
364
371
  bigFont: '',
365
- color: 0xffffff,
366
372
  },
367
373
  styleManager,
368
- fontManager
374
+ fontManager,
375
+ colorSettings
369
376
  );
370
377
 
371
378
  // Build geometry and load fonts on demand
@@ -381,7 +388,14 @@ scene.add(mtext);
381
388
  // Ensure required fonts are loaded beforehand
382
389
  await fontManager.loadFontsByNames(['simsun']);
383
390
 
384
- const mtext = new MText(mtextContent, textStyle, styleManager, fontManager);
391
+ const colorSettings = {
392
+ layer: '0',
393
+ color: new MTextColor(256),
394
+ byLayerColor: 0xffffff,
395
+ byBlockColor: 0xffffff,
396
+ };
397
+
398
+ const mtext = new MText(mtextContent, textStyle, styleManager, fontManager, colorSettings);
385
399
 
386
400
  // Build geometry synchronously (no awaits here)
387
401
  mtext.syncDraw();
@@ -393,16 +407,23 @@ scene.add(mtext);
393
407
  ### Using MainThreadRenderer
394
408
 
395
409
  ```typescript
396
- import { MainThreadRenderer } from '@mlightcad/mtext-renderer';
410
+ import { MainThreadRenderer, MTextColor } from '@mlightcad/mtext-renderer';
397
411
 
398
412
  // Create main thread renderer
399
413
  const renderer = new MainThreadRenderer();
400
414
 
415
+ const colorSettings = {
416
+ layer: '0',
417
+ color: new MTextColor(256),
418
+ byLayerColor: 0xffffff,
419
+ byBlockColor: 0xffffff,
420
+ };
421
+
401
422
  // Render MText content asynchronously (fonts are loaded on demand)
402
423
  const mtextObject = await renderer.asyncRenderMText(
403
424
  mtextContent,
404
425
  textStyle,
405
- { byLayerColor: 0xffffff, byBlockColor: 0xffffff }
426
+ colorSettings
406
427
  );
407
428
 
408
429
  // Add to scene
@@ -413,7 +434,7 @@ scene.add(mtextObject);
413
434
  const syncObject = renderer.syncRenderMText(
414
435
  mtextContent,
415
436
  textStyle,
416
- { byLayerColor: 0xffffff, byBlockColor: 0xffffff }
437
+ colorSettings
417
438
  );
418
439
  scene.add(syncObject);
419
440
  ```
@@ -421,11 +442,18 @@ scene.add(syncObject);
421
442
  ### Using WebWorkerRenderer
422
443
 
423
444
  ```typescript
424
- import { WebWorkerRenderer } from '@mlightcad/mtext-renderer';
445
+ import { WebWorkerRenderer, MTextColor } from '@mlightcad/mtext-renderer';
425
446
 
426
447
  // Create worker renderer with custom pool size
427
448
  const workerRenderer = new WebWorkerRenderer({ poolSize: 4 }); // 4 workers
428
449
 
450
+ const colorSettings = {
451
+ layer: '0',
452
+ color: new MTextColor(256),
453
+ byLayerColor: 0xffffff,
454
+ byBlockColor: 0xffffff,
455
+ };
456
+
429
457
  // Optionally preload fonts once via a coordinator to avoid duplicate concurrent loads
430
458
  // await workerRenderer.loadFonts(['simsun', 'arial']);
431
459
 
@@ -433,7 +461,7 @@ const workerRenderer = new WebWorkerRenderer({ poolSize: 4 }); // 4 workers
433
461
  const mtextObject = await workerRenderer.asyncRenderMText(
434
462
  mtextContent,
435
463
  textStyle,
436
- { byLayerColor: 0xffffff, byBlockColor: 0xffffff }
464
+ colorSettings
437
465
  );
438
466
 
439
467
  // Add to scene
@@ -448,16 +476,23 @@ Note: Synchronous rendering is not supported in worker mode.
448
476
  ### Using UnifiedRenderer
449
477
 
450
478
  ```typescript
451
- import { UnifiedRenderer } from '@mlightcad/mtext-renderer';
479
+ import { UnifiedRenderer, MTextColor } from '@mlightcad/mtext-renderer';
452
480
 
453
481
  // Create unified renderer with default mode 'main' (optional worker config as second param)
454
482
  const unifiedRenderer = new UnifiedRenderer('main');
455
483
 
484
+ const colorSettings = {
485
+ layer: '0',
486
+ color: new MTextColor(256),
487
+ byLayerColor: 0xffffff,
488
+ byBlockColor: 0xffffff,
489
+ };
490
+
456
491
  // Render using default mode (main) asynchronously (fonts loaded on demand)
457
492
  let mtextObject = await unifiedRenderer.asyncRenderMText(
458
493
  mtextContent,
459
494
  textStyle,
460
- { byLayerColor: 0xffffff, byBlockColor: 0xffffff }
495
+ colorSettings
461
496
  );
462
497
 
463
498
  scene.add(mtextObject);
@@ -470,7 +505,7 @@ unifiedRenderer.setDefaultMode('worker');
470
505
  mtextObject = await unifiedRenderer.asyncRenderMText(
471
506
  heavyMtextContent,
472
507
  textStyle,
473
- { byLayerColor: 0xffffff, byBlockColor: 0xffffff },
508
+ colorSettings,
474
509
  'worker'
475
510
  );
476
511
 
@@ -521,4 +556,4 @@ MIT
521
556
 
522
557
  ## Contributing
523
558
 
524
- Contributions are welcome! Please read our contributing guidelines for details.
559
+ Contributions are welcome! Please read our contributing guidelines for details.