@vertexvis/viewer 0.15.2-testing.2 → 0.15.2-testing.4
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/{config-6e330a82.js → config-4a86ae0b.js} +1 -1
- package/dist/cjs/{entities-7b2e8c03.js → entities-496b61cd.js} +2 -2
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mapper-0f2294a6.js → mapper-216603b0.js} +1 -1
- package/dist/cjs/{scene-56438693.js → scene-0ce59b26.js} +28 -1
- package/dist/cjs/{streamAttributes-c64aee75.js → streamAttributes-7725f5c4.js} +976 -4
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-box-query-tool.cjs.entry.js +245 -0
- package/dist/cjs/vertex-viewer-dom-element_2.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer.cjs.entry.js +3 -3
- package/dist/cjs/viewer.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.css +74 -0
- package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.js +191 -0
- package/dist/collection/lib/scenes/mapper.js +12 -1
- package/dist/collection/lib/scenes/queries.js +17 -1
- package/dist/collection/lib/volume-intersection/controller.js +48 -0
- package/dist/collection/lib/volume-intersection/interactions.js +37 -0
- package/dist/collection/lib/volume-intersection/model.js +67 -0
- package/dist/custom-elements/index.d.ts +6 -0
- package/dist/custom-elements/index.js +1241 -5
- package/dist/esm/{config-49688db8.js → config-6cdeb6ca.js} +1 -1
- package/dist/esm/{entities-a5bfef48.js → entities-6f3c5437.js} +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/{mapper-5894c2a4.js → mapper-941ff03c.js} +1 -1
- package/dist/esm/{scene-5b919078.js → scene-970f5000.js} +28 -1
- package/dist/esm/{streamAttributes-7e8565be.js → streamAttributes-24bd7b3a.js} +976 -4
- package/dist/esm/vertex-scene-tree.entry.js +2 -2
- package/dist/esm/vertex-viewer-box-query-tool.entry.js +241 -0
- package/dist/esm/vertex-viewer-dom-element_2.entry.js +1 -1
- package/dist/esm/vertex-viewer-measurement-details.entry.js +1 -1
- package/dist/esm/vertex-viewer-measurement-distance.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-line_2.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-precise.entry.js +4 -4
- package/dist/esm/vertex-viewer-pin-group.entry.js +2 -2
- package/dist/esm/vertex-viewer-transform-widget.entry.js +1 -1
- package/dist/esm/vertex-viewer-view-cube.entry.js +1 -1
- package/dist/esm/vertex-viewer.entry.js +3 -3
- package/dist/esm/viewer.js +1 -1
- package/dist/types/components/viewer-box-query-tool/viewer-box-query-tool.d.ts +60 -0
- package/dist/types/components.d.ts +48 -0
- package/dist/types/lib/scenes/queries.d.ts +14 -2
- package/dist/types/lib/volume-intersection/controller.d.ts +17 -0
- package/dist/types/lib/volume-intersection/interactions.d.ts +13 -0
- package/dist/types/lib/volume-intersection/model.d.ts +26 -0
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/{p-1e0dd2e9.js → p-10145045.js} +1 -1
- package/dist/viewer/{p-a6558bb2.entry.js → p-1bba9ade.entry.js} +1 -1
- package/dist/viewer/{p-3f6f2457.entry.js → p-24cda14a.entry.js} +1 -1
- package/dist/viewer/{p-b7e170ac.entry.js → p-2b58afc3.entry.js} +1 -1
- package/dist/viewer/{p-22ae6785.entry.js → p-51966cef.entry.js} +1 -1
- package/dist/viewer/{p-1fc24ec6.js → p-52ab9ec0.js} +1 -1
- package/dist/viewer/{p-927b528b.js → p-597cc9b5.js} +1 -1
- package/dist/viewer/{p-61e50e11.entry.js → p-608925c5.entry.js} +1 -1
- package/dist/viewer/p-68e192b9.js +4 -0
- package/dist/viewer/{p-d34ad2b2.entry.js → p-69a3fce8.entry.js} +1 -1
- package/dist/viewer/{p-7579e2a1.entry.js → p-74c772bb.entry.js} +1 -1
- package/dist/viewer/{p-40a9dd7d.js → p-9e1384c9.js} +1 -1
- package/dist/viewer/{p-d64c1e14.entry.js → p-a107b65e.entry.js} +2 -2
- package/dist/viewer/p-bb425931.entry.js +4 -0
- package/dist/viewer/{p-920c9a88.entry.js → p-bfacbaa8.entry.js} +1 -1
- package/dist/viewer/{p-f3ea0c2b.entry.js → p-c72da0fb.entry.js} +1 -1
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +8 -8
- package/dist/viewer/p-31b87b90.js +0 -4
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Point } from '@vertexvis/geometry';
|
|
2
|
+
import { SceneItemOperationsBuilder } from '../scenes';
|
|
3
|
+
import { VolumeIntersectionQueryModel } from './model';
|
|
4
|
+
export declare const DEFAULT_CONCURRENT_VOLUME_QUERY_LIMIT = 5;
|
|
5
|
+
export declare type OperationTransform = (builder: SceneItemOperationsBuilder) => SceneItemOperationsBuilder;
|
|
6
|
+
export declare class VolumeIntersectionQueryController {
|
|
7
|
+
private model;
|
|
8
|
+
private viewer;
|
|
9
|
+
private previousViewerCameraControls?;
|
|
10
|
+
private operationTransform;
|
|
11
|
+
private inFlightOperations;
|
|
12
|
+
constructor(model: VolumeIntersectionQueryModel, viewer: HTMLVertexViewerElement);
|
|
13
|
+
setStartPoint(point: Point.Point): void;
|
|
14
|
+
setEndPoint(point: Point.Point): void;
|
|
15
|
+
setOperationTransform(operationTransform: (builder: SceneItemOperationsBuilder) => SceneItemOperationsBuilder): void;
|
|
16
|
+
execute(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InteractionHandler } from '../interactions/interactionHandler';
|
|
2
|
+
import { VolumeIntersectionQueryController } from './controller';
|
|
3
|
+
export declare class VolumeIntersectionQueryInteractionHandler implements InteractionHandler {
|
|
4
|
+
private controller;
|
|
5
|
+
private element?;
|
|
6
|
+
private isInteracting?;
|
|
7
|
+
constructor(controller: VolumeIntersectionQueryController);
|
|
8
|
+
initialize(element: HTMLElement): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
private handleDragBegin;
|
|
11
|
+
private handleDrag;
|
|
12
|
+
private handleDragEnd;
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Point, Rectangle } from '@vertexvis/geometry';
|
|
2
|
+
import { Disposable, Listener } from '@vertexvis/utils';
|
|
3
|
+
export declare type QueryType = 'inclusive' | 'exclusive';
|
|
4
|
+
export interface VolumeIntersectionQueryDetails {
|
|
5
|
+
screenBounds: Rectangle.Rectangle;
|
|
6
|
+
type: QueryType;
|
|
7
|
+
}
|
|
8
|
+
export declare class VolumeIntersectionQueryModel {
|
|
9
|
+
private startPoint?;
|
|
10
|
+
private endPoint?;
|
|
11
|
+
private type?;
|
|
12
|
+
private dragStarted;
|
|
13
|
+
private dragComplete;
|
|
14
|
+
private screenBoundsChanged;
|
|
15
|
+
setStartPoint(point: Point.Point): void;
|
|
16
|
+
setEndPoint(point: Point.Point): void;
|
|
17
|
+
complete(): void;
|
|
18
|
+
reset(): void;
|
|
19
|
+
getScreenBounds(): Rectangle.Rectangle | undefined;
|
|
20
|
+
getType(): QueryType | undefined;
|
|
21
|
+
onScreenBoundsChanged(listener: Listener<VolumeIntersectionQueryDetails | undefined>): Disposable;
|
|
22
|
+
onDragStarted(listener: Listener<void>): Disposable;
|
|
23
|
+
onDragComplete(listener: Listener<VolumeIntersectionQueryDetails>): Disposable;
|
|
24
|
+
private getQueryDetails;
|
|
25
|
+
private updateQueryType;
|
|
26
|
+
}
|
package/dist/viewer/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**!
|
|
2
2
|
* Copyright (c) 2022 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
export{c as ColorMaterial,l as LoadableResource,S as Scene,a as SynchronizedClock}from"./p-
|
|
4
|
+
export{c as ColorMaterial,l as LoadableResource,S as Scene,a as SynchronizedClock}from"./p-10145045.js";export{C as CursorManager,l as labelPinCursor,m as measurementCursor,a as measurementWithArrowCursor,p as pinCursor}from"./p-3ca4a7c1.js";export{M as MeasurementController,a as MeasurementEntity}from"./p-9e1384c9.js";export{M as MeasurementModel}from"./p-661b5234.js";export{M as MeasurementOverlayManager}from"./p-7f6251da.js";export{m as makeMinimumDistanceResult}from"./p-096e60bd.js";export{A as AngleUnits,f as AreaUnits,D as DistanceUnits,F as FrameCameraBase,a as ReceivedFrame,b as ReceivedFrameImage,c as ReceivedFrameScene,d as ReceivedOrthographicCamera,e as ReceivedPerspectiveCamera}from"./p-68e192b9.js";export{E as EntityType}from"./p-df8fbe56.js";export{A as ArrowMarkup,C as CircleMarkup,F as FreeformMarkup}from"./p-0fcafbf9.js";export{V as Viewport}from"./p-29986489.js";import"./p-65af7a89.js";import"./p-70e5e8a8.js";import"./p-52ab9ec0.js";import"./p-dfe5a97d.js";import"./p-92fe4417.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**!
|
|
2
2
|
* Copyright (c) 2022 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{c as t,u as e,a as s,b as i}from"./p-65af7a89.js";import{v as r,b as n,a,m as o,q as h,r as u,p as c,d as l}from"./p-70e5e8a8.js";import{v as d,t as p,g as w,e as v,h as m,d as y,w as f,i as b}from"./p-31b87b90.js";import"./p-df8fbe56.js";const g={opacity:255,glossiness:4,diffuse:{r:0,g:0,b:0,a:0},ambient:{r:0,g:0,b:0,a:0},specular:{r:0,g:0,b:0,a:0},emissive:{r:0,g:0,b:0,a:0}},x=(e,s)=>{const i=t.fromHexString(e);return Object.assign(Object.assign({},g),{opacity:null!=s?s:g.opacity,diffuse:Object.assign({},null!=i?i:g.diffuse)})},O={opacity:g.opacity,glossiness:g.glossiness,diffuse:{r:255,g:255,b:0,a:0},ambient:{r:0,g:0,b:0,a:0},specular:{r:255,g:255,b:255,a:0},emissive:{r:0,g:0,b:0,a:0}},j=Object.freeze({__proto__:null,defaultColor:g,create:(t,e,s,i)=>Object.assign(Object.assign({},g),{opacity:null!=i?i:g.opacity,diffuse:{r:t,g:e,b:s,a:0}}),fromHex:x,defaultSelectionMaterial:O});class I extends Error{constructor(t,e){super(),this.message=t,this.stack=null==e?void 0:e.stack,this.name=this.constructor.name,Object.setPrototypeOf(this,I.prototype)}}class T extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,T.prototype)}}class k extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,k.prototype)}}class A extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,A.prototype)}}class S extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,S.prototype)}}class C extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,C.prototype)}}class V extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,V.prototype)}}class B extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,B.prototype)}}class M extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,M.prototype)}}class R extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,R.prototype)}}class D extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,D.prototype)}}function U(t){const s=e.parse(t);if("urn"!==s.scheme||null==s.path)throw new Error("Invalid URN. Expected URN scheme.");const[i,r,n]=s.path.split(":");if("vertexvis"!==i)throw new Error("Invalid URN. Expected URN to be vertexvis namespace");switch(r){case"stream-key":return{resource:{type:"stream-key",id:n},queries:(a=s.query,null!=a?a.split("&").map((t=>{const[e,s]=t.split("=");switch(e){case"scene-view-state":return{type:"scene-view-state",id:s};default:throw new Error("Invalid URN. Unknown query resource type")}})):[])};default:throw new T(`Invalid URN. Unknown resource type ${r}`)}var a}const E=Object.freeze({__proto__:null,fromUrn:U});class N{constructor(t,e=new Date){this.knownRemoteTime=t,this.knownLocalTime=e}localOffset(){return this.duration(this.knownLocalTime,this.localNow())}localTime(t){const e="number"==typeof t?new Date(this.knownLocalTime.getTime()+t):t,s=this.duration(this.knownRemoteTime,e);return this.addDuration(this.knownLocalTime,s)}remoteOffset(t=new Date){return this.duration(this.remoteTime(this.knownLocalTime),this.remoteTime(t))}remoteNow(){return this.remoteTime(this.localNow())}remoteTime(t){const e="number"==typeof t?new Date(this.knownLocalTime.getTime()+t):t,s=this.duration(this.knownLocalTime,e);return this.addDuration(this.knownRemoteTime,s)}addDuration(t,e){return new Date(t.getTime()+e)}duration(t,e){return e.getTime()-t.getTime()}localNow(){return new Date(Date.now())}}class _{constructor(t,e,s,i=1e4){this.stream=t,this.predicate=e,this.transform=s,this.timeout=i,this.listeners=[],this.handleMessage=this.handleMessage.bind(this)}on(t){this.listeners=[...this.listeners,t],null!=this.eventDisposable&&null!=this.requestDisposable||this.addListeners()}off(t){this.listeners=this.listeners.filter((e=>e!==t)),0===this.listeners.length&&this.removeListeners()}once(){let t;return s.timeout(this.timeout,new Promise((e=>{t=s=>{e(s),this.off(t)},this.on(t)}))).finally((()=>{this.off(t)}))}handleMessage(t){if(this.predicate(t)){const e=this.transform(t);null!=e&&this.listeners.forEach((t=>t(e)))}}addListeners(){this.eventDisposable=this.stream.onEvent(this.handleMessage),this.requestDisposable=this.stream.onRequest(this.handleMessage)}removeListeners(){var t,e;null===(t=this.eventDisposable)||void 0===t||t.dispose(),null===(e=this.requestDisposable)||void 0===e||e.dispose()}}class F{constructor(t,e,{animationId:s,correlationId:i},r){this.data=void 0,this.onAnimationCompleted=new _(t,(t=>{var e,i,r;return(null===(r=null===(i=null===(e=t.event)||void 0===e?void 0:e.animationCompleted)||void 0===i?void 0:i.animationId)||void 0===r?void 0:r.hex)===s}),(t=>{var e,s,i;return(null===(i=null===(s=null===(e=t.event)||void 0===e?void 0:e.animationCompleted)||void 0===s?void 0:s.animationId)||void 0===i?void 0:i.hex)||void 0}),r),this.onFrameReceived=new _(t,(t=>{var e,s,r;return!!(null===(r=null===(s=null===(e=t.request)||void 0===e?void 0:e.drawFrame)||void 0===s?void 0:s.frameCorrelationIds)||void 0===r?void 0:r.some((t=>t===i)))}),(t=>{var s;return null!=(null===(s=t.request)||void 0===s?void 0:s.drawFrame)?e(t.request.drawFrame):void 0}),r)}}function z(t){switch(t.type){case"item-id":return{id:new d.protobuf.core.Uuid({hex:t.value})};case"supplied-id":return{suppliedId:t.value};default:return{}}}class q{constructor(t){this.flyToOptions=t}build(){return this.flyToOptions}}class P{withItemId(t){return new q({flyTo:{type:"internal",data:t}})}withSuppliedId(t){return new q({flyTo:{type:"supplied",data:t}})}withCamera(t){return new q({flyTo:{type:"camera",data:t}})}withBoundingBox(t){return new q({flyTo:{type:"bounding-box",data:t}})}build(){return this.flyToOptions}}class H{constructor(t,e,s,i,r,n){this.stream=t,this.aspect=e,this.data=s,this.boundingBox=i,this.decodeFrame=r,this.flyToOptions=n}fitCameraToBoundingBox(t,e,s){const i=r.scale(e,r.normalize(s)),a=n.center(t),o=r.subtract(a,i);return this.update({lookAt:a,position:o,viewVector:i})}signedDistanceToBoundingBoxCenter(t){const{position:e,viewVector:s}=f(this.data),i=n.center(null!=t?t:this.boundingBox),a=r.subtract(i,e);return r.dot(s,a)/r.magnitude(s)}flyTo(t){return this.updateFlyToOptions("function"!=typeof t?{flyTo:this.buildFlyToType(t)}:t(new P).build())}viewAll(){return this.fitToBoundingBox(this.boundingBox)}async render(t){var e,s,r;null==this.flyToOptions&&null!=t&&(this.flyToOptions={flyTo:{type:"camera",data:this.data}});try{const n=i.create();if(null!=this.flyToOptions){const i=function(t,e,s){const i={frameCorrelationId:{value:t},animation:s?{duration:p(s.milliseconds)}:void 0};switch(e.flyTo.type){case"supplied":return Object.assign(Object.assign({},i),{itemSuppliedId:e.flyTo.data});case"internal":return Object.assign(Object.assign({},i),{itemId:new d.protobuf.core.Uuid({hex:e.flyTo.data})});case"camera":return Object.assign(Object.assign({},i),{camera:w(e.flyTo.data)});case"bounding-box":return Object.assign(Object.assign({},i),{boundingBox:{xmin:e.flyTo.data.min.x,xmax:e.flyTo.data.max.x,ymin:e.flyTo.data.min.y,ymax:e.flyTo.data.max.y,zmin:e.flyTo.data.min.z,zmax:e.flyTo.data.max.z}});default:return{}}}(n,this.flyToOptions,null==t?void 0:t.animation),a=await this.stream.flyTo(i,!0);return new F(this.stream,this.decodeFrame,{correlationId:n,animationId:(null===(s=null===(e=a.flyTo)||void 0===e?void 0:e.animationId)||void 0===s?void 0:s.hex)||void 0},null!=(null===(r=null==t?void 0:t.animation)||void 0===r?void 0:r.milliseconds)?t.animation.milliseconds+1e4:void 0)}return this.stream.replaceCamera({camera:w(this.data),frameCorrelationId:{value:n}}),new F(this.stream,this.decodeFrame,{correlationId:n})}catch(t){throw console.warn("Error when performing render: ",t),t}}rotateAroundAxis(t,e){return this.rotateAroundAxisAtPoint(t,this.data.lookAt,e)}alignTo(t,e){const s=r.normalize(r.cross(this.up,r.normalize(this.viewVector))),i=r.normalize(r.cross(r.normalize(this.viewVector),s)),n=r.angleTo(e,i)>Math.PI/2?r.negate(i):i,a=r.isEqual(n,e)?s:r.normalize(r.cross(n,e)),c=r.transformMatrix(this.viewVector,o.makeRotation(h.fromAxisAngle(a,r.angleTo(e,n)))),l=u.create({origin:t,direction:r.normalize(c)}),d=u.at(l,r.magnitude(this.viewVector));return this.update({position:t,lookAt:d,up:e})}standardView(t){return this.update({position:t.position,viewVector:r.subtract(r.origin(),t.position),lookAt:r.origin(),up:t.up})}buildFlyToType(t){if(null!=t.boundingBox)return{type:"bounding-box",data:t.boundingBox};if(null!=t.camera)return{type:"camera",data:t.camera};if(null!=t.itemId)return{type:"internal",data:t.itemId};if(null!=t.itemSuppliedId)return{type:"supplied",data:t.itemSuppliedId};throw new Error("Fly to must specify at least one option.")}computeClippingPlanes(t){return b(this.boundingBox,t)}}class L extends H{constructor(t,e,s,i,r,n){super(t,e,s,i,r,n),this.perspectiveData=s}moveBy(t){return this.update({position:r.add(this.position,t),lookAt:r.add(this.lookAt,t)})}rotateAroundAxisAtPoint(t,e,s){return this.update({position:r.rotateAboutAxis(t,this.position,s,e),lookAt:r.rotateAboutAxis(t,this.lookAt,s,e),up:r.rotateAboutAxis(t,this.up,s,r.origin())})}fitToBoundingBox(t){var e;const s=1.1*r.magnitude(r.subtract(t.max,n.center(t)));let i=Math.tan(.008726646259972*(null!==(e=this.fovY)&&void 0!==e?e:45));this.aspect<1&&(i*=this.aspect);const a=Math.abs(s/i);return super.fitCameraToBoundingBox(t,a,this.viewVector)}update(t){return new L(this.stream,this.aspect,Object.assign(Object.assign({},this.perspectiveData),t),this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){var t;return new v(this.position,this.lookAt,this.up,this.near,this.far,this.aspectRatio,null!==(t=this.fovY)&&void 0!==t?t:45)}get viewVector(){return r.subtract(this.lookAt,this.position)}get position(){return Object.assign({},this.perspectiveData.position)}get up(){return Object.assign({},this.perspectiveData.up)}get lookAt(){return Object.assign({},this.perspectiveData.lookAt)}get fovY(){return this.perspectiveData.fovY}get aspectRatio(){return this.aspect}get near(){const{near:t}=this.computeClippingPlanes(this.perspectiveData);return t}get far(){const{far:t}=this.computeClippingPlanes(this.perspectiveData);return t}updateFlyToOptions(t){return new L(this.stream,this.aspect,this.perspectiveData,this.boundingBox,this.decodeFrame,t)}}class Q extends H{constructor(t,e,s,i,r,n){super(t,e,s,i,r,n),this.orthographicData=s}moveBy(t){return this.update({lookAt:r.add(this.lookAt,t)})}rotateAroundAxisAtPoint(t,e,s){const i=r.rotateAboutAxis(t,this.lookAt,s,e),n=r.rotateAboutAxis(t,this.position,s,e),o=m(r.subtract(i,n),a.create(this.boundingBox));return this.update({viewVector:o,lookAt:i,up:r.rotateAboutAxis(t,this.up,s,r.origin())})}fitToBoundingBox(t){const e=a.create(t),s=super.fitCameraToBoundingBox(t,e.radius,this.viewVector);return this.update({lookAt:s.lookAt,viewVector:s.viewVector,fovHeight:2*e.radius})}update(t){return new Q(this.stream,this.aspect,Object.assign(Object.assign({},this.orthographicData),t),this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){return new y(m(this.viewVector,a.create(this.boundingBox)),this.lookAt,this.up,this.near,this.far,this.aspectRatio,this.fovHeight)}get viewVector(){return Object.assign({},this.orthographicData.viewVector)}get position(){return r.add(this.lookAt,r.negate(this.viewVector))}get up(){return Object.assign({},this.orthographicData.up)}get lookAt(){return Object.assign({},this.orthographicData.lookAt)}get fovHeight(){return this.orthographicData.fovHeight}get aspectRatio(){return this.aspect}get near(){const{near:t}=this.computeClippingPlanes(this.orthographicData);return t}get far(){const{far:t}=this.computeClippingPlanes(this.orthographicData);return t}updateFlyToOptions(t){return new Q(this.stream,this.aspect,this.orthographicData,this.boundingBox,this.decodeFrame,t)}}class Y{constructor(t,e){this.stream=t,this.imageScaleProvider=e}async hitItems(t,e){const s=this.imageScaleProvider();return(await this.stream.hitItems({point:c.scale(t,(null==s?void 0:s.x)||1,(null==s?void 0:s.y)||1),includeMetadata:null==e?void 0:e.includeMetadata},!0)).hitItems||void 0}}class W{constructor(t,e){this.stream=t,this.data=e}async update(t){return(await this.stream.updateCrossSectioning({crossSectioning:t},!0)).updateCrossSectioning||void 0}current(){return this.data}}class ${constructor(t=[]){this.operations=t}build(){return this.operations.concat()}materialOverride(t){return new $(this.operations.concat([{type:"change-material",material:t}]))}show(){return new $(this.operations.concat([{type:"show"}]))}hide(){return new $(this.operations.concat([{type:"hide"}]))}select(t){return new $(this.operations.concat([{type:"select",material:t}]))}deselect(){return new $(this.operations.concat([{type:"deselect"}]))}clearMaterialOverrides(){return new $(this.operations.concat([{type:"clear-override"}]))}transform(t){return new $(this.operations.concat([{type:"change-transform",transform:t}]))}clearTransforms(t=!0){return new $(this.operations.concat([{type:"clear-transform",cascade:t}]))}}class G{all(){return new J}withItemIds(t){return new et(t,"item-id")}withSuppliedIds(t){return new et(t,"supplied-id")}withItemId(t){return new st({type:"item-id",value:t})}withSuppliedId(t){return new st({type:"supplied-id",value:t})}withSceneTreeRange(t){return new K(t)}withMetadata(t,e,s){return new X(t,e,s)}withSelected(){return new Z}withPoint(t){return new tt(t)}}class J{build(){return{type:"all"}}}class K{constructor(t){this.range=t}build(){return{type:"scene-tree-range",range:this.range}}}class X{constructor(t,e,s){this.filter=t,this.keys=e,this.exactMatch=s}build(){return{type:"metadata",filter:this.filter,keys:this.keys,exactMatch:this.exactMatch}}}class Z{build(){return{type:"all-selected"}}}class tt{constructor(t){this.point=t}build(){return{type:"point",point:this.point}}}class et{constructor(t,e){this.ids=t,this.type=e}build(){return{type:"or",expressions:this.ids.map((t=>({type:this.type,value:t})))}}}class st{constructor(t){this.query=t}build(){return Object.assign({},this.query)}and(){return new rt([this.query])}or(){return new it([this.query])}}class it{constructor(t){this.expressions=t}build(){return{type:"or",expressions:[...this.expressions]}}withItemId(t){return new it([...this.expressions,{type:"item-id",value:t}])}withSuppliedId(t){return new it([...this.expressions,{type:"supplied-id",value:t}])}or(){return this}}class rt{constructor(t){this.expressions=t}build(){return{type:"and",expressions:[...this.expressions]}}withItemId(t){return new rt([...this.expressions,{type:"item-id",value:t}])}withSuppliedId(t){return new rt([...this.expressions,{type:"supplied-id",value:t}])}and(){return this}}class nt{constructor(t){this.defaultSelectionMaterial=t}where(t){const e=t(new G).build();return new at(e,this.defaultSelectionMaterial)}}class at{constructor(t,e,s){this.query=t,this.defaultSelectionMaterial=e,this.builder=null!=s?s:new $}materialOverride(t){return new at(this.query,this.defaultSelectionMaterial,this.builder.materialOverride("string"==typeof t?x(t):t))}hide(){return new at(this.query,this.defaultSelectionMaterial,this.builder.hide())}show(){return new at(this.query,this.defaultSelectionMaterial,this.builder.show())}select(t){return new at(this.query,this.defaultSelectionMaterial,this.builder.select("string"==typeof t?x(t):t||this.defaultSelectionMaterial))}deselect(){return new at(this.query,this.defaultSelectionMaterial,this.builder.deselect())}clearMaterialOverrides(){return new at(this.query,this.defaultSelectionMaterial,this.builder.clearMaterialOverrides())}transform(t){if(Array.isArray(t)){if(16!==t.length)throw new R("Matrix provided must contain exactly 16 values (4x4).");return new at(this.query,this.defaultSelectionMaterial,this.builder.transform({r0:{x:t[0],y:t[1],z:t[2],w:t[3]},r1:{x:t[4],y:t[5],z:t[6],w:t[7]},r2:{x:t[8],y:t[9],z:t[10],w:t[11]},r3:{x:t[12],y:t[13],z:t[14],w:t[15]}}))}return new at(this.query,this.defaultSelectionMaterial,this.builder.transform(t))}clearTransforms(t=!0){return new at(this.query,this.defaultSelectionMaterial,this.builder.clearTransforms(t))}build(){return{query:this.query,operations:this.builder.build()}}}class ot{constructor(t,e,s,i){this.sceneViewId=t,this.stream=e,this.dimensions=s,this.queryOperations=i}async execute(t){const e=this.queryOperations.map((t=>function(t,e,s){const i=function(t){return t.map((t=>{switch(t.type){case"change-material":return{changeMaterial:{material:{d:t.material.opacity,ns:t.material.glossiness,ka:t.material.ambient,kd:t.material.diffuse,ks:t.material.specular,ke:t.material.emissive}}};case"clear-override":return{changeMaterial:{}};case"change-transform":return{changeTransform:{transform:Object.assign({},t.transform)}};case"clear-transform":return{clearTransform:{cascade:t.cascade}};case"hide":return{changeVisibility:{visible:!1}};case"show":return{changeVisibility:{visible:!0}};case"select":return{changeSelection:{material:{d:t.material.opacity,ns:t.material.glossiness,ka:t.material.ambient,kd:t.material.diffuse,ks:t.material.specular,ke:t.material.emissive}}};case"deselect":return{changeSelection:{}};default:return{}}}))}(e);switch(t.type){case"and":case"or":return{[t.type]:{queries:t.expressions.map((t=>({sceneItemQuery:z(t)})))},operationTypes:i};case"item-id":case"supplied-id":return{item:{sceneItemQuery:z(t)},operationTypes:i};case"all":return{all:{},operationTypes:i};case"scene-tree-range":return{sceneTreeRange:{start:t.range.start,end:t.range.end},operationTypes:i};case"metadata":return{metadata:{valueFilter:t.filter,keys:t.keys,exactMatch:t.exactMatch},operationTypes:i};case"all-selected":return{override:{selection:{}},operationTypes:i};case"point":return{point:{point:t.point,viewport:s.dimensions},operationTypes:i};default:return{}}}(t.query,t.operations,{dimensions:this.dimensions}))),s={sceneViewId:{hex:this.sceneViewId},operations:e,suppliedCorrelationId:null!=(null==t?void 0:t.suppliedCorrelationId)?{value:null==t?void 0:t.suppliedCorrelationId}:void 0};await this.stream.createSceneAlteration(s)}}class ht{constructor(t,e,s,i,r,n,a,o){this.stream=t,this.frame=e,this.decodeFrame=s,this.imageScaleProvider=i,this.dimensions=r,this.sceneId=n,this.sceneViewId=a,this.defaultSelectionMaterial=o}async applySceneViewState(t,e={}){return await this.stream.loadSceneViewState({sceneViewStateId:{hex:t},frameCorrelationId:e.suppliedCorrelationId?{value:e.suppliedCorrelationId}:void 0},!0)}async reset(t={}){return await this.stream.resetSceneView({includeCamera:t.includeCamera,frameCorrelationId:t.suppliedCorrelationId?{value:t.suppliedCorrelationId}:void 0},!0)}items(t){const e=t(new nt(this.defaultSelectionMaterial)),s=(Array.isArray(e)?e:[e]).reduce(((t,e)=>t.concat(e.build())),[]);return new ot(this.sceneViewId,this.stream,this.dimensions,s)}camera(){const{scene:t}=this.frame;if(t.camera.isOrthographic())return new Q(this.stream,l.aspectRatio(this.viewport()),{viewVector:t.camera.viewVector,lookAt:t.camera.lookAt,up:t.camera.up,fovHeight:t.camera.fovHeight},this.frame.scene.boundingBox,this.decodeFrame);if(t.camera.isPerspective())return new L(this.stream,l.aspectRatio(this.viewport()),{position:t.camera.position,lookAt:t.camera.lookAt,up:t.camera.up,fovY:t.camera.fovY},this.frame.scene.boundingBox,this.decodeFrame);throw new D("Cannot retrieve camera. Scene has an unknown or invalid camera type.")}boundingBox(){return this.frame.scene.boundingBox}crossSectioning(){return new W(this.stream,this.frame.scene.crossSection)}raycaster(){return new Y(this.stream,this.imageScaleProvider)}viewport(){return this.frame.dimensions}scale(){return this.imageScaleProvider()||c.create(1,1)}}export{I as C,B as I,ht as S,k as V,C as W,N as a,S as b,j as c,O as d,V as e,U as f,A as g,M as h,x as i,E as l}
|
|
4
|
+
import{c as t,u as e,a as s,b as i}from"./p-65af7a89.js";import{v as r,b as n,a,m as o,q as h,r as u,p as c,d as l}from"./p-70e5e8a8.js";import{v as d,t as p,g as w,e as v,h as m,d as y,w as f,i as b}from"./p-68e192b9.js";import"./p-df8fbe56.js";const g={opacity:255,glossiness:4,diffuse:{r:0,g:0,b:0,a:0},ambient:{r:0,g:0,b:0,a:0},specular:{r:0,g:0,b:0,a:0},emissive:{r:0,g:0,b:0,a:0}},x=(e,s)=>{const i=t.fromHexString(e);return Object.assign(Object.assign({},g),{opacity:null!=s?s:g.opacity,diffuse:Object.assign({},null!=i?i:g.diffuse)})},O={opacity:g.opacity,glossiness:g.glossiness,diffuse:{r:255,g:255,b:0,a:0},ambient:{r:0,g:0,b:0,a:0},specular:{r:255,g:255,b:255,a:0},emissive:{r:0,g:0,b:0,a:0}},j=Object.freeze({__proto__:null,defaultColor:g,create:(t,e,s,i)=>Object.assign(Object.assign({},g),{opacity:null!=i?i:g.opacity,diffuse:{r:t,g:e,b:s,a:0}}),fromHex:x,defaultSelectionMaterial:O});class I extends Error{constructor(t,e){super(),this.message=t,this.stack=null==e?void 0:e.stack,this.name=this.constructor.name,Object.setPrototypeOf(this,I.prototype)}}class T extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,T.prototype)}}class k extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,k.prototype)}}class A extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,A.prototype)}}class S extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,S.prototype)}}class V extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,V.prototype)}}class B extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,B.prototype)}}class C extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,C.prototype)}}class M extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,M.prototype)}}class R extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,R.prototype)}}class D extends I{constructor(t,e){super(t,e),Object.setPrototypeOf(this,D.prototype)}}function U(t){const s=e.parse(t);if("urn"!==s.scheme||null==s.path)throw new Error("Invalid URN. Expected URN scheme.");const[i,r,n]=s.path.split(":");if("vertexvis"!==i)throw new Error("Invalid URN. Expected URN to be vertexvis namespace");switch(r){case"stream-key":return{resource:{type:"stream-key",id:n},queries:(a=s.query,null!=a?a.split("&").map((t=>{const[e,s]=t.split("=");switch(e){case"scene-view-state":return{type:"scene-view-state",id:s};default:throw new Error("Invalid URN. Unknown query resource type")}})):[])};default:throw new T(`Invalid URN. Unknown resource type ${r}`)}var a}const E=Object.freeze({__proto__:null,fromUrn:U});class N{constructor(t,e=new Date){this.knownRemoteTime=t,this.knownLocalTime=e}localOffset(){return this.duration(this.knownLocalTime,this.localNow())}localTime(t){const e="number"==typeof t?new Date(this.knownLocalTime.getTime()+t):t,s=this.duration(this.knownRemoteTime,e);return this.addDuration(this.knownLocalTime,s)}remoteOffset(t=new Date){return this.duration(this.remoteTime(this.knownLocalTime),this.remoteTime(t))}remoteNow(){return this.remoteTime(this.localNow())}remoteTime(t){const e="number"==typeof t?new Date(this.knownLocalTime.getTime()+t):t,s=this.duration(this.knownLocalTime,e);return this.addDuration(this.knownRemoteTime,s)}addDuration(t,e){return new Date(t.getTime()+e)}duration(t,e){return e.getTime()-t.getTime()}localNow(){return new Date(Date.now())}}class _{constructor(t,e,s,i=1e4){this.stream=t,this.predicate=e,this.transform=s,this.timeout=i,this.listeners=[],this.handleMessage=this.handleMessage.bind(this)}on(t){this.listeners=[...this.listeners,t],null!=this.eventDisposable&&null!=this.requestDisposable||this.addListeners()}off(t){this.listeners=this.listeners.filter((e=>e!==t)),0===this.listeners.length&&this.removeListeners()}once(){let t;return s.timeout(this.timeout,new Promise((e=>{t=s=>{e(s),this.off(t)},this.on(t)}))).finally((()=>{this.off(t)}))}handleMessage(t){if(this.predicate(t)){const e=this.transform(t);null!=e&&this.listeners.forEach((t=>t(e)))}}addListeners(){this.eventDisposable=this.stream.onEvent(this.handleMessage),this.requestDisposable=this.stream.onRequest(this.handleMessage)}removeListeners(){var t,e;null===(t=this.eventDisposable)||void 0===t||t.dispose(),null===(e=this.requestDisposable)||void 0===e||e.dispose()}}class F{constructor(t,e,{animationId:s,correlationId:i},r){this.data=void 0,this.onAnimationCompleted=new _(t,(t=>{var e,i,r;return(null===(r=null===(i=null===(e=t.event)||void 0===e?void 0:e.animationCompleted)||void 0===i?void 0:i.animationId)||void 0===r?void 0:r.hex)===s}),(t=>{var e,s,i;return(null===(i=null===(s=null===(e=t.event)||void 0===e?void 0:e.animationCompleted)||void 0===s?void 0:s.animationId)||void 0===i?void 0:i.hex)||void 0}),r),this.onFrameReceived=new _(t,(t=>{var e,s,r;return!!(null===(r=null===(s=null===(e=t.request)||void 0===e?void 0:e.drawFrame)||void 0===s?void 0:s.frameCorrelationIds)||void 0===r?void 0:r.some((t=>t===i)))}),(t=>{var s;return null!=(null===(s=t.request)||void 0===s?void 0:s.drawFrame)?e(t.request.drawFrame):void 0}),r)}}function z(t){switch(t.type){case"item-id":return{id:new d.protobuf.core.Uuid({hex:t.value})};case"supplied-id":return{suppliedId:t.value};default:return{}}}class q{constructor(t){this.flyToOptions=t}build(){return this.flyToOptions}}class P{withItemId(t){return new q({flyTo:{type:"internal",data:t}})}withSuppliedId(t){return new q({flyTo:{type:"supplied",data:t}})}withCamera(t){return new q({flyTo:{type:"camera",data:t}})}withBoundingBox(t){return new q({flyTo:{type:"bounding-box",data:t}})}build(){return this.flyToOptions}}class H{constructor(t,e,s,i,r,n){this.stream=t,this.aspect=e,this.data=s,this.boundingBox=i,this.decodeFrame=r,this.flyToOptions=n}fitCameraToBoundingBox(t,e,s){const i=r.scale(e,r.normalize(s)),a=n.center(t),o=r.subtract(a,i);return this.update({lookAt:a,position:o,viewVector:i})}signedDistanceToBoundingBoxCenter(t){const{position:e,viewVector:s}=f(this.data),i=n.center(null!=t?t:this.boundingBox),a=r.subtract(i,e);return r.dot(s,a)/r.magnitude(s)}flyTo(t){return this.updateFlyToOptions("function"!=typeof t?{flyTo:this.buildFlyToType(t)}:t(new P).build())}viewAll(){return this.fitToBoundingBox(this.boundingBox)}async render(t){var e,s,r;null==this.flyToOptions&&null!=t&&(this.flyToOptions={flyTo:{type:"camera",data:this.data}});try{const n=i.create();if(null!=this.flyToOptions){const i=function(t,e,s){const i={frameCorrelationId:{value:t},animation:s?{duration:p(s.milliseconds)}:void 0};switch(e.flyTo.type){case"supplied":return Object.assign(Object.assign({},i),{itemSuppliedId:e.flyTo.data});case"internal":return Object.assign(Object.assign({},i),{itemId:new d.protobuf.core.Uuid({hex:e.flyTo.data})});case"camera":return Object.assign(Object.assign({},i),{camera:w(e.flyTo.data)});case"bounding-box":return Object.assign(Object.assign({},i),{boundingBox:{xmin:e.flyTo.data.min.x,xmax:e.flyTo.data.max.x,ymin:e.flyTo.data.min.y,ymax:e.flyTo.data.max.y,zmin:e.flyTo.data.min.z,zmax:e.flyTo.data.max.z}});default:return{}}}(n,this.flyToOptions,null==t?void 0:t.animation),a=await this.stream.flyTo(i,!0);return new F(this.stream,this.decodeFrame,{correlationId:n,animationId:(null===(s=null===(e=a.flyTo)||void 0===e?void 0:e.animationId)||void 0===s?void 0:s.hex)||void 0},null!=(null===(r=null==t?void 0:t.animation)||void 0===r?void 0:r.milliseconds)?t.animation.milliseconds+1e4:void 0)}return this.stream.replaceCamera({camera:w(this.data),frameCorrelationId:{value:n}}),new F(this.stream,this.decodeFrame,{correlationId:n})}catch(t){throw console.warn("Error when performing render: ",t),t}}rotateAroundAxis(t,e){return this.rotateAroundAxisAtPoint(t,this.data.lookAt,e)}alignTo(t,e){const s=r.normalize(r.cross(this.up,r.normalize(this.viewVector))),i=r.normalize(r.cross(r.normalize(this.viewVector),s)),n=r.angleTo(e,i)>Math.PI/2?r.negate(i):i,a=r.isEqual(n,e)?s:r.normalize(r.cross(n,e)),c=r.transformMatrix(this.viewVector,o.makeRotation(h.fromAxisAngle(a,r.angleTo(e,n)))),l=u.create({origin:t,direction:r.normalize(c)}),d=u.at(l,r.magnitude(this.viewVector));return this.update({position:t,lookAt:d,up:e})}standardView(t){return this.update({position:t.position,viewVector:r.subtract(r.origin(),t.position),lookAt:r.origin(),up:t.up})}buildFlyToType(t){if(null!=t.boundingBox)return{type:"bounding-box",data:t.boundingBox};if(null!=t.camera)return{type:"camera",data:t.camera};if(null!=t.itemId)return{type:"internal",data:t.itemId};if(null!=t.itemSuppliedId)return{type:"supplied",data:t.itemSuppliedId};throw new Error("Fly to must specify at least one option.")}computeClippingPlanes(t){return b(this.boundingBox,t)}}class L extends H{constructor(t,e,s,i,r,n){super(t,e,s,i,r,n),this.perspectiveData=s}moveBy(t){return this.update({position:r.add(this.position,t),lookAt:r.add(this.lookAt,t)})}rotateAroundAxisAtPoint(t,e,s){return this.update({position:r.rotateAboutAxis(t,this.position,s,e),lookAt:r.rotateAboutAxis(t,this.lookAt,s,e),up:r.rotateAboutAxis(t,this.up,s,r.origin())})}fitToBoundingBox(t){var e;const s=1.1*r.magnitude(r.subtract(t.max,n.center(t)));let i=Math.tan(.008726646259972*(null!==(e=this.fovY)&&void 0!==e?e:45));this.aspect<1&&(i*=this.aspect);const a=Math.abs(s/i);return super.fitCameraToBoundingBox(t,a,this.viewVector)}update(t){return new L(this.stream,this.aspect,Object.assign(Object.assign({},this.perspectiveData),t),this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){var t;return new v(this.position,this.lookAt,this.up,this.near,this.far,this.aspectRatio,null!==(t=this.fovY)&&void 0!==t?t:45)}get viewVector(){return r.subtract(this.lookAt,this.position)}get position(){return Object.assign({},this.perspectiveData.position)}get up(){return Object.assign({},this.perspectiveData.up)}get lookAt(){return Object.assign({},this.perspectiveData.lookAt)}get fovY(){return this.perspectiveData.fovY}get aspectRatio(){return this.aspect}get near(){const{near:t}=this.computeClippingPlanes(this.perspectiveData);return t}get far(){const{far:t}=this.computeClippingPlanes(this.perspectiveData);return t}updateFlyToOptions(t){return new L(this.stream,this.aspect,this.perspectiveData,this.boundingBox,this.decodeFrame,t)}}class Q extends H{constructor(t,e,s,i,r,n){super(t,e,s,i,r,n),this.orthographicData=s}moveBy(t){return this.update({lookAt:r.add(this.lookAt,t)})}rotateAroundAxisAtPoint(t,e,s){const i=r.rotateAboutAxis(t,this.lookAt,s,e),n=r.rotateAboutAxis(t,this.position,s,e),o=m(r.subtract(i,n),a.create(this.boundingBox));return this.update({viewVector:o,lookAt:i,up:r.rotateAboutAxis(t,this.up,s,r.origin())})}fitToBoundingBox(t){const e=a.create(t),s=super.fitCameraToBoundingBox(t,e.radius,this.viewVector);return this.update({lookAt:s.lookAt,viewVector:s.viewVector,fovHeight:2*e.radius})}update(t){return new Q(this.stream,this.aspect,Object.assign(Object.assign({},this.orthographicData),t),this.boundingBox,this.decodeFrame,this.flyToOptions)}toFrameCamera(){return new y(m(this.viewVector,a.create(this.boundingBox)),this.lookAt,this.up,this.near,this.far,this.aspectRatio,this.fovHeight)}get viewVector(){return Object.assign({},this.orthographicData.viewVector)}get position(){return r.add(this.lookAt,r.negate(this.viewVector))}get up(){return Object.assign({},this.orthographicData.up)}get lookAt(){return Object.assign({},this.orthographicData.lookAt)}get fovHeight(){return this.orthographicData.fovHeight}get aspectRatio(){return this.aspect}get near(){const{near:t}=this.computeClippingPlanes(this.orthographicData);return t}get far(){const{far:t}=this.computeClippingPlanes(this.orthographicData);return t}updateFlyToOptions(t){return new Q(this.stream,this.aspect,this.orthographicData,this.boundingBox,this.decodeFrame,t)}}class Y{constructor(t,e){this.stream=t,this.imageScaleProvider=e}async hitItems(t,e){const s=this.imageScaleProvider();return(await this.stream.hitItems({point:c.scale(t,(null==s?void 0:s.x)||1,(null==s?void 0:s.y)||1),includeMetadata:null==e?void 0:e.includeMetadata},!0)).hitItems||void 0}}class W{constructor(t,e){this.stream=t,this.data=e}async update(t){return(await this.stream.updateCrossSectioning({crossSectioning:t},!0)).updateCrossSectioning||void 0}current(){return this.data}}class ${constructor(t=[]){this.operations=t}build(){return this.operations.concat()}materialOverride(t){return new $(this.operations.concat([{type:"change-material",material:t}]))}show(){return new $(this.operations.concat([{type:"show"}]))}hide(){return new $(this.operations.concat([{type:"hide"}]))}select(t){return new $(this.operations.concat([{type:"select",material:t}]))}deselect(){return new $(this.operations.concat([{type:"deselect"}]))}clearMaterialOverrides(){return new $(this.operations.concat([{type:"clear-override"}]))}transform(t){return new $(this.operations.concat([{type:"change-transform",transform:t}]))}clearTransforms(t=!0){return new $(this.operations.concat([{type:"clear-transform",cascade:t}]))}}class G{all(){return new J}withItemIds(t){return new st(t,"item-id")}withSuppliedIds(t){return new st(t,"supplied-id")}withItemId(t){return new it({type:"item-id",value:t})}withSuppliedId(t){return new it({type:"supplied-id",value:t})}withSceneTreeRange(t){return new K(t)}withMetadata(t,e,s){return new X(t,e,s)}withSelected(){return new Z}withPoint(t){return new tt(t)}withVolumeIntersection(t,e){return new et(t,e)}}class J{build(){return{type:"all"}}}class K{constructor(t){this.range=t}build(){return{type:"scene-tree-range",range:this.range}}}class X{constructor(t,e,s){this.filter=t,this.keys=e,this.exactMatch=s}build(){return{type:"metadata",filter:this.filter,keys:this.keys,exactMatch:this.exactMatch}}}class Z{build(){return{type:"all-selected"}}}class tt{constructor(t){this.point=t}build(){return{type:"point",point:this.point}}}class et{constructor(t,e){this.rectangle=t,this.exclusive=e}build(){return{type:"volume-intersection",rectangle:this.rectangle,exclusive:!!this.exclusive}}}class st{constructor(t,e){this.ids=t,this.type=e}build(){return{type:"or",expressions:this.ids.map((t=>({type:this.type,value:t})))}}}class it{constructor(t){this.query=t}build(){return Object.assign({},this.query)}and(){return new nt([this.query])}or(){return new rt([this.query])}}class rt{constructor(t){this.expressions=t}build(){return{type:"or",expressions:[...this.expressions]}}withItemId(t){return new rt([...this.expressions,{type:"item-id",value:t}])}withSuppliedId(t){return new rt([...this.expressions,{type:"supplied-id",value:t}])}or(){return this}}class nt{constructor(t){this.expressions=t}build(){return{type:"and",expressions:[...this.expressions]}}withItemId(t){return new nt([...this.expressions,{type:"item-id",value:t}])}withSuppliedId(t){return new nt([...this.expressions,{type:"supplied-id",value:t}])}and(){return this}}class at{constructor(t){this.defaultSelectionMaterial=t}where(t){const e=t(new G).build();return new ot(e,this.defaultSelectionMaterial)}}class ot{constructor(t,e,s){this.query=t,this.defaultSelectionMaterial=e,this.builder=null!=s?s:new $}materialOverride(t){return new ot(this.query,this.defaultSelectionMaterial,this.builder.materialOverride("string"==typeof t?x(t):t))}hide(){return new ot(this.query,this.defaultSelectionMaterial,this.builder.hide())}show(){return new ot(this.query,this.defaultSelectionMaterial,this.builder.show())}select(t){return new ot(this.query,this.defaultSelectionMaterial,this.builder.select("string"==typeof t?x(t):t||this.defaultSelectionMaterial))}deselect(){return new ot(this.query,this.defaultSelectionMaterial,this.builder.deselect())}clearMaterialOverrides(){return new ot(this.query,this.defaultSelectionMaterial,this.builder.clearMaterialOverrides())}transform(t){if(Array.isArray(t)){if(16!==t.length)throw new R("Matrix provided must contain exactly 16 values (4x4).");return new ot(this.query,this.defaultSelectionMaterial,this.builder.transform({r0:{x:t[0],y:t[1],z:t[2],w:t[3]},r1:{x:t[4],y:t[5],z:t[6],w:t[7]},r2:{x:t[8],y:t[9],z:t[10],w:t[11]},r3:{x:t[12],y:t[13],z:t[14],w:t[15]}}))}return new ot(this.query,this.defaultSelectionMaterial,this.builder.transform(t))}clearTransforms(t=!0){return new ot(this.query,this.defaultSelectionMaterial,this.builder.clearTransforms(t))}build(){return{query:this.query,operations:this.builder.build()}}}class ht{constructor(t,e,s,i){this.sceneViewId=t,this.stream=e,this.dimensions=s,this.queryOperations=i}async execute(t){const e=this.queryOperations.map((t=>function(t,e,s){const i=function(t){return t.map((t=>{switch(t.type){case"change-material":return{changeMaterial:{material:{d:t.material.opacity,ns:t.material.glossiness,ka:t.material.ambient,kd:t.material.diffuse,ks:t.material.specular,ke:t.material.emissive}}};case"clear-override":return{changeMaterial:{}};case"change-transform":return{changeTransform:{transform:Object.assign({},t.transform)}};case"clear-transform":return{clearTransform:{cascade:t.cascade}};case"hide":return{changeVisibility:{visible:!1}};case"show":return{changeVisibility:{visible:!0}};case"select":return{changeSelection:{material:{d:t.material.opacity,ns:t.material.glossiness,ka:t.material.ambient,kd:t.material.diffuse,ks:t.material.specular,ke:t.material.emissive}}};case"deselect":return{changeSelection:{}};default:return{}}}))}(e);switch(t.type){case"and":case"or":return{[t.type]:{queries:t.expressions.map((t=>({sceneItemQuery:z(t)})))},operationTypes:i};case"item-id":case"supplied-id":return{item:{sceneItemQuery:z(t)},operationTypes:i};case"all":return{all:{},operationTypes:i};case"scene-tree-range":return{sceneTreeRange:{start:t.range.start,end:t.range.end},operationTypes:i};case"metadata":return{metadata:{valueFilter:t.filter,keys:t.keys,exactMatch:t.exactMatch},operationTypes:i};case"all-selected":return{override:{selection:{}},operationTypes:i};case"point":return{point:{point:t.point,viewport:s.dimensions},operationTypes:i};case"volume-intersection":return{volume:{frustumByRectangle:{rectangle:t.rectangle},exclusive:t.exclusive,viewport:s.dimensions},operationTypes:i};default:return{}}}(t.query,t.operations,{dimensions:this.dimensions}))),s={sceneViewId:{hex:this.sceneViewId},operations:e,suppliedCorrelationId:null!=(null==t?void 0:t.suppliedCorrelationId)?{value:null==t?void 0:t.suppliedCorrelationId}:void 0};await this.stream.createSceneAlteration(s)}}class ut{constructor(t,e,s,i,r,n,a,o){this.stream=t,this.frame=e,this.decodeFrame=s,this.imageScaleProvider=i,this.dimensions=r,this.sceneId=n,this.sceneViewId=a,this.defaultSelectionMaterial=o}async applySceneViewState(t,e={}){return await this.stream.loadSceneViewState({sceneViewStateId:{hex:t},frameCorrelationId:e.suppliedCorrelationId?{value:e.suppliedCorrelationId}:void 0},!0)}async reset(t={}){return await this.stream.resetSceneView({includeCamera:t.includeCamera,frameCorrelationId:t.suppliedCorrelationId?{value:t.suppliedCorrelationId}:void 0},!0)}items(t){const e=t(new at(this.defaultSelectionMaterial)),s=(Array.isArray(e)?e:[e]).reduce(((t,e)=>t.concat(e.build())),[]);return new ht(this.sceneViewId,this.stream,this.dimensions,s)}camera(){const{scene:t}=this.frame;if(t.camera.isOrthographic())return new Q(this.stream,l.aspectRatio(this.viewport()),{viewVector:t.camera.viewVector,lookAt:t.camera.lookAt,up:t.camera.up,fovHeight:t.camera.fovHeight},this.frame.scene.boundingBox,this.decodeFrame);if(t.camera.isPerspective())return new L(this.stream,l.aspectRatio(this.viewport()),{position:t.camera.position,lookAt:t.camera.lookAt,up:t.camera.up,fovY:t.camera.fovY},this.frame.scene.boundingBox,this.decodeFrame);throw new D("Cannot retrieve camera. Scene has an unknown or invalid camera type.")}boundingBox(){return this.frame.scene.boundingBox}crossSectioning(){return new W(this.stream,this.frame.scene.crossSection)}raycaster(){return new Y(this.stream,this.imageScaleProvider)}viewport(){return this.frame.dimensions}scale(){return this.imageScaleProvider()||c.create(1,1)}}export{I as C,C as I,ut as S,k as V,V as W,N as a,S as b,j as c,O as d,B as e,U as f,A as g,M as h,x as i,E as l}
|