three-text 0.2.15 → 0.2.17

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.
@@ -34,6 +34,7 @@ export declare class GlyphGeometryBuilder {
34
34
  private wordCache;
35
35
  private contourCache;
36
36
  private clusteringCache;
37
+ private emptyGlyphs;
37
38
  constructor(cache: LRUCache<string, GlyphData>, loadedFont: LoadedFont);
38
39
  getOptimizationStats(): import("../geometry/PathOptimizer").OptimizationStats;
39
40
  setCurveFidelityConfig(config?: CurveFidelityConfig): void;
@@ -1,9 +1,10 @@
1
1
  import type { Path, ProcessedGeometry } from '../types';
2
2
  export declare class Tessellator {
3
- process(paths: Path[], removeOverlaps?: boolean, isCFF?: boolean): ProcessedGeometry;
3
+ process(paths: Path[], removeOverlaps?: boolean, isCFF?: boolean, needsExtrusionContours?: boolean): ProcessedGeometry;
4
4
  private tessellate;
5
5
  private pathsToContours;
6
6
  private performTessellation;
7
7
  private boundaryToContours;
8
- private reverseWinding;
8
+ private needsWindingNormalization;
9
+ private signedArea;
9
10
  }
@@ -47,6 +47,7 @@ export interface LineBreakOptions {
47
47
  hyphenate?: boolean;
48
48
  language?: string;
49
49
  measureText: (text: string) => number;
50
+ measureTextWidths?: (text: string) => number[];
50
51
  respectExistingBreaks?: boolean;
51
52
  hyphenationPatterns?: HyphenationPatternsMap;
52
53
  unitsPerEm?: number;
@@ -80,7 +81,7 @@ export declare class LineBreak {
80
81
  private static badness;
81
82
  static findHyphenationPoints(word: string, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number): number[];
82
83
  static itemizeText(text: string, measureText: (text: string) => number, // function to measure text width
83
- hyphenate?: boolean, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number, context?: LineBreakContext): Item[];
84
+ measureTextWidths: ((text: string) => number[]) | undefined, hyphenate?: boolean, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number, context?: LineBreakContext): Item[];
84
85
  static isCJK(char: string): boolean;
85
86
  static isCJClosingPunctuation(char: string): boolean;
86
87
  static isCJOpeningPunctuation(char: string): boolean;
@@ -41,4 +41,19 @@ export declare class TextLayout {
41
41
  };
42
42
  };
43
43
  };
44
+ computeAlignmentOffset(options: AlignmentOptions): {
45
+ offset: number;
46
+ adjustedBounds: {
47
+ min: {
48
+ x: number;
49
+ y: number;
50
+ z: number;
51
+ };
52
+ max: {
53
+ x: number;
54
+ y: number;
55
+ z: number;
56
+ };
57
+ };
58
+ };
44
59
  }
@@ -1,4 +1,5 @@
1
1
  import type { LoadedFont } from '../types';
2
2
  export declare class TextMeasurer {
3
+ static measureTextWidths(loadedFont: LoadedFont, text: string, letterSpacing?: number): number[];
3
4
  static measureTextWidth(loadedFont: LoadedFont, text: string, letterSpacing?: number): number;
4
5
  }
@@ -10,6 +10,7 @@ export interface WebGPUBufferSet {
10
10
  color?: GPUVertexBufferLayout;
11
11
  };
12
12
  indexCount: number;
13
+ indexFormat: GPUIndexFormat;
13
14
  dispose(): void;
14
15
  }
15
16
  export declare function createWebGPUBuffers(device: GPUDevice, textGeometry: TextGeometryInfo): WebGPUBufferSet;
@@ -4,17 +4,18 @@
4
4
  function createWebGPUBuffers(device, textGeometry) {
5
5
  const { vertices, normals, indices, colors } = textGeometry;
6
6
  const indexCount = indices.length;
7
+ const indexFormat = indices instanceof Uint16Array ? 'uint16' : 'uint32';
7
8
  // Interleave position and normal data for better cache coherency
8
9
  // Layout: [px, py, pz, nx, ny, nz, px, py, pz, nx, ny, nz, ...]
9
10
  const interleavedData = new Float32Array((vertices.length / 3) * 6);
10
11
  for (let i = 0; i < vertices.length / 3; i++) {
11
12
  const baseIndex = i * 6;
12
13
  const vertIndex = i * 3;
13
- // Position (NO FLIP - pass through)
14
+ // Position
14
15
  interleavedData[baseIndex] = vertices[vertIndex];
15
16
  interleavedData[baseIndex + 1] = vertices[vertIndex + 1];
16
17
  interleavedData[baseIndex + 2] = vertices[vertIndex + 2];
17
- // Normal (NO FLIP - pass through)
18
+ // Normal
18
19
  interleavedData[baseIndex + 3] = normals[vertIndex];
19
20
  interleavedData[baseIndex + 4] = normals[vertIndex + 1];
20
21
  interleavedData[baseIndex + 5] = normals[vertIndex + 2];
@@ -86,6 +87,7 @@ function createWebGPUBuffers(device, textGeometry) {
86
87
  buffers,
87
88
  layout,
88
89
  indexCount,
90
+ indexFormat,
89
91
  dispose() {
90
92
  vertexBuffer.destroy();
91
93
  indexBuffer.destroy();
@@ -11,6 +11,7 @@ interface WebGPUBufferSet {
11
11
  color?: GPUVertexBufferLayout;
12
12
  };
13
13
  indexCount: number;
14
+ indexFormat: GPUIndexFormat;
14
15
  dispose(): void;
15
16
  }
16
17
  declare function createWebGPUBuffers(device: GPUDevice, textGeometry: TextGeometryInfo): WebGPUBufferSet;
@@ -2,17 +2,18 @@
2
2
  function createWebGPUBuffers(device, textGeometry) {
3
3
  const { vertices, normals, indices, colors } = textGeometry;
4
4
  const indexCount = indices.length;
5
+ const indexFormat = indices instanceof Uint16Array ? 'uint16' : 'uint32';
5
6
  // Interleave position and normal data for better cache coherency
6
7
  // Layout: [px, py, pz, nx, ny, nz, px, py, pz, nx, ny, nz, ...]
7
8
  const interleavedData = new Float32Array((vertices.length / 3) * 6);
8
9
  for (let i = 0; i < vertices.length / 3; i++) {
9
10
  const baseIndex = i * 6;
10
11
  const vertIndex = i * 3;
11
- // Position (NO FLIP - pass through)
12
+ // Position
12
13
  interleavedData[baseIndex] = vertices[vertIndex];
13
14
  interleavedData[baseIndex + 1] = vertices[vertIndex + 1];
14
15
  interleavedData[baseIndex + 2] = vertices[vertIndex + 2];
15
- // Normal (NO FLIP - pass through)
16
+ // Normal
16
17
  interleavedData[baseIndex + 3] = normals[vertIndex];
17
18
  interleavedData[baseIndex + 4] = normals[vertIndex + 1];
18
19
  interleavedData[baseIndex + 5] = normals[vertIndex + 2];
@@ -84,6 +85,7 @@ function createWebGPUBuffers(device, textGeometry) {
84
85
  buffers,
85
86
  layout,
86
87
  indexCount,
88
+ indexFormat,
87
89
  dispose() {
88
90
  vertexBuffer.destroy();
89
91
  indexBuffer.destroy();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-text",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "description": "3D font rendering and text layout engine for the web",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",