@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
@@ -6194,54 +6194,49 @@ const math = {
6194
6194
  @static
6195
6195
  @param {Number[]} viewMatrix View matrix
6196
6196
  @param {Number[]} projMatrix Projection matrix
6197
+ @param {String} projection Projection type (e.g. "ortho")
6197
6198
  @param {Number[]} canvasPos The Canvas-space position.
6198
6199
  @param {Number[]} worldRayOrigin The World-space ray origin.
6199
6200
  @param {Number[]} worldRayDir The World-space ray direction.
6200
6201
  */
6201
6202
  canvasPosToWorldRay: ((() => {
6202
6203
 
6203
- const tempMat4b = new FloatArrayType(16);
6204
- const tempMat4c = new FloatArrayType(16);
6205
- const tempVec4a = new FloatArrayType(4);
6206
- const tempVec4b = new FloatArrayType(4);
6207
- const tempVec4c = new FloatArrayType(4);
6208
- const tempVec4d = new FloatArrayType(4);
6204
+ const pvMatInv = new FloatArrayType(16);
6205
+ const vec4Near = new FloatArrayType(4);
6206
+ const vec4Far = new FloatArrayType(4);
6209
6207
 
6210
- return (canvas, viewMatrix, projMatrix, canvasPos, worldRayOrigin, worldRayDir) => {
6208
+ const clipToWorld = (clipX, clipY, clipZ, isOrtho, outVec4) => {
6209
+ outVec4[0] = clipX;
6210
+ outVec4[1] = clipY;
6211
+ outVec4[2] = clipZ;
6212
+ outVec4[3] = 1;
6211
6213
 
6212
- const pvMat = math.mulMat4(projMatrix, viewMatrix, tempMat4b);
6213
- const pvMatInverse = math.inverseMat4(pvMat, tempMat4c);
6214
-
6215
- // Calculate clip space coordinates, which will be in range
6216
- // of x=[-1..1] and y=[-1..1], with y=(+1) at top
6214
+ math.transformVec4(pvMatInv, outVec4, outVec4);
6215
+ if (! isOrtho)
6216
+ math.mulVec4Scalar(outVec4, 1 / outVec4[3]);
6217
+ };
6217
6218
 
6218
- const canvasWidth = canvas.width;
6219
- const canvasHeight = canvas.height;
6219
+ return (canvas, viewMatrix, projMatrix, projection, canvasPos, worldRayOrigin, worldRayDir) => {
6220
+ const isOrtho = projection === "ortho";
6220
6221
 
6221
- const clipX = (canvasPos[0] - canvasWidth / 2) / (canvasWidth / 2); // Calculate clip space coordinates
6222
- const clipY = -(canvasPos[1] - canvasHeight / 2) / (canvasHeight / 2);
6222
+ math.mulMat4(projMatrix, viewMatrix, pvMatInv);
6223
+ math.inverseMat4(pvMatInv, pvMatInv);
6223
6224
 
6224
- tempVec4a[0] = clipX;
6225
- tempVec4a[1] = clipY;
6226
- tempVec4a[2] = -1;
6227
- tempVec4a[3] = 1;
6225
+ // Calculate clip space coordinates, which will be in range
6226
+ // of x=[-1..1] and y=[-1..1], with y=(+1) at top
6228
6227
 
6229
- math.transformVec4(pvMatInverse, tempVec4a, tempVec4b);
6230
- math.mulVec4Scalar(tempVec4b, 1 / tempVec4b[3]);
6228
+ const clipX = 2 * canvasPos[0] / canvas.width - 1; // Calculate clip space coordinates
6229
+ const clipY = 1 - 2 * canvasPos[1] / canvas.height;
6231
6230
 
6232
- tempVec4c[0] = clipX;
6233
- tempVec4c[1] = clipY;
6234
- tempVec4c[2] = 1;
6235
- tempVec4c[3] = 1;
6231
+ clipToWorld(clipX, clipY, -1, isOrtho, vec4Near);
6236
6232
 
6237
- math.transformVec4(pvMatInverse, tempVec4c, tempVec4d);
6238
- math.mulVec4Scalar(tempVec4d, 1 / tempVec4d[3]);
6233
+ clipToWorld(clipX, clipY, 1, isOrtho, vec4Far);
6239
6234
 
6240
- worldRayOrigin[0] = tempVec4d[0];
6241
- worldRayOrigin[1] = tempVec4d[1];
6242
- worldRayOrigin[2] = tempVec4d[2];
6235
+ worldRayOrigin[0] = vec4Near[0];
6236
+ worldRayOrigin[1] = vec4Near[1];
6237
+ worldRayOrigin[2] = vec4Near[2];
6243
6238
 
6244
- math.subVec3(tempVec4d, tempVec4b, worldRayDir);
6239
+ math.subVec3(vec4Far, vec4Near, worldRayDir);
6245
6240
 
6246
6241
  math.normalizeVec3(worldRayDir);
6247
6242
  };
@@ -6265,8 +6260,8 @@ const math = {
6265
6260
  const worldRayOrigin = new FloatArrayType(3);
6266
6261
  const worldRayDir = new FloatArrayType(3);
6267
6262
 
6268
- return (canvas, viewMatrix, projMatrix, worldMatrix, canvasPos, localRayOrigin, localRayDir) => {
6269
- math.canvasPosToWorldRay(canvas, viewMatrix, projMatrix, canvasPos, worldRayOrigin, worldRayDir);
6263
+ return (canvas, viewMatrix, projMatrix, projection, worldMatrix, canvasPos, localRayOrigin, localRayDir) => {
6264
+ math.canvasPosToWorldRay(canvas, viewMatrix, projMatrix, projection, canvasPos, worldRayOrigin, worldRayDir);
6270
6265
  math.worldRayToLocalRay(worldMatrix, worldRayOrigin, worldRayDir, localRayOrigin, localRayDir);
6271
6266
  };
6272
6267
  }))(),
@@ -11121,7 +11116,7 @@ function activateDraggableDot(dot, cfg) {
11121
11116
  const pickWorldPos = canvasPos => {
11122
11117
  const origin = math.vec3();
11123
11118
  const direction = math.vec3();
11124
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
11119
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
11125
11120
  return ray2WorldPos(origin, direction, canvasPos);
11126
11121
  };
11127
11122
 
@@ -14529,6 +14524,7 @@ class Annotation extends Marker {
14529
14524
  this._values = cfg.values || {};
14530
14525
  this._layoutDirty = true;
14531
14526
  this._visibilityDirty = true;
14527
+ this._labelPosition = 24;
14532
14528
 
14533
14529
  this._buildHTML();
14534
14530
 
@@ -14659,17 +14655,23 @@ class Annotation extends Marker {
14659
14655
  * @private
14660
14656
  */
14661
14657
  _updatePosition() {
14658
+ const px = x => x + "px";
14662
14659
  const boundary = this.scene.canvas.boundary;
14663
- const left = boundary[0];
14664
- const top = boundary[1];
14665
- const canvasPos = this.canvasPos;
14666
- this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
14667
- this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
14660
+ const left = boundary[0] + this.canvasPos[0];
14661
+ const top = boundary[1] + this.canvasPos[1];
14662
+ const markerRect = this._marker.getBoundingClientRect();
14663
+ const markerWidth = markerRect.width;
14664
+ const markerDir = (this._markerAlign === "right") ? -1 : ((this._markerAlign === "center") ? 0 : 1);
14665
+ const markerCenter = left + markerDir * (markerWidth / 2 - 12);
14666
+ this._marker.style.left = px(markerCenter - markerWidth / 2);
14667
+ this._marker.style.top = px(top - 12);
14668
14668
  this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
14669
- const offsetX = 20;
14670
- const offsetY = -17;
14671
- this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
14672
- this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
14669
+
14670
+ const labelRect = this._label.getBoundingClientRect();
14671
+ const labelWidth = labelRect.width;
14672
+ const labelDir = Math.sign(this._labelPosition);
14673
+ this._label.style.left = px(markerCenter + labelDir * (markerWidth / 2 + Math.abs(this._labelPosition) + labelWidth / 2) - labelWidth / 2);
14674
+ this._label.style.top = px(top - 17);
14673
14675
  this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
14674
14676
  }
14675
14677
 
@@ -14704,6 +14706,37 @@ class Annotation extends Marker {
14704
14706
  }
14705
14707
  }
14706
14708
 
14709
+ /**
14710
+ * Sets the horizontal alignment of the Annotation's marker HTML.
14711
+ *
14712
+ * @param {String} align Either "left", "center", "right" (default "left")
14713
+ */
14714
+ setMarkerAlign(align) {
14715
+ const valid = [ "left", "center", "right" ];
14716
+ if (! valid.includes(align)) {
14717
+ this.error("Param 'align' should be one of: " + JSON.stringify(valid));
14718
+ } else {
14719
+ this._markerAlign = align;
14720
+ this._updatePosition();
14721
+ }
14722
+ }
14723
+
14724
+ /**
14725
+ * Sets the relative horizontal position of the Annotation's label HTML.
14726
+ *
14727
+ * @param {Number} position Negative - to the left, positive - to the right, otherwise ignore (default 24)
14728
+ */
14729
+ setLabelPosition(position) {
14730
+ if (typeof position !== "number") {
14731
+ this.error("Param 'position' is not a number");
14732
+ } else if (position === 0) {
14733
+ this.error("Param 'position' is zero");
14734
+ } else {
14735
+ this._labelPosition = position;
14736
+ this._updatePosition();
14737
+ }
14738
+ }
14739
+
14707
14740
  /**
14708
14741
  * Sets whether or not to show this Annotation's marker.
14709
14742
  *
@@ -19976,6 +20009,7 @@ const Renderer$1 = function (scene, options) {
19976
20009
  let look;
19977
20010
  let pickViewMatrix = null;
19978
20011
  let pickProjMatrix = null;
20012
+ let projection = null;
19979
20013
 
19980
20014
  pickResult.pickSurface = params.pickSurface;
19981
20015
 
@@ -19986,6 +20020,7 @@ const Renderer$1 = function (scene, options) {
19986
20020
 
19987
20021
  pickViewMatrix = scene.camera.viewMatrix;
19988
20022
  pickProjMatrix = scene.camera.projMatrix;
20023
+ projection = scene.camera.projection;
19989
20024
 
19990
20025
  pickResult.canvasPos = params.canvasPos;
19991
20026
 
@@ -19998,6 +20033,7 @@ const Renderer$1 = function (scene, options) {
19998
20033
 
19999
20034
  pickViewMatrix = params.matrix;
20000
20035
  pickProjMatrix = scene.camera.projMatrix;
20036
+ projection = scene.camera.projection;
20001
20037
 
20002
20038
  } else {
20003
20039
 
@@ -20016,6 +20052,7 @@ const Renderer$1 = function (scene, options) {
20016
20052
  pickViewMatrix = math.lookAtMat4v(worldRayOrigin, look, up, tempMat4b);
20017
20053
  // pickProjMatrix = scene.camera.projMatrix;
20018
20054
  pickProjMatrix = scene.camera.ortho.matrix;
20055
+ projection = "ortho";
20019
20056
 
20020
20057
  pickResult.origin = worldRayOrigin;
20021
20058
  pickResult.direction = worldRayDir;
@@ -20063,7 +20100,7 @@ const Renderer$1 = function (scene, options) {
20063
20100
 
20064
20101
  gpuPickTriangle(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, pickResult);
20065
20102
 
20066
- pickable.pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult);
20103
+ pickable.pickTriangleSurface(pickViewMatrix, pickProjMatrix, projection, pickResult);
20067
20104
 
20068
20105
  pickResult.pickSurfacePrecision = false;
20069
20106
 
@@ -20336,7 +20373,9 @@ const Renderer$1 = function (scene, options) {
20336
20373
 
20337
20374
  const _pickResult = new PickResult();
20338
20375
 
20339
- return function (canvasPos, snapRadiusInPixels, snapToVertex, snapToEdge, pickResult = _pickResult) {
20376
+ return function (params, pickResult = _pickResult) {
20377
+
20378
+ const {canvasPos, origin, direction, snapRadius, snapToVertex, snapToEdge} = params;
20340
20379
 
20341
20380
  if (!snapToVertex && !snapToEdge) {
20342
20381
  return this.pick({canvasPos, pickSurface: true});
@@ -20350,7 +20389,7 @@ const Renderer$1 = function (scene, options) {
20350
20389
  frameCtx.pickZNear = scene.camera.project.near;
20351
20390
  frameCtx.pickZFar = scene.camera.project.far;
20352
20391
 
20353
- snapRadiusInPixels = snapRadiusInPixels || 30;
20392
+ const snapRadiusInPixels = snapRadius || 30;
20354
20393
 
20355
20394
  const vertexPickBuffer = renderBufferManager.getRenderBuffer("uniquePickColors-aabs", {
20356
20395
  depthTexture: true,
@@ -20361,8 +20400,8 @@ const Renderer$1 = function (scene, options) {
20361
20400
  });
20362
20401
 
20363
20402
  frameCtx.snapVectorA = [
20364
- getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20365
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20403
+ canvasPos ? getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth) : 0,
20404
+ canvasPos ? getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight) : 0,
20366
20405
  ];
20367
20406
 
20368
20407
  frameCtx.snapInvVectorAB = [
@@ -20389,7 +20428,14 @@ const Renderer$1 = function (scene, options) {
20389
20428
  // Set view and proj mats for VBO renderers
20390
20429
  ///////////////////////////////////////
20391
20430
 
20392
- const pickViewMatrix = scene.camera.viewMatrix;
20431
+ frameCtx.pickViewMatrix = (canvasPos
20432
+ ? scene.camera.viewMatrix
20433
+ : math.lookAtMat4v(
20434
+ origin,
20435
+ math.addVec3(origin, direction, math.vec3()),
20436
+ math.vec3([0, 1, 0]),
20437
+ math.mat4()));
20438
+
20393
20439
  const pickProjMatrix = scene.camera.projMatrix;
20394
20440
 
20395
20441
  for (let type in drawableTypeInfo) {
@@ -20398,7 +20444,7 @@ const Renderer$1 = function (scene, options) {
20398
20444
  for (let i = 0, len = drawableList.length; i < len; i++) {
20399
20445
  const drawable = drawableList[i];
20400
20446
  if (drawable.setPickMatrices) { // Eg. SceneModel, which needs pre-loading into texture
20401
- drawable.setPickMatrices(pickViewMatrix, pickProjMatrix);
20447
+ drawable.setPickMatrices(frameCtx.pickViewMatrix, pickProjMatrix);
20402
20448
  }
20403
20449
  }
20404
20450
  }
@@ -20575,7 +20621,7 @@ const Renderer$1 = function (scene, options) {
20575
20621
  pickResult.worldPos = snappedWorldPos;
20576
20622
  pickResult.worldNormal = snappedWorldNormal;
20577
20623
  pickResult.entity = snappedEntity;
20578
- pickResult.canvasPos = canvasPos;
20624
+ pickResult.canvasPos = canvasPos || scene.camera.projectWorldPos(worldPos || snappedWorldPos);
20579
20625
  pickResult.snappedCanvasPos = snappedCanvasPos || canvasPos;
20580
20626
 
20581
20627
  return pickResult;
@@ -31777,10 +31823,10 @@ class Scene extends Component {
31777
31823
  */
31778
31824
  get center() {
31779
31825
  if (this._aabbDirty || !this._center) {
31780
- if (!this._center || !this._center) {
31826
+ const aabb = this.aabb;
31827
+ if (!this._center) {
31781
31828
  this._center = math.vec3();
31782
31829
  }
31783
- const aabb = this.aabb;
31784
31830
  this._center[0] = (aabb[0] + aabb[3]) / 2;
31785
31831
  this._center[1] = (aabb[1] + aabb[4]) / 2;
31786
31832
  this._center[2] = (aabb[2] + aabb[5]) / 2;
@@ -31855,6 +31901,7 @@ class Scene extends Component {
31855
31901
  this._aabb[4] = ymax;
31856
31902
  this._aabb[5] = zmax;
31857
31903
  this._aabbDirty = false;
31904
+ this._center = null;
31858
31905
  }
31859
31906
  return this._aabb;
31860
31907
  }
@@ -31980,11 +32027,6 @@ class Scene extends Component {
31980
32027
  return null;
31981
32028
  }
31982
32029
 
31983
- if ((params.snapToVertex || params.snapToEdge) && !params.canvasPos) {
31984
- this.error("Scene.snapPick() `canvasPos` parameter expected for `snapToVertex:true` or `snapToEdge:true`");
31985
- return;
31986
- }
31987
-
31988
32030
  params = params || {};
31989
32031
 
31990
32032
  params.pickSurface = params.pickSurface || params.rayPick; // Backwards compatibility
@@ -32010,13 +32052,7 @@ class Scene extends Component {
32010
32052
  }
32011
32053
 
32012
32054
  if (params.snapToEdge || params.snapToVertex) {
32013
- pickResult = this._renderer.snapPick(
32014
- params.canvasPos,
32015
- params.snapRadius || 30,
32016
- params.snapToVertex,
32017
- params.snapToEdge,
32018
- pickResult
32019
- );
32055
+ pickResult = this._renderer.snapPick(params, pickResult);
32020
32056
  } else {
32021
32057
  pickResult = this._renderer.pick(params, pickResult);
32022
32058
  }
@@ -32047,12 +32083,7 @@ class Scene extends Component {
32047
32083
  this.error("Scene.snapPick() canvasPos parameter expected");
32048
32084
  return;
32049
32085
  }
32050
- return this._renderer.snapPick(
32051
- params.canvasPos,
32052
- params.snapRadius || 30,
32053
- params.snapToVertex,
32054
- params.snapToEdge,
32055
- );
32086
+ return this._renderer.snapPick(params);
32056
32087
  }
32057
32088
 
32058
32089
  /**
@@ -39790,8 +39821,8 @@ class Mesh extends Component {
39790
39821
  }
39791
39822
 
39792
39823
  /** @private */
39793
- pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult) {
39794
- pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, pickResult);
39824
+ pickTriangleSurface(pickViewMatrix, pickProjMatrix, projection, pickResult) {
39825
+ pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, projection, pickResult);
39795
39826
  }
39796
39827
 
39797
39828
  /** @private */
@@ -39883,7 +39914,7 @@ const pickTriangleSurface = (function () {
39883
39914
  const tempVec3j = math.vec3();
39884
39915
  const tempVec3k = math.vec3();
39885
39916
 
39886
- return function (mesh, pickViewMatrix, pickProjMatrix, pickResult) {
39917
+ return function (mesh, pickViewMatrix, pickProjMatrix, projection, pickResult) {
39887
39918
 
39888
39919
  var primIndex = pickResult.primIndex;
39889
39920
 
@@ -39962,7 +39993,7 @@ const pickTriangleSurface = (function () {
39962
39993
  // Attempt to ray-pick the triangle in local space
39963
39994
 
39964
39995
  if (pickResult.canvasPos) {
39965
- math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
39996
+ math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, projection, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
39966
39997
 
39967
39998
  } else if (pickResult.origin && pickResult.direction) {
39968
39999
  math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
@@ -87537,7 +87568,7 @@ class DistanceMeasurement extends Component {
87537
87568
  }
87538
87569
 
87539
87570
  if (!this._zAxisLabelCulled) {
87540
- if(this._measurementOrientation === 'Vertical') {
87571
+ if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
87541
87572
  this._zAxisLabel.setPrefix("");
87542
87573
  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);
87543
87574
  }
@@ -88575,27 +88606,27 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
88575
88606
  if (!this._active) {
88576
88607
  return;
88577
88608
  }
88578
-
88609
+
88579
88610
  this.fire("activated", false);
88580
88611
 
88581
88612
  if (this.pointerLens) {
88582
88613
  this.pointerLens.visible = false;
88583
88614
  }
88584
- if (this._markerDiv) {
88585
- this._destroyMarkerDiv();
88586
- }
88587
- this.reset();
88615
+ // if (this._markerDiv) {
88616
+ // this._destroyMarkerDiv()
88617
+ // }
88618
+ // this.reset();
88588
88619
  const canvas = this.scene.canvas.canvas;
88589
88620
  canvas.removeEventListener("mousedown", this._onMouseDown);
88590
88621
  canvas.removeEventListener("mouseup", this._onMouseUp);
88591
88622
  const cameraControl = this.distanceMeasurementsPlugin.viewer.cameraControl;
88592
88623
  cameraControl.off(this._onCameraControlHoverSnapOrSurface);
88593
88624
  cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);
88594
- if (this._currentDistanceMeasurement) {
88595
- this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
88596
- this._currentDistanceMeasurement.destroy();
88597
- this._currentDistanceMeasurement = null;
88598
- }
88625
+ // if (this._currentDistanceMeasurement) {
88626
+ // this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
88627
+ // this._currentDistanceMeasurement.destroy();
88628
+ // this._currentDistanceMeasurement = null;
88629
+ // }
88599
88630
  this._active = false;
88600
88631
  }
88601
88632
 
@@ -89130,7 +89161,7 @@ class DistanceMeasurementsPlugin extends Plugin {
89130
89161
  axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
89131
89162
  xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
89132
89163
  yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
89133
- zAxisVisibld: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
89164
+ zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
89134
89165
  xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
89135
89166
  yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
89136
89167
  zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
@@ -96774,7 +96805,7 @@ class KeyboardAxisViewHandler {
96774
96805
  return;
96775
96806
  }
96776
96807
 
96777
- if (!states.mouseover) {
96808
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
96778
96809
  return;
96779
96810
  }
96780
96811
 
@@ -96923,8 +96954,7 @@ class MousePickHandler {
96923
96954
  {
96924
96955
  const origin = math.vec3();
96925
96956
  const direction = math.vec3();
96926
- // The origin from math.canvasPosToWorldRay is incorrect for a perspective camera, should be the same as scene.camera.eye
96927
- math.canvasPosToWorldRay(scene.canvas.canvas, scene.camera.viewMatrix, scene.camera.projMatrix, states.pointerCanvasPos, origin, direction);
96957
+ math.canvasPosToWorldRay(scene.canvas.canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, states.pointerCanvasPos, origin, direction);
96928
96958
  cameraControl.fire("rayMove", { canvasPos: states.pointerCanvasPos, ray: { origin: origin, direction: direction, canvasPos: states.pointerCanvasPos } }, true);
96929
96959
  }
96930
96960
 
@@ -97268,7 +97298,7 @@ class KeyboardPanRotateDollyHandler {
97268
97298
  if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
97269
97299
  return;
97270
97300
  }
97271
- if (!states.mouseover) {
97301
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
97272
97302
  return;
97273
97303
  }
97274
97304
  keyDownMap[keyCode] = true;
@@ -97299,7 +97329,7 @@ class KeyboardPanRotateDollyHandler {
97299
97329
  return;
97300
97330
  }
97301
97331
 
97302
- if (!states.mouseover) {
97332
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
97303
97333
  return;
97304
97334
  }
97305
97335
 
@@ -98940,6 +98970,8 @@ class CameraControl extends Component {
98940
98970
  snapToEdge: DEFAULT_SNAP_EDGE,
98941
98971
  snapRadius: DEFAULT_SNAP_PICK_RADIUS,
98942
98972
 
98973
+ keyboardEnabledOnlyIfMouseover: true,
98974
+
98943
98975
  // Rotation
98944
98976
 
98945
98977
  dragRotationRate: 360.0,
@@ -99250,6 +99282,24 @@ class CameraControl extends Component {
99250
99282
  get snapRadius() {
99251
99283
  return this._configs.snapRadius;
99252
99284
  }
99285
+
99286
+ /**
99287
+ * If `true`, the keyboard shortcuts are enabled ONLY if the mouse is over the canvas.
99288
+ *
99289
+ * @param {boolean} value
99290
+ */
99291
+ set keyboardEnabledOnlyIfMouseover(value) {
99292
+ this._configs.keyboardEnabledOnlyIfMouseover = !!value;
99293
+ }
99294
+
99295
+ /**
99296
+ * Gets whether the keyboard shortcuts are enabled ONLY if the mouse is over the canvas or ALWAYS.
99297
+ *
99298
+ * @returns {boolean}
99299
+ */
99300
+ get keyboardEnabledOnlyIfMouseover() {
99301
+ return this._configs.keyboardEnabledOnlyIfMouseover;
99302
+ }
99253
99303
 
99254
99304
  /**
99255
99305
  * Sets the current navigation mode.
@@ -139012,7 +139062,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
139012
139062
  const pickWorldPos = canvasPos => {
139013
139063
  const origin = math.vec3();
139014
139064
  const direction = math.vec3();
139015
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
139065
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
139016
139066
  return ray2WorldPos(origin, direction);
139017
139067
  };
139018
139068
 
@@ -139087,7 +139137,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
139087
139137
  const pickWorldPos = canvasPos => {
139088
139138
  const origin = math.vec3();
139089
139139
  const direction = math.vec3();
139090
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
139140
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
139091
139141
  return ray2WorldPos(origin, direction);
139092
139142
  };
139093
139143
 
@@ -140307,7 +140357,7 @@ class ZoneTranslateControl extends Component {
140307
140357
  const pickWorldPos = canvasPos => {
140308
140358
  const origin = math.vec3();
140309
140359
  const direction = math.vec3();
140310
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
140360
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
140311
140361
  return ray2WorldPos(origin, direction);
140312
140362
  };
140313
140363