@xeokit/xeokit-sdk 2.4.0-alpha-38 → 2.4.0-alpha-40

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.
@@ -33262,6 +33262,12 @@ class DataTextureSceneModel extends Component {
33262
33262
 
33263
33263
  this._edgeThreshold = cfg.edgeThreshold || 10;
33264
33264
 
33265
+ /**
33266
+ * True when this model has been finalized after a successful call to finalize().
33267
+ * @type {boolean}
33268
+ */
33269
+ this.finalized = false;
33270
+
33265
33271
  this.visible = cfg.visible;
33266
33272
  this.culled = cfg.culled;
33267
33273
  this.pickable = cfg.pickable;
@@ -34568,6 +34574,8 @@ class DataTextureSceneModel extends Component {
34568
34574
  const layer = this._layerList[i];
34569
34575
  layer.attachToRenderingEvent();
34570
34576
  }
34577
+
34578
+ this.finalized = true;
34571
34579
  }
34572
34580
 
34573
34581
  _rebuildAABB() {
@@ -52496,11 +52504,8 @@ const pickTriangleSurface = (function () {
52496
52504
 
52497
52505
  // Attempt to ray-pick the triangle in local space
52498
52506
 
52499
- let canvasPos;
52500
-
52501
52507
  if (pickResult.canvasPos) {
52502
- canvasPos = pickResult.canvasPos;
52503
- math.canvasPosToLocalRay(canvas.canvas, pickViewMatrix, pickProjMatrix, mesh.worldMatrix, canvasPos, localRayOrigin, localRayDir);
52508
+ math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
52504
52509
 
52505
52510
  } else if (pickResult.origin && pickResult.direction) {
52506
52511
  math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
@@ -52531,6 +52536,12 @@ const pickTriangleSurface = (function () {
52531
52536
  worldPos[1] = tempVec4b[1];
52532
52537
  worldPos[2] = tempVec4b[2];
52533
52538
 
52539
+ if (pickResult.canvasPos && mesh.origin) {
52540
+ worldPos[0] += mesh.origin[0];
52541
+ worldPos[1] += mesh.origin[1];
52542
+ worldPos[2] += mesh.origin[2];
52543
+ }
52544
+
52534
52545
  pickResult.worldPos = worldPos;
52535
52546
 
52536
52547
  // Get View-space cartesian coordinates of the ray-triangle intersection
@@ -62529,7 +62540,7 @@ class Bitmap extends Component {
62529
62540
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#LineSet_grid)]
62530
62541
  *
62531
62542
  * ````javascript
62532
- * import {Viewer, XKTLoaderPlugin, LineSet, buildGridGeometry} from "../dist/xeokit-sdk.es.js";
62543
+ * import {Viewer, XKTLoaderPlugin, LineSet, buildGridGeometry} from "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.es.min.js";
62533
62544
  *
62534
62545
  * const viewer = new Viewer({
62535
62546
  * canvasId: "myCanvas",
@@ -67686,7 +67697,7 @@ class LightMap extends CubeTexture {
67686
67697
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#markers_SpriteMarker)]
67687
67698
  *
67688
67699
  * ```` javascript
67689
- * import {Viewer, SpriteMarker } from "./../dist/xeokit-sdk.es.js";
67700
+ * import {Viewer, SpriteMarker } from "./https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.es.min.js";
67690
67701
  *
67691
67702
  * const viewer = new Viewer({
67692
67703
  * canvasId: "myCanvas",
@@ -96337,6 +96348,12 @@ class VBOSceneModel extends Component {
96337
96348
  /** @private **/
96338
96349
  this.renderFlags = new RenderFlags();
96339
96350
 
96351
+ /**
96352
+ * True when this model has been finalized after a successful call to finalize().
96353
+ * @type {boolean}
96354
+ */
96355
+ this.finalized = false;
96356
+
96340
96357
  /**
96341
96358
  * @private
96342
96359
  */
@@ -98154,6 +98171,8 @@ ${cfg.uv && cfg.uv.length > 0 ? 1 : 0}-${cfg.uvCompressed && cfg.uvCompressed.le
98154
98171
  this.glRedraw();
98155
98172
 
98156
98173
  this.scene._aabbDirty = true;
98174
+
98175
+ this.finalized = true;
98157
98176
  }
98158
98177
 
98159
98178
  _rebuildAABB() {
@@ -99332,13 +99351,17 @@ const getCanvasPosFromEvent$4 = function (event, canvasPos) {
99332
99351
  let element = event.target;
99333
99352
  let totalOffsetLeft = 0;
99334
99353
  let totalOffsetTop = 0;
99354
+ let totalScrollX = 0;
99355
+ let totalScrollY = 0;
99335
99356
  while (element.offsetParent) {
99336
- totalOffsetLeft += element.offsetLeft;
99337
- totalOffsetTop += element.offsetTop;
99338
- element = element.offsetParent;
99357
+ totalOffsetLeft += element.offsetLeft;
99358
+ totalOffsetTop += element.offsetTop;
99359
+ totalScrollX += element.scrollLeft;
99360
+ totalScrollY += element.scrollTop;
99361
+ element = element.offsetParent;
99339
99362
  }
99340
- canvasPos[0] = event.pageX - totalOffsetLeft;
99341
- canvasPos[1] = event.pageY - totalOffsetTop;
99363
+ canvasPos[0] = event.pageX + totalScrollX - totalOffsetLeft;
99364
+ canvasPos[1] = event.pageY + totalScrollY - totalOffsetTop;
99342
99365
  }
99343
99366
  return canvasPos;
99344
99367
  };
@@ -102819,7 +102842,7 @@ class MetaModel {
102819
102842
  /**
102820
102843
  * @private
102821
102844
  */
102822
- constructor(metaScene, id, projectId, revisionId, author, createdAt, creatingApplication, schema, propertySets) {
102845
+ constructor(params) {
102823
102846
 
102824
102847
  /**
102825
102848
  * Globally-unique ID.
@@ -102831,14 +102854,14 @@ class MetaModel {
102831
102854
  * @property id
102832
102855
  * @type {String|Number}
102833
102856
  */
102834
- this.id = id;
102857
+ this.id = params.id;
102835
102858
 
102836
102859
  /**
102837
102860
  * The project ID
102838
102861
  * @property projectId
102839
102862
  * @type {String|Number}
102840
102863
  */
102841
- this.projectId = projectId;
102864
+ this.projectId = params.projectId;
102842
102865
 
102843
102866
  /**
102844
102867
  * The revision ID, if available.
@@ -102848,7 +102871,7 @@ class MetaModel {
102848
102871
  * @property revisionId
102849
102872
  * @type {String|Number}
102850
102873
  */
102851
- this.revisionId = revisionId;
102874
+ this.revisionId = params.revisionId;
102852
102875
 
102853
102876
  /**
102854
102877
  * The model author, if available.
@@ -102858,7 +102881,7 @@ class MetaModel {
102858
102881
  * @property author
102859
102882
  * @type {String}
102860
102883
  */
102861
- this.author = author;
102884
+ this.author = params.author;
102862
102885
 
102863
102886
  /**
102864
102887
  * The date the model was created, if available.
@@ -102868,7 +102891,7 @@ class MetaModel {
102868
102891
  * @property createdAt
102869
102892
  * @type {String}
102870
102893
  */
102871
- this.createdAt = createdAt;
102894
+ this.createdAt = params.createdAt;
102872
102895
 
102873
102896
  /**
102874
102897
  * The application that created the model, if available.
@@ -102878,7 +102901,7 @@ class MetaModel {
102878
102901
  * @property creatingApplication
102879
102902
  * @type {String}
102880
102903
  */
102881
- this.creatingApplication = creatingApplication;
102904
+ this.creatingApplication = params.creatingApplication;
102882
102905
 
102883
102906
  /**
102884
102907
  * The model schema version, if available.
@@ -102888,7 +102911,7 @@ class MetaModel {
102888
102911
  * @property schema
102889
102912
  * @type {String}
102890
102913
  */
102891
- this.schema = schema;
102914
+ this.schema = params.schema;
102892
102915
 
102893
102916
  /**
102894
102917
  * Metadata on the {@link Scene}.
@@ -102896,15 +102919,15 @@ class MetaModel {
102896
102919
  * @property metaScene
102897
102920
  * @type {MetaScene}
102898
102921
  */
102899
- this.metaScene = metaScene;
102922
+ this.metaScene = params.metaScene;
102900
102923
 
102901
102924
  /**
102902
102925
  * The {@link PropertySet}s in this MetaModel.
102903
102926
  *
102904
102927
  * @property propertySets
102905
- * @type {{String:PropertySet}}
102928
+ * @type {PropertySet[]}
102906
102929
  */
102907
- this.propertySets = propertySets;
102930
+ this.propertySets = [];
102908
102931
 
102909
102932
  /**
102910
102933
  * The root {@link MetaObject} in this MetaModel's composition structure hierarchy.
@@ -102922,6 +102945,20 @@ class MetaModel {
102922
102945
  * @type {MetaObject[]}
102923
102946
  */
102924
102947
  this.rootMetaObjects = [];
102948
+
102949
+ /**
102950
+ * The {@link MetaObject}s in this MetaModel, each mapped to its ID.
102951
+ *
102952
+ * @property metaObjects
102953
+ * @type {MetaObject[]}
102954
+ */
102955
+ this.metaObjects=[];
102956
+
102957
+ /**
102958
+ * Connectivity graph.
102959
+ * @type {{}}
102960
+ */
102961
+ this.graph = params.graph || {};
102925
102962
  }
102926
102963
 
102927
102964
  getJSON() {
@@ -102980,7 +103017,7 @@ class MetaObject {
102980
103017
  /**
102981
103018
  * @private
102982
103019
  */
102983
- constructor(metaModel, id, originalSystemId, name, type, propertySets, parent, children, external) {
103020
+ constructor(params) {
102984
103021
 
102985
103022
  /**
102986
103023
  * Model metadata.
@@ -102989,13 +103026,13 @@ class MetaObject {
102989
103026
  * @type {MetaModel}
102990
103027
  * @deprecated
102991
103028
  */
102992
- this.metaModel = metaModel;
103029
+ this.metaModel = null;
102993
103030
 
102994
103031
  /**
102995
103032
  * The MetaModels that share this MetaObject.
102996
103033
  * @type {MetaModel[]}
102997
103034
  */
102998
- this.metaModels = [metaModel];
103035
+ this.metaModels = [];
102999
103036
 
103000
103037
  /**
103001
103038
  * Globally-unique ID.
@@ -103005,7 +103042,19 @@ class MetaObject {
103005
103042
  * @property id
103006
103043
  * @type {String|Number}
103007
103044
  */
103008
- this.id = id;
103045
+ this.id = params.id;
103046
+
103047
+ /**
103048
+ * ID of the parent MetaObject.
103049
+ * @type {String|Number}
103050
+ */
103051
+ this.parentId = params.parentId;
103052
+
103053
+ /**
103054
+ * The parent MetaObject.
103055
+ * @type {MetaObject | null}
103056
+ */
103057
+ this.parent = null;
103009
103058
 
103010
103059
  /**
103011
103060
  * ID of the corresponding object within the originating system, if any.
@@ -103013,7 +103062,7 @@ class MetaObject {
103013
103062
  * @type {String}
103014
103063
  * @abstract
103015
103064
  */
103016
- this.originalSystemId = originalSystemId;
103065
+ this.originalSystemId = params.originalSystemId;
103017
103066
 
103018
103067
  /**
103019
103068
  * Human-readable name.
@@ -103021,7 +103070,7 @@ class MetaObject {
103021
103070
  * @property name
103022
103071
  * @type {String}
103023
103072
  */
103024
- this.name = name;
103073
+ this.name = params.name;
103025
103074
 
103026
103075
  /**
103027
103076
  * Type - often an IFC product type.
@@ -103029,7 +103078,7 @@ class MetaObject {
103029
103078
  * @property type
103030
103079
  * @type {String}
103031
103080
  */
103032
- this.type = type;
103081
+ this.type = params.type;
103033
103082
 
103034
103083
  /**
103035
103084
  * Optional {@link PropertySet}s used by this MetaObject.
@@ -103037,46 +103086,20 @@ class MetaObject {
103037
103086
  * @property propertySets
103038
103087
  * @type {PropertySet[]}
103039
103088
  */
103040
- this.propertySets = propertySets;
103089
+ this.propertySets = [];
103041
103090
 
103042
- if (parent !== undefined && parent !== null) {
103043
-
103044
- /**
103045
- * The parent MetaObject within the structure hierarchy.
103046
- *
103047
- * Undefined when this is the root of its structure.
103048
- *
103049
- * @property parent
103050
- * @type {MetaObject}
103051
- */
103052
- this.parent = parent;
103053
- }
103054
-
103055
- if (children !== undefined && children !== null) {
103056
-
103057
- /**
103058
- * Child ObjectMeta instances within the structure hierarchy.
103059
- *
103060
- * Undefined when there are no children.
103061
- *
103062
- * @property children
103063
- * @type {Array}
103064
- */
103065
- this.children = children;
103066
- }
103067
-
103068
- if (external !== undefined && external !== null) {
103069
-
103070
- /**
103071
- * External application-specific metadata
103072
- *
103073
- * Undefined when there are is no external application-specific metadata.
103074
- *
103075
- * @property external
103076
- * @type {*}
103077
- */
103078
- this.external = external;
103079
- }
103091
+ // if (external !== undefined && external !== null) {
103092
+ //
103093
+ // /**
103094
+ // * External application-specific metadata
103095
+ // *
103096
+ // * Undefined when there are is no external application-specific metadata.
103097
+ // *
103098
+ // * @property external
103099
+ // * @type {*}
103100
+ // */
103101
+ // this.external = external;
103102
+ // }
103080
103103
  }
103081
103104
 
103082
103105
  /**
@@ -103266,6 +103289,12 @@ class PropertySet {
103266
103289
  */
103267
103290
  this.originalSystemId = originalSystemId;
103268
103291
 
103292
+ /**
103293
+ * The MetaModels that share this PropertySet.
103294
+ * @type {MetaModel[]}
103295
+ */
103296
+ this.metaModels = [];
103297
+
103269
103298
  /**
103270
103299
  * Human-readable name of this PropertySet.
103271
103300
  *
@@ -103362,12 +103391,6 @@ class MetaScene {
103362
103391
  */
103363
103392
  this.rootMetaObjects = {};
103364
103393
 
103365
- /**
103366
- * Tracks number of MetaObjects of each type.
103367
- * @private
103368
- */
103369
- this._typeCounts = {};
103370
-
103371
103394
  /**
103372
103395
  * Subscriptions to events sent with {@link fire}.
103373
103396
  * @private
@@ -103435,119 +103458,143 @@ class MetaScene {
103435
103458
  */
103436
103459
  createMetaModel(modelId, metaModelData, options = {}) {
103437
103460
 
103438
- const projectId = metaModelData.projectId || "none";
103439
- const revisionId = metaModelData.revisionId || "none";
103440
- const newPropertySets = metaModelData.propertySets || [];
103441
- const newObjects = metaModelData.metaObjects || [];
103442
- const author = metaModelData.author;
103443
- const createdAt = metaModelData.createdAt;
103444
- const creatingApplication = metaModelData.creatingApplication;
103445
- const schema = metaModelData.schema;
103446
- // if (options.excludeTypes) {
103447
- // excludeTypes = {};
103448
- // for (let i = 0, len = options.excludeTypes.length; i < len; i++) {
103449
- // includeTypes[options.excludeTypes[i]] = true;
103450
- // }
103451
- // }
103461
+ this._globalizeIDs(modelId, metaModelData, options);
103452
103462
 
103453
- const metaModel = new MetaModel(this, modelId, projectId, revisionId, author, createdAt, creatingApplication, schema, [], null);
103463
+ // Create MetaModel
103464
+
103465
+ const metaModel = new MetaModel({
103466
+ metaScene: this,
103467
+ id: modelId,
103468
+ projectId: metaModelData.projectId || "none",
103469
+ revisionId: metaModelData.revisionId || "none",
103470
+ author: metaModelData.author || "none",
103471
+ createdAt: metaModelData.createdAt || "none",
103472
+ creatingApplication: metaModelData.creatingApplication || "none",
103473
+ schema: metaModelData.schema || "none",
103474
+ propertySets: []
103475
+ });
103454
103476
 
103455
103477
  this.metaModels[modelId] = metaModel;
103456
103478
 
103457
- for (let i = 0, len = newPropertySets.length; i < len; i++) {
103458
- const propertySetCfg = newPropertySets[i];
103459
- const propertySetId = propertySetCfg.id;
103460
- const propertySet = new PropertySet(propertySetId, propertySetCfg.originalSystemId, propertySetCfg.name, propertySetCfg.type, propertySetCfg.properties);
103461
- metaModel.propertySets[propertySetId] = propertySet;
103462
- this.propertySets[propertySetId] = propertySet;
103479
+ // Create global Property Sets
103480
+
103481
+ for (let i = 0, len = metaModelData.propertySets.length; i < len; i++) {
103482
+ const propertySetData = metaModelData.propertySets[i];
103483
+ let propertySet = this.propertySets[propertySetData.id];
103484
+ if (!propertySet) {
103485
+ propertySet = new PropertySet({
103486
+ id: propertySetData.id,
103487
+ originalSystemId: propertySetData.originalSystemId,
103488
+ type: propertySetData.type,
103489
+ name: propertySetData.name,
103490
+ properties: propertySetData.properties
103491
+ });
103492
+ this.propertySets[propertySet.id] = propertySet;
103493
+ }
103494
+ propertySet.metaModels.push(metaModel);
103495
+ metaModel.propertySets.push(propertySet);
103463
103496
  }
103464
103497
 
103465
- const filteredObjectsParams = []; // Params for each new metaobject that passes our filters
103466
- const existingObjects = []; // List of our metaobjects that are already existing, to which we'll also append new metaobjects we'll create
103467
- const createObjectsParams = []; // List of params for metaobjects we'll create
103498
+ // Create MetaObjects
103499
+ // Don't re-create reused MetaObjects
103500
+ // Save root MetaObjects on MetaModel
103501
+ // Save root MetaObjects on MetaScene
103468
103502
 
103469
-
103470
- // Filter out the parameters we'll create
103471
-
103472
- for (let i = 0, len = newObjects.length; i < len; i++) {
103473
- const newObject = newObjects[i];
103474
- newObject.type;
103475
- filteredObjectsParams.push(newObject);
103503
+ for (let i = 0, len = metaModelData.metaObjects.length; i < len; i++) {
103504
+ const metaObjectData = metaModelData.metaObjects[i];
103505
+ const type = metaObjectData.type;
103506
+ const id = metaObjectData.id;
103507
+ let metaObject = this.metaObjects[id];
103508
+ if (!metaObject) {
103509
+ metaObject = new MetaObject({
103510
+ id,
103511
+ parentId: metaObjectData.parent,
103512
+ type,
103513
+ name: metaObjectData.name,
103514
+ propertySetIds: metaObjectData.propertySetIds
103515
+ });
103516
+ this.metaObjects[id] = metaObject;
103517
+ }
103518
+ metaObject.metaModels.push(metaModel);
103519
+ if (!metaObjectData.parent) {
103520
+ metaModel.rootMetaObjects.push(metaObject);
103521
+ this.rootMetaObjects[id] = metaObject;
103522
+ }
103523
+ metaModel.metaObjects.push(metaObject);
103476
103524
  }
103477
103525
 
103478
- // Build list of params for metaobjects we'll create
103526
+ // Re-link entire MetaObject parent/child hierarchy
103479
103527
 
103480
- for (let i = 0, len = filteredObjectsParams.length; i < len; i++) {
103481
- let filteredObject = filteredObjectsParams[i];
103482
- const existingObject = this.metaObjects[filteredObject.id];
103483
- if (existingObject) {
103484
- existingObject.metaModels.push(metaModel);
103485
- existingObjects.push(existingObject);
103486
- continue;
103528
+ for (let objectId in this.metaObjects) {
103529
+ const metaObject = this.metaObjects[objectId];
103530
+ if (metaObject.children) {
103531
+ metaObject.children = [];
103487
103532
  }
103488
- createObjectsParams.push(filteredObject);
103489
103533
  }
103490
103534
 
103491
- // Create metaobjects in the creation list, add them to list of existing metaobjects
103492
-
103493
- for (let i = 0, len = createObjectsParams.length; i < len; i++) {
103494
- const createObject = createObjectsParams[i];
103495
- const type = createObject.type;
103496
- const objectId = options.globalizeObjectIds ? math.globalizeObjectId(modelId, createObject.id) : createObject.id;
103497
- const originalSystemId = createObject.id;
103498
- const name = createObject.name;
103499
- const propertySets = [];
103500
- if (createObject.propertySetIds && createObject.propertySetIds.length > 0) {
103501
- for (let j = 0, lenj = createObject.propertySetIds.length; j < lenj; j++) {
103502
- const propertySetId = createObject.propertySetIds[j];
103503
- const propertySet = metaModel.propertySets[propertySetId];
103504
- if (propertySet) {
103505
- propertySets.push(propertySet);
103506
- }
103507
- }
103508
- }
103509
- const parent = null;
103510
- const children = null;
103511
- const external = createObject.external;
103512
- const metaObject = new MetaObject(metaModel, objectId, originalSystemId, name, type, propertySets, parent, children, external);
103513
- metaObject._parentId = createObject.parent;
103514
- this.metaObjects[objectId] = metaObject;
103515
- (this.metaObjectsByType[type] || (this.metaObjectsByType[type] = {}))[objectId] = metaObject;
103516
- if (this._typeCounts[type] === undefined) {
103517
- this._typeCounts[type] = 1;
103518
- } else {
103519
- this._typeCounts[type]++;
103520
- }
103521
- existingObjects.push(metaObject);
103522
- if (createObject.parent === undefined || createObject.parent === null) ;
103523
- }
103524
-
103525
- // Ensure that metaobjects in the existing metaobject list are all attached to their parents,
103526
- // or registered as root metaobjects
103527
-
103528
- for (let i = 0, len = existingObjects.length; i < len; i++) {
103529
- const existingObject = existingObjects[i];
103530
- const objectId = options.globalizeObjectIds ? math.globalizeObjectId(modelId, existingObject.id) : existingObject.id;
103531
- if ((existingObject._parentId === undefined || existingObject._parentId === null) && !existingObject.parent) {
103532
- metaModel.rootMetaObject = existingObject; // Deprecated, and won't work for federated models
103533
- metaModel.rootMetaObjects[objectId] = existingObject;
103534
- this.rootMetaObjects[objectId] = existingObject;
103535
- } else if (existingObject._parentId) {
103536
- const parentId = options.globalizeObjectIds ? math.globalizeObjectId(modelId, existingObject._parentId) : existingObject._parentId;
103537
- existingObject._parentId = null;
103538
- let parentMetaObject = this.metaObjects[parentId];
103535
+ for (let objectId in this.metaObjects) {
103536
+ const metaObject = this.metaObjects[objectId];
103537
+ if (metaObject.parentId) {
103538
+ const parentMetaObject = this.metaObjects[metaObject.parentId];
103539
103539
  if (parentMetaObject) {
103540
- existingObject.parent = parentMetaObject;
103541
- parentMetaObject.children = parentMetaObject.children || [];
103542
- parentMetaObject.children.push(existingObject);
103540
+ metaObject.parent = parentMetaObject;
103541
+ (parentMetaObject.children || (parentMetaObject.children = [])).push(metaObject);
103543
103542
  }
103544
103543
  }
103545
103544
  }
103546
103545
 
103546
+ // Create MetaObjects-by-type lookup
103547
+
103548
+ this.metaObjectsByType = {};
103549
+ for (let objectId in this.metaObjects) {
103550
+ const metaObject = this.metaObjects[objectId];
103551
+ const type = metaObject.type;
103552
+ (this.metaObjectsByType[type] || (this.metaObjectsByType[type] = {}))[objectId] = metaObject;
103553
+ }
103554
+
103547
103555
  this.fire("metaModelCreated", modelId);
103556
+
103548
103557
  return metaModel;
103549
103558
  }
103550
103559
 
103560
+ _globalizeIDs(modelId, metaModelData, options) {
103561
+ const globalize = !!options.globalizeObjectIds;
103562
+ for (let i = 0, len = metaModelData.metaObjects.length; i < len; i++) {
103563
+ const metaObjectData = metaModelData.metaObjects[i];
103564
+
103565
+ // Globalize MetaObject IDs and parent IDs
103566
+
103567
+ metaObjectData.originalSystemId = metaObjectData.id;
103568
+ metaObjectData.originalParentSystemId = metaObjectData.parent;
103569
+ if (globalize) {
103570
+ metaObjectData.id = math.globalizeObjectId(modelId, metaObject.id);
103571
+ metaObjectData.parent = math.globalizeObjectId(modelId, metaObject.parent);
103572
+ }
103573
+
103574
+ // Globalize MetaObject property set IDs
103575
+
103576
+ const propertySetIds = metaObjectData.propertySetIds;
103577
+ if (propertySetIds) {
103578
+ const propertySetGlobalIds = [];
103579
+ for (let j = 0, lenj = propertySetIds.length; j < lenj; j++) {
103580
+ propertySetGlobalIds.push(math.globalizeObjectId(modelId, propertySetIds[j]));
103581
+ }
103582
+ metaObjectData.propertySetIds = propertySetGlobalIds;
103583
+ metaObjectData.originalSystemPropertySetIds = propertySetIds;
103584
+ }
103585
+ }
103586
+
103587
+ // Globalize global PropertySet IDs
103588
+
103589
+ for (let i = 0, len = metaModelData.propertySets.length; i < len; i++) {
103590
+ const propertySet = metaModelData.propertySets[i];
103591
+ propertySet.originalSystemId = propertySet.id;
103592
+ if (globalize) {
103593
+ propertySet.id = math.globalizeObjectId(modelId, propertySet.id);
103594
+ }
103595
+ }
103596
+ }
103597
+
103551
103598
  /**
103552
103599
  * Removes a {@link MetaModel} from this MetaScene.
103553
103600
  *
@@ -103556,43 +103603,86 @@ class MetaScene {
103556
103603
  * @param {String} id ID of the target {@link MetaModel}.
103557
103604
  */
103558
103605
  destroyMetaModel(id) {
103606
+
103559
103607
  const metaModel = this.metaModels[id];
103560
103608
  if (!metaModel) {
103561
103609
  return;
103562
103610
  }
103563
- this._removeMetaModel(metaModel);
103564
- this.fire("metaModelDestroyed", id);
103565
- }
103566
103611
 
103567
- _removeMetaModel(metaModel) {
103568
- const metaObjects = this.metaObjects;
103569
- const metaObjectsByType = this.metaObjectsByType;
103570
- let visit = (metaObject) => {
103571
- delete metaObjects[metaObject.id];
103572
- const types = metaObjectsByType[metaObject.type];
103573
- if (types && types[metaObject.id]) {
103574
- delete types[metaObject.id];
103575
- if (--this._typeCounts[metaObject.type] === 0) {
103576
- delete this._typeCounts[metaObject.type];
103577
- delete metaObjectsByType[metaObject.type];
103612
+ // Remove global PropertySets
103613
+
103614
+ for (let i = 0, len = metaModel.propertySets.length; i < len; i++) {
103615
+ const propertySet = metaModel.propertySets[i];
103616
+ if (propertySet.metaModels.length === 1) { // Property set owned by one model, delete
103617
+ delete this.propertySets[propertySet.id];
103618
+ } else {
103619
+ const newMetaModels = [];
103620
+ for (let j = 0, lenj = propertySet.metaModels.length; j < lenj; j++) {
103621
+ if (propertySet.metaModels[i].id !== id) {
103622
+ newMetaModels.push(propertySet.metaModels[i]);
103623
+ }
103578
103624
  }
103625
+ propertySet.metaModels = newMetaModels;
103579
103626
  }
103580
- const children = metaObject.children;
103581
- if (children) {
103582
- for (let i = 0, len = children.length; i < len; i++) {
103583
- const childMetaObject = children[i];
103584
- visit(childMetaObject);
103627
+ }
103628
+
103629
+ // Remove MetaObjects
103630
+
103631
+ for (let i = 0, len = metaModel.metaObjects.length; i < len; i++) {
103632
+ const metaObject = metaModel.metaObjects[i];
103633
+ metaObject.type;
103634
+ const id = metaObject.id;
103635
+ if (metaObject.metaModels.length === 1) { // MetaObject owned by one model, delete
103636
+ delete this.metaObjects[id];
103637
+ if (!metaObject.parent) {
103638
+ delete this.rootMetaObjects[id];
103639
+ }
103640
+ } else {
103641
+ const newMetaModels = [];
103642
+ const metaModelId = metaModel.id;
103643
+ for (let i = 0, len = metaObject.metaModels.length; i < len; i++) {
103644
+ if (metaObject.metaModels[i].id !== metaModelId) {
103645
+ newMetaModels.push(metaObject.metaModels[i]);
103646
+ }
103585
103647
  }
103648
+ metaObject.metaModels = newMetaModels;
103586
103649
  }
103587
- };
103588
- visit(metaModel.rootMetaObject);
103589
- for (let propertySetId in metaModel.propertySets) {
103590
- if (metaModel.propertySets.hasOwnProperty(propertySetId)) {
103591
- delete this.propertySets[propertySetId];
103650
+ }
103651
+
103652
+ // Re-link entire MetaObject parent/child hierarchy
103653
+
103654
+ for (let objectId in this.metaObjects) {
103655
+ const metaObject = this.metaObjects[objectId];
103656
+ if (metaObject.children) {
103657
+ metaObject.children = [];
103592
103658
  }
103593
103659
  }
103594
- delete this.rootMetaObjects[metaModel.rootMetaObject.id];
103595
- delete this.metaModels[metaModel.id];
103660
+
103661
+ this.metaObjectsByType = {};
103662
+
103663
+ for (let objectId in this.metaObjects) {
103664
+ const metaObject = this.metaObjects[objectId];
103665
+ const type = metaObject.type;
103666
+ if (metaObject.children) {
103667
+ metaObject.children = null;
103668
+ }
103669
+ (this.metaObjectsByType[type] || (this.metaObjectsByType[type] = {}))[objectId] = metaObject;
103670
+ }
103671
+
103672
+ for (let objectId in this.metaObjects) {
103673
+ const metaObject = this.metaObjects[objectId];
103674
+ if (metaObject.parentId) {
103675
+ const parentMetaObject = this.metaObjects[metaObject.parentId];
103676
+ if (parentMetaObject) {
103677
+ metaObject.parent = parentMetaObject;
103678
+ (parentMetaObject.children || (parentMetaObject.children = [])).push(metaObject);
103679
+ }
103680
+ }
103681
+ }
103682
+
103683
+ delete this.metaModels[id];
103684
+
103685
+ this.fire("metaModelDestroyed", id);
103596
103686
  }
103597
103687
 
103598
103688
  /**
@@ -103615,12 +103705,13 @@ class MetaScene {
103615
103705
  * @returns {String[]} Array of {@link MetaObject#id}s.
103616
103706
  */
103617
103707
  getObjectIDsInSubtree(id, includeTypes, excludeTypes) {
103708
+
103618
103709
  const list = [];
103619
103710
  const metaObject = this.metaObjects[id];
103620
103711
  const includeMask = (includeTypes && includeTypes.length > 0) ? arrayToMap(includeTypes) : null;
103621
103712
  const excludeMask = (excludeTypes && excludeTypes.length > 0) ? arrayToMap(excludeTypes) : null;
103622
103713
 
103623
- function visit(metaObject) {
103714
+ const visit = (metaObject) => {
103624
103715
  if (!metaObject) {
103625
103716
  return;
103626
103717
  }
@@ -103639,7 +103730,7 @@ class MetaScene {
103639
103730
  visit(children[i]);
103640
103731
  }
103641
103732
  }
103642
- }
103733
+ };
103643
103734
 
103644
103735
  visit(metaObject);
103645
103736
  return list;
@@ -103673,94 +103764,94 @@ function arrayToMap(array) {
103673
103764
  * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
103674
103765
  * Released under MIT License
103675
103766
  */
103676
- /*! *****************************************************************************
103677
- Copyright (c) Microsoft Corporation.
103678
-
103679
- Permission to use, copy, modify, and/or distribute this software for any
103680
- purpose with or without fee is hereby granted.
103681
-
103682
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
103683
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
103684
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
103685
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
103686
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
103687
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
103688
- PERFORMANCE OF THIS SOFTWARE.
103689
- ***************************************************************************** */
103690
- /* global Reflect, Promise */
103691
-
103692
- var extendStatics = function(d, b) {
103693
- extendStatics = Object.setPrototypeOf ||
103694
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
103695
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
103696
- return extendStatics(d, b);
103697
- };
103698
-
103699
- function __extends(d, b) {
103700
- if (typeof b !== "function" && b !== null)
103701
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
103702
- extendStatics(d, b);
103703
- function __() { this.constructor = d; }
103704
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
103705
- }
103706
-
103707
- var __assign = function() {
103708
- __assign = Object.assign || function __assign(t) {
103709
- for (var s, i = 1, n = arguments.length; i < n; i++) {
103710
- s = arguments[i];
103711
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
103712
- }
103713
- return t;
103714
- };
103715
- return __assign.apply(this, arguments);
103716
- };
103717
-
103718
- function __awaiter(thisArg, _arguments, P, generator) {
103719
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103720
- return new (P || (P = Promise))(function (resolve, reject) {
103721
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
103722
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
103723
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
103724
- step((generator = generator.apply(thisArg, _arguments || [])).next());
103725
- });
103726
- }
103727
-
103728
- function __generator(thisArg, body) {
103729
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
103730
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
103731
- function verb(n) { return function (v) { return step([n, v]); }; }
103732
- function step(op) {
103733
- if (f) throw new TypeError("Generator is already executing.");
103734
- while (_) try {
103735
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
103736
- if (y = 0, t) op = [op[0] & 2, t.value];
103737
- switch (op[0]) {
103738
- case 0: case 1: t = op; break;
103739
- case 4: _.label++; return { value: op[1], done: false };
103740
- case 5: _.label++; y = op[1]; op = [0]; continue;
103741
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
103742
- default:
103743
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
103744
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
103745
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
103746
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
103747
- if (t[2]) _.ops.pop();
103748
- _.trys.pop(); continue;
103749
- }
103750
- op = body.call(thisArg, _);
103751
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
103752
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
103753
- }
103754
- }
103755
-
103756
- function __spreadArray(to, from, pack) {
103757
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
103758
- if (ar || !(i in from)) {
103759
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
103760
- ar[i] = from[i];
103761
- }
103762
- }
103763
- return to.concat(ar || from);
103767
+ /*! *****************************************************************************
103768
+ Copyright (c) Microsoft Corporation.
103769
+
103770
+ Permission to use, copy, modify, and/or distribute this software for any
103771
+ purpose with or without fee is hereby granted.
103772
+
103773
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
103774
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
103775
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
103776
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
103777
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
103778
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
103779
+ PERFORMANCE OF THIS SOFTWARE.
103780
+ ***************************************************************************** */
103781
+ /* global Reflect, Promise */
103782
+
103783
+ var extendStatics = function(d, b) {
103784
+ extendStatics = Object.setPrototypeOf ||
103785
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
103786
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
103787
+ return extendStatics(d, b);
103788
+ };
103789
+
103790
+ function __extends(d, b) {
103791
+ if (typeof b !== "function" && b !== null)
103792
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
103793
+ extendStatics(d, b);
103794
+ function __() { this.constructor = d; }
103795
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
103796
+ }
103797
+
103798
+ var __assign = function() {
103799
+ __assign = Object.assign || function __assign(t) {
103800
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
103801
+ s = arguments[i];
103802
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
103803
+ }
103804
+ return t;
103805
+ };
103806
+ return __assign.apply(this, arguments);
103807
+ };
103808
+
103809
+ function __awaiter(thisArg, _arguments, P, generator) {
103810
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103811
+ return new (P || (P = Promise))(function (resolve, reject) {
103812
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
103813
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
103814
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
103815
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
103816
+ });
103817
+ }
103818
+
103819
+ function __generator(thisArg, body) {
103820
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
103821
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
103822
+ function verb(n) { return function (v) { return step([n, v]); }; }
103823
+ function step(op) {
103824
+ if (f) throw new TypeError("Generator is already executing.");
103825
+ while (_) try {
103826
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
103827
+ if (y = 0, t) op = [op[0] & 2, t.value];
103828
+ switch (op[0]) {
103829
+ case 0: case 1: t = op; break;
103830
+ case 4: _.label++; return { value: op[1], done: false };
103831
+ case 5: _.label++; y = op[1]; op = [0]; continue;
103832
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
103833
+ default:
103834
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
103835
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
103836
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
103837
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
103838
+ if (t[2]) _.ops.pop();
103839
+ _.trys.pop(); continue;
103840
+ }
103841
+ op = body.call(thisArg, _);
103842
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
103843
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
103844
+ }
103845
+ }
103846
+
103847
+ function __spreadArray(to, from, pack) {
103848
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
103849
+ if (ar || !(i in from)) {
103850
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
103851
+ ar[i] = from[i];
103852
+ }
103853
+ }
103854
+ return to.concat(ar || from);
103764
103855
  }
103765
103856
 
103766
103857
  var Bounds = /** @class */ (function () {
@@ -112035,7 +112126,7 @@ class Viewer {
112035
112126
  * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#Configs_disableDoublePrecisionAndRAF)]
112036
112127
  *
112037
112128
  * ````javascript
112038
- * import {Configs, Viewer, XKTLoaderPlugin} from "../dist/xeokit-sdk.es.js";
112129
+ * import {Configs, Viewer, XKTLoaderPlugin} from "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.es.min.js";
112039
112130
  *
112040
112131
  * // Access xeoit-sdk global configs.
112041
112132
  * // We typically set configs only before we create any Viewers.