@vertexvis/viewer 0.13.1 → 0.13.2-canary.10
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.
- package/dist/cjs/{browser.esm-31b03292.js → browser.esm-075810bf.js} +1 -1
- package/dist/cjs/{bundle.esm-dc0a8361.js → bundle.esm-618a5fe9.js} +80 -28
- package/dist/cjs/{config-90ee43d5.js → config-fb124bac.js} +2 -2
- package/dist/cjs/{cursors-ad2fd395.js → cursors-d71f6a74.js} +1 -1
- package/dist/cjs/{dom-dd265f48.js → dom-57ef84e9.js} +1 -1
- package/dist/cjs/{entities-aa59890e.js → entities-90f1347a.js} +3 -3
- package/dist/cjs/index.cjs.js +14 -12
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mapper-f6e6cafe.js → mapper-80ee2957.js} +2 -2
- package/dist/cjs/{markup-fb1553b1.js → markup-7f7de5f2.js} +2 -2
- package/dist/cjs/{measurement-aba1e0e8.js → measurement-f1ae9248.js} +2 -2
- package/dist/cjs/{model-4ec0c36e.js → model-55abd9ab.js} +1 -1
- package/dist/cjs/{overlays-40c6cbc7.js → overlays-68e8eff2.js} +2 -2
- package/dist/cjs/{png-decoder-27d25eed.js → png-decoder-076131d8.js} +1 -1
- package/dist/cjs/{results-bc325974.js → results-e9496869.js} +1 -1
- package/dist/cjs/{scene-d420fd26.js → scene-92728420.js} +188 -90
- package/dist/cjs/{streamAttributes-d6236448.js → streamAttributes-81eb52f2.js} +1508 -43
- package/dist/cjs/{utils-545b1865.js → utils-463cd52e.js} +1 -1
- package/dist/cjs/{utils-f80be307.js → utils-6397efca.js} +1 -1
- package/dist/cjs/vertex-scene-tree-search_3.cjs.entry.js +1 -1
- package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js +1 -1
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-dom-element_3.cjs.entry.js +8 -7
- package/dist/cjs/vertex-viewer-markup-arrow_3.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer-markup-tool.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-markup.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +20 -15
- package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +6 -6
- package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +10 -10
- package/dist/cjs/vertex-viewer-measurement-tool.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-measurements.cjs.entry.js +8 -8
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer.cjs.entry.js +287 -80
- package/dist/cjs/viewer.cjs.js +1 -1
- package/dist/cjs/{viewport-8c39089f.js → viewport-54b1389d.js} +34 -2
- package/dist/collection/components/scene-tree-table-cell/scene-tree-table-cell.css +1 -1
- package/dist/collection/components/viewer/viewer.js +68 -4
- package/dist/collection/components/viewer-dom-renderer/renderer2d.js +1 -1
- package/dist/collection/components/viewer-dom-renderer/renderer3d.js +4 -2
- package/dist/collection/components/viewer-dom-renderer/viewer-dom-renderer.js +5 -6
- package/dist/collection/components/viewer-measurement-distance/hitTest.js +9 -4
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance.js +5 -5
- package/dist/collection/components/viewer-measurement-overlays/viewer-measurement-overlays.js +3 -3
- package/dist/collection/index.js +2 -2
- package/dist/collection/lib/errors.js +8 -1
- package/dist/collection/lib/interactions/index.js +3 -1
- package/dist/collection/lib/interactions/interactionApi.js +4 -25
- package/dist/collection/lib/interactions/interactionApiOrthographic.js +136 -0
- package/dist/collection/lib/interactions/interactionApiPerspective.js +51 -0
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js +3 -2
- package/dist/collection/lib/mappers/frameStreaming.js +27 -5
- package/dist/collection/lib/rendering/matrices.js +13 -4
- package/dist/collection/lib/rendering/vectors.js +7 -0
- package/dist/collection/lib/scenes/__mocks__/mocks.js +2 -2
- package/dist/collection/lib/scenes/camera.js +163 -83
- package/dist/collection/lib/scenes/mapper.js +3 -2
- package/dist/collection/lib/scenes/scene.js +22 -9
- package/dist/collection/lib/types/clippingPlanes.js +48 -20
- package/dist/collection/lib/types/depthBuffer.js +32 -3
- package/dist/collection/lib/types/frame.js +133 -24
- package/dist/collection/lib/types/frameCamera.js +87 -6
- package/dist/collection/lib/types/viewport.js +34 -2
- package/dist/collection/testing/fixtures.js +28 -15
- package/dist/collection/testing/viewer.js +5 -3
- package/dist/custom-elements/index.js +2135 -283
- package/dist/esm/{browser.esm-59e914f6.js → browser.esm-e72d80ad.js} +1 -1
- package/dist/esm/{bundle.esm-d899b2d5.js → bundle.esm-8ceccb91.js} +80 -29
- package/dist/esm/{config-604c644e.js → config-fb7cd8ff.js} +2 -2
- package/dist/esm/{cursors-a7ec4adb.js → cursors-fc2deed7.js} +1 -1
- package/dist/esm/{dom-780d25be.js → dom-2cd18856.js} +1 -1
- package/dist/esm/{entities-759d97cd.js → entities-78557270.js} +3 -3
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.mjs +12 -12
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/{mapper-4b815e31.js → mapper-da36de17.js} +2 -2
- package/dist/esm/{markup-1d177b4a.js → markup-c313d99c.js} +2 -2
- package/dist/esm/{measurement-12cdbf5c.js → measurement-544b69d5.js} +2 -2
- package/dist/esm/{model-e5a4f00f.js → model-2a34b443.js} +1 -1
- package/dist/esm/{overlays-1919b192.js → overlays-354e275c.js} +2 -2
- package/dist/esm/{png-decoder-3f1fa486.js → png-decoder-07de80d1.js} +1 -1
- package/dist/esm/{results-994bdb50.js → results-4d0c3568.js} +1 -1
- package/dist/esm/{scene-2c2460d5.js → scene-2bfcce74.js} +188 -90
- package/dist/esm/{streamAttributes-d623bb60.js → streamAttributes-d0b384b3.js} +1502 -44
- package/dist/esm/{utils-83a19677.js → utils-3ea0acdd.js} +1 -1
- package/dist/esm/{utils-5e57bf24.js → utils-e0941c61.js} +1 -1
- package/dist/esm/vertex-scene-tree-search_3.entry.js +1 -1
- package/dist/esm/vertex-scene-tree-table-cell.entry.js +1 -1
- package/dist/esm/vertex-scene-tree.entry.js +4 -4
- package/dist/esm/vertex-viewer-dom-element_3.entry.js +8 -7
- package/dist/esm/vertex-viewer-markup-arrow_3.entry.js +3 -3
- package/dist/esm/vertex-viewer-markup-tool.entry.js +4 -4
- package/dist/esm/vertex-viewer-markup.entry.js +4 -4
- package/dist/esm/vertex-viewer-measurement-details.entry.js +3 -3
- package/dist/esm/vertex-viewer-measurement-distance.entry.js +20 -15
- package/dist/esm/vertex-viewer-measurement-line_2.entry.js +6 -6
- package/dist/esm/vertex-viewer-measurement-precise.entry.js +10 -10
- package/dist/esm/vertex-viewer-measurement-tool.entry.js +5 -5
- package/dist/esm/vertex-viewer-measurements.entry.js +8 -8
- package/dist/esm/vertex-viewer-view-cube.entry.js +3 -3
- package/dist/esm/vertex-viewer.entry.js +287 -80
- package/dist/esm/viewer.js +1 -1
- package/dist/esm/{viewport-01c886ea.js → viewport-5cc7b128.js} +34 -2
- package/dist/types/components/scene-tree-table-cell/scene-tree-table-cell.d.ts +1 -1
- package/dist/types/components/viewer/viewer.d.ts +8 -0
- package/dist/types/components/viewer-dom-renderer/renderer2d.d.ts +2 -2
- package/dist/types/components/viewer-dom-renderer/renderer3d.d.ts +3 -3
- package/dist/types/components/viewer-dom-renderer/viewer-dom-renderer.d.ts +2 -2
- package/dist/types/components/viewer-measurement-distance/hitTest.d.ts +3 -2
- package/dist/types/components/viewer-measurement-distance/utils.d.ts +2 -2
- package/dist/types/components/viewer-measurement-distance/viewer-measurement-distance.d.ts +2 -2
- package/dist/types/components/viewer-measurement-overlays/viewer-measurement-overlays-components.d.ts +2 -2
- package/dist/types/components/viewer-measurement-overlays/viewer-measurement-overlays.d.ts +2 -2
- package/dist/types/components.d.ts +15 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/errors.d.ts +3 -0
- package/dist/types/lib/interactions/index.d.ts +2 -0
- package/dist/types/lib/interactions/interactionApi.d.ts +34 -26
- package/dist/types/lib/interactions/interactionApiOrthographic.d.ts +35 -0
- package/dist/types/lib/interactions/interactionApiPerspective.d.ts +21 -0
- package/dist/types/lib/mappers/frameStreaming.d.ts +2 -0
- package/dist/types/lib/rendering/vectors.d.ts +2 -0
- package/dist/types/lib/scenes/__mocks__/mocks.d.ts +2 -2
- package/dist/types/lib/scenes/camera.d.ts +101 -38
- package/dist/types/lib/scenes/scene.d.ts +1 -1
- package/dist/types/lib/types/clippingPlanes.d.ts +3 -1
- package/dist/types/lib/types/depthBuffer.d.ts +28 -6
- package/dist/types/lib/types/frame.d.ts +80 -11
- package/dist/types/lib/types/frameCamera.d.ts +22 -3
- package/dist/types/lib/types/viewport.d.ts +24 -4
- package/dist/types/testing/fixtures.d.ts +8 -5
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/{p-f8d01b8a.entry.js → p-0a189e62.entry.js} +1 -1
- package/dist/viewer/{p-e07377fa.entry.js → p-1ca95f9a.entry.js} +1 -1
- package/dist/viewer/{p-d00e9203.js → p-3561d910.js} +1 -1
- package/dist/viewer/p-388a43f7.js +4 -0
- package/dist/viewer/{p-3810c24d.js → p-3f0f83ad.js} +1 -1
- package/dist/viewer/{p-8decee06.entry.js → p-41028d3b.entry.js} +1 -1
- package/dist/viewer/{p-439220c6.js → p-487e054a.js} +1 -1
- package/dist/viewer/p-49d36e94.entry.js +4 -0
- package/dist/viewer/{p-da2f4a56.js → p-5b342e97.js} +1 -1
- package/dist/viewer/p-661f0612.js +18 -0
- package/dist/viewer/{p-364ce21c.js → p-69058178.js} +1 -1
- package/dist/viewer/{p-353cfc7a.entry.js → p-73a5eacc.entry.js} +1 -1
- package/dist/viewer/p-77be081a.js +4 -0
- package/dist/viewer/{p-a0df0e0c.js → p-809d09d9.js} +1 -1
- package/dist/viewer/{p-d90f2f6d.entry.js → p-858bd2c7.entry.js} +1 -1
- package/dist/viewer/{p-25eaab00.entry.js → p-89b66838.entry.js} +1 -1
- package/dist/viewer/p-a93a63a9.js +4 -0
- package/dist/viewer/{p-df292b56.entry.js → p-b043b076.entry.js} +1 -1
- package/dist/viewer/{p-915d95ad.entry.js → p-b0ac6b3c.entry.js} +1 -1
- package/dist/viewer/{p-fec1a8d0.entry.js → p-b7624ff2.entry.js} +1 -1
- package/dist/viewer/{p-f7cb7e59.js → p-b8774c9c.js} +1 -1
- package/dist/viewer/{p-67446e35.js → p-bcb66f97.js} +1 -1
- package/dist/viewer/p-bcde5521.entry.js +4 -0
- package/dist/viewer/{p-7cad9bf4.js → p-d1584404.js} +1 -1
- package/dist/viewer/p-d32b54cb.js +4 -0
- package/dist/viewer/{p-f755af5a.entry.js → p-d3a20af4.entry.js} +1 -1
- package/dist/viewer/{p-c62cb926.entry.js → p-d9f99f4d.entry.js} +1 -1
- package/dist/viewer/p-e38458da.js +4 -0
- package/dist/viewer/{p-301660cf.js → p-e75bba97.js} +2 -2
- package/dist/viewer/{p-6e80f8b0.entry.js → p-ebd55df7.entry.js} +1 -1
- package/dist/viewer/{p-671c113c.entry.js → p-f0411993.entry.js} +1 -1
- package/dist/viewer/{p-2cefb1b0.js → p-fa9a0bed.js} +1 -1
- package/dist/viewer/p-ffdeb08c.js +4 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +8 -8
- package/dist/viewer/p-081e6873.js +0 -4
- package/dist/viewer/p-085e908a.js +0 -4
- package/dist/viewer/p-0aba71fd.js +0 -18
- package/dist/viewer/p-3f6ac74f.js +0 -4
- package/dist/viewer/p-423410be.js +0 -4
- package/dist/viewer/p-432267bc.entry.js +0 -4
- package/dist/viewer/p-4985fad5.js +0 -4
- package/dist/viewer/p-e2297df2.entry.js +0 -4
- 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-
|
|
5
|
-
import { v as vector3, b as boundingBox, p as point, d as dimensions } from './bundle.esm-
|
|
6
|
-
import { v as vertexvis, t as toProtoDuration,
|
|
4
|
+
import { c as color, u as uri, a as async, b as uuid } from './browser.esm-e72d80ad.js';
|
|
5
|
+
import { v as vector3, b as boundingBox, a as boundingSphere, p as point, d as dimensions } from './bundle.esm-8ceccb91.js';
|
|
6
|
+
import { v as vertexvis, t as toProtoDuration, g as toProtobuf, e as FramePerspectiveCamera, h as constrainViewVector, d as FrameOrthographicCamera, w as withPositionAndViewVector, i as fromBoundingBoxAndLookAtCamera } from './streamAttributes-d0b384b3.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,19 @@ 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
|
-
|
|
603
|
-
* be contained within the camera's view.
|
|
604
|
-
*
|
|
605
|
-
* @param boundingBox The bounding box to position to.
|
|
606
|
-
*/
|
|
607
|
-
fitToBoundingBox(boundingBox$1) {
|
|
608
|
-
const radius = 1.1 *
|
|
609
|
-
vector3.magnitude(vector3.subtract(boundingBox$1.max, boundingBox.center(boundingBox$1)));
|
|
610
|
-
// 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;
|
|
614
|
-
}
|
|
615
|
-
const distance = Math.abs(radius / hOverD);
|
|
616
|
-
const vvec = vector3.scale(distance, vector3.normalize(this.viewVector()));
|
|
609
|
+
fitCameraToBoundingBox(boundingBox$1, distance, viewVector) {
|
|
610
|
+
const vvec = vector3.scale(distance, vector3.normalize(viewVector));
|
|
617
611
|
const lookAt = boundingBox.center(boundingBox$1);
|
|
618
612
|
const position = vector3.subtract(lookAt, vvec);
|
|
619
|
-
return this.update({ lookAt, position });
|
|
613
|
+
return this.update({ lookAt, position, viewVector: vvec });
|
|
620
614
|
}
|
|
621
615
|
/**
|
|
622
616
|
* Returns the distance from the camera's position to the center
|
|
@@ -624,12 +618,11 @@ class Camera {
|
|
|
624
618
|
*
|
|
625
619
|
* @param boundingBox - The bounding box to determine distance from.
|
|
626
620
|
*/
|
|
627
|
-
|
|
628
|
-
const
|
|
629
|
-
const boundingBoxCenter = boundingBox.center(
|
|
630
|
-
const cameraToCenter = vector3.subtract(
|
|
631
|
-
|
|
632
|
-
return distanceToCenterAlongViewVec;
|
|
621
|
+
signedDistanceToBoundingBoxCenter(boundingBox$1) {
|
|
622
|
+
const { position, viewVector } = withPositionAndViewVector(this.data);
|
|
623
|
+
const boundingBoxCenter = boundingBox.center(boundingBox$1 !== null && boundingBox$1 !== void 0 ? boundingBox$1 : this.boundingBox);
|
|
624
|
+
const cameraToCenter = vector3.subtract(boundingBoxCenter, position);
|
|
625
|
+
return (vector3.dot(viewVector, cameraToCenter) / vector3.magnitude(viewVector));
|
|
633
626
|
}
|
|
634
627
|
/**
|
|
635
628
|
* Specifies that the next render of the camera will be repositioned to one of
|
|
@@ -640,26 +633,14 @@ class Camera {
|
|
|
640
633
|
*/
|
|
641
634
|
flyTo(paramsOrQuery) {
|
|
642
635
|
if (typeof paramsOrQuery !== 'function') {
|
|
643
|
-
|
|
644
|
-
|
|
636
|
+
return this.updateFlyToOptions({
|
|
637
|
+
flyTo: this.buildFlyToType(paramsOrQuery),
|
|
638
|
+
});
|
|
645
639
|
}
|
|
646
640
|
else {
|
|
647
|
-
this.
|
|
648
|
-
return this;
|
|
641
|
+
return this.updateFlyToOptions(paramsOrQuery(new FlyToExecutor()).build());
|
|
649
642
|
}
|
|
650
643
|
}
|
|
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
644
|
viewAll() {
|
|
664
645
|
return this.fitToBoundingBox(this.boundingBox);
|
|
665
646
|
}
|
|
@@ -691,7 +672,7 @@ class Camera {
|
|
|
691
672
|
}
|
|
692
673
|
else {
|
|
693
674
|
this.stream.replaceCamera({
|
|
694
|
-
camera: this.data,
|
|
675
|
+
camera: toProtobuf(this.data),
|
|
695
676
|
frameCorrelationId: { value: corrId },
|
|
696
677
|
});
|
|
697
678
|
return new CameraRenderResult(this.stream, this.decodeFrame, {
|
|
@@ -711,22 +692,7 @@ class Camera {
|
|
|
711
692
|
* @param axis A normalized vector to rotate around.
|
|
712
693
|
*/
|
|
713
694
|
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
|
-
});
|
|
695
|
+
return this.rotateAroundAxisAtPoint(angleInRadians, this.data.lookAt, axis);
|
|
730
696
|
}
|
|
731
697
|
/**
|
|
732
698
|
* Updates the `position` and `up` vectors of the camera to the given standard
|
|
@@ -738,24 +704,11 @@ class Camera {
|
|
|
738
704
|
standardView(standardView) {
|
|
739
705
|
return this.update({
|
|
740
706
|
position: standardView.position,
|
|
707
|
+
viewVector: vector3.subtract(vector3.origin(), standardView.position),
|
|
741
708
|
lookAt: vector3.origin(),
|
|
742
709
|
up: standardView.up,
|
|
743
710
|
});
|
|
744
711
|
}
|
|
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
712
|
buildFlyToType(options) {
|
|
760
713
|
if (options.boundingBox != null) {
|
|
761
714
|
return { type: 'bounding-box', data: options.boundingBox };
|
|
@@ -776,36 +729,165 @@ class Camera {
|
|
|
776
729
|
computeClippingPlanes(camera) {
|
|
777
730
|
return fromBoundingBoxAndLookAtCamera(this.boundingBox, camera);
|
|
778
731
|
}
|
|
732
|
+
}
|
|
733
|
+
class PerspectiveCamera extends Camera {
|
|
734
|
+
constructor(stream, aspect, perspectiveData, boundingBox, decodeFrame, flyToOptions) {
|
|
735
|
+
super(stream, aspect, perspectiveData, boundingBox, decodeFrame, flyToOptions);
|
|
736
|
+
this.perspectiveData = perspectiveData;
|
|
737
|
+
}
|
|
779
738
|
/**
|
|
780
|
-
*
|
|
781
|
-
*
|
|
739
|
+
* Shifts the position of the camera by the given delta.
|
|
740
|
+
*
|
|
741
|
+
* @param delta The number of units to shift the camera on the X, Y, and Z
|
|
742
|
+
* axis.
|
|
782
743
|
*/
|
|
783
|
-
|
|
744
|
+
moveBy(delta) {
|
|
745
|
+
return this.update({
|
|
746
|
+
position: vector3.add(this.position, delta),
|
|
747
|
+
lookAt: vector3.add(this.lookAt, delta),
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
rotateAroundAxisAtPoint(angleInRadians, point, axis) {
|
|
751
|
+
return this.update({
|
|
752
|
+
position: vector3.rotateAboutAxis(angleInRadians, this.position, axis, point),
|
|
753
|
+
lookAt: vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point),
|
|
754
|
+
up: vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin()),
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
fitToBoundingBox(boundingBox$1) {
|
|
758
|
+
var _a;
|
|
759
|
+
const radius = 1.1 *
|
|
760
|
+
vector3.magnitude(vector3.subtract(boundingBox$1.max, boundingBox.center(boundingBox$1)));
|
|
761
|
+
// ratio of the height of the frustum to the distance along the view vector
|
|
762
|
+
let hOverD = Math.tan(((_a = this.fovY) !== null && _a !== void 0 ? _a : 45) * PI_OVER_360);
|
|
763
|
+
if (this.aspect < 1.0) {
|
|
764
|
+
hOverD *= this.aspect;
|
|
765
|
+
}
|
|
766
|
+
const distance = Math.abs(radius / hOverD);
|
|
767
|
+
return super.fitCameraToBoundingBox(boundingBox$1, distance, this.viewVector);
|
|
768
|
+
}
|
|
769
|
+
update(camera) {
|
|
770
|
+
return new PerspectiveCamera(this.stream, this.aspect, Object.assign(Object.assign({}, this.perspectiveData), camera), this.boundingBox, this.decodeFrame, this.flyToOptions);
|
|
771
|
+
}
|
|
772
|
+
toFrameCamera() {
|
|
773
|
+
var _a;
|
|
774
|
+
return new FramePerspectiveCamera(this.position, this.lookAt, this.up, this.near, this.far, this.aspectRatio, (_a = this.fovY) !== null && _a !== void 0 ? _a : 45);
|
|
775
|
+
}
|
|
776
|
+
get viewVector() {
|
|
784
777
|
return vector3.subtract(this.lookAt, this.position);
|
|
785
778
|
}
|
|
786
779
|
/**
|
|
787
780
|
* The position vector for the camera, in world space coordinates.
|
|
788
781
|
*/
|
|
789
782
|
get position() {
|
|
790
|
-
return Object.assign({}, this.
|
|
783
|
+
return Object.assign({}, this.perspectiveData.position);
|
|
791
784
|
}
|
|
792
785
|
/**
|
|
793
786
|
* A normalized vector representing the up direction.
|
|
794
787
|
*/
|
|
795
788
|
get up() {
|
|
796
|
-
return Object.assign({}, this.
|
|
789
|
+
return Object.assign({}, this.perspectiveData.up);
|
|
797
790
|
}
|
|
798
791
|
/**
|
|
799
792
|
* A vector, in world space coordinates, of where the camera is pointed at.
|
|
800
793
|
*/
|
|
801
794
|
get lookAt() {
|
|
802
|
-
return Object.assign({}, this.
|
|
795
|
+
return Object.assign({}, this.perspectiveData.lookAt);
|
|
803
796
|
}
|
|
804
797
|
/**
|
|
805
798
|
* The camera's field of view.
|
|
806
799
|
*/
|
|
807
800
|
get fovY() {
|
|
808
|
-
return
|
|
801
|
+
return this.perspectiveData.fovY;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* The aspect ratio of the camera.
|
|
805
|
+
*/
|
|
806
|
+
get aspectRatio() {
|
|
807
|
+
return this.aspect;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* The camera's near clipping plane.
|
|
811
|
+
*/
|
|
812
|
+
get near() {
|
|
813
|
+
const { near } = this.computeClippingPlanes(this.perspectiveData);
|
|
814
|
+
return near;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* The camera's far clipping plane.
|
|
818
|
+
*/
|
|
819
|
+
get far() {
|
|
820
|
+
const { far } = this.computeClippingPlanes(this.perspectiveData);
|
|
821
|
+
return far;
|
|
822
|
+
}
|
|
823
|
+
updateFlyToOptions(flyToOptions) {
|
|
824
|
+
return new PerspectiveCamera(this.stream, this.aspect, this.perspectiveData, this.boundingBox, this.decodeFrame, flyToOptions);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
class OrthographicCamera extends Camera {
|
|
828
|
+
constructor(stream, aspect, orthographicData, boundingBox, decodeFrame, flyToOptions) {
|
|
829
|
+
super(stream, aspect, orthographicData, boundingBox, decodeFrame, flyToOptions);
|
|
830
|
+
this.orthographicData = orthographicData;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Shifts the position of the camera by the given delta.
|
|
834
|
+
*
|
|
835
|
+
* @param delta The number of units to shift the camera on the X, Y, and Z
|
|
836
|
+
* axis.
|
|
837
|
+
*/
|
|
838
|
+
moveBy(delta) {
|
|
839
|
+
return this.update({
|
|
840
|
+
lookAt: vector3.add(this.lookAt, delta),
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
rotateAroundAxisAtPoint(angleInRadians, point, axis) {
|
|
844
|
+
const updatedLookAt = vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point);
|
|
845
|
+
const updatedPosition = vector3.rotateAboutAxis(angleInRadians, this.position, axis, point);
|
|
846
|
+
const viewVector = constrainViewVector(vector3.subtract(updatedLookAt, updatedPosition), boundingSphere.create(this.boundingBox));
|
|
847
|
+
return this.update({
|
|
848
|
+
viewVector: viewVector,
|
|
849
|
+
lookAt: updatedLookAt,
|
|
850
|
+
up: vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin()),
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
fitToBoundingBox(boundingBox) {
|
|
854
|
+
const boundingSphere$1 = boundingSphere.create(boundingBox);
|
|
855
|
+
const fitAll = super.fitCameraToBoundingBox(boundingBox, boundingSphere$1.radius, this.viewVector);
|
|
856
|
+
return this.update({
|
|
857
|
+
lookAt: fitAll.lookAt,
|
|
858
|
+
viewVector: fitAll.viewVector,
|
|
859
|
+
fovHeight: boundingSphere$1.radius * 2,
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
update(camera) {
|
|
863
|
+
return new OrthographicCamera(this.stream, this.aspect, Object.assign(Object.assign({}, this.orthographicData), camera), this.boundingBox, this.decodeFrame, this.flyToOptions);
|
|
864
|
+
}
|
|
865
|
+
toFrameCamera() {
|
|
866
|
+
return new FrameOrthographicCamera(constrainViewVector(this.viewVector, boundingSphere.create(this.boundingBox)), this.lookAt, this.up, this.near, this.far, this.aspectRatio, this.fovHeight);
|
|
867
|
+
}
|
|
868
|
+
get viewVector() {
|
|
869
|
+
return Object.assign({}, this.orthographicData.viewVector);
|
|
870
|
+
}
|
|
871
|
+
get position() {
|
|
872
|
+
return vector3.add(this.lookAt, vector3.negate(this.viewVector));
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* A normalized vector representing the up direction.
|
|
876
|
+
*/
|
|
877
|
+
get up() {
|
|
878
|
+
return Object.assign({}, this.orthographicData.up);
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* A vector, in world space coordinates, of where the camera is pointed at.
|
|
882
|
+
*/
|
|
883
|
+
get lookAt() {
|
|
884
|
+
return Object.assign({}, this.orthographicData.lookAt);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* The camera's field of view.
|
|
888
|
+
*/
|
|
889
|
+
get fovHeight() {
|
|
890
|
+
return this.orthographicData.fovHeight;
|
|
809
891
|
}
|
|
810
892
|
/**
|
|
811
893
|
* The aspect ratio of the camera.
|
|
@@ -817,16 +899,19 @@ class Camera {
|
|
|
817
899
|
* The camera's near clipping plane.
|
|
818
900
|
*/
|
|
819
901
|
get near() {
|
|
820
|
-
const { near } = this.computeClippingPlanes(this.
|
|
902
|
+
const { near } = this.computeClippingPlanes(this.orthographicData);
|
|
821
903
|
return near;
|
|
822
904
|
}
|
|
823
905
|
/**
|
|
824
906
|
* The camera's far clipping plane.
|
|
825
907
|
*/
|
|
826
908
|
get far() {
|
|
827
|
-
const { far } = this.computeClippingPlanes(this.
|
|
909
|
+
const { far } = this.computeClippingPlanes(this.orthographicData);
|
|
828
910
|
return far;
|
|
829
911
|
}
|
|
912
|
+
updateFlyToOptions(flyToOptions) {
|
|
913
|
+
return new OrthographicCamera(this.stream, this.aspect, this.orthographicData, this.boundingBox, this.decodeFrame, flyToOptions);
|
|
914
|
+
}
|
|
830
915
|
}
|
|
831
916
|
|
|
832
917
|
/**
|
|
@@ -1233,12 +1318,25 @@ class Scene {
|
|
|
1233
1318
|
*/
|
|
1234
1319
|
camera() {
|
|
1235
1320
|
const { scene } = this.frame;
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1321
|
+
if (scene.camera.isOrthographic()) {
|
|
1322
|
+
return new OrthographicCamera(this.stream, dimensions.aspectRatio(this.viewport()), {
|
|
1323
|
+
viewVector: scene.camera.viewVector,
|
|
1324
|
+
lookAt: scene.camera.lookAt,
|
|
1325
|
+
up: scene.camera.up,
|
|
1326
|
+
fovHeight: scene.camera.fovHeight,
|
|
1327
|
+
}, this.frame.scene.boundingBox, this.decodeFrame);
|
|
1328
|
+
}
|
|
1329
|
+
else if (scene.camera.isPerspective()) {
|
|
1330
|
+
return new PerspectiveCamera(this.stream, dimensions.aspectRatio(this.viewport()), {
|
|
1331
|
+
position: scene.camera.position,
|
|
1332
|
+
lookAt: scene.camera.lookAt,
|
|
1333
|
+
up: scene.camera.up,
|
|
1334
|
+
fovY: scene.camera.fovY,
|
|
1335
|
+
}, this.frame.scene.boundingBox, this.decodeFrame);
|
|
1336
|
+
}
|
|
1337
|
+
else {
|
|
1338
|
+
throw new InvalidCameraError('Cannot retrieve camera. Scene has an unknown or invalid camera type.');
|
|
1339
|
+
}
|
|
1242
1340
|
}
|
|
1243
1341
|
boundingBox() {
|
|
1244
1342
|
return this.frame.scene.boundingBox;
|