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