@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.25",
3
+ "version": "2.6.27",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -75,6 +75,7 @@ class Annotation extends Marker {
75
75
  this._values = cfg.values || {};
76
76
  this._layoutDirty = true;
77
77
  this._visibilityDirty = true;
78
+ this._labelPosition = 24;
78
79
 
79
80
  this._buildHTML();
80
81
 
@@ -205,17 +206,23 @@ class Annotation extends Marker {
205
206
  * @private
206
207
  */
207
208
  _updatePosition() {
209
+ const px = x => x + "px";
208
210
  const boundary = this.scene.canvas.boundary;
209
- const left = boundary[0];
210
- const top = boundary[1];
211
- const canvasPos = this.canvasPos;
212
- this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
213
- this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
211
+ const left = boundary[0] + this.canvasPos[0];
212
+ const top = boundary[1] + this.canvasPos[1];
213
+ const markerRect = this._marker.getBoundingClientRect();
214
+ const markerWidth = markerRect.width;
215
+ const markerDir = (this._markerAlign === "right") ? -1 : ((this._markerAlign === "center") ? 0 : 1);
216
+ const markerCenter = left + markerDir * (markerWidth / 2 - 12);
217
+ this._marker.style.left = px(markerCenter - markerWidth / 2);
218
+ this._marker.style.top = px(top - 12);
214
219
  this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
215
- const offsetX = 20;
216
- const offsetY = -17;
217
- this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
218
- this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
220
+
221
+ const labelRect = this._label.getBoundingClientRect();
222
+ const labelWidth = labelRect.width;
223
+ const labelDir = Math.sign(this._labelPosition);
224
+ this._label.style.left = px(markerCenter + labelDir * (markerWidth / 2 + Math.abs(this._labelPosition) + labelWidth / 2) - labelWidth / 2);
225
+ this._label.style.top = px(top - 17);
219
226
  this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
220
227
  }
221
228
 
@@ -250,6 +257,37 @@ class Annotation extends Marker {
250
257
  }
251
258
  }
252
259
 
260
+ /**
261
+ * Sets the horizontal alignment of the Annotation's marker HTML.
262
+ *
263
+ * @param {String} align Either "left", "center", "right" (default "left")
264
+ */
265
+ setMarkerAlign(align) {
266
+ const valid = [ "left", "center", "right" ];
267
+ if (! valid.includes(align)) {
268
+ this.error("Param 'align' should be one of: " + JSON.stringify(valid));
269
+ } else {
270
+ this._markerAlign = align;
271
+ this._updatePosition();
272
+ }
273
+ }
274
+
275
+ /**
276
+ * Sets the relative horizontal position of the Annotation's label HTML.
277
+ *
278
+ * @param {Number} position Negative - to the left, positive - to the right, otherwise ignore (default 24)
279
+ */
280
+ setLabelPosition(position) {
281
+ if (typeof position !== "number") {
282
+ this.error("Param 'position' is not a number");
283
+ } else if (position === 0) {
284
+ this.error("Param 'position' is zero");
285
+ } else {
286
+ this._labelPosition = position;
287
+ this._updatePosition();
288
+ }
289
+ }
290
+
253
291
  /**
254
292
  * Sets whether or not to show this Annotation's marker.
255
293
  *
@@ -539,7 +539,7 @@ class DistanceMeasurement extends Component {
539
539
  }
540
540
 
541
541
  if (!this._zAxisLabelCulled) {
542
- if(this._measurementOrientation === 'Vertical') {
542
+ if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
543
543
  this._zAxisLabel.setPrefix("");
544
544
  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);
545
545
  }
@@ -353,27 +353,27 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
353
353
  if (!this._active) {
354
354
  return;
355
355
  }
356
-
356
+
357
357
  this.fire("activated", false);
358
358
 
359
359
  if (this.pointerLens) {
360
360
  this.pointerLens.visible = false;
361
361
  }
362
- if (this._markerDiv) {
363
- this._destroyMarkerDiv()
364
- }
365
- this.reset();
362
+ // if (this._markerDiv) {
363
+ // this._destroyMarkerDiv()
364
+ // }
365
+ // this.reset();
366
366
  const canvas = this.scene.canvas.canvas;
367
367
  canvas.removeEventListener("mousedown", this._onMouseDown);
368
368
  canvas.removeEventListener("mouseup", this._onMouseUp);
369
369
  const cameraControl = this.distanceMeasurementsPlugin.viewer.cameraControl;
370
370
  cameraControl.off(this._onCameraControlHoverSnapOrSurface);
371
371
  cameraControl.off(this._onCameraControlHoverSnapOrSurfaceOff);
372
- if (this._currentDistanceMeasurement) {
373
- this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
374
- this._currentDistanceMeasurement.destroy();
375
- this._currentDistanceMeasurement = null;
376
- }
372
+ // if (this._currentDistanceMeasurement) {
373
+ // this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
374
+ // this._currentDistanceMeasurement.destroy();
375
+ // this._currentDistanceMeasurement = null;
376
+ // }
377
377
  this._active = false;
378
378
  }
379
379
 
@@ -489,7 +489,7 @@ class DistanceMeasurementsPlugin extends Plugin {
489
489
  axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
490
490
  xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
491
491
  yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
492
- zAxisVisibld: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
492
+ zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
493
493
  xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
494
494
  yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
495
495
  zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
@@ -393,7 +393,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
393
393
  const pickWorldPos = canvasPos => {
394
394
  const origin = math.vec3();
395
395
  const direction = math.vec3();
396
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
396
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
397
397
  return ray2WorldPos(origin, direction);
398
398
  };
399
399
 
@@ -468,7 +468,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
468
468
  const pickWorldPos = canvasPos => {
469
469
  const origin = math.vec3();
470
470
  const direction = math.vec3();
471
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
471
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
472
472
  return ray2WorldPos(origin, direction);
473
473
  };
474
474
 
@@ -1711,7 +1711,7 @@ export class ZoneTranslateControl extends Component {
1711
1711
  const pickWorldPos = canvasPos => {
1712
1712
  const origin = math.vec3();
1713
1713
  const direction = math.vec3();
1714
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
1714
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
1715
1715
  return ray2WorldPos(origin, direction);
1716
1716
  };
1717
1717
 
@@ -111,7 +111,7 @@ export function activateDraggableDot(dot, cfg) {
111
111
  const pickWorldPos = canvasPos => {
112
112
  const origin = math.vec3();
113
113
  const direction = math.vec3();
114
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
114
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
115
115
  return ray2WorldPos(origin, direction, canvasPos);
116
116
  };
117
117
 
@@ -649,6 +649,8 @@ class CameraControl extends Component {
649
649
  snapToEdge: DEFAULT_SNAP_EDGE,
650
650
  snapRadius: DEFAULT_SNAP_PICK_RADIUS,
651
651
 
652
+ keyboardEnabledOnlyIfMouseover: true,
653
+
652
654
  // Rotation
653
655
 
654
656
  dragRotationRate: 360.0,
@@ -959,6 +961,24 @@ class CameraControl extends Component {
959
961
  get snapRadius() {
960
962
  return this._configs.snapRadius;
961
963
  }
964
+
965
+ /**
966
+ * If `true`, the keyboard shortcuts are enabled ONLY if the mouse is over the canvas.
967
+ *
968
+ * @param {boolean} value
969
+ */
970
+ set keyboardEnabledOnlyIfMouseover(value) {
971
+ this._configs.keyboardEnabledOnlyIfMouseover = !!value;
972
+ }
973
+
974
+ /**
975
+ * Gets whether the keyboard shortcuts are enabled ONLY if the mouse is over the canvas or ALWAYS.
976
+ *
977
+ * @returns {boolean}
978
+ */
979
+ get keyboardEnabledOnlyIfMouseover() {
980
+ return this._configs.keyboardEnabledOnlyIfMouseover;
981
+ }
962
982
 
963
983
  /**
964
984
  * Sets the current navigation mode.
@@ -29,7 +29,7 @@ class KeyboardAxisViewHandler {
29
29
  return;
30
30
  }
31
31
 
32
- if (!states.mouseover) {
32
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
33
33
  return;
34
34
  }
35
35
 
@@ -22,7 +22,7 @@ class KeyboardPanRotateDollyHandler {
22
22
  if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
23
23
  return;
24
24
  }
25
- if (!states.mouseover) {
25
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
26
26
  return;
27
27
  }
28
28
  keyDownMap[keyCode] = true;
@@ -53,7 +53,7 @@ class KeyboardPanRotateDollyHandler {
53
53
  return;
54
54
  }
55
55
 
56
- if (!states.mouseover) {
56
+ if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
57
57
  return;
58
58
  }
59
59
 
@@ -59,8 +59,7 @@ class MousePickHandler {
59
59
  {
60
60
  const origin = math.vec3();
61
61
  const direction = math.vec3();
62
- // The origin from math.canvasPosToWorldRay is incorrect for a perspective camera, should be the same as scene.camera.eye
63
- math.canvasPosToWorldRay(scene.canvas.canvas, scene.camera.viewMatrix, scene.camera.projMatrix, states.pointerCanvasPos, origin, direction);
62
+ math.canvasPosToWorldRay(scene.canvas.canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, states.pointerCanvasPos, origin, direction);
64
63
  cameraControl.fire("rayMove", { canvasPos: states.pointerCanvasPos, ray: { origin: origin, direction: direction, canvasPos: states.pointerCanvasPos } }, true);
65
64
  }
66
65
 
@@ -4909,54 +4909,49 @@ const math = {
4909
4909
  @static
4910
4910
  @param {Number[]} viewMatrix View matrix
4911
4911
  @param {Number[]} projMatrix Projection matrix
4912
+ @param {String} projection Projection type (e.g. "ortho")
4912
4913
  @param {Number[]} canvasPos The Canvas-space position.
4913
4914
  @param {Number[]} worldRayOrigin The World-space ray origin.
4914
4915
  @param {Number[]} worldRayDir The World-space ray direction.
4915
4916
  */
4916
4917
  canvasPosToWorldRay: ((() => {
4917
4918
 
4918
- const tempMat4b = new FloatArrayType(16);
4919
- const tempMat4c = new FloatArrayType(16);
4920
- const tempVec4a = new FloatArrayType(4);
4921
- const tempVec4b = new FloatArrayType(4);
4922
- const tempVec4c = new FloatArrayType(4);
4923
- const tempVec4d = new FloatArrayType(4);
4924
-
4925
- return (canvas, viewMatrix, projMatrix, canvasPos, worldRayOrigin, worldRayDir) => {
4919
+ const pvMatInv = new FloatArrayType(16);
4920
+ const vec4Near = new FloatArrayType(4);
4921
+ const vec4Far = new FloatArrayType(4);
4926
4922
 
4927
- const pvMat = math.mulMat4(projMatrix, viewMatrix, tempMat4b);
4928
- const pvMatInverse = math.inverseMat4(pvMat, tempMat4c);
4923
+ const clipToWorld = (clipX, clipY, clipZ, isOrtho, outVec4) => {
4924
+ outVec4[0] = clipX;
4925
+ outVec4[1] = clipY;
4926
+ outVec4[2] = clipZ;
4927
+ outVec4[3] = 1;
4929
4928
 
4930
- // Calculate clip space coordinates, which will be in range
4931
- // of x=[-1..1] and y=[-1..1], with y=(+1) at top
4929
+ math.transformVec4(pvMatInv, outVec4, outVec4);
4930
+ if (! isOrtho)
4931
+ math.mulVec4Scalar(outVec4, 1 / outVec4[3]);
4932
+ };
4932
4933
 
4933
- const canvasWidth = canvas.width;
4934
- const canvasHeight = canvas.height;
4934
+ return (canvas, viewMatrix, projMatrix, projection, canvasPos, worldRayOrigin, worldRayDir) => {
4935
+ const isOrtho = projection === "ortho";
4935
4936
 
4936
- const clipX = (canvasPos[0] - canvasWidth / 2) / (canvasWidth / 2); // Calculate clip space coordinates
4937
- const clipY = -(canvasPos[1] - canvasHeight / 2) / (canvasHeight / 2);
4937
+ math.mulMat4(projMatrix, viewMatrix, pvMatInv);
4938
+ math.inverseMat4(pvMatInv, pvMatInv);
4938
4939
 
4939
- tempVec4a[0] = clipX;
4940
- tempVec4a[1] = clipY;
4941
- tempVec4a[2] = -1;
4942
- tempVec4a[3] = 1;
4940
+ // Calculate clip space coordinates, which will be in range
4941
+ // of x=[-1..1] and y=[-1..1], with y=(+1) at top
4943
4942
 
4944
- math.transformVec4(pvMatInverse, tempVec4a, tempVec4b);
4945
- math.mulVec4Scalar(tempVec4b, 1 / tempVec4b[3]);
4943
+ const clipX = 2 * canvasPos[0] / canvas.width - 1; // Calculate clip space coordinates
4944
+ const clipY = 1 - 2 * canvasPos[1] / canvas.height;
4946
4945
 
4947
- tempVec4c[0] = clipX;
4948
- tempVec4c[1] = clipY;
4949
- tempVec4c[2] = 1;
4950
- tempVec4c[3] = 1;
4946
+ clipToWorld(clipX, clipY, -1, isOrtho, vec4Near);
4951
4947
 
4952
- math.transformVec4(pvMatInverse, tempVec4c, tempVec4d);
4953
- math.mulVec4Scalar(tempVec4d, 1 / tempVec4d[3]);
4948
+ clipToWorld(clipX, clipY, 1, isOrtho, vec4Far);
4954
4949
 
4955
- worldRayOrigin[0] = tempVec4d[0];
4956
- worldRayOrigin[1] = tempVec4d[1];
4957
- worldRayOrigin[2] = tempVec4d[2];
4950
+ worldRayOrigin[0] = vec4Near[0];
4951
+ worldRayOrigin[1] = vec4Near[1];
4952
+ worldRayOrigin[2] = vec4Near[2];
4958
4953
 
4959
- math.subVec3(tempVec4d, tempVec4b, worldRayDir);
4954
+ math.subVec3(vec4Far, vec4Near, worldRayDir);
4960
4955
 
4961
4956
  math.normalizeVec3(worldRayDir);
4962
4957
  };
@@ -4980,8 +4975,8 @@ const math = {
4980
4975
  const worldRayOrigin = new FloatArrayType(3);
4981
4976
  const worldRayDir = new FloatArrayType(3);
4982
4977
 
4983
- return (canvas, viewMatrix, projMatrix, worldMatrix, canvasPos, localRayOrigin, localRayDir) => {
4984
- math.canvasPosToWorldRay(canvas, viewMatrix, projMatrix, canvasPos, worldRayOrigin, worldRayDir);
4978
+ return (canvas, viewMatrix, projMatrix, projection, worldMatrix, canvasPos, localRayOrigin, localRayDir) => {
4979
+ math.canvasPosToWorldRay(canvas, viewMatrix, projMatrix, projection, canvasPos, worldRayOrigin, worldRayDir);
4985
4980
  math.worldRayToLocalRay(worldMatrix, worldRayOrigin, worldRayDir, localRayOrigin, localRayDir);
4986
4981
  };
4987
4982
  }))(),
@@ -1898,8 +1898,8 @@ class Mesh extends Component {
1898
1898
  }
1899
1899
 
1900
1900
  /** @private */
1901
- pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult) {
1902
- pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, pickResult);
1901
+ pickTriangleSurface(pickViewMatrix, pickProjMatrix, projection, pickResult) {
1902
+ pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, projection, pickResult);
1903
1903
  }
1904
1904
 
1905
1905
  /** @private */
@@ -1991,7 +1991,7 @@ const pickTriangleSurface = (function () {
1991
1991
  const tempVec3j = math.vec3();
1992
1992
  const tempVec3k = math.vec3();
1993
1993
 
1994
- return function (mesh, pickViewMatrix, pickProjMatrix, pickResult) {
1994
+ return function (mesh, pickViewMatrix, pickProjMatrix, projection, pickResult) {
1995
1995
 
1996
1996
  var primIndex = pickResult.primIndex;
1997
1997
 
@@ -2070,7 +2070,7 @@ const pickTriangleSurface = (function () {
2070
2070
  // Attempt to ray-pick the triangle in local space
2071
2071
 
2072
2072
  if (pickResult.canvasPos) {
2073
- math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
2073
+ math.canvasPosToLocalRay(canvas.canvas, mesh.origin ? createRTCViewMat(pickViewMatrix, mesh.origin) : pickViewMatrix, pickProjMatrix, projection, mesh.worldMatrix, pickResult.canvasPos, localRayOrigin, localRayDir);
2074
2074
 
2075
2075
  } else if (pickResult.origin && pickResult.direction) {
2076
2076
  math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
@@ -2099,10 +2099,10 @@ class Scene extends Component {
2099
2099
  */
2100
2100
  get center() {
2101
2101
  if (this._aabbDirty || !this._center) {
2102
- if (!this._center || !this._center) {
2102
+ const aabb = this.aabb;
2103
+ if (!this._center) {
2103
2104
  this._center = math.vec3();
2104
2105
  }
2105
- const aabb = this.aabb;
2106
2106
  this._center[0] = (aabb[0] + aabb[3]) / 2;
2107
2107
  this._center[1] = (aabb[1] + aabb[4]) / 2;
2108
2108
  this._center[2] = (aabb[2] + aabb[5]) / 2;
@@ -2177,6 +2177,7 @@ class Scene extends Component {
2177
2177
  this._aabb[4] = ymax;
2178
2178
  this._aabb[5] = zmax;
2179
2179
  this._aabbDirty = false;
2180
+ this._center = null;
2180
2181
  }
2181
2182
  return this._aabb;
2182
2183
  }
@@ -2302,11 +2303,6 @@ class Scene extends Component {
2302
2303
  return null;
2303
2304
  }
2304
2305
 
2305
- if ((params.snapToVertex || params.snapToEdge) && !params.canvasPos) {
2306
- this.error("Scene.snapPick() `canvasPos` parameter expected for `snapToVertex:true` or `snapToEdge:true`");
2307
- return;
2308
- }
2309
-
2310
2306
  params = params || {};
2311
2307
 
2312
2308
  params.pickSurface = params.pickSurface || params.rayPick; // Backwards compatibility
@@ -2332,13 +2328,7 @@ class Scene extends Component {
2332
2328
  }
2333
2329
 
2334
2330
  if (params.snapToEdge || params.snapToVertex) {
2335
- pickResult = this._renderer.snapPick(
2336
- params.canvasPos,
2337
- params.snapRadius || 30,
2338
- params.snapToVertex,
2339
- params.snapToEdge,
2340
- pickResult
2341
- );
2331
+ pickResult = this._renderer.snapPick(params, pickResult);
2342
2332
  } else {
2343
2333
  pickResult = this._renderer.pick(params, pickResult);
2344
2334
  }
@@ -2369,12 +2359,7 @@ class Scene extends Component {
2369
2359
  this.error("Scene.snapPick() canvasPos parameter expected");
2370
2360
  return;
2371
2361
  }
2372
- return this._renderer.snapPick(
2373
- params.canvasPos,
2374
- params.snapRadius || 30,
2375
- params.snapToVertex,
2376
- params.snapToEdge,
2377
- );
2362
+ return this._renderer.snapPick(params);
2378
2363
  }
2379
2364
 
2380
2365
  /**
@@ -2832,4 +2817,4 @@ class Scene extends Component {
2832
2817
  }
2833
2818
  }
2834
2819
 
2835
- export {Scene};
2820
+ export {Scene};
@@ -932,6 +932,7 @@ const Renderer = function (scene, options) {
932
932
  let look;
933
933
  let pickViewMatrix = null;
934
934
  let pickProjMatrix = null;
935
+ let projection = null;
935
936
 
936
937
  pickResult.pickSurface = params.pickSurface;
937
938
 
@@ -942,6 +943,7 @@ const Renderer = function (scene, options) {
942
943
 
943
944
  pickViewMatrix = scene.camera.viewMatrix;
944
945
  pickProjMatrix = scene.camera.projMatrix;
946
+ projection = scene.camera.projection;
945
947
 
946
948
  pickResult.canvasPos = params.canvasPos;
947
949
 
@@ -954,6 +956,7 @@ const Renderer = function (scene, options) {
954
956
 
955
957
  pickViewMatrix = params.matrix;
956
958
  pickProjMatrix = scene.camera.projMatrix;
959
+ projection = scene.camera.projection;
957
960
 
958
961
  } else {
959
962
 
@@ -972,6 +975,7 @@ const Renderer = function (scene, options) {
972
975
  pickViewMatrix = math.lookAtMat4v(worldRayOrigin, look, up, tempMat4b);
973
976
  // pickProjMatrix = scene.camera.projMatrix;
974
977
  pickProjMatrix = scene.camera.ortho.matrix;
978
+ projection = "ortho";
975
979
 
976
980
  pickResult.origin = worldRayOrigin;
977
981
  pickResult.direction = worldRayDir;
@@ -1019,7 +1023,7 @@ const Renderer = function (scene, options) {
1019
1023
 
1020
1024
  gpuPickTriangle(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, pickResult);
1021
1025
 
1022
- pickable.pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult);
1026
+ pickable.pickTriangleSurface(pickViewMatrix, pickProjMatrix, projection, pickResult);
1023
1027
 
1024
1028
  pickResult.pickSurfacePrecision = false;
1025
1029
 
@@ -1292,7 +1296,9 @@ const Renderer = function (scene, options) {
1292
1296
 
1293
1297
  const _pickResult = new PickResult();
1294
1298
 
1295
- return function (canvasPos, snapRadiusInPixels, snapToVertex, snapToEdge, pickResult = _pickResult) {
1299
+ return function (params, pickResult = _pickResult) {
1300
+
1301
+ const {canvasPos, origin, direction, snapRadius, snapToVertex, snapToEdge} = params;
1296
1302
 
1297
1303
  if (!snapToVertex && !snapToEdge) {
1298
1304
  return this.pick({canvasPos, pickSurface: true});
@@ -1306,7 +1312,7 @@ const Renderer = function (scene, options) {
1306
1312
  frameCtx.pickZNear = scene.camera.project.near;
1307
1313
  frameCtx.pickZFar = scene.camera.project.far;
1308
1314
 
1309
- snapRadiusInPixels = snapRadiusInPixels || 30;
1315
+ const snapRadiusInPixels = snapRadius || 30;
1310
1316
 
1311
1317
  const vertexPickBuffer = renderBufferManager.getRenderBuffer("uniquePickColors-aabs", {
1312
1318
  depthTexture: true,
@@ -1317,8 +1323,8 @@ const Renderer = function (scene, options) {
1317
1323
  });
1318
1324
 
1319
1325
  frameCtx.snapVectorA = [
1320
- getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
1321
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
1326
+ canvasPos ? getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth) : 0,
1327
+ canvasPos ? getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight) : 0,
1322
1328
  ];
1323
1329
 
1324
1330
  frameCtx.snapInvVectorAB = [
@@ -1345,7 +1351,14 @@ const Renderer = function (scene, options) {
1345
1351
  // Set view and proj mats for VBO renderers
1346
1352
  ///////////////////////////////////////
1347
1353
 
1348
- const pickViewMatrix = scene.camera.viewMatrix;
1354
+ frameCtx.pickViewMatrix = (canvasPos
1355
+ ? scene.camera.viewMatrix
1356
+ : math.lookAtMat4v(
1357
+ origin,
1358
+ math.addVec3(origin, direction, math.vec3()),
1359
+ math.vec3([0, 1, 0]),
1360
+ math.mat4()));
1361
+
1349
1362
  const pickProjMatrix = scene.camera.projMatrix;
1350
1363
 
1351
1364
  for (let type in drawableTypeInfo) {
@@ -1354,7 +1367,7 @@ const Renderer = function (scene, options) {
1354
1367
  for (let i = 0, len = drawableList.length; i < len; i++) {
1355
1368
  const drawable = drawableList[i];
1356
1369
  if (drawable.setPickMatrices) { // Eg. SceneModel, which needs pre-loading into texture
1357
- drawable.setPickMatrices(pickViewMatrix, pickProjMatrix);
1370
+ drawable.setPickMatrices(frameCtx.pickViewMatrix, pickProjMatrix);
1358
1371
  }
1359
1372
  }
1360
1373
  }
@@ -1533,7 +1546,7 @@ const Renderer = function (scene, options) {
1533
1546
  pickResult.worldPos = snappedWorldPos;
1534
1547
  pickResult.worldNormal = snappedWorldNormal;
1535
1548
  pickResult.entity = snappedEntity;
1536
- pickResult.canvasPos = canvasPos;
1549
+ pickResult.canvasPos = canvasPos || scene.camera.projectWorldPos(worldPos || snappedWorldPos);
1537
1550
  pickResult.snappedCanvasPos = snappedCanvasPos || canvasPos;
1538
1551
 
1539
1552
  return pickResult;
@@ -40,6 +40,20 @@ export declare class AngleMeasurement extends Component {
40
40
  * @type {Boolean}
41
41
  */
42
42
  get visible(): boolean;
43
+
44
+ /**
45
+ * Sets whether this AngleMeasurement is highlighted or not.
46
+ *
47
+ * @type {Boolean}
48
+ */
49
+ set highlighted(arg: boolean);
50
+ /**
51
+ * Gets whether this AngleMeasurement is highlighted or not.
52
+ *
53
+ * @type {Boolean}
54
+ */
55
+ get highlighted(): boolean;
56
+
43
57
  /**
44
58
  * Sets if the origin {@link Marker} is visible.
45
59
  *