@xeokit/xeokit-sdk 2.6.25 → 2.6.27

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 (26) hide show
  1. package/dist/xeokit-sdk.cjs.js +146 -96
  2. package/dist/xeokit-sdk.es.js +146 -96
  3. package/dist/xeokit-sdk.es5.js +62 -37
  4. package/dist/xeokit-sdk.min.cjs.js +3 -3
  5. package/dist/xeokit-sdk.min.es.js +4 -4
  6. package/dist/xeokit-sdk.min.es5.js +4 -4
  7. package/package.json +1 -1
  8. package/src/plugins/AnnotationsPlugin/Annotation.js +47 -9
  9. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +1 -1
  10. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +10 -10
  11. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +1 -1
  12. package/src/plugins/ZonesPlugin/index.js +3 -3
  13. package/src/plugins/lib/ui/index.js +1 -1
  14. package/src/viewer/scene/CameraControl/CameraControl.js +20 -0
  15. package/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +1 -1
  16. package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +2 -2
  17. package/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +1 -2
  18. package/src/viewer/scene/math/math.js +29 -34
  19. package/src/viewer/scene/mesh/Mesh.js +4 -4
  20. package/src/viewer/scene/scene/Scene.js +6 -21
  21. package/src/viewer/scene/webgl/Renderer.js +21 -8
  22. package/types/plugins/AngleMeasurementsPlugin/AngleMeasurement.d.ts +14 -0
  23. package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.d.ts +81 -1
  24. package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +13 -0
  25. package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.d.ts +15 -0
  26. package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +81 -0
@@ -6190,54 +6190,49 @@ const math = {
6190
6190
  @static
6191
6191
  @param {Number[]} viewMatrix View matrix
6192
6192
  @param {Number[]} projMatrix Projection matrix
6193
+ @param {String} projection Projection type (e.g. "ortho")
6193
6194
  @param {Number[]} canvasPos The Canvas-space position.
6194
6195
  @param {Number[]} worldRayOrigin The World-space ray origin.
6195
6196
  @param {Number[]} worldRayDir The World-space ray direction.
6196
6197
  */
6197
6198
  canvasPosToWorldRay: ((() => {
6198
6199
 
6199
- const tempMat4b = new FloatArrayType(16);
6200
- const tempMat4c = new FloatArrayType(16);
6201
- const tempVec4a = new FloatArrayType(4);
6202
- const tempVec4b = new FloatArrayType(4);
6203
- const tempVec4c = new FloatArrayType(4);
6204
- const tempVec4d = new FloatArrayType(4);
6200
+ const pvMatInv = new FloatArrayType(16);
6201
+ const vec4Near = new FloatArrayType(4);
6202
+ const vec4Far = new FloatArrayType(4);
6205
6203
 
6206
- return (canvas, viewMatrix, projMatrix, canvasPos, worldRayOrigin, worldRayDir) => {
6204
+ const clipToWorld = (clipX, clipY, clipZ, isOrtho, outVec4) => {
6205
+ outVec4[0] = clipX;
6206
+ outVec4[1] = clipY;
6207
+ outVec4[2] = clipZ;
6208
+ outVec4[3] = 1;
6207
6209
 
6208
- const pvMat = math.mulMat4(projMatrix, viewMatrix, tempMat4b);
6209
- const pvMatInverse = math.inverseMat4(pvMat, tempMat4c);
6210
-
6211
- // Calculate clip space coordinates, which will be in range
6212
- // of x=[-1..1] and y=[-1..1], with y=(+1) at top
6210
+ math.transformVec4(pvMatInv, outVec4, outVec4);
6211
+ if (! isOrtho)
6212
+ math.mulVec4Scalar(outVec4, 1 / outVec4[3]);
6213
+ };
6213
6214
 
6214
- const canvasWidth = canvas.width;
6215
- const canvasHeight = canvas.height;
6215
+ return (canvas, viewMatrix, projMatrix, projection, canvasPos, worldRayOrigin, worldRayDir) => {
6216
+ const isOrtho = projection === "ortho";
6216
6217
 
6217
- const clipX = (canvasPos[0] - canvasWidth / 2) / (canvasWidth / 2); // Calculate clip space coordinates
6218
- const clipY = -(canvasPos[1] - canvasHeight / 2) / (canvasHeight / 2);
6218
+ math.mulMat4(projMatrix, viewMatrix, pvMatInv);
6219
+ math.inverseMat4(pvMatInv, pvMatInv);
6219
6220
 
6220
- tempVec4a[0] = clipX;
6221
- tempVec4a[1] = clipY;
6222
- tempVec4a[2] = -1;
6223
- tempVec4a[3] = 1;
6221
+ // Calculate clip space coordinates, which will be in range
6222
+ // of x=[-1..1] and y=[-1..1], with y=(+1) at top
6224
6223
 
6225
- math.transformVec4(pvMatInverse, tempVec4a, tempVec4b);
6226
- math.mulVec4Scalar(tempVec4b, 1 / tempVec4b[3]);
6224
+ const clipX = 2 * canvasPos[0] / canvas.width - 1; // Calculate clip space coordinates
6225
+ const clipY = 1 - 2 * canvasPos[1] / canvas.height;
6227
6226
 
6228
- tempVec4c[0] = clipX;
6229
- tempVec4c[1] = clipY;
6230
- tempVec4c[2] = 1;
6231
- tempVec4c[3] = 1;
6227
+ clipToWorld(clipX, clipY, -1, isOrtho, vec4Near);
6232
6228
 
6233
- math.transformVec4(pvMatInverse, tempVec4c, tempVec4d);
6234
- math.mulVec4Scalar(tempVec4d, 1 / tempVec4d[3]);
6229
+ clipToWorld(clipX, clipY, 1, isOrtho, vec4Far);
6235
6230
 
6236
- worldRayOrigin[0] = tempVec4d[0];
6237
- worldRayOrigin[1] = tempVec4d[1];
6238
- worldRayOrigin[2] = tempVec4d[2];
6231
+ worldRayOrigin[0] = vec4Near[0];
6232
+ worldRayOrigin[1] = vec4Near[1];
6233
+ worldRayOrigin[2] = vec4Near[2];
6239
6234
 
6240
- math.subVec3(tempVec4d, tempVec4b, worldRayDir);
6235
+ math.subVec3(vec4Far, vec4Near, worldRayDir);
6241
6236
 
6242
6237
  math.normalizeVec3(worldRayDir);
6243
6238
  };
@@ -6261,8 +6256,8 @@ const math = {
6261
6256
  const worldRayOrigin = new FloatArrayType(3);
6262
6257
  const worldRayDir = new FloatArrayType(3);
6263
6258
 
6264
- return (canvas, viewMatrix, projMatrix, worldMatrix, canvasPos, localRayOrigin, localRayDir) => {
6265
- math.canvasPosToWorldRay(canvas, viewMatrix, projMatrix, canvasPos, worldRayOrigin, worldRayDir);
6259
+ return (canvas, viewMatrix, projMatrix, projection, worldMatrix, canvasPos, localRayOrigin, localRayDir) => {
6260
+ math.canvasPosToWorldRay(canvas, viewMatrix, projMatrix, projection, canvasPos, worldRayOrigin, worldRayDir);
6266
6261
  math.worldRayToLocalRay(worldMatrix, worldRayOrigin, worldRayDir, localRayOrigin, localRayDir);
6267
6262
  };
6268
6263
  }))(),
@@ -11117,7 +11112,7 @@ function activateDraggableDot(dot, cfg) {
11117
11112
  const pickWorldPos = canvasPos => {
11118
11113
  const origin = math.vec3();
11119
11114
  const direction = math.vec3();
11120
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
11115
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
11121
11116
  return ray2WorldPos(origin, direction, canvasPos);
11122
11117
  };
11123
11118
 
@@ -14525,6 +14520,7 @@ class Annotation extends Marker {
14525
14520
  this._values = cfg.values || {};
14526
14521
  this._layoutDirty = true;
14527
14522
  this._visibilityDirty = true;
14523
+ this._labelPosition = 24;
14528
14524
 
14529
14525
  this._buildHTML();
14530
14526
 
@@ -14655,17 +14651,23 @@ class Annotation extends Marker {
14655
14651
  * @private
14656
14652
  */
14657
14653
  _updatePosition() {
14654
+ const px = x => x + "px";
14658
14655
  const boundary = this.scene.canvas.boundary;
14659
- const left = boundary[0];
14660
- const top = boundary[1];
14661
- const canvasPos = this.canvasPos;
14662
- this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
14663
- this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
14656
+ const left = boundary[0] + this.canvasPos[0];
14657
+ const top = boundary[1] + this.canvasPos[1];
14658
+ const markerRect = this._marker.getBoundingClientRect();
14659
+ const markerWidth = markerRect.width;
14660
+ const markerDir = (this._markerAlign === "right") ? -1 : ((this._markerAlign === "center") ? 0 : 1);
14661
+ const markerCenter = left + markerDir * (markerWidth / 2 - 12);
14662
+ this._marker.style.left = px(markerCenter - markerWidth / 2);
14663
+ this._marker.style.top = px(top - 12);
14664
14664
  this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
14665
- const offsetX = 20;
14666
- const offsetY = -17;
14667
- this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
14668
- this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
14665
+
14666
+ const labelRect = this._label.getBoundingClientRect();
14667
+ const labelWidth = labelRect.width;
14668
+ const labelDir = Math.sign(this._labelPosition);
14669
+ this._label.style.left = px(markerCenter + labelDir * (markerWidth / 2 + Math.abs(this._labelPosition) + labelWidth / 2) - labelWidth / 2);
14670
+ this._label.style.top = px(top - 17);
14669
14671
  this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
14670
14672
  }
14671
14673
 
@@ -14700,6 +14702,37 @@ class Annotation extends Marker {
14700
14702
  }
14701
14703
  }
14702
14704
 
14705
+ /**
14706
+ * Sets the horizontal alignment of the Annotation's marker HTML.
14707
+ *
14708
+ * @param {String} align Either "left", "center", "right" (default "left")
14709
+ */
14710
+ setMarkerAlign(align) {
14711
+ const valid = [ "left", "center", "right" ];
14712
+ if (! valid.includes(align)) {
14713
+ this.error("Param 'align' should be one of: " + JSON.stringify(valid));
14714
+ } else {
14715
+ this._markerAlign = align;
14716
+ this._updatePosition();
14717
+ }
14718
+ }
14719
+
14720
+ /**
14721
+ * Sets the relative horizontal position of the Annotation's label HTML.
14722
+ *
14723
+ * @param {Number} position Negative - to the left, positive - to the right, otherwise ignore (default 24)
14724
+ */
14725
+ setLabelPosition(position) {
14726
+ if (typeof position !== "number") {
14727
+ this.error("Param 'position' is not a number");
14728
+ } else if (position === 0) {
14729
+ this.error("Param 'position' is zero");
14730
+ } else {
14731
+ this._labelPosition = position;
14732
+ this._updatePosition();
14733
+ }
14734
+ }
14735
+
14703
14736
  /**
14704
14737
  * Sets whether or not to show this Annotation's marker.
14705
14738
  *
@@ -19972,6 +20005,7 @@ const Renderer$1 = function (scene, options) {
19972
20005
  let look;
19973
20006
  let pickViewMatrix = null;
19974
20007
  let pickProjMatrix = null;
20008
+ let projection = null;
19975
20009
 
19976
20010
  pickResult.pickSurface = params.pickSurface;
19977
20011
 
@@ -19982,6 +20016,7 @@ const Renderer$1 = function (scene, options) {
19982
20016
 
19983
20017
  pickViewMatrix = scene.camera.viewMatrix;
19984
20018
  pickProjMatrix = scene.camera.projMatrix;
20019
+ projection = scene.camera.projection;
19985
20020
 
19986
20021
  pickResult.canvasPos = params.canvasPos;
19987
20022
 
@@ -19994,6 +20029,7 @@ const Renderer$1 = function (scene, options) {
19994
20029
 
19995
20030
  pickViewMatrix = params.matrix;
19996
20031
  pickProjMatrix = scene.camera.projMatrix;
20032
+ projection = scene.camera.projection;
19997
20033
 
19998
20034
  } else {
19999
20035
 
@@ -20012,6 +20048,7 @@ const Renderer$1 = function (scene, options) {
20012
20048
  pickViewMatrix = math.lookAtMat4v(worldRayOrigin, look, up, tempMat4b);
20013
20049
  // pickProjMatrix = scene.camera.projMatrix;
20014
20050
  pickProjMatrix = scene.camera.ortho.matrix;
20051
+ projection = "ortho";
20015
20052
 
20016
20053
  pickResult.origin = worldRayOrigin;
20017
20054
  pickResult.direction = worldRayDir;
@@ -20059,7 +20096,7 @@ const Renderer$1 = function (scene, options) {
20059
20096
 
20060
20097
  gpuPickTriangle(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, pickResult);
20061
20098
 
20062
- pickable.pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult);
20099
+ pickable.pickTriangleSurface(pickViewMatrix, pickProjMatrix, projection, pickResult);
20063
20100
 
20064
20101
  pickResult.pickSurfacePrecision = false;
20065
20102
 
@@ -20332,7 +20369,9 @@ const Renderer$1 = function (scene, options) {
20332
20369
 
20333
20370
  const _pickResult = new PickResult();
20334
20371
 
20335
- return function (canvasPos, snapRadiusInPixels, snapToVertex, snapToEdge, pickResult = _pickResult) {
20372
+ return function (params, pickResult = _pickResult) {
20373
+
20374
+ const {canvasPos, origin, direction, snapRadius, snapToVertex, snapToEdge} = params;
20336
20375
 
20337
20376
  if (!snapToVertex && !snapToEdge) {
20338
20377
  return this.pick({canvasPos, pickSurface: true});
@@ -20346,7 +20385,7 @@ const Renderer$1 = function (scene, options) {
20346
20385
  frameCtx.pickZNear = scene.camera.project.near;
20347
20386
  frameCtx.pickZFar = scene.camera.project.far;
20348
20387
 
20349
- snapRadiusInPixels = snapRadiusInPixels || 30;
20388
+ const snapRadiusInPixels = snapRadius || 30;
20350
20389
 
20351
20390
  const vertexPickBuffer = renderBufferManager.getRenderBuffer("uniquePickColors-aabs", {
20352
20391
  depthTexture: true,
@@ -20357,8 +20396,8 @@ const Renderer$1 = function (scene, options) {
20357
20396
  });
20358
20397
 
20359
20398
  frameCtx.snapVectorA = [
20360
- getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20361
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20399
+ canvasPos ? getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth) : 0,
20400
+ canvasPos ? getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight) : 0,
20362
20401
  ];
20363
20402
 
20364
20403
  frameCtx.snapInvVectorAB = [
@@ -20385,7 +20424,14 @@ const Renderer$1 = function (scene, options) {
20385
20424
  // Set view and proj mats for VBO renderers
20386
20425
  ///////////////////////////////////////
20387
20426
 
20388
- const pickViewMatrix = scene.camera.viewMatrix;
20427
+ frameCtx.pickViewMatrix = (canvasPos
20428
+ ? scene.camera.viewMatrix
20429
+ : math.lookAtMat4v(
20430
+ origin,
20431
+ math.addVec3(origin, direction, math.vec3()),
20432
+ math.vec3([0, 1, 0]),
20433
+ math.mat4()));
20434
+
20389
20435
  const pickProjMatrix = scene.camera.projMatrix;
20390
20436
 
20391
20437
  for (let type in drawableTypeInfo) {
@@ -20394,7 +20440,7 @@ const Renderer$1 = function (scene, options) {
20394
20440
  for (let i = 0, len = drawableList.length; i < len; i++) {
20395
20441
  const drawable = drawableList[i];
20396
20442
  if (drawable.setPickMatrices) { // Eg. SceneModel, which needs pre-loading into texture
20397
- drawable.setPickMatrices(pickViewMatrix, pickProjMatrix);
20443
+ drawable.setPickMatrices(frameCtx.pickViewMatrix, pickProjMatrix);
20398
20444
  }
20399
20445
  }
20400
20446
  }
@@ -20571,7 +20617,7 @@ const Renderer$1 = function (scene, options) {
20571
20617
  pickResult.worldPos = snappedWorldPos;
20572
20618
  pickResult.worldNormal = snappedWorldNormal;
20573
20619
  pickResult.entity = snappedEntity;
20574
- pickResult.canvasPos = canvasPos;
20620
+ pickResult.canvasPos = canvasPos || scene.camera.projectWorldPos(worldPos || snappedWorldPos);
20575
20621
  pickResult.snappedCanvasPos = snappedCanvasPos || canvasPos;
20576
20622
 
20577
20623
  return pickResult;
@@ -31773,10 +31819,10 @@ class Scene extends Component {
31773
31819
  */
31774
31820
  get center() {
31775
31821
  if (this._aabbDirty || !this._center) {
31776
- if (!this._center || !this._center) {
31822
+ const aabb = this.aabb;
31823
+ if (!this._center) {
31777
31824
  this._center = math.vec3();
31778
31825
  }
31779
- const aabb = this.aabb;
31780
31826
  this._center[0] = (aabb[0] + aabb[3]) / 2;
31781
31827
  this._center[1] = (aabb[1] + aabb[4]) / 2;
31782
31828
  this._center[2] = (aabb[2] + aabb[5]) / 2;
@@ -31851,6 +31897,7 @@ class Scene extends Component {
31851
31897
  this._aabb[4] = ymax;
31852
31898
  this._aabb[5] = zmax;
31853
31899
  this._aabbDirty = false;
31900
+ this._center = null;
31854
31901
  }
31855
31902
  return this._aabb;
31856
31903
  }
@@ -31976,11 +32023,6 @@ class Scene extends Component {
31976
32023
  return null;
31977
32024
  }
31978
32025
 
31979
- if ((params.snapToVertex || params.snapToEdge) && !params.canvasPos) {
31980
- this.error("Scene.snapPick() `canvasPos` parameter expected for `snapToVertex:true` or `snapToEdge:true`");
31981
- return;
31982
- }
31983
-
31984
32026
  params = params || {};
31985
32027
 
31986
32028
  params.pickSurface = params.pickSurface || params.rayPick; // Backwards compatibility
@@ -32006,13 +32048,7 @@ class Scene extends Component {
32006
32048
  }
32007
32049
 
32008
32050
  if (params.snapToEdge || params.snapToVertex) {
32009
- pickResult = this._renderer.snapPick(
32010
- params.canvasPos,
32011
- params.snapRadius || 30,
32012
- params.snapToVertex,
32013
- params.snapToEdge,
32014
- pickResult
32015
- );
32051
+ pickResult = this._renderer.snapPick(params, pickResult);
32016
32052
  } else {
32017
32053
  pickResult = this._renderer.pick(params, pickResult);
32018
32054
  }
@@ -32043,12 +32079,7 @@ class Scene extends Component {
32043
32079
  this.error("Scene.snapPick() canvasPos parameter expected");
32044
32080
  return;
32045
32081
  }
32046
- return this._renderer.snapPick(
32047
- params.canvasPos,
32048
- params.snapRadius || 30,
32049
- params.snapToVertex,
32050
- params.snapToEdge,
32051
- );
32082
+ return this._renderer.snapPick(params);
32052
32083
  }
32053
32084
 
32054
32085
  /**
@@ -39786,8 +39817,8 @@ class Mesh extends Component {
39786
39817
  }
39787
39818
 
39788
39819
  /** @private */
39789
- pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult) {
39790
- pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, pickResult);
39820
+ pickTriangleSurface(pickViewMatrix, pickProjMatrix, projection, pickResult) {
39821
+ pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, projection, pickResult);
39791
39822
  }
39792
39823
 
39793
39824
  /** @private */
@@ -39879,7 +39910,7 @@ const pickTriangleSurface = (function () {
39879
39910
  const tempVec3j = math.vec3();
39880
39911
  const tempVec3k = math.vec3();
39881
39912
 
39882
- return function (mesh, pickViewMatrix, pickProjMatrix, pickResult) {
39913
+ return function (mesh, pickViewMatrix, pickProjMatrix, projection, pickResult) {
39883
39914
 
39884
39915
  var primIndex = pickResult.primIndex;
39885
39916
 
@@ -39958,7 +39989,7 @@ const pickTriangleSurface = (function () {
39958
39989
  // Attempt to ray-pick the triangle in local space
39959
39990
 
39960
39991
  if (pickResult.canvasPos) {
39961
- math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
39992
+ math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, projection, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
39962
39993
 
39963
39994
  } else if (pickResult.origin && pickResult.direction) {
39964
39995
  math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
@@ -87533,7 +87564,7 @@ class DistanceMeasurement extends Component {
87533
87564
  }
87534
87565
 
87535
87566
  if (!this._zAxisLabelCulled) {
87536
- if(this._measurementOrientation === 'Vertical') {
87567
+ if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
87537
87568
  this._zAxisLabel.setPrefix("");
87538
87569
  this._zAxisLabel.setText(tilde + Math.abs(math.lenVec3(math.subVec3(this._targetWorld, [this._originWorld[0], this._targetWorld[1], this._originWorld[2]], distVec3)) * scale).toFixed(2) + unitAbbrev);
87539
87570
  }
@@ -88571,27 +88602,27 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
88571
88602
  if (!this._active) {
88572
88603
  return;
88573
88604
  }
88574
-
88605
+
88575
88606
  this.fire("activated", false);
88576
88607
 
88577
88608
  if (this.pointerLens) {
88578
88609
  this.pointerLens.visible = false;
88579
88610
  }
88580
- if (this._markerDiv) {
88581
- this._destroyMarkerDiv();
88582
- }
88583
- this.reset();
88611
+ // if (this._markerDiv) {
88612
+ // this._destroyMarkerDiv()
88613
+ // }
88614
+ // this.reset();
88584
88615
  const canvas = this.scene.canvas.canvas;
88585
88616
  canvas.removeEventListener("mousedown", this._onMouseDown);
88586
88617
  canvas.removeEventListener("mouseup", this._onMouseUp);
88587
88618
  const cameraControl = this.distanceMeasurementsPlugin.viewer.cameraControl;
88588
88619
  cameraControl.off(this._onCameraControlHoverSnapOrSurface);
88589
88620
  cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);
88590
- if (this._currentDistanceMeasurement) {
88591
- this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
88592
- this._currentDistanceMeasurement.destroy();
88593
- this._currentDistanceMeasurement = null;
88594
- }
88621
+ // if (this._currentDistanceMeasurement) {
88622
+ // this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
88623
+ // this._currentDistanceMeasurement.destroy();
88624
+ // this._currentDistanceMeasurement = null;
88625
+ // }
88595
88626
  this._active = false;
88596
88627
  }
88597
88628
 
@@ -89126,7 +89157,7 @@ class DistanceMeasurementsPlugin extends Plugin {
89126
89157
  axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
89127
89158
  xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
89128
89159
  yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
89129
- zAxisVisibld: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
89160
+ zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
89130
89161
  xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
89131
89162
  yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
89132
89163
  zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
@@ -96770,7 +96801,7 @@ class KeyboardAxisViewHandler {
96770
96801
  return;
96771
96802
  }
96772
96803
 
96773
- if (!states.mouseover) {
96804
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
96774
96805
  return;
96775
96806
  }
96776
96807
 
@@ -96919,8 +96950,7 @@ class MousePickHandler {
96919
96950
  {
96920
96951
  const origin = math.vec3();
96921
96952
  const direction = math.vec3();
96922
- // The origin from math.canvasPosToWorldRay is incorrect for a perspective camera, should be the same as scene.camera.eye
96923
- math.canvasPosToWorldRay(scene.canvas.canvas, scene.camera.viewMatrix, scene.camera.projMatrix, states.pointerCanvasPos, origin, direction);
96953
+ math.canvasPosToWorldRay(scene.canvas.canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, states.pointerCanvasPos, origin, direction);
96924
96954
  cameraControl.fire("rayMove", { canvasPos: states.pointerCanvasPos, ray: { origin: origin, direction: direction, canvasPos: states.pointerCanvasPos } }, true);
96925
96955
  }
96926
96956
 
@@ -97264,7 +97294,7 @@ class KeyboardPanRotateDollyHandler {
97264
97294
  if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
97265
97295
  return;
97266
97296
  }
97267
- if (!states.mouseover) {
97297
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
97268
97298
  return;
97269
97299
  }
97270
97300
  keyDownMap[keyCode] = true;
@@ -97295,7 +97325,7 @@ class KeyboardPanRotateDollyHandler {
97295
97325
  return;
97296
97326
  }
97297
97327
 
97298
- if (!states.mouseover) {
97328
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
97299
97329
  return;
97300
97330
  }
97301
97331
 
@@ -98936,6 +98966,8 @@ class CameraControl extends Component {
98936
98966
  snapToEdge: DEFAULT_SNAP_EDGE,
98937
98967
  snapRadius: DEFAULT_SNAP_PICK_RADIUS,
98938
98968
 
98969
+ keyboardEnabledOnlyIfMouseover: true,
98970
+
98939
98971
  // Rotation
98940
98972
 
98941
98973
  dragRotationRate: 360.0,
@@ -99246,6 +99278,24 @@ class CameraControl extends Component {
99246
99278
  get snapRadius() {
99247
99279
  return this._configs.snapRadius;
99248
99280
  }
99281
+
99282
+ /**
99283
+ * If `true`, the keyboard shortcuts are enabled ONLY if the mouse is over the canvas.
99284
+ *
99285
+ * @param {boolean} value
99286
+ */
99287
+ set keyboardEnabledOnlyIfMouseover(value) {
99288
+ this._configs.keyboardEnabledOnlyIfMouseover = !!value;
99289
+ }
99290
+
99291
+ /**
99292
+ * Gets whether the keyboard shortcuts are enabled ONLY if the mouse is over the canvas or ALWAYS.
99293
+ *
99294
+ * @returns {boolean}
99295
+ */
99296
+ get keyboardEnabledOnlyIfMouseover() {
99297
+ return this._configs.keyboardEnabledOnlyIfMouseover;
99298
+ }
99249
99299
 
99250
99300
  /**
99251
99301
  * Sets the current navigation mode.
@@ -139008,7 +139058,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
139008
139058
  const pickWorldPos = canvasPos => {
139009
139059
  const origin = math.vec3();
139010
139060
  const direction = math.vec3();
139011
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
139061
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
139012
139062
  return ray2WorldPos(origin, direction);
139013
139063
  };
139014
139064
 
@@ -139083,7 +139133,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
139083
139133
  const pickWorldPos = canvasPos => {
139084
139134
  const origin = math.vec3();
139085
139135
  const direction = math.vec3();
139086
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
139136
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
139087
139137
  return ray2WorldPos(origin, direction);
139088
139138
  };
139089
139139
 
@@ -140303,7 +140353,7 @@ class ZoneTranslateControl extends Component {
140303
140353
  const pickWorldPos = canvasPos => {
140304
140354
  const origin = math.vec3();
140305
140355
  const direction = math.vec3();
140306
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
140356
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
140307
140357
  return ray2WorldPos(origin, direction);
140308
140358
  };
140309
140359