three-text 0.5.1 → 0.6.0

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.
Files changed (61) hide show
  1. package/LICENSE_THIRD_PARTY +15 -0
  2. package/README.md +80 -50
  3. package/dist/index.cjs +66 -20
  4. package/dist/index.d.ts +8 -0
  5. package/dist/index.js +66 -20
  6. package/dist/index.min.cjs +310 -307
  7. package/dist/index.min.js +265 -262
  8. package/dist/index.umd.js +68 -21
  9. package/dist/index.umd.min.js +268 -265
  10. package/dist/three/index.cjs +2 -1
  11. package/dist/three/index.d.ts +1 -0
  12. package/dist/three/index.js +2 -1
  13. package/dist/three/react.cjs +35 -17
  14. package/dist/three/react.d.ts +8 -0
  15. package/dist/three/react.js +35 -17
  16. package/dist/types/core/Text.d.ts +6 -0
  17. package/dist/types/core/types.d.ts +2 -33
  18. package/dist/types/three/index.d.ts +1 -0
  19. package/dist/types/vector/core/index.d.ts +28 -0
  20. package/dist/types/vector/index.d.ts +17 -12
  21. package/dist/types/vector/react.d.ts +3 -4
  22. package/dist/types/vector/slug/SlugPacker.d.ts +2 -0
  23. package/dist/types/vector/slug/curveUtils.d.ts +6 -0
  24. package/dist/types/vector/slug/index.d.ts +8 -0
  25. package/dist/types/vector/slug/shaderStrings.d.ts +4 -0
  26. package/dist/types/vector/slug/slugGLSL.d.ts +21 -0
  27. package/dist/types/vector/slug/slugTSL.d.ts +13 -0
  28. package/dist/types/vector/slug/types.d.ts +30 -0
  29. package/dist/types/vector/slug/unpackVertices.d.ts +11 -0
  30. package/dist/types/vector/webgl/index.d.ts +7 -3
  31. package/dist/types/vector/webgpu/index.d.ts +4 -4
  32. package/dist/vector/all.cjs +21 -0
  33. package/dist/vector/all.d.ts +134 -0
  34. package/dist/vector/all.js +2 -0
  35. package/dist/vector/core/index.cjs +856 -0
  36. package/dist/vector/core/index.d.ts +63 -0
  37. package/dist/vector/core/index.js +854 -0
  38. package/dist/vector/core.cjs +5489 -0
  39. package/dist/vector/core.d.ts +402 -0
  40. package/dist/vector/core.js +5486 -0
  41. package/dist/vector/index.cjs +5 -1305
  42. package/dist/vector/index.d.ts +41 -67
  43. package/dist/vector/index.js +3 -1306
  44. package/dist/vector/index2.cjs +287 -0
  45. package/dist/vector/index2.js +264 -0
  46. package/dist/vector/loopBlinnTSL.d.ts +69 -0
  47. package/dist/vector/react.cjs +54 -40
  48. package/dist/vector/react.d.ts +11 -2
  49. package/dist/vector/react.js +55 -41
  50. package/dist/vector/slugTSL.cjs +252 -0
  51. package/dist/vector/slugTSL.js +231 -0
  52. package/dist/vector/webgl/index.cjs +131 -201
  53. package/dist/vector/webgl/index.d.ts +19 -44
  54. package/dist/vector/webgl/index.js +131 -201
  55. package/dist/vector/webgpu/index.cjs +100 -283
  56. package/dist/vector/webgpu/index.d.ts +16 -45
  57. package/dist/vector/webgpu/index.js +100 -283
  58. package/package.json +6 -1
  59. package/dist/types/vector/GlyphVectorGeometryBuilder.d.ts +0 -26
  60. package/dist/types/vector/LoopBlinnGeometry.d.ts +0 -68
  61. package/dist/types/vector/loopBlinnTSL.d.ts +0 -11
@@ -55,7 +55,8 @@ function buildThreeResult(layoutHandle, meshPipeline, options) {
55
55
  getCacheSize: () => meshPipeline.getCacheSize(),
56
56
  clearCache: () => meshPipeline.clearCache(),
57
57
  measureTextWidth: (text, letterSpacing) => layoutHandle.measureTextWidth(text, letterSpacing),
58
- update
58
+ update,
59
+ dispose: () => layoutHandle.dispose()
59
60
  };
60
61
  }
61
62
  class Text {
@@ -17,6 +17,7 @@ interface ThreeTextGeometryInfo extends Omit<TextGeometryInfo, 'vertices' | 'nor
17
17
  clearCache(): void;
18
18
  measureTextWidth(text: string, letterSpacing?: number): number;
19
19
  update(options: Partial<TextOptions>): Promise<ThreeTextGeometryInfo>;
20
+ dispose(): void;
20
21
  }
21
22
  declare class Text {
22
23
  static setHarfBuzzPath: typeof Text$1.setHarfBuzzPath;
@@ -53,7 +53,8 @@ function buildThreeResult(layoutHandle, meshPipeline, options) {
53
53
  getCacheSize: () => meshPipeline.getCacheSize(),
54
54
  clearCache: () => meshPipeline.clearCache(),
55
55
  measureTextWidth: (text, letterSpacing) => layoutHandle.measureTextWidth(text, letterSpacing),
56
- update
56
+ update,
57
+ dispose: () => layoutHandle.dispose()
57
58
  };
58
59
  }
59
60
  class Text {
@@ -69,7 +69,12 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
69
69
  const { children, font, material, position = [0, 0, 0], rotation = [0, 0, 0], scale = [1, 1, 1], onLoad, onError, vertexColors = true, ...restOptions } = props;
70
70
  const [geometry, setGeometry] = react.useState(null);
71
71
  const [error, setError] = react.useState(null);
72
- const geometryRef = react.useRef(null);
72
+ const textRef = react.useRef(null);
73
+ const opRef = react.useRef(Promise.resolve(null));
74
+ const onLoadRef = react.useRef(onLoad);
75
+ const onErrorRef = react.useRef(onError);
76
+ onLoadRef.current = onLoad;
77
+ onErrorRef.current = onError;
73
78
  const defaultMaterial = react.useMemo(() => {
74
79
  return new THREE__namespace.MeshBasicMaterial({
75
80
  color: 0xffffff,
@@ -86,29 +91,42 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
86
91
  setError(null);
87
92
  if (cancelled)
88
93
  return;
89
- const text = await index.Text.create({
90
- text: children,
91
- font,
92
- ...memoizedTextOptions
94
+ const textPromise = opRef.current.catch(() => null).then(() => {
95
+ if (cancelled)
96
+ return null;
97
+ return textRef.current
98
+ ? textRef.current.update({
99
+ text: children,
100
+ font,
101
+ ...memoizedTextOptions
102
+ })
103
+ : index.Text.create({
104
+ text: children,
105
+ font,
106
+ ...memoizedTextOptions
107
+ });
93
108
  });
109
+ opRef.current = textPromise.catch(() => null);
110
+ const text = await textPromise;
111
+ if (!text)
112
+ return;
94
113
  if (cancelled) {
95
- // If a newer render superseded this request, avoid leaking geometry
96
- text.geometry.dispose();
114
+ text.dispose();
97
115
  return;
98
116
  }
99
- // Dispose previous geometry (if any) before swapping
100
- geometryRef.current?.dispose();
101
- geometryRef.current = text.geometry;
117
+ const prev = textRef.current;
118
+ textRef.current = text;
102
119
  setGeometry(text.geometry);
103
- if (onLoad)
104
- onLoad(text.geometry, text);
120
+ if (onLoadRef.current)
121
+ onLoadRef.current(text.geometry, text);
122
+ requestAnimationFrame(() => prev?.dispose());
105
123
  }
106
124
  catch (err) {
107
125
  const error = err;
108
126
  if (!cancelled) {
109
127
  setError(error);
110
- if (onError)
111
- onError(error);
128
+ if (onErrorRef.current)
129
+ onErrorRef.current(error);
112
130
  else
113
131
  console.error('ThreeText error:', error);
114
132
  }
@@ -118,12 +136,12 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
118
136
  return () => {
119
137
  cancelled = true;
120
138
  };
121
- }, [font, children, memoizedTextOptions, onLoad, onError]);
139
+ }, [font, children, memoizedTextOptions]);
122
140
  // Cleanup geometry on unmount
123
141
  react.useEffect(() => {
124
142
  return () => {
125
- geometryRef.current?.dispose();
126
- geometryRef.current = null;
143
+ textRef.current?.dispose();
144
+ textRef.current = null;
127
145
  };
128
146
  }, []);
129
147
  // Cleanup default material when it changes or on unmount
@@ -208,6 +208,8 @@ interface TextOptions {
208
208
  geometryOptimization?: GeometryOptimizationOptions;
209
209
  layout?: LayoutOptions;
210
210
  color?: [number, number, number] | ColorOptions;
211
+ /** Enable rotated RGSS-4 adaptive supersampling (4 samples per pixel). Takes effect when the GLSL rendering path is active. */
212
+ adaptiveSupersampling?: boolean;
211
213
  }
212
214
  interface HyphenationPatternsMap {
213
215
  [language: string]: HyphenationTrieNode;
@@ -255,6 +257,8 @@ declare class Text$1 {
255
257
  private static patternCache;
256
258
  private static hbInitPromise;
257
259
  private static fontCache;
260
+ private static fontLoadPromises;
261
+ private static fontRefCounts;
258
262
  private static fontCacheMemoryBytes;
259
263
  private static maxFontCacheMemoryBytes;
260
264
  private static fontIdCounter;
@@ -263,6 +267,7 @@ declare class Text$1 {
263
267
  private fontLoader;
264
268
  private loadedFont?;
265
269
  private currentFontId;
270
+ private currentFontCacheKey?;
266
271
  private textShaper?;
267
272
  private textLayout?;
268
273
  private constructor();
@@ -270,6 +275,8 @@ declare class Text$1 {
270
275
  static setHarfBuzzBuffer(wasmBuffer: ArrayBuffer): void;
271
276
  static init(): Promise<HarfBuzzInstance>;
272
277
  static create(options: TextOptions): Promise<TextLayoutHandle>;
278
+ private static retainFont;
279
+ private static releaseFont;
273
280
  private static resolveFont;
274
281
  private static loadAndCacheFont;
275
282
  private static trackFontCacheAdd;
@@ -277,6 +284,7 @@ declare class Text$1 {
277
284
  private static enforceFontCacheMemoryLimit;
278
285
  private static generateFontContentHash;
279
286
  private setLoadedFont;
287
+ private releaseCurrentFont;
280
288
  private loadFont;
281
289
  private createLayout;
282
290
  private prepareHyphenation;
@@ -48,7 +48,12 @@ const Text$1 = forwardRef(function Text(props, ref) {
48
48
  const { children, font, material, position = [0, 0, 0], rotation = [0, 0, 0], scale = [1, 1, 1], onLoad, onError, vertexColors = true, ...restOptions } = props;
49
49
  const [geometry, setGeometry] = useState(null);
50
50
  const [error, setError] = useState(null);
51
- const geometryRef = useRef(null);
51
+ const textRef = useRef(null);
52
+ const opRef = useRef(Promise.resolve(null));
53
+ const onLoadRef = useRef(onLoad);
54
+ const onErrorRef = useRef(onError);
55
+ onLoadRef.current = onLoad;
56
+ onErrorRef.current = onError;
52
57
  const defaultMaterial = useMemo(() => {
53
58
  return new THREE.MeshBasicMaterial({
54
59
  color: 0xffffff,
@@ -65,29 +70,42 @@ const Text$1 = forwardRef(function Text(props, ref) {
65
70
  setError(null);
66
71
  if (cancelled)
67
72
  return;
68
- const text = await Text$2.create({
69
- text: children,
70
- font,
71
- ...memoizedTextOptions
73
+ const textPromise = opRef.current.catch(() => null).then(() => {
74
+ if (cancelled)
75
+ return null;
76
+ return textRef.current
77
+ ? textRef.current.update({
78
+ text: children,
79
+ font,
80
+ ...memoizedTextOptions
81
+ })
82
+ : Text$2.create({
83
+ text: children,
84
+ font,
85
+ ...memoizedTextOptions
86
+ });
72
87
  });
88
+ opRef.current = textPromise.catch(() => null);
89
+ const text = await textPromise;
90
+ if (!text)
91
+ return;
73
92
  if (cancelled) {
74
- // If a newer render superseded this request, avoid leaking geometry
75
- text.geometry.dispose();
93
+ text.dispose();
76
94
  return;
77
95
  }
78
- // Dispose previous geometry (if any) before swapping
79
- geometryRef.current?.dispose();
80
- geometryRef.current = text.geometry;
96
+ const prev = textRef.current;
97
+ textRef.current = text;
81
98
  setGeometry(text.geometry);
82
- if (onLoad)
83
- onLoad(text.geometry, text);
99
+ if (onLoadRef.current)
100
+ onLoadRef.current(text.geometry, text);
101
+ requestAnimationFrame(() => prev?.dispose());
84
102
  }
85
103
  catch (err) {
86
104
  const error = err;
87
105
  if (!cancelled) {
88
106
  setError(error);
89
- if (onError)
90
- onError(error);
107
+ if (onErrorRef.current)
108
+ onErrorRef.current(error);
91
109
  else
92
110
  console.error('ThreeText error:', error);
93
111
  }
@@ -97,12 +115,12 @@ const Text$1 = forwardRef(function Text(props, ref) {
97
115
  return () => {
98
116
  cancelled = true;
99
117
  };
100
- }, [font, children, memoizedTextOptions, onLoad, onError]);
118
+ }, [font, children, memoizedTextOptions]);
101
119
  // Cleanup geometry on unmount
102
120
  useEffect(() => {
103
121
  return () => {
104
- geometryRef.current?.dispose();
105
- geometryRef.current = null;
122
+ textRef.current?.dispose();
123
+ textRef.current = null;
106
124
  };
107
125
  }, []);
108
126
  // Cleanup default material when it changes or on unmount
@@ -10,6 +10,8 @@ export declare class Text {
10
10
  private static patternCache;
11
11
  private static hbInitPromise;
12
12
  private static fontCache;
13
+ private static fontLoadPromises;
14
+ private static fontRefCounts;
13
15
  private static fontCacheMemoryBytes;
14
16
  private static maxFontCacheMemoryBytes;
15
17
  private static fontIdCounter;
@@ -18,6 +20,7 @@ export declare class Text {
18
20
  private fontLoader;
19
21
  private loadedFont?;
20
22
  private currentFontId;
23
+ private currentFontCacheKey?;
21
24
  private textShaper?;
22
25
  private textLayout?;
23
26
  private constructor();
@@ -25,6 +28,8 @@ export declare class Text {
25
28
  static setHarfBuzzBuffer(wasmBuffer: ArrayBuffer): void;
26
29
  static init(): Promise<HarfBuzzInstance>;
27
30
  static create(options: TextOptions): Promise<TextLayoutHandle>;
31
+ private static retainFont;
32
+ private static releaseFont;
28
33
  private static resolveFont;
29
34
  private static loadAndCacheFont;
30
35
  private static trackFontCacheAdd;
@@ -32,6 +37,7 @@ export declare class Text {
32
37
  private static enforceFontCacheMemoryLimit;
33
38
  private static generateFontContentHash;
34
39
  private setLoadedFont;
40
+ private releaseCurrentFont;
35
41
  private loadFont;
36
42
  private createLayout;
37
43
  private prepareHyphenation;
@@ -294,39 +294,6 @@ export interface VectorGlyphInfo extends GlyphGeometryInfo {
294
294
  segmentStart: number;
295
295
  segmentCount: number;
296
296
  }
297
- export interface PackedFloatTexture {
298
- width: number;
299
- height: number;
300
- data: Float32Array;
301
- }
302
- export interface VectorTextGeometryInfo {
303
- quadVertices: Float32Array;
304
- quadIndices: Uint16Array;
305
- instances: {
306
- position: Float32Array;
307
- bounds: Float32Array;
308
- segmentRange: Uint32Array;
309
- glyphDataIndex: Uint32Array;
310
- glyphIndex: Uint32Array;
311
- textIndex: Uint32Array;
312
- lineIndex: Uint32Array;
313
- };
314
- segmentTexelsPerSegment: number;
315
- segments: PackedFloatTexture;
316
- segmentBounds?: PackedFloatTexture;
317
- bandCount?: number;
318
- bandRanges?: PackedFloatTexture;
319
- bandIndices?: PackedFloatTexture;
320
- xBandCount?: number;
321
- xBandRanges?: PackedFloatTexture;
322
- xBandIndices?: PackedFloatTexture;
323
- tileCountX?: number;
324
- tileCountY?: number;
325
- tileRanges?: PackedFloatTexture;
326
- tileIndices?: PackedFloatTexture;
327
- glyphs: VectorGlyphInfo[];
328
- planeBounds: BoundingBox;
329
- }
330
297
  export interface TextLayoutData {
331
298
  lines: LineInfo[];
332
299
  scaledLineHeight: number;
@@ -403,6 +370,8 @@ export interface TextOptions {
403
370
  geometryOptimization?: GeometryOptimizationOptions;
404
371
  layout?: LayoutOptions;
405
372
  color?: [number, number, number] | ColorOptions;
373
+ /** Enable rotated RGSS-4 adaptive supersampling (4 samples per pixel). Takes effect when the GLSL rendering path is active. */
374
+ adaptiveSupersampling?: boolean;
406
375
  }
407
376
  export interface HyphenationPatternsMap {
408
377
  [language: string]: HyphenationTrieNode;
@@ -9,6 +9,7 @@ export interface ThreeTextGeometryInfo extends Omit<CoreTextGeometryInfo, 'verti
9
9
  clearCache(): void;
10
10
  measureTextWidth(text: string, letterSpacing?: number): number;
11
11
  update(options: Partial<TextOptions>): Promise<ThreeTextGeometryInfo>;
12
+ dispose(): void;
12
13
  }
13
14
  export declare class Text {
14
15
  static setHarfBuzzPath: typeof TextCore.setHarfBuzzPath;
@@ -0,0 +1,28 @@
1
+ import { Text as TextCore } from '../../core/Text';
2
+ import type { TextOptions, VectorGlyphInfo, LoadedFont, TextQueryOptions, TextRange } from '../../core/types';
3
+ import type { BoundingBox } from '../../utils/vectors';
4
+ import type { SlugGPUData } from '../slug/types';
5
+ import type { HyphenationTrieNode } from '../../hyphenation';
6
+ export interface VectorTextResult {
7
+ gpuData: SlugGPUData;
8
+ glyphs: VectorGlyphInfo[];
9
+ planeBounds: BoundingBox;
10
+ query(options: TextQueryOptions): TextRange[];
11
+ getLoadedFont(): LoadedFont | undefined;
12
+ measureTextWidth(text: string, letterSpacing?: number): number;
13
+ update(options: Partial<TextOptions>): Promise<VectorTextResult>;
14
+ dispose(): void;
15
+ }
16
+ export declare class Text {
17
+ static setHarfBuzzPath: typeof TextCore.setHarfBuzzPath;
18
+ static setHarfBuzzBuffer: typeof TextCore.setHarfBuzzBuffer;
19
+ static init: typeof TextCore.init;
20
+ static registerPattern: typeof TextCore.registerPattern;
21
+ static preloadPatterns: typeof TextCore.preloadPatterns;
22
+ static setMaxFontCacheMemoryMB: typeof TextCore.setMaxFontCacheMemoryMB;
23
+ static enableWoff2: typeof TextCore.enableWoff2;
24
+ static create(options: TextOptions): Promise<VectorTextResult>;
25
+ }
26
+ export type { TextOptions, VectorTextResult as TextGeometryInfo, VectorGlyphInfo, LoadedFont };
27
+ export type { HyphenationTrieNode };
28
+ export type { SlugGPUData } from '../slug/types';
@@ -1,10 +1,14 @@
1
- import { Text as TextCore } from '../core/Text';
2
1
  import type { TextOptions, VectorGlyphInfo, LoadedFont, TextQueryOptions, TextRange } from '../core/types';
3
- import type { VectorGeometryData } from './LoopBlinnGeometry';
2
+ import type { BoundingBox } from '../utils/vectors';
3
+ import type { SlugGPUData } from './slug/types';
4
4
  import type { HyphenationTrieNode } from '../hyphenation';
5
+ import * as THREE from 'three';
5
6
  export interface VectorTextResult {
7
+ group: THREE.Group;
8
+ mesh: THREE.Mesh;
9
+ gpuData: SlugGPUData;
6
10
  glyphs: VectorGlyphInfo[];
7
- geometryData: VectorGeometryData;
11
+ planeBounds: BoundingBox;
8
12
  query(options: TextQueryOptions): TextRange[];
9
13
  getLoadedFont(): LoadedFont | undefined;
10
14
  measureTextWidth(text: string, letterSpacing?: number): number;
@@ -12,16 +16,17 @@ export interface VectorTextResult {
12
16
  dispose(): void;
13
17
  }
14
18
  export declare class Text {
15
- static setHarfBuzzPath: typeof TextCore.setHarfBuzzPath;
16
- static setHarfBuzzBuffer: typeof TextCore.setHarfBuzzBuffer;
17
- static init: typeof TextCore.init;
18
- static registerPattern: typeof TextCore.registerPattern;
19
- static preloadPatterns: typeof TextCore.preloadPatterns;
20
- static setMaxFontCacheMemoryMB: typeof TextCore.setMaxFontCacheMemoryMB;
21
- static enableWoff2: typeof TextCore.enableWoff2;
19
+ static setHarfBuzzPath: typeof import("..").Text.setHarfBuzzPath;
20
+ static setHarfBuzzBuffer: typeof import("..").Text.setHarfBuzzBuffer;
21
+ static init: typeof import("..").Text.init;
22
+ static registerPattern: typeof import("..").Text.registerPattern;
23
+ static preloadPatterns: typeof import("..").Text.preloadPatterns;
24
+ static setMaxFontCacheMemoryMB: typeof import("..").Text.setMaxFontCacheMemoryMB;
25
+ static enableWoff2: typeof import("..").Text.enableWoff2;
22
26
  static create(options: TextOptions): Promise<VectorTextResult>;
23
27
  }
24
28
  export type { TextOptions, VectorTextResult as TextGeometryInfo, VectorGlyphInfo, LoadedFont };
25
29
  export type { HyphenationTrieNode };
26
- export { buildVectorGeometry, extractContours } from './LoopBlinnGeometry';
27
- export type { VectorGeometryData, VectorGlyphAttributes, GlyphRange, VectorContour, LoopBlinnInput, LoopBlinnGlyphInput, QuadraticSegment } from './LoopBlinnGeometry';
30
+ export { createSlugGLSLMesh } from './slug/slugGLSL';
31
+ export type { SlugGLSLMesh, SlugGLSLMeshOptions } from './slug/slugGLSL';
32
+ export type { SlugGPUData } from './slug/types';
@@ -1,7 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import { Text as VectorTextCore } from './index';
3
- import type { VectorTextResult } from './index';
4
- import type { TextOptions } from '../core/types';
2
+ import { Text as VectorText, type VectorTextResult, type TextOptions } from './index';
5
3
  export interface TextProps extends Omit<TextOptions, 'text' | 'color'> {
6
4
  children: string;
7
5
  font: string | ArrayBuffer;
@@ -9,6 +7,7 @@ export interface TextProps extends Omit<TextOptions, 'text' | 'color'> {
9
7
  position?: [number, number, number];
10
8
  rotation?: [number, number, number];
11
9
  scale?: [number, number, number];
10
+ positionNode?: any;
12
11
  onLoad?: (result: VectorTextResult) => void;
13
12
  onError?: (error: Error) => void;
14
13
  }
@@ -20,5 +19,5 @@ export declare const Text: import("react").ForwardRefExoticComponent<TextProps &
20
19
  preloadPatterns: typeof import("..").Text.preloadPatterns;
21
20
  setMaxFontCacheMemoryMB: typeof import("..").Text.setMaxFontCacheMemoryMB;
22
21
  enableWoff2: typeof import("..").Text.enableWoff2;
23
- create: typeof VectorTextCore.create;
22
+ create: typeof VectorText.create;
24
23
  };
@@ -0,0 +1,2 @@
1
+ import type { SlugShape, SlugGPUData, SlugPackOptions } from './types';
2
+ export declare function packSlugData(shapes: SlugShape[], options?: SlugPackOptions): SlugGPUData;
@@ -0,0 +1,6 @@
1
+ import type { QuadCurve, SlugVec2 } from './types';
2
+ export declare function lineToQuadratic(p0: SlugVec2, p1: SlugVec2): QuadCurve;
3
+ export declare function cubicToQuadratics(p0: SlugVec2, p1: SlugVec2, p2: SlugVec2, p3: SlugVec2, options?: {
4
+ maxError?: number;
5
+ maxDepth?: number;
6
+ }): QuadCurve[];
@@ -0,0 +1,8 @@
1
+ export { packSlugData } from './SlugPacker';
2
+ export { lineToQuadratic, cubicToQuadratics } from './curveUtils';
3
+ export { unpackSlugVertices } from './unpackVertices';
4
+ export { vertexShaderGLSL300, fragmentShaderGLSL300, vertexShaderWGSL, fragmentShaderWGSL } from './shaderStrings';
5
+ export type { QuadCurve, SlugVec2, SlugShape, SlugPackedTexture, SlugGPUData, SlugPackOptions } from './types';
6
+ export type { SlugVertexArrays } from './unpackVertices';
7
+ export { createSlugTSLMesh } from './slugTSL';
8
+ export type { SlugTSLMesh } from './slugTSL';
@@ -0,0 +1,4 @@
1
+ export declare const vertexShaderGLSL300: string;
2
+ export declare const fragmentShaderGLSL300: string;
3
+ export declare const vertexShaderWGSL: string;
4
+ export declare const fragmentShaderWGSL: string;
@@ -0,0 +1,21 @@
1
+ import * as THREE from 'three';
2
+ import type { SlugGPUData } from './types';
3
+ export interface SlugGLSLMeshOptions {
4
+ color?: {
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ };
9
+ animationDeclarations?: string;
10
+ animationBody?: string;
11
+ uniforms?: Record<string, THREE.IUniform>;
12
+ adaptiveSupersampling?: boolean;
13
+ }
14
+ export interface SlugGLSLMesh {
15
+ mesh: THREE.Mesh;
16
+ uniforms: Record<string, THREE.IUniform>;
17
+ setOffset(x: number, y: number, z?: number): void;
18
+ setColor(r: number, g: number, b: number): void;
19
+ dispose(): void;
20
+ }
21
+ export declare function createSlugGLSLMesh(gpuData: SlugGPUData, options?: SlugGLSLMeshOptions): SlugGLSLMesh;
@@ -0,0 +1,13 @@
1
+ import * as THREE from 'three';
2
+ import type { SlugGPUData } from './types';
3
+ export interface SlugTSLMesh {
4
+ mesh: THREE.Mesh;
5
+ setOffset(x: number, y: number, z?: number): void;
6
+ setColor(r: number, g: number, b: number): void;
7
+ dispose(): void;
8
+ }
9
+ export declare function createSlugTSLMesh(gpuData: SlugGPUData, color?: {
10
+ r: number;
11
+ g: number;
12
+ b: number;
13
+ }): SlugTSLMesh;
@@ -0,0 +1,30 @@
1
+ export interface QuadCurve {
2
+ p1: [number, number];
3
+ p2: [number, number];
4
+ p3: [number, number];
5
+ }
6
+ export type SlugVec2 = [number, number];
7
+ export interface SlugShape {
8
+ curves: QuadCurve[];
9
+ bounds: [number, number, number, number];
10
+ }
11
+ export interface SlugPackedTexture {
12
+ data: Float32Array | Uint32Array;
13
+ width: number;
14
+ height: number;
15
+ }
16
+ export interface SlugGPUData {
17
+ curveTexture: SlugPackedTexture & {
18
+ data: Float32Array;
19
+ };
20
+ bandTexture: SlugPackedTexture & {
21
+ data: Uint32Array;
22
+ };
23
+ vertices: Float32Array;
24
+ indices: Uint16Array;
25
+ shapeCount: number;
26
+ }
27
+ export interface SlugPackOptions {
28
+ bandCount?: number;
29
+ evenOdd?: boolean;
30
+ }
@@ -0,0 +1,11 @@
1
+ import type { SlugGPUData } from './types';
2
+ export interface SlugVertexArrays {
3
+ positions: Float32Array;
4
+ texcoords: Float32Array;
5
+ bandings: Float32Array;
6
+ glyphData: Float32Array;
7
+ colors: Float32Array;
8
+ glyphCenters: Float32Array;
9
+ glyphIndices: Float32Array;
10
+ }
11
+ export declare function unpackSlugVertices(gpuData: SlugGPUData): SlugVertexArrays;
@@ -1,7 +1,11 @@
1
- import type { VectorGeometryData } from '../LoopBlinnGeometry';
1
+ import type { SlugGPUData } from '../slug/types';
2
2
  export interface WebGLVectorRenderer {
3
- setGeometry(data: VectorGeometryData): void;
3
+ setGeometry(data: SlugGPUData): void;
4
4
  render(mvp: Float32Array, color: Float32Array): void;
5
5
  dispose(): void;
6
6
  }
7
- export declare function createWebGLVectorRenderer(gl: WebGL2RenderingContext): WebGLVectorRenderer;
7
+ export interface WebGLVectorRendererOptions {
8
+ adaptiveSupersampling?: boolean;
9
+ }
10
+ export declare function createWebGLVectorRenderer(gl: WebGL2RenderingContext, options?: WebGLVectorRendererOptions): WebGLVectorRenderer;
11
+ export type { SlugGPUData };
@@ -1,11 +1,11 @@
1
- import type { VectorGeometryData } from '../LoopBlinnGeometry';
1
+ import type { SlugGPUData } from '../slug/types';
2
2
  export interface WebGPUVectorRenderer {
3
- setGeometry(data: VectorGeometryData): void;
4
- render(passEncoder: GPURenderPassEncoder, mvp: Float32Array, color: Float32Array): void;
3
+ setGeometry(data: SlugGPUData): void;
4
+ render(passEncoder: GPURenderPassEncoder, mvp: Float32Array, color: Float32Array, viewportWidth?: number, viewportHeight?: number): void;
5
5
  dispose(): void;
6
6
  }
7
7
  export interface WebGPUVectorRendererOptions {
8
- depthStencilFormat?: GPUTextureFormat;
9
8
  sampleCount?: number;
10
9
  }
11
10
  export declare function createWebGPUVectorRenderer(device: GPUDevice, format: GPUTextureFormat, options?: WebGPUVectorRendererOptions): WebGPUVectorRenderer;
11
+ export type { SlugGPUData };
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index.cjs');
4
+ var loopBlinnTSL = require('./loopBlinnTSL.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, 'createVectorMeshes', {
9
+ enumerable: true,
10
+ get: function () { return loopBlinnTSL.createVectorMeshes; }
11
+ });
12
+ Object.defineProperty(exports, 'loopBlinnFragment', {
13
+ enumerable: true,
14
+ get: function () { return loopBlinnTSL.loopBlinnFragment; }
15
+ });
16
+ Object.keys(index).forEach(function (k) {
17
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
18
+ enumerable: true,
19
+ get: function () { return index[k]; }
20
+ });
21
+ });