@xeokit/xeokit-sdk 2.6.52 → 2.6.53

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.
@@ -127477,7 +127477,7 @@ class TreeViewPlugin extends Plugin {
127477
127477
  return;
127478
127478
  }
127479
127479
  const firstChild = children[0];
127480
- if (this._hierarchy === "storeys" && firstChild.type === "IfcBuildingStorey") {
127480
+ if ((this._hierarchy === "storeys" || this._hierarchy === "containment") && firstChild.type === "IfcBuildingStorey") {
127481
127481
  children.sort(this._getSpatialSortFunc());
127482
127482
  } else {
127483
127483
  children.sort(this._alphaSortFunc);
@@ -127488,36 +127488,30 @@ class TreeViewPlugin extends Plugin {
127488
127488
  }
127489
127489
  }
127490
127490
 
127491
- _getSpatialSortFunc() { // Creates cached sort func with Viewer in scope
127491
+ _getSpatialSortFunc() {
127492
127492
  const viewer = this.viewer;
127493
127493
  const scene = viewer.scene;
127494
127494
  const camera = scene.camera;
127495
- const metaScene = viewer.metaScene;
127496
- return this._spatialSortFunc || (this._spatialSortFunc = (node1, node2) => {
127497
- if (!node1.aabb || !node2.aabb) {
127498
- // Sorting on lowest point of the AABB is likely more more robust when objects could overlap storeys
127499
- if (!node1.aabb) {
127500
- node1.aabb = scene.getAABB(metaScene.getObjectIDsInSubtree(node1.objectId));
127495
+ return this._spatialSortFunc || (this._spatialSortFunc = (storey1, storey2) => {
127496
+ if (camera.xUp) ; else if (camera.yUp) ; else ;
127497
+ const metaScene = this.viewer.metaScene;
127498
+ const storey1MetaObject = metaScene.metaObjects[storey1.objectId];
127499
+ const storey2MetaObject = metaScene.metaObjects[storey2.objectId];
127500
+
127501
+ if (storey1MetaObject && (storey1MetaObject.attributes && storey1MetaObject.attributes.elevation !== undefined) &&
127502
+ storey2MetaObject && (storey2MetaObject.attributes && storey2MetaObject.attributes.elevation !== undefined)) {
127503
+ const elevation1 = storey1MetaObject.attributes.elevation;
127504
+ const elevation2 = storey2MetaObject.attributes.elevation;
127505
+ if (elevation1 > elevation2) {
127506
+ return -1;
127501
127507
  }
127502
- if (!node2.aabb) {
127503
- node2.aabb = scene.getAABB(metaScene.getObjectIDsInSubtree(node2.objectId));
127508
+ if (elevation1 < elevation2) {
127509
+ return 1;
127504
127510
  }
127505
- }
127506
- let idx = 0;
127507
- if (camera.xUp) {
127508
- idx = 0;
127509
- } else if (camera.yUp) {
127510
- idx = 1;
127511
+ return 0;
127511
127512
  } else {
127512
- idx = 2;
127513
- }
127514
- if (node1.aabb[idx] > node2.aabb[idx]) {
127515
- return -1;
127516
- }
127517
- if (node1.aabb[idx] < node2.aabb[idx]) {
127518
- return 1;
127513
+ return 0;
127519
127514
  }
127520
- return 0;
127521
127515
  });
127522
127516
  }
127523
127517
 
@@ -127473,7 +127473,7 @@ class TreeViewPlugin extends Plugin {
127473
127473
  return;
127474
127474
  }
127475
127475
  const firstChild = children[0];
127476
- if (this._hierarchy === "storeys" && firstChild.type === "IfcBuildingStorey") {
127476
+ if ((this._hierarchy === "storeys" || this._hierarchy === "containment") && firstChild.type === "IfcBuildingStorey") {
127477
127477
  children.sort(this._getSpatialSortFunc());
127478
127478
  } else {
127479
127479
  children.sort(this._alphaSortFunc);
@@ -127484,36 +127484,30 @@ class TreeViewPlugin extends Plugin {
127484
127484
  }
127485
127485
  }
127486
127486
 
127487
- _getSpatialSortFunc() { // Creates cached sort func with Viewer in scope
127487
+ _getSpatialSortFunc() {
127488
127488
  const viewer = this.viewer;
127489
127489
  const scene = viewer.scene;
127490
127490
  const camera = scene.camera;
127491
- const metaScene = viewer.metaScene;
127492
- return this._spatialSortFunc || (this._spatialSortFunc = (node1, node2) => {
127493
- if (!node1.aabb || !node2.aabb) {
127494
- // Sorting on lowest point of the AABB is likely more more robust when objects could overlap storeys
127495
- if (!node1.aabb) {
127496
- node1.aabb = scene.getAABB(metaScene.getObjectIDsInSubtree(node1.objectId));
127491
+ return this._spatialSortFunc || (this._spatialSortFunc = (storey1, storey2) => {
127492
+ if (camera.xUp) ; else if (camera.yUp) ; else ;
127493
+ const metaScene = this.viewer.metaScene;
127494
+ const storey1MetaObject = metaScene.metaObjects[storey1.objectId];
127495
+ const storey2MetaObject = metaScene.metaObjects[storey2.objectId];
127496
+
127497
+ if (storey1MetaObject && (storey1MetaObject.attributes && storey1MetaObject.attributes.elevation !== undefined) &&
127498
+ storey2MetaObject && (storey2MetaObject.attributes && storey2MetaObject.attributes.elevation !== undefined)) {
127499
+ const elevation1 = storey1MetaObject.attributes.elevation;
127500
+ const elevation2 = storey2MetaObject.attributes.elevation;
127501
+ if (elevation1 > elevation2) {
127502
+ return -1;
127497
127503
  }
127498
- if (!node2.aabb) {
127499
- node2.aabb = scene.getAABB(metaScene.getObjectIDsInSubtree(node2.objectId));
127504
+ if (elevation1 < elevation2) {
127505
+ return 1;
127500
127506
  }
127501
- }
127502
- let idx = 0;
127503
- if (camera.xUp) {
127504
- idx = 0;
127505
- } else if (camera.yUp) {
127506
- idx = 1;
127507
+ return 0;
127507
127508
  } else {
127508
- idx = 2;
127509
- }
127510
- if (node1.aabb[idx] > node2.aabb[idx]) {
127511
- return -1;
127512
- }
127513
- if (node1.aabb[idx] < node2.aabb[idx]) {
127514
- return 1;
127509
+ return 0;
127515
127510
  }
127516
- return 0;
127517
127511
  });
127518
127512
  }
127519
127513