-
Notifications
You must be signed in to change notification settings - Fork 54
/
xeokit-convert.cjs.js
13482 lines (12890 loc) · 511 KB
/
xeokit-convert.cjs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["convert2xkt"] = factory();
else
root["convert2xkt"] = factory();
})(global, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/XKTModel/KDNode.js":
/*!********************************!*\
!*** ./src/XKTModel/KDNode.js ***!
\********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ KDNode: () => (/* binding */ KDNode)
/* harmony export */ });
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* A kd-Tree node, used internally by {@link XKTModel}.
*
* @private
*/
var KDNode = /*#__PURE__*/_createClass(
/**
* Create a KDNode with an axis-aligned 3D World-space boundary.
*/
function KDNode(aabb) {
_classCallCheck(this, KDNode);
/**
* The axis-aligned 3D World-space boundary of this KDNode.
*
* @type {Float64Array}
*/
this.aabb = aabb;
/**
* The {@link XKTEntity}s within this KDNode.
*/
this.entities = null;
/**
* The left child KDNode.
*/
this.left = null;
/**
* The right child KDNode.
*/
this.right = null;
});
/***/ }),
/***/ "./src/XKTModel/XKTEntity.js":
/*!***********************************!*\
!*** ./src/XKTModel/XKTEntity.js ***!
\***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ XKTEntity: () => (/* binding */ XKTEntity)
/* harmony export */ });
/* harmony import */ var _lib_math_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/math.js */ "./src/lib/math.js");
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* An object within an {@link XKTModel}.
*
* * Created by {@link XKTModel#createEntity}
* * Stored in {@link XKTModel#entities} and {@link XKTModel#entitiesList}
* * Has one or more {@link XKTMesh}s, each having an {@link XKTGeometry}
*
* @class XKTEntity
*/
var XKTEntity = /*#__PURE__*/_createClass(
/**
* @private
* @param entityId
* @param meshes
*/
function XKTEntity(entityId, meshes) {
_classCallCheck(this, XKTEntity);
/**
* Unique ID of this ````XKTEntity```` in {@link XKTModel#entities}.
*
* For a BIM model, this will be an IFC product ID.
*
* We can also use {@link XKTModel#createMetaObject} to create an {@link XKTMetaObject} to specify metadata for
* this ````XKTEntity````. To associate the {@link XKTMetaObject} with our {@link XKTEntity}, we give
* {@link XKTMetaObject#metaObjectId} the same value as {@link XKTEntity#entityId}.
*
* @type {String}
*/
this.entityId = entityId;
/**
* Index of this ````XKTEntity```` in {@link XKTModel#entitiesList}.
*
* Set by {@link XKTModel#finalize}.
*
* @type {Number}
*/
this.entityIndex = null;
/**
* A list of {@link XKTMesh}s that indicate which {@link XKTGeometry}s are used by this Entity.
*
* @type {XKTMesh[]}
*/
this.meshes = meshes;
/**
* World-space axis-aligned bounding box (AABB) that encloses the {@link XKTGeometry#positions} of
* the {@link XKTGeometry}s that are used by this ````XKTEntity````.
*
* Set by {@link XKTModel#finalize}.
*
* @type {Float32Array}
*/
this.aabb = _lib_math_js__WEBPACK_IMPORTED_MODULE_0__.math.AABB3();
/**
* Indicates if this ````XKTEntity```` shares {@link XKTGeometry}s with other {@link XKTEntity}'s.
*
* Set by {@link XKTModel#finalize}.
*
* Note that when an ````XKTEntity```` shares ````XKTGeometrys````, it shares **all** of its ````XKTGeometrys````. An ````XKTEntity````
* never shares only some of its ````XKTGeometrys```` - it always shares either the whole set or none at all.
*
* @type {Boolean}
*/
this.hasReusedGeometries = false;
});
/***/ }),
/***/ "./src/XKTModel/XKTGeometry.js":
/*!*************************************!*\
!*** ./src/XKTModel/XKTGeometry.js ***!
\*************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ XKTGeometry: () => (/* binding */ XKTGeometry)
/* harmony export */ });
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**
* An element of reusable geometry within an {@link XKTModel}.
*
* * Created by {@link XKTModel#createGeometry}
* * Stored in {@link XKTModel#geometries} and {@link XKTModel#geometriesList}
* * Referenced by {@link XKTMesh}s, which belong to {@link XKTEntity}s
*
* @class XKTGeometry
*/
var XKTGeometry = /*#__PURE__*/function () {
/**
* @private
* @param {*} cfg Configuration for the XKTGeometry.
* @param {Number} cfg.geometryId Unique ID of the geometry in {@link XKTModel#geometries}.
* @param {String} cfg.primitiveType Type of this geometry - "triangles", "points" or "lines" so far.
* @param {Number} cfg.geometryIndex Index of this XKTGeometry in {@link XKTModel#geometriesList}.
* @param {Float64Array} cfg.positions Non-quantized 3D vertex positions.
* @param {Float32Array} cfg.normals Non-compressed vertex normals.
* @param {Uint8Array} cfg.colorsCompressed Unsigned 8-bit integer RGBA vertex colors.
* @param {Float32Array} cfg.uvs Non-compressed vertex UV coordinates.
* @param {Uint32Array} cfg.indices Indices to organize the vertex positions and normals into triangles.
* @param {Uint32Array} cfg.edgeIndices Indices to organize the vertex positions into edges.
*/
function XKTGeometry(cfg) {
_classCallCheck(this, XKTGeometry);
/**
* Unique ID of this XKTGeometry in {@link XKTModel#geometries}.
*
* @type {Number}
*/
this.geometryId = cfg.geometryId;
/**
* The type of primitive - "triangles" | "points" | "lines".
*
* @type {String}
*/
this.primitiveType = cfg.primitiveType;
/**
* Index of this XKTGeometry in {@link XKTModel#geometriesList}.
*
* @type {Number}
*/
this.geometryIndex = cfg.geometryIndex;
/**
* The number of {@link XKTMesh}s that reference this XKTGeometry.
*
* @type {Number}
*/
this.numInstances = 0;
/**
* Non-quantized 3D vertex positions.
*
* Defined for all primitive types.
*
* @type {Float64Array}
*/
this.positions = cfg.positions;
/**
* Quantized vertex positions.
*
* Defined for all primitive types.
*
* This array is later created from {@link XKTGeometry#positions} by {@link XKTModel#finalize}.
*
* @type {Uint16Array}
*/
this.positionsQuantized = new Uint16Array(cfg.positions.length);
/**
* Non-compressed 3D vertex normals.
*
* Defined only for triangle primitives. Can be null if we want xeokit to auto-generate them. Ignored for points and lines.
*
* @type {Float32Array}
*/
this.normals = cfg.normals;
/**
* Compressed vertex normals.
*
* Defined only for triangle primitives. Ignored for points and lines.
*
* This array is later created from {@link XKTGeometry#normals} by {@link XKTModel#finalize}.
*
* Will be null if {@link XKTGeometry#normals} is also null.
*
* @type {Int8Array}
*/
this.normalsOctEncoded = null;
/**
* Compressed RGBA vertex colors.
*
* Defined only for point primitives. Ignored for triangles and lines.
*
* @type {Uint8Array}
*/
this.colorsCompressed = cfg.colorsCompressed;
/**
* Non-compressed vertex UVs.
*
* @type {Float32Array}
*/
this.uvs = cfg.uvs;
/**
* Compressed vertex UVs.
*
* @type {Uint16Array}
*/
this.uvsCompressed = cfg.uvsCompressed;
/**
* Indices that organize the vertex positions and normals as triangles.
*
* Defined only for triangle and lines primitives. Ignored for points.
*
* @type {Uint32Array}
*/
this.indices = cfg.indices;
/**
* Indices that organize the vertex positions as edges.
*
* Defined only for triangle primitives. Ignored for points and lines.
*
* @type {Uint32Array}
*/
this.edgeIndices = cfg.edgeIndices;
/**
* When {@link XKTGeometry#primitiveType} is "triangles", this is ````true```` when this geometry is a watertight mesh.
*
* Defined only for triangle primitives. Ignored for points and lines.
*
* Set by {@link XKTModel#finalize}.
*
* @type {boolean}
*/
this.solid = false;
}
/**
* Convenience property that is ````true```` when {@link XKTGeometry#numInstances} is greater that one.
* @returns {boolean}
*/
_createClass(XKTGeometry, [{
key: "reused",
get: function get() {
return this.numInstances > 1;
}
}]);
return XKTGeometry;
}();
/***/ }),
/***/ "./src/XKTModel/XKTMesh.js":
/*!*********************************!*\
!*** ./src/XKTModel/XKTMesh.js ***!
\*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ XKTMesh: () => (/* binding */ XKTMesh)
/* harmony export */ });
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Represents the usage of a {@link XKTGeometry} by an {@link XKTEntity}.
*
* * Created by {@link XKTModel#createEntity}
* * Stored in {@link XKTEntity#meshes} and {@link XKTModel#meshesList}
* * Has an {@link XKTGeometry}, and an optional {@link XKTTextureSet}, both of which it can share with other {@link XKTMesh}es
* * Has {@link XKTMesh#color}, {@link XKTMesh#opacity}, {@link XKTMesh#metallic} and {@link XKTMesh#roughness} PBR attributes
* @class XKTMesh
*/
var XKTMesh = /*#__PURE__*/_createClass(
/**
* @private
*/
function XKTMesh(cfg) {
_classCallCheck(this, XKTMesh);
/**
* Unique ID of this XKTMesh in {@link XKTModel#meshes}.
*
* @type {Number}
*/
this.meshId = cfg.meshId;
/**
* Index of this XKTMesh in {@link XKTModel#meshesList};
*
* @type {Number}
*/
this.meshIndex = cfg.meshIndex;
/**
* The 4x4 modeling transform matrix.
*
* Transform is relative to the center of the {@link XKTTile} that contains this XKTMesh's {@link XKTEntity},
* which is given in {@link XKTMesh#entity}.
*
* When the ````XKTEntity```` shares its {@link XKTGeometry}s with other ````XKTEntity````s, this matrix is used
* to transform this XKTMesh's XKTGeometry into World-space. When this XKTMesh does not share its ````XKTGeometry````,
* then this matrix is ignored.
*
* @type {Number[]}
*/
this.matrix = cfg.matrix;
/**
* The instanced {@link XKTGeometry}.
*
* @type {XKTGeometry}
*/
this.geometry = cfg.geometry;
/**
* RGB color of this XKTMesh.
*
* @type {Float32Array}
*/
this.color = cfg.color || new Float32Array([1, 1, 1]);
/**
* PBR metallness of this XKTMesh.
*
* @type {Number}
*/
this.metallic = cfg.metallic !== null && cfg.metallic !== undefined ? cfg.metallic : 0;
/**
* PBR roughness of this XKTMesh.
* The {@link XKTTextureSet} that defines the appearance of this XKTMesh.
*
* @type {Number}
* @type {XKTTextureSet}
*/
this.roughness = cfg.roughness !== null && cfg.roughness !== undefined ? cfg.roughness : 1;
/**
* Opacity of this XKTMesh.
*
* @type {Number}
*/
this.opacity = cfg.opacity !== undefined && cfg.opacity !== null ? cfg.opacity : 1.0;
/**
* The {@link XKTTextureSet} that defines the appearance of this XKTMesh.
*
* @type {XKTTextureSet}
*/
this.textureSet = cfg.textureSet;
/**
* The owner {@link XKTEntity}.
*
* Set by {@link XKTModel#createEntity}.
*
* @type {XKTEntity}
*/
this.entity = null; // Set after instantiation, when the Entity is known
});
/***/ }),
/***/ "./src/XKTModel/XKTMetaObject.js":
/*!***************************************!*\
!*** ./src/XKTModel/XKTMetaObject.js ***!
\***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ XKTMetaObject: () => (/* binding */ XKTMetaObject)
/* harmony export */ });
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* A meta object within an {@link XKTModel}.
*
* These are plugged together into a parent-child hierarchy to represent structural
* metadata for the {@link XKTModel}.
*
* The leaf XKTMetaObjects are usually associated with
* an {@link XKTEntity}, which they do so by sharing the same ID,
* ie. where {@link XKTMetaObject#metaObjectId} == {@link XKTEntity#entityId}.
*
* * Created by {@link XKTModel#createMetaObject}
* * Stored in {@link XKTModel#metaObjects} and {@link XKTModel#metaObjectsList}
* * Has an ID, a type, and a human-readable name
* * May have a parent {@link XKTMetaObject}
* * When no children, is usually associated with an {@link XKTEntity}
*
* @class XKTMetaObject
*/
var XKTMetaObject = /*#__PURE__*/_createClass(
/**
* @private
* @param metaObjectId
* @param propertySetIds
* @param metaObjectType
* @param metaObjectName
* @param parentMetaObjectId
*/
function XKTMetaObject(metaObjectId, propertySetIds, metaObjectType, metaObjectName, parentMetaObjectId) {
_classCallCheck(this, XKTMetaObject);
/**
* Unique ID of this ````XKTMetaObject```` in {@link XKTModel#metaObjects}.
*
* For a BIM model, this will be an IFC product ID.
*
* If this is a leaf XKTMetaObject, where it is not a parent to any other XKTMetaObject,
* then this will be equal to the ID of an {@link XKTEntity} in {@link XKTModel#entities},
* ie. where {@link XKTMetaObject#metaObjectId} == {@link XKTEntity#entityId}.
*
* @type {String}
*/
this.metaObjectId = metaObjectId;
/**
* Unique ID of one or more property sets that contains additional metadata about this
* {@link XKTMetaObject}. The property sets can be stored in an external system, or
* within the {@link XKTModel}, as {@link XKTPropertySet}s within {@link XKTModel#propertySets}.
*
* @type {String[]}
*/
this.propertySetIds = propertySetIds;
/**
* Indicates the XKTMetaObject meta object type.
*
* This defaults to "default".
*
* @type {string}
*/
this.metaObjectType = metaObjectType;
/**
* Indicates the XKTMetaObject meta object name.
*
* This defaults to {@link XKTMetaObject#metaObjectId}.
*
* @type {string}
*/
this.metaObjectName = metaObjectName;
/**
* The parent XKTMetaObject, if any.
*
* Will be null if there is no parent.
*
* @type {String}
*/
this.parentMetaObjectId = parentMetaObjectId;
});
/***/ }),
/***/ "./src/XKTModel/XKTModel.js":
/*!**********************************!*\
!*** ./src/XKTModel/XKTModel.js ***!
\**********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ XKTModel: () => (/* binding */ XKTModel)
/* harmony export */ });
/* harmony import */ var _lib_math_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/math.js */ "./src/lib/math.js");
/* harmony import */ var _lib_geometryCompression_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/geometryCompression.js */ "./src/XKTModel/lib/geometryCompression.js");
/* harmony import */ var _lib_buildEdgeIndices_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/buildEdgeIndices.js */ "./src/XKTModel/lib/buildEdgeIndices.js");
/* harmony import */ var _lib_isTriangleMeshSolid_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lib/isTriangleMeshSolid.js */ "./src/XKTModel/lib/isTriangleMeshSolid.js");
/* harmony import */ var _XKTMesh_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./XKTMesh.js */ "./src/XKTModel/XKTMesh.js");
/* harmony import */ var _XKTGeometry_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./XKTGeometry.js */ "./src/XKTModel/XKTGeometry.js");
/* harmony import */ var _XKTEntity_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./XKTEntity.js */ "./src/XKTModel/XKTEntity.js");
/* harmony import */ var _XKTTile_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./XKTTile.js */ "./src/XKTModel/XKTTile.js");
/* harmony import */ var _KDNode_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KDNode.js */ "./src/XKTModel/KDNode.js");
/* harmony import */ var _XKTMetaObject_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./XKTMetaObject.js */ "./src/XKTModel/XKTMetaObject.js");
/* harmony import */ var _XKTPropertySet_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./XKTPropertySet.js */ "./src/XKTModel/XKTPropertySet.js");
/* harmony import */ var _lib_mergeVertices_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../lib/mergeVertices.js */ "./src/lib/mergeVertices.js");
/* harmony import */ var _XKT_INFO_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../XKT_INFO.js */ "./src/XKT_INFO.js");
/* harmony import */ var _XKTTexture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./XKTTexture */ "./src/XKTModel/XKTTexture.js");
/* harmony import */ var _XKTTextureSet__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./XKTTextureSet */ "./src/XKTModel/XKTTextureSet.js");
/* harmony import */ var _loaders_gl_core__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @loaders.gl/core */ "@loaders.gl/core");
/* harmony import */ var _loaders_gl_core__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_loaders_gl_core__WEBPACK_IMPORTED_MODULE_15__);
/* harmony import */ var _loaders_gl_textures__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @loaders.gl/textures */ "@loaders.gl/textures");
/* harmony import */ var _loaders_gl_textures__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_loaders_gl_textures__WEBPACK_IMPORTED_MODULE_16__);
/* harmony import */ var _loaders_gl_images__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @loaders.gl/images */ "@loaders.gl/images");
/* harmony import */ var _loaders_gl_images__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_loaders_gl_images__WEBPACK_IMPORTED_MODULE_17__);
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var tempVec4a = _lib_math_js__WEBPACK_IMPORTED_MODULE_0__.math.vec4([0, 0, 0, 1]);
var tempVec4b = _lib_math_js__WEBPACK_IMPORTED_MODULE_0__.math.vec4([0, 0, 0, 1]);
var tempMat4 = _lib_math_js__WEBPACK_IMPORTED_MODULE_0__.math.mat4();
var tempMat4b = _lib_math_js__WEBPACK_IMPORTED_MODULE_0__.math.mat4();
var kdTreeDimLength = new Float64Array(3);
// XKT texture types
var COLOR_TEXTURE = 0;
var METALLIC_ROUGHNESS_TEXTURE = 1;
var NORMALS_TEXTURE = 2;
var EMISSIVE_TEXTURE = 3;
var OCCLUSION_TEXTURE = 4;
// KTX2 encoding options for each texture type
var TEXTURE_ENCODING_OPTIONS = {};
TEXTURE_ENCODING_OPTIONS[COLOR_TEXTURE] = {
useSRGB: true,
qualityLevel: 50,
encodeUASTC: true,
mipmaps: true
};
TEXTURE_ENCODING_OPTIONS[EMISSIVE_TEXTURE] = {
useSRGB: true,
encodeUASTC: true,
qualityLevel: 10,
mipmaps: false
};
TEXTURE_ENCODING_OPTIONS[METALLIC_ROUGHNESS_TEXTURE] = {
useSRGB: false,
encodeUASTC: true,
qualityLevel: 50,
mipmaps: true // Needed for GGX roughness shading
};
TEXTURE_ENCODING_OPTIONS[NORMALS_TEXTURE] = {
useSRGB: false,
encodeUASTC: true,
qualityLevel: 10,
mipmaps: false
};
TEXTURE_ENCODING_OPTIONS[OCCLUSION_TEXTURE] = {
useSRGB: false,
encodeUASTC: true,
qualityLevel: 10,
mipmaps: false
};
/**
* A document model that represents the contents of an .XKT file.
*
* * An XKTModel contains {@link XKTTile}s, which spatially subdivide the model into axis-aligned, box-shaped regions.
* * Each {@link XKTTile} contains {@link XKTEntity}s, which represent the objects within its region.
* * Each {@link XKTEntity} has {@link XKTMesh}s, which each have a {@link XKTGeometry}. Each {@link XKTGeometry} can be shared by multiple {@link XKTMesh}s.
* * Import models into an XKTModel using {@link parseGLTFJSONIntoXKTModel}, {@link parseIFCIntoXKTModel}, {@link parseCityJSONIntoXKTModel} etc.
* * Build an XKTModel programmatically using {@link XKTModel#createGeometry}, {@link XKTModel#createMesh} and {@link XKTModel#createEntity}.
* * Serialize an XKTModel to an ArrayBuffer using {@link writeXKTModelToArrayBuffer}.
*
* ## Usage
*
* See [main docs page](/docs/#javascript-api) for usage examples.
*
* @class XKTModel
*/
var XKTModel = /*#__PURE__*/function () {
/**
* Constructs a new XKTModel.
*
* @param {*} [cfg] Configuration
* @param {Number} [cfg.edgeThreshold=10]
* @param {Number} [cfg.minTileSize=500]
*/
function XKTModel() {
var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, XKTModel);
/**
* The model's ID, if available.
*
* Will be "default" by default.
*
* @type {String}
*/
this.modelId = cfg.modelId || "default";
/**
* The project ID, if available.
*
* Will be an empty string by default.
*
* @type {String}
*/
this.projectId = cfg.projectId || "";
/**
* The revision ID, if available.
*
* Will be an empty string by default.
*
* @type {String}
*/
this.revisionId = cfg.revisionId || "";
/**
* The model author, if available.
*
* Will be an empty string by default.
*
* @property author
* @type {String}
*/
this.author = cfg.author || "";
/**
* The date the model was created, if available.
*
* Will be an empty string by default.
*
* @property createdAt
* @type {String}
*/
this.createdAt = cfg.createdAt || "";
/**
* The application that created the model, if available.
*
* Will be an empty string by default.
*
* @property creatingApplication
* @type {String}
*/
this.creatingApplication = cfg.creatingApplication || "";
/**
* The model schema version, if available.
*
* In the case of IFC, this could be "IFC2x3" or "IFC4", for example.
*
* Will be an empty string by default.
*
* @property schema
* @type {String}
*/
this.schema = cfg.schema || "";
/**
* The XKT format version.
*
* @property xktVersion;
* @type {number}
*/
this.xktVersion = _XKT_INFO_js__WEBPACK_IMPORTED_MODULE_12__.XKT_INFO.xktVersion;
/**
*
* @type {Number|number}
*/
this.edgeThreshold = cfg.edgeThreshold || 10;
/**
* Minimum diagonal size of the boundary of an {@link XKTTile}.
*
* @type {Number|number}
*/
this.minTileSize = cfg.minTileSize || 500;
/**
* Optional overall AABB that contains all the {@link XKTEntity}s we'll create in this model, if previously known.
*
* This is the AABB of a complete set of input files that are provided as a split-model set for conversion.
*
* This is used to help the {@link XKTTile.aabb}s within split models align neatly with each other, as we
* build them with a k-d tree in {@link XKTModel#finalize}. Without this, the AABBs of the different parts
* tend to misalign slightly, resulting in excess number of {@link XKTTile}s, which degrades memory and rendering
* performance when the XKT is viewer in the xeokit Viewer.
*/
this.modelAABB = cfg.modelAABB;
/**
* Map of {@link XKTPropertySet}s within this XKTModel, each mapped to {@link XKTPropertySet#propertySetId}.
*
* Created by {@link XKTModel#createPropertySet}.
*
* @type {{String:XKTPropertySet}}
*/
this.propertySets = {};
/**
* {@link XKTPropertySet}s within this XKTModel.
*
* Each XKTPropertySet holds its position in this list in {@link XKTPropertySet#propertySetIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTPropertySet[]}
*/
this.propertySetsList = [];
/**
* Map of {@link XKTMetaObject}s within this XKTModel, each mapped to {@link XKTMetaObject#metaObjectId}.
*
* Created by {@link XKTModel#createMetaObject}.
*
* @type {{String:XKTMetaObject}}
*/
this.metaObjects = {};
/**
* {@link XKTMetaObject}s within this XKTModel.
*
* Each XKTMetaObject holds its position in this list in {@link XKTMetaObject#metaObjectIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTMetaObject[]}
*/
this.metaObjectsList = [];
/**
* The positions of all shared {@link XKTGeometry}s are de-quantized using this singular
* de-quantization matrix.
*
* This de-quantization matrix is generated from the collective Local-space boundary of the
* positions of all shared {@link XKTGeometry}s.
*
* @type {Float32Array}
*/
this.reusedGeometriesDecodeMatrix = new Float32Array(16);
/**
* Map of {@link XKTGeometry}s within this XKTModel, each mapped to {@link XKTGeometry#geometryId}.
*
* Created by {@link XKTModel#createGeometry}.
*
* @type {{Number:XKTGeometry}}
*/
this.geometries = {};
/**
* List of {@link XKTGeometry}s within this XKTModel, in the order they were created.
*
* Each XKTGeometry holds its position in this list in {@link XKTGeometry#geometryIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTGeometry[]}
*/
this.geometriesList = [];
/**
* Map of {@link XKTTexture}s within this XKTModel, each mapped to {@link XKTTexture#textureId}.
*
* Created by {@link XKTModel#createTexture}.
*
* @type {{Number:XKTTexture}}
*/
this.textures = {};
/**
* List of {@link XKTTexture}s within this XKTModel, in the order they were created.
*
* Each XKTTexture holds its position in this list in {@link XKTTexture#textureIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTTexture[]}
*/
this.texturesList = [];
/**
* Map of {@link XKTTextureSet}s within this XKTModel, each mapped to {@link XKTTextureSet#textureSetId}.
*
* Created by {@link XKTModel#createTextureSet}.
*
* @type {{Number:XKTTextureSet}}
*/
this.textureSets = {};
/**
* List of {@link XKTTextureSet}s within this XKTModel, in the order they were created.
*
* Each XKTTextureSet holds its position in this list in {@link XKTTextureSet#textureSetIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTTextureSet[]}
*/
this.textureSetsList = [];
/**
* Map of {@link XKTMesh}s within this XKTModel, each mapped to {@link XKTMesh#meshId}.
*
* Created by {@link XKTModel#createMesh}.
*
* @type {{Number:XKTMesh}}
*/
this.meshes = {};
/**
* List of {@link XKTMesh}s within this XKTModel, in the order they were created.
*
* Each XKTMesh holds its position in this list in {@link XKTMesh#meshIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTMesh[]}
*/
this.meshesList = [];
/**
* Map of {@link XKTEntity}s within this XKTModel, each mapped to {@link XKTEntity#entityId}.
*
* Created by {@link XKTModel#createEntity}.
*
* @type {{String:XKTEntity}}
*/
this.entities = {};
/**
* {@link XKTEntity}s within this XKTModel.
*
* Each XKTEntity holds its position in this list in {@link XKTEntity#entityIndex}.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTEntity[]}
*/
this.entitiesList = [];
/**
* {@link XKTTile}s within this XKTModel.
*
* Created by {@link XKTModel#finalize}.
*
* @type {XKTTile[]}
*/
this.tilesList = [];
/**
* The axis-aligned 3D World-space boundary of this XKTModel.
*
* Created by {@link XKTModel#finalize}.
*
* @type {Float64Array}
*/
this.aabb = _lib_math_js__WEBPACK_IMPORTED_MODULE_0__.math.AABB3();
/**
* Indicates if this XKTModel has been finalized.
*
* Set ````true```` by {@link XKTModel#finalize}.
*
* @type {boolean}
*/
this.finalized = false;
}
/**
* Creates an {@link XKTPropertySet} within this XKTModel.
*
* Logs error and does nothing if this XKTModel has been finalized (see {@link XKTModel#finalized}).
*
* @param {*} params Method parameters.
* @param {String} params.propertySetId Unique ID for the {@link XKTPropertySet}.
* @param {String} [params.propertySetType="default"] A meta type for the {@link XKTPropertySet}.
* @param {String} [params.propertySetName] Human-readable name for the {@link XKTPropertySet}. Defaults to the ````propertySetId```` parameter.
* @param {String[]} params.properties Properties for the {@link XKTPropertySet}.
* @returns {XKTPropertySet} The new {@link XKTPropertySet}.
*/
_createClass(XKTModel, [{
key: "createPropertySet",
value: function createPropertySet(params) {
if (!params) {
throw "[XKTModel.createPropertySet] Parameters expected: params";
}
if (params.propertySetId === null || params.propertySetId === undefined) {
throw "[XKTModel.createPropertySet] Parameter expected: params.propertySetId";
}
if (params.properties === null || params.properties === undefined) {
throw "[XKTModel.createPropertySet] Parameter expected: params.properties";
}
if (this.finalized) {
console.error("XKTModel has been finalized, can't add more property sets");
return;
}
if (this.propertySets[params.propertySetId]) {
// console.error("XKTPropertySet already exists with this ID: " + params.propertySetId);
return;
}