@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
@@ -1059,13 +1059,10 @@ class PointerLens {
1059
1059
  this.scene = this.viewer.scene;
1060
1060
 
1061
1061
  this._lensCursorDiv = document.createElement('div');
1062
- this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._lensCursorDiv, this.viewer.scene.canvas.canvas);
1063
- this._lensCursorDiv.style.background = "pink";
1064
- this._lensCursorDiv.style.border = "2px solid red";
1065
- this._lensCursorDiv.style.borderRadius = "20px";
1066
- this._lensCursorDiv.style.width = "10px";
1067
- this._lensCursorDiv.style.height = "10px";
1068
- this._lensCursorDiv.style.margin = "-200px -200px";
1062
+ this._lensParams = { canvasSize: 300, cursorBorder: 2, cursorSize: 10 };
1063
+ this._lensCursorDiv.style.borderRadius = "50%";
1064
+ this._lensCursorDiv.style.width = this._lensParams.cursorSize + "px";
1065
+ this._lensCursorDiv.style.height = this._lensParams.cursorSize + "px";
1069
1066
  this._lensCursorDiv.style.zIndex = "100000";
1070
1067
  this._lensCursorDiv.style.position = "absolute";
1071
1068
  this._lensCursorDiv.style.pointerEvents = "none";
@@ -1078,8 +1075,8 @@ class PointerLens {
1078
1075
  this._lensContainer.style.background = "white";
1079
1076
  // this._lensContainer.style.opacity = "0";
1080
1077
  this._lensContainer.style.borderRadius = "50%";
1081
- this._lensContainer.style.width = "300px";
1082
- this._lensContainer.style.height = "300px";
1078
+ this._lensContainer.style.width = this._lensParams.canvasSize + "px";
1079
+ this._lensContainer.style.height = this._lensParams.canvasSize + "px";
1083
1080
 
1084
1081
  this._lensContainer.style.zIndex = "15000";
1085
1082
  this._lensContainer.style.position = "absolute";
@@ -1091,13 +1088,14 @@ class PointerLens {
1091
1088
  // this._lensCanvas.style.background = "darkblue";
1092
1089
  this._lensCanvas.style.borderRadius = "50%";
1093
1090
 
1094
- this._lensCanvas.style.width = "300px";
1095
- this._lensCanvas.style.height = "300px";
1091
+ this._lensCanvas.style.width = this._lensParams.canvasSize + "px";
1092
+ this._lensCanvas.style.height = this._lensParams.canvasSize + "px";
1096
1093
  this._lensCanvas.style.zIndex = "15000";
1097
1094
  this._lensCanvas.style.pointerEvents = "none";
1098
1095
 
1099
1096
  document.body.appendChild(this._lensContainer);
1100
1097
  this._lensContainer.appendChild(this._lensCanvas);
1098
+ this._lensContainer.appendChild(this._lensCursorDiv);
1101
1099
 
1102
1100
  this._lensCanvasContext = this._lensCanvas.getContext('2d');
1103
1101
  this._canvasElement = this.viewer.scene.canvas.canvas;
@@ -1115,7 +1113,7 @@ class PointerLens {
1115
1113
 
1116
1114
  this._active = (cfg.active !== false);
1117
1115
  this._visible = false;
1118
- this._snapped = false;
1116
+ this.snapped = false;
1119
1117
 
1120
1118
  this._onViewerRendering = this.viewer.scene.on("rendering", () => {
1121
1119
  if (this._active && this._visible) {
@@ -1162,21 +1160,13 @@ class PointerLens {
1162
1160
  this._lensCanvas.height // destination height
1163
1161
  );
1164
1162
 
1165
- const centerLensCanvas = [
1166
- (lensRect.left + lensRect.right) / 2 - canvasRect.left,
1167
- (lensRect.top + lensRect.bottom) / 2 - canvasRect.top
1168
- ];
1163
+ const middle = this._lensParams.canvasSize / 2 - this._lensParams.cursorSize / 2 - this._lensParams.cursorBorder;
1169
1164
 
1170
- if (this._snappedCanvasPos) {
1171
- const deltaX = this._snappedCanvasPos[0] - this._canvasPos[0];
1172
- const deltaY = this._snappedCanvasPos[1] - this._canvasPos[1];
1165
+ const deltaX = this._snappedCanvasPos ? (this._snappedCanvasPos[0] - this._canvasPos[0]) : 0;
1166
+ const deltaY = this._snappedCanvasPos ? (this._snappedCanvasPos[1] - this._canvasPos[1]) : 0;
1173
1167
 
1174
- this._lensCursorDiv.style.marginLeft = `${centerLensCanvas[0] + deltaX * this._zoomLevel - 10}px`;
1175
- this._lensCursorDiv.style.marginTop = `${centerLensCanvas[1] + deltaY * this._zoomLevel - 10}px`;
1176
- } else {
1177
- this._lensCursorDiv.style.marginLeft = `${centerLensCanvas[0] - 10}px`;
1178
- this._lensCursorDiv.style.marginTop = `${centerLensCanvas[1] - 10}px`;
1179
- }
1168
+ this._lensCursorDiv.style.left = `${middle + deltaX * this._zoomLevel}px`;
1169
+ this._lensCursorDiv.style.top = `${middle + deltaY * this._zoomLevel}px`;
1180
1170
  }
1181
1171
 
1182
1172
 
@@ -1244,14 +1234,10 @@ class PointerLens {
1244
1234
  * @private
1245
1235
  */
1246
1236
  set snapped(snapped) {
1247
- this._snapped = snapped;
1248
- if (snapped) {
1249
- this._lensCursorDiv.style.background = "greenyellow";
1250
- this._lensCursorDiv.style.border = "2px solid green";
1251
- } else {
1252
- this._lensCursorDiv.style.background = "pink";
1253
- this._lensCursorDiv.style.border = "2px solid red";
1254
- }
1237
+ this._snapped = snapped;
1238
+ const [ bg, border ] = snapped ? [ "greenyellow", "green" ] : [ "pink", "red" ];
1239
+ this._lensCursorDiv.style.background = bg;
1240
+ this._lensCursorDiv.style.border = this._lensParams.cursorBorder + "px solid " + border;
1255
1241
  }
1256
1242
 
1257
1243
  /**
@@ -1263,19 +1249,19 @@ class PointerLens {
1263
1249
  get snapped() {
1264
1250
  return this._snapped;
1265
1251
  }
1266
-
1252
+
1253
+ _updateActiveVisible() {
1254
+ this._lensContainer.style.visibility = (this._active && this._visible) ? "visible" : "hidden";
1255
+ this.update();
1256
+ }
1257
+
1267
1258
  /**
1268
1259
  * Sets if this PointerLens is active.
1269
1260
  * @param active
1270
1261
  */
1271
1262
  set active(active) {
1272
1263
  this._active = active;
1273
- this._lensContainer.style.visibility = (active && this._visible) ? "visible" : "hidden";
1274
- if (!active || !this._visible ) {
1275
- this._lensCursorDiv.style.marginLeft = `-100px`;
1276
- this._lensCursorDiv.style.marginTop = `-100px`;
1277
- }
1278
- this.update();
1264
+ this._updateActiveVisible();
1279
1265
  }
1280
1266
 
1281
1267
  /**
@@ -1294,12 +1280,7 @@ class PointerLens {
1294
1280
  */
1295
1281
  set visible(visible) {
1296
1282
  this._visible = visible;
1297
- this._lensContainer.style.visibility = (visible && this._active) ? "visible" : "hidden";
1298
- if (!visible || !this._active) {
1299
- this._lensCursorDiv.style.marginLeft = `-100px`;
1300
- this._lensCursorDiv.style.marginTop = `-100px`;
1301
- }
1302
- this.update();
1283
+ this._updateActiveVisible();
1303
1284
  }
1304
1285
 
1305
1286
  /**
@@ -1330,7 +1311,7 @@ class PointerLens {
1330
1311
  let doublePrecision = true;
1331
1312
  let FloatArrayType = doublePrecision ? Float64Array : Float32Array;
1332
1313
 
1333
- const tempVec3a$N = new FloatArrayType(3);
1314
+ const tempVec3a$O = new FloatArrayType(3);
1334
1315
 
1335
1316
  const tempMat1 = new FloatArrayType(16);
1336
1317
  const tempMat2 = new FloatArrayType(16);
@@ -6700,10 +6681,10 @@ math.buildEdgeIndices = (function () {
6700
6681
  */
6701
6682
  math.planeClipsPositions3 = function (pos, dir, positions, numElementsPerPosition = 3) {
6702
6683
  for (let i = 0, len = positions.length; i < len; i += numElementsPerPosition) {
6703
- tempVec3a$N[0] = positions[i + 0] - pos[0];
6704
- tempVec3a$N[1] = positions[i + 1] - pos[1];
6705
- tempVec3a$N[2] = positions[i + 2] - pos[2];
6706
- let dotProduct = tempVec3a$N[0] * dir[0] + tempVec3a$N[1] * dir[1] + tempVec3a$N[2] * dir[2];
6684
+ tempVec3a$O[0] = positions[i + 0] - pos[0];
6685
+ tempVec3a$O[1] = positions[i + 1] - pos[1];
6686
+ tempVec3a$O[2] = positions[i + 2] - pos[2];
6687
+ let dotProduct = tempVec3a$O[0] * dir[0] + tempVec3a$O[1] * dir[1] + tempVec3a$O[2] * dir[2];
6707
6688
  if (dotProduct < 0) {
6708
6689
  return true;
6709
6690
  }
@@ -8583,8 +8564,8 @@ class Component {
8583
8564
  }
8584
8565
  }
8585
8566
 
8586
- const tempVec3a$M = math.vec3();
8587
- const tempVec3b$A = math.vec3();
8567
+ const tempVec3a$N = math.vec3();
8568
+ const tempVec3b$B = math.vec3();
8588
8569
  const tempMat4a$s = math.mat4();
8589
8570
 
8590
8571
  /**
@@ -8661,8 +8642,8 @@ function frustumIntersectsAABB3(frustum, aabb) {
8661
8642
 
8662
8643
  let ret = Frustum$1.INSIDE;
8663
8644
 
8664
- const min = tempVec3a$M;
8665
- const max = tempVec3b$A;
8645
+ const min = tempVec3a$N;
8646
+ const max = tempVec3b$B;
8666
8647
 
8667
8648
  min[0] = aabb[0];
8668
8649
  min[1] = aabb[1];
@@ -9297,7 +9278,7 @@ class PointerCircle {
9297
9278
  }
9298
9279
 
9299
9280
  /**
9300
- * Stop the shricking circle and hide it.
9281
+ * Stop the shrinking circle and hide it.
9301
9282
  */
9302
9283
  stop() {
9303
9284
  if (this._destroyed) {
@@ -9590,7 +9571,8 @@ const os = {
9590
9571
  }
9591
9572
  };
9592
9573
 
9593
- function addContextMenuListener(elem, callback) {
9574
+ //failCallback will be called when the press is not long enough to considered a long press
9575
+ function addContextMenuListener(elem, callback, failCallback = () => {}) {
9594
9576
  if (!elem || !callback) return;
9595
9577
 
9596
9578
  let timeout = null;
@@ -9644,6 +9626,7 @@ function addContextMenuListener(elem, callback) {
9644
9626
  const touchEndHandler = (event) => {
9645
9627
  event.preventDefault();
9646
9628
  if (timeout) {
9629
+ failCallback(event);
9647
9630
  clearTimeout(timeout);
9648
9631
  timeout = null;
9649
9632
  }
@@ -10279,7 +10262,7 @@ class Wire {
10279
10262
  }
10280
10263
  }
10281
10264
 
10282
- const tempVec3a$L = math.vec3();
10265
+ const tempVec3a$M = math.vec3();
10283
10266
  const tempVec4$1 = math.vec4();
10284
10267
 
10285
10268
  /**
@@ -10360,7 +10343,7 @@ function worldToRTCPos(worldPos, rtcCenter, rtcPos) {
10360
10343
  */
10361
10344
  function worldToRTCPositions(worldPositions, rtcPositions, rtcCenter, cellSize = 1000) {
10362
10345
 
10363
- const center = math.getPositionsCenter(worldPositions, tempVec3a$L);
10346
+ const center = math.getPositionsCenter(worldPositions, tempVec3a$M);
10364
10347
 
10365
10348
  const rtcCenterX = Math.round(center[0] / cellSize) * cellSize;
10366
10349
  const rtcCenterY = Math.round(center[1] / cellSize) * cellSize;
@@ -10414,7 +10397,7 @@ function getPlaneRTCPos(dist, dir, rtcOrigin, rtcPlanePos, originMatrix) {
10414
10397
  ? (tempVec4$1.set(rtcOrigin, 0), tempVec4$1[3] = 1, math.mulMat4v4(originMatrix, tempVec4$1, tempVec4$1))
10415
10398
  : rtcOrigin);
10416
10399
  const rtcCenterToPlaneDist = math.dotVec3(dir, rtcCenter) + dist;
10417
- const dirNormalized = math.normalizeVec3(dir, tempVec3a$L);
10400
+ const dirNormalized = math.normalizeVec3(dir, tempVec3a$M);
10418
10401
  math.mulVec3Scalar(dirNormalized, -rtcCenterToPlaneDist, rtcPlanePos);
10419
10402
  return rtcPlanePos;
10420
10403
  }
@@ -11202,7 +11185,7 @@ class SceneModelEntity {
11202
11185
  }
11203
11186
  }
11204
11187
 
11205
- const tempVec4a$b = math.vec4();
11188
+ const tempVec4a$c = math.vec4();
11206
11189
  const tempVec4b$7 = math.vec4();
11207
11190
 
11208
11191
 
@@ -11362,9 +11345,9 @@ class Marker extends Component {
11362
11345
  this.fire("viewPos", this._viewPos);
11363
11346
  }
11364
11347
  if (this._canvasPosDirty) {
11365
- tempVec4a$b.set(this._viewPos);
11366
- tempVec4a$b[3] = 1.0;
11367
- math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$b, tempVec4b$7);
11348
+ tempVec4a$c.set(this._viewPos);
11349
+ tempVec4a$c[3] = 1.0;
11350
+ math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$c, tempVec4b$7);
11368
11351
  const aabb = this.scene.canvas.boundary;
11369
11352
  this._canvasPos[0] = Math.floor((1 + tempVec4b$7[0] / tempVec4b$7[3]) * aabb[2] / 2);
11370
11353
  this._canvasPos[1] = Math.floor((1 - tempVec4b$7[1] / tempVec4b$7[3]) * aabb[3] / 2);
@@ -13785,6 +13768,8 @@ const WAITING_FOR_TARGET_LONG_TOUCH_END$1 = 8;
13785
13768
 
13786
13769
  const TOUCH_CANCELING$1 = 7;
13787
13770
 
13771
+ const tmpVec2$1 = math.vec2();
13772
+
13788
13773
  /**
13789
13774
  * Creates {@link AngleMeasurement}s from touch input.
13790
13775
  *
@@ -13923,6 +13908,19 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13923
13908
  this._touchState = WAITING_FOR_ORIGIN_TOUCH_START$1;
13924
13909
  };
13925
13910
 
13911
+ const copyCanvasPos = (event, dst) => {
13912
+ dst[0] = event.clientX;
13913
+ dst[1] = event.clientY;
13914
+ transformToNode(canvas.ownerDocument.documentElement, canvas, dst);
13915
+ return dst;
13916
+ };
13917
+
13918
+ const toBodyPos = (pos, dst) => {
13919
+ dst.set(pos);
13920
+ transformToNode(canvas, canvas.ownerDocument.documentElement, dst);
13921
+ return dst;
13922
+ };
13923
+
13926
13924
  canvas.addEventListener("touchstart", this._onCanvasTouchStart = (event) => {
13927
13925
 
13928
13926
  const currentNumTouches = event.touches.length;
@@ -13936,11 +13934,8 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13936
13934
  }
13937
13935
 
13938
13936
  const touch = event.touches[0];
13939
- const touchX = touch.clientX;
13940
- const touchY = touch.clientY;
13941
-
13942
- touchStartCanvasPos.set([touchX, touchY]);
13943
- touchMoveCanvasPos.set([touchX, touchY]);
13937
+ copyCanvasPos(touch, touchStartCanvasPos);
13938
+ touchMoveCanvasPos.set(touchStartCanvasPos);
13944
13939
 
13945
13940
  switch (this._touchState) {
13946
13941
 
@@ -13956,7 +13951,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13956
13951
  });
13957
13952
  if (snapPickResult && snapPickResult.snapped) {
13958
13953
  pointerWorldPos.set(snapPickResult.worldPos);
13959
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
13954
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2$1));
13960
13955
  } else {
13961
13956
  const pickResult = scene.pick({
13962
13957
  canvasPos: touchMoveCanvasPos,
@@ -13964,7 +13959,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
13964
13959
  });
13965
13960
  if (pickResult && pickResult.worldPos) {
13966
13961
  pointerWorldPos.set(pickResult.worldPos);
13967
- this.pointerCircle.start(pickResult.canvasPos);
13962
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2$1));
13968
13963
  } else {
13969
13964
  return;
13970
13965
  }
@@ -14071,7 +14066,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14071
14066
  this.pointerLens.cursorPos = snapPickResult.snappedCanvasPos;
14072
14067
  this.pointerLens.snapped = true;
14073
14068
  }
14074
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
14069
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2$1));
14075
14070
  pointerWorldPos.set(snapPickResult.worldPos);
14076
14071
  this._currentAngleMeasurement.corner.worldPos = snapPickResult.worldPos;
14077
14072
  this._currentAngleMeasurement.corner.entity = snapPickResult.entity;
@@ -14093,7 +14088,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14093
14088
  this.pointerLens.cursorPos = pickResult.canvasPos;
14094
14089
  this.pointerLens.snapped = false;
14095
14090
  }
14096
- this.pointerCircle.start(pickResult.canvasPos);
14091
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2$1));
14097
14092
  pointerWorldPos.set(pickResult.worldPos);
14098
14093
  this._currentAngleMeasurement.corner.worldPos = pickResult.worldPos;
14099
14094
  this._currentAngleMeasurement.corner.entity = pickResult.entity;
@@ -14164,7 +14159,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14164
14159
  this.pointerLens.cursorPos = snapPickResult.snappedCanvasPos;
14165
14160
  this.pointerLens.snapped = true;
14166
14161
  }
14167
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
14162
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2$1));
14168
14163
  pointerWorldPos.set(snapPickResult.worldPos);
14169
14164
  this._currentAngleMeasurement.target.worldPos = snapPickResult.worldPos;
14170
14165
  this._currentAngleMeasurement.target.entity = snapPickResult.entity;
@@ -14186,7 +14181,7 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14186
14181
  this.pointerLens.cursorPos = pickResult.canvasPos;
14187
14182
  this.pointerLens.snapped = false;
14188
14183
  }
14189
- this.pointerCircle.start(pickResult.canvasPos);
14184
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2$1));
14190
14185
  pointerWorldPos.set(pickResult.worldPos);
14191
14186
  this._currentAngleMeasurement.target.worldPos = pickResult.worldPos;
14192
14187
  this._currentAngleMeasurement.target.entity = pickResult.entity;
@@ -14250,14 +14245,11 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14250
14245
  }
14251
14246
 
14252
14247
  const touch = event.touches[0];
14253
- const touchX = touch.clientX;
14254
- const touchY = touch.clientY;
14255
-
14256
14248
  if (touch.identifier !== touchId) {
14257
14249
  return;
14258
14250
  }
14259
14251
 
14260
- touchMoveCanvasPos.set([touchX, touchY]);
14252
+ copyCanvasPos(touch, touchMoveCanvasPos);
14261
14253
 
14262
14254
  let snapPickResult;
14263
14255
  let pickResult;
@@ -14427,9 +14419,6 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14427
14419
  }
14428
14420
 
14429
14421
  const touch = event.changedTouches[0];
14430
- const touchX = touch.clientX;
14431
- const touchY = touch.clientY;
14432
-
14433
14422
  if (touch.identifier !== touchId) {
14434
14423
  return;
14435
14424
  }
@@ -14439,7 +14428,10 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
14439
14428
  longTouchTimeout = null;
14440
14429
  }
14441
14430
 
14442
- touchEndCanvasPos.set([touchX, touchY]);
14431
+ copyCanvasPos(touch, touchEndCanvasPos);
14432
+
14433
+ const touchX = touchEndCanvasPos[0];
14434
+ const touchY = touchEndCanvasPos[1];
14443
14435
 
14444
14436
  switch (this._touchState) {
14445
14437
 
@@ -14750,8 +14742,8 @@ class AngleMeasurementEditTouchControl extends AngleMeasurementEditControl {
14750
14742
  }
14751
14743
  }
14752
14744
 
14753
- const tempVec3a$K = math.vec3();
14754
- const tempVec3b$z = math.vec3();
14745
+ const tempVec3a$L = math.vec3();
14746
+ const tempVec3b$A = math.vec3();
14755
14747
  const tempVec3c$v = math.vec3();
14756
14748
 
14757
14749
  /**
@@ -14920,6 +14912,9 @@ class Annotation extends Marker {
14920
14912
  addContextMenuListener(this._marker, e => {
14921
14913
  e.preventDefault();
14922
14914
  this.plugin.fire("contextmenu", this);
14915
+ }, e => {
14916
+ e.preventDefault();
14917
+ this.plugin.fire("markerClicked", this);
14923
14918
  });
14924
14919
  this._marker.addEventListener("mouseenter", () => {
14925
14920
  this.plugin.fire("markerMouseEnter", this);
@@ -14997,9 +14992,9 @@ class Annotation extends Marker {
14997
14992
  if (!pickResult.worldPos || !pickResult.worldNormal) {
14998
14993
  this.error("Param 'pickResult' does not have both worldPos and worldNormal");
14999
14994
  } else {
15000
- const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$K);
14995
+ const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$L);
15001
14996
  const offset = (this.plugin && this.plugin.surfaceOffset) || 0;
15002
- const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b$z);
14997
+ const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b$A);
15003
14998
  const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c$v);
15004
14999
  this.entity = pickResult.entity;
15005
15000
  this.worldPos = offsetWorldPos;
@@ -17869,7 +17864,7 @@ class OcclusionLayer {
17869
17864
  const MARKER_COLOR = math.vec3([1.0, 0.0, 0.0]);
17870
17865
  const POINT_SIZE = 20;
17871
17866
 
17872
- const tempVec3a$J = math.vec3();
17867
+ const tempVec3a$K = math.vec3();
17873
17868
 
17874
17869
  /**
17875
17870
  * Manages occlusion testing. Private member of a Renderer.
@@ -18208,7 +18203,7 @@ class OcclusionTester {
18208
18203
  gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
18209
18204
  if (active) {
18210
18205
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
18211
- gl.uniform3fv(sectionPlaneUniforms.pos, getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$J));
18206
+ gl.uniform3fv(sectionPlaneUniforms.pos, getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$K));
18212
18207
  gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
18213
18208
  }
18214
18209
  }
@@ -20308,6 +20303,9 @@ const Renderer$1 = function (scene, options) {
20308
20303
  pickProjMatrix = scene.camera.projMatrix;
20309
20304
  projection = scene.camera.projection;
20310
20305
 
20306
+ nearAndFar[0] = scene.camera.project.near;
20307
+ nearAndFar[1] = scene.camera.project.far;
20308
+
20311
20309
  pickResult.canvasPos = params.canvasPos;
20312
20310
 
20313
20311
  } else {
@@ -20321,6 +20319,9 @@ const Renderer$1 = function (scene, options) {
20321
20319
  pickProjMatrix = scene.camera.projMatrix;
20322
20320
  projection = scene.camera.projection;
20323
20321
 
20322
+ nearAndFar[0] = scene.camera.project.near;
20323
+ nearAndFar[1] = scene.camera.project.far;
20324
+
20324
20325
  } else {
20325
20326
 
20326
20327
  worldRayOrigin.set(params.origin || [0, 0, 0]);
@@ -20340,6 +20341,9 @@ const Renderer$1 = function (scene, options) {
20340
20341
  pickProjMatrix = scene.camera.ortho.matrix;
20341
20342
  projection = "ortho";
20342
20343
 
20344
+ nearAndFar[0] = scene.camera.ortho.near;
20345
+ nearAndFar[1] = scene.camera.ortho.far;
20346
+
20343
20347
  pickResult.origin = worldRayOrigin;
20344
20348
  pickResult.direction = worldRayDir;
20345
20349
  }
@@ -20394,9 +20398,6 @@ const Renderer$1 = function (scene, options) {
20394
20398
 
20395
20399
  if (pickable.canPickWorldPos && pickable.canPickWorldPos()) {
20396
20400
 
20397
- nearAndFar[0] = scene.camera.project.near;
20398
- nearAndFar[1] = scene.camera.project.far;
20399
-
20400
20401
  gpuPickWorldPos(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult);
20401
20402
 
20402
20403
  if (params.pickSurfaceNormal !== false) {
@@ -23814,12 +23815,12 @@ class CustomProjection extends Component {
23814
23815
  }
23815
23816
 
23816
23817
  const tempVec3$6 = math.vec3();
23817
- const tempVec3b$y = math.vec3();
23818
+ const tempVec3b$z = math.vec3();
23818
23819
  const tempVec3c$u = math.vec3();
23819
23820
  const tempVec3d$d = math.vec3();
23820
23821
  const tempVec3e$2 = math.vec3();
23821
23822
  const tempVec3f$2 = math.vec3();
23822
- const tempVec4a$a = math.vec4();
23823
+ const tempVec4a$b = math.vec4();
23823
23824
  const tempVec4b$6 = math.vec4();
23824
23825
  const tempVec4c$2 = math.vec4();
23825
23826
  const tempMat = math.mat4();
@@ -24127,7 +24128,7 @@ class Camera extends Component {
24127
24128
  orbitYaw(angleInc) {
24128
24129
  let lookEyeVec = math.subVec3(this._eye, this._look, tempVec3$6);
24129
24130
  math.rotationMat4v(angleInc * 0.0174532925, this._gimbalLock ? this._worldUp : this._up, tempMat);
24130
- lookEyeVec = math.transformPoint3(tempMat, lookEyeVec, tempVec3b$y);
24131
+ lookEyeVec = math.transformPoint3(tempMat, lookEyeVec, tempVec3b$z);
24131
24132
  this.eye = math.addVec3(this._look, lookEyeVec, tempVec3c$u); // Set eye position as 'look' plus 'eye' vector
24132
24133
  this.up = math.transformPoint3(tempMat, this._up, tempVec3d$d); // Rotate 'up' vector
24133
24134
  }
@@ -24145,7 +24146,7 @@ class Camera extends Component {
24145
24146
  }
24146
24147
  }
24147
24148
  let eye2 = math.subVec3(this._eye, this._look, tempVec3$6);
24148
- const left = math.cross3Vec3(math.normalizeVec3(eye2, tempVec3b$y), math.normalizeVec3(this._up, tempVec3c$u));
24149
+ const left = math.cross3Vec3(math.normalizeVec3(eye2, tempVec3b$z), math.normalizeVec3(this._up, tempVec3c$u));
24149
24150
  math.rotationMat4v(angleInc * 0.0174532925, left, tempMat);
24150
24151
  eye2 = math.transformPoint3(tempMat, eye2, tempVec3d$d);
24151
24152
  this.up = math.transformPoint3(tempMat, this._up, tempVec3e$2);
@@ -24160,7 +24161,7 @@ class Camera extends Component {
24160
24161
  yaw(angleInc) {
24161
24162
  let look2 = math.subVec3(this._look, this._eye, tempVec3$6);
24162
24163
  math.rotationMat4v(angleInc * 0.0174532925, this._gimbalLock ? this._worldUp : this._up, tempMat);
24163
- look2 = math.transformPoint3(tempMat, look2, tempVec3b$y);
24164
+ look2 = math.transformPoint3(tempMat, look2, tempVec3b$z);
24164
24165
  this.look = math.addVec3(look2, this._eye, tempVec3c$u);
24165
24166
  if (this._gimbalLock) {
24166
24167
  this.up = math.transformPoint3(tempMat, this._up, tempVec3d$d);
@@ -24180,7 +24181,7 @@ class Camera extends Component {
24180
24181
  }
24181
24182
  }
24182
24183
  let look2 = math.subVec3(this._look, this._eye, tempVec3$6);
24183
- const left = math.cross3Vec3(math.normalizeVec3(look2, tempVec3b$y), math.normalizeVec3(this._up, tempVec3c$u));
24184
+ const left = math.cross3Vec3(math.normalizeVec3(look2, tempVec3b$z), math.normalizeVec3(this._up, tempVec3c$u));
24184
24185
  math.rotationMat4v(angleInc * 0.0174532925, left, tempMat);
24185
24186
  this.up = math.transformPoint3(tempMat, this._up, tempVec3f$2);
24186
24187
  look2 = math.transformPoint3(tempMat, look2, tempVec3d$d);
@@ -24197,7 +24198,7 @@ class Camera extends Component {
24197
24198
  const vec = [0, 0, 0];
24198
24199
  let v;
24199
24200
  if (pan[0] !== 0) {
24200
- const left = math.cross3Vec3(math.normalizeVec3(eye2, []), math.normalizeVec3(this._up, tempVec3b$y));
24201
+ const left = math.cross3Vec3(math.normalizeVec3(eye2, []), math.normalizeVec3(this._up, tempVec3b$z));
24201
24202
  v = math.mulVec3Scalar(left, pan[0]);
24202
24203
  vec[0] += v[0];
24203
24204
  vec[1] += v[1];
@@ -24226,7 +24227,7 @@ class Camera extends Component {
24226
24227
  */
24227
24228
  zoom(delta) {
24228
24229
  const vec = math.subVec3(this._eye, this._look, tempVec3$6);
24229
- const lenLook = Math.abs(math.lenVec3(vec, tempVec3b$y));
24230
+ const lenLook = Math.abs(math.lenVec3(vec, tempVec3b$z));
24230
24231
  const newLenLook = Math.abs(lenLook + delta);
24231
24232
  if (newLenLook < 0.5) {
24232
24233
  return;
@@ -24685,7 +24686,7 @@ class Camera extends Component {
24685
24686
  * @returns {[number, number]} the canvas position
24686
24687
  */
24687
24688
  projectWorldPos(worldPos) {
24688
- const _worldPos = tempVec4a$a;
24689
+ const _worldPos = tempVec4a$b;
24689
24690
  const viewPos = tempVec4b$6;
24690
24691
  const screenPos = tempVec4c$2;
24691
24692
  _worldPos[0] = worldPos[0];
@@ -34770,7 +34771,7 @@ function buildFragmentDraw(mesh) {
34770
34771
  * @author xeolabs / https://github.com/xeolabs
34771
34772
  */
34772
34773
 
34773
- const tempVec3a$I = math.vec3();
34774
+ const tempVec3a$J = math.vec3();
34774
34775
 
34775
34776
  const ids$2 = new Map$1({});
34776
34777
 
@@ -34872,7 +34873,7 @@ DrawRenderer.prototype.drawMesh = function (frameCtx, mesh) {
34872
34873
  if (active) {
34873
34874
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
34874
34875
  if (origin) {
34875
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$I);
34876
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$J);
34876
34877
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
34877
34878
  } else {
34878
34879
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -36018,7 +36019,7 @@ function buildFragment$5(mesh) {
36018
36019
 
36019
36020
  const ids$1 = new Map$1({});
36020
36021
 
36021
- const tempVec3a$H = math.vec3();
36022
+ const tempVec3a$I = math.vec3();
36022
36023
 
36023
36024
  /**
36024
36025
  * @private
@@ -36105,7 +36106,7 @@ EmphasisFillRenderer.prototype.drawMesh = function (frameCtx, mesh, mode) {
36105
36106
  if (active) {
36106
36107
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
36107
36108
  if (origin) {
36108
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$H);
36109
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$I);
36109
36110
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
36110
36111
  } else {
36111
36112
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -36449,7 +36450,7 @@ function buildFragment$4(mesh) {
36449
36450
 
36450
36451
  const ids = new Map$1({});
36451
36452
 
36452
- const tempVec3a$G = math.vec3();
36453
+ const tempVec3a$H = math.vec3();
36453
36454
 
36454
36455
  /**
36455
36456
  * @private
@@ -36535,7 +36536,7 @@ EmphasisEdgesRenderer.prototype.drawMesh = function (frameCtx, mesh, mode) {
36535
36536
  if (active) {
36536
36537
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
36537
36538
  if (origin) {
36538
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$G);
36539
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$H);
36539
36540
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
36540
36541
  } else {
36541
36542
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -36848,7 +36849,7 @@ function buildFragment$3(mesh) {
36848
36849
  * @author xeolabs / https://github.com/xeolabs
36849
36850
  */
36850
36851
 
36851
- const tempVec3a$F = math.vec3();
36852
+ const tempVec3a$G = math.vec3();
36852
36853
 
36853
36854
  // No ID, because there is exactly one PickMeshRenderer per scene
36854
36855
 
@@ -36935,7 +36936,7 @@ PickMeshRenderer.prototype.drawMesh = function (frameCtx, mesh) {
36935
36936
  if (active) {
36936
36937
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
36937
36938
  if (origin) {
36938
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$F);
36939
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$G);
36939
36940
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
36940
36941
  } else {
36941
36942
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -37187,7 +37188,7 @@ function buildFragment$2(mesh) {
37187
37188
  * @author xeolabs / https://github.com/xeolabs
37188
37189
  */
37189
37190
 
37190
- const tempVec3a$E = math.vec3();
37191
+ const tempVec3a$F = math.vec3();
37191
37192
 
37192
37193
  /**
37193
37194
  * @private
@@ -37282,7 +37283,7 @@ PickTriangleRenderer.prototype.drawMesh = function (frameCtx, mesh) {
37282
37283
  if (active) {
37283
37284
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
37284
37285
  if (origin) {
37285
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$E);
37286
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$F);
37286
37287
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
37287
37288
  } else {
37288
37289
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -37531,7 +37532,7 @@ function buildFragment$1(mesh) {
37531
37532
  * @author xeolabs / https://github.com/xeolabs
37532
37533
  */
37533
37534
 
37534
- const tempVec3a$D = math.vec3();
37535
+ const tempVec3a$E = math.vec3();
37535
37536
 
37536
37537
  // No ID, because there is exactly one PickMeshRenderer per scene
37537
37538
 
@@ -37646,7 +37647,7 @@ OcclusionRenderer.prototype.drawMesh = function (frameCtx, mesh) {
37646
37647
  if (active) {
37647
37648
  const sectionPlane = sectionPlanes[sectionPlaneIndex];
37648
37649
  if (origin) {
37649
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$D);
37650
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a$E);
37650
37651
  gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
37651
37652
  } else {
37652
37653
  gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
@@ -42891,7 +42892,12 @@ class AxisGizmoPlugin extends Plugin {
42891
42892
  }
42892
42893
  }
42893
42894
 
42894
- math.vec3();
42895
+ const tempVec3a$D = math.vec3();
42896
+ const tempVec3b$y = math.vec3();
42897
+ const tempVec4a$a = math.vec4();
42898
+ const front = math.vec3([0, 0, -1]);
42899
+ const back = math.vec3([0, 0, 1]);
42900
+ const up = math.vec3([0, 1, 0]);
42895
42901
 
42896
42902
  /**
42897
42903
  * @desc An arbitrarily-aligned World-space clipping plane.
@@ -42963,6 +42969,8 @@ class SectionPlane extends Component {
42963
42969
  this._state = new RenderState({
42964
42970
  active: true,
42965
42971
  pos: math.vec3(),
42972
+ quaternion: math.vec4(),
42973
+ roll: 0,
42966
42974
  dir: math.vec3(),
42967
42975
  dist: 0
42968
42976
  });
@@ -43024,6 +43032,59 @@ class SectionPlane extends Component {
43024
43032
  return this._state.pos;
43025
43033
  }
43026
43034
 
43035
+ /**
43036
+ * Sets the quaternion of this SectionPlane's plane.
43037
+ *
43038
+ * Default value is ````[0, -1, 0, 0]````.
43039
+ *
43040
+ * @param {Number[]} value New quaternion.
43041
+ */
43042
+ set quaternion(value) {
43043
+ this._state.quaternion.set(value || [0, 0, 0, -1]);
43044
+ math.vec3ApplyQuaternion(this._state.quaternion, back, this._state.dir);
43045
+ const quatUp = math.vec3ApplyQuaternion(this._state.quaternion, up, tempVec3a$D);
43046
+ const dirOnlyQ = math.vec3PairToQuaternion(back, this._state.dir, tempVec4a$a);
43047
+ const dirOnlyUp = math.vec3ApplyQuaternion(dirOnlyQ, up, tempVec3b$y);
43048
+ const angle = Math.acos(Math.min(1, math.dotVec3(quatUp, dirOnlyUp)));
43049
+ const sign = Math.sign(math.dotVec3(this._state.dir, math.cross3Vec3(quatUp, dirOnlyUp, tempVec3b$y)));
43050
+ this._state.roll = sign * angle;
43051
+ this._onDirUpdated();
43052
+ }
43053
+
43054
+ /**
43055
+ * Gets the quaternion of this SectionPlane's plane.
43056
+ *
43057
+ * Default value is ````[0, -1, 0, 0]````.
43058
+ *
43059
+ * @returns {Number[]} value Current quaternion.
43060
+ */
43061
+ get quaternion() {
43062
+ return this._state.quaternion;
43063
+ }
43064
+
43065
+ /**
43066
+ * Sets the roll of this SectionPlane's plane.
43067
+ *
43068
+ * Default value is ````0````.
43069
+ *
43070
+ * @param {Number[]} value New roll.
43071
+ */
43072
+ set roll(value) {
43073
+ this._state.roll = value || 0;
43074
+ this._onDirRollUpdated();
43075
+ }
43076
+
43077
+ /**
43078
+ * Gets the roll of this SectionPlane's plane.
43079
+ *
43080
+ * Default value is ````0````.
43081
+ *
43082
+ * @returns {Number[]} value Current roll.
43083
+ */
43084
+ get roll() {
43085
+ return this._state.roll;
43086
+ }
43087
+
43027
43088
  /**
43028
43089
  * Sets the direction of this SectionPlane's plane.
43029
43090
  *
@@ -43032,7 +43093,25 @@ class SectionPlane extends Component {
43032
43093
  * @param {Number[]} value New direction.
43033
43094
  */
43034
43095
  set dir(value) {
43035
- this._state.dir.set(value || [0, 0, -1]);
43096
+ this._state.dir.set(value || front);
43097
+ this._onDirRollUpdated();
43098
+ }
43099
+
43100
+ _onDirRollUpdated() {
43101
+ math.vec3PairToQuaternion(back, this._state.dir, this._state.quaternion);
43102
+
43103
+ tempVec4a$a[0] = 0;
43104
+ tempVec4a$a[1] = 0;
43105
+ tempVec4a$a[2] = -1;
43106
+ tempVec4a$a[3] = this._state.roll;
43107
+ math.angleAxisToQuaternion(tempVec4a$a, tempVec4a$a);
43108
+
43109
+ math.mulQuaternions(this._state.quaternion, tempVec4a$a, this._state.quaternion);
43110
+
43111
+ this._onDirUpdated();
43112
+ }
43113
+
43114
+ _onDirUpdated() {
43036
43115
  this._state.dist = (-math.dotVec3(this._state.pos, this._state.dir));
43037
43116
  this.glRedraw();
43038
43117
  this.fire("dir", this._state.dir);
@@ -52689,7 +52768,10 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
52689
52768
  }
52690
52769
 
52691
52770
  if (scene.logarithmicDepthBufferEnabled) {
52692
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
52771
+ src.push(" float dx = dFdx(vFragDepth);");
52772
+ src.push(" float dy = dFdy(vFragDepth);");
52773
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
52774
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
52693
52775
  }
52694
52776
 
52695
52777
  if (this._withSAO) {
@@ -58040,7 +58122,10 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
58040
58122
  }
58041
58123
 
58042
58124
  if (scene.logarithmicDepthBufferEnabled) {
58043
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
58125
+ src.push(" float dx = dFdx(vFragDepth);");
58126
+ src.push(" float dy = dFdy(vFragDepth);");
58127
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
58128
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
58044
58129
  }
58045
58130
 
58046
58131
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -66124,7 +66209,7 @@ class VBOInstancingLinesLayer {
66124
66209
 
66125
66210
  let pickFlag = (visible && !culled && pickable) ? RENDER_PASSES.PICK : RENDER_PASSES.NOT_RENDERED;
66126
66211
 
66127
- const clippableFlag = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 255 : 0;
66212
+ const clippableFlag = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 1 : 0;
66128
66213
 
66129
66214
  let vertFlag = 0;
66130
66215
  vertFlag |= colorFlag;
@@ -80701,8 +80786,7 @@ class DTXTrianglesLayer {
80701
80786
  worldPos[2] = positions[i + 2];
80702
80787
  worldPos[3] = 1.0;
80703
80788
  math.decompressPosition(worldPos, positionsDecodeMatrix);
80704
- math.transformPoint4(this.model.worldMatrix, worldPos, worldPos);
80705
- math.transformPoint4(this.model.worldMatrix, worldPos, worldPos);
80789
+ math.mulMat4v4(this.model.worldMatrix, worldPos, worldPos);
80706
80790
  worldPos[0] += offsetX;
80707
80791
  worldPos[1] += offsetY;
80708
80792
  worldPos[2] += offsetZ;
@@ -84486,6 +84570,7 @@ class SceneModel extends Component {
84486
84570
  set matrix(value) {
84487
84571
  this._matrix.set(value || DEFAULT_MATRIX);
84488
84572
  math.decomposeMat4(this._matrix, this._position, this._quaternion, this._scale);
84573
+ math.quaternionToEuler(this._quaternion, "XYZ", this._rotation);
84489
84574
  this._matrixDirty = false;
84490
84575
  this._setWorldMatrixDirty();
84491
84576
  this._sceneModelDirty();
@@ -89878,6 +89963,8 @@ const WAITING_FOR_TARGET_LONG_TOUCH_END = 5;
89878
89963
 
89879
89964
  const TOUCH_CANCELING = 7;
89880
89965
 
89966
+ const tmpVec2 = math.vec2();
89967
+
89881
89968
  /**
89882
89969
  * Creates {@link DistanceMeasurement}s from touch input.
89883
89970
  *
@@ -90024,6 +90111,19 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90024
90111
  this._touchState = WAITING_FOR_ORIGIN_TOUCH_START;
90025
90112
  };
90026
90113
 
90114
+ const copyCanvasPos = (event, dst) => {
90115
+ dst[0] = event.clientX;
90116
+ dst[1] = event.clientY;
90117
+ transformToNode(canvas.ownerDocument.documentElement, canvas, dst);
90118
+ return dst;
90119
+ };
90120
+
90121
+ const toBodyPos = (pos, dst) => {
90122
+ dst.set(pos);
90123
+ transformToNode(canvas, canvas.ownerDocument.documentElement, dst);
90124
+ return dst;
90125
+ };
90126
+
90027
90127
  canvas.addEventListener("touchstart", this._onCanvasTouchStart = (event) => {
90028
90128
 
90029
90129
  const currentNumTouches = event.touches.length;
@@ -90037,16 +90137,8 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90037
90137
  }
90038
90138
 
90039
90139
  const touch = event.touches[0];
90040
-
90041
- // Get the canvas's bounding rectangle
90042
- const rect = canvas.getBoundingClientRect();
90043
-
90044
- // Calculate the touch position relative to the canvas
90045
- const touchX = touch.clientX - rect.left;
90046
- const touchY = touch.clientY - rect.top;
90047
-
90048
- touchStartCanvasPos.set([touchX, touchY]);
90049
- touchMoveCanvasPos.set([touchX, touchY]);
90140
+ copyCanvasPos(touch, touchStartCanvasPos);
90141
+ touchMoveCanvasPos.set(touchStartCanvasPos);
90050
90142
 
90051
90143
  switch (this._touchState) {
90052
90144
 
@@ -90062,7 +90154,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90062
90154
  });
90063
90155
  if (snapPickResult && snapPickResult.snapped) {
90064
90156
  pointerWorldPos.set(snapPickResult.worldPos);
90065
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
90157
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2));
90066
90158
  } else {
90067
90159
  const pickResult = scene.pick({
90068
90160
  canvasPos: touchMoveCanvasPos,
@@ -90070,7 +90162,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90070
90162
  });
90071
90163
  if (pickResult && pickResult.worldPos) {
90072
90164
  pointerWorldPos.set(pickResult.worldPos);
90073
- this.pointerCircle.start(pickResult.canvasPos);
90165
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2));
90074
90166
  } else {
90075
90167
  return;
90076
90168
  }
@@ -90174,7 +90266,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90174
90266
  this.pointerLens.cursorPos = snapPickResult.snappedCanvasPos;
90175
90267
  this.pointerLens.snapped = true;
90176
90268
  }
90177
- this.pointerCircle.start(snapPickResult.snappedCanvasPos);
90269
+ this.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos, tmpVec2));
90178
90270
  pointerWorldPos.set(snapPickResult.worldPos);
90179
90271
  this._currentDistanceMeasurement.target.worldPos = snapPickResult.worldPos;
90180
90272
  this._currentDistanceMeasurement.target.entity = snapPickResult.entity;
@@ -90192,7 +90284,7 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90192
90284
  this.pointerLens.cursorPos = pickResult.canvasPos;
90193
90285
  this.pointerLens.snapped = false;
90194
90286
  }
90195
- this.pointerCircle.start(pickResult.canvasPos);
90287
+ this.pointerCircle.start(toBodyPos(pickResult.canvasPos, tmpVec2));
90196
90288
  pointerWorldPos.set(pickResult.worldPos);
90197
90289
  this._currentDistanceMeasurement.target.worldPos = pickResult.worldPos;
90198
90290
  this._currentDistanceMeasurement.target.entity = pickResult.entity;
@@ -90251,19 +90343,11 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90251
90343
  }
90252
90344
 
90253
90345
  const touch = event.touches[0];
90254
-
90255
- // Get the canvas's bounding rectangle
90256
- const rect = canvas.getBoundingClientRect();
90257
-
90258
- // Calculate the touch position relative to the canvas
90259
- const touchX = touch.clientX - rect.left;
90260
- const touchY = touch.clientY - rect.top;
90261
-
90262
90346
  if (touch.identifier !== touchId) {
90263
90347
  return;
90264
90348
  }
90265
90349
 
90266
- touchMoveCanvasPos.set([touchX, touchY]);
90350
+ copyCanvasPos(touch, touchMoveCanvasPos);
90267
90351
 
90268
90352
  let snapPickResult;
90269
90353
  let pickResult;
@@ -90425,14 +90509,6 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90425
90509
  }
90426
90510
 
90427
90511
  const touch = event.changedTouches[0];
90428
-
90429
- // Get the canvas's bounding rectangle
90430
- const rect = canvas.getBoundingClientRect();
90431
-
90432
- // Calculate the touch position relative to the canvas
90433
- const touchX = touch.clientX - rect.left;
90434
- const touchY = touch.clientY - rect.top;
90435
-
90436
90512
  if (touch.identifier !== touchId) {
90437
90513
  return;
90438
90514
  }
@@ -90442,7 +90518,10 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
90442
90518
  longTouchTimeout = null;
90443
90519
  }
90444
90520
 
90445
- touchEndCanvasPos.set([touchX, touchY]);
90521
+ copyCanvasPos(touch, touchEndCanvasPos);
90522
+
90523
+ const touchX = touchEndCanvasPos[0];
90524
+ const touchY = touchEndCanvasPos[1];
90446
90525
 
90447
90526
  switch (this._touchState) {
90448
90527
 
@@ -93267,7 +93346,7 @@ CameraPathAnimation.PLAYING_TO = 3;
93267
93346
  const tempVec3$3 = math.vec3();
93268
93347
  const tempVec3b$5 = math.vec3();
93269
93348
  math.vec3();
93270
- const zeroVec$2 = math.vec3([0, -1, 0]);
93349
+ const zeroVec$1 = math.vec3([0, -1, 0]);
93271
93350
  const tempQuat = math.vec4([0, 0, 0, 1]);
93272
93351
 
93273
93352
  /**
@@ -93694,7 +93773,7 @@ class ImagePlane extends Component {
93694
93773
 
93695
93774
  math.normalizeVec3(negDir);
93696
93775
  math.mulVec3Scalar(negDir, dist, tempVec3b$5);
93697
- math.vec3PairToQuaternion(zeroVec$2, dir, tempQuat);
93776
+ math.vec3PairToQuaternion(zeroVec$1, dir, tempQuat);
93698
93777
 
93699
93778
  this._node.quaternion = tempQuat;
93700
93779
  }
@@ -120733,9 +120812,6 @@ class OBJLoaderPlugin extends Plugin {
120733
120812
  }
120734
120813
  }
120735
120814
 
120736
- const zeroVec$1 = new Float64Array([0, 0, 1]);
120737
- const quat$1 = new Float64Array(4);
120738
-
120739
120815
  /**
120740
120816
  * Controls a {@link SectionPlane} with mouse and touch input.
120741
120817
  *
@@ -120853,15 +120929,13 @@ class Control {
120853
120929
  });
120854
120930
 
120855
120931
  const handlers = { };
120856
- const addAxis = (rgb, axisDirection, hoopDirection) => {
120932
+ const addAxis = (rgb, hoopRot) => {
120933
+ math.mulVec3Scalar(rgb, -1, math.vec3());
120857
120934
  const material = colorMaterial(rgb);
120858
120935
 
120859
- const rotateToHorizontal = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
120860
- const hoopRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], hoopDirection), math.identityMat4());
120861
- const hoopMatrix = math.mulMat4(hoopRotation, rotateToHorizontal, math.identityMat4());
120862
-
120936
+ const hoopMatrix = math.quaternionToRotationMat4(hoopRot, math.identityMat4());
120937
+ math.mulMat4(math.rotationMat4v(Math.PI, [0,1,0], math.mat4()), hoopMatrix, hoopMatrix);
120863
120938
  const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
120864
-
120865
120939
  const scaledArrowMatrix = (t, matR) => {
120866
120940
  const matT = math.translateMat4v(t, math.identityMat4());
120867
120941
  const ret = math.identityMat4();
@@ -120930,7 +121004,8 @@ class Control {
120930
121004
  }), NO_STATE_INHERIT);
120931
121005
 
120932
121006
 
120933
- const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], axisDirection), math.identityMat4());
121007
+ const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], rgb), math.identityMat4());
121008
+ math.mulMat4(math.rotationMat4v(Math.PI, [0,1,0], math.mat4()), axisRotation, axisRotation);
120934
121009
 
120935
121010
  const translatedAxisMatrix = (yOffset) => math.mulMat4(axisRotation, math.translateMat4c(0, yOffset, 0, math.identityMat4()), math.identityMat4());
120936
121011
  const arrowMatrix = translatedAxisMatrix(arrowLength + .1);
@@ -120991,8 +121066,10 @@ class Control {
120991
121066
  isObject: false
120992
121067
  }), NO_STATE_INHERIT);
120993
121068
 
121069
+ const localToWorldVec = (localVec, worldVec) => math.vec3ApplyQuaternion(rootNode.quaternion, localVec, worldVec);
121070
+
120994
121071
  const closestPointOnAxis = (function() {
120995
- const worldAxis = math.vec4();
121072
+ const worldAxis = math.vec3();
120996
121073
  const org = math.vec3();
120997
121074
  const dir = math.vec3();
120998
121075
  return (canvasPos, dst) => {
@@ -121027,22 +121104,39 @@ class Control {
121027
121104
  if (closestPointOnAxis(canvasPos, tempVec3)) {
121028
121105
  math.subVec3(tempVec3, initOffset, tempVec3);
121029
121106
  setPos(tempVec3);
121030
- if (self._sectionPlane) {
121031
- self._sectionPlane.pos = tempVec3;
121107
+ if (this._sectionPlane) {
121108
+ this._sectionPlane.pos = tempVec3;
121032
121109
  }
121033
121110
  }
121034
121111
  });
121035
121112
  }
121036
121113
  };
121037
121114
 
121038
- const lastCanvasPos = math.vec2();
121039
121115
  handlers[rotateHandle.id] = {
121040
121116
  setActivated: a => hoop.visible = a,
121041
121117
  initDragAction: (initCanvasPos) => {
121042
- lastCanvasPos.set(initCanvasPos);
121118
+ const rotationFromCanvasPos = (function() {
121119
+ const planeCanvasPos = camera.projectWorldPos(pos);
121120
+ localToWorldVec(rgb, tempVec3);
121121
+ math.transformVec3(camera.normalMatrix, tempVec3, tempVec3);
121122
+ const axisCoeff = Math.sign(tempVec3[2]);
121123
+ return (canvasPos) => {
121124
+ const dx = canvasPos[0] - planeCanvasPos[0];
121125
+ const dy = canvasPos[1] - planeCanvasPos[1];
121126
+ return axisCoeff * Math.atan2(-dy, dx);
121127
+ };
121128
+ })();
121129
+
121130
+ let lastRotation = rotationFromCanvasPos(initCanvasPos);
121131
+
121043
121132
  return canvasPos => {
121044
- dragRotateSectionPlane(rgb, lastCanvasPos, canvasPos);
121045
- lastCanvasPos.set(canvasPos);
121133
+ const rotation = rotationFromCanvasPos(canvasPos);
121134
+ rootNode.rotate(rgb, (rotation - lastRotation) * 180 / Math.PI);
121135
+ if (this._sectionPlane) {
121136
+ ignoreNextSectionPlaneDirUpdate = true;
121137
+ this._sectionPlane.quaternion = rootNode.quaternion;
121138
+ }
121139
+ lastRotation = rotation;
121046
121140
  };
121047
121141
  }
121048
121142
  };
@@ -121154,9 +121248,9 @@ class Control {
121154
121248
  //
121155
121249
  //----------------------------------------------------------------------------------------------------------
121156
121250
 
121157
- addAxis([1,0,0], [ 1, 0, 0 ], [ 1, 0, 0 ]),
121158
- addAxis([0,1,0], [ 0, -1, 0 ], [ 0, 1, 0 ]),
121159
- addAxis([0,0,1], [ 0, 0, -1 ], [ 0, 0, -1 ])
121251
+ addAxis([1,0,0], math.vec3PairToQuaternion([1,0,0], [0,0,1])),
121252
+ addAxis([0,1,0], math.eulerToQuaternion([90,0,0], "XYZ")),
121253
+ addAxis([0,0,1], math.identityQuaternion())
121160
121254
  ];
121161
121255
 
121162
121256
  const cleanups = [ ];
@@ -121178,101 +121272,6 @@ class Control {
121178
121272
  cleanups.push(() => scene.off(onSceneTick));
121179
121273
  }
121180
121274
 
121181
- const localToWorldVec = (function () {
121182
- const mat = math.mat4();
121183
- return function (localVec, worldVec) {
121184
- math.quaternionToMat4(rootNode.quaternion, mat);
121185
- math.transformVec3(mat, localVec, worldVec);
121186
- math.normalizeVec3(worldVec);
121187
- return worldVec;
121188
- };
121189
- })();
121190
-
121191
- const getTranslationPlane = (worldAxis, planeNormal) => {
121192
- const absX = Math.abs(worldAxis[0]);
121193
- if (absX > Math.abs(worldAxis[1]) && absX > Math.abs(worldAxis[2])) {
121194
- math.cross3Vec3(worldAxis, [0, 1, 0], planeNormal);
121195
- } else {
121196
- math.cross3Vec3(worldAxis, [1, 0, 0], planeNormal);
121197
- }
121198
- math.cross3Vec3(planeNormal, worldAxis, planeNormal);
121199
- math.normalizeVec3(planeNormal);
121200
- };
121201
-
121202
- const self = this;
121203
- var dragRotateSectionPlane = (function () {
121204
- const p1 = math.vec4();
121205
- const p2 = math.vec4();
121206
- const c = math.vec4();
121207
- const worldAxis = math.vec4();
121208
- const dir = math.vec3();
121209
- const mat = math.mat4();
121210
- const planeNormal = math.vec3();
121211
- return function (baseAxis, fromMouse, toMouse) {
121212
- localToWorldVec(baseAxis, worldAxis);
121213
- const hasData = getPointerPlaneIntersect(fromMouse, worldAxis, p1) && getPointerPlaneIntersect(toMouse, worldAxis, p2);
121214
- if (!hasData) { // Find intersections with view plane and project down to origin
121215
- getTranslationPlane(worldAxis, planeNormal);
121216
- getPointerPlaneIntersect(fromMouse, planeNormal, p1, 1); // Ensure plane moves closer to camera so angles become workable
121217
- getPointerPlaneIntersect(toMouse, planeNormal, p2, 1);
121218
- var dot = math.dotVec3(p1, worldAxis);
121219
- p1[0] -= dot * worldAxis[0];
121220
- p1[1] -= dot * worldAxis[1];
121221
- p1[2] -= dot * worldAxis[2];
121222
- dot = math.dotVec3(p2, worldAxis);
121223
- p2[0] -= dot * worldAxis[0];
121224
- p2[1] -= dot * worldAxis[1];
121225
- p2[2] -= dot * worldAxis[2];
121226
- }
121227
- math.normalizeVec3(p1);
121228
- math.normalizeVec3(p2);
121229
- dot = math.dotVec3(p1, p2);
121230
- dot = math.clamp(dot, -1.0, 1.0); // Rounding errors cause dot to exceed allowed range
121231
- var incDegrees = Math.acos(dot) * math.RADTODEG;
121232
- math.cross3Vec3(p1, p2, c);
121233
- if (math.dotVec3(c, worldAxis) < 0.0) {
121234
- incDegrees = -incDegrees;
121235
- }
121236
- rootNode.rotate(baseAxis, incDegrees);
121237
-
121238
- if (self._sectionPlane) {
121239
- math.quaternionToMat4(rootNode.quaternion, mat); // << ---
121240
- math.transformVec3(mat, [0, 0, 1], dir);
121241
- ignoreNextSectionPlaneDirUpdate = true;
121242
- self._sectionPlane.dir = dir;
121243
- }
121244
- };
121245
- })();
121246
-
121247
- var getPointerPlaneIntersect = (function () {
121248
- const dir = math.vec4([0, 0, 0, 1]);
121249
- const matrix = math.mat4();
121250
- return function (mouse, axis, dest, offset) {
121251
- offset = offset || 0;
121252
- dir[0] = mouse[0] / canvas.width * 2.0 - 1.0;
121253
- dir[1] = -(mouse[1] / canvas.height * 2.0 - 1.0);
121254
- dir[2] = 0.0;
121255
- dir[3] = 1.0;
121256
- math.mulMat4(camera.projMatrix, camera.viewMatrix, matrix); // Unproject norm device coords to view coords
121257
- math.inverseMat4(matrix);
121258
- math.transformVec4(matrix, dir, dir);
121259
- math.mulVec4Scalar(dir, 1.0 / dir[3]); // This is now point A on the ray in world space
121260
- var rayO = camera.eye; // The direction
121261
- math.subVec4(dir, rayO, dir);
121262
- const origin = self._sectionPlane.pos; // Plane origin:
121263
- var d = -math.dotVec3(origin, axis) - offset;
121264
- var dot = math.dotVec3(axis, dir);
121265
- if (Math.abs(dot) > 0.005) {
121266
- var t = -(math.dotVec3(axis, rayO) + d) / dot;
121267
- math.mulVec3Scalar(dir, t, dest);
121268
- math.addVec3(dest, rayO);
121269
- math.subVec3(dest, origin, dest);
121270
- return true;
121271
- }
121272
- return false;
121273
- };
121274
- })();
121275
-
121276
121275
  {
121277
121276
  let deactivateActive = null;
121278
121277
  let currentDrag = null;
@@ -121389,7 +121388,7 @@ class Control {
121389
121388
  this.id = sectionPlane.id;
121390
121389
  this._sectionPlane = sectionPlane;
121391
121390
  const setPosFromSectionPlane = () => setPos(sectionPlane.pos);
121392
- const setDirFromSectionPlane = () => rootNode.quaternion = math.vec3PairToQuaternion(zeroVec$1, sectionPlane.dir, quat$1);
121391
+ const setDirFromSectionPlane = () => rootNode.quaternion = sectionPlane.quaternion;
121393
121392
  setPosFromSectionPlane();
121394
121393
  setDirFromSectionPlane();
121395
121394
  const onSectionPlanePos = sectionPlane.on("pos", setPosFromSectionPlane);
@@ -126055,6 +126054,8 @@ class TreeViewPlugin extends Plugin {
126055
126054
  * @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
126056
126055
  * @param {Boolean} [cfg.showIndeterminate=false] When true, will show indeterminate state for checkboxes when some but not all child nodes are checked
126057
126056
  * @param {Boolean} [cfg.showProjectNode=false] When true, will show top level project node when hierarchy is set to "storeys"
126057
+ * @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.
126058
+ * @param {Function} [cfg.defaultSortFunction] Optional function to replace the default sort function. The function should take two nodes and return -1, 0 or 1.
126058
126059
  */
126059
126060
  constructor(viewer, cfg = {}) {
126060
126061
 
@@ -126108,6 +126109,8 @@ class TreeViewPlugin extends Plugin {
126108
126109
  this._renderService = cfg.renderService || new RenderService();
126109
126110
  this._showIndeterminate = cfg.showIndeterminate ?? false;
126110
126111
  this._showProjectNode = cfg.showProjectNode ?? false;
126112
+ this._elevationSortFunction = cfg.elevationSortFunction ?? undefined;
126113
+ this._defaultSortFunction = cfg.defaultSortFunction ?? undefined;
126111
126114
 
126112
126115
  if (!this._renderService) {
126113
126116
  throw new Error('TreeViewPlugin: no render service set');
@@ -126921,9 +126924,11 @@ class TreeViewPlugin extends Plugin {
126921
126924
  }
126922
126925
  const firstChild = children[0];
126923
126926
  if ((this._hierarchy === "storeys" || this._hierarchy === "containment") && firstChild.type === "IfcBuildingStorey") {
126924
- children.sort(this._getSpatialSortFunc());
126927
+ if (this._elevationSortFunction) children.sort(this._elevationSortFunction);
126928
+ else children.sort(this._getSpatialSortFunc());
126925
126929
  } else {
126926
- children.sort(this._alphaSortFunc);
126930
+ if (this._defaultSortFunction) children.sort(this._defaultSortFunction);
126931
+ else children.sort(this._alphaSortFunc);
126927
126932
  }
126928
126933
  for (let i = 0, len = children.length; i < len; i++) {
126929
126934
  const node = children[i];