@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.52",
3
+ "version": "2.6.53",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -1205,7 +1205,7 @@ export class TreeViewPlugin extends Plugin {
1205
1205
  return;
1206
1206
  }
1207
1207
  const firstChild = children[0];
1208
- if (this._hierarchy === "storeys" && firstChild.type === "IfcBuildingStorey") {
1208
+ if ((this._hierarchy === "storeys" || this._hierarchy === "containment") && firstChild.type === "IfcBuildingStorey") {
1209
1209
  children.sort(this._getSpatialSortFunc());
1210
1210
  } else {
1211
1211
  children.sort(this._alphaSortFunc);
@@ -1216,21 +1216,11 @@ export class TreeViewPlugin extends Plugin {
1216
1216
  }
1217
1217
  }
1218
1218
 
1219
- _getSpatialSortFunc() { // Creates cached sort func with Viewer in scope
1219
+ _getSpatialSortFunc() {
1220
1220
  const viewer = this.viewer;
1221
1221
  const scene = viewer.scene;
1222
1222
  const camera = scene.camera;
1223
- const metaScene = viewer.metaScene;
1224
- return this._spatialSortFunc || (this._spatialSortFunc = (node1, node2) => {
1225
- if (!node1.aabb || !node2.aabb) {
1226
- // Sorting on lowest point of the AABB is likely more more robust when objects could overlap storeys
1227
- if (!node1.aabb) {
1228
- node1.aabb = scene.getAABB(metaScene.getObjectIDsInSubtree(node1.objectId));
1229
- }
1230
- if (!node2.aabb) {
1231
- node2.aabb = scene.getAABB(metaScene.getObjectIDsInSubtree(node2.objectId));
1232
- }
1233
- }
1223
+ return this._spatialSortFunc || (this._spatialSortFunc = (storey1, storey2) => {
1234
1224
  let idx = 0;
1235
1225
  if (camera.xUp) {
1236
1226
  idx = 0;
@@ -1239,13 +1229,24 @@ export class TreeViewPlugin extends Plugin {
1239
1229
  } else {
1240
1230
  idx = 2;
1241
1231
  }
1242
- if (node1.aabb[idx] > node2.aabb[idx]) {
1243
- return -1;
1244
- }
1245
- if (node1.aabb[idx] < node2.aabb[idx]) {
1246
- return 1;
1232
+ const metaScene = this.viewer.metaScene;
1233
+ const storey1MetaObject = metaScene.metaObjects[storey1.objectId];
1234
+ const storey2MetaObject = metaScene.metaObjects[storey2.objectId];
1235
+
1236
+ if (storey1MetaObject && (storey1MetaObject.attributes && storey1MetaObject.attributes.elevation !== undefined) &&
1237
+ storey2MetaObject && (storey2MetaObject.attributes && storey2MetaObject.attributes.elevation !== undefined)) {
1238
+ const elevation1 = storey1MetaObject.attributes.elevation;
1239
+ const elevation2 = storey2MetaObject.attributes.elevation;
1240
+ if (elevation1 > elevation2) {
1241
+ return -1;
1242
+ }
1243
+ if (elevation1 < elevation2) {
1244
+ return 1;
1245
+ }
1246
+ return 0;
1247
+ } else {
1248
+ return 0;
1247
1249
  }
1248
- return 0;
1249
1250
  });
1250
1251
  }
1251
1252