@vertexvis/viewer 0.13.1 → 0.13.2-canary.2

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 (167) hide show
  1. package/dist/cjs/{browser.esm-31b03292.js → browser.esm-c51162f8.js} +1 -1
  2. package/dist/cjs/{bundle.esm-dc0a8361.js → bundle.esm-1b8b1f36.js} +34 -0
  3. package/dist/cjs/{config-90ee43d5.js → config-91efd353.js} +2 -2
  4. package/dist/cjs/{cursors-ad2fd395.js → cursors-14827f58.js} +1 -1
  5. package/dist/cjs/{dom-dd265f48.js → dom-c697cf99.js} +1 -1
  6. package/dist/cjs/{entities-aa59890e.js → entities-0829b4a4.js} +3 -3
  7. package/dist/cjs/index.cjs.js +13 -12
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/{mapper-f6e6cafe.js → mapper-67af470b.js} +2 -2
  10. package/dist/cjs/{markup-fb1553b1.js → markup-835f2e83.js} +2 -2
  11. package/dist/cjs/{measurement-aba1e0e8.js → measurement-8e0ce89a.js} +2 -2
  12. package/dist/cjs/{model-4ec0c36e.js → model-78241d4f.js} +1 -1
  13. package/dist/cjs/{overlays-40c6cbc7.js → overlays-06786e52.js} +2 -2
  14. package/dist/cjs/{png-decoder-27d25eed.js → png-decoder-01b76242.js} +1 -1
  15. package/dist/cjs/{results-bc325974.js → results-7a694238.js} +1 -1
  16. package/dist/cjs/{scene-d420fd26.js → scene-23535fc0.js} +176 -85
  17. package/dist/cjs/{streamAttributes-d6236448.js → streamAttributes-f13c1a96.js} +1431 -41
  18. package/dist/cjs/{utils-f80be307.js → utils-4a02e54b.js} +1 -1
  19. package/dist/cjs/{utils-545b1865.js → utils-5cc32a26.js} +1 -1
  20. package/dist/cjs/vertex-scene-tree-search_3.cjs.entry.js +1 -1
  21. package/dist/cjs/vertex-scene-tree.cjs.entry.js +4 -4
  22. package/dist/cjs/vertex-viewer-dom-element_3.cjs.entry.js +4 -4
  23. package/dist/cjs/vertex-viewer-markup-arrow_3.cjs.entry.js +3 -3
  24. package/dist/cjs/vertex-viewer-markup-tool.cjs.entry.js +4 -4
  25. package/dist/cjs/vertex-viewer-markup.cjs.entry.js +4 -4
  26. package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +3 -3
  27. package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +11 -11
  28. package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +6 -6
  29. package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +10 -10
  30. package/dist/cjs/vertex-viewer-measurement-tool.cjs.entry.js +5 -5
  31. package/dist/cjs/vertex-viewer-measurements.cjs.entry.js +8 -8
  32. package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +3 -3
  33. package/dist/cjs/vertex-viewer.cjs.entry.js +198 -79
  34. package/dist/cjs/viewer.cjs.js +1 -1
  35. package/dist/cjs/{viewport-8c39089f.js → viewport-052809c7.js} +1 -1
  36. package/dist/collection/components/viewer/viewer.js +68 -4
  37. package/dist/collection/components/viewer-dom-renderer/renderer2d.js +1 -1
  38. package/dist/collection/components/viewer-dom-renderer/renderer3d.js +1 -1
  39. package/dist/collection/components/viewer-dom-renderer/viewer-dom-renderer.js +3 -3
  40. package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance.js +3 -3
  41. package/dist/collection/components/viewer-measurement-overlays/viewer-measurement-overlays.js +3 -3
  42. package/dist/collection/index.js +2 -2
  43. package/dist/collection/lib/errors.js +8 -1
  44. package/dist/collection/lib/interactions/index.js +3 -1
  45. package/dist/collection/lib/interactions/interactionApi.js +4 -25
  46. package/dist/collection/lib/interactions/interactionApiOrthographic.js +50 -0
  47. package/dist/collection/lib/interactions/interactionApiPerspective.js +50 -0
  48. package/dist/collection/lib/mappers/frameStreaming.js +27 -5
  49. package/dist/collection/lib/rendering/matrices.js +13 -4
  50. package/dist/collection/lib/scenes/__mocks__/mocks.js +2 -2
  51. package/dist/collection/lib/scenes/camera.js +149 -77
  52. package/dist/collection/lib/scenes/mapper.js +3 -2
  53. package/dist/collection/lib/scenes/scene.js +23 -9
  54. package/dist/collection/lib/types/clippingPlanes.js +54 -17
  55. package/dist/collection/lib/types/depthBuffer.js +1 -1
  56. package/dist/collection/lib/types/frame.js +88 -23
  57. package/dist/collection/lib/types/frameCamera.js +81 -6
  58. package/dist/collection/lib/types/viewport.js +1 -1
  59. package/dist/collection/testing/fixtures.js +23 -10
  60. package/dist/collection/testing/viewer.js +5 -3
  61. package/dist/custom-elements/index.js +1821 -194
  62. package/dist/esm/{browser.esm-59e914f6.js → browser.esm-48f051a3.js} +1 -1
  63. package/dist/esm/{bundle.esm-d899b2d5.js → bundle.esm-df3a8a42.js} +35 -1
  64. package/dist/esm/{config-604c644e.js → config-3a5d3ea3.js} +2 -2
  65. package/dist/esm/{cursors-a7ec4adb.js → cursors-45f23dfe.js} +1 -1
  66. package/dist/esm/{dom-780d25be.js → dom-18d9ac79.js} +1 -1
  67. package/dist/esm/{entities-759d97cd.js → entities-60dfd79d.js} +3 -3
  68. package/dist/esm/index.js +12 -12
  69. package/dist/esm/index.mjs +12 -12
  70. package/dist/esm/loader.js +1 -1
  71. package/dist/esm/loader.mjs +1 -1
  72. package/dist/esm/{mapper-4b815e31.js → mapper-adf23dc4.js} +2 -2
  73. package/dist/esm/{markup-1d177b4a.js → markup-accb6b5c.js} +2 -2
  74. package/dist/esm/{measurement-12cdbf5c.js → measurement-6cd457a6.js} +2 -2
  75. package/dist/esm/{model-e5a4f00f.js → model-4982c15d.js} +1 -1
  76. package/dist/esm/{overlays-1919b192.js → overlays-1783a61a.js} +2 -2
  77. package/dist/esm/{png-decoder-3f1fa486.js → png-decoder-f35def4c.js} +1 -1
  78. package/dist/esm/{results-994bdb50.js → results-93d45acc.js} +1 -1
  79. package/dist/esm/{scene-2c2460d5.js → scene-2d8bdccc.js} +176 -85
  80. package/dist/esm/{streamAttributes-d623bb60.js → streamAttributes-87a3605c.js} +1426 -43
  81. package/dist/esm/{utils-5e57bf24.js → utils-9f4b25ec.js} +1 -1
  82. package/dist/esm/{utils-83a19677.js → utils-ed2346c0.js} +1 -1
  83. package/dist/esm/vertex-scene-tree-search_3.entry.js +1 -1
  84. package/dist/esm/vertex-scene-tree.entry.js +4 -4
  85. package/dist/esm/vertex-viewer-dom-element_3.entry.js +4 -4
  86. package/dist/esm/vertex-viewer-markup-arrow_3.entry.js +3 -3
  87. package/dist/esm/vertex-viewer-markup-tool.entry.js +4 -4
  88. package/dist/esm/vertex-viewer-markup.entry.js +4 -4
  89. package/dist/esm/vertex-viewer-measurement-details.entry.js +3 -3
  90. package/dist/esm/vertex-viewer-measurement-distance.entry.js +11 -11
  91. package/dist/esm/vertex-viewer-measurement-line_2.entry.js +6 -6
  92. package/dist/esm/vertex-viewer-measurement-precise.entry.js +10 -10
  93. package/dist/esm/vertex-viewer-measurement-tool.entry.js +5 -5
  94. package/dist/esm/vertex-viewer-measurements.entry.js +8 -8
  95. package/dist/esm/vertex-viewer-view-cube.entry.js +3 -3
  96. package/dist/esm/vertex-viewer.entry.js +198 -79
  97. package/dist/esm/viewer.js +1 -1
  98. package/dist/esm/{viewport-01c886ea.js → viewport-6d4c0af0.js} +1 -1
  99. package/dist/types/components/viewer/viewer.d.ts +8 -0
  100. package/dist/types/components/viewer-dom-renderer/renderer2d.d.ts +2 -2
  101. package/dist/types/components/viewer-dom-renderer/renderer3d.d.ts +3 -3
  102. package/dist/types/components/viewer-dom-renderer/viewer-dom-renderer.d.ts +2 -2
  103. package/dist/types/components/viewer-measurement-distance/utils.d.ts +2 -2
  104. package/dist/types/components/viewer-measurement-distance/viewer-measurement-distance.d.ts +2 -2
  105. package/dist/types/components/viewer-measurement-overlays/viewer-measurement-overlays-components.d.ts +2 -2
  106. package/dist/types/components/viewer-measurement-overlays/viewer-measurement-overlays.d.ts +2 -2
  107. package/dist/types/components.d.ts +15 -7
  108. package/dist/types/index.d.ts +1 -1
  109. package/dist/types/lib/errors.d.ts +3 -0
  110. package/dist/types/lib/interactions/index.d.ts +2 -0
  111. package/dist/types/lib/interactions/interactionApi.d.ts +20 -21
  112. package/dist/types/lib/interactions/interactionApiOrthographic.d.ts +21 -0
  113. package/dist/types/lib/interactions/interactionApiPerspective.d.ts +21 -0
  114. package/dist/types/lib/mappers/frameStreaming.d.ts +2 -0
  115. package/dist/types/lib/scenes/__mocks__/mocks.d.ts +2 -2
  116. package/dist/types/lib/scenes/camera.d.ts +100 -37
  117. package/dist/types/lib/scenes/scene.d.ts +1 -1
  118. package/dist/types/lib/types/clippingPlanes.d.ts +3 -1
  119. package/dist/types/lib/types/depthBuffer.d.ts +4 -4
  120. package/dist/types/lib/types/frame.d.ts +54 -11
  121. package/dist/types/lib/types/frameCamera.d.ts +21 -2
  122. package/dist/types/lib/types/viewport.d.ts +2 -3
  123. package/dist/types/testing/fixtures.d.ts +4 -2
  124. package/dist/viewer/index.esm.js +1 -1
  125. package/dist/viewer/{p-3f6ac74f.js → p-014561cd.js} +1 -1
  126. package/dist/viewer/p-121f2b40.js +18 -0
  127. package/dist/viewer/p-18ec4fed.js +4 -0
  128. package/dist/viewer/{p-e2297df2.entry.js → p-1acd0e56.entry.js} +1 -1
  129. package/dist/viewer/{p-da2f4a56.js → p-25dfee48.js} +1 -1
  130. package/dist/viewer/p-2e75198d.js +4 -0
  131. package/dist/viewer/p-38c06c25.js +4 -0
  132. package/dist/viewer/{p-67446e35.js → p-463151e0.js} +1 -1
  133. package/dist/viewer/{p-301660cf.js → p-546ae240.js} +1 -1
  134. package/dist/viewer/{p-d00e9203.js → p-6120a219.js} +1 -1
  135. package/dist/viewer/p-61db972b.js +4 -0
  136. package/dist/viewer/{p-a0df0e0c.js → p-6d9d3553.js} +1 -1
  137. package/dist/viewer/{p-f8d01b8a.entry.js → p-7c5bee8e.entry.js} +1 -1
  138. package/dist/viewer/{p-8decee06.entry.js → p-8de749a5.entry.js} +1 -1
  139. package/dist/viewer/{p-081e6873.js → p-8df35eee.js} +1 -1
  140. package/dist/viewer/{p-671c113c.entry.js → p-923b616f.entry.js} +1 -1
  141. package/dist/viewer/p-9b1ecc71.js +4 -0
  142. package/dist/viewer/{p-3810c24d.js → p-9fd5fc8e.js} +1 -1
  143. package/dist/viewer/p-b2d4c0cf.entry.js +4 -0
  144. package/dist/viewer/{p-364ce21c.js → p-b8bc15ec.js} +1 -1
  145. package/dist/viewer/{p-439220c6.js → p-b8f027eb.js} +1 -1
  146. package/dist/viewer/p-bc7f0ad6.entry.js +4 -0
  147. package/dist/viewer/{p-2cefb1b0.js → p-ce0fe8be.js} +1 -1
  148. package/dist/viewer/p-d939ecd3.entry.js +4 -0
  149. package/dist/viewer/{p-25eaab00.entry.js → p-de7eecce.entry.js} +1 -1
  150. package/dist/viewer/{p-4985fad5.js → p-e3fff448.js} +1 -1
  151. package/dist/viewer/{p-6e80f8b0.entry.js → p-e4934f47.entry.js} +1 -1
  152. package/dist/viewer/{p-df292b56.entry.js → p-e8f6cba6.entry.js} +1 -1
  153. package/dist/viewer/{p-353cfc7a.entry.js → p-ee86bed2.entry.js} +1 -1
  154. package/dist/viewer/{p-c62cb926.entry.js → p-f359a9ac.entry.js} +1 -1
  155. package/dist/viewer/{p-e07377fa.entry.js → p-fa7f2d0c.entry.js} +1 -1
  156. package/dist/viewer/{p-915d95ad.entry.js → p-ffde162f.entry.js} +1 -1
  157. package/dist/viewer/viewer.esm.js +1 -1
  158. package/package.json +8 -8
  159. package/dist/viewer/p-085e908a.js +0 -4
  160. package/dist/viewer/p-0aba71fd.js +0 -18
  161. package/dist/viewer/p-423410be.js +0 -4
  162. package/dist/viewer/p-432267bc.entry.js +0 -4
  163. package/dist/viewer/p-7cad9bf4.js +0 -4
  164. package/dist/viewer/p-d90f2f6d.entry.js +0 -4
  165. package/dist/viewer/p-f755af5a.entry.js +0 -4
  166. package/dist/viewer/p-f7cb7e59.js +0 -4
  167. package/dist/viewer/p-fe11d694.js +0 -4
@@ -1,9 +1,9 @@
1
1
  /**!
2
2
  * Copyright (c) 2022 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import { c as color, u as uri, a as async, b as uuid } from './browser.esm-59e914f6.js';
5
- import { v as vector3, b as boundingBox, p as point, d as dimensions } from './bundle.esm-d899b2d5.js';
6
- import { v as vertexvis, t as toProtoDuration, c as FramePerspectiveCamera, f as fromBoundingBoxAndLookAtCamera } from './streamAttributes-d623bb60.js';
4
+ import { c as color, u as uri, a as async, b as uuid } from './browser.esm-48f051a3.js';
5
+ import { v as vector3, b as boundingBox, p as point, d as dimensions } from './bundle.esm-df3a8a42.js';
6
+ import { v as vertexvis, t as toProtoDuration, f as toProtobuf, d as FramePerspectiveCamera, c as FrameOrthographicCamera, w as withPositionAndViewVector, g as fromBoundingBoxAndLookAtCamera } from './streamAttributes-87a3605c.js';
7
7
 
8
8
  const defaultColor = {
9
9
  opacity: 100,
@@ -167,6 +167,13 @@ class InvalidArgumentError extends CustomError {
167
167
  Object.setPrototypeOf(this, InvalidArgumentError.prototype);
168
168
  }
169
169
  }
170
+ class InvalidCameraError extends CustomError {
171
+ constructor(message, e) {
172
+ super(message, e);
173
+ // Allows for `instanceof` checks.
174
+ Object.setPrototypeOf(this, InvalidCameraError.prototype);
175
+ }
176
+ }
170
177
 
171
178
  function fromUrn(urn) {
172
179
  const uri$1 = uri.parse(urn);
@@ -457,7 +464,7 @@ function buildFlyToOperation(frameCorrelationId, options, animation) {
457
464
  }) });
458
465
  }
459
466
  case 'camera': {
460
- return Object.assign(Object.assign({}, payload), { camera: options.flyTo.data });
467
+ return Object.assign(Object.assign({}, payload), { camera: toProtobuf(options.flyTo.data) });
461
468
  }
462
469
  case 'bounding-box': {
463
470
  return Object.assign(Object.assign({}, payload), { boundingBox: {
@@ -591,32 +598,27 @@ class FlyToExecutor {
591
598
  * a new instance of the class with the updated properties.
592
599
  */
593
600
  class Camera {
594
- constructor(stream, aspect, data, boundingBox, decodeFrame) {
601
+ constructor(stream, aspect, data, boundingBox, decodeFrame, flyToOptions) {
595
602
  this.stream = stream;
596
603
  this.aspect = aspect;
597
604
  this.data = data;
598
605
  this.boundingBox = boundingBox;
599
606
  this.decodeFrame = decodeFrame;
607
+ this.flyToOptions = flyToOptions;
600
608
  }
601
- /**
602
- * Updates the position of the camera such that the given bounding box will
603
- * be contained within the camera's view.
604
- *
605
- * @param boundingBox The bounding box to position to.
606
- */
607
- fitToBoundingBox(boundingBox$1) {
609
+ fitCameraToBoundingBox(boundingBox$1, fovVertical, viewVector) {
608
610
  const radius = 1.1 *
609
611
  vector3.magnitude(vector3.subtract(boundingBox$1.max, boundingBox.center(boundingBox$1)));
610
612
  // ratio of the height of the frustum to the distance along the view vector
611
- let hOverD = Math.tan(this.fovY * PI_OVER_360);
612
- if (this.aspectRatio < 1.0) {
613
- hOverD *= this.aspectRatio;
613
+ let hOverD = Math.tan(fovVertical * PI_OVER_360);
614
+ if (this.aspect < 1.0) {
615
+ hOverD *= this.aspect;
614
616
  }
615
617
  const distance = Math.abs(radius / hOverD);
616
- const vvec = vector3.scale(distance, vector3.normalize(this.viewVector()));
618
+ const vvec = vector3.scale(distance, vector3.normalize(viewVector));
617
619
  const lookAt = boundingBox.center(boundingBox$1);
618
620
  const position = vector3.subtract(lookAt, vvec);
619
- return this.update({ lookAt, position });
621
+ return this.update({ lookAt, position, viewVector: vvec });
620
622
  }
621
623
  /**
622
624
  * Returns the distance from the camera's position to the center
@@ -624,12 +626,11 @@ class Camera {
624
626
  *
625
627
  * @param boundingBox - The bounding box to determine distance from.
626
628
  */
627
- distanceToBoundingBoxCenter(boundingBox$1) {
628
- const box = boundingBox$1 || this.boundingBox;
629
- const boundingBoxCenter = boundingBox.center(box);
630
- const cameraToCenter = vector3.subtract(this.position, boundingBoxCenter);
631
- const distanceToCenterAlongViewVec = Math.abs(vector3.dot(vector3.subtract(this.lookAt, this.position), cameraToCenter)) / vector3.magnitude(vector3.subtract(this.lookAt, this.position));
632
- return distanceToCenterAlongViewVec;
629
+ signedDistanceToBoundingBoxCenter(boundingBox$1) {
630
+ const { position, viewVector } = withPositionAndViewVector(this.data);
631
+ const boundingBoxCenter = boundingBox.center(boundingBox$1 !== null && boundingBox$1 !== void 0 ? boundingBox$1 : this.boundingBox);
632
+ const cameraToCenter = vector3.subtract(boundingBoxCenter, position);
633
+ return (vector3.dot(viewVector, cameraToCenter) / vector3.magnitude(viewVector));
633
634
  }
634
635
  /**
635
636
  * Specifies that the next render of the camera will be repositioned to one of
@@ -640,26 +641,14 @@ class Camera {
640
641
  */
641
642
  flyTo(paramsOrQuery) {
642
643
  if (typeof paramsOrQuery !== 'function') {
643
- this.flyToOptions = { flyTo: this.buildFlyToType(paramsOrQuery) };
644
- return this;
644
+ return this.updateFlyToOptions({
645
+ flyTo: this.buildFlyToType(paramsOrQuery),
646
+ });
645
647
  }
646
648
  else {
647
- this.flyToOptions = paramsOrQuery(new FlyToExecutor()).build();
648
- return this;
649
+ return this.updateFlyToOptions(paramsOrQuery(new FlyToExecutor()).build());
649
650
  }
650
651
  }
651
- /**
652
- * Shifts the position of the camera by the given delta.
653
- *
654
- * @param delta The number of units to shift the camera on the X, Y, and Z
655
- * axis.
656
- */
657
- moveBy(delta) {
658
- return this.update({
659
- position: vector3.add(this.position, delta),
660
- lookAt: vector3.add(this.lookAt, delta),
661
- });
662
- }
663
652
  viewAll() {
664
653
  return this.fitToBoundingBox(this.boundingBox);
665
654
  }
@@ -691,7 +680,7 @@ class Camera {
691
680
  }
692
681
  else {
693
682
  this.stream.replaceCamera({
694
- camera: this.data,
683
+ camera: toProtobuf(this.data),
695
684
  frameCorrelationId: { value: corrId },
696
685
  });
697
686
  return new CameraRenderResult(this.stream, this.decodeFrame, {
@@ -711,22 +700,7 @@ class Camera {
711
700
  * @param axis A normalized vector to rotate around.
712
701
  */
713
702
  rotateAroundAxis(angleInRadians, axis) {
714
- return this.rotateAroundAxisAtPoint(angleInRadians, this.lookAt, axis);
715
- }
716
- /**
717
- * Repositions the camera by rotating its current position around an axis
718
- * defined at a specific world point.
719
- *
720
- * @param angleInRadians The angle, in radians, to rotate.
721
- * @param point The point in world space to place the axis at.
722
- * @param axis A normalized vector to rotate around.
723
- */
724
- rotateAroundAxisAtPoint(angleInRadians, point, axis) {
725
- return this.update({
726
- position: vector3.rotateAboutAxis(angleInRadians, this.position, axis, point),
727
- lookAt: vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point),
728
- up: vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin()),
729
- });
703
+ return this.rotateAroundAxisAtPoint(angleInRadians, this.data.lookAt, axis);
730
704
  }
731
705
  /**
732
706
  * Updates the `position` and `up` vectors of the camera to the given standard
@@ -742,20 +716,6 @@ class Camera {
742
716
  up: standardView.up,
743
717
  });
744
718
  }
745
- /**
746
- * Updates the `position`, `lookAt` and/or `up` vectors of the camera.
747
- *
748
- * @param camera The values to update the camera to.
749
- */
750
- update(camera) {
751
- return new Camera(this.stream, this.aspectRatio, Object.assign(Object.assign({}, this.data), camera), this.boundingBox, this.decodeFrame);
752
- }
753
- /**
754
- * Returns a `FramePerspectiveCamera` representation.
755
- */
756
- toFrameCamera() {
757
- return new FramePerspectiveCamera(this.position, this.lookAt, this.up, this.near, this.far, this.aspectRatio, this.fovY);
758
- }
759
719
  buildFlyToType(options) {
760
720
  if (options.boundingBox != null) {
761
721
  return { type: 'bounding-box', data: options.boundingBox };
@@ -776,36 +736,66 @@ class Camera {
776
736
  computeClippingPlanes(camera) {
777
737
  return fromBoundingBoxAndLookAtCamera(this.boundingBox, camera);
778
738
  }
739
+ }
740
+ class PerspectiveCamera extends Camera {
741
+ constructor(stream, aspect, perspectiveData, boundingBox, decodeFrame, flyToOptions) {
742
+ super(stream, aspect, perspectiveData, boundingBox, decodeFrame, flyToOptions);
743
+ this.perspectiveData = perspectiveData;
744
+ }
779
745
  /**
780
- * Returns the view vector for the camera, which is the direction between the
781
- * `position` and `lookAt` vectors.
746
+ * Shifts the position of the camera by the given delta.
747
+ *
748
+ * @param delta The number of units to shift the camera on the X, Y, and Z
749
+ * axis.
782
750
  */
783
- viewVector() {
751
+ moveBy(delta) {
752
+ return this.update({
753
+ position: vector3.add(this.position, delta),
754
+ lookAt: vector3.add(this.lookAt, delta),
755
+ });
756
+ }
757
+ rotateAroundAxisAtPoint(angleInRadians, point, axis) {
758
+ return this.update({
759
+ position: vector3.rotateAboutAxis(angleInRadians, this.position, axis, point),
760
+ lookAt: vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point),
761
+ up: vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin()),
762
+ });
763
+ }
764
+ fitToBoundingBox(boundingBox) {
765
+ return super.fitCameraToBoundingBox(boundingBox, this.fovY, this.viewVector);
766
+ }
767
+ update(camera) {
768
+ return new PerspectiveCamera(this.stream, this.aspect, Object.assign(Object.assign({}, this.perspectiveData), camera), this.boundingBox, this.decodeFrame, this.flyToOptions);
769
+ }
770
+ toFrameCamera() {
771
+ return new FramePerspectiveCamera(this.position, this.lookAt, this.up, this.near, this.far, this.aspectRatio, this.fovY);
772
+ }
773
+ get viewVector() {
784
774
  return vector3.subtract(this.lookAt, this.position);
785
775
  }
786
776
  /**
787
777
  * The position vector for the camera, in world space coordinates.
788
778
  */
789
779
  get position() {
790
- return Object.assign({}, this.data.position);
780
+ return Object.assign({}, this.perspectiveData.position);
791
781
  }
792
782
  /**
793
783
  * A normalized vector representing the up direction.
794
784
  */
795
785
  get up() {
796
- return Object.assign({}, this.data.up);
786
+ return Object.assign({}, this.perspectiveData.up);
797
787
  }
798
788
  /**
799
789
  * A vector, in world space coordinates, of where the camera is pointed at.
800
790
  */
801
791
  get lookAt() {
802
- return Object.assign({}, this.data.lookAt);
792
+ return Object.assign({}, this.perspectiveData.lookAt);
803
793
  }
804
794
  /**
805
795
  * The camera's field of view.
806
796
  */
807
797
  get fovY() {
808
- return 45;
798
+ return this.perspectiveData.fovY;
809
799
  }
810
800
  /**
811
801
  * The aspect ratio of the camera.
@@ -817,16 +807,104 @@ class Camera {
817
807
  * The camera's near clipping plane.
818
808
  */
819
809
  get near() {
820
- const { near } = this.computeClippingPlanes(this.data);
810
+ const { near } = this.computeClippingPlanes(this.perspectiveData);
821
811
  return near;
822
812
  }
823
813
  /**
824
814
  * The camera's far clipping plane.
825
815
  */
826
816
  get far() {
827
- const { far } = this.computeClippingPlanes(this.data);
817
+ const { far } = this.computeClippingPlanes(this.perspectiveData);
828
818
  return far;
829
819
  }
820
+ updateFlyToOptions(flyToOptions) {
821
+ return new PerspectiveCamera(this.stream, this.aspect, this.perspectiveData, this.boundingBox, this.decodeFrame, flyToOptions);
822
+ }
823
+ }
824
+ class OrthographicCamera extends Camera {
825
+ constructor(stream, aspect, orthographicData, boundingBox, decodeFrame, flyToOptions) {
826
+ super(stream, aspect, orthographicData, boundingBox, decodeFrame, flyToOptions);
827
+ this.orthographicData = orthographicData;
828
+ }
829
+ /**
830
+ * Shifts the position of the camera by the given delta.
831
+ *
832
+ * @param delta The number of units to shift the camera on the X, Y, and Z
833
+ * axis.
834
+ */
835
+ moveBy(delta) {
836
+ const updatedLookAt = vector3.add(this.lookAt, delta);
837
+ return this.update({
838
+ viewVector: vector3.subtract(updatedLookAt, vector3.add(this.position, delta)),
839
+ lookAt: updatedLookAt,
840
+ });
841
+ }
842
+ rotateAroundAxisAtPoint(angleInRadians, point, axis) {
843
+ const newLookAt = vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point);
844
+ const newUp = vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin());
845
+ const newViewVector = vector3.subtract(vector3.rotateAboutAxis(angleInRadians, this.position, axis, point), newLookAt);
846
+ return this.update({
847
+ viewVector: newViewVector,
848
+ lookAt: newLookAt,
849
+ up: newUp,
850
+ });
851
+ }
852
+ fitToBoundingBox(boundingBox) {
853
+ return super.fitCameraToBoundingBox(boundingBox, this.fovHeight, this.viewVector);
854
+ }
855
+ update(camera) {
856
+ return new OrthographicCamera(this.stream, this.aspect, Object.assign(Object.assign({}, this.orthographicData), camera), this.boundingBox, this.decodeFrame, this.flyToOptions);
857
+ }
858
+ toFrameCamera() {
859
+ return new FrameOrthographicCamera(this.viewVector, this.lookAt, this.up, this.near, this.far, this.aspectRatio, this.fovHeight);
860
+ }
861
+ get viewVector() {
862
+ return Object.assign({}, this.orthographicData.viewVector);
863
+ }
864
+ get position() {
865
+ return vector3.add(this.lookAt, vector3.negate(this.viewVector));
866
+ }
867
+ /**
868
+ * A normalized vector representing the up direction.
869
+ */
870
+ get up() {
871
+ return Object.assign({}, this.orthographicData.up);
872
+ }
873
+ /**
874
+ * A vector, in world space coordinates, of where the camera is pointed at.
875
+ */
876
+ get lookAt() {
877
+ return Object.assign({}, this.orthographicData.lookAt);
878
+ }
879
+ /**
880
+ * The camera's field of view.
881
+ */
882
+ get fovHeight() {
883
+ return this.orthographicData.fovHeight;
884
+ }
885
+ /**
886
+ * The aspect ratio of the camera.
887
+ */
888
+ get aspectRatio() {
889
+ return this.aspect;
890
+ }
891
+ /**
892
+ * The camera's near clipping plane.
893
+ */
894
+ get near() {
895
+ const { near } = this.computeClippingPlanes(this.orthographicData);
896
+ return near;
897
+ }
898
+ /**
899
+ * The camera's far clipping plane.
900
+ */
901
+ get far() {
902
+ const { far } = this.computeClippingPlanes(this.orthographicData);
903
+ return far;
904
+ }
905
+ updateFlyToOptions(flyToOptions) {
906
+ return new OrthographicCamera(this.stream, this.aspect, this.orthographicData, this.boundingBox, this.decodeFrame, flyToOptions);
907
+ }
830
908
  }
831
909
 
832
910
  /**
@@ -1233,12 +1311,25 @@ class Scene {
1233
1311
  */
1234
1312
  camera() {
1235
1313
  const { scene } = this.frame;
1236
- const data = {
1237
- position: scene.camera.position,
1238
- lookAt: scene.camera.lookAt,
1239
- up: scene.camera.up,
1240
- };
1241
- return new Camera(this.stream, dimensions.aspectRatio(this.viewport()), data, this.frame.scene.boundingBox, this.decodeFrame);
1314
+ if (scene.camera instanceof FrameOrthographicCamera) {
1315
+ return new OrthographicCamera(this.stream, dimensions.aspectRatio(this.viewport()), {
1316
+ viewVector: scene.camera.viewVector,
1317
+ lookAt: scene.camera.lookAt,
1318
+ up: scene.camera.up,
1319
+ fovHeight: scene.camera.fovHeight,
1320
+ }, this.frame.scene.boundingBox, this.decodeFrame);
1321
+ }
1322
+ else if (scene.camera instanceof FramePerspectiveCamera) {
1323
+ return new PerspectiveCamera(this.stream, dimensions.aspectRatio(this.viewport()), {
1324
+ position: scene.camera.position,
1325
+ lookAt: scene.camera.lookAt,
1326
+ up: scene.camera.up,
1327
+ fovY: scene.camera.fovY,
1328
+ }, this.frame.scene.boundingBox, this.decodeFrame);
1329
+ }
1330
+ else {
1331
+ throw new InvalidCameraError('Cannot retrieve camera. Scene has an unknown or invalid camera type.');
1332
+ }
1242
1333
  }
1243
1334
  boundingBox() {
1244
1335
  return this.frame.scene.boundingBox;