@vertexvis/viewer 0.23.6-canary.8 → 0.23.6-testing.0

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 (38) hide show
  1. package/dist/cjs/index-4ebe6acf.js +138 -1
  2. package/dist/cjs/{regl-component-b9b3e921.js → regl-component-32e37b41.js} +30 -2
  3. package/dist/cjs/{regl-component-b9b3e921.js.map → regl-component-32e37b41.js.map} +1 -1
  4. package/dist/cjs/vertex-viewer-hit-result-indicator.cjs.entry.js +1 -1
  5. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +1 -1
  6. package/dist/cjs/vertex-viewer.cjs.entry.js +89 -15
  7. package/dist/cjs/vertex-viewer.cjs.entry.js.map +1 -1
  8. package/dist/collection/lib/interactions/interactionApi.js +66 -8
  9. package/dist/collection/lib/interactions/interactionApi.js.map +1 -1
  10. package/dist/collection/lib/interactions/interactionApiOrthographic.js +23 -7
  11. package/dist/collection/lib/interactions/interactionApiOrthographic.js.map +1 -1
  12. package/dist/collection/lib/webgl/regl-component.js +29 -1
  13. package/dist/collection/lib/webgl/regl-component.js.map +1 -1
  14. package/dist/components/regl-component.js +29 -1
  15. package/dist/components/regl-component.js.map +1 -1
  16. package/dist/components/vertex-viewer.js +90 -16
  17. package/dist/components/vertex-viewer.js.map +1 -1
  18. package/dist/esm/index-fef00dee.js +138 -1
  19. package/dist/esm/{regl-component-3d0639a6.js → regl-component-76cd98b9.js} +30 -2
  20. package/dist/esm/{regl-component-3d0639a6.js.map → regl-component-76cd98b9.js.map} +1 -1
  21. package/dist/esm/vertex-viewer-hit-result-indicator.entry.js +1 -1
  22. package/dist/esm/vertex-viewer-transform-widget.entry.js +1 -1
  23. package/dist/esm/vertex-viewer.entry.js +90 -16
  24. package/dist/esm/vertex-viewer.entry.js.map +1 -1
  25. package/dist/types/lib/webgl/regl-component.d.ts +4 -0
  26. package/dist/viewer/{p-d7a621a2.entry.js → p-07d2b2fa.entry.js} +2 -2
  27. package/dist/viewer/{p-ed1460ad.js → p-75cad0f2.js} +2 -2
  28. package/dist/viewer/p-75cad0f2.js.map +1 -0
  29. package/dist/viewer/{p-96dd1ad5.entry.js → p-9c4fc8bd.entry.js} +2 -2
  30. package/dist/viewer/p-d2ddc770.entry.js +5 -0
  31. package/dist/viewer/p-d2ddc770.entry.js.map +1 -0
  32. package/dist/viewer/viewer.esm.js +1 -1
  33. package/package.json +7 -7
  34. package/dist/viewer/p-7e808b58.entry.js +0 -5
  35. package/dist/viewer/p-7e808b58.entry.js.map +0 -1
  36. package/dist/viewer/p-ed1460ad.js.map +0 -1
  37. /package/dist/viewer/{p-d7a621a2.entry.js.map → p-07d2b2fa.entry.js.map} +0 -0
  38. /package/dist/viewer/{p-96dd1ad5.entry.js.map → p-9c4fc8bd.entry.js.map} +0 -0
@@ -4,7 +4,7 @@
4
4
  import { r as registerInstance, h, H as Host, g as getElement } from './index-fef00dee.js';
5
5
  import { v as vector3, m as matrix4, q as quaternion, r as ray, c as angle } from './bundle.esm-5c4f484e.js';
6
6
  import { w as writeDOM, r as readDOM } from './stencil-819ab171.js';
7
- import { M as MeshPoints, R as ReglComponent, r as regl, s as shapeBuilder, T as TriangleMesh, c as computeArrowNdcValues, a as Mesh, A as AxisLine, b as axisPositions } from './regl-component-3d0639a6.js';
7
+ import { M as MeshPoints, R as ReglComponent, r as regl, s as shapeBuilder, T as TriangleMesh, c as computeArrowNdcValues, a as Mesh, A as AxisLine, b as axisPositions } from './regl-component-76cd98b9.js';
8
8
  import './_commonjsHelpers-6e425ac3.js';
9
9
  import './browser.esm-39ef5fa0.js';
10
10
  import './util-a19a8523.js';
@@ -9,7 +9,7 @@ import { T as TransformController } from './controller-d0269a5e.js';
9
9
  import { D as DistanceUnits, A as AngleUnits } from './streamAttributes-f200ca9d.js';
10
10
  import './entities-f59f520e.js';
11
11
  import { E as EventDispatcher } from './browser.esm-39ef5fa0.js';
12
- import { d as TriangleMeshPoints, T as TriangleMesh, R as ReglComponent, e as computeDrawable2dBounds, r as regl, s as shapeBuilder, x as xAxisArrowPositions, A as AxisLine, b as axisPositions, y as yAxisArrowPositions, z as zAxisArrowPositions, f as rotationAxisPositions, g as RotationLine } from './regl-component-3d0639a6.js';
12
+ import { d as TriangleMeshPoints, T as TriangleMesh, R as ReglComponent, e as computeDrawable2dBounds, r as regl, s as shapeBuilder, x as xAxisArrowPositions, A as AxisLine, b as axisPositions, y as yAxisArrowPositions, z as zAxisArrowPositions, f as rotationAxisPositions, g as RotationLine } from './regl-component-76cd98b9.js';
13
13
  import './_commonjsHelpers-6e425ac3.js';
14
14
  import './bundle.esm-776b774b.js';
15
15
  import './util-a19a8523.js';
@@ -754,14 +754,72 @@ class InteractionApi {
754
754
  * values zoom out.
755
755
  */
756
756
  async zoomCamera(delta) {
757
- return this.transformCamera(({ camera, viewport }) => {
758
- const vv = camera.viewVector;
759
- const v = vector3.normalize(vv);
760
- const distance = vector3.magnitude(vv);
761
- const epsilon = (3 * distance * delta) / viewport.height;
762
- const position = vector3.add(camera.position, vector3.scale(epsilon, v));
763
- const newCamera = camera.update({ position });
764
- return newCamera;
757
+ return this.transformCamera(({ camera, viewport, frame, boundingBox: boundingBox$1 }) => {
758
+ if (viewport != null && frame != null) {
759
+ const isPerspective = camera === null || camera === void 0 ? void 0 : camera.toFrameCamera().isPerspective();
760
+ if (isPerspective) {
761
+ const vv = camera.viewVector;
762
+ // Calculate the unit-less scalar determining the amount to zoom. The delta parameter
763
+ // is scaled by the viewport height because if the viewport is larger, then the
764
+ // user should have to perform a bigger action to zoom the model the same amount.
765
+ // Note that delta and viewport.height both have units of pixels. Further, the
766
+ // 3 multiplier was chosen to match the desired zoom speed.
767
+ const distance = vector3.magnitude(vv);
768
+ const relativeDeltaToViewportHeight = 3 * distance * (delta / viewport.height);
769
+ // Scale the current viewVector by the scalar calculated above to determine how to adjust the camera position
770
+ const v = vector3.normalize(vv);
771
+ const positionChange = vector3.scale(relativeDeltaToViewportHeight, v);
772
+ // Calculate the new camera position
773
+ const position = vector3.add(camera.position, positionChange);
774
+ // Update the camera with the new position
775
+ const newCamera = camera.update({ position });
776
+ return newCamera;
777
+ }
778
+ else {
779
+ // Retrieve properties of the current camera
780
+ const orthographicCamera = camera;
781
+ const frameCam = camera.toFrameCamera();
782
+ const dir = frameCam.direction;
783
+ const ray$1 = viewport.transformPointToRay(viewport.center, frame.image, frameCam);
784
+ // Calculate the unit-less scalar determining the amount to zoom. The delta parameter
785
+ // is scaled by the viewport height because if the viewport is larger, then the
786
+ // user should have to perform a bigger action to zoom the model the same amount.
787
+ // Note that delta and viewport.height both have units of pixels. Further, the
788
+ // 4 multiplier was chosen to match the desired zoom speed.
789
+ const relativeDeltaToViewportHeight = 4 * (delta / viewport.height);
790
+ // Calculate the fovHeight after performing the zoom. zoomedFovHeight has the
791
+ // same units of camera.fovHeight (the world units). The new fovHeight
792
+ // has a minimum value, which is a function of the size of the bounding box,
793
+ // which ensures the new fovHeight is a positive, non-zero number.
794
+ const minimumFovHeight = vector3.magnitude(boundingBox.diagonal(boundingBox$1)) * 1e-5;
795
+ const zoomedFovHeight = Math.max(minimumFovHeight, orthographicCamera.fovHeight * (1 - relativeDeltaToViewportHeight));
796
+ // Calculate the plane and point to zoom relative to
797
+ const planeToZoomRelativeTo = plane.fromNormalAndCoplanarPoint(dir, frameCam.lookAt);
798
+ const pointToZoomRelativeTo = ray.intersectPlane(ray$1, planeToZoomRelativeTo);
799
+ if (pointToZoomRelativeTo != null) {
800
+ // Project the current look at point onto the zoom plane
801
+ const projectedLookAt = plane.projectPoint(planeToZoomRelativeTo, orthographicCamera.lookAt);
802
+ // Calculate the vector to determine how to adjust the camera's look at point.
803
+ // Ensure that the viewVector is scaled to the expected length in order to
804
+ // ensure other camera calculations are correct, for example, the occlusion
805
+ // calculations for pins.
806
+ const fovHeightRelativeChange = (orthographicCamera.fovHeight - zoomedFovHeight) /
807
+ orthographicCamera.fovHeight;
808
+ const lookAtChangeVector = vector3.scale(fovHeightRelativeChange, vector3.subtract(pointToZoomRelativeTo, projectedLookAt));
809
+ // Calculate the camera's new look at point
810
+ const updatedLookAt = vector3.add(orthographicCamera.lookAt, lookAtChangeVector);
811
+ // Update the orthographic camera
812
+ // Note rotationPoint should match lookAt after a zoom interaction
813
+ const newCamera = camera.update({
814
+ lookAt: updatedLookAt,
815
+ rotationPoint: updatedLookAt,
816
+ fovHeight: zoomedFovHeight,
817
+ });
818
+ return newCamera;
819
+ }
820
+ }
821
+ }
822
+ return camera;
765
823
  });
766
824
  }
767
825
  /**
@@ -951,7 +1009,7 @@ class InteractionApiOrthographic extends InteractionApi {
951
1009
  });
952
1010
  }
953
1011
  async zoomCameraToPoint(point$1, delta) {
954
- return this.transformCamera(({ camera, viewport, frame, depthBuffer, boundingBox }) => {
1012
+ return this.transformCamera(({ camera, viewport, frame, depthBuffer, boundingBox: boundingBox$1 }) => {
955
1013
  if (this.orthographicZoomData == null ||
956
1014
  point.distance(point$1, this.orthographicZoomData.startingScreenPt) > 2) {
957
1015
  const frameCam = camera.toFrameCamera();
@@ -975,17 +1033,33 @@ class InteractionApiOrthographic extends InteractionApi {
975
1033
  }
976
1034
  if (this.orthographicZoomData != null) {
977
1035
  const { hitPt, hitPlane } = this.orthographicZoomData;
978
- // The 4 multiplier was chosen to match the desired zoom speed
979
- const relativeDelta = 4 * (camera.fovHeight / viewport.height) * delta;
980
- const fovHeight = Math.max(1, camera.fovHeight - relativeDelta);
1036
+ // Calculate the unit-less scalar determining the amount to zoom. The delta parameter
1037
+ // is scaled by the viewport height because if the viewport is larger, then the
1038
+ // user should have to perform a bigger action to zoom the model the same amount.
1039
+ // Note that delta and viewport.height both have units of pixels. Further, the
1040
+ // 4 multiplier was chosen to match the desired zoom speed.
1041
+ const relativeDeltaToViewportHeight = 4 * (delta / viewport.height);
1042
+ // Calculate the fovHeight after performing the zoom. zoomedFovHeight has the
1043
+ // same units of camera.fovHeight (the world units). The new fovHeight
1044
+ // has a minimum value, which is a function of the size of the bounding box,
1045
+ // which ensures the new fovHeight is a positive, non-zero number.
1046
+ const minimumFovHeight = vector3.magnitude(boundingBox.diagonal(boundingBox$1)) * 1e-5;
1047
+ const zoomedFovHeight = Math.max(minimumFovHeight, camera.fovHeight * (1 - relativeDeltaToViewportHeight));
1048
+ // Calculate the vector to determine how to adjust the camera's look at point.
1049
+ // Ensure that the viewVector is scaled to the expected length in order to
1050
+ // ensure other camera calculations are correct, for example, the occlusion
1051
+ // calculations for pins.
981
1052
  const projectedLookAt = plane.projectPoint(hitPlane, camera.lookAt);
982
- const diff = vector3.scale((camera.fovHeight - fovHeight) / camera.fovHeight, vector3.subtract(hitPt, projectedLookAt));
983
- // rotationPoint should match lookAt after a zoom interaction
984
- const updatedLookAt = vector3.add(camera.lookAt, diff);
1053
+ const fovHeightRelativeChange = (camera.fovHeight - zoomedFovHeight) / camera.fovHeight;
1054
+ const lookAtChangeVector = vector3.scale(fovHeightRelativeChange, vector3.subtract(hitPt, projectedLookAt));
1055
+ // Calculate the camera's new look at point
1056
+ const updatedLookAt = vector3.add(camera.lookAt, lookAtChangeVector);
1057
+ // Return the updated camera
1058
+ // Note rotationPoint should match lookAt after a zoom interaction
985
1059
  return camera.update({
986
1060
  lookAt: updatedLookAt,
987
1061
  rotationPoint: updatedLookAt,
988
- fovHeight: Math.max(1, camera.fovHeight - relativeDelta),
1062
+ fovHeight: zoomedFovHeight,
989
1063
  });
990
1064
  }
991
1065
  return camera;