string-tune-3d 0.0.5 → 0.0.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/dist/index.cjs +243 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +369 -29
- package/dist/index.d.ts +369 -29
- package/dist/index.js +243 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +243 -132
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
- package/readme.md +191 -107
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
import { StringModule, StringContext, StringObject, StringData } from '@fiddle-digital/string-tune';
|
|
2
2
|
|
|
3
|
+
type UniformType = "float" | "int" | "vec2" | "vec3" | "vec4" | "color" | "texture" | "mat3" | "mat4";
|
|
4
|
+
type UniformDefinition = {
|
|
5
|
+
type: UniformType;
|
|
6
|
+
value: any;
|
|
7
|
+
css?: string;
|
|
8
|
+
};
|
|
9
|
+
type ShaderInjectionPoint = "vertex_pars" | "vertex_header" | "vertex_transform" | "vertex_output" | "fragment_pars" | "fragment_header" | "fragment_color" | "fragment_normal" | "fragment_emissive" | "fragment_output";
|
|
10
|
+
type ShaderInjection = {
|
|
11
|
+
point: ShaderInjectionPoint;
|
|
12
|
+
code: string;
|
|
13
|
+
order?: number;
|
|
14
|
+
};
|
|
15
|
+
type MaterialBlendMode = "normal" | "additive" | "subtractive" | "multiply";
|
|
16
|
+
type MaterialSide = "front" | "back" | "double";
|
|
17
|
+
type String3DCustomMaterialDefinition = {
|
|
18
|
+
name: string;
|
|
19
|
+
extends?: "basic" | "standard" | "physical" | "shader";
|
|
20
|
+
vertexShader?: string;
|
|
21
|
+
fragmentShader?: string;
|
|
22
|
+
injections?: ShaderInjection[];
|
|
23
|
+
uniforms?: Record<string, UniformDefinition>;
|
|
24
|
+
properties?: {
|
|
25
|
+
transparent?: boolean;
|
|
26
|
+
side?: MaterialSide;
|
|
27
|
+
depthWrite?: boolean;
|
|
28
|
+
depthTest?: boolean;
|
|
29
|
+
blending?: MaterialBlendMode;
|
|
30
|
+
wireframe?: boolean;
|
|
31
|
+
};
|
|
32
|
+
lights?: boolean;
|
|
33
|
+
parse?: (element: HTMLElement, style: CSSStyleDeclaration) => Record<string, any>;
|
|
34
|
+
};
|
|
35
|
+
declare class String3DCustomMaterialRegistry {
|
|
36
|
+
private static materials;
|
|
37
|
+
private static registeredCssVars;
|
|
38
|
+
static register(definition: String3DCustomMaterialDefinition): void;
|
|
39
|
+
private static registerCssVarsForMaterial;
|
|
40
|
+
private static resolveCssSyntax;
|
|
41
|
+
private static defaultCssInitialValue;
|
|
42
|
+
static get(name: string): String3DCustomMaterialDefinition | undefined;
|
|
43
|
+
static has(name: string): boolean;
|
|
44
|
+
static list(): String3DCustomMaterialDefinition[];
|
|
45
|
+
static unregister(name: string): boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type MaterialUpdateCallback = (uniforms: Record<string, any>) => void;
|
|
49
|
+
interface IMaterialInstance {
|
|
50
|
+
material: any;
|
|
51
|
+
definition: String3DCustomMaterialDefinition;
|
|
52
|
+
update: MaterialUpdateCallback;
|
|
53
|
+
dispose: () => void;
|
|
54
|
+
}
|
|
55
|
+
interface IMaterialFactory {
|
|
56
|
+
supports(definition: String3DCustomMaterialDefinition): boolean;
|
|
57
|
+
create(definition: String3DCustomMaterialDefinition, initialUniforms?: Record<string, any>): IMaterialInstance;
|
|
58
|
+
parseUniformsFromCSS(definition: String3DCustomMaterialDefinition, element: HTMLElement, style: CSSStyleDeclaration): Record<string, any>;
|
|
59
|
+
}
|
|
60
|
+
|
|
3
61
|
interface I3DVector3 {
|
|
4
62
|
x: number;
|
|
5
63
|
y: number;
|
|
@@ -74,6 +132,59 @@ interface I3DMaterial {
|
|
|
74
132
|
opacity?: number;
|
|
75
133
|
transparent?: boolean;
|
|
76
134
|
}
|
|
135
|
+
interface I3DRenderTarget {
|
|
136
|
+
texture: any;
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
setSize(width: number, height: number): void;
|
|
140
|
+
dispose(): void;
|
|
141
|
+
}
|
|
142
|
+
type ParticleMode = "emitter" | "instanced";
|
|
143
|
+
type ParticleSystemConfig = {
|
|
144
|
+
mode: ParticleMode;
|
|
145
|
+
count: number;
|
|
146
|
+
size: number;
|
|
147
|
+
color: string;
|
|
148
|
+
opacity: number;
|
|
149
|
+
spread: number;
|
|
150
|
+
seed: number;
|
|
151
|
+
emitRate: number;
|
|
152
|
+
emitBurst: number;
|
|
153
|
+
particleLife: number;
|
|
154
|
+
particleSpeed: number;
|
|
155
|
+
particleDirection: [number, number, number];
|
|
156
|
+
particleGravity: [number, number, number];
|
|
157
|
+
particleDrag: number;
|
|
158
|
+
particleSizeVariation: number;
|
|
159
|
+
particleColorVariation: number;
|
|
160
|
+
particleShape: "box" | "sphere" | "model";
|
|
161
|
+
particleModelUrl: string;
|
|
162
|
+
particleModelLoader: string;
|
|
163
|
+
particleModelNode: string;
|
|
164
|
+
instanceShape: "box" | "sphere" | "model";
|
|
165
|
+
instanceModelUrl: string;
|
|
166
|
+
instanceModelLoader: string;
|
|
167
|
+
instanceModelNode: string;
|
|
168
|
+
instanceScale: number;
|
|
169
|
+
instanceScaleVariation: number;
|
|
170
|
+
instanceRotationSpeed: number;
|
|
171
|
+
instanceJitter: number;
|
|
172
|
+
instanceFlow: number;
|
|
173
|
+
instanceDisperse: number;
|
|
174
|
+
instanceDisperseScatter: number;
|
|
175
|
+
instanceDisperseScatterX: number;
|
|
176
|
+
instanceDisperseScatterY: number;
|
|
177
|
+
instanceDisperseScatterZ: number;
|
|
178
|
+
};
|
|
179
|
+
interface I3DParticleSystem extends I3DObject {
|
|
180
|
+
update?(dt: number): void;
|
|
181
|
+
setConfig?(config: ParticleSystemConfig): void;
|
|
182
|
+
setMaterial?(material: I3DMaterial | null, options?: {
|
|
183
|
+
points?: boolean;
|
|
184
|
+
meshes?: boolean;
|
|
185
|
+
}): void;
|
|
186
|
+
dispose?(): void;
|
|
187
|
+
}
|
|
77
188
|
interface I3DLight extends I3DObject {
|
|
78
189
|
color: any;
|
|
79
190
|
intensity: number;
|
|
@@ -117,10 +228,32 @@ interface I3DRenderer {
|
|
|
117
228
|
enabled: boolean;
|
|
118
229
|
type: any;
|
|
119
230
|
};
|
|
231
|
+
setRenderTarget?(target: I3DRenderTarget | null): void;
|
|
232
|
+
getRenderTarget?(): I3DRenderTarget | null;
|
|
233
|
+
clear?(color?: boolean, depth?: boolean, stencil?: boolean): void;
|
|
120
234
|
}
|
|
121
235
|
interface I3DTextureLoader {
|
|
122
236
|
load(url: string, onLoad?: (texture: any) => void): any;
|
|
123
237
|
}
|
|
238
|
+
type TextGeometryOptions = {
|
|
239
|
+
size: number;
|
|
240
|
+
height: number;
|
|
241
|
+
curveSegments: number;
|
|
242
|
+
bevelEnabled: boolean;
|
|
243
|
+
bevelThickness: number;
|
|
244
|
+
bevelSize: number;
|
|
245
|
+
bevelOffset: number;
|
|
246
|
+
bevelSegments: number;
|
|
247
|
+
lineHeight: number;
|
|
248
|
+
letterSpacing: number;
|
|
249
|
+
align: "left" | "center" | "right";
|
|
250
|
+
layout?: Array<{
|
|
251
|
+
char: string;
|
|
252
|
+
x: number;
|
|
253
|
+
y: number;
|
|
254
|
+
scale?: number;
|
|
255
|
+
}>;
|
|
256
|
+
};
|
|
124
257
|
interface I3DModelLoader {
|
|
125
258
|
load(url: string, onLoad?: (model: any) => void, onProgress?: (progress: any) => void, onError?: (error: any) => void): void;
|
|
126
259
|
}
|
|
@@ -147,6 +280,7 @@ interface I3DEngine {
|
|
|
147
280
|
createCylinderGeometry(radiusTop: number, radiusBottom: number, height: number, segments?: number): I3DGeometry;
|
|
148
281
|
createMeshBasicMaterial(params?: any): I3DMaterial;
|
|
149
282
|
createMeshStandardMaterial(params?: any): I3DMaterial;
|
|
283
|
+
createShaderMaterial?(params?: any): I3DMaterial;
|
|
150
284
|
createPointLight(color?: string | number, intensity?: number, distance?: number, decay?: number): I3DLight;
|
|
151
285
|
createSpotLight(color?: string | number, intensity?: number, distance?: number, angle?: number, penumbra?: number, decay?: number): I3DLight;
|
|
152
286
|
createHemisphereLight(skyColor?: string | number, groundColor?: string | number, intensity?: number): I3DLight;
|
|
@@ -154,6 +288,12 @@ interface I3DEngine {
|
|
|
154
288
|
createDirectionalLight(color?: string | number, intensity?: number): I3DLight;
|
|
155
289
|
createTextureLoader(): I3DTextureLoader;
|
|
156
290
|
createModelLoader(type: string): I3DModelLoader;
|
|
291
|
+
createRenderTarget?(width: number, height: number, options?: any): I3DRenderTarget;
|
|
292
|
+
getMaterialFactory?(): IMaterialFactory | null;
|
|
293
|
+
createParticleSystem?(config: ParticleSystemConfig): I3DParticleSystem;
|
|
294
|
+
loadFont?(url: string): Promise<any>;
|
|
295
|
+
createTextGeometry?(text: string, font: any, options: TextGeometryOptions): I3DGeometry | null;
|
|
296
|
+
simplifyGeometry?(geometry: I3DGeometry, quality: number): I3DGeometry | null;
|
|
157
297
|
degToRad(degrees: number): number;
|
|
158
298
|
radToDeg(radians: number): number;
|
|
159
299
|
computeBoundingBoxRecursively(object: I3DObject): I3DBox3;
|
|
@@ -172,8 +312,8 @@ interface String3DOptions {
|
|
|
172
312
|
modelLoader?: I3DModelLoader;
|
|
173
313
|
modelLoaderFactory?: (engine: I3DEngine, type?: string) => I3DModelLoader;
|
|
174
314
|
useDirtySync?: boolean;
|
|
175
|
-
|
|
176
|
-
|
|
315
|
+
styleReadIntervalMs?: number;
|
|
316
|
+
layoutReadIntervalMs?: number;
|
|
177
317
|
}
|
|
178
318
|
declare class String3D extends StringModule {
|
|
179
319
|
private static provider;
|
|
@@ -186,19 +326,14 @@ declare class String3D extends StringModule {
|
|
|
186
326
|
private isLoading;
|
|
187
327
|
private options;
|
|
188
328
|
private useDirtySync;
|
|
189
|
-
private
|
|
190
|
-
private observedElements;
|
|
191
|
-
private resizeObserver;
|
|
192
|
-
private mutationObserver;
|
|
329
|
+
private dirtySyncManager;
|
|
193
330
|
private lastSyncData;
|
|
194
|
-
private
|
|
195
|
-
private workerHasResult;
|
|
196
|
-
private workerObjectMap;
|
|
197
|
-
private domVersion;
|
|
198
|
-
private lastSubmittedVersion;
|
|
199
|
-
private scrollTicking;
|
|
200
|
-
private onScrollBound;
|
|
331
|
+
private filterController;
|
|
201
332
|
static setProvider(provider: I3DEngineProvider): void;
|
|
333
|
+
static registerFont(name: string, url: string, options?: {
|
|
334
|
+
default?: boolean;
|
|
335
|
+
}): void;
|
|
336
|
+
static setDefaultFont(name: string): void;
|
|
202
337
|
constructor(context: StringContext);
|
|
203
338
|
canConnect(object: StringObject): boolean;
|
|
204
339
|
initializeObject(globalId: number, object: StringObject, element: HTMLElement, attributes: Record<string, any>): void;
|
|
@@ -213,22 +348,10 @@ declare class String3D extends StringModule {
|
|
|
213
348
|
private applyContainerStyles;
|
|
214
349
|
onObjectConnected(object: StringObject): void;
|
|
215
350
|
onFrame(data: StringData): void;
|
|
351
|
+
private batchReadLayouts;
|
|
216
352
|
private syncRecursive;
|
|
217
353
|
private injectCSS;
|
|
218
354
|
private registerTypedProperties;
|
|
219
|
-
private setupObservers;
|
|
220
|
-
private setupScrollListeners;
|
|
221
|
-
private removeScrollListeners;
|
|
222
|
-
private handleScroll;
|
|
223
|
-
private observeElement;
|
|
224
|
-
private observeSceneElements;
|
|
225
|
-
private observeRecursive;
|
|
226
|
-
private markDirty;
|
|
227
|
-
private markAllDirty;
|
|
228
|
-
private readNumberStyle;
|
|
229
|
-
private buildWorkerCameraData;
|
|
230
|
-
private collectWorkerInputs;
|
|
231
|
-
private applyWorkerResults;
|
|
232
355
|
destroy(): void;
|
|
233
356
|
}
|
|
234
357
|
|
|
@@ -274,6 +397,8 @@ declare class String3DObject {
|
|
|
274
397
|
private _bbox;
|
|
275
398
|
el: any;
|
|
276
399
|
private _children;
|
|
400
|
+
private _flatObjectsCache;
|
|
401
|
+
private _subtreeCache;
|
|
277
402
|
private engine;
|
|
278
403
|
get children(): String3DObject[];
|
|
279
404
|
constructor(id: string, type: string, object: I3DObject, engine: I3DEngine, options?: {
|
|
@@ -303,6 +428,10 @@ declare class String3DObject {
|
|
|
303
428
|
set geometry(geometry: I3DGeometry | undefined);
|
|
304
429
|
updateBoundingBox(): void;
|
|
305
430
|
destroy(): void;
|
|
431
|
+
getFlatObjects(): I3DObject[];
|
|
432
|
+
getSubtreeObjects(): I3DObject[];
|
|
433
|
+
private invalidateFlatCache;
|
|
434
|
+
private invalidateSubtreeCache;
|
|
306
435
|
private disposeObjectResources;
|
|
307
436
|
}
|
|
308
437
|
|
|
@@ -315,6 +444,7 @@ declare class String3DScene {
|
|
|
315
444
|
private _objects;
|
|
316
445
|
private _rootObjects;
|
|
317
446
|
private _elementMap;
|
|
447
|
+
private _materialInstances;
|
|
318
448
|
private engine;
|
|
319
449
|
private _modelLoader?;
|
|
320
450
|
private _modelLoaderFactory?;
|
|
@@ -323,6 +453,7 @@ declare class String3DScene {
|
|
|
323
453
|
constructor(engine: I3DEngine, options?: String3DSceneOptions);
|
|
324
454
|
getScene(): I3DScene;
|
|
325
455
|
getObject(id: string): String3DObject | undefined;
|
|
456
|
+
getAllObjects(): String3DObject[];
|
|
326
457
|
hasObject(id: string): boolean;
|
|
327
458
|
deleteObject(id: string): boolean;
|
|
328
459
|
createFromElement(object: StringObject): void;
|
|
@@ -334,11 +465,17 @@ declare class String3DScene {
|
|
|
334
465
|
private createPlane;
|
|
335
466
|
private createCylinder;
|
|
336
467
|
private createModel;
|
|
468
|
+
private createParticles;
|
|
469
|
+
private createText;
|
|
470
|
+
private getGeometryQuality;
|
|
337
471
|
private resolveModelLoader;
|
|
338
472
|
private centerObject;
|
|
339
473
|
private getBoxCenter;
|
|
340
474
|
private createMaterialFromObject;
|
|
341
475
|
private createMaterialFromElement;
|
|
476
|
+
private tryCreateCustomMaterial;
|
|
477
|
+
updateMaterialUniforms(objectId: string, uniforms: Record<string, any>): void;
|
|
478
|
+
getMaterialInstance(objectId: string): IMaterialInstance | undefined;
|
|
342
479
|
private loadTexture;
|
|
343
480
|
private parseFlipY;
|
|
344
481
|
private shouldOverrideModelMaterial;
|
|
@@ -346,20 +483,87 @@ declare class String3DScene {
|
|
|
346
483
|
destroy(): void;
|
|
347
484
|
}
|
|
348
485
|
|
|
486
|
+
type String3DFilterEffect = {
|
|
487
|
+
type: "blur";
|
|
488
|
+
amount: number;
|
|
489
|
+
} | {
|
|
490
|
+
type: "pixel";
|
|
491
|
+
size: number;
|
|
492
|
+
} | {
|
|
493
|
+
type: "bloom";
|
|
494
|
+
intensity: number;
|
|
495
|
+
threshold: number;
|
|
496
|
+
} | {
|
|
497
|
+
type: "brightness";
|
|
498
|
+
amount: number;
|
|
499
|
+
} | {
|
|
500
|
+
type: "contrast";
|
|
501
|
+
amount: number;
|
|
502
|
+
} | {
|
|
503
|
+
type: "saturate";
|
|
504
|
+
amount: number;
|
|
505
|
+
} | {
|
|
506
|
+
type: "grayscale";
|
|
507
|
+
amount: number;
|
|
508
|
+
} | {
|
|
509
|
+
type: "sepia";
|
|
510
|
+
amount: number;
|
|
511
|
+
} | {
|
|
512
|
+
type: "invert";
|
|
513
|
+
amount: number;
|
|
514
|
+
} | {
|
|
515
|
+
type: "hue-rotate";
|
|
516
|
+
angle: number;
|
|
517
|
+
} | {
|
|
518
|
+
type: "custom";
|
|
519
|
+
name: string;
|
|
520
|
+
uniforms: Record<string, any>;
|
|
521
|
+
};
|
|
522
|
+
type String3DFilterChain = String3DFilterEffect[];
|
|
523
|
+
type String3DFilterTarget = {
|
|
524
|
+
object: String3DObject;
|
|
525
|
+
effects: String3DFilterChain;
|
|
526
|
+
effectsKey: string;
|
|
527
|
+
dirty: boolean;
|
|
528
|
+
};
|
|
529
|
+
|
|
349
530
|
declare class String3DRenderer {
|
|
350
531
|
private _container;
|
|
351
532
|
private _renderer;
|
|
352
533
|
private _width;
|
|
353
534
|
private _height;
|
|
354
535
|
private engine;
|
|
536
|
+
private filterPipeline;
|
|
537
|
+
private filterCache;
|
|
538
|
+
private frameId;
|
|
539
|
+
private lastFrameTime;
|
|
540
|
+
private avgFrameMs;
|
|
541
|
+
private qualityScale;
|
|
542
|
+
private lastQualityChange;
|
|
543
|
+
private filterLayer;
|
|
355
544
|
constructor(container: HTMLElement, engine: I3DEngine);
|
|
356
545
|
attach(): void;
|
|
357
|
-
render(scene: String3DScene, camera: String3DCamera): void;
|
|
546
|
+
render(scene: String3DScene, camera: String3DCamera, filterTargets?: String3DFilterTarget[]): void;
|
|
358
547
|
resize(camera: String3DCamera): void;
|
|
359
548
|
get width(): number;
|
|
360
549
|
get height(): number;
|
|
361
550
|
get renderer(): I3DRenderer;
|
|
362
551
|
destroy(): void;
|
|
552
|
+
private ensureFilterPipeline;
|
|
553
|
+
private canCreateFilterPipeline;
|
|
554
|
+
private collectSubtreeObjects;
|
|
555
|
+
private setVisible;
|
|
556
|
+
private getFilterCenter;
|
|
557
|
+
private injectEffectContext;
|
|
558
|
+
private updateQuality;
|
|
559
|
+
private invalidateFilterCache;
|
|
560
|
+
private evictCache;
|
|
561
|
+
private supportsLayers;
|
|
562
|
+
private hasLayers;
|
|
563
|
+
private applyLayerMask;
|
|
564
|
+
private restoreLayerMask;
|
|
565
|
+
private setCameraLayer;
|
|
566
|
+
private restoreCameraLayer;
|
|
363
567
|
}
|
|
364
568
|
|
|
365
569
|
declare class String3DSynchronizer {
|
|
@@ -368,15 +572,96 @@ declare class String3DSynchronizer {
|
|
|
368
572
|
viewportHeight: number;
|
|
369
573
|
engine: I3DEngine;
|
|
370
574
|
private strategies;
|
|
575
|
+
private styleReadIntervalMs;
|
|
576
|
+
private layoutReadIntervalMs;
|
|
371
577
|
constructor(camera: String3DCamera, viewportWidth: number, viewportHeight: number, engine: I3DEngine);
|
|
372
|
-
syncElement(el: HTMLElement, object: String3DObject, parentData: any
|
|
578
|
+
syncElement(el: HTMLElement, object: String3DObject, parentData: any, hints?: {
|
|
579
|
+
dirtySet?: Set<HTMLElement> | null;
|
|
580
|
+
forceSync?: boolean;
|
|
581
|
+
}): any;
|
|
582
|
+
setSyncOptions(options: {
|
|
583
|
+
styleReadIntervalMs?: number;
|
|
584
|
+
layoutReadIntervalMs?: number;
|
|
585
|
+
}): void;
|
|
373
586
|
updateViewportSize(width: number, height: number): void;
|
|
374
587
|
}
|
|
375
588
|
|
|
589
|
+
type String3DCustomFilterDefinition = {
|
|
590
|
+
name: string;
|
|
591
|
+
fragmentShader: string;
|
|
592
|
+
uniforms?: Record<string, any>;
|
|
593
|
+
parse?: (args: string) => Record<string, any> | null;
|
|
594
|
+
};
|
|
595
|
+
declare class String3DCustomFilterRegistry {
|
|
596
|
+
private static filters;
|
|
597
|
+
static register(definition: String3DCustomFilterDefinition): void;
|
|
598
|
+
static get(name: string): String3DCustomFilterDefinition | undefined;
|
|
599
|
+
static has(name: string): boolean;
|
|
600
|
+
static list(): String3DCustomFilterDefinition[];
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
type String3DFontEntry = {
|
|
604
|
+
name: string;
|
|
605
|
+
url: string;
|
|
606
|
+
};
|
|
607
|
+
declare class String3DFontRegistry {
|
|
608
|
+
private static fonts;
|
|
609
|
+
private static defaultFont;
|
|
610
|
+
static register(name: string, url: string): void;
|
|
611
|
+
static setDefault(name: string): void;
|
|
612
|
+
static get(name: string): String3DFontEntry | undefined;
|
|
613
|
+
static list(): String3DFontEntry[];
|
|
614
|
+
static resolveFontFamily(fontFamily: string): String3DFontEntry | null;
|
|
615
|
+
private static getDefault;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
interface FontData {
|
|
619
|
+
glyphs: Record<string, GlyphData>;
|
|
620
|
+
familyName: string;
|
|
621
|
+
ascender: number;
|
|
622
|
+
descender: number;
|
|
623
|
+
underlinePosition: number;
|
|
624
|
+
underlineThickness: number;
|
|
625
|
+
boundingBox: {
|
|
626
|
+
xMin: number;
|
|
627
|
+
xMax: number;
|
|
628
|
+
yMin: number;
|
|
629
|
+
yMax: number;
|
|
630
|
+
};
|
|
631
|
+
resolution: number;
|
|
632
|
+
original_font_information: Record<string, any>;
|
|
633
|
+
}
|
|
634
|
+
interface GlyphData {
|
|
635
|
+
ha: number;
|
|
636
|
+
x_min: number;
|
|
637
|
+
x_max: number;
|
|
638
|
+
o: string;
|
|
639
|
+
}
|
|
640
|
+
type FontSource = string | ArrayBuffer | Uint8Array;
|
|
641
|
+
declare class FontConverter {
|
|
642
|
+
private static cache;
|
|
643
|
+
private static loadingPromises;
|
|
644
|
+
static load(source: FontSource): Promise<FontData>;
|
|
645
|
+
private static doLoad;
|
|
646
|
+
private static convertToTypeFace;
|
|
647
|
+
private static pathToOutline;
|
|
648
|
+
private static round;
|
|
649
|
+
static isTypefaceJson(url: string): boolean;
|
|
650
|
+
static isFontFile(url: string): boolean;
|
|
651
|
+
static clearCache(): void;
|
|
652
|
+
}
|
|
653
|
+
|
|
376
654
|
declare class ThreeJSEngine implements I3DEngine {
|
|
377
655
|
private THREE;
|
|
378
656
|
private loaders;
|
|
657
|
+
private materialFactory;
|
|
658
|
+
private particleModelCache;
|
|
659
|
+
private particleModelPromiseCache;
|
|
660
|
+
private fontCache;
|
|
661
|
+
private fontPromiseCache;
|
|
662
|
+
private fontMetricsCache;
|
|
379
663
|
constructor(THREE: any, loaders?: Record<string, any>);
|
|
664
|
+
getMaterialFactory(): IMaterialFactory | null;
|
|
380
665
|
createVector3(x?: number, y?: number, z?: number): I3DVector3;
|
|
381
666
|
createVector2(x?: number, y?: number): I3DVector2;
|
|
382
667
|
createQuaternion(x?: number, y?: number, z?: number, w?: number): I3DQuaternion;
|
|
@@ -399,6 +684,7 @@ declare class ThreeJSEngine implements I3DEngine {
|
|
|
399
684
|
createCylinderGeometry(radiusTop: number, radiusBottom: number, height: number, segments?: number): I3DGeometry;
|
|
400
685
|
createMeshBasicMaterial(params?: any): I3DMaterial;
|
|
401
686
|
createMeshStandardMaterial(params?: any): I3DMaterial;
|
|
687
|
+
createShaderMaterial(params?: any): I3DMaterial;
|
|
402
688
|
createPointLight(color?: string | number, intensity?: number, distance?: number, decay?: number): I3DLight;
|
|
403
689
|
createSpotLight(color?: string | number, intensity?: number, distance?: number, angle?: number, penumbra?: number, decay?: number): I3DLight;
|
|
404
690
|
createHemisphereLight(skyColor?: string | number, groundColor?: string | number, intensity?: number): I3DLight;
|
|
@@ -406,6 +692,36 @@ declare class ThreeJSEngine implements I3DEngine {
|
|
|
406
692
|
createDirectionalLight(color?: string | number, intensity?: number): I3DLight;
|
|
407
693
|
createTextureLoader(): I3DTextureLoader;
|
|
408
694
|
createModelLoader(type: string): I3DModelLoader;
|
|
695
|
+
createRenderTarget(width: number, height: number, options?: any): I3DRenderTarget;
|
|
696
|
+
loadFont(url: string): Promise<any>;
|
|
697
|
+
private loadFontWithConverter;
|
|
698
|
+
private loadFontWithLoader;
|
|
699
|
+
/**
|
|
700
|
+
* Create a Three.js-compatible Font object from FontData
|
|
701
|
+
*/
|
|
702
|
+
private createFontFromData;
|
|
703
|
+
/**
|
|
704
|
+
* Generate Three.js Shapes from FontData for given text
|
|
705
|
+
* This generates shapes for a SINGLE character only (used by buildLineShapes)
|
|
706
|
+
*/
|
|
707
|
+
private generateShapesFromFontData;
|
|
708
|
+
private parseOutlineToShapes;
|
|
709
|
+
private reversePath;
|
|
710
|
+
createTextGeometry(text: string, font: any, options: any): I3DGeometry | null;
|
|
711
|
+
private buildLineShapes;
|
|
712
|
+
private getGlyphAdvance;
|
|
713
|
+
private translateShape;
|
|
714
|
+
private scaleShape;
|
|
715
|
+
private buildGlyphShapesFromCanvas;
|
|
716
|
+
private measureFontMetrics;
|
|
717
|
+
private traceContoursFromAlpha;
|
|
718
|
+
private simplifyCollinear;
|
|
719
|
+
private simplifyRdp;
|
|
720
|
+
private pointLineDistance;
|
|
721
|
+
private contoursToShapes;
|
|
722
|
+
private resolveParticleModelGeometry;
|
|
723
|
+
createParticleSystem(config: ParticleSystemConfig): I3DParticleSystem;
|
|
724
|
+
simplifyGeometry(geometry: I3DGeometry, quality: number): I3DGeometry | null;
|
|
409
725
|
degToRad(degrees: number): number;
|
|
410
726
|
radToDeg(radians: number): number;
|
|
411
727
|
computeBoundingBoxRecursively(object: I3DObject): I3DBox3;
|
|
@@ -417,4 +733,28 @@ declare class ThreeJSProvider implements I3DEngineProvider {
|
|
|
417
733
|
getName(): string;
|
|
418
734
|
}
|
|
419
735
|
|
|
420
|
-
|
|
736
|
+
declare class ThreeJSMaterialFactory implements IMaterialFactory {
|
|
737
|
+
private THREE;
|
|
738
|
+
private textureLoader;
|
|
739
|
+
private textureCache;
|
|
740
|
+
constructor(THREE: any);
|
|
741
|
+
supports(definition: String3DCustomMaterialDefinition): boolean;
|
|
742
|
+
create(definition: String3DCustomMaterialDefinition, initialUniforms?: Record<string, any>): IMaterialInstance;
|
|
743
|
+
parseUniformsFromCSS(definition: String3DCustomMaterialDefinition, element: HTMLElement, style: CSSStyleDeclaration): Record<string, any>;
|
|
744
|
+
private buildUniforms;
|
|
745
|
+
private convertUniformValue;
|
|
746
|
+
private loadTexture;
|
|
747
|
+
private createShaderMaterial;
|
|
748
|
+
private createExtendedMaterial;
|
|
749
|
+
private injectVertexShader;
|
|
750
|
+
private injectFragmentShader;
|
|
751
|
+
private generateUniformDeclarations;
|
|
752
|
+
private inferGLSLType;
|
|
753
|
+
private applyMaterialProperties;
|
|
754
|
+
private updateUniforms;
|
|
755
|
+
private getDefaultVertexShader;
|
|
756
|
+
private getDefaultFragmentShader;
|
|
757
|
+
dispose(): void;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export { type CameraMode, FontConverter, type FontData, type FontSource, type I3DBox3, type I3DCamera, type I3DEngine, type I3DEngineProvider, type I3DEuler, type I3DGeometry, type I3DLight, type I3DMaterial, type I3DMatrix4, type I3DMesh, type I3DModelLoader, type I3DObject, type I3DOrthographicCamera, type I3DParticleSystem, type I3DPerspectiveCamera, type I3DQuaternion, type I3DRenderTarget, type I3DRenderer, type I3DScene, type I3DTextureLoader, type I3DVector2, type I3DVector3, type IMaterialFactory, type IMaterialInstance, type MaterialBlendMode, type MaterialSide, type ParticleMode, type ParticleSystemConfig, type ShaderInjection, type ShaderInjectionPoint, String3D, String3DCamera, type String3DCustomFilterDefinition, String3DCustomFilterRegistry, type String3DCustomMaterialDefinition, String3DCustomMaterialRegistry, type String3DFontEntry, String3DFontRegistry, String3DObject, type String3DOptions, String3DRenderer, String3DScene, String3DSynchronizer, ThreeJSEngine, ThreeJSMaterialFactory, ThreeJSProvider, type UniformDefinition, type UniformType };
|