@xtctwins/tctwins-core 1.0.35 → 1.0.37

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.
@@ -8,664 +8,684 @@ import { SceneModelTextureSet } from "./SceneModelTextureSet";
8
8
  * A high-performance model representation for efficient rendering and low memory usage.
9
9
  */
10
10
  export declare class SceneModel extends Component {
11
-
12
- /**
13
- * Fires when the model is loaded
14
- * @param event The loaded event
15
- * @param callback Called fired on the event
16
- * @param scope Scope for the callback
17
- */
18
- on(event: "loaded", callback: (loaded: true) => void, scope?: any): string;
19
-
20
- /**
21
- * Fires when the loading the model has an error
22
- * @param event The error event
23
- * @param callback Called fired on the event
24
- * @param scope Scope for the callback
25
- */
26
- on(event: "error", callback: (msg: string) => void, scope?: any): string;
27
-
28
- /**
29
- * Returns the {@link SceneModelEntity}s in this SceneModel.
30
- * @returns {*|{}}
31
- */
32
- get objects(): { [key: string]: SceneModelEntity }
33
-
34
- /**
35
- * Gets the 3D World-space origin for this SceneModel.
36
- *
37
- * Each geometry or mesh origin, if supplied, is relative to this origin.
38
- *
39
- * Default value is ````[0,0,0]````.
40
- *
41
- * @type {number[]}
42
- */
43
- get origin(): number[];
44
-
45
- /**
46
- * Gets the SceneModel's local translation.
47
- *
48
- * Default value is ````[0,0,0]````.
49
- *
50
- * @type {number[]}
51
- */
52
- get position(): number[];
53
-
54
- /**
55
- * Gets the SceneModel's local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
56
- *
57
- * Default value is ````[0,0,0]````.
58
- *
59
- * @type {number[]}
60
- */
61
- get rotation(): number[];
62
-
63
- /**
64
- * Gets the VBOSceneModels's local rotation quaternion.
65
- *
66
- * Default value is ````[0,0,0,1]````.
67
- *
68
- * @type {number[]}
69
- */
70
- get quaternion(): number[];
71
-
72
- /**
73
- * Gets the SceneModel's local scale.
74
- *
75
- * Default value is ````[1,1,1]````.
76
- *
77
- * @type {number[]}
78
- */
79
- get scale(): number[];
80
-
81
- /**
82
- * Gets the SceneModel's local modeling transform matrix.
83
- *
84
- * Default value is ````[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]````.
85
- *
86
- * @type {number[]}
87
- */
88
- get matrix(): number[];
89
-
90
- /**
91
- * Gets the SceneModel's World matrix.
92
- *
93
- * @type {number[]}
94
- */
95
- get worldMatrix(): number[];
96
-
97
- /**
98
- * Gets the SceneModel's World normal matrix.
99
- *
100
- * @type {number[]}
101
- */
102
- get worldNormalMatrix(): number[];
103
-
104
- /**
105
- * Sets if backfaces are rendered for this SceneModel.
106
- *
107
- * Default is ````false````.
108
- *
109
- * @type {Boolean}
110
- */
111
- get backfaces(): boolean;
112
-
113
- /**
114
- * Sets if backfaces are rendered for this SceneModel.
115
- *
116
- * Default is ````false````.
117
- *
118
- * When we set this ````true````, then backfaces are always rendered for this SceneModel.
119
- *
120
- * When we set this ````false````, then we allow the Viewer to decide whether to render backfaces. In this case,
121
- * the Viewer will:
122
- *
123
- * * hide backfaces on watertight meshes,
124
- * * show backfaces on open meshes, and
125
- * * always show backfaces on meshes when we slice them open with {@link SectionPlane}s.
126
- *
127
- * @type {Boolean}
128
- */
129
- set backfaces(backfaces: boolean);
130
-
131
- /**
132
- * Gets the list of {@link SceneModelEntity}s within this SceneModel.
133
- *
134
- * @returns {SceneModelEntity[]}
135
- */
136
- get entityList(): SceneModelEntity[];
137
-
138
- /**
139
- * Returns true to indicate that SceneModel is an {@link SceneModelEntity}.
140
- * @type {Boolean}
141
- */
142
- get isEntity(): boolean;
143
-
144
- /**
145
- * Returns ````true```` if this SceneModel represents a model.
146
- *
147
- * When ````true```` the SceneModel will be registered by {@link SceneModel.id} in
148
- * {@link Scene.models} and may also have a {@link MetaObject} with matching {@link MetaObject.id}.
149
- *
150
- * @type {Boolean}
151
- */
152
- get isModel(): boolean;
153
-
154
- /**
155
- * Returns ````false```` to indicate that SceneModel never represents an object.
156
- *
157
- * @type {Boolean}
158
- */
159
- get isObject(): boolean;
160
-
161
- /**
162
- * Gets the SceneModel's World-space 3D axis-aligned bounding box.
163
- *
164
- * Represented by a six-element Float64Array containing the min/max extents of the
165
- * axis-aligned volume, ie. ````[xmin, ymin,zmin,xmax,ymax, zmax]````.
166
- *
167
- * @type {number[]}
168
- */
169
- get aabb(): number[];
170
-
171
-
172
- get numEntities(): number;
173
-
174
- /**
175
- * The number of entities in this SceneModel.
176
- *
177
- * @type {number}
178
- */
179
- get numEntities(): number;
180
-
181
- /**
182
- * The approximate number of triangle primitives in this SceneModel.
183
- *
184
- * @type {number}
185
- */
186
- get numTriangles(): number;
187
-
188
- /**
189
- * The approximate number of line primitives in this SceneModel.
190
- *
191
- * @type {number}
192
- */
193
- get numLines(): number;
194
-
195
- /**
196
- * The approximate number of point primitives in this SceneModel.
197
- *
198
- * @type {number}
199
- */
200
- get numPoints(): number;
201
-
202
- /**
203
- * Gets if any {@link SceneModelEntity}s in this SceneModel are visible.
204
- *
205
- * The SceneModel is only rendered when {@link SceneModel.visible} is ````true```` and {@link SceneModel.culled} is ````false````.
206
- *
207
- * @type {Boolean}
208
- */
209
- get visible(): boolean;
210
-
211
- /**
212
- * Sets if this SceneModel is visible.
213
- *
214
- * The SceneModel is only rendered when {@link SceneModel.visible} is ````true```` and {@link SceneModel.culled} is ````false````.
215
- **
216
- * @type {Boolean}
217
- */
218
- set visible(visible: boolean);
219
-
220
- /**
221
- * Gets if any {@link SceneModelEntity}s in this SceneModel are xrayed.
222
- *
223
- * @type {Boolean}
224
- */
225
- get xrayed(): boolean
226
-
227
- /**
228
- * Sets if all {@link SceneModelEntity}s in this SceneModel are xrayed.
229
- *
230
- * @type {Boolean}
231
- */
232
- set xrayed(xrayed: boolean);
233
-
234
- /**
235
- * Gets if any {@link SceneModelEntity}s in this SceneModel are highlighted.
236
- *
237
- * @type {Boolean}
238
- */
239
- get highlighted(): boolean;
240
-
241
- /**
242
- * Sets if all {@link SceneModelEntity}s in this SceneModel are highlighted.
243
- *
244
- * @type {Boolean}
245
- */
246
- set highlighted(highlighted: boolean);
247
-
248
- /**
249
- * Gets if any {@link SceneModelEntity}s in this SceneModel are selected.
250
- *
251
- * @type {Boolean}
252
- */
253
- get selected(): boolean;
254
-
255
- /**
256
- * Sets if all {@link SceneModelEntity}s in this SceneModel are selected.
257
- *
258
- * @type {Boolean}
259
- */
260
- set selected(selected: boolean);
261
-
262
- /**
263
- * Gets if any {@link SceneModelEntity}s in this SceneModel have edges emphasised.
264
- *
265
- * @type {Boolean}
266
- */
267
- get edges(): boolean;
268
-
269
- /**
270
- * Sets if all {@link SceneModelEntity}s in this SceneModel have edges emphasised.
271
- *
272
- * @type {Boolean}
273
- */
274
- set edges(edges: boolean);
275
-
276
- /**
277
- * Gets if this SceneModel is culled from view.
278
- *
279
- * The SceneModel is only rendered when {@link SceneModel.visible} is true and {@link SceneModel.culled} is false.
280
- *
281
- * @type {Boolean}
282
- */
283
- get culled(): boolean;
284
-
285
- /**
286
- * Sets if this SceneModel is culled from view.
287
- *
288
- * The SceneModel is only rendered when {@link SceneModel.visible} is true and {@link SceneModel.culled} is false.
289
- *
290
- * @type {Boolean}
291
- */
292
- set culled(culled: boolean);
293
-
294
- /**
295
- * Gets if {@link SceneModelEntity}s in this SceneModel are clippable.
296
- *
297
- * Clipping is done by the {@link SectionPlane}s in {@link Scene.sectionPlanes}.
298
- *
299
- * @type {Boolean}
300
- */
301
- get clippable(): boolean;
302
-
303
- /**
304
- * Sets if {@link SceneModelEntity}s in this SceneModel are clippable.
305
- *
306
- * Clipping is done by the {@link SectionPlane}s in {@link Scene.sectionPlanes}.
307
- *
308
- * @type {Boolean}
309
- */
310
- set clippable(clippable: boolean);
311
-
312
- /**
313
- * Gets if this SceneModel is collidable.
314
- *
315
- * @type {Boolean}
316
- */
317
- get collidable(): boolean;
318
-
319
- /**
320
- * Sets if {@link SceneModelEntity}s in this SceneModel are collidable.
321
- *
322
- * @type {Boolean}
323
- */
324
- set collidable(collidable: boolean);
325
-
326
- /**
327
- * Gets if this SceneModel is pickable.
328
- *
329
- * Picking is done via calls to {@link Scene.pick}.
330
- *
331
- * @type {Boolean}
332
- */
333
- get pickable(): boolean;
334
-
335
- /**
336
- * Sets if {@link SceneModelEntity}s in this SceneModel are pickable.
337
- *
338
- * Picking is done via calls to {@link Scene.pick}.
339
- *
340
- * @type {Boolean}
341
- */
342
- set pickable(pickable: boolean);
343
-
344
- /**
345
- * Gets the RGB colorize color for this SceneModel.
346
- *
347
- * Each element of the color is in range ````[0..1]````.
348
- *
349
- * @type {number[]}
350
- */
351
- get colorize(): number[];
352
-
353
- /**
354
- * Sets the RGB colorize color for this SceneModel.
355
- *
356
- * Multiplies by rendered fragment colors.
357
- *
358
- * Each element of the color is in range ````[0..1]````.
359
- *
360
- * @type {number[]}
361
- */
362
- set colorize(colorize: number[]);
363
-
364
- /**
365
- * Gets this SceneModel's opacity factor.
366
- *
367
- * This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
368
- *
369
- * @type {number}
370
- */
371
- get opacity(): number;
372
-
373
- /**
374
- * Sets the opacity factor for this SceneModel.
375
- *
376
- * This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
377
- *
378
- * @type {number}
379
- */
380
- set opacity(opacity: number);
381
-
382
- /**
383
- * Gets if this SceneModel casts a shadow.
384
- *
385
- * @type {Boolean}
386
- */
387
- get castsShadow(): boolean;
388
-
389
- /**
390
- * Sets if this SceneModel casts a shadow.
391
- *
392
- * @type {Boolean}
393
- */
394
- set castsShadow(castsShadow: boolean);
395
-
396
- /**
397
- * Sets if this SceneModel can have shadow cast upon it.
398
- *
399
- * @type {Boolean}
400
- */
401
- get receivesShadow(): boolean;
402
-
403
- /**
404
- * Sets if this SceneModel can have shadow cast upon it.
405
- *
406
- * @type {Boolean}
407
- */
408
- set receivesShadow(receivesShadow: boolean);
409
-
410
- /**
411
- * Gets if Scalable Ambient Obscurance (SAO) will apply to this SceneModel.
412
- *
413
- * SAO is configured by the Scene's {@link SAO} component.
414
- *
415
- * Only works when {@link SAO.enabled} is also true.
416
- *
417
- * @type {Boolean}
418
- */
419
- get saoEnabled(): boolean;
420
-
421
- /**
422
- * Gets if physically-based rendering (PBR) is enabled for this SceneModel.
423
- *
424
- * Only works when {@link Scene.pbrEnabled} is also true.
425
- *
426
- * @type {Boolean}
427
- */
428
- get pbrEnabled(): boolean;
429
-
430
- /**
431
- * Returns true to indicate that SceneModel is implements {@link Drawable}.
432
- *
433
- * @type {Boolean}
434
- */
435
- get isDrawable(): boolean;
436
-
437
- /**
438
- * Configures the appearance of xrayed {@link SceneModelEntity}s within this SceneModel.
439
- *
440
- * This is the {@link Scene.xrayMaterial}.
441
- *
442
- * @type {EmphasisMaterial}
443
- */
444
- get xrayMaterial(): EmphasisMaterial;
445
-
446
- /**
447
- * Configures the appearance of highlighted {@link SceneModelEntity}s within this SceneModel.
448
- *
449
- * This is the {@link Scene.highlightMaterial}.
450
- *
451
- * @type {EmphasisMaterial}
452
- */
453
- get highlightMaterial(): EmphasisMaterial;
454
-
455
- /**
456
- * Configures the appearance of selected {@link SceneModelEntity}s within this SceneModel.
457
- *
458
- * This is the {@link Scene.selectedMaterial}.
459
- *
460
- * @type {EmphasisMaterial}
461
- */
462
- get selectedMaterial(): EmphasisMaterial;
463
-
464
- /**
465
- * Configures the appearance of edges of {@link SceneModelEntity}s within this SceneModel.
466
- *
467
- * This is the {@link Scene.edgeMaterial}.
468
- *
469
- * @type {EdgeMaterial}
470
- */
471
- get edgeMaterial(): EdgeMaterial;
472
-
473
- /**
474
- * Creates a texture within this SceneModel.
475
- *
476
- * We can then supply the texture ID to {@link SceneModel#createTextureSet} when we want to create texture sets that use the texture.
477
- *
478
- * @param {*} cfg Texture properties.
479
- * @param {string|number} cfg.id Mandatory ID for the texture, to refer to with {@link SceneModel#createTextureSet}.
480
- * @param {string} [cfg.src] Image file for the texture. Assumed to be transcoded if not having a recognized image file
481
- * extension (jpg, jpeg, png etc.). If transcoded, then assumes ````SceneModel```` is configured with a {@link TextureTranscoder}.
482
- * @param {ArrayBuffer[]} [cfg.buffers] Transcoded texture data. Assumes ````SceneModel```` is
483
- * configured with a {@link TextureTranscoder}. This parameter is given as an array of buffers so we can potentially support multi-image textures, such as cube maps.
484
- * @param {HTMLImageElement} [cfg.image] HTML Image object to load into this texture. Overrides ````src```` and ````buffers````. Never transcoded.
485
- * @param {number} [cfg.minFilter=LinearMipmapLinearFilter] How the texture is sampled when a texel covers less than one pixel.
486
- * Supported values are {@link LinearMipmapLinearFilter}, {@link LinearMipMapNearestFilter}, {@link NearestMipMapNearestFilter}, {@link NearestMipMapLinearFilter} and {@link LinearMipMapLinearFilter}.
487
- * @param {number} [cfg.magFilter=LinearFilter] How the texture is sampled when a texel covers more than one pixel. Supported values are {@link LinearFilter} and {@link NearestFilter}.
488
- * @param {number} [cfg.wrapS=RepeatWrapping] Wrap parameter for texture coordinate *S*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
489
- * @param {number} [cfg.wrapT=RepeatWrapping] Wrap parameter for texture coordinate *T*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}..
490
- * @param {number} [cfg.wrapR=RepeatWrapping] Wrap parameter for texture coordinate *R*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
491
- * @param {Boolean} [cfg.flipY=false] Flips this Texture's source data along its vertical axis when ````true````.
492
- * @param {number} [cfg.encoding=LinearEncoding] Encoding format. Supported values are {@link LinearEncoding} and {@link sRGBEncoding}.
493
- */
494
- createTexture(cfg: {
495
- id: string | number,
496
- src?: string,
497
- buffer?: ArrayBuffer[],
498
- image?: HTMLImageElement,
499
- minFilter?: number,
500
- magFilter?: number,
501
- wrapS?: number,
502
- wrapT?: number,
503
- flipY?: boolean,
504
- encoding?: number
505
- }): void;
506
-
507
- /**
508
- * Creates a texture set within this SceneModel.
509
- *
510
- * * Stores the new {@link SceneModelTextureSet} in {@link SceneModel#textureSets}.
511
- *
512
- * A texture set is a collection of textures that can be shared among meshes. We can then supply the texture set
513
- * ID to {@link SceneModel#createMesh} when we want to create meshes that use the texture set.
514
- *
515
- * The textures can work as a texture atlas, where each mesh can have geometry UVs that index
516
- * a different part of the textures. This allows us to minimize the number of textures in our models, which
517
- * means faster rendering.
518
- *
519
- * @param {*} cfg Texture set properties.
520
- * @param {string|number} cfg.id Mandatory ID for the texture set, to refer to with {@link SceneModel#createMesh}.
521
- * @param {*} [cfg.colorTextureId] ID of *RGBA* base color texture, with color in *RGB* and alpha in *A*.
522
- * @param {*} [cfg.metallicRoughnessTextureId] ID of *RGBA* metal-roughness texture, with the metallic factor in *R*, and roughness factor in *G*.
523
- * @param {*} [cfg.normalsTextureId] ID of *RGBA* normal map texture, with normal map vectors in *RGB*.
524
- * @param {*} [cfg.emissiveTextureId] ID of *RGBA* emissive map texture, with emissive color in *RGB*.
525
- * @param {*} [cfg.occlusionTextureId] ID of *RGBA* occlusion map texture, with occlusion factor in *R*.
526
- * @returns {SceneModelTransform} The new texture set.
527
- */
528
- createTextureSet(cfg: {
529
- id: string | number,
530
- colorTextureId?: string | number,
531
- metallicRoughnessTextureId?: string | number,
532
- normalsTextureId?: string | number,
533
- emissiveTextureId?: string | number,
534
- occlusionTextureId?: string | number
535
- }): SceneModelTextureSet;
536
-
537
- /**
538
- * Creates a reusable geometry within this SceneModel.
539
- *
540
- * We can then supply the geometry ID to {@link SceneModel.createMesh} when we want to create meshes that instance the geometry.
541
- *
542
- * If provide a ````positionsDecodeMatrix```` , then ````createGeometry()```` will assume
543
- * that the ````positions```` and ````normals```` arrays are compressed. When compressed, ````positions```` will be
544
- * quantized and in World-space, and ````normals```` will be oct-encoded and in World-space.
545
- *
546
- * Note that ````positions````, ````normals```` and ````indices```` are all required together.
547
- *
548
- * @param {*} cfg Geometry properties.
549
- * @param {string|number} cfg.id Mandatory ID for the geometry, to refer to with {@link SceneModel.createMesh}.
550
- * @param {string} cfg.primitive The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.
551
- * @param {number[]} cfg.positions Flat array of positions.
552
- * @param {number[]} [cfg.normals] Flat array of normal vectors. Only used with 'triangles' primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
553
- * @param {number[]} [cfg.colors] Flat array of RGBA vertex colors as float values in range ````[0..1]````. Ignored when ````geometryId```` is given, overidden by ````color```` and ````colorsCompressed````.
554
- * @param {number[]} [cfg.colorsCompressed] Flat array of RGBA vertex colors as unsigned short integers in range ````[0..255]````. Ignored when ````geometryId```` is given, overrides ````colors```` and is overriden by ````color````.
555
- * @param {number[]} [cfg.indices] Array of indices. Not required for `points` primitives.
556
- * @param {number[]} [cfg.edgeIndices] Array of edge line indices. Used only for Required for 'triangles' primitives. These are automatically generated internally if not supplied, using the ````edgeThreshold```` given to the ````SceneModel```` constructor.
557
- * @param {number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positions````.
558
- * @param {number[]} [cfg.origin] Optional geometry origin, relative to {@link SceneModel.origin}. When this is given, then every mesh created with {@link SceneModel.createMesh} that uses this geometry will
559
- * be transformed relative to this origin.
560
- */
561
- createGeometry(cfg: {
562
- id: string | number;
563
- primitive: "lines" | "triangles" | "solid" | "surface";
564
- positions: number[];
565
- normals: number[];
566
- colors: number[];
567
- colorsCompressed: number[];
568
- indices: number[];
569
- edgeIndices: number[];
570
- positionsDecodeMatrix: number[];
571
- origin?: number[];
572
- }): void;
573
-
574
- /**
575
- * Creates a new {@link SceneModelTransform} within this SceneModel.
576
- *
577
- * * Stores the new {@link SceneModelTransform} in {@link SceneModel#transforms}.
578
- * * Can be connected into hierarchies
579
- * * Each {@link SceneModelTransform} can be used by unlimited {@link SceneModelMesh}es
580
- *
581
- * @param {*} cfg Transform creation parameters.
582
- * @param {string} cfg.id Mandatory ID for the new transform. Must not clash with any existing components within the {@link Scene}.
583
- * @param {string} [cfg.parentTransformId] ID of a parent transform, previously created with {@link SceneModel#createTextureSet}.
584
- * @param {number[]} [cfg.position=[0,0,0]] Local 3D position of the mesh. Overridden by ````transformId````.
585
- * @param {number[]} [cfg.scale=[1,1,1]] Scale of the transform.
586
- * @param {number[]} [cfg.rotation=[0,0,0]] Rotation of the transform as Euler angles given in degrees, for each of the X, Y and Z axis.
587
- * @param {number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Modelling transform matrix. Overrides the ````position````, ````scale```` and ````rotation```` parameters.
588
- * @returns {SceneModelTransform} The new transform.
589
- */
590
- createTransform(cfg: {
591
- id: string | number,
592
- parentTransformId: string | number,
593
- position?: number[],
594
- scale?: number[],
595
- rotation?: number[],
596
- matrix?: number[]
597
- }): SceneModelMesh;
598
-
599
- /**
600
- * Creates a new {@link SceneModelMesh} within this SceneModel.
601
- *
602
- * * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
603
- * * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
604
- * various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
605
- * with {@link SceneModel#createGeometry}.
606
- * * If you accompany the arrays with an ````origin````, then ````createMesh()```` will assume
607
- * that the geometry ````positions```` are in relative-to-center (RTC) coordinates, with ````origin```` being the
608
- * origin of their RTC coordinate system.
609
- *
610
- * @param {object} cfg Object properties.
611
- * @param {String} cfg.id Mandatory ID for the new mesh. Must not clash with any existing components within the {@link Scene}.
612
- * @param {String|Number} [cfg.textureSetId] ID of a {@link SceneModelTextureSet} previously created with {@link SceneModel#createTextureSet}.
613
- * @param {String|Number} [cfg.transformId] ID of a {@link SceneModelTransform} to instance, previously created with {@link SceneModel#createTransform}. Overrides all other transform parameters given to this method.
614
- * @param {String|Number} [cfg.geometryId] ID of a geometry to instance, previously created with {@link SceneModel#createGeometry}. Overrides all other geometry parameters given to this method.
615
- * @param {String} cfg.primitive The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.
616
- * @param {Number[]} [cfg.positions] Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by ````positionsCompressed````.
617
- * @param {Number[]} [cfg.positionsCompressed] Flat array of quantized 3D vertex positions. Overrides ````positions````, and must be accompanied by ````positionsDecodeMatrix````.
618
- * @param {Number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positionsCompressed````. Must be accompanied by ````positionsCompressed````.
619
- * @param {Number[]} [cfg.normals] Flat array of normal vectors. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
620
- * @param {Number[]} [cfg.normalsCompressed] Flat array of oct-encoded normal vectors. Overrides ````normals````. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
621
- * @param {Number[]} [cfg.colors] Flat array of uncompressed RGBA vertex colors, as float values in range ````[0..1]````. Ignored when ````geometryId```` is given. Overridden by ````color```` and ````colorsCompressed````.
622
- * @param {Number[]} [cfg.colorsCompressed] Flat array of compressed RGBA vertex colors, as unsigned short integers in range ````[0..255]````. Ignored when ````geometryId```` is given. Overrides ````colors```` and is overridden by ````color````.
623
- * @param {Number[]} [cfg.uv] Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.
624
- * @param {Number[]} [cfg.uvCompressed] Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides ````uv````. Must be accompanied by ````uvDecodeMatrix````. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.
625
- * @param {Number[]} [cfg.uvDecodeMatrix] A 3x3 matrix for decompressing ````uvCompressed````.
626
- * @param {Number[]} [cfg.indices] Array of primitive connectivity indices. Not required for `points` primitives.
627
- * @param {Number[]} [cfg.edgeIndices] Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional ````edgeThreshold```` given to the ````SceneModel```` constructor.
628
- * @param {Number[]} [cfg.origin] Optional geometry origin, relative to {@link SceneModel#origin}. When this is given, then ````positions```` are assumed to be relative to this.
629
- * @param {Number[]} [cfg.position=[0,0,0]] Local 3D position of the mesh. Overridden by ````transformId````.
630
- * @param {Number[]} [cfg.scale=[1,1,1]] Scale of the mesh. Overridden by ````transformId````.
631
- * @param {Number[]} [cfg.rotation=[0,0,0]] Rotation of the mesh as Euler angles given in degrees, for each of the X, Y and Z axis. Overridden by ````transformId````.
632
- * @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Mesh modelling transform matrix. Overrides the ````position````, ````scale```` and ````rotation```` parameters. Also overridden by ````transformId````.
633
- * @param {Number[]} [cfg.color=[1,1,1]] RGB color in range ````[0..1, 0..1, 0..1]````. Overridden by texture set ````colorTexture````. Overrides ````colors```` and ````colorsCompressed````.
634
- * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
635
- * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
636
- * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
637
- * @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
638
- */
639
- createMesh(cfg: {
640
- id: string;
641
- textureSetId?: string | number;
642
- transformId?: string | number;
643
- geometryId?: string | number;
644
- primitive: "lines" | "triangles" | "points";
645
- positions: number[];
646
- positionsCompressed: number[];
647
- positionsDecodeMatrix: number[];
648
- normals: number[];
649
- normalsCompressed: number[];
650
- colors: number[];
651
- colorsCompressed: number[];
652
- uv: number[];
653
- uvCompressed: number[];
654
- uvDecodeMatrix: number[];
655
- indices: number[];
656
- edgeIndices: number[];
657
- origin?: number[];
658
- position?: number[];
659
- scale?: number[];
660
- rotation?: number[];
661
- matrix?: number[];
662
- color?: number[];
663
- opacity?: number;
664
- metallic?: number;
665
- roughness?: number;
666
- }): boolean;
667
-
668
- /**
11
+ /**
12
+ * Fires when the model is loaded
13
+ * @param event The loaded event
14
+ * @param callback Called fired on the event
15
+ * @param scope Scope for the callback
16
+ */
17
+ on(event: "loaded", callback: (loaded: true) => void, scope?: any): string;
18
+
19
+ /**
20
+ * Fires when the loading the model has an error
21
+ * @param event The error event
22
+ * @param callback Called fired on the event
23
+ * @param scope Scope for the callback
24
+ */
25
+ on(event: "error", callback: (msg: string) => void, scope?: any): string;
26
+
27
+ /**
28
+ * Returns the {@link SceneModelEntity}s in this SceneModel.
29
+ * @returns {*|{}}
30
+ */
31
+ get objects(): { [key: string]: SceneModelEntity };
32
+
33
+ /**
34
+ * Gets the 3D World-space origin for this SceneModel.
35
+ *
36
+ * Each geometry or mesh origin, if supplied, is relative to this origin.
37
+ *
38
+ * Default value is ````[0,0,0]````.
39
+ *
40
+ * @type {number[]}
41
+ */
42
+ get origin(): number[];
43
+
44
+ /**
45
+ * Gets the SceneModel's local translation.
46
+ *
47
+ * Default value is ````[0,0,0]````.
48
+ *
49
+ * @type {number[]}
50
+ */
51
+ get position(): number[];
52
+
53
+ /**
54
+ * Gets the SceneModel's local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
55
+ *
56
+ * Default value is ````[0,0,0]````.
57
+ *
58
+ * @type {number[]}
59
+ */
60
+ get rotation(): number[];
61
+
62
+ /**
63
+ * Gets the VBOSceneModels's local rotation quaternion.
64
+ *
65
+ * Default value is ````[0,0,0,1]````.
66
+ *
67
+ * @type {number[]}
68
+ */
69
+ get quaternion(): number[];
70
+
71
+ /**
72
+ * Gets the SceneModel's local scale.
73
+ *
74
+ * Default value is ````[1,1,1]````.
75
+ *
76
+ * @type {number[]}
77
+ */
78
+ get scale(): number[];
79
+
80
+ /**
81
+ * Gets the SceneModel's local modeling transform matrix.
82
+ *
83
+ * Default value is ````[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]````.
84
+ *
85
+ * @type {number[]}
86
+ */
87
+ get matrix(): number[];
88
+
89
+ /**
90
+ * Gets the SceneModel's World matrix.
91
+ *
92
+ * @type {number[]}
93
+ */
94
+ get worldMatrix(): number[];
95
+
96
+ /**
97
+ * Gets the SceneModel's World normal matrix.
98
+ *
99
+ * @type {number[]}
100
+ */
101
+ get worldNormalMatrix(): number[];
102
+
103
+ /**
104
+ * Sets if backfaces are rendered for this SceneModel.
105
+ *
106
+ * Default is ````false````.
107
+ *
108
+ * @type {Boolean}
109
+ */
110
+ get backfaces(): boolean;
111
+
112
+ /**
113
+ * Sets if backfaces are rendered for this SceneModel.
114
+ *
115
+ * Default is ````false````.
116
+ *
117
+ * When we set this ````true````, then backfaces are always rendered for this SceneModel.
118
+ *
119
+ * When we set this ````false````, then we allow the Viewer to decide whether to render backfaces. In this case,
120
+ * the Viewer will:
121
+ *
122
+ * * hide backfaces on watertight meshes,
123
+ * * show backfaces on open meshes, and
124
+ * * always show backfaces on meshes when we slice them open with {@link SectionPlane}s.
125
+ *
126
+ * @type {Boolean}
127
+ */
128
+ set backfaces(backfaces: boolean);
129
+
130
+ /**
131
+ * Gets the list of {@link SceneModelEntity}s within this SceneModel.
132
+ *
133
+ * @returns {SceneModelEntity[]}
134
+ */
135
+ get entityList(): SceneModelEntity[];
136
+
137
+ /**
138
+ * Returns true to indicate that SceneModel is an {@link SceneModelEntity}.
139
+ * @type {Boolean}
140
+ */
141
+ get isEntity(): boolean;
142
+
143
+ /**
144
+ * Returns ````true```` if this SceneModel represents a model.
145
+ *
146
+ * When ````true```` the SceneModel will be registered by {@link SceneModel.id} in
147
+ * {@link Scene.models} and may also have a {@link MetaObject} with matching {@link MetaObject.id}.
148
+ *
149
+ * @type {Boolean}
150
+ */
151
+ get isModel(): boolean;
152
+
153
+ /**
154
+ * Returns ````false```` to indicate that SceneModel never represents an object.
155
+ *
156
+ * @type {Boolean}
157
+ */
158
+ get isObject(): boolean;
159
+
160
+ /**
161
+ * Gets the SceneModel's World-space 3D axis-aligned bounding box.
162
+ *
163
+ * Represented by a six-element Float64Array containing the min/max extents of the
164
+ * axis-aligned volume, ie. ````[xmin, ymin,zmin,xmax,ymax, zmax]````.
165
+ *
166
+ * @type {number[]}
167
+ */
168
+ get aabb(): number[];
169
+
170
+ /**
171
+ * 获取aabb排除在外的对象id
172
+ * @type {string[]}
173
+ */
174
+ get exceptionIds(): string[];
175
+
176
+ /**
177
+ * 设置aabb排除在外的对象id(自动更新新的aabb)
178
+ * @param {string[]} exceptionIds
179
+ */
180
+ set exceptionIds(exceptionIds: string[]);
181
+
182
+ /**
183
+ * 排除异常构建以更新包围盒
184
+ * @param exceptionIds
185
+ * @param callback
186
+ */
187
+ updateAABBCullException(exceptionIds: any, callback?: Function): void;
188
+
189
+ /**
190
+ * 取消模型构建异常检测更新效果
191
+ */
192
+ cancelCullException(callback?: Function): void;
193
+
194
+ /**
195
+ * The number of entities in this SceneModel.
196
+ *
197
+ * @type {number}
198
+ */
199
+ get numEntities(): number;
200
+
201
+ /**
202
+ * The approximate number of triangle primitives in this SceneModel.
203
+ *
204
+ * @type {number}
205
+ */
206
+ get numTriangles(): number;
207
+
208
+ /**
209
+ * The approximate number of line primitives in this SceneModel.
210
+ *
211
+ * @type {number}
212
+ */
213
+ get numLines(): number;
214
+
215
+ /**
216
+ * The approximate number of point primitives in this SceneModel.
217
+ *
218
+ * @type {number}
219
+ */
220
+ get numPoints(): number;
221
+
222
+ /**
223
+ * Gets if any {@link SceneModelEntity}s in this SceneModel are visible.
224
+ *
225
+ * The SceneModel is only rendered when {@link SceneModel.visible} is ````true```` and {@link SceneModel.culled} is ````false````.
226
+ *
227
+ * @type {Boolean}
228
+ */
229
+ get visible(): boolean;
230
+
231
+ /**
232
+ * Sets if this SceneModel is visible.
233
+ *
234
+ * The SceneModel is only rendered when {@link SceneModel.visible} is ````true```` and {@link SceneModel.culled} is ````false````.
235
+ **
236
+ * @type {Boolean}
237
+ */
238
+ set visible(visible: boolean);
239
+
240
+ /**
241
+ * Gets if any {@link SceneModelEntity}s in this SceneModel are xrayed.
242
+ *
243
+ * @type {Boolean}
244
+ */
245
+ get xrayed(): boolean;
246
+
247
+ /**
248
+ * Sets if all {@link SceneModelEntity}s in this SceneModel are xrayed.
249
+ *
250
+ * @type {Boolean}
251
+ */
252
+ set xrayed(xrayed: boolean);
253
+
254
+ /**
255
+ * Gets if any {@link SceneModelEntity}s in this SceneModel are highlighted.
256
+ *
257
+ * @type {Boolean}
258
+ */
259
+ get highlighted(): boolean;
260
+
261
+ /**
262
+ * Sets if all {@link SceneModelEntity}s in this SceneModel are highlighted.
263
+ *
264
+ * @type {Boolean}
265
+ */
266
+ set highlighted(highlighted: boolean);
267
+
268
+ /**
269
+ * Gets if any {@link SceneModelEntity}s in this SceneModel are selected.
270
+ *
271
+ * @type {Boolean}
272
+ */
273
+ get selected(): boolean;
274
+
275
+ /**
276
+ * Sets if all {@link SceneModelEntity}s in this SceneModel are selected.
277
+ *
278
+ * @type {Boolean}
279
+ */
280
+ set selected(selected: boolean);
281
+
282
+ /**
283
+ * Gets if any {@link SceneModelEntity}s in this SceneModel have edges emphasised.
284
+ *
285
+ * @type {Boolean}
286
+ */
287
+ get edges(): boolean;
288
+
289
+ /**
290
+ * Sets if all {@link SceneModelEntity}s in this SceneModel have edges emphasised.
291
+ *
292
+ * @type {Boolean}
293
+ */
294
+ set edges(edges: boolean);
295
+
296
+ /**
297
+ * Gets if this SceneModel is culled from view.
298
+ *
299
+ * The SceneModel is only rendered when {@link SceneModel.visible} is true and {@link SceneModel.culled} is false.
300
+ *
301
+ * @type {Boolean}
302
+ */
303
+ get culled(): boolean;
304
+
305
+ /**
306
+ * Sets if this SceneModel is culled from view.
307
+ *
308
+ * The SceneModel is only rendered when {@link SceneModel.visible} is true and {@link SceneModel.culled} is false.
309
+ *
310
+ * @type {Boolean}
311
+ */
312
+ set culled(culled: boolean);
313
+
314
+ /**
315
+ * Gets if {@link SceneModelEntity}s in this SceneModel are clippable.
316
+ *
317
+ * Clipping is done by the {@link SectionPlane}s in {@link Scene.sectionPlanes}.
318
+ *
319
+ * @type {Boolean}
320
+ */
321
+ get clippable(): boolean;
322
+
323
+ /**
324
+ * Sets if {@link SceneModelEntity}s in this SceneModel are clippable.
325
+ *
326
+ * Clipping is done by the {@link SectionPlane}s in {@link Scene.sectionPlanes}.
327
+ *
328
+ * @type {Boolean}
329
+ */
330
+ set clippable(clippable: boolean);
331
+
332
+ /**
333
+ * Gets if this SceneModel is collidable.
334
+ *
335
+ * @type {Boolean}
336
+ */
337
+ get collidable(): boolean;
338
+
339
+ /**
340
+ * Sets if {@link SceneModelEntity}s in this SceneModel are collidable.
341
+ *
342
+ * @type {Boolean}
343
+ */
344
+ set collidable(collidable: boolean);
345
+
346
+ /**
347
+ * Gets if this SceneModel is pickable.
348
+ *
349
+ * Picking is done via calls to {@link Scene.pick}.
350
+ *
351
+ * @type {Boolean}
352
+ */
353
+ get pickable(): boolean;
354
+
355
+ /**
356
+ * Sets if {@link SceneModelEntity}s in this SceneModel are pickable.
357
+ *
358
+ * Picking is done via calls to {@link Scene.pick}.
359
+ *
360
+ * @type {Boolean}
361
+ */
362
+ set pickable(pickable: boolean);
363
+
364
+ /**
365
+ * Gets the RGB colorize color for this SceneModel.
366
+ *
367
+ * Each element of the color is in range ````[0..1]````.
368
+ *
369
+ * @type {number[]}
370
+ */
371
+ get colorize(): number[];
372
+
373
+ /**
374
+ * Sets the RGB colorize color for this SceneModel.
375
+ *
376
+ * Multiplies by rendered fragment colors.
377
+ *
378
+ * Each element of the color is in range ````[0..1]````.
379
+ *
380
+ * @type {number[]}
381
+ */
382
+ set colorize(colorize: number[]);
383
+
384
+ /**
385
+ * Gets this SceneModel's opacity factor.
386
+ *
387
+ * This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
388
+ *
389
+ * @type {number}
390
+ */
391
+ get opacity(): number;
392
+
393
+ /**
394
+ * Sets the opacity factor for this SceneModel.
395
+ *
396
+ * This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
397
+ *
398
+ * @type {number}
399
+ */
400
+ set opacity(opacity: number);
401
+
402
+ /**
403
+ * Gets if this SceneModel casts a shadow.
404
+ *
405
+ * @type {Boolean}
406
+ */
407
+ get castsShadow(): boolean;
408
+
409
+ /**
410
+ * Sets if this SceneModel casts a shadow.
411
+ *
412
+ * @type {Boolean}
413
+ */
414
+ set castsShadow(castsShadow: boolean);
415
+
416
+ /**
417
+ * Sets if this SceneModel can have shadow cast upon it.
418
+ *
419
+ * @type {Boolean}
420
+ */
421
+ get receivesShadow(): boolean;
422
+
423
+ /**
424
+ * Sets if this SceneModel can have shadow cast upon it.
425
+ *
426
+ * @type {Boolean}
427
+ */
428
+ set receivesShadow(receivesShadow: boolean);
429
+
430
+ /**
431
+ * Gets if Scalable Ambient Obscurance (SAO) will apply to this SceneModel.
432
+ *
433
+ * SAO is configured by the Scene's {@link SAO} component.
434
+ *
435
+ * Only works when {@link SAO.enabled} is also true.
436
+ *
437
+ * @type {Boolean}
438
+ */
439
+ get saoEnabled(): boolean;
440
+
441
+ /**
442
+ * Gets if physically-based rendering (PBR) is enabled for this SceneModel.
443
+ *
444
+ * Only works when {@link Scene.pbrEnabled} is also true.
445
+ *
446
+ * @type {Boolean}
447
+ */
448
+ get pbrEnabled(): boolean;
449
+
450
+ /**
451
+ * Returns true to indicate that SceneModel is implements {@link Drawable}.
452
+ *
453
+ * @type {Boolean}
454
+ */
455
+ get isDrawable(): boolean;
456
+
457
+ /**
458
+ * Configures the appearance of xrayed {@link SceneModelEntity}s within this SceneModel.
459
+ *
460
+ * This is the {@link Scene.xrayMaterial}.
461
+ *
462
+ * @type {EmphasisMaterial}
463
+ */
464
+ get xrayMaterial(): EmphasisMaterial;
465
+
466
+ /**
467
+ * Configures the appearance of highlighted {@link SceneModelEntity}s within this SceneModel.
468
+ *
469
+ * This is the {@link Scene.highlightMaterial}.
470
+ *
471
+ * @type {EmphasisMaterial}
472
+ */
473
+ get highlightMaterial(): EmphasisMaterial;
474
+
475
+ /**
476
+ * Configures the appearance of selected {@link SceneModelEntity}s within this SceneModel.
477
+ *
478
+ * This is the {@link Scene.selectedMaterial}.
479
+ *
480
+ * @type {EmphasisMaterial}
481
+ */
482
+ get selectedMaterial(): EmphasisMaterial;
483
+
484
+ /**
485
+ * Configures the appearance of edges of {@link SceneModelEntity}s within this SceneModel.
486
+ *
487
+ * This is the {@link Scene.edgeMaterial}.
488
+ *
489
+ * @type {EdgeMaterial}
490
+ */
491
+ get edgeMaterial(): EdgeMaterial;
492
+
493
+ /**
494
+ * Creates a texture within this SceneModel.
495
+ *
496
+ * We can then supply the texture ID to {@link SceneModel#createTextureSet} when we want to create texture sets that use the texture.
497
+ *
498
+ * @param {*} cfg Texture properties.
499
+ * @param {string|number} cfg.id Mandatory ID for the texture, to refer to with {@link SceneModel#createTextureSet}.
500
+ * @param {string} [cfg.src] Image file for the texture. Assumed to be transcoded if not having a recognized image file
501
+ * extension (jpg, jpeg, png etc.). If transcoded, then assumes ````SceneModel```` is configured with a {@link TextureTranscoder}.
502
+ * @param {ArrayBuffer[]} [cfg.buffers] Transcoded texture data. Assumes ````SceneModel```` is
503
+ * configured with a {@link TextureTranscoder}. This parameter is given as an array of buffers so we can potentially support multi-image textures, such as cube maps.
504
+ * @param {HTMLImageElement} [cfg.image] HTML Image object to load into this texture. Overrides ````src```` and ````buffers````. Never transcoded.
505
+ * @param {number} [cfg.minFilter=LinearMipmapLinearFilter] How the texture is sampled when a texel covers less than one pixel.
506
+ * Supported values are {@link LinearMipmapLinearFilter}, {@link LinearMipMapNearestFilter}, {@link NearestMipMapNearestFilter}, {@link NearestMipMapLinearFilter} and {@link LinearMipMapLinearFilter}.
507
+ * @param {number} [cfg.magFilter=LinearFilter] How the texture is sampled when a texel covers more than one pixel. Supported values are {@link LinearFilter} and {@link NearestFilter}.
508
+ * @param {number} [cfg.wrapS=RepeatWrapping] Wrap parameter for texture coordinate *S*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
509
+ * @param {number} [cfg.wrapT=RepeatWrapping] Wrap parameter for texture coordinate *T*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}..
510
+ * @param {number} [cfg.wrapR=RepeatWrapping] Wrap parameter for texture coordinate *R*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
511
+ * @param {Boolean} [cfg.flipY=false] Flips this Texture's source data along its vertical axis when ````true````.
512
+ * @param {number} [cfg.encoding=LinearEncoding] Encoding format. Supported values are {@link LinearEncoding} and {@link sRGBEncoding}.
513
+ */
514
+ createTexture(cfg: {
515
+ id: string | number;
516
+ src?: string;
517
+ buffer?: ArrayBuffer[];
518
+ image?: HTMLImageElement;
519
+ minFilter?: number;
520
+ magFilter?: number;
521
+ wrapS?: number;
522
+ wrapT?: number;
523
+ flipY?: boolean;
524
+ encoding?: number;
525
+ }): void;
526
+
527
+ /**
528
+ * Creates a texture set within this SceneModel.
529
+ *
530
+ * * Stores the new {@link SceneModelTextureSet} in {@link SceneModel#textureSets}.
531
+ *
532
+ * A texture set is a collection of textures that can be shared among meshes. We can then supply the texture set
533
+ * ID to {@link SceneModel#createMesh} when we want to create meshes that use the texture set.
534
+ *
535
+ * The textures can work as a texture atlas, where each mesh can have geometry UVs that index
536
+ * a different part of the textures. This allows us to minimize the number of textures in our models, which
537
+ * means faster rendering.
538
+ *
539
+ * @param {*} cfg Texture set properties.
540
+ * @param {string|number} cfg.id Mandatory ID for the texture set, to refer to with {@link SceneModel#createMesh}.
541
+ * @param {*} [cfg.colorTextureId] ID of *RGBA* base color texture, with color in *RGB* and alpha in *A*.
542
+ * @param {*} [cfg.metallicRoughnessTextureId] ID of *RGBA* metal-roughness texture, with the metallic factor in *R*, and roughness factor in *G*.
543
+ * @param {*} [cfg.normalsTextureId] ID of *RGBA* normal map texture, with normal map vectors in *RGB*.
544
+ * @param {*} [cfg.emissiveTextureId] ID of *RGBA* emissive map texture, with emissive color in *RGB*.
545
+ * @param {*} [cfg.occlusionTextureId] ID of *RGBA* occlusion map texture, with occlusion factor in *R*.
546
+ * @returns {SceneModelTransform} The new texture set.
547
+ */
548
+ createTextureSet(cfg: {
549
+ id: string | number;
550
+ colorTextureId?: string | number;
551
+ metallicRoughnessTextureId?: string | number;
552
+ normalsTextureId?: string | number;
553
+ emissiveTextureId?: string | number;
554
+ occlusionTextureId?: string | number;
555
+ }): SceneModelTextureSet;
556
+
557
+ /**
558
+ * Creates a reusable geometry within this SceneModel.
559
+ *
560
+ * We can then supply the geometry ID to {@link SceneModel.createMesh} when we want to create meshes that instance the geometry.
561
+ *
562
+ * If provide a ````positionsDecodeMatrix```` , then ````createGeometry()```` will assume
563
+ * that the ````positions```` and ````normals```` arrays are compressed. When compressed, ````positions```` will be
564
+ * quantized and in World-space, and ````normals```` will be oct-encoded and in World-space.
565
+ *
566
+ * Note that ````positions````, ````normals```` and ````indices```` are all required together.
567
+ *
568
+ * @param {*} cfg Geometry properties.
569
+ * @param {string|number} cfg.id Mandatory ID for the geometry, to refer to with {@link SceneModel.createMesh}.
570
+ * @param {string} cfg.primitive The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.
571
+ * @param {number[]} cfg.positions Flat array of positions.
572
+ * @param {number[]} [cfg.normals] Flat array of normal vectors. Only used with 'triangles' primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
573
+ * @param {number[]} [cfg.colors] Flat array of RGBA vertex colors as float values in range ````[0..1]````. Ignored when ````geometryId```` is given, overidden by ````color```` and ````colorsCompressed````.
574
+ * @param {number[]} [cfg.colorsCompressed] Flat array of RGBA vertex colors as unsigned short integers in range ````[0..255]````. Ignored when ````geometryId```` is given, overrides ````colors```` and is overriden by ````color````.
575
+ * @param {number[]} [cfg.indices] Array of indices. Not required for `points` primitives.
576
+ * @param {number[]} [cfg.edgeIndices] Array of edge line indices. Used only for Required for 'triangles' primitives. These are automatically generated internally if not supplied, using the ````edgeThreshold```` given to the ````SceneModel```` constructor.
577
+ * @param {number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positions````.
578
+ * @param {number[]} [cfg.origin] Optional geometry origin, relative to {@link SceneModel.origin}. When this is given, then every mesh created with {@link SceneModel.createMesh} that uses this geometry will
579
+ * be transformed relative to this origin.
580
+ */
581
+ createGeometry(cfg: {
582
+ id: string | number;
583
+ primitive: "lines" | "triangles" | "solid" | "surface";
584
+ positions: number[];
585
+ normals: number[];
586
+ colors: number[];
587
+ colorsCompressed: number[];
588
+ indices: number[];
589
+ edgeIndices: number[];
590
+ positionsDecodeMatrix: number[];
591
+ origin?: number[];
592
+ }): void;
593
+
594
+ /**
595
+ * Creates a new {@link SceneModelTransform} within this SceneModel.
596
+ *
597
+ * * Stores the new {@link SceneModelTransform} in {@link SceneModel#transforms}.
598
+ * * Can be connected into hierarchies
599
+ * * Each {@link SceneModelTransform} can be used by unlimited {@link SceneModelMesh}es
600
+ *
601
+ * @param {*} cfg Transform creation parameters.
602
+ * @param {string} cfg.id Mandatory ID for the new transform. Must not clash with any existing components within the {@link Scene}.
603
+ * @param {string} [cfg.parentTransformId] ID of a parent transform, previously created with {@link SceneModel#createTextureSet}.
604
+ * @param {number[]} [cfg.position=[0,0,0]] Local 3D position of the mesh. Overridden by ````transformId````.
605
+ * @param {number[]} [cfg.scale=[1,1,1]] Scale of the transform.
606
+ * @param {number[]} [cfg.rotation=[0,0,0]] Rotation of the transform as Euler angles given in degrees, for each of the X, Y and Z axis.
607
+ * @param {number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Modelling transform matrix. Overrides the ````position````, ````scale```` and ````rotation```` parameters.
608
+ * @returns {SceneModelTransform} The new transform.
609
+ */
610
+ createTransform(cfg: {
611
+ id: string | number;
612
+ parentTransformId: string | number;
613
+ position?: number[];
614
+ scale?: number[];
615
+ rotation?: number[];
616
+ matrix?: number[];
617
+ }): SceneModelMesh;
618
+
619
+ /**
620
+ * Creates a new {@link SceneModelMesh} within this SceneModel.
621
+ *
622
+ * * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
623
+ * * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
624
+ * various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
625
+ * with {@link SceneModel#createGeometry}.
626
+ * * If you accompany the arrays with an ````origin````, then ````createMesh()```` will assume
627
+ * that the geometry ````positions```` are in relative-to-center (RTC) coordinates, with ````origin```` being the
628
+ * origin of their RTC coordinate system.
629
+ *
630
+ * @param {object} cfg Object properties.
631
+ * @param {String} cfg.id Mandatory ID for the new mesh. Must not clash with any existing components within the {@link Scene}.
632
+ * @param {String|Number} [cfg.textureSetId] ID of a {@link SceneModelTextureSet} previously created with {@link SceneModel#createTextureSet}.
633
+ * @param {String|Number} [cfg.transformId] ID of a {@link SceneModelTransform} to instance, previously created with {@link SceneModel#createTransform}. Overrides all other transform parameters given to this method.
634
+ * @param {String|Number} [cfg.geometryId] ID of a geometry to instance, previously created with {@link SceneModel#createGeometry}. Overrides all other geometry parameters given to this method.
635
+ * @param {String} cfg.primitive The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.
636
+ * @param {Number[]} [cfg.positions] Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by ````positionsCompressed````.
637
+ * @param {Number[]} [cfg.positionsCompressed] Flat array of quantized 3D vertex positions. Overrides ````positions````, and must be accompanied by ````positionsDecodeMatrix````.
638
+ * @param {Number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positionsCompressed````. Must be accompanied by ````positionsCompressed````.
639
+ * @param {Number[]} [cfg.normals] Flat array of normal vectors. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
640
+ * @param {Number[]} [cfg.normalsCompressed] Flat array of oct-encoded normal vectors. Overrides ````normals````. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.
641
+ * @param {Number[]} [cfg.colors] Flat array of uncompressed RGBA vertex colors, as float values in range ````[0..1]````. Ignored when ````geometryId```` is given. Overridden by ````color```` and ````colorsCompressed````.
642
+ * @param {Number[]} [cfg.colorsCompressed] Flat array of compressed RGBA vertex colors, as unsigned short integers in range ````[0..255]````. Ignored when ````geometryId```` is given. Overrides ````colors```` and is overridden by ````color````.
643
+ * @param {Number[]} [cfg.uv] Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.
644
+ * @param {Number[]} [cfg.uvCompressed] Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides ````uv````. Must be accompanied by ````uvDecodeMatrix````. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.
645
+ * @param {Number[]} [cfg.uvDecodeMatrix] A 3x3 matrix for decompressing ````uvCompressed````.
646
+ * @param {Number[]} [cfg.indices] Array of primitive connectivity indices. Not required for `points` primitives.
647
+ * @param {Number[]} [cfg.edgeIndices] Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional ````edgeThreshold```` given to the ````SceneModel```` constructor.
648
+ * @param {Number[]} [cfg.origin] Optional geometry origin, relative to {@link SceneModel#origin}. When this is given, then ````positions```` are assumed to be relative to this.
649
+ * @param {Number[]} [cfg.position=[0,0,0]] Local 3D position of the mesh. Overridden by ````transformId````.
650
+ * @param {Number[]} [cfg.scale=[1,1,1]] Scale of the mesh. Overridden by ````transformId````.
651
+ * @param {Number[]} [cfg.rotation=[0,0,0]] Rotation of the mesh as Euler angles given in degrees, for each of the X, Y and Z axis. Overridden by ````transformId````.
652
+ * @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Mesh modelling transform matrix. Overrides the ````position````, ````scale```` and ````rotation```` parameters. Also overridden by ````transformId````.
653
+ * @param {Number[]} [cfg.color=[1,1,1]] RGB color in range ````[0..1, 0..1, 0..1]````. Overridden by texture set ````colorTexture````. Overrides ````colors```` and ````colorsCompressed````.
654
+ * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
655
+ * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
656
+ * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
657
+ * @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
658
+ */
659
+ createMesh(cfg: {
660
+ id: string;
661
+ textureSetId?: string | number;
662
+ transformId?: string | number;
663
+ geometryId?: string | number;
664
+ primitive: "lines" | "triangles" | "points";
665
+ positions: number[];
666
+ positionsCompressed: number[];
667
+ positionsDecodeMatrix: number[];
668
+ normals: number[];
669
+ normalsCompressed: number[];
670
+ colors: number[];
671
+ colorsCompressed: number[];
672
+ uv: number[];
673
+ uvCompressed: number[];
674
+ uvDecodeMatrix: number[];
675
+ indices: number[];
676
+ edgeIndices: number[];
677
+ origin?: number[];
678
+ position?: number[];
679
+ scale?: number[];
680
+ rotation?: number[];
681
+ matrix?: number[];
682
+ color?: number[];
683
+ opacity?: number;
684
+ metallic?: number;
685
+ roughness?: number;
686
+ }): boolean;
687
+
688
+ /**
669
689
  * Creates an {@link SceneModelEntity} within this SceneModel, giving it one or more meshes previously created with {@link SceneModel.createMesh}.
670
690
  *
671
691
  * A mesh can only belong to one {@link SceneModelEntity}, so you'll get an error if you try to reuse a mesh among multiple {@link SceneModelEntity}s.
@@ -688,29 +708,29 @@ export declare class SceneModel extends Component {
688
708
  * @param {Boolean} [cfg.edges=false] Indicates if the SceneModelEntity's edges are initially emphasized. Edges appearance is configured by {@link SceneModel.edgeMaterial}.
689
709
  * @returns {SceneModelEntity}
690
710
  */
691
- createEntity(cfg: {
692
- id: string;
693
- meshIds: string[]
694
- isObject: boolean;
695
- visible?: boolean;
696
- culled?: boolean;
697
- pickable?: boolean;
698
- clippable?: boolean;
699
- collidable?: boolean;
700
- castsShadow?: boolean;
701
- receivesShadow?: boolean;
702
- xrayed?: boolean;
703
- highlighted?: boolean;
704
- selected?: boolean;
705
- edges?: boolean;
706
- }): SceneModelEntity;
707
-
708
- /**
709
- * Finalizes this SceneModel.
710
- *
711
- * Immediately creates the SceneModel's {@link SceneModelEntity}s within the {@link Scene}.
712
- *
713
- * Once finalized, you can't add anything more to this SceneModel.
714
- */
715
- finalize(): void;
711
+ createEntity(cfg: {
712
+ id: string;
713
+ meshIds: string[];
714
+ isObject: boolean;
715
+ visible?: boolean;
716
+ culled?: boolean;
717
+ pickable?: boolean;
718
+ clippable?: boolean;
719
+ collidable?: boolean;
720
+ castsShadow?: boolean;
721
+ receivesShadow?: boolean;
722
+ xrayed?: boolean;
723
+ highlighted?: boolean;
724
+ selected?: boolean;
725
+ edges?: boolean;
726
+ }): SceneModelEntity;
727
+
728
+ /**
729
+ * Finalizes this SceneModel.
730
+ *
731
+ * Immediately creates the SceneModel's {@link SceneModelEntity}s within the {@link Scene}.
732
+ *
733
+ * Once finalized, you can't add anything more to this SceneModel.
734
+ */
735
+ finalize(): void;
716
736
  }