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