@xeokit/xeokit-sdk 2.6.49 → 2.6.51

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.49",
3
+ "version": "2.6.51",
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",
@@ -1,4 +1,5 @@
1
1
  import {math} from "../../viewer/scene/math/math.js";
2
+ import {transformToNode} from "../lib/ui/index.js";
2
3
  import {AngleMeasurementsControl} from "./AngleMeasurementsControl.js";
3
4
 
4
5
  const MOUSE_FINDING_ORIGIN = 0;
@@ -172,9 +173,6 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
172
173
  const mouseHoverCanvasPos = math.vec2();
173
174
  this._currentAngleMeasurement = null;
174
175
 
175
- const getTop = el => el.offsetTop + (el.offsetParent && (el.offsetParent !== canvas.parentNode) && getTop(el.offsetParent));
176
- const getLeft = el => el.offsetLeft + (el.offsetParent && (el.offsetParent !== canvas.parentNode) && getLeft(el.offsetParent));
177
-
178
176
  const pagePos = math.vec2();
179
177
 
180
178
  const hoverOn = event => {
@@ -209,8 +207,10 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
209
207
  this.markerDiv.style.left = `${pagePos[0] - 5}px`;
210
208
  this.markerDiv.style.top = `${pagePos[1] - 5}px`;
211
209
  } else {
212
- this.markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
213
- this.markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
210
+ const markerPos = math.vec2(canvasPos);
211
+ transformToNode(canvas, this.markerDiv.parentNode, markerPos);
212
+ this.markerDiv.style.left = `${markerPos[0] - 5}px`;
213
+ this.markerDiv.style.top = `${markerPos[1] - 5}px`;
214
214
  }
215
215
  break;
216
216
  case MOUSE_FINDING_CORNER:
@@ -1,4 +1,5 @@
1
1
  import {math} from "../../viewer/scene/math/math.js";
2
+ import {transformToNode} from "../lib/ui/index.js";
2
3
  import {DistanceMeasurementsControl} from "./DistanceMeasurementsControl.js";
3
4
 
4
5
  const MOUSE_FIRST_CLICK_EXPECTED = 0;
@@ -181,9 +182,6 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
181
182
 
182
183
  this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
183
184
 
184
- const getTop = el => el.offsetTop + (el.offsetParent && (el.offsetParent !== canvas.parentNode) && getTop(el.offsetParent));
185
- const getLeft = el => el.offsetLeft + (el.offsetParent && (el.offsetParent !== canvas.parentNode) && getLeft(el.offsetParent));
186
-
187
185
  const pagePos = math.vec2();
188
186
 
189
187
  const hoverOn = event => {
@@ -198,8 +196,10 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
198
196
  this._markerDiv.style.left = `${pagePos[0] - 5}px`;
199
197
  this._markerDiv.style.top = `${pagePos[1] - 5}px`;
200
198
  } else {
201
- this._markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
202
- this._markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
199
+ const markerPos = math.vec2(canvasPos);
200
+ transformToNode(canvas, this._markerDiv.parentNode, markerPos);
201
+ this._markerDiv.style.left = `${markerPos[0] - 5}px`;
202
+ this._markerDiv.style.top = `${markerPos[1] - 5}px`;
203
203
  }
204
204
 
205
205
  this._markerDiv.style.background = "pink";
@@ -41,7 +41,7 @@ class Storey {
41
41
  /**
42
42
  * Axis-aligned World-space boundary of the {@link Entity}s that represent the IfcBuildingStorey.
43
43
  *
44
- * The boundary is a six-element Float32Array containing the min/max extents of the
44
+ * The boundary is a six-element Float64Array containing the min/max extents of the
45
45
  * axis-aligned boundary, ie. ````[xmin, ymin, zmin, xmax, ymax, zmax]````
46
46
  *
47
47
  * @property storeyAABB
@@ -52,7 +52,7 @@ class Storey {
52
52
  /**
53
53
  * Axis-aligned World-space boundary of the {@link Entity}s that represent the IfcBuildingStorey.
54
54
  *
55
- * The boundary is a six-element Float32Array containing the min/max extents of the
55
+ * The boundary is a six-element Float64Array containing the min/max extents of the
56
56
  * axis-aligned boundary, ie. ````[xmin, ymin, zmin, xmax, ymax, zmax]````
57
57
  *
58
58
  * @deprecated
@@ -64,7 +64,7 @@ class Storey {
64
64
  /**
65
65
  * Axis-aligned World-space boundary of the {@link Entity}s that represent the model.
66
66
  *
67
- * The boundary is a six-element Float32Array containing the min/max extents of the
67
+ * The boundary is a six-element Float64Array containing the min/max extents of the
68
68
  * axis-aligned boundary, ie. ````[xmin, ymin, zmin, xmax, ymax, zmax]````
69
69
  *
70
70
  * @property modelAABB
@@ -258,6 +258,8 @@ class StoreyViewsPlugin extends Plugin {
258
258
  */
259
259
  this.storeys = {};
260
260
 
261
+ this._storeysList = null;
262
+
261
263
  /**
262
264
  * A set of {@link Storey}s for each {@link MetaModel}.
263
265
  *
@@ -299,6 +301,7 @@ class StoreyViewsPlugin extends Plugin {
299
301
  this.fire("storeys", this.storeys);
300
302
  });
301
303
  this.storeys[storeyId] = storey;
304
+ this._storeysList= null;
302
305
  if (!this.modelStoreys[modelId]) {
303
306
  this.modelStoreys[modelId] = {};
304
307
  }
@@ -319,6 +322,7 @@ class StoreyViewsPlugin extends Plugin {
319
322
  model.off(storey._onModelDestroyed);
320
323
  }
321
324
  delete this.storeys[storyObjectId];
325
+ this._storeysList= null;
322
326
  }
323
327
  }
324
328
  delete this.modelStoreys[modelId];
@@ -423,7 +427,7 @@ class StoreyViewsPlugin extends Plugin {
423
427
  * @param {String} storeyId ID of the ````IfcBuildingStorey```` object.
424
428
  * @param {*} [options] Options for showing the Entitys within the storey.
425
429
  * @param {Boolean} [options.hideOthers=false] When ````true````, hide all other {@link Entity}s.
426
- */
430
+ */
427
431
  showStoreyObjects(storeyId, options = {}) {
428
432
 
429
433
  const storey = this.storeys[storeyId];
@@ -448,7 +452,7 @@ class StoreyViewsPlugin extends Plugin {
448
452
 
449
453
  this.withStoreyObjects(storeyId, (entity, metaObject) => {
450
454
  if (entity) {
451
- entity.visible = true;
455
+ entity.visible = true;
452
456
  }
453
457
  });
454
458
  }
@@ -684,7 +688,7 @@ class StoreyViewsPlugin extends Plugin {
684
688
 
685
689
  /**
686
690
  * Gets the ID of the storey which's bounding box contains the y point of the world position
687
- *
691
+ *
688
692
  * @param {Number[]} worldPos 3D World-space position.
689
693
  * @returns {String} ID of the storey containing the position, or null if the position falls outside all the storeys.
690
694
  */
@@ -804,6 +808,42 @@ class StoreyViewsPlugin extends Plugin {
804
808
  this.viewer.scene.off(this._onModelLoaded);
805
809
  super.destroy();
806
810
  }
811
+
812
+ /**
813
+ * Gets Storeys in a list, spatially sorted on the vertical World axis, the lowest Storey first.
814
+ *
815
+ * @returns {null}
816
+ */
817
+ get storeysList() {
818
+ if (!this._storeysList) {
819
+ this._storeysList = Object.values(this.storeys);
820
+ this._storeysList.sort(this._getSpatialSortFunc());
821
+ }
822
+ return this._storeysList;
823
+ }
824
+
825
+ _getSpatialSortFunc() {
826
+ const viewer = this.viewer;
827
+ const scene = viewer.scene;
828
+ const camera = scene.camera;
829
+ return this._spatialSortFunc || (this._spatialSortFunc = (storey1, storey2) => {
830
+ let idx = 0;
831
+ if (camera.xUp) {
832
+ idx = 0;
833
+ } else if (camera.yUp) {
834
+ idx = 1;
835
+ } else {
836
+ idx = 2;
837
+ }
838
+ if (storey1.aabb[idx] > storey2.aabb[idx]) {
839
+ return -1;
840
+ }
841
+ if (storey1.aabb[idx] < storey2.aabb[idx]) {
842
+ return 1;
843
+ }
844
+ return 0;
845
+ });
846
+ }
807
847
  }
808
848
 
809
849
  export {StoreyViewsPlugin}
@@ -984,7 +984,7 @@ export class TreeViewPlugin extends Plugin {
984
984
  buildingNode = {
985
985
  nodeId: `${this._id}-${objectId}`,
986
986
  objectId: objectId,
987
- title: (metaObject.metaModels.length === 0) ? "na" : this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
987
+ title: (metaObject.metaModels.length === 0) ? metaObjectName : this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
988
988
  type: metaObjectType,
989
989
  parent: null,
990
990
  numEntities: 0,
@@ -1087,7 +1087,7 @@ export class TreeViewPlugin extends Plugin {
1087
1087
  rootNode = {
1088
1088
  nodeId: `${this._id}-${objectId}`,
1089
1089
  objectId: objectId,
1090
- title: metaObject.metaModels.length === 0 ? "na" : this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
1090
+ title: metaObject.metaModels.length === 0 ? metaObjectName : this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
1091
1091
  type: metaObjectType,
1092
1092
  parent: null,
1093
1093
  numEntities: 0,
@@ -1168,7 +1168,7 @@ export class TreeViewPlugin extends Plugin {
1168
1168
  const node = {
1169
1169
  nodeId: `${this._id}-${objectId}`,
1170
1170
  objectId: objectId,
1171
- title: (!parent) ? metaObject.metaModels.length === 0 ? "na" : (this._rootNames[metaObject.metaModels[0].id] || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
1171
+ title: (!parent) ? metaObject.metaModels.length === 0 ? metaObjectName : (this._rootNames[metaObject.metaModels[0].id] || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
1172
1172
  type: metaObjectType,
1173
1173
  parent: parent,
1174
1174
  numEntities: 0,
@@ -1204,8 +1204,8 @@ export class TreeViewPlugin extends Plugin {
1204
1204
  if (!children || children.length === 0) {
1205
1205
  return;
1206
1206
  }
1207
- if (this._hierarchy === "storeys" && node.type === "IfcBuilding") {
1208
- // Assumes that children of an IfcBuilding will always be IfcBuildingStoreys
1207
+ const firstChild = children[0];
1208
+ if (this._hierarchy === "storeys" && firstChild.type === "IfcBuildingStorey") {
1209
1209
  children.sort(this._getSpatialSortFunc());
1210
1210
  } else {
1211
1211
  children.sort(this._alphaSortFunc);
@@ -304,8 +304,8 @@ class MetaModel {
304
304
 
305
305
  for (let modelId in metaScene.metaModels) {
306
306
  const metaModel = metaScene.metaModels[modelId];
307
- for (let i = 0, len = metaModel.metaObjects.length; i < len; i++) {
308
- const metaObject = metaModel.metaObjects[i];
307
+ for (let objectId in metaModel.metaObjects) {
308
+ const metaObject = metaModel.metaObjects[objectId];
309
309
  metaObject.metaModels.push(metaModel);
310
310
  }
311
311
  }
@@ -1562,13 +1562,7 @@ export class SceneModel extends Component {
1562
1562
  */
1563
1563
  set matrix(value) {
1564
1564
  this._matrix.set(value || DEFAULT_MATRIX);
1565
-
1566
- math.quaternionToRotationMat4(this._quaternion, this._worldRotationMatrix);
1567
- math.conjugateQuaternion(this._quaternion, this._conjugateQuaternion);
1568
- math.quaternionToRotationMat4(this._quaternion, this._worldRotationMatrixConjugate);
1569
- this._matrix.set(this._worldRotationMatrix);
1570
- math.translateMat4v(this._position, this._matrix);
1571
-
1565
+ math.decomposeMat4(this._matrix, this._position, this._quaternion, this._scale);
1572
1566
  this._matrixDirty = false;
1573
1567
  this._setWorldMatrixDirty();
1574
1568
  this._sceneModelDirty();
@@ -1602,6 +1596,8 @@ export class SceneModel extends Component {
1602
1596
  math.quaternionToRotationMat4(this._quaternion, this._worldRotationMatrix);
1603
1597
  math.conjugateQuaternion(this._quaternion, this._conjugateQuaternion);
1604
1598
  math.quaternionToRotationMat4(this._conjugateQuaternion, this._worldRotationMatrixConjugate);
1599
+ math.scaleMat4v(this._scale, this._worldRotationMatrix);
1600
+ math.scaleMat4v(this._scale, this._worldRotationMatrixConjugate);
1605
1601
  this._matrix.set(this._worldRotationMatrix);
1606
1602
  math.translateMat4v(this._position, this._matrix);
1607
1603
  this._matrixDirty = false;
@@ -107,7 +107,7 @@ export declare interface ITreeViewRenderService {
107
107
  * @param nodeId {String} The node id.
108
108
  * @param checked {Boolean} Whether the node is checked.
109
109
  */
110
- setCheckbox(nodeId: string, checked: boolean): void;
110
+ setCheckbox(nodeId: string, checked: boolean, indeterminate?: boolean): void;
111
111
 
112
112
  /**
113
113
  * Sets the node's xrayed state.