@xeokit/xeokit-sdk 2.4.2-beta-8 → 2.4.2-beta-9
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/xeokit-sdk.cjs.js +47 -18
- package/dist/xeokit-sdk.es.js +47 -18
- package/dist/xeokit-sdk.es5.js +75 -66
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/dist/xeokit-sdk.min.es5.js +1 -1
- package/package.json +1 -1
- package/src/viewer/metadata/MetaModel.js +17 -2
- package/src/viewer/scene/model/vbo/linesInstancing/LinesInstancingLayer.js +5 -0
- package/src/viewer/scene/model/vbo/pointsInstancing/PointsInstancingLayer.js +4 -0
- package/src/viewer/scene/model/vbo/trianglesInstancing/TrianglesInstancingLayer.js +21 -16
- package/types/viewer/scene/mesh/Mesh.d.ts +7 -0
- package/types/viewer/scene/models/PerformanceModel/PerformanceModel.d.ts +3 -609
- package/types/viewer/scene/models/SceneModel.d.ts +708 -0
- package/types/viewer/scene/models/SceneModelEntity.d.ts +418 -0
- package/types/viewer/scene/models/SceneModelMesh.d.ts +68 -0
- package/types/viewer/scene/models/SceneModelTexture.d.ts +16 -0
- package/types/viewer/scene/models/SceneModelTextureSet.d.ts +51 -0
- package/types/viewer/scene/models/SceneModelTransform.d.ts +197 -0
- package/types/viewer/scene/models/VBOSceneModel/VBOSceneModel.d.ts +2 -610
- package/types/viewer/scene/models/index.d.ts +8 -1
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
import {Component} from "../Component";
|
|
2
|
+
import {SceneModelEntity} from "./SceneModelEntity";
|
|
3
|
+
import {EdgeMaterial, EmphasisMaterial} from "../materials";
|
|
4
|
+
import {SceneModelMesh} from "./SceneModelMesh";
|
|
5
|
+
import {SceneModelTextureSet} from "./SceneModelTextureSet";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A high-performance model representation for efficient rendering and low memory usage.
|
|
9
|
+
*/
|
|
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
|
+
* The approximate number of triangle primitives in this SceneModel.
|
|
173
|
+
*
|
|
174
|
+
* @type {number}
|
|
175
|
+
*/
|
|
176
|
+
get numTriangles(): number;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The approximate number of line primitives in this SceneModel.
|
|
180
|
+
*
|
|
181
|
+
* @type {number}
|
|
182
|
+
*/
|
|
183
|
+
get numLines(): number;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The approximate number of point primitives in this SceneModel.
|
|
187
|
+
*
|
|
188
|
+
* @type {number}
|
|
189
|
+
*/
|
|
190
|
+
get numPoints(): number;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Gets if any {@link SceneModelEntity}s in this SceneModel are visible.
|
|
194
|
+
*
|
|
195
|
+
* The SceneModel is only rendered when {@link SceneModel.visible} is ````true```` and {@link SceneModel.culled} is ````false````.
|
|
196
|
+
*
|
|
197
|
+
* @type {Boolean}
|
|
198
|
+
*/
|
|
199
|
+
get visible(): boolean;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sets if this SceneModel is visible.
|
|
203
|
+
*
|
|
204
|
+
* The SceneModel is only rendered when {@link SceneModel.visible} is ````true```` and {@link SceneModel.culled} is ````false````.
|
|
205
|
+
**
|
|
206
|
+
* @type {Boolean}
|
|
207
|
+
*/
|
|
208
|
+
set visible(visible: boolean);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Gets if any {@link SceneModelEntity}s in this SceneModel are xrayed.
|
|
212
|
+
*
|
|
213
|
+
* @type {Boolean}
|
|
214
|
+
*/
|
|
215
|
+
get xrayed(): boolean
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Sets if all {@link SceneModelEntity}s in this SceneModel are xrayed.
|
|
219
|
+
*
|
|
220
|
+
* @type {Boolean}
|
|
221
|
+
*/
|
|
222
|
+
set xrayed(xrayed: boolean);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Gets if any {@link SceneModelEntity}s in this SceneModel are highlighted.
|
|
226
|
+
*
|
|
227
|
+
* @type {Boolean}
|
|
228
|
+
*/
|
|
229
|
+
get highlighted(): boolean;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Sets if all {@link SceneModelEntity}s in this SceneModel are highlighted.
|
|
233
|
+
*
|
|
234
|
+
* @type {Boolean}
|
|
235
|
+
*/
|
|
236
|
+
set highlighted(highlighted: boolean);
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Gets if any {@link SceneModelEntity}s in this SceneModel are selected.
|
|
240
|
+
*
|
|
241
|
+
* @type {Boolean}
|
|
242
|
+
*/
|
|
243
|
+
get selected(): boolean;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Sets if all {@link SceneModelEntity}s in this SceneModel are selected.
|
|
247
|
+
*
|
|
248
|
+
* @type {Boolean}
|
|
249
|
+
*/
|
|
250
|
+
set selected(selected: boolean);
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Gets if any {@link SceneModelEntity}s in this SceneModel have edges emphasised.
|
|
254
|
+
*
|
|
255
|
+
* @type {Boolean}
|
|
256
|
+
*/
|
|
257
|
+
get edges(): boolean;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Sets if all {@link SceneModelEntity}s in this SceneModel have edges emphasised.
|
|
261
|
+
*
|
|
262
|
+
* @type {Boolean}
|
|
263
|
+
*/
|
|
264
|
+
set edges(edges: boolean);
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Gets if this SceneModel is culled from view.
|
|
268
|
+
*
|
|
269
|
+
* The SceneModel is only rendered when {@link SceneModel.visible} is true and {@link SceneModel.culled} is false.
|
|
270
|
+
*
|
|
271
|
+
* @type {Boolean}
|
|
272
|
+
*/
|
|
273
|
+
get culled(): boolean;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Sets if this SceneModel is culled from view.
|
|
277
|
+
*
|
|
278
|
+
* The SceneModel is only rendered when {@link SceneModel.visible} is true and {@link SceneModel.culled} is false.
|
|
279
|
+
*
|
|
280
|
+
* @type {Boolean}
|
|
281
|
+
*/
|
|
282
|
+
set culled(culled: boolean);
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Gets if {@link SceneModelEntity}s in this SceneModel are clippable.
|
|
286
|
+
*
|
|
287
|
+
* Clipping is done by the {@link SectionPlane}s in {@link Scene.sectionPlanes}.
|
|
288
|
+
*
|
|
289
|
+
* @type {Boolean}
|
|
290
|
+
*/
|
|
291
|
+
get clippable(): boolean;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Sets if {@link SceneModelEntity}s in this SceneModel are clippable.
|
|
295
|
+
*
|
|
296
|
+
* Clipping is done by the {@link SectionPlane}s in {@link Scene.sectionPlanes}.
|
|
297
|
+
*
|
|
298
|
+
* @type {Boolean}
|
|
299
|
+
*/
|
|
300
|
+
set clippable(clippable: boolean) ;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Gets if this SceneModel is collidable.
|
|
304
|
+
*
|
|
305
|
+
* @type {Boolean}
|
|
306
|
+
*/
|
|
307
|
+
get collidable(): boolean;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Sets if {@link SceneModelEntity}s in this SceneModel are collidable.
|
|
311
|
+
*
|
|
312
|
+
* @type {Boolean}
|
|
313
|
+
*/
|
|
314
|
+
set collidable(collidable: boolean);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Gets if this SceneModel is pickable.
|
|
318
|
+
*
|
|
319
|
+
* Picking is done via calls to {@link Scene.pick}.
|
|
320
|
+
*
|
|
321
|
+
* @type {Boolean}
|
|
322
|
+
*/
|
|
323
|
+
get pickable(): boolean;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Sets if {@link SceneModelEntity}s in this SceneModel are pickable.
|
|
327
|
+
*
|
|
328
|
+
* Picking is done via calls to {@link Scene.pick}.
|
|
329
|
+
*
|
|
330
|
+
* @type {Boolean}
|
|
331
|
+
*/
|
|
332
|
+
set pickable(pickable: boolean);
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Gets the RGB colorize color for this SceneModel.
|
|
336
|
+
*
|
|
337
|
+
* Each element of the color is in range ````[0..1]````.
|
|
338
|
+
*
|
|
339
|
+
* @type {number[]}
|
|
340
|
+
*/
|
|
341
|
+
get colorize(): number[];
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Sets the RGB colorize color for this SceneModel.
|
|
345
|
+
*
|
|
346
|
+
* Multiplies by rendered fragment colors.
|
|
347
|
+
*
|
|
348
|
+
* Each element of the color is in range ````[0..1]````.
|
|
349
|
+
*
|
|
350
|
+
* @type {number[]}
|
|
351
|
+
*/
|
|
352
|
+
set colorize(colorize: number[]);
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Gets this SceneModel's opacity factor.
|
|
356
|
+
*
|
|
357
|
+
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
|
358
|
+
*
|
|
359
|
+
* @type {number}
|
|
360
|
+
*/
|
|
361
|
+
get opacity(): number;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Sets the opacity factor for this SceneModel.
|
|
365
|
+
*
|
|
366
|
+
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
|
367
|
+
*
|
|
368
|
+
* @type {number}
|
|
369
|
+
*/
|
|
370
|
+
set opacity(opacity: number);
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Gets if this SceneModel casts a shadow.
|
|
374
|
+
*
|
|
375
|
+
* @type {Boolean}
|
|
376
|
+
*/
|
|
377
|
+
get castsShadow(): boolean;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Sets if this SceneModel casts a shadow.
|
|
381
|
+
*
|
|
382
|
+
* @type {Boolean}
|
|
383
|
+
*/
|
|
384
|
+
set castsShadow(castsShadow: boolean);
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Sets if this SceneModel can have shadow cast upon it.
|
|
388
|
+
*
|
|
389
|
+
* @type {Boolean}
|
|
390
|
+
*/
|
|
391
|
+
get receivesShadow(): boolean;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Sets if this SceneModel can have shadow cast upon it.
|
|
395
|
+
*
|
|
396
|
+
* @type {Boolean}
|
|
397
|
+
*/
|
|
398
|
+
set receivesShadow(receivesShadow: boolean) ;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Gets if Scalable Ambient Obscurance (SAO) will apply to this SceneModel.
|
|
402
|
+
*
|
|
403
|
+
* SAO is configured by the Scene's {@link SAO} component.
|
|
404
|
+
*
|
|
405
|
+
* Only works when {@link SAO.enabled} is also true.
|
|
406
|
+
*
|
|
407
|
+
* @type {Boolean}
|
|
408
|
+
*/
|
|
409
|
+
get saoEnabled(): boolean;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Gets if physically-based rendering (PBR) is enabled for this SceneModel.
|
|
413
|
+
*
|
|
414
|
+
* Only works when {@link Scene.pbrEnabled} is also true.
|
|
415
|
+
*
|
|
416
|
+
* @type {Boolean}
|
|
417
|
+
*/
|
|
418
|
+
get pbrEnabled(): boolean;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Returns true to indicate that SceneModel is implements {@link Drawable}.
|
|
422
|
+
*
|
|
423
|
+
* @type {Boolean}
|
|
424
|
+
*/
|
|
425
|
+
get isDrawable(): boolean;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Configures the appearance of xrayed {@link SceneModelEntity}s within this SceneModel.
|
|
429
|
+
*
|
|
430
|
+
* This is the {@link Scene.xrayMaterial}.
|
|
431
|
+
*
|
|
432
|
+
* @type {EmphasisMaterial}
|
|
433
|
+
*/
|
|
434
|
+
get xrayMaterial(): EmphasisMaterial;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Configures the appearance of highlighted {@link SceneModelEntity}s within this SceneModel.
|
|
438
|
+
*
|
|
439
|
+
* This is the {@link Scene.highlightMaterial}.
|
|
440
|
+
*
|
|
441
|
+
* @type {EmphasisMaterial}
|
|
442
|
+
*/
|
|
443
|
+
get highlightMaterial(): EmphasisMaterial;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Configures the appearance of selected {@link SceneModelEntity}s within this SceneModel.
|
|
447
|
+
*
|
|
448
|
+
* This is the {@link Scene.selectedMaterial}.
|
|
449
|
+
*
|
|
450
|
+
* @type {EmphasisMaterial}
|
|
451
|
+
*/
|
|
452
|
+
get selectedMaterial(): EmphasisMaterial;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Configures the appearance of edges of {@link SceneModelEntity}s within this SceneModel.
|
|
456
|
+
*
|
|
457
|
+
* This is the {@link Scene.edgeMaterial}.
|
|
458
|
+
*
|
|
459
|
+
* @type {EdgeMaterial}
|
|
460
|
+
*/
|
|
461
|
+
get edgeMaterial(): EdgeMaterial;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Creates a texture within this SceneModel.
|
|
465
|
+
*
|
|
466
|
+
* We can then supply the texture ID to {@link SceneModel#createTextureSet} when we want to create texture sets that use the texture.
|
|
467
|
+
*
|
|
468
|
+
* @param {*} cfg Texture properties.
|
|
469
|
+
* @param {string|number} cfg.id Mandatory ID for the texture, to refer to with {@link SceneModel#createTextureSet}.
|
|
470
|
+
* @param {string} [cfg.src] Image file for the texture. Assumed to be transcoded if not having a recognized image file
|
|
471
|
+
* extension (jpg, jpeg, png etc.). If transcoded, then assumes ````SceneModel```` is configured with a {@link TextureTranscoder}.
|
|
472
|
+
* @param {ArrayBuffer[]} [cfg.buffers] Transcoded texture data. Assumes ````SceneModel```` is
|
|
473
|
+
* 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.
|
|
474
|
+
* @param {HTMLImageElement} [cfg.image] HTML Image object to load into this texture. Overrides ````src```` and ````buffers````. Never transcoded.
|
|
475
|
+
* @param {number} [cfg.minFilter=LinearMipmapLinearFilter] How the texture is sampled when a texel covers less than one pixel.
|
|
476
|
+
* Supported values are {@link LinearMipmapLinearFilter}, {@link LinearMipMapNearestFilter}, {@link NearestMipMapNearestFilter}, {@link NearestMipMapLinearFilter} and {@link LinearMipMapLinearFilter}.
|
|
477
|
+
* @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}.
|
|
478
|
+
* @param {number} [cfg.wrapS=RepeatWrapping] Wrap parameter for texture coordinate *S*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
|
|
479
|
+
* @param {number} [cfg.wrapT=RepeatWrapping] Wrap parameter for texture coordinate *T*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}..
|
|
480
|
+
* @param {number} [cfg.wrapR=RepeatWrapping] Wrap parameter for texture coordinate *R*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
|
|
481
|
+
* @param {Boolean} [cfg.flipY=false] Flips this Texture's source data along its vertical axis when ````true````.
|
|
482
|
+
* @param {number} [cfg.encoding=LinearEncoding] Encoding format. Supported values are {@link LinearEncoding} and {@link sRGBEncoding}.
|
|
483
|
+
*/
|
|
484
|
+
createTexture(cfg: {
|
|
485
|
+
id: string | number,
|
|
486
|
+
src?: string,
|
|
487
|
+
buffer?: ArrayBuffer[],
|
|
488
|
+
image?: HTMLImageElement,
|
|
489
|
+
minFilter?: number,
|
|
490
|
+
magFilter?: number,
|
|
491
|
+
wrapS?: number,
|
|
492
|
+
wrapT?: number,
|
|
493
|
+
flipY?: boolean,
|
|
494
|
+
encoding?: number
|
|
495
|
+
}): void;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Creates a texture set within this SceneModel.
|
|
499
|
+
*
|
|
500
|
+
* * Stores the new {@link SceneModelTextureSet} in {@link SceneModel#textureSets}.
|
|
501
|
+
*
|
|
502
|
+
* A texture set is a collection of textures that can be shared among meshes. We can then supply the texture set
|
|
503
|
+
* ID to {@link SceneModel#createMesh} when we want to create meshes that use the texture set.
|
|
504
|
+
*
|
|
505
|
+
* The textures can work as a texture atlas, where each mesh can have geometry UVs that index
|
|
506
|
+
* a different part of the textures. This allows us to minimize the number of textures in our models, which
|
|
507
|
+
* means faster rendering.
|
|
508
|
+
*
|
|
509
|
+
* @param {*} cfg Texture set properties.
|
|
510
|
+
* @param {string|number} cfg.id Mandatory ID for the texture set, to refer to with {@link SceneModel#createMesh}.
|
|
511
|
+
* @param {*} [cfg.colorTextureId] ID of *RGBA* base color texture, with color in *RGB* and alpha in *A*.
|
|
512
|
+
* @param {*} [cfg.metallicRoughnessTextureId] ID of *RGBA* metal-roughness texture, with the metallic factor in *R*, and roughness factor in *G*.
|
|
513
|
+
* @param {*} [cfg.normalsTextureId] ID of *RGBA* normal map texture, with normal map vectors in *RGB*.
|
|
514
|
+
* @param {*} [cfg.emissiveTextureId] ID of *RGBA* emissive map texture, with emissive color in *RGB*.
|
|
515
|
+
* @param {*} [cfg.occlusionTextureId] ID of *RGBA* occlusion map texture, with occlusion factor in *R*.
|
|
516
|
+
* @returns {SceneModelTransform} The new texture set.
|
|
517
|
+
*/
|
|
518
|
+
createTextureSet(cfg: {
|
|
519
|
+
id: string | number,
|
|
520
|
+
colorTextureId?: string | number,
|
|
521
|
+
metallicRoughnessTextureId?: string | number,
|
|
522
|
+
normalsTextureId?: string | number,
|
|
523
|
+
emissiveTextureId?: string | number,
|
|
524
|
+
occlusionTextureId?: string | number
|
|
525
|
+
}): SceneModelTextureSet;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Creates a reusable geometry within this SceneModel.
|
|
529
|
+
*
|
|
530
|
+
* We can then supply the geometry ID to {@link SceneModel.createMesh} when we want to create meshes that instance the geometry.
|
|
531
|
+
*
|
|
532
|
+
* If provide a ````positionsDecodeMatrix```` , then ````createGeometry()```` will assume
|
|
533
|
+
* that the ````positions```` and ````normals```` arrays are compressed. When compressed, ````positions```` will be
|
|
534
|
+
* quantized and in World-space, and ````normals```` will be oct-encoded and in World-space.
|
|
535
|
+
*
|
|
536
|
+
* Note that ````positions````, ````normals```` and ````indices```` are all required together.
|
|
537
|
+
*
|
|
538
|
+
* @param {*} cfg Geometry properties.
|
|
539
|
+
* @param {string|number} cfg.id Mandatory ID for the geometry, to refer to with {@link SceneModel.createMesh}.
|
|
540
|
+
* @param {string} cfg.primitive The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.
|
|
541
|
+
* @param {number[]} cfg.positions Flat array of positions.
|
|
542
|
+
* @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.
|
|
543
|
+
* @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````.
|
|
544
|
+
* @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````.
|
|
545
|
+
* @param {number[]} [cfg.indices] Array of indices. Not required for `points` primitives.
|
|
546
|
+
* @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.
|
|
547
|
+
* @param {number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positions````.
|
|
548
|
+
* @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
|
|
549
|
+
* be transformed relative to this origin.
|
|
550
|
+
*/
|
|
551
|
+
createGeometry(cfg: {
|
|
552
|
+
id: string | number;
|
|
553
|
+
primitive: "lines" | "triangles" | "solid" | "surface";
|
|
554
|
+
positions: number[];
|
|
555
|
+
normals: number[];
|
|
556
|
+
colors: number[];
|
|
557
|
+
colorsCompressed: number[];
|
|
558
|
+
indices: number[];
|
|
559
|
+
edgeIndices: number[];
|
|
560
|
+
positionsDecodeMatrix: number[];
|
|
561
|
+
origin?: number[];
|
|
562
|
+
}): void;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Creates a new {@link SceneModelTransform} within this SceneModel.
|
|
566
|
+
*
|
|
567
|
+
* * Stores the new {@link SceneModelTransform} in {@link SceneModel#transforms}.
|
|
568
|
+
* * Can be connected into hierarchies
|
|
569
|
+
* * Each {@link SceneModelTransform} can be used by unlimited {@link SceneModelMesh}es
|
|
570
|
+
*
|
|
571
|
+
* @param {*} cfg Transform creation parameters.
|
|
572
|
+
* @param {string} cfg.id Mandatory ID for the new transform. Must not clash with any existing components within the {@link Scene}.
|
|
573
|
+
* @param {string} [cfg.parentTransformId] ID of a parent transform, previously created with {@link SceneModel#createTextureSet}.
|
|
574
|
+
* @param {number[]} [cfg.position=[0,0,0]] Local 3D position of the mesh. Overridden by ````transformId````.
|
|
575
|
+
* @param {number[]} [cfg.scale=[1,1,1]] Scale of the transform.
|
|
576
|
+
* @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.
|
|
577
|
+
* @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.
|
|
578
|
+
* @returns {SceneModelTransform} The new transform.
|
|
579
|
+
*/
|
|
580
|
+
createTransform(cfg: {
|
|
581
|
+
id: string | number,
|
|
582
|
+
parentTransformId: string | number,
|
|
583
|
+
position?: number[],
|
|
584
|
+
scale?: number[],
|
|
585
|
+
rotation?: number[],
|
|
586
|
+
matrix?: number[]
|
|
587
|
+
}): SceneModelMesh;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Creates a mesh within this SceneModel.
|
|
591
|
+
*
|
|
592
|
+
* A mesh can either share geometry with other meshes, or have its own unique geometry.
|
|
593
|
+
*
|
|
594
|
+
* To share a geometry with other meshes, provide the ID of a geometry created earlier
|
|
595
|
+
* with {@link SceneModel.createGeometry}.
|
|
596
|
+
*
|
|
597
|
+
* To create unique geometry for the mesh, provide geometry data arrays.
|
|
598
|
+
*
|
|
599
|
+
* Internally, SceneModel will batch all unique mesh geometries into the same arrays, which improves
|
|
600
|
+
* rendering performance.
|
|
601
|
+
*
|
|
602
|
+
* If you accompany the arrays with a ````positionsDecodeMatrix```` , then ````createMesh()```` will assume
|
|
603
|
+
* that the ````positions```` and ````normals```` arrays are compressed. When compressed, ````positions```` will be
|
|
604
|
+
* quantized and in World-space, and ````normals```` will be oct-encoded and in World-space.
|
|
605
|
+
*
|
|
606
|
+
* If you accompany the arrays with an ````origin````, then ````createMesh()```` will assume
|
|
607
|
+
* that the ````positions```` are in relative-to-center (RTC) coordinates, with ````origin```` being the origin of their
|
|
608
|
+
* RTC coordinate system.
|
|
609
|
+
*
|
|
610
|
+
* When providing either ````positionsDecodeMatrix```` or ````origin````, ````createMesh()```` will start a new
|
|
611
|
+
* batch each time either of those two parameters change since the last call. Therefore, to combine arrays into the
|
|
612
|
+
* minimum number of batches, it's best for performance to create your shared meshes in runs that have the same value
|
|
613
|
+
* for ````positionsDecodeMatrix```` and ````origin````.
|
|
614
|
+
*
|
|
615
|
+
* Note that ````positions````, ````normals```` and ````indices```` are all required together.
|
|
616
|
+
*
|
|
617
|
+
* @param {object} cfg Object properties.
|
|
618
|
+
* @param {string} cfg.id Mandatory ID for the new mesh. Must not clash with any existing components within the {@link Scene}.
|
|
619
|
+
* @param {string|number} [cfg.geometryId] ID of a geometry to instance, previously created with {@link SceneModel.createGeometry:method"}}createMesh(){{/crossLink}}. Overrides all other geometry parameters given to this method.
|
|
620
|
+
* @param {string} [cfg.primitive="triangles"] Geometry primitive type. Ignored when ````geometryId```` is given. Accepted values are 'points', 'lines' and 'triangles'.
|
|
621
|
+
* @param {number[]} [cfg.positions] Flat array of vertex positions. Ignored when ````geometryId```` is given.
|
|
622
|
+
* @param {number[]} [cfg.colors] Flat array of RGB vertex colors as float values in range ````[0..1]````. Ignored when ````geometryId```` is given, overriden by ````color```` and ````colorsCompressed````.
|
|
623
|
+
* @param {number[]} [cfg.colorsCompressed] Flat array of RGB vertex colors as unsigned short integers in range ````[0..255]````. Ignored when ````geometryId```` is given, overrides ````colors```` and is overriden by ````color````.
|
|
624
|
+
* @param {number[]} [cfg.normals] Flat array of normal vectors. Only used with 'triangles' primitives. When no normals are given, the mesh will be flat shaded using auto-generated face-aligned normals.
|
|
625
|
+
* @param {number[]} [cfg.positionsDecodeMatrix] A 4x4 matrix for decompressing ````positions````.
|
|
626
|
+
* @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.
|
|
627
|
+
* @param {number[]} [cfg.indices] Array of triangle indices. Ignored when ````geometryId```` is given.
|
|
628
|
+
* @param {number[]} [cfg.edgeIndices] Array of edge line indices. If ````geometryId```` is not given, edge line indices are
|
|
629
|
+
* automatically generated internally if not given, using the ````edgeThreshold```` given to the ````SceneModel````
|
|
630
|
+
* constructor. This parameter is ignored when ````geometryId```` is given.
|
|
631
|
+
* @param {number[]} [cfg.position=[0,0,0]] Local 3D position. of the mesh
|
|
632
|
+
* @param {number[]} [cfg.scale=[1,1,1]] Scale of the mesh.
|
|
633
|
+
* @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.
|
|
634
|
+
* @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.
|
|
635
|
+
* @param {number[]} [cfg.color=[1,1,1]] RGB color in range ````[0..1, 0..`, 0..1]````. Overrides ````colors```` and ````colorsCompressed````.
|
|
636
|
+
* @param {number} [cfg.opacity=1] Opacity in range ````[0..1]````.
|
|
637
|
+
*/
|
|
638
|
+
createMesh(cfg: {
|
|
639
|
+
id: string;
|
|
640
|
+
geometryId?: string | number;
|
|
641
|
+
transformId?: string | number;
|
|
642
|
+
textureSetId?: string | number;
|
|
643
|
+
primitive: "lines" | "triangles" | "points";
|
|
644
|
+
positions: number[];
|
|
645
|
+
normals: number[];
|
|
646
|
+
colors: number[];
|
|
647
|
+
colorsCompressed: number[];
|
|
648
|
+
indices: number[];
|
|
649
|
+
edgeIndices: number[];
|
|
650
|
+
positionsDecodeMatrix: number[];
|
|
651
|
+
origin?: number[];
|
|
652
|
+
position?: number[];
|
|
653
|
+
scale?: number[];
|
|
654
|
+
rotation?: number[];
|
|
655
|
+
matrix?: number[];
|
|
656
|
+
color?: number[];
|
|
657
|
+
opacity?: number;
|
|
658
|
+
}): SceneModelMesh;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Creates an {@link SceneModelEntity} within this SceneModel, giving it one or more meshes previously created with {@link SceneModel.createMesh}.
|
|
662
|
+
*
|
|
663
|
+
* 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.
|
|
664
|
+
*
|
|
665
|
+
* @param {Object} cfg SceneModelEntity configuration.
|
|
666
|
+
* @param {string} cfg.id Optional ID for the new SceneModelEntity. Must not clash with any existing components within the {@link Scene}.
|
|
667
|
+
* @param {string[]} cfg.meshIds IDs of one or more meshes created previously with {@link SceneModel@createMesh}.
|
|
668
|
+
|
|
669
|
+
* @param {Boolean} [cfg.isObject] Set ````true```` if the {@link SceneModelEntity} represents an object, in which case it will be registered by {@link SceneModelEntity.id} in {@link Scene.objects} and can also have a corresponding {@link MetaObject} with matching {@link MetaObject.id}, registered by that ID in {@link MetaScene.metaObjects}.
|
|
670
|
+
* @param {Boolean} [cfg.visible=true] Indicates if the SceneModelEntity is initially visible.
|
|
671
|
+
* @param {Boolean} [cfg.culled=false] Indicates if the SceneModelEntity is initially culled from view.
|
|
672
|
+
* @param {Boolean} [cfg.pickable=true] Indicates if the SceneModelEntity is initially pickable.
|
|
673
|
+
* @param {Boolean} [cfg.clippable=true] Indicates if the SceneModelEntity is initially clippable.
|
|
674
|
+
* @param {Boolean} [cfg.collidable=true] Indicates if the SceneModelEntity is initially included in boundary calculations.
|
|
675
|
+
* @param {Boolean} [cfg.castsShadow=true] Indicates if the SceneModelEntity initially casts shadows.
|
|
676
|
+
* @param {Boolean} [cfg.receivesShadow=true] Indicates if the SceneModelEntity initially receives shadows.
|
|
677
|
+
* @param {Boolean} [cfg.xrayed=false] Indicates if the SceneModelEntity is initially xrayed. XRayed appearance is configured by {@link SceneModel.xrayMaterial}.
|
|
678
|
+
* @param {Boolean} [cfg.highlighted=false] Indicates if the SceneModelEntity is initially highlighted. Highlighted appearance is configured by {@link SceneModel.highlightMaterial}.
|
|
679
|
+
* @param {Boolean} [cfg.selected=false] Indicates if the SceneModelEntity is initially selected. Selected appearance is configured by {@link SceneModel.selectedMaterial}.
|
|
680
|
+
* @param {Boolean} [cfg.edges=false] Indicates if the SceneModelEntity's edges are initially emphasized. Edges appearance is configured by {@link SceneModel.edgeMaterial}.
|
|
681
|
+
* @returns {SceneModelEntity}
|
|
682
|
+
*/
|
|
683
|
+
createEntity(cfg: {
|
|
684
|
+
id: string;
|
|
685
|
+
meshIds: string[]
|
|
686
|
+
isObject: boolean;
|
|
687
|
+
visible?: boolean;
|
|
688
|
+
culled?: boolean;
|
|
689
|
+
pickable?: boolean;
|
|
690
|
+
clippable?: boolean;
|
|
691
|
+
collidable?: boolean;
|
|
692
|
+
castsShadow?: boolean;
|
|
693
|
+
receivesShadow?: boolean;
|
|
694
|
+
xrayed?: boolean;
|
|
695
|
+
highlighted?: boolean;
|
|
696
|
+
selected?: boolean;
|
|
697
|
+
edges?: boolean;
|
|
698
|
+
}): SceneModelEntity;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Finalizes this SceneModel.
|
|
702
|
+
*
|
|
703
|
+
* Immediately creates the SceneModel's {@link SceneModelEntity}s within the {@link Scene}.
|
|
704
|
+
*
|
|
705
|
+
* Once finalized, you can't add anything more to this SceneModel.
|
|
706
|
+
*/
|
|
707
|
+
finalize(): void;
|
|
708
|
+
}
|