@xeokit/xeokit-sdk 2.6.64 → 2.6.66

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.
Files changed (36) hide show
  1. package/dist/xeokit-sdk.cjs.js +277 -272
  2. package/dist/xeokit-sdk.es.js +277 -272
  3. package/dist/xeokit-sdk.es5.js +132 -119
  4. package/dist/xeokit-sdk.min.cjs.js +5 -5
  5. package/dist/xeokit-sdk.min.es.js +5 -5
  6. package/dist/xeokit-sdk.min.es5.js +4 -4
  7. package/package.json +1 -1
  8. package/src/extras/PointerCircle/PointerCircle.js +1 -1
  9. package/src/extras/PointerLens/PointerLens.js +27 -46
  10. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.js +29 -20
  11. package/src/plugins/AnnotationsPlugin/Annotation.js +3 -0
  12. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +27 -33
  13. package/src/plugins/SectionPlanesPlugin/Control.js +36 -126
  14. package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +10 -4
  15. package/src/plugins/lib/html/MenuEvent.js +3 -1
  16. package/src/viewer/scene/model/SceneModel.js +1 -0
  17. package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +1 -2
  18. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +4 -1
  19. package/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +1 -1
  20. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +4 -1
  21. package/src/viewer/scene/sectionPlane/SectionPlane.js +79 -1
  22. package/src/viewer/scene/webgl/Renderer.js +9 -3
  23. package/types/extras/PointerCircle/PointerCircle.d.ts +50 -0
  24. package/types/extras/PointerCircle/index.d.ts +1 -0
  25. package/types/plugins/AngleMeasurementsPlugin/index.d.ts +2 -1
  26. package/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts +4 -0
  27. package/types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts +121 -0
  28. package/types/plugins/DotBIMLoaderPlugin/index.d.ts +1 -0
  29. package/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +4 -0
  30. package/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +4 -0
  31. package/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts +4 -0
  32. package/types/plugins/TreeViewPlugin/TreeViewPlugin.d.ts +4 -0
  33. package/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts +4 -0
  34. package/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +19 -1
  35. package/types/plugins/index.d.ts +2 -0
  36. package/types/plugins/lib/ui/index.d.ts +12 -0
@@ -1055,13 +1055,10 @@ class PointerLens {
1055
1055
  this.scene = this.viewer.scene;
1056
1056
 
1057
1057
  this._lensCursorDiv = document.createElement('div');
1058
- this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._lensCursorDiv, this.viewer.scene.canvas.canvas);
1059
- this._lensCursorDiv.style.background = "pink";
1060
- this._lensCursorDiv.style.border = "2px solid red";
1061
- this._lensCursorDiv.style.borderRadius = "20px";
1062
- this._lensCursorDiv.style.width = "10px";
1063
- this._lensCursorDiv.style.height = "10px";
1064
- this._lensCursorDiv.style.margin = "-200px -200px";
1058
+ this._lensParams = { canvasSize: 300, cursorBorder: 2, cursorSize: 10 };
1059
+ this._lensCursorDiv.style.borderRadius = "50%";
1060
+ this._lensCursorDiv.style.width = this._lensParams.cursorSize + "px";
1061
+ this._lensCursorDiv.style.height = this._lensParams.cursorSize + "px";
1065
1062
  this._lensCursorDiv.style.zIndex = "100000";
1066
1063
  this._lensCursorDiv.style.position = "absolute";
1067
1064
  this._lensCursorDiv.style.pointerEvents = "none";
@@ -1074,8 +1071,8 @@ class PointerLens {
1074
1071
  this._lensContainer.style.background = "white";
1075
1072
  // this._lensContainer.style.opacity = "0";
1076
1073
  this._lensContainer.style.borderRadius = "50%";
1077
- this._lensContainer.style.width = "300px";
1078
- this._lensContainer.style.height = "300px";
1074
+ this._lensContainer.style.width = this._lensParams.canvasSize + "px";
1075
+ this._lensContainer.style.height = this._lensParams.canvasSize + "px";
1079
1076
 
1080
1077
  this._lensContainer.style.zIndex = "15000";
1081
1078
  this._lensContainer.style.position = "absolute";
@@ -1087,13 +1084,14 @@ class PointerLens {
1087
1084
  // this._lensCanvas.style.background = "darkblue";
1088
1085
  this._lensCanvas.style.borderRadius = "50%";
1089
1086
 
1090
- this._lensCanvas.style.width = "300px";
1091
- this._lensCanvas.style.height = "300px";
1087
+ this._lensCanvas.style.width = this._lensParams.canvasSize + "px";
1088
+ this._lensCanvas.style.height = this._lensParams.canvasSize + "px";
1092
1089
  this._lensCanvas.style.zIndex = "15000";
1093
1090
  this._lensCanvas.style.pointerEvents = "none";
1094
1091
 
1095
1092
  document.body.appendChild(this._lensContainer);
1096
1093
  this._lensContainer.appendChild(this._lensCanvas);
1094
+ this._lensContainer.appendChild(this._lensCursorDiv);
1097
1095
 
1098
1096
  this._lensCanvasContext = this._lensCanvas.getContext('2d');
1099
1097
  this._canvasElement = this.viewer.scene.canvas.canvas;
@@ -1111,7 +1109,7 @@ class PointerLens {
1111
1109
 
1112
1110
  this._active = (cfg.active !== false);
1113
1111
  this._visible = false;
1114
- this._snapped = false;
1112
+ this.snapped = false;
1115
1113
 
1116
1114
  this._onViewerRendering = this.viewer.scene.on("rendering", () => {
1117
1115
  if (this._active && this._visible) {
@@ -1158,21 +1156,13 @@ class PointerLens {
1158
1156
  this._lensCanvas.height // destination height
1159
1157
  );
1160
1158
 
1161
- const centerLensCanvas = [
1162
- (lensRect.left + lensRect.right) / 2 - canvasRect.left,
1163
- (lensRect.top + lensRect.bottom) / 2 - canvasRect.top
1164
- ];
1159
+ const middle = this._lensParams.canvasSize / 2 - this._lensParams.cursorSize / 2 - this._lensParams.cursorBorder;
1165
1160
 
1166
- if (this._snappedCanvasPos) {
1167
- const deltaX = this._snappedCanvasPos[0] - this._canvasPos[0];
1168
- const deltaY = this._snappedCanvasPos[1] - this._canvasPos[1];
1161
+ const deltaX = this._snappedCanvasPos ? (this._snappedCanvasPos[0] - this._canvasPos[0]) : 0;
1162
+ const deltaY = this._snappedCanvasPos ? (this._snappedCanvasPos[1] - this._canvasPos[1]) : 0;
1169
1163
 
1170
- this._lensCursorDiv.style.marginLeft = `${centerLensCanvas[0] + deltaX * this._zoomLevel - 10}px`;
1171
- this._lensCursorDiv.style.marginTop = `${centerLensCanvas[1] + deltaY * this._zoomLevel - 10}px`;
1172
- } else {
1173
- this._lensCursorDiv.style.marginLeft = `${centerLensCanvas[0] - 10}px`;
1174
- this._lensCursorDiv.style.marginTop = `${centerLensCanvas[1] - 10}px`;
1175
- }
1164
+ this._lensCursorDiv.style.left = `${middle + deltaX * this._zoomLevel}px`;
1165
+ this._lensCursorDiv.style.top = `${middle + deltaY * this._zoomLevel}px`;
1176
1166
  }
1177
1167
 
1178
1168
 
@@ -1240,14 +1230,10 @@ class PointerLens {
1240
1230
  * @private
1241
1231
  */
1242
1232
  set snapped(snapped) {
1243
- this._snapped = snapped;
1244
- if (snapped) {
1245
- this._lensCursorDiv.style.background = "greenyellow";
1246
- this._lensCursorDiv.style.border = "2px solid green";
1247
- } else {
1248
- this._lensCursorDiv.style.background = "pink";
1249
- this._lensCursorDiv.style.border = "2px solid red";
1250
- }
1233
+ this._snapped = snapped;
1234
+ const [ bg, border ] = snapped ? [ "greenyellow", "green" ] : [ "pink", "red" ];
1235
+ this._lensCursorDiv.style.background = bg;
1236
+ this._lensCursorDiv.style.border = this._lensParams.cursorBorder + "px solid " + border;
1251
1237
  }
1252
1238
 
1253
1239
  /**
@@ -1259,19 +1245,19 @@ class PointerLens {
1259
1245
  get snapped() {
1260
1246
  return this._snapped;
1261
1247
  }
1262
-
1248
+
1249
+ _updateActiveVisible() {
1250
+ this._lensContainer.style.visibility = (this._active && this._visible) ? "visible" : "hidden";
1251
+ this.update();
1252
+ }
1253
+
1263
1254
  /**
1264
1255
  * Sets if this PointerLens is active.
1265
1256
  * @param active
1266
1257
  */
1267
1258
  set active(active) {
1268
1259
  this._active = active;
1269
- this._lensContainer.style.visibility = (active && this._visible) ? "visible" : "hidden";
1270
- if (!active || !this._visible ) {
1271
- this._lensCursorDiv.style.marginLeft = `-100px`;
1272
- this._lensCursorDiv.style.marginTop = `-100px`;
1273
- }
1274
- this.update();
1260
+ this._updateActiveVisible();
1275
1261
  }
1276
1262
 
1277
1263
  /**
@@ -1290,12 +1276,7 @@ class PointerLens {
1290
1276
  */
1291
1277
  set visible(visible) {
1292
1278
  this._visible = visible;
1293
- this._lensContainer.style.visibility = (visible && this._active) ? "visible" : "hidden";
1294
- if (!visible || !this._active) {
1295
- this._lensCursorDiv.style.marginLeft = `-100px`;
1296
- this._lensCursorDiv.style.marginTop = `-100px`;
1297
- }
1298
- this.update();
1279
+ this._updateActiveVisible();
1299
1280
  }
1300
1281
 
1301
1282
  /**
@@ -1326,7 +1307,7 @@ class PointerLens {
1326
1307
  let doublePrecision = true;
1327
1308
  let FloatArrayType = doublePrecision ? Float64Array : Float32Array;
1328
1309
 
1329
- const tempVec3a$N = new FloatArrayType(3);
1310
+ const tempVec3a$O = new FloatArrayType(3);
1330
1311
 
1331
1312
  const tempMat1 = new FloatArrayType(16);
1332
1313
  const tempMat2 = new FloatArrayType(16);
@@ -6696,10 +6677,10 @@ math.buildEdgeIndices = (function () {
6696
6677
  */
6697
6678
  math.planeClipsPositions3 = function (pos, dir, positions, numElementsPerPosition = 3) {
6698
6679
  for (let i = 0, len = positions.length; i < len; i += numElementsPerPosition) {
6699
- tempVec3a$N[0] = positions[i + 0] - pos[0];
6700
- tempVec3a$N[1] = positions[i + 1] - pos[1];
6701
- tempVec3a$N[2] = positions[i + 2] - pos[2];
6702
- let dotProduct = tempVec3a$N[0] * dir[0] + tempVec3a$N[1] * dir[1] + tempVec3a$N[2] * dir[2];
6680
+ tempVec3a$O[0] = positions[i + 0] - pos[0];
6681
+ tempVec3a$O[1] = positions[i + 1] - pos[1];
6682
+ tempVec3a$O[2] = positions[i + 2] - pos[2];
6683
+ let dotProduct = tempVec3a$O[0] * dir[0] + tempVec3a$O[1] * dir[1] + tempVec3a$O[2] * dir[2];
6703
6684
  if (dotProduct < 0) {
6704
6685
  return true;
6705
6686
  }
@@ -8579,8 +8560,8 @@ class Component {
8579
8560
  }
8580
8561
  }
8581
8562
 
8582
- const tempVec3a$M = math.vec3();
8583
- const tempVec3b$A = math.vec3();
8563
+ const tempVec3a$N = math.vec3();
8564
+ const tempVec3b$B = math.vec3();
8584
8565
  const tempMat4a$s = math.mat4();
8585
8566
 
8586
8567
  /**
@@ -8657,8 +8638,8 @@ function frustumIntersectsAABB3(frustum, aabb) {
8657
8638
 
8658
8639
  let ret = Frustum$1.INSIDE;
8659
8640
 
8660
- const min = tempVec3a$M;
8661
- const max = tempVec3b$A;
8641
+ const min = tempVec3a$N;
8642
+ const max = tempVec3b$B;
8662
8643
 
8663
8644
  min[0] = aabb[0];
8664
8645
  min[1] = aabb[1];
@@ -9293,7 +9274,7 @@ class PointerCircle {
9293
9274
  }
9294
9275
 
9295
9276
  /**
9296
- * Stop the shricking circle and hide it.
9277
+ * Stop the shrinking circle and hide it.
9297
9278
  */
9298
9279
  stop() {
9299
9280
  if (this._destroyed) {
@@ -9586,7 +9567,8 @@ const os = {
9586
9567
  }
9587
9568
  };
9588
9569
 
9589
- function addContextMenuListener(elem, callback) {
9570
+ //failCallback will be called when the press is not long enough to considered a long press
9571
+ function addContextMenuListener(elem, callback, failCallback = () => {}) {
9590
9572
  if (!elem || !callback) return;
9591
9573
 
9592
9574
  let timeout = null;
@@ -9640,6 +9622,7 @@ function addContextMenuListener(elem, callback) {
9640
9622
  const touchEndHandler = (event) => {
9641
9623
  event.preventDefault();
9642
9624
  if (timeout) {
9625
+ failCallback(event);
9643
9626
  clearTimeout(timeout);
9644
9627
  timeout = null;
9645
9628
  }
@@ -10275,7 +10258,7 @@ class Wire {
10275
10258
  }
10276
10259
  }
10277
10260
 
10278
- const tempVec3a$L = math.vec3();
10261
+ const tempVec3a$M = math.vec3();
10279
10262
  const tempVec4$1 = math.vec4();
10280
10263
 
10281
10264
  /**
@@ -10356,7 +10339,7 @@ function worldToRTCPos(worldPos, rtcCenter, rtcPos) {
10356
10339
  */
10357
10340
  function worldToRTCPositions(worldPositions, rtcPositions, rtcCenter, cellSize = 1000) {
10358
10341
 
10359
- const center = math.getPositionsCenter(worldPositions, tempVec3a$L);
10342
+ const center = math.getPositionsCenter(worldPositions, tempVec3a$M);
10360
10343
 
10361
10344
  const rtcCenterX = Math.round(center[0] / cellSize) * cellSize;
10362
10345
  const rtcCenterY = Math.round(center[1] / cellSize) * cellSize;
@@ -10410,7 +10393,7 @@ function getPlaneRTCPos(dist, dir, rtcOrigin, rtcPlanePos, originMatrix) {
10410
10393
  ? (tempVec4$1.set(rtcOrigin, 0), tempVec4$1[3] = 1, math.mulMat4v4(originMatrix, tempVec4$1, tempVec4$1))
10411
10394
  : rtcOrigin);
10412
10395
  const rtcCenterToPlaneDist = math.dotVec3(dir, rtcCenter) + dist;
10413
- const dirNormalized = math.normalizeVec3(dir, tempVec3a$L);
10396
+ const dirNormalized = math.normalizeVec3(dir, tempVec3a$M);
10414
10397
  math.mulVec3Scalar(dirNormalized, -rtcCenterToPlaneDist, rtcPlanePos);
10415
10398
  return rtcPlanePos;
10416
10399
  }
@@ -11198,7 +11181,7 @@ class SceneModelEntity {
11198
11181
  }
11199
11182
  }
11200
11183
 
11201
- const tempVec4a$b = math.vec4();
11184
+ const tempVec4a$c = math.vec4();
11202
11185
  const tempVec4b$7 = math.vec4();
11203
11186
 
11204
11187
 
@@ -11358,9 +11341,9 @@ class Marker extends Component {
11358
11341
  this.fire("viewPos", this._viewPos);
11359
11342
  }
11360
11343
  if (this._canvasPosDirty) {
11361
- tempVec4a$b.set(this._viewPos);
11362
- tempVec4a$b[3] = 1.0;
11363
- math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$b, tempVec4b$7);
11344
+ tempVec4a$c.set(this._viewPos);
11345
+ tempVec4a$c[3] = 1.0;
11346
+ math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$c, tempVec4b$7);
11364
11347
  const aabb = this.scene.canvas.boundary;
11365
11348
  this._canvasPos[0] = Math.floor((1 + tempVec4b$7[0] / tempVec4b$7[3]) * aabb[2] / 2);
11366
11349
  this._canvasPos[1] = Math.floor((1 - tempVec4b$7[1] / tempVec4b$7[3]) * aabb[3] / 2);
@@ -13781,6 +13764,8 @@ const WAITING_FOR_TARGET_LONG_TOUCH_END$1 = 8;
13781
13764
 
13782
13765
  const TOUCH_CANCELING$1 = 7;
13783
13766
 
13767
+ const tmpVec2$1 = math.vec2();
13768
+
13784
13769
  /**
13785
13770
  * Creates {@link AngleMeasurement}s from touch input.
13786
13771
  *
@@ -13919,6 +13904,19 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13919
13904
  this._touchState = WAITING_FOR_ORIGIN_TOUCH_START$1;
13920
13905
  };
13921
13906
 
13907
+ const copyCanvasPos = (event, dst) => {
13908
+ dst[0] = event.clientX;
13909
+ dst[1] = event.clientY;
13910
+ transformToNode(canvas.ownerDocument.documentElement, canvas, dst);
13911
+ return dst;
13912
+ };
13913
+
13914
+ const toBodyPos = (pos, dst) => {
13915
+ dst.set(pos);
13916
+ transformToNode(canvas, canvas.ownerDocument.documentElement, dst);
13917
+ return dst;
13918
+ };
13919
+
13922
13920
  canvas.addEventListener("touchstart", this._onCanvasTouchStart = (event) => {
13923
13921
 
13924
13922
  const currentNumTouches = event.touches.length;
@@ -13932,11 +13930,8 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13932
13930
  }
13933
13931
 
13934
13932
  const touch = event.touches[0];
13935
- const touchX = touch.clientX;
13936
- const touchY = touch.clientY;
13937
-
13938
- touchStartCanvasPos.set([touchX, touchY]);
13939
- touchMoveCanvasPos.set([touchX, touchY]);
13933
+ copyCanvasPos(touch, touchStartCanvasPos);
13934
+ touchMoveCanvasPos.set(touchStartCanvasPos);
13940
13935
 
13941
13936
  switch (this._touchState) {
13942
13937
 
@@ -13952,7 +13947,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13952
13947
  });
13953
13948
  if (snapPickResult && snapPickResult.snapped) {
13954
13949
  pointerWorldPos.set(snapPickResult.worldPos);
13955
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
13950
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2$1));
13956
13951
  } else {
13957
13952
  const pickResult = scene.pick({
13958
13953
  canvasPos: touchMoveCanvasPos,
@@ -13960,7 +13955,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13960
13955
  });
13961
13956
  if (pickResult && pickResult.worldPos) {
13962
13957
  pointerWorldPos.set(pickResult.worldPos);
13963
- this.pointerCircle.start(pickResult.canvasPos);
13958
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2$1));
13964
13959
  } else {
13965
13960
  return;
13966
13961
  }
@@ -14067,7 +14062,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14067
14062
  this.pointerLens.cursorPos = snapPickResult.snappedCanvasPos;
14068
14063
  this.pointerLens.snapped = true;
14069
14064
  }
14070
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
14065
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2$1));
14071
14066
  pointerWorldPos.set(snapPickResult.worldPos);
14072
14067
  this._currentAngleMeasurement.corner.worldPos = snapPickResult.worldPos;
14073
14068
  this._currentAngleMeasurement.corner.entity = snapPickResult.entity;
@@ -14089,7 +14084,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14089
14084
  this.pointerLens.cursorPos = pickResult.canvasPos;
14090
14085
  this.pointerLens.snapped = false;
14091
14086
  }
14092
- this.pointerCircle.start(pickResult.canvasPos);
14087
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2$1));
14093
14088
  pointerWorldPos.set(pickResult.worldPos);
14094
14089
  this._currentAngleMeasurement.corner.worldPos = pickResult.worldPos;
14095
14090
  this._currentAngleMeasurement.corner.entity = pickResult.entity;
@@ -14160,7 +14155,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14160
14155
  this.pointerLens.cursorPos = snapPickResult.snappedCanvasPos;
14161
14156
  this.pointerLens.snapped = true;
14162
14157
  }
14163
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
14158
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2$1));
14164
14159
  pointerWorldPos.set(snapPickResult.worldPos);
14165
14160
  this._currentAngleMeasurement.target.worldPos = snapPickResult.worldPos;
14166
14161
  this._currentAngleMeasurement.target.entity = snapPickResult.entity;
@@ -14182,7 +14177,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14182
14177
  this.pointerLens.cursorPos = pickResult.canvasPos;
14183
14178
  this.pointerLens.snapped = false;
14184
14179
  }
14185
- this.pointerCircle.start(pickResult.canvasPos);
14180
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2$1));
14186
14181
  pointerWorldPos.set(pickResult.worldPos);
14187
14182
  this._currentAngleMeasurement.target.worldPos = pickResult.worldPos;
14188
14183
  this._currentAngleMeasurement.target.entity = pickResult.entity;
@@ -14246,14 +14241,11 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14246
14241
  }
14247
14242
 
14248
14243
  const touch = event.touches[0];
14249
- const touchX = touch.clientX;
14250
- const touchY = touch.clientY;
14251
-
14252
14244
  if (touch.identifier !== touchId) {
14253
14245
  return;
14254
14246
  }
14255
14247
 
14256
- touchMoveCanvasPos.set([touchX, touchY]);
14248
+ copyCanvasPos(touch, touchMoveCanvasPos);
14257
14249
 
14258
14250
  let snapPickResult;
14259
14251
  let pickResult;
@@ -14423,9 +14415,6 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14423
14415
  }
14424
14416
 
14425
14417
  const touch = event.changedTouches[0];
14426
- const touchX = touch.clientX;
14427
- const touchY = touch.clientY;
14428
-
14429
14418
  if (touch.identifier !== touchId) {
14430
14419
  return;
14431
14420
  }
@@ -14435,7 +14424,10 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14435
14424
  longTouchTimeout = null;
14436
14425
  }
14437
14426
 
14438
- touchEndCanvasPos.set([touchX, touchY]);
14427
+ copyCanvasPos(touch, touchEndCanvasPos);
14428
+
14429
+ const touchX = touchEndCanvasPos[0];
14430
+ const touchY = touchEndCanvasPos[1];
14439
14431
 
14440
14432
  switch (this._touchState) {
14441
14433
 
@@ -14746,8 +14738,8 @@ class AngleMeasurementEditTouchControl extends AngleMeasurementEditControl {
14746
14738
  }
14747
14739
  }
14748
14740
 
14749
- const tempVec3a$K = math.vec3();
14750
- const tempVec3b$z = math.vec3();
14741
+ const tempVec3a$L = math.vec3();
14742
+ const tempVec3b$A = math.vec3();
14751
14743
  const tempVec3c$v = math.vec3();
14752
14744
 
14753
14745
  /**
@@ -14916,6 +14908,9 @@ class Annotation extends Marker {
14916
14908
  addContextMenuListener(this._marker, e => {
14917
14909
  e.preventDefault();
14918
14910
  this.plugin.fire("contextmenu", this);
14911
+ }, e => {
14912
+ e.preventDefault();
14913
+ this.plugin.fire("markerClicked", this);
14919
14914
  });
14920
14915
  this._marker.addEventListener("mouseenter", () => {
14921
14916
  this.plugin.fire("markerMouseEnter", this);
@@ -14993,9 +14988,9 @@ class Annotation extends Marker {
14993
14988
  if (!pickResult.worldPos || !pickResult.worldNormal) {
14994
14989
  this.error("Param 'pickResult' does not have both worldPos and worldNormal");
14995
14990
  } else {
14996
- const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$K);
14991
+ const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$L);
14997
14992
  const offset = (this.plugin && this.plugin.surfaceOffset) || 0;
14998
- const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b$z);
14993
+ const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b$A);
14999
14994
  const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c$v);
15000
14995
  this.entity = pickResult.entity;
15001
14996
  this.worldPos = offsetWorldPos;
@@ -17865,7 +17860,7 @@ class OcclusionLayer {
17865
17860
  const MARKER_COLOR = math.vec3([1.0, 0.0, 0.0]);
17866
17861
  const POINT_SIZE = 20;
17867
17862
 
17868
- const tempVec3a$J = math.vec3();
17863
+ const tempVec3a$K = math.vec3();
17869
17864
 
17870
17865
  /**
17871
17866
  * Manages occlusion testing. Private member of a Renderer.
@@ -18204,7 +18199,7 @@ class OcclusionTester {
18204
18199
  gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
18205
18200
  if (active) {
18206
18201
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
18207
- gl.uniform3fv(sectionPlaneUniforms.pos, getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$J));
18202
+ gl.uniform3fv(sectionPlaneUniforms.pos, getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$K));
18208
18203
  gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
18209
18204
  }
18210
18205
  }
@@ -20304,6 +20299,9 @@ const Renderer$1 = function (scene, options) {
20304
20299
  pickProjMatrix = scene.camera.projMatrix;
20305
20300
  projection = scene.camera.projection;
20306
20301
 
20302
+ nearAndFar[0] = scene.camera.project.near;
20303
+ nearAndFar[1] = scene.camera.project.far;
20304
+
20307
20305
  pickResult.canvasPos = params.canvasPos;
20308
20306
 
20309
20307
  } else {
@@ -20317,6 +20315,9 @@ const Renderer$1 = function (scene, options) {
20317
20315
  pickProjMatrix = scene.camera.projMatrix;
20318
20316
  projection = scene.camera.projection;
20319
20317
 
20318
+ nearAndFar[0] = scene.camera.project.near;
20319
+ nearAndFar[1] = scene.camera.project.far;
20320
+
20320
20321
  } else {
20321
20322
 
20322
20323
  worldRayOrigin.set(params.origin || [0, 0, 0]);
@@ -20336,6 +20337,9 @@ const Renderer$1 = function (scene, options) {
20336
20337
  pickProjMatrix = scene.camera.ortho.matrix;
20337
20338
  projection = "ortho";
20338
20339
 
20340
+ nearAndFar[0] = scene.camera.ortho.near;
20341
+ nearAndFar[1] = scene.camera.ortho.far;
20342
+
20339
20343
  pickResult.origin = worldRayOrigin;
20340
20344
  pickResult.direction = worldRayDir;
20341
20345
  }
@@ -20390,9 +20394,6 @@ const Renderer$1 = function (scene, options) {
20390
20394
 
20391
20395
  if (pickable.canPickWorldPos && pickable.canPickWorldPos()) {
20392
20396
 
20393
- nearAndFar[0] = scene.camera.project.near;
20394
- nearAndFar[1] = scene.camera.project.far;
20395
-
20396
20397
  gpuPickWorldPos(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult);
20397
20398
 
20398
20399
  if (params.pickSurfaceNormal !== false) {
@@ -23810,12 +23811,12 @@ class CustomProjection extends Component {
23810
23811
  }
23811
23812
 
23812
23813
  const tempVec3$6 = math.vec3();
23813
- const tempVec3b$y = math.vec3();
23814
+ const tempVec3b$z = math.vec3();
23814
23815
  const tempVec3c$u = math.vec3();
23815
23816
  const tempVec3d$d = math.vec3();
23816
23817
  const tempVec3e$2 = math.vec3();
23817
23818
  const tempVec3f$2 = math.vec3();
23818
- const tempVec4a$a = math.vec4();
23819
+ const tempVec4a$b = math.vec4();
23819
23820
  const tempVec4b$6 = math.vec4();
23820
23821
  const tempVec4c$2 = math.vec4();
23821
23822
  const tempMat = math.mat4();
@@ -24123,7 +24124,7 @@ class Camera extends Component {
24123
24124
  orbitYaw(angleInc) {
24124
24125
  let lookEyeVec = math.subVec3(this._eye, this._look, tempVec3$6);
24125
24126
  math.rotationMat4v(angleInc * 0.0174532925, this._gimbalLock ? this._worldUp : this._up, tempMat);
24126
- lookEyeVec = math.transformPoint3(tempMat, lookEyeVec, tempVec3b$y);
24127
+ lookEyeVec = math.transformPoint3(tempMat, lookEyeVec, tempVec3b$z);
24127
24128
  this.eye = math.addVec3(this._look, lookEyeVec, tempVec3c$u); // Set eye position as 'look' plus 'eye' vector
24128
24129
  this.up = math.transformPoint3(tempMat, this._up, tempVec3d$d); // Rotate 'up' vector
24129
24130
  }
@@ -24141,7 +24142,7 @@ class Camera extends Component {
24141
24142
  }
24142
24143
  }
24143
24144
  let eye2 = math.subVec3(this._eye, this._look, tempVec3$6);
24144
- const left = math.cross3Vec3(math.normalizeVec3(eye2, tempVec3b$y), math.normalizeVec3(this._up, tempVec3c$u));
24145
+ const left = math.cross3Vec3(math.normalizeVec3(eye2, tempVec3b$z), math.normalizeVec3(this._up, tempVec3c$u));
24145
24146
  math.rotationMat4v(angleInc * 0.0174532925, left, tempMat);
24146
24147
  eye2 = math.transformPoint3(tempMat, eye2, tempVec3d$d);
24147
24148
  this.up = math.transformPoint3(tempMat, this._up, tempVec3e$2);
@@ -24156,7 +24157,7 @@ class Camera extends Component {
24156
24157
  yaw(angleInc) {
24157
24158
  let look2 = math.subVec3(this._look, this._eye, tempVec3$6);
24158
24159
  math.rotationMat4v(angleInc * 0.0174532925, this._gimbalLock ? this._worldUp : this._up, tempMat);
24159
- look2 = math.transformPoint3(tempMat, look2, tempVec3b$y);
24160
+ look2 = math.transformPoint3(tempMat, look2, tempVec3b$z);
24160
24161
  this.look = math.addVec3(look2, this._eye, tempVec3c$u);
24161
24162
  if (this._gimbalLock) {
24162
24163
  this.up = math.transformPoint3(tempMat, this._up, tempVec3d$d);
@@ -24176,7 +24177,7 @@ class Camera extends Component {
24176
24177
  }
24177
24178
  }
24178
24179
  let look2 = math.subVec3(this._look, this._eye, tempVec3$6);
24179
- const left = math.cross3Vec3(math.normalizeVec3(look2, tempVec3b$y), math.normalizeVec3(this._up, tempVec3c$u));
24180
+ const left = math.cross3Vec3(math.normalizeVec3(look2, tempVec3b$z), math.normalizeVec3(this._up, tempVec3c$u));
24180
24181
  math.rotationMat4v(angleInc * 0.0174532925, left, tempMat);
24181
24182
  this.up = math.transformPoint3(tempMat, this._up, tempVec3f$2);
24182
24183
  look2 = math.transformPoint3(tempMat, look2, tempVec3d$d);
@@ -24193,7 +24194,7 @@ class Camera extends Component {
24193
24194
  const vec = [0, 0, 0];
24194
24195
  let v;
24195
24196
  if (pan[0] !== 0) {
24196
- const left = math.cross3Vec3(math.normalizeVec3(eye2, []), math.normalizeVec3(this._up, tempVec3b$y));
24197
+ const left = math.cross3Vec3(math.normalizeVec3(eye2, []), math.normalizeVec3(this._up, tempVec3b$z));
24197
24198
  v = math.mulVec3Scalar(left, pan[0]);
24198
24199
  vec[0] += v[0];
24199
24200
  vec[1] += v[1];
@@ -24222,7 +24223,7 @@ class Camera extends Component {
24222
24223
  */
24223
24224
  zoom(delta) {
24224
24225
  const vec = math.subVec3(this._eye, this._look, tempVec3$6);
24225
- const lenLook = Math.abs(math.lenVec3(vec, tempVec3b$y));
24226
+ const lenLook = Math.abs(math.lenVec3(vec, tempVec3b$z));
24226
24227
  const newLenLook = Math.abs(lenLook + delta);
24227
24228
  if (newLenLook < 0.5) {
24228
24229
  return;
@@ -24681,7 +24682,7 @@ class Camera extends Component {
24681
24682
  * @returns {[number, number]} the canvas position
24682
24683
  */
24683
24684
  projectWorldPos(worldPos) {
24684
- const _worldPos = tempVec4a$a;
24685
+ const _worldPos = tempVec4a$b;
24685
24686
  const viewPos = tempVec4b$6;
24686
24687
  const screenPos = tempVec4c$2;
24687
24688
  _worldPos[0] = worldPos[0];
@@ -34766,7 +34767,7 @@ function buildFragmentDraw(mesh) {
34766
34767
  * @author xeolabs / https://github.com/xeolabs
34767
34768
  */
34768
34769
 
34769
- const tempVec3a$I = math.vec3();
34770
+ const tempVec3a$J = math.vec3();
34770
34771
 
34771
34772
  const ids$2 = new Map$1({});
34772
34773
 
@@ -34868,7 +34869,7 @@ DrawRenderer.prototype.drawMesh = function (frameCtx, mesh) {
34868
34869
  if (active) {
34869
34870
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
34870
34871
  if (origin) {
34871
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$I);
34872
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$J);
34872
34873
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
34873
34874
  } else {
34874
34875
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -36014,7 +36015,7 @@ function buildFragment$5(mesh) {
36014
36015
 
36015
36016
  const ids$1 = new Map$1({});
36016
36017
 
36017
- const tempVec3a$H = math.vec3();
36018
+ const tempVec3a$I = math.vec3();
36018
36019
 
36019
36020
  /**
36020
36021
  * @private
@@ -36101,7 +36102,7 @@ EmphasisFillRenderer.prototype.drawMesh = function (frameCtx, mesh, mode) {
36101
36102
  if (active) {
36102
36103
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
36103
36104
  if (origin) {
36104
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$H);
36105
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$I);
36105
36106
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
36106
36107
  } else {
36107
36108
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -36445,7 +36446,7 @@ function buildFragment$4(mesh) {
36445
36446
 
36446
36447
  const ids = new Map$1({});
36447
36448
 
36448
- const tempVec3a$G = math.vec3();
36449
+ const tempVec3a$H = math.vec3();
36449
36450
 
36450
36451
  /**
36451
36452
  * @private
@@ -36531,7 +36532,7 @@ EmphasisEdgesRenderer.prototype.drawMesh = function (frameCtx, mesh, mode) {
36531
36532
  if (active) {
36532
36533
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
36533
36534
  if (origin) {
36534
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$G);
36535
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$H);
36535
36536
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
36536
36537
  } else {
36537
36538
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -36844,7 +36845,7 @@ function buildFragment$3(mesh) {
36844
36845
  * @author xeolabs / https://github.com/xeolabs
36845
36846
  */
36846
36847
 
36847
- const tempVec3a$F = math.vec3();
36848
+ const tempVec3a$G = math.vec3();
36848
36849
 
36849
36850
  // No ID, because there is exactly one PickMeshRenderer per scene
36850
36851
 
@@ -36931,7 +36932,7 @@ PickMeshRenderer.prototype.drawMesh = function (frameCtx, mesh) {
36931
36932
  if (active) {
36932
36933
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
36933
36934
  if (origin) {
36934
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$F);
36935
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$G);
36935
36936
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
36936
36937
  } else {
36937
36938
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -37183,7 +37184,7 @@ function buildFragment$2(mesh) {
37183
37184
  * @author xeolabs / https://github.com/xeolabs
37184
37185
  */
37185
37186
 
37186
- const tempVec3a$E = math.vec3();
37187
+ const tempVec3a$F = math.vec3();
37187
37188
 
37188
37189
  /**
37189
37190
  * @private
@@ -37278,7 +37279,7 @@ PickTriangleRenderer.prototype.drawMesh = function (frameCtx, mesh) {
37278
37279
  if (active) {
37279
37280
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
37280
37281
  if (origin) {
37281
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$E);
37282
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$F);
37282
37283
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
37283
37284
  } else {
37284
37285
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -37527,7 +37528,7 @@ function buildFragment$1(mesh) {
37527
37528
  * @author xeolabs / https://github.com/xeolabs
37528
37529
  */
37529
37530
 
37530
- const tempVec3a$D = math.vec3();
37531
+ const tempVec3a$E = math.vec3();
37531
37532
 
37532
37533
  // No ID, because there is exactly one PickMeshRenderer per scene
37533
37534
 
@@ -37642,7 +37643,7 @@ OcclusionRenderer.prototype.drawMesh = function (frameCtx, mesh) {
37642
37643
  if (active) {
37643
37644
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
37644
37645
  if (origin) {
37645
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$D);
37646
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$E);
37646
37647
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
37647
37648
  } else {
37648
37649
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -42887,7 +42888,12 @@ class AxisGizmoPlugin extends Plugin {
42887
42888
  }
42888
42889
  }
42889
42890
 
42890
- math.vec3();
42891
+ const tempVec3a$D = math.vec3();
42892
+ const tempVec3b$y = math.vec3();
42893
+ const tempVec4a$a = math.vec4();
42894
+ const front = math.vec3([0, 0, -1]);
42895
+ const back = math.vec3([0, 0, 1]);
42896
+ const up = math.vec3([0, 1, 0]);
42891
42897
 
42892
42898
  /**
42893
42899
  * @desc An arbitrarily-aligned World-space clipping plane.
@@ -42959,6 +42965,8 @@ class SectionPlane extends Component {
42959
42965
  this._state = new RenderState({
42960
42966
  active: true,
42961
42967
  pos: math.vec3(),
42968
+ quaternion: math.vec4(),
42969
+ roll: 0,
42962
42970
  dir: math.vec3(),
42963
42971
  dist: 0
42964
42972
  });
@@ -43020,6 +43028,59 @@ class SectionPlane extends Component {
43020
43028
  return this._state.pos;
43021
43029
  }
43022
43030
 
43031
+ /**
43032
+ * Sets the quaternion of this SectionPlane's plane.
43033
+ *
43034
+ * Default value is ````[0, -1, 0, 0]````.
43035
+ *
43036
+ * @param {Number[]} value New quaternion.
43037
+ */
43038
+ set quaternion(value) {
43039
+ this._state.quaternion.set(value || [0, 0, 0, -1]);
43040
+ math.vec3ApplyQuaternion(this._state.quaternion, back, this._state.dir);
43041
+ const quatUp = math.vec3ApplyQuaternion(this._state.quaternion, up, tempVec3a$D);
43042
+ const dirOnlyQ = math.vec3PairToQuaternion(back, this._state.dir, tempVec4a$a);
43043
+ const dirOnlyUp = math.vec3ApplyQuaternion(dirOnlyQ, up, tempVec3b$y);
43044
+ const angle = Math.acos(Math.min(1, math.dotVec3(quatUp, dirOnlyUp)));
43045
+ const sign = Math.sign(math.dotVec3(this._state.dir, math.cross3Vec3(quatUp, dirOnlyUp, tempVec3b$y)));
43046
+ this._state.roll = sign * angle;
43047
+ this._onDirUpdated();
43048
+ }
43049
+
43050
+ /**
43051
+ * Gets the quaternion of this SectionPlane's plane.
43052
+ *
43053
+ * Default value is ````[0, -1, 0, 0]````.
43054
+ *
43055
+ * @returns {Number[]} value Current quaternion.
43056
+ */
43057
+ get quaternion() {
43058
+ return this._state.quaternion;
43059
+ }
43060
+
43061
+ /**
43062
+ * Sets the roll of this SectionPlane's plane.
43063
+ *
43064
+ * Default value is ````0````.
43065
+ *
43066
+ * @param {Number[]} value New roll.
43067
+ */
43068
+ set roll(value) {
43069
+ this._state.roll = value || 0;
43070
+ this._onDirRollUpdated();
43071
+ }
43072
+
43073
+ /**
43074
+ * Gets the roll of this SectionPlane's plane.
43075
+ *
43076
+ * Default value is ````0````.
43077
+ *
43078
+ * @returns {Number[]} value Current roll.
43079
+ */
43080
+ get roll() {
43081
+ return this._state.roll;
43082
+ }
43083
+
43023
43084
  /**
43024
43085
  * Sets the direction of this SectionPlane's plane.
43025
43086
  *
@@ -43028,7 +43089,25 @@ class SectionPlane extends Component {
43028
43089
  * @param {Number[]} value New direction.
43029
43090
  */
43030
43091
  set dir(value) {
43031
- this._state.dir.set(value || [0, 0, -1]);
43092
+ this._state.dir.set(value || front);
43093
+ this._onDirRollUpdated();
43094
+ }
43095
+
43096
+ _onDirRollUpdated() {
43097
+ math.vec3PairToQuaternion(back, this._state.dir, this._state.quaternion);
43098
+
43099
+ tempVec4a$a[0] = 0;
43100
+ tempVec4a$a[1] = 0;
43101
+ tempVec4a$a[2] = -1;
43102
+ tempVec4a$a[3] = this._state.roll;
43103
+ math.angleAxisToQuaternion(tempVec4a$a, tempVec4a$a);
43104
+
43105
+ math.mulQuaternions(this._state.quaternion, tempVec4a$a, this._state.quaternion);
43106
+
43107
+ this._onDirUpdated();
43108
+ }
43109
+
43110
+ _onDirUpdated() {
43032
43111
  this._state.dist = (-math.dotVec3(this._state.pos, this._state.dir));
43033
43112
  this.glRedraw();
43034
43113
  this.fire("dir", this._state.dir);
@@ -52685,7 +52764,10 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
52685
52764
  }
52686
52765
 
52687
52766
  if (scene.logarithmicDepthBufferEnabled) {
52688
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
52767
+ src.push(" float dx = dFdx(vFragDepth);");
52768
+ src.push(" float dy = dFdy(vFragDepth);");
52769
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
52770
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
52689
52771
  }
52690
52772
 
52691
52773
  if (this._withSAO) {
@@ -58036,7 +58118,10 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
58036
58118
  }
58037
58119
 
58038
58120
  if (scene.logarithmicDepthBufferEnabled) {
58039
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
58121
+ src.push(" float dx = dFdx(vFragDepth);");
58122
+ src.push(" float dy = dFdy(vFragDepth);");
58123
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
58124
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
58040
58125
  }
58041
58126
 
58042
58127
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -66120,7 +66205,7 @@ class VBOInstancingLinesLayer {
66120
66205
 
66121
66206
  let pickFlag = (visible && !culled && pickable) ? RENDER_PASSES.PICK : RENDER_PASSES.NOT_RENDERED;
66122
66207
 
66123
- const clippableFlag = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 255 : 0;
66208
+ const clippableFlag = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 1 : 0;
66124
66209
 
66125
66210
  let vertFlag = 0;
66126
66211
  vertFlag |= colorFlag;
@@ -80697,8 +80782,7 @@ class DTXTrianglesLayer {
80697
80782
  worldPos[2] = positions[i + 2];
80698
80783
  worldPos[3] = 1.0;
80699
80784
  math.decompressPosition(worldPos, positionsDecodeMatrix);
80700
- math.transformPoint4(this.model.worldMatrix, worldPos, worldPos);
80701
- math.transformPoint4(this.model.worldMatrix, worldPos, worldPos);
80785
+ math.mulMat4v4(this.model.worldMatrix, worldPos, worldPos);
80702
80786
  worldPos[0] += offsetX;
80703
80787
  worldPos[1] += offsetY;
80704
80788
  worldPos[2] += offsetZ;
@@ -84482,6 +84566,7 @@ class SceneModel extends Component {
84482
84566
  set matrix(value) {
84483
84567
  this._matrix.set(value || DEFAULT_MATRIX);
84484
84568
  math.decomposeMat4(this._matrix, this._position, this._quaternion, this._scale);
84569
+ math.quaternionToEuler(this._quaternion, "XYZ", this._rotation);
84485
84570
  this._matrixDirty = false;
84486
84571
  this._setWorldMatrixDirty();
84487
84572
  this._sceneModelDirty();
@@ -89874,6 +89959,8 @@ const WAITING_FOR_TARGET_LONG_TOUCH_END = 5;
89874
89959
 
89875
89960
  const TOUCH_CANCELING = 7;
89876
89961
 
89962
+ const tmpVec2 = math.vec2();
89963
+
89877
89964
  /**
89878
89965
  * Creates {@link DistanceMeasurement}s from touch input.
89879
89966
  *
@@ -90020,6 +90107,19 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90020
90107
  this._touchState = WAITING_FOR_ORIGIN_TOUCH_START;
90021
90108
  };
90022
90109
 
90110
+ const copyCanvasPos = (event, dst) => {
90111
+ dst[0] = event.clientX;
90112
+ dst[1] = event.clientY;
90113
+ transformToNode(canvas.ownerDocument.documentElement, canvas, dst);
90114
+ return dst;
90115
+ };
90116
+
90117
+ const toBodyPos = (pos, dst) => {
90118
+ dst.set(pos);
90119
+ transformToNode(canvas, canvas.ownerDocument.documentElement, dst);
90120
+ return dst;
90121
+ };
90122
+
90023
90123
  canvas.addEventListener("touchstart", this._onCanvasTouchStart = (event) => {
90024
90124
 
90025
90125
  const currentNumTouches = event.touches.length;
@@ -90033,16 +90133,8 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90033
90133
  }
90034
90134
 
90035
90135
  const touch = event.touches[0];
90036
-
90037
- // Get the canvas's bounding rectangle
90038
- const rect = canvas.getBoundingClientRect();
90039
-
90040
- // Calculate the touch position relative to the canvas
90041
- const touchX = touch.clientX - rect.left;
90042
- const touchY = touch.clientY - rect.top;
90043
-
90044
- touchStartCanvasPos.set([touchX, touchY]);
90045
- touchMoveCanvasPos.set([touchX, touchY]);
90136
+ copyCanvasPos(touch, touchStartCanvasPos);
90137
+ touchMoveCanvasPos.set(touchStartCanvasPos);
90046
90138
 
90047
90139
  switch (this._touchState) {
90048
90140
 
@@ -90058,7 +90150,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90058
90150
  });
90059
90151
  if (snapPickResult && snapPickResult.snapped) {
90060
90152
  pointerWorldPos.set(snapPickResult.worldPos);
90061
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
90153
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2));
90062
90154
  } else {
90063
90155
  const pickResult = scene.pick({
90064
90156
  canvasPos: touchMoveCanvasPos,
@@ -90066,7 +90158,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90066
90158
  });
90067
90159
  if (pickResult && pickResult.worldPos) {
90068
90160
  pointerWorldPos.set(pickResult.worldPos);
90069
- this.pointerCircle.start(pickResult.canvasPos);
90161
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2));
90070
90162
  } else {
90071
90163
  return;
90072
90164
  }
@@ -90170,7 +90262,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90170
90262
  this.pointerLens.cursorPos = snapPickResult.snappedCanvasPos;
90171
90263
  this.pointerLens.snapped = true;
90172
90264
  }
90173
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
90265
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2));
90174
90266
  pointerWorldPos.set(snapPickResult.worldPos);
90175
90267
  this._currentDistanceMeasurement.target.worldPos = snapPickResult.worldPos;
90176
90268
  this._currentDistanceMeasurement.target.entity = snapPickResult.entity;
@@ -90188,7 +90280,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90188
90280
  this.pointerLens.cursorPos = pickResult.canvasPos;
90189
90281
  this.pointerLens.snapped = false;
90190
90282
  }
90191
- this.pointerCircle.start(pickResult.canvasPos);
90283
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2));
90192
90284
  pointerWorldPos.set(pickResult.worldPos);
90193
90285
  this._currentDistanceMeasurement.target.worldPos = pickResult.worldPos;
90194
90286
  this._currentDistanceMeasurement.target.entity = pickResult.entity;
@@ -90247,19 +90339,11 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90247
90339
  }
90248
90340
 
90249
90341
  const touch = event.touches[0];
90250
-
90251
- // Get the canvas's bounding rectangle
90252
- const rect = canvas.getBoundingClientRect();
90253
-
90254
- // Calculate the touch position relative to the canvas
90255
- const touchX = touch.clientX - rect.left;
90256
- const touchY = touch.clientY - rect.top;
90257
-
90258
90342
  if (touch.identifier !== touchId) {
90259
90343
  return;
90260
90344
  }
90261
90345
 
90262
- touchMoveCanvasPos.set([touchX, touchY]);
90346
+ copyCanvasPos(touch, touchMoveCanvasPos);
90263
90347
 
90264
90348
  let snapPickResult;
90265
90349
  let pickResult;
@@ -90421,14 +90505,6 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90421
90505
  }
90422
90506
 
90423
90507
  const touch = event.changedTouches[0];
90424
-
90425
- // Get the canvas's bounding rectangle
90426
- const rect = canvas.getBoundingClientRect();
90427
-
90428
- // Calculate the touch position relative to the canvas
90429
- const touchX = touch.clientX - rect.left;
90430
- const touchY = touch.clientY - rect.top;
90431
-
90432
90508
  if (touch.identifier !== touchId) {
90433
90509
  return;
90434
90510
  }
@@ -90438,7 +90514,10 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90438
90514
  longTouchTimeout = null;
90439
90515
  }
90440
90516
 
90441
- touchEndCanvasPos.set([touchX, touchY]);
90517
+ copyCanvasPos(touch, touchEndCanvasPos);
90518
+
90519
+ const touchX = touchEndCanvasPos[0];
90520
+ const touchY = touchEndCanvasPos[1];
90442
90521
 
90443
90522
  switch (this._touchState) {
90444
90523
 
@@ -93263,7 +93342,7 @@ CameraPathAnimation.PLAYING_TO = 3;
93263
93342
  const tempVec3$3 = math.vec3();
93264
93343
  const tempVec3b$5 = math.vec3();
93265
93344
  math.vec3();
93266
- const zeroVec$2 = math.vec3([0, -1, 0]);
93345
+ const zeroVec$1 = math.vec3([0, -1, 0]);
93267
93346
  const tempQuat = math.vec4([0, 0, 0, 1]);
93268
93347
 
93269
93348
  /**
@@ -93690,7 +93769,7 @@ class ImagePlane extends Component {
93690
93769
 
93691
93770
  math.normalizeVec3(negDir);
93692
93771
  math.mulVec3Scalar(negDir, dist, tempVec3b$5);
93693
- math.vec3PairToQuaternion(zeroVec$2, dir, tempQuat);
93772
+ math.vec3PairToQuaternion(zeroVec$1, dir, tempQuat);
93694
93773
 
93695
93774
  this._node.quaternion = tempQuat;
93696
93775
  }
@@ -120729,9 +120808,6 @@ class OBJLoaderPlugin extends Plugin {
120729
120808
  }
120730
120809
  }
120731
120810
 
120732
- const zeroVec$1 = new Float64Array([0, 0, 1]);
120733
- const quat$1 = new Float64Array(4);
120734
-
120735
120811
  /**
120736
120812
  * Controls a {@link SectionPlane} with mouse and touch input.
120737
120813
  *
@@ -120849,15 +120925,13 @@ class Control {
120849
120925
  });
120850
120926
 
120851
120927
  const handlers = { };
120852
- const addAxis = (rgb, axisDirection, hoopDirection) => {
120928
+ const addAxis = (rgb, hoopRot) => {
120929
+ math.mulVec3Scalar(rgb, -1, math.vec3());
120853
120930
  const material = colorMaterial(rgb);
120854
120931
 
120855
- const rotateToHorizontal = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
120856
- const hoopRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], hoopDirection), math.identityMat4());
120857
- const hoopMatrix = math.mulMat4(hoopRotation, rotateToHorizontal, math.identityMat4());
120858
-
120932
+ const hoopMatrix = math.quaternionToRotationMat4(hoopRot, math.identityMat4());
120933
+ math.mulMat4(math.rotationMat4v(Math.PI, [0,1,0], math.mat4()), hoopMatrix, hoopMatrix);
120859
120934
  const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
120860
-
120861
120935
  const scaledArrowMatrix = (t, matR) => {
120862
120936
  const matT = math.translateMat4v(t, math.identityMat4());
120863
120937
  const ret = math.identityMat4();
@@ -120926,7 +121000,8 @@ class Control {
120926
121000
  }), NO_STATE_INHERIT);
120927
121001
 
120928
121002
 
120929
- const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], axisDirection), math.identityMat4());
121003
+ const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], rgb), math.identityMat4());
121004
+ math.mulMat4(math.rotationMat4v(Math.PI, [0,1,0], math.mat4()), axisRotation, axisRotation);
120930
121005
 
120931
121006
  const translatedAxisMatrix = (yOffset) => math.mulMat4(axisRotation, math.translateMat4c(0, yOffset, 0, math.identityMat4()), math.identityMat4());
120932
121007
  const arrowMatrix = translatedAxisMatrix(arrowLength + .1);
@@ -120987,8 +121062,10 @@ class Control {
120987
121062
  isObject: false
120988
121063
  }), NO_STATE_INHERIT);
120989
121064
 
121065
+ const localToWorldVec = (localVec, worldVec) => math.vec3ApplyQuaternion(rootNode.quaternion, localVec, worldVec);
121066
+
120990
121067
  const closestPointOnAxis = (function() {
120991
- const worldAxis = math.vec4();
121068
+ const worldAxis = math.vec3();
120992
121069
  const org = math.vec3();
120993
121070
  const dir = math.vec3();
120994
121071
  return (canvasPos, dst) => {
@@ -121023,22 +121100,39 @@ class Control {
121023
121100
  if (closestPointOnAxis(canvasPos, tempVec3)) {
121024
121101
  math.subVec3(tempVec3, initOffset, tempVec3);
121025
121102
  setPos(tempVec3);
121026
- if (self._sectionPlane) {
121027
- self._sectionPlane.pos = tempVec3;
121103
+ if (this._sectionPlane) {
121104
+ this._sectionPlane.pos = tempVec3;
121028
121105
  }
121029
121106
  }
121030
121107
  });
121031
121108
  }
121032
121109
  };
121033
121110
 
121034
- const lastCanvasPos = math.vec2();
121035
121111
  handlers[rotateHandle.id] = {
121036
121112
  setActivated: a => hoop.visible = a,
121037
121113
  initDragAction: (initCanvasPos) => {
121038
- lastCanvasPos.set(initCanvasPos);
121114
+ const rotationFromCanvasPos = (function() {
121115
+ const planeCanvasPos = camera.projectWorldPos(pos);
121116
+ localToWorldVec(rgb, tempVec3);
121117
+ math.transformVec3(camera.normalMatrix, tempVec3, tempVec3);
121118
+ const axisCoeff = Math.sign(tempVec3[2]);
121119
+ return (canvasPos) => {
121120
+ const dx = canvasPos[0] - planeCanvasPos[0];
121121
+ const dy = canvasPos[1] - planeCanvasPos[1];
121122
+ return axisCoeff * Math.atan2(-dy, dx);
121123
+ };
121124
+ })();
121125
+
121126
+ let lastRotation = rotationFromCanvasPos(initCanvasPos);
121127
+
121039
121128
  return canvasPos => {
121040
- dragRotateSectionPlane(rgb, lastCanvasPos, canvasPos);
121041
- lastCanvasPos.set(canvasPos);
121129
+ const rotation = rotationFromCanvasPos(canvasPos);
121130
+ rootNode.rotate(rgb, (rotation - lastRotation) * 180 / Math.PI);
121131
+ if (this._sectionPlane) {
121132
+ ignoreNextSectionPlaneDirUpdate = true;
121133
+ this._sectionPlane.quaternion = rootNode.quaternion;
121134
+ }
121135
+ lastRotation = rotation;
121042
121136
  };
121043
121137
  }
121044
121138
  };
@@ -121150,9 +121244,9 @@ class Control {
121150
121244
  //
121151
121245
  //----------------------------------------------------------------------------------------------------------
121152
121246
 
121153
- addAxis([1,0,0], [ 1, 0, 0 ], [ 1, 0, 0 ]),
121154
- addAxis([0,1,0], [ 0, -1, 0 ], [ 0, 1, 0 ]),
121155
- addAxis([0,0,1], [ 0, 0, -1 ], [ 0, 0, -1 ])
121247
+ addAxis([1,0,0], math.vec3PairToQuaternion([1,0,0], [0,0,1])),
121248
+ addAxis([0,1,0], math.eulerToQuaternion([90,0,0], "XYZ")),
121249
+ addAxis([0,0,1], math.identityQuaternion())
121156
121250
  ];
121157
121251
 
121158
121252
  const cleanups = [ ];
@@ -121174,101 +121268,6 @@ class Control {
121174
121268
  cleanups.push(() => scene.off(onSceneTick));
121175
121269
  }
121176
121270
 
121177
- const localToWorldVec = (function () {
121178
- const mat = math.mat4();
121179
- return function (localVec, worldVec) {
121180
- math.quaternionToMat4(rootNode.quaternion, mat);
121181
- math.transformVec3(mat, localVec, worldVec);
121182
- math.normalizeVec3(worldVec);
121183
- return worldVec;
121184
- };
121185
- })();
121186
-
121187
- const getTranslationPlane = (worldAxis, planeNormal) => {
121188
- const absX = Math.abs(worldAxis[0]);
121189
- if (absX > Math.abs(worldAxis[1]) && absX > Math.abs(worldAxis[2])) {
121190
- math.cross3Vec3(worldAxis, [0, 1, 0], planeNormal);
121191
- } else {
121192
- math.cross3Vec3(worldAxis, [1, 0, 0], planeNormal);
121193
- }
121194
- math.cross3Vec3(planeNormal, worldAxis, planeNormal);
121195
- math.normalizeVec3(planeNormal);
121196
- };
121197
-
121198
- const self = this;
121199
- var dragRotateSectionPlane = (function () {
121200
- const p1 = math.vec4();
121201
- const p2 = math.vec4();
121202
- const c = math.vec4();
121203
- const worldAxis = math.vec4();
121204
- const dir = math.vec3();
121205
- const mat = math.mat4();
121206
- const planeNormal = math.vec3();
121207
- return function (baseAxis, fromMouse, toMouse) {
121208
- localToWorldVec(baseAxis, worldAxis);
121209
- const hasData = getPointerPlaneIntersect(fromMouse, worldAxis, p1) && getPointerPlaneIntersect(toMouse, worldAxis, p2);
121210
- if (!hasData) { // Find intersections with view plane and project down to origin
121211
- getTranslationPlane(worldAxis, planeNormal);
121212
- getPointerPlaneIntersect(fromMouse, planeNormal, p1, 1); // Ensure plane moves closer to camera so angles become workable
121213
- getPointerPlaneIntersect(toMouse, planeNormal, p2, 1);
121214
- var dot = math.dotVec3(p1, worldAxis);
121215
- p1[0] -= dot * worldAxis[0];
121216
- p1[1] -= dot * worldAxis[1];
121217
- p1[2] -= dot * worldAxis[2];
121218
- dot = math.dotVec3(p2, worldAxis);
121219
- p2[0] -= dot * worldAxis[0];
121220
- p2[1] -= dot * worldAxis[1];
121221
- p2[2] -= dot * worldAxis[2];
121222
- }
121223
- math.normalizeVec3(p1);
121224
- math.normalizeVec3(p2);
121225
- dot = math.dotVec3(p1, p2);
121226
- dot = math.clamp(dot, -1.0, 1.0); // Rounding errors cause dot to exceed allowed range
121227
- var incDegrees = Math.acos(dot) * math.RADTODEG;
121228
- math.cross3Vec3(p1, p2, c);
121229
- if (math.dotVec3(c, worldAxis) < 0.0) {
121230
- incDegrees = -incDegrees;
121231
- }
121232
- rootNode.rotate(baseAxis, incDegrees);
121233
-
121234
- if (self._sectionPlane) {
121235
- math.quaternionToMat4(rootNode.quaternion, mat); // << ---
121236
- math.transformVec3(mat, [0, 0, 1], dir);
121237
- ignoreNextSectionPlaneDirUpdate = true;
121238
- self._sectionPlane.dir = dir;
121239
- }
121240
- };
121241
- })();
121242
-
121243
- var getPointerPlaneIntersect = (function () {
121244
- const dir = math.vec4([0, 0, 0, 1]);
121245
- const matrix = math.mat4();
121246
- return function (mouse, axis, dest, offset) {
121247
- offset = offset || 0;
121248
- dir[0] = mouse[0] / canvas.width * 2.0 - 1.0;
121249
- dir[1] = -(mouse[1] / canvas.height * 2.0 - 1.0);
121250
- dir[2] = 0.0;
121251
- dir[3] = 1.0;
121252
- math.mulMat4(camera.projMatrix, camera.viewMatrix, matrix); // Unproject norm device coords to view coords
121253
- math.inverseMat4(matrix);
121254
- math.transformVec4(matrix, dir, dir);
121255
- math.mulVec4Scalar(dir, 1.0 / dir[3]); // This is now point A on the ray in world space
121256
- var rayO = camera.eye; // The direction
121257
- math.subVec4(dir, rayO, dir);
121258
- const origin = self._sectionPlane.pos; // Plane origin:
121259
- var d = -math.dotVec3(origin, axis) - offset;
121260
- var dot = math.dotVec3(axis, dir);
121261
- if (Math.abs(dot) > 0.005) {
121262
- var t = -(math.dotVec3(axis, rayO) + d) / dot;
121263
- math.mulVec3Scalar(dir, t, dest);
121264
- math.addVec3(dest, rayO);
121265
- math.subVec3(dest, origin, dest);
121266
- return true;
121267
- }
121268
- return false;
121269
- };
121270
- })();
121271
-
121272
121271
  {
121273
121272
  let deactivateActive = null;
121274
121273
  let currentDrag = null;
@@ -121385,7 +121384,7 @@ class Control {
121385
121384
  this.id = sectionPlane.id;
121386
121385
  this._sectionPlane = sectionPlane;
121387
121386
  const setPosFromSectionPlane = () => setPos(sectionPlane.pos);
121388
- const setDirFromSectionPlane = () => rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$1, sectionPlane.dir, quat$1);
121387
+ const setDirFromSectionPlane = () => rootNode.quaternion = sectionPlane.quaternion;
121389
121388
  setPosFromSectionPlane();
121390
121389
  setDirFromSectionPlane();
121391
121390
  const onSectionPlanePos = sectionPlane.on("pos", setPosFromSectionPlane);
@@ -126051,6 +126050,8 @@ class TreeViewPlugin extends Plugin {
126051
126050
  * @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
126052
126051
  * @param {Boolean} [cfg.showIndeterminate=false] When true, will show indeterminate state for checkboxes when some but not all child nodes are checked
126053
126052
  * @param {Boolean} [cfg.showProjectNode=false] When true, will show top level project node when hierarchy is set to "storeys"
126053
+ * @param {Function} [cfg.elevationSortFunction] Optional function to replace the default elevation sort function. The function should take two nodes and return -1, 0 or 1.
126054
+ * @param {Function} [cfg.defaultSortFunction] Optional function to replace the default sort function. The function should take two nodes and return -1, 0 or 1.
126054
126055
  */
126055
126056
  constructor(viewer, cfg = {}) {
126056
126057
 
@@ -126104,6 +126105,8 @@ class TreeViewPlugin extends Plugin {
126104
126105
  this._renderService = cfg.renderService || new RenderService();
126105
126106
  this._showIndeterminate = cfg.showIndeterminate ?? false;
126106
126107
  this._showProjectNode = cfg.showProjectNode ?? false;
126108
+ this._elevationSortFunction = cfg.elevationSortFunction ?? undefined;
126109
+ this._defaultSortFunction = cfg.defaultSortFunction ?? undefined;
126107
126110
 
126108
126111
  if (!this._renderService) {
126109
126112
  throw new Error('TreeViewPlugin: no render service set');
@@ -126917,9 +126920,11 @@ class TreeViewPlugin extends Plugin {
126917
126920
  }
126918
126921
  const firstChild = children[0];
126919
126922
  if ((this._hierarchy === "storeys" || this._hierarchy === "containment") && firstChild.type === "IfcBuildingStorey") {
126920
- children.sort(this._getSpatialSortFunc());
126923
+ if (this._elevationSortFunction) children.sort(this._elevationSortFunction);
126924
+ else children.sort(this._getSpatialSortFunc());
126921
126925
  } else {
126922
- children.sort(this._alphaSortFunc);
126926
+ if (this._defaultSortFunction) children.sort(this._defaultSortFunction);
126927
+ else children.sort(this._alphaSortFunc);
126923
126928
  }
126924
126929
  for (let i = 0, len = children.length; i < len; i++) {
126925
126930
  const node = children[i];