@vertexvis/viewer 0.22.0-canary.3 → 0.22.0-testing.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cjs/index.cjs.js +4 -1
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/cjs/multiElementInteractionHandler-93bd9593.js.map +1 -1
  4. package/dist/cjs/{queries-d9cd5ec1.js → queries-918bb133.js} +315 -41
  5. package/dist/cjs/queries-918bb133.js.map +1 -0
  6. package/dist/cjs/vertex-viewer.cjs.entry.js +3 -256
  7. package/dist/cjs/vertex-viewer.cjs.entry.js.map +1 -1
  8. package/dist/collection/index.js +1 -0
  9. package/dist/collection/index.js.map +1 -1
  10. package/dist/collection/lib/interactions/baseInteractionHandler.js.map +1 -1
  11. package/dist/collection/lib/interactions/index.js +1 -0
  12. package/dist/collection/lib/interactions/index.js.map +1 -1
  13. package/dist/collection/lib/interactions/mouseInteractions.js +6 -0
  14. package/dist/collection/lib/interactions/mouseInteractions.js.map +1 -1
  15. package/dist/collection/lib/interactions/pointerInteractionHandler.js +6 -0
  16. package/dist/collection/lib/interactions/pointerInteractionHandler.js.map +1 -1
  17. package/dist/components/index.js +1 -1
  18. package/dist/components/multiElementInteractionHandler.js.map +1 -1
  19. package/dist/components/queries.js +269 -2
  20. package/dist/components/queries.js.map +1 -1
  21. package/dist/components/vertex-viewer.js +3 -256
  22. package/dist/components/vertex-viewer.js.map +1 -1
  23. package/dist/esm/index.js +3 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/index.mjs +3 -1
  26. package/dist/esm/multiElementInteractionHandler-8b48d16e.js.map +1 -1
  27. package/dist/esm/{queries-2834b01d.js → queries-e3684cb0.js} +270 -3
  28. package/dist/esm/queries-e3684cb0.js.map +1 -0
  29. package/dist/esm/vertex-viewer.entry.js +3 -256
  30. package/dist/esm/vertex-viewer.entry.js.map +1 -1
  31. package/dist/types/index.d.ts +1 -0
  32. package/dist/types/lib/interactions/baseInteractionHandler.d.ts +6 -6
  33. package/dist/types/lib/interactions/index.d.ts +1 -0
  34. package/dist/types/lib/interactions/mouseInteractions.d.ts +2 -0
  35. package/dist/types/lib/interactions/pointerInteractionHandler.d.ts +2 -0
  36. package/dist/viewer/index.esm.js +1 -1
  37. package/dist/viewer/index.esm.js.map +1 -1
  38. package/dist/viewer/p-0ab3b3cc.js +5 -0
  39. package/dist/viewer/p-0ab3b3cc.js.map +1 -0
  40. package/dist/viewer/p-8a56c008.entry.js +5 -0
  41. package/dist/viewer/p-8a56c008.entry.js.map +1 -0
  42. package/dist/viewer/p-bf67f570.js.map +1 -1
  43. package/dist/viewer/viewer.esm.js +1 -1
  44. package/package.json +7 -7
  45. package/dist/cjs/queries-d9cd5ec1.js.map +0 -1
  46. package/dist/esm/queries-2834b01d.js.map +0 -1
  47. package/dist/viewer/p-339774b3.js +0 -5
  48. package/dist/viewer/p-339774b3.js.map +0 -1
  49. package/dist/viewer/p-b8dfa0c1.entry.js +0 -5
  50. package/dist/viewer/p-b8dfa0c1.entry.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["src/lib/scenes/colorMaterial.ts","src/lib/types/loadableResource.ts","src/lib/types/sceneViewStateIdentifier.ts","src/lib/types/synchronizedClock.ts","src/lib/stream/dispatcher.ts","src/lib/scenes/cameraRenderResult.ts","src/lib/scenes/mapper.ts","src/lib/scenes/camera.ts","src/lib/scenes/crossSectioner.ts","src/lib/scenes/operations.ts","src/lib/scenes/raycaster.ts","src/lib/scenes/sceneViewStateLoader.ts","src/lib/scenes/scene.ts","src/lib/scenes/queries.ts"],"names":["defaultColor","opacity","glossiness","diffuse","r","g","b","a","ambient","specular","emissive","create","Object","assign","fromHex","hex","color","Color","fromHexString","fromUrn","urn","uri","Uri","parse","scheme","path","Error","nid","resourceType","resourceId","subResourcePath","split","console","warn","queries","fromQuery","query","subResource","_a","fromSubResourcePath","join","find","q","type","resource","id","filter","InvalidResourceUrnError","subResourceType","subResourceId","undefined","map","queryFragment","isSceneViewStateId","identifier","isSceneViewStateSuppliedId","suppliedId","SynchronizedClock","[object Object]","knownRemoteTime","knownLocalTime","Date","this","duration","localNow","remoteTimeOrDurationInMs","remoteTime","getTime","addDuration","localTime","localTimeOrDurationInMs","start","end","now","DEFAULT_TIMEOUT_IN_MS","StreamApiEventDispatcher","stream","predicate","transform","timeout","listeners","handleMessage","bind","listener","eventDisposable","requestDisposable","addListeners","l","length","removeListeners","handler","Async","Promise","resolve","data","off","on","finally","msg","transformed","forEach","onEvent","onRequest","dispose","_b","CameraRenderResult","decodeFrame","animationId","correlationId","onAnimationCompleted","_c","event","animationCompleted","onFrameReceived","request","drawFrame","frameCorrelationIds","some","buildSceneViewStateIdentifier","sceneViewStateId","SceneViewStateIdentifier.isSceneViewStateId","SceneViewStateIdentifier.isSceneViewStateSuppliedId","sceneViewStateSuppliedId","value","buildQueryExpression","context","operand","itemCollection","expressions","exp","sceneItemQuery","buildSceneItemQuery","not","expression","item","root","sceneTreeRange","range","removeHiddenItems","and","first","metadata","valueFilter","keys","exactMatch","second","override","visibility","visibilityState","selection","point","viewport","dimensions","volume","frustumByRectangle","rectangle","exclusive","buildSceneOperation","operations","operationTypes","buildOperationTypes","queryExpression","vertexvis","protobuf","core","Uuid","buildFlyToOperation","frameCorrelationId","options","animation","baseCamera","payload","toProtoDuration","milliseconds","FrameCamera.toProtobuf","flyTo","itemSuppliedId","itemId","camera","boundingBox","xmin","min","x","xmax","max","ymin","y","ymax","zmin","z","zmax","op","changeMaterial","materialOverride","colorMaterial","d","material","ns","ka","kd","ks","ke","clearMaterial","changeTransform","clearTransform","cascade","changeVisibility","visible","changeSelection","selected","changePhantom","phantom","phantomState","changeEndItem","endItem","endItemState","viewRendition","viewDefaultRendition","clearRendition","viewRepresentation","predefinedId","RepresentationPredefinedId","REPRESENTATION_PREDEFINED_ID_EMPTY","REPRESENTATION_PREDEFINED_ID_ENTIRE_PART","clearRepresentation","toPbSceneViewStateFeatures","features","feature","SceneViewStateFeature","SCENE_VIEW_STATE_FEATURE_CAMERA","SCENE_VIEW_STATE_FEATURE_MATERIAL_OVERRIDE","SCENE_VIEW_STATE_FEATURE_SELECTION","SCENE_VIEW_STATE_FEATURE_VISIBILITY","SCENE_VIEW_STATE_FEATURE_TRANSFORM","SCENE_VIEW_STATE_FEATURE_CROSS_SECTION","SCENE_VIEW_STATE_FEATURE_PHANTOM","SCENE_VIEW_STATE_FEATURE_INVALID","TerminalFlyToExecutor","flyToOptions","FlyToExecutor","Camera","aspect","position","viewVector","withPositionAndViewVector","boundingBoxCenter","BoundingBox","center","cameraToCenter","Vector3","subtract","dot","magnitude","paramsOrQuery","updateFlyToOptions","buildFlyToType","build","fitToBoundingBox","renderOptions","corrId","UUID","toFrameCamera","flyToResponse","replaceCamera","e","angleInRadians","axis","rotateAroundAxisAtPoint","lookAt","normal","worldX","normalize","cross","up","positiveWorldY","worldY","angleTo","Math","PI","negate","localX","isEqual","transformedViewVector","transformMatrix","Matrix4","makeRotation","Quaternion","fromAxisAngle","lookAtRay","Ray","origin","direction","at","update","standardView","standardViewRay","updatedPosition","ClippingPlanes.fromBoundingBoxAndLookAtCamera","PerspectiveCamera","perspectiveData","super","delta","add","rotateAboutAxis","fovY","FramePerspectiveCamera","near","far","aspectRatio","computeClippingPlanes","OrthographicCamera","orthographicData","updatedPoint","rotationPoint","updatedLookAt","constrainViewVector","BoundingSphere","boundingSphere","updateLookAtRelativeToBoundingBoxCenter","FrameOrthographicCamera","fovHeight","CrossSectioner","crossSectioning","res","updateCrossSectioning","sectionPlanes","highlightColor","lineWidth","SceneOperationBuilder","concat","matrix","Raycaster","imageScaleProvider","scale","hitItems","Point","includeMetadata","SceneViewStateLoader","sceneId","sceneViewId","opts","pbIdField","animateToSceneViewState","loadSceneViewState","suppliedCorrelationId","featuresToApply","pbFeatures","includes","sceneViewStateFeatureSubset","flyToResult","sceneViewStateIdentifier","waitForAnimation","renderResult","once","SceneItemOperationsBuilder","givenBuilder","builder","hide","show","select","deselect","clearMaterialOverrides","Array","isArray","InvalidArgumentError","r0","w","r1","r2","r3","clearTransforms","setPhantom","clearPhantom","setEndItem","clearEndItem","viewRenditionById","viewRenditionBySuppliedId","ItemsOperationExecutor","queryOperations","executionOptions","pbOperations","createSceneAlteration","Scene","frame","sceneViewStateLoader","applySceneViewState","applyPartialSceneViewState","resetSceneView","includeCamera","sceneOperations","SceneItemQueryExecutor","ops","operationList","reduce","acc","scene","isOrthographic","Dimensions","isPerspective","InvalidCameraError","crossSection","TerminalQuery","inverted","queryExpressionBuilder","RootQuery","AllQuery","NotQuery","ids","BulkQuery","SingleQuery","SceneTreeRangeQuery","MetadataQuery","AllSelectedQuery","AllVisibleQuery","PointQuery","VolumeIntersectionQuery","AndQuery","OrQuery"],"mappings":";;;gXAcO,MAAMA,EAA8B,CACzCC,QAAS,IACTC,WAAY,EACZC,QAAS,CACPC,EAAG,EACHC,EAAG,EACHC,EAAG,EACHC,EAAG,GAELC,QAAS,CACPJ,EAAG,EACHC,EAAG,EACHC,EAAG,EACHC,EAAG,GAGLE,SAAU,CACRL,EAAG,EACHC,EAAG,EACHC,EAAG,EACHC,EAAG,GAELG,SAAU,CACRN,EAAG,EACHC,EAAG,EACHC,EAAG,EACHC,EAAG,IASA,MAAMI,EAAS,CACpBP,EACAC,EACAC,EACAL,IAEAW,OAAAC,OAAAD,OAAAC,OAAA,GACKb,GAAY,CACfC,QAASA,IAAO,MAAPA,SAAO,EAAPA,EAAWD,EAAaC,QACjCE,QAAS,CACPC,EAAAA,EACAC,EAAAA,EACAC,EAAAA,EACAC,EAAG,KAUF,MAAMO,EAAU,CAACC,EAAad,KACnC,MAAMe,EAAQC,EAAMC,cAAcH,GAElC,OAAAH,OAAAC,OAAAD,OAAAC,OAAA,GACKb,GAAY,CACfC,QAASA,IAAO,MAAPA,SAAO,EAAPA,EAAWD,EAAaC,QACjCE,QAASa,GAAS,KAAIJ,OAAAC,OAAA,GAAQG,GAAKJ,OAA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O9E,IAChDiB,KAAKoV,UAIFxV,eAAeb,GACpB,OAAO,IAAIoX,GACT,IAAInW,KAAKkE,YAAa,CAAErF,KAAM,cAAegF,MAAO9E,IACpDiB,KAAKoV,UAIFxV,KACL,OAAOI,YAIEkW,WAAiBf,GAC5BvV,YACUsE,EACRkR,GAEAtG,MAAMsG,GAHEpV,KAAAkE,YAAAA,EAMHtE,yBACL,MAAO,CAAEf,KAAM,MAAOqF,YAAa,IAAIlE,KAAKkE,cAGvCtE,WAAWb,GAChB,OAAO,IAAImX,GACT,IAAIlW,KAAKkE,YAAa,CAAErF,KAAM,UAAWgF,MAAO9E,IAChDiB,KAAKoV,UAIFxV,eAAeb,GACpB,OAAO,IAAImX,GACT,IAAIlW,KAAKkE,YAAa,CAAErF,KAAM,cAAegF,MAAO9E,IACpDiB,KAAKoV,UAIFxV,MACL,OAAOI,YAIEwU,GACJ5U,MACLtB,GAEA,MAAMiG,EAA8BjG,EAAM,IAAIgX,IAAapJ,QAE3D,OAAO,IAAIkG,GAA2B7N","sourcesContent":["import { Color } from '@vertexvis/utils';\n\n/**\n * The `ColorMaterial` interface is here.\n */\nexport interface ColorMaterial {\n opacity: number;\n glossiness: number;\n diffuse: Color.Color;\n ambient: Color.Color;\n specular: Color.Color;\n emissive: Color.Color;\n}\n\nexport const defaultColor: ColorMaterial = {\n opacity: 255,\n glossiness: 4,\n diffuse: {\n r: 0,\n g: 0,\n b: 0,\n a: 0,\n },\n ambient: {\n r: 0,\n g: 0,\n b: 0,\n a: 0,\n },\n\n specular: {\n r: 0,\n g: 0,\n b: 0,\n a: 0,\n },\n emissive: {\n r: 0,\n g: 0,\n b: 0,\n a: 0,\n },\n};\n\n/**\n * This helper creates an rgb value color\n * @param hex\n * @param opacity\n */\nexport const create = (\n r: number,\n g: number,\n b: number,\n opacity?: number\n): ColorMaterial => {\n return {\n ...defaultColor,\n opacity: opacity ?? defaultColor.opacity,\n diffuse: {\n r,\n g,\n b,\n a: 0,\n },\n };\n};\n\n/**\n * This helper converts a hex string to a ColorMaterial object\n * @param hex\n * @param opacity\n */\nexport const fromHex = (hex: string, opacity?: number): ColorMaterial => {\n const color = Color.fromHexString(hex);\n\n return {\n ...defaultColor,\n opacity: opacity ?? defaultColor.opacity,\n diffuse: color != null ? { ...color } : { ...defaultColor.diffuse },\n };\n};\n","import { Uri } from '@vertexvis/utils';\n\nimport { InvalidResourceUrnError } from '../errors';\n\ninterface StreamKeyResource {\n type: 'stream-key';\n id: string;\n}\n\nexport type LoadableResource = StreamKeyResource;\n\nexport interface Resource {\n resource: LoadableResource;\n subResource?: PathResource;\n queries: QueryValue[];\n}\n\nexport function fromUrn(urn: string): Resource {\n const uri = Uri.parse(urn);\n\n if (uri.scheme !== 'urn' || uri.path == null) {\n throw new Error('Invalid URN. Expected URN scheme.');\n }\n\n const [nid, resourceType, resourceId, ...subResourcePath] =\n uri.path.split(/[:/]/);\n\n if (nid !== 'vertexvis' && nid !== 'vertex') {\n throw new Error('Invalid URN. Expected URN to be vertex namespace');\n }\n\n if (nid === 'vertexvis') {\n console.warn(\n \"vertexvis namespace is deprecated. Use 'vertex' for the namespace urn instead\"\n );\n }\n\n switch (resourceType) {\n case 'stream-key':\n const queries = fromQuery(uri.query);\n const subResource =\n fromSubResourcePath(subResourcePath.join('/')) ??\n (queries.find((q) => q.type === 'scene-view-state') as\n | SceneViewStateResource\n | undefined);\n\n return {\n resource: { type: 'stream-key', id: resourceId },\n subResource,\n queries: queries.filter((q) => q.type !== 'scene-view-state'),\n };\n default:\n throw new InvalidResourceUrnError(\n `Invalid URN. Unknown resource type ${resourceType}`\n );\n }\n}\n\nexport interface SceneViewStateResource {\n type: 'scene-view-state';\n id?: string;\n}\n\nexport type PathResource = SceneViewStateResource;\n\nfunction fromSubResourcePath(path?: string): PathResource | undefined {\n if (path != null) {\n const [subResourceType, subResourceId] = path.split('/');\n\n switch (subResourceType) {\n case 'scene-view-states':\n return {\n type: 'scene-view-state',\n id: subResourceId,\n };\n default:\n return undefined;\n }\n }\n}\n\nexport interface SuppliedIdQueryValue {\n type: 'supplied-id';\n id: string;\n}\n\nexport type QueryValue = SceneViewStateResource | SuppliedIdQueryValue;\n\nfunction fromQuery(query?: string): QueryValue[] {\n if (query != null) {\n return query.split('&').map((queryFragment) => {\n const [resourceType, resourceId] = queryFragment.split('=');\n\n switch (resourceType) {\n case 'supplied-id':\n return { type: 'supplied-id', id: resourceId };\n case 'scene-view-state':\n return { type: 'scene-view-state', id: resourceId };\n default:\n throw new Error('Invalid URN. Unknown query value type');\n }\n });\n } else {\n return [];\n }\n}\n","import { UUID } from '@vertexvis/utils';\n\nexport interface SceneViewStateId {\n id: UUID.UUID;\n}\n\nexport interface SceneViewStateSuppliedId {\n suppliedId: string;\n}\n\n/**\n * An object describing an ID for the scene view state. Can either be an\n * object containing the ID generated on creation, or an object containing\n * a supplied id provided during creation.\n */\nexport type SceneViewStateIdentifier =\n | SceneViewStateId\n | SceneViewStateSuppliedId;\n\nexport function isSceneViewStateId(\n identifier: SceneViewStateIdentifier\n): identifier is SceneViewStateId {\n return (identifier as SceneViewStateId).id != null;\n}\n\nexport function isSceneViewStateSuppliedId(\n identifier: SceneViewStateIdentifier\n): identifier is SceneViewStateSuppliedId {\n return (identifier as SceneViewStateSuppliedId).suppliedId != null;\n}\n","type Milliseconds = number;\n\n/**\n * A `SynchronizedClock` allows for approximating the time on a remote machine.\n *\n * During initialization, a known time of the remote host must be supplied. Once\n * the remote time is known, this class can approximate the time on the remote\n * machine from a date or duration.\n *\n * @example\n * ```\n * const knownRemoteTime = await getRemoteTime();\n * const clock = new SynchronizedClock(knownRemoteTime);\n *\n * const localDate = new Date();\n * const serverTime = clock.remoteTime(localDate);\n *\n * const remoteDate = await getRemoteTime();\n * const localTime = clock.localTime(remoteDate);\n *\n * const currentRemoteTime = clock.remoteNow();\n * ```\n */\nexport class SynchronizedClock {\n public constructor(\n public readonly knownRemoteTime: Date,\n public readonly knownLocalTime = new Date()\n ) {}\n\n /**\n * Computes an offset duration from when this clock was instantiated.\n */\n public localOffset(): Milliseconds {\n return this.duration(this.knownLocalTime, this.localNow());\n }\n\n /**\n * Approximates the local time from a timestamp originating from the remote\n * machine.\n *\n * @param remoteTime A remote timestamp.\n */\n public localTime(remoteTime: Date): Date;\n\n /**\n * Approximates the local from an offset duration originating from the remote\n * machine's last known time.\n *\n * @param remoteDurationInMs A remote duration, in milliseconds.\n */\n public localTime(remoteDurationInMs: Milliseconds): Date;\n\n /**\n * Approximates the local time from a remote timestamp or duration.\n *\n * @param remoteTimeOrDurationInMs A remote timestamp or duration.\n */\n public localTime(remoteTimeOrDurationInMs: Milliseconds | Date): Date {\n const remoteTime =\n typeof remoteTimeOrDurationInMs === 'number'\n ? new Date(this.knownLocalTime.getTime() + remoteTimeOrDurationInMs)\n : remoteTimeOrDurationInMs;\n const duration = this.duration(this.knownRemoteTime, remoteTime);\n return this.addDuration(this.knownLocalTime, duration);\n }\n\n /**\n * Approximates an offset duration on the remote machine.\n *\n * @param localTime A local timestamp. Defaults to the current local time.\n */\n public remoteOffset(localTime: Date = new Date()): Milliseconds {\n return this.duration(\n this.remoteTime(this.knownLocalTime),\n this.remoteTime(localTime)\n );\n }\n\n /**\n * Approximates the current time on the remote machine.\n */\n public remoteNow(): Date {\n return this.remoteTime(this.localNow());\n }\n\n /**\n * Approximates the remote time from a local timestamp.\n *\n * @param localTime A local timestamp.\n */\n public remoteTime(localTime: Date): Date;\n\n /**\n * Approximates the remote time from a local offset duration.\n *\n * @param localDurationInMs A local offset, in milliseconds.\n * @see #localOffset\n */\n public remoteTime(localDurationInMs: Milliseconds): Date;\n\n /**\n * Approximates the remote time from either a local timestamp or duration.\n *\n * @param localTimeOrDurationInMs A local timestamp or duration.\n */\n public remoteTime(localTimeOrDurationInMs: Milliseconds | Date): Date {\n const localTime =\n typeof localTimeOrDurationInMs === 'number'\n ? new Date(this.knownLocalTime.getTime() + localTimeOrDurationInMs)\n : localTimeOrDurationInMs;\n const duration = this.duration(this.knownLocalTime, localTime);\n return this.addDuration(this.knownRemoteTime, duration);\n }\n\n private addDuration(start: Date, duration: Milliseconds): Date {\n return new Date(start.getTime() + duration);\n }\n\n private duration(start: Date, end: Date): Milliseconds {\n return end.getTime() - start.getTime();\n }\n\n private localNow(): Date {\n return new Date(Date.now());\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { StreamApi } from '@vertexvis/stream-api';\nimport { Async, Disposable, Listener } from '@vertexvis/utils';\n\nexport const DEFAULT_TIMEOUT_IN_MS = 1000 * 10;\n\nexport class StreamApiEventDispatcher<T> {\n private listeners: Array<Listener<T>> = [];\n private eventDisposable?: Disposable;\n private requestDisposable?: Disposable;\n\n public constructor(\n private stream: StreamApi,\n private predicate: (\n msg: vertexvis.protobuf.stream.IStreamMessage\n ) => boolean,\n private transform: (\n msg: vertexvis.protobuf.stream.IStreamMessage\n ) => T | undefined,\n private timeout: number = DEFAULT_TIMEOUT_IN_MS\n ) {\n this.handleMessage = this.handleMessage.bind(this);\n }\n\n public on(listener: Listener<T>): void {\n this.listeners = [...this.listeners, listener];\n if (this.eventDisposable == null || this.requestDisposable == null) {\n this.addListeners();\n }\n }\n\n public off(listener: Listener<T>): void {\n this.listeners = this.listeners.filter((l) => l !== listener);\n if (this.listeners.length === 0) {\n this.removeListeners();\n }\n }\n\n public once(): Promise<T> {\n let handler: (data: T) => void;\n return Async.timeout(\n this.timeout,\n new Promise<T>((resolve) => {\n handler = (data: T) => {\n resolve(data);\n this.off(handler);\n };\n\n this.on(handler);\n })\n ).finally(() => {\n this.off(handler);\n });\n }\n\n private handleMessage(msg: vertexvis.protobuf.stream.IStreamMessage): void {\n if (this.predicate(msg)) {\n const transformed = this.transform(msg);\n\n if (transformed != null) {\n this.listeners.forEach((l) => l(transformed));\n }\n }\n }\n\n private addListeners(): void {\n this.eventDisposable = this.stream.onEvent(this.handleMessage);\n this.requestDisposable = this.stream.onRequest(this.handleMessage);\n }\n\n private removeListeners(): void {\n this.eventDisposable?.dispose();\n this.requestDisposable?.dispose();\n }\n}\n","import { StreamApi } from '@vertexvis/stream-api';\n\nimport type { FrameDecoder } from '../mappers';\nimport { StreamApiEventDispatcher } from '../stream/dispatcher';\nimport { Result } from '../stream/result';\nimport { Frame } from '../types';\n\nexport interface RenderResultIds {\n animationId?: string;\n correlationId?: string;\n}\n\nexport class CameraRenderResult implements Result {\n public data = undefined;\n public onAnimationCompleted: StreamApiEventDispatcher<string>;\n public onFrameReceived: StreamApiEventDispatcher<Frame>;\n\n public constructor(\n stream: StreamApi,\n decodeFrame: FrameDecoder,\n { animationId, correlationId }: RenderResultIds,\n timeout?: number\n ) {\n this.onAnimationCompleted = new StreamApiEventDispatcher(\n stream,\n (msg) => msg.event?.animationCompleted?.animationId?.hex === animationId,\n (msg) => msg.event?.animationCompleted?.animationId?.hex || undefined,\n timeout\n );\n this.onFrameReceived = new StreamApiEventDispatcher<Frame>(\n stream,\n (msg) =>\n !!msg.request?.drawFrame?.frameCorrelationIds?.some(\n (id) => id === correlationId\n ),\n (msg) =>\n msg.request?.drawFrame != null\n ? decodeFrame(msg.request.drawFrame)\n : undefined,\n timeout\n );\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { Dimensions } from '@vertexvis/geometry';\nimport { RepresentationPredefinedId } from '@vertexvis/scene-view-protos/core/protos/representation_pb';\nimport { toProtoDuration } from '@vertexvis/stream-api';\nimport { UUID } from '@vertexvis/utils';\n\nimport {\n Animation,\n FlyTo,\n FrameCamera,\n SceneViewStateIdentifier,\n} from '../types';\nimport { ItemOperation } from './operations';\nimport { QueryExpression } from './queries';\nimport { SceneViewStateFeature } from './scene';\n\nexport interface BuildSceneOperationContext {\n dimensions: Dimensions.Dimensions;\n}\n\nexport function buildSceneViewStateIdentifier(\n identifier: UUID.UUID | SceneViewStateIdentifier.SceneViewStateIdentifier\n):\n | Pick<\n vertexvis.protobuf.stream.ILoadSceneViewStatePayload,\n 'sceneViewStateId'\n >\n | Pick<\n vertexvis.protobuf.stream.ILoadSceneViewStatePayload,\n 'sceneViewStateSuppliedId'\n > {\n if (typeof identifier === 'string') {\n return { sceneViewStateId: { hex: identifier } };\n } else if (SceneViewStateIdentifier.isSceneViewStateId(identifier)) {\n return { sceneViewStateId: { hex: identifier.id } };\n } else if (SceneViewStateIdentifier.isSceneViewStateSuppliedId(identifier)) {\n return { sceneViewStateSuppliedId: { value: identifier.suppliedId } };\n } else {\n throw new Error(\n 'Unable to build scene view state identifier, input must be a string or `SceneViewStateIdentifier`.'\n );\n }\n}\n\nexport function buildQueryExpression(\n query: QueryExpression,\n context: BuildSceneOperationContext\n): vertexvis.protobuf.stream.IQueryExpression {\n switch (query.type) {\n case 'and':\n case 'or':\n return {\n operand: {\n itemCollection: {\n queries: query.expressions.map((exp) => ({\n sceneItemQuery: buildSceneItemQuery(exp),\n })),\n },\n },\n };\n case 'not':\n return {\n not: {\n expression: buildQueryExpression(query.query, context),\n },\n };\n case 'item-id':\n case 'supplied-id':\n return {\n operand: {\n item: {\n sceneItemQuery: buildSceneItemQuery(query),\n },\n },\n };\n case 'all':\n return {\n operand: {\n root: {},\n },\n };\n case 'scene-tree-range':\n return {\n operand: {\n sceneTreeRange: {\n start: query.range.start,\n end: query.range.end,\n },\n },\n };\n case 'metadata':\n if (query.removeHiddenItems) {\n return {\n and: {\n first: {\n operand: {\n metadata: {\n valueFilter: query.filter,\n keys: query.keys,\n exactMatch: query.exactMatch,\n },\n },\n },\n second: {\n operand: {\n override: {\n visibility: {\n visibilityState: true,\n },\n },\n },\n },\n },\n };\n } else {\n return {\n operand: {\n metadata: {\n valueFilter: query.filter,\n keys: query.keys,\n exactMatch: query.exactMatch,\n },\n },\n };\n }\n case 'all-selected':\n return {\n operand: {\n override: {\n selection: {},\n },\n },\n };\n case 'all-visible':\n return {\n operand: {\n override: {\n visibility: {\n visibilityState: true,\n },\n },\n },\n };\n case 'point':\n return {\n operand: {\n point: {\n point: query.point,\n viewport: context.dimensions,\n },\n },\n };\n case 'volume-intersection':\n return {\n operand: {\n volume: {\n frustumByRectangle: {\n rectangle: query.rectangle,\n },\n exclusive: query.exclusive,\n viewport: context.dimensions,\n },\n },\n };\n default:\n return {};\n }\n}\n\nexport function buildSceneOperation(\n query: QueryExpression,\n operations: ItemOperation[],\n context: BuildSceneOperationContext\n): vertexvis.protobuf.stream.ISceneOperation {\n const operationTypes = buildOperationTypes(operations);\n const queryExpression = buildQueryExpression(query, context);\n\n return { queryExpression, operationTypes };\n}\n\nfunction buildSceneItemQuery(\n item: QueryExpression\n): vertexvis.protobuf.stream.ISceneItemQuery {\n switch (item.type) {\n case 'item-id':\n return {\n id: new vertexvis.protobuf.core.Uuid({\n hex: item.value,\n }),\n };\n case 'supplied-id':\n return {\n suppliedId: item.value,\n };\n default:\n return {};\n }\n}\n\nexport function buildFlyToOperation(\n frameCorrelationId: UUID.UUID,\n options: FlyTo.FlyToOptions,\n animation?: Animation.Animation,\n baseCamera?: FrameCamera.FrameCamera\n): vertexvis.protobuf.stream.IFlyToPayload {\n const payload = {\n frameCorrelationId: {\n value: frameCorrelationId,\n },\n animation: animation\n ? {\n duration: toProtoDuration(animation.milliseconds),\n }\n : undefined,\n baseCamera:\n baseCamera != null ? FrameCamera.toProtobuf(baseCamera) : undefined,\n };\n\n switch (options.flyTo.type) {\n case 'supplied': {\n return {\n ...payload,\n itemSuppliedId: options.flyTo.data,\n };\n }\n case 'internal': {\n return {\n ...payload,\n itemId: new vertexvis.protobuf.core.Uuid({\n hex: options.flyTo.data,\n }),\n };\n }\n case 'camera': {\n return {\n ...payload,\n camera: FrameCamera.toProtobuf(options.flyTo.data),\n };\n }\n\n case 'bounding-box': {\n return {\n ...payload,\n boundingBox: {\n xmin: options.flyTo.data.min.x,\n xmax: options.flyTo.data.max.x,\n ymin: options.flyTo.data.min.y,\n ymax: options.flyTo.data.max.y,\n zmin: options.flyTo.data.min.z,\n zmax: options.flyTo.data.max.z,\n },\n };\n }\n default:\n return {};\n }\n}\n\nfunction buildOperationTypes(\n operations: ItemOperation[]\n): vertexvis.protobuf.stream.IOperationType[] {\n return operations.map((op) => {\n switch (op.type) {\n case 'change-material':\n return {\n changeMaterial: {\n materialOverride: {\n colorMaterial: {\n d: op.material.opacity,\n ns: op.material.glossiness,\n ka: op.material.ambient,\n kd: op.material.diffuse,\n ks: op.material.specular,\n ke: op.material.emissive,\n },\n },\n },\n };\n case 'clear-override':\n return { clearMaterial: {} };\n case 'change-transform':\n return { changeTransform: { transform: { ...op.transform } } };\n case 'clear-transform':\n return { clearTransform: { cascade: op.cascade } };\n case 'hide':\n return { changeVisibility: { visible: false } };\n case 'show':\n return { changeVisibility: { visible: true } };\n case 'select':\n return { changeSelection: { selected: true } };\n case 'deselect':\n return { changeSelection: { selected: false } };\n case 'change-phantom':\n return { changePhantom: { phantom: op.phantomState ?? true } };\n case 'clear-phantom':\n return { changePhantom: { phantom: false } };\n case 'change-end-item':\n return { changeEndItem: { endItem: op.endItemState ?? true } };\n case 'clear-end-item':\n return { changeEndItem: { endItem: false } };\n case 'view-rendition-by-id':\n return {\n viewRendition: {\n id: new vertexvis.protobuf.core.Uuid({ hex: op.id }),\n },\n };\n case 'view-rendition-by-supplied-id':\n return { viewRendition: { suppliedId: op.suppliedId } };\n case 'view-default-rendition':\n return { viewDefaultRendition: {} };\n case 'clear-rendition':\n return { clearRendition: {} };\n case 'view-representation':\n if (op.id === 'empty') {\n return {\n viewRepresentation: {\n predefinedId:\n RepresentationPredefinedId.REPRESENTATION_PREDEFINED_ID_EMPTY,\n },\n };\n } else if (op.id === 'entire-part') {\n return {\n viewRepresentation: {\n predefinedId:\n RepresentationPredefinedId.REPRESENTATION_PREDEFINED_ID_ENTIRE_PART,\n },\n };\n } else {\n return {\n viewRepresentation: {\n id: new vertexvis.protobuf.core.Uuid({ hex: op.id }),\n },\n };\n }\n case 'clear-representation':\n return { clearRepresentation: {} };\n default:\n return {};\n }\n });\n}\n\nexport function toPbSceneViewStateFeatures(\n features: SceneViewStateFeature[]\n): vertexvis.protobuf.stream.SceneViewStateFeature[] {\n return features.map((feature) => {\n switch (feature) {\n case 'camera':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_CAMERA;\n case 'material_overrides':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_MATERIAL_OVERRIDE;\n case 'selection':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_SELECTION;\n case 'visibility':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_VISIBILITY;\n case 'transforms':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_TRANSFORM;\n case 'cross_section':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_CROSS_SECTION;\n case 'phantom':\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_PHANTOM;\n default:\n return vertexvis.protobuf.stream.SceneViewStateFeature\n .SCENE_VIEW_STATE_FEATURE_INVALID;\n }\n });\n}\n","import {\n BoundingBox,\n BoundingSphere,\n Matrix4,\n Quaternion,\n Ray,\n Vector3,\n} from '@vertexvis/geometry';\nimport { StreamApi } from '@vertexvis/stream-api';\nimport { UUID } from '@vertexvis/utils';\n\nimport { FrameDecoder } from '../mappers';\nimport {\n constrainViewVector,\n updateLookAtRelativeToBoundingBoxCenter,\n} from '../rendering/vectors';\nimport { DEFAULT_TIMEOUT_IN_MS } from '../stream/dispatcher';\nimport {\n Animation,\n ClippingPlanes,\n FlyTo,\n FrameCamera,\n FrameCameraBase,\n FrameOrthographicCamera,\n FramePerspectiveCamera,\n StandardView,\n} from '../types';\nimport { withPositionAndViewVector } from '../types/frameCamera';\nimport { CameraRenderResult } from './cameraRenderResult';\nimport { buildFlyToOperation } from './mapper';\n\nexport interface CameraRenderOptions {\n animation?: Animation.Animation;\n}\n\nexport class TerminalFlyToExecutor {\n public constructor(private flyToOptions?: FlyTo.FlyToOptions) {}\n\n public build(): FlyTo.FlyToOptions | undefined {\n return this.flyToOptions;\n }\n}\n\nexport class FlyToExecutor {\n private flyToOptions?: FlyTo.FlyToOptions;\n\n public withItemId(id: string): TerminalFlyToExecutor {\n return new TerminalFlyToExecutor({\n flyTo: {\n type: 'internal',\n data: id,\n },\n });\n }\n\n public withSuppliedId(id: string): TerminalFlyToExecutor {\n return new TerminalFlyToExecutor({\n flyTo: {\n type: 'supplied',\n data: id,\n },\n });\n }\n\n public withCamera(camera: FrameCamera.FrameCamera): TerminalFlyToExecutor {\n return new TerminalFlyToExecutor({\n flyTo: {\n type: 'camera',\n data: camera,\n },\n });\n }\n\n public withBoundingBox(\n boundingBox: BoundingBox.BoundingBox\n ): TerminalFlyToExecutor {\n return new TerminalFlyToExecutor({\n flyTo: {\n type: 'bounding-box',\n data: boundingBox,\n },\n });\n }\n\n public build(): FlyTo.FlyToOptions | undefined {\n return this.flyToOptions;\n }\n}\n\nexport interface FlyToParams {\n itemId?: string;\n camera?: FrameCamera.FrameCamera;\n boundingBox?: BoundingBox.BoundingBox;\n itemSuppliedId?: string;\n}\n\n/**\n * The `Camera` class contains properties that reflect a world space position, a\n * view direction (lookAt), and normalized vector representing the up direction.\n *\n * It also provides utility methods to update orientation of the camera and\n * rerender the scene.\n *\n * This class in intended to treated as an immutable type. Any mutations return\n * a new instance of the class with the updated properties.\n */\nexport abstract class Camera {\n public constructor(\n protected stream: StreamApi,\n protected aspect: number,\n private data: FrameCamera.FrameCamera,\n protected boundingBox: BoundingBox.BoundingBox,\n protected decodeFrame: FrameDecoder,\n protected flyToOptions?: FlyTo.FlyToOptions\n ) {}\n\n /**\n * Updates the position of the camera such that the given bounding box will\n * be contained within the camera's view.\n *\n * @param boundingBox The bounding box to position to.\n */\n public fitToBoundingBox(boundingBox: BoundingBox.BoundingBox): Camera {\n return this.flyTo({\n boundingBox,\n });\n }\n\n /**\n * Returns the distance from the camera's position to the center\n * of the provided bounding box (or the scene's visible bounding box if not provided).\n *\n * @param boundingBox - The bounding box to determine distance from.\n */\n public signedDistanceToBoundingBoxCenter(\n boundingBox?: BoundingBox.BoundingBox\n ): number {\n const { position, viewVector } = withPositionAndViewVector(this.data);\n\n const boundingBoxCenter = BoundingBox.center(\n boundingBox ?? this.boundingBox\n );\n const cameraToCenter = Vector3.subtract(boundingBoxCenter, position);\n\n return (\n Vector3.dot(viewVector, cameraToCenter) / Vector3.magnitude(viewVector)\n );\n }\n\n /**\n * Specifies that the next render of the camera will be repositioned to one of\n * the options specified in `options`.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector(\"vertex-viewer\");\n * const scene = await viewer.scene();\n * const camera = scene.camera();\n *\n * // Fly to and fit to a specific item by ID with an animation of 1 second\n * await camera\n * .flyTo({ itemId: \"item-id\" })\n * .render({ animation: { milliseconds: 1000 } });\n *\n * // Fly to and fit to a specific item by supplied ID with an animation of 1 second\n * await camera\n * .flyTo({ itemSuppliedId: \"item-supplied-id\" })\n * .render({ animation: { milliseconds: 1000 } });\n *\n * // Fly to and fit to the bounding box of the current set of selected items\n * // with an animation of 1 second\n * await camera\n * .flyTo({\n * boundingBox:\n * viewer.frame.scene.sceneViewSummary.selectedVisibleSummary.boundingBox,\n * })\n * .render({ animation: { milliseconds: 1000 } });\n *\n * // Fly to a specific camera\n * await camera\n * .flyTo({\n * camera: {\n * position: {\n * x: 1,\n * y: 2,\n * z: 3,\n * },\n * lookAt: {\n * x: 0,\n * y: 0,\n * z: 0,\n * },\n * up: {\n * x: 0,\n * y: 1,\n * z: 0,\n * },\n * },\n * })\n * .render({ animation: { milliseconds: 1000 } });\n * ```\n *\n * @param paramsOrQuery An object or query describing how the camera should\n * be positioned.\n */\n public flyTo(\n paramsOrQuery: FlyToParams | ((q: FlyToExecutor) => TerminalFlyToExecutor)\n ): Camera {\n if (typeof paramsOrQuery !== 'function') {\n return this.updateFlyToOptions({\n flyTo: this.buildFlyToType(paramsOrQuery),\n });\n } else {\n return this.updateFlyToOptions(\n paramsOrQuery(new FlyToExecutor()).build()\n );\n }\n }\n\n /**\n * Performs a `flyTo` operation with the current visible bounding box of\n * the scene.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n * const camera = scene.camera();\n *\n * // Fit to the visible bounding box of the scene with an animation of 1 second\n * await camera.viewAll().render({ animation: { milliseconds: 1000 } });\n * ```\n */\n public viewAll(): Camera {\n return this.fitToBoundingBox(this.boundingBox);\n }\n\n /**\n * Queues the rendering for a new frame using this camera. The returned\n * promise will resolve when a frame is received that contains this camera.\n */\n public async render(\n renderOptions?: CameraRenderOptions\n ): Promise<CameraRenderResult> {\n if (this.flyToOptions == null && renderOptions != null) {\n this.flyToOptions = {\n flyTo: {\n type: 'camera',\n data: this.data,\n },\n };\n }\n\n try {\n const corrId = UUID.create();\n if (this.flyToOptions != null) {\n const payload = buildFlyToOperation(\n corrId,\n this.flyToOptions,\n renderOptions?.animation,\n this.toFrameCamera()\n );\n const flyToResponse = await this.stream.flyTo(payload, true);\n\n return new CameraRenderResult(\n this.stream,\n this.decodeFrame,\n {\n correlationId: corrId,\n animationId: flyToResponse.flyTo?.animationId?.hex || undefined,\n },\n renderOptions?.animation?.milliseconds != null\n ? renderOptions.animation.milliseconds + DEFAULT_TIMEOUT_IN_MS\n : undefined\n );\n } else {\n this.stream.replaceCamera({\n camera: FrameCamera.toProtobuf(this.data),\n frameCorrelationId: { value: corrId },\n });\n\n return new CameraRenderResult(this.stream, this.decodeFrame, {\n correlationId: corrId,\n });\n }\n } catch (e) {\n console.warn('Error when performing render: ', e);\n throw e;\n }\n }\n\n /**\n * Repositions the camera by rotating its current position around an axis placed\n * at the `lookAt` point. This method internally will call {@link Camera.rotateAroundAxisAtPoint}\n * with the `point` parameter set to the current `lookAt` point.\n *\n * @see {@link Camera.rotateAroundAxisAtPoint} for more information.\n *\n * @param angleInRadians The angle, in radians, to rotate.\n * @param axis A normalized vector to rotate around.\n */\n public rotateAroundAxis(\n angleInRadians: number,\n axis: Vector3.Vector3\n ): Camera {\n return this.rotateAroundAxisAtPoint(angleInRadians, this.data.lookAt, axis);\n }\n\n /**\n * Aligns the camera to the plane defined by the provided position and normal.\n * This will place the camera at the provided position, set the up vector to\n * the provided normal, and place the lookAt on the defined plane. The point\n * chosen for the lookAt will be determined using the current view vector.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector(\"vertex-viewer\");\n *\n * viewer.addEventListener(\"tap\", async (event) => {\n * const scene = await viewer.scene();\n * const raycaster = scene.raycaster();\n *\n * const [hit] = await raycaster.hitItems(event.detail.position);\n *\n * if (hit != null) {\n * const camera = scene.camera();\n *\n * // Align to the plane represented by the hit result with an animation of 1 second\n * await camera\n * .alignTo(hit.hitPoint, hit.hitNormal)\n * .render({ animation: { milliseconds: 1000 } });\n * }\n * });\n * ```\n *\n * @param position The position to place the camera at.\n * @param normal The normal of the plane to align to.\n */\n public alignTo(position: Vector3.Vector3, normal: Vector3.Vector3): Camera {\n const worldX = Vector3.normalize(\n Vector3.cross(this.up, Vector3.normalize(this.viewVector))\n );\n const positiveWorldY = Vector3.normalize(\n Vector3.cross(Vector3.normalize(this.viewVector), worldX)\n );\n\n // Invert the world y axis if the provided normal is more than 90 degrees from it\n // to compute a proper angle to rotate the view vector by\n const worldY =\n Vector3.angleTo(normal, positiveWorldY) > Math.PI / 2\n ? Vector3.negate(positiveWorldY)\n : positiveWorldY;\n const localX = Vector3.isEqual(worldY, normal)\n ? worldX\n : Vector3.normalize(Vector3.cross(worldY, normal));\n\n const transformedViewVector = Vector3.transformMatrix(\n this.viewVector,\n Matrix4.makeRotation(\n Quaternion.fromAxisAngle(localX, Vector3.angleTo(normal, worldY))\n )\n );\n const lookAtRay = Ray.create({\n origin: position,\n direction: Vector3.normalize(transformedViewVector),\n });\n const lookAt = Ray.at(lookAtRay, Vector3.magnitude(this.viewVector));\n\n return this.update({\n position,\n lookAt,\n up: normal,\n });\n }\n\n /**\n * Updates the `position` and `up` vectors of the camera to the given standard\n * view, and sets the `lookAt` point to the origin.\n *\n * @see {@link StandardView} for the available standard views.\n *\n * @param standardView The standard view to apply.\n * @returns A new camera.\n */\n public standardView(standardView: StandardView): Camera {\n return this.update({\n position: standardView.position,\n viewVector: Vector3.subtract(Vector3.origin(), standardView.position),\n lookAt: Vector3.origin(),\n up: standardView.up,\n });\n }\n\n /**\n * Updates the `position` and `up` vectors of the camera to the given standard\n * view, maintaining the existing `lookAt` point.\n *\n * @see {@link StandardView} for the available standard views.\n *\n * @param standardView The standard view to apply.\n * @returns A new camera.\n */\n public standardViewFixedLookAt(standardView: StandardView): Camera {\n const standardViewRay = Ray.create({\n origin: this.lookAt,\n direction: Vector3.normalize(standardView.position),\n });\n const updatedPosition = Ray.at(\n standardViewRay,\n Vector3.magnitude(this.viewVector)\n );\n\n return this.update({\n up: standardView.up,\n position: updatedPosition,\n viewVector: Vector3.subtract(this.lookAt, updatedPosition),\n });\n }\n\n private buildFlyToType(options: FlyToParams): FlyTo.FlyToType {\n if (options.boundingBox != null) {\n return { type: 'bounding-box', data: options.boundingBox };\n } else if (options.camera != null) {\n return { type: 'camera', data: options.camera };\n } else if (options.itemId != null) {\n return { type: 'internal', data: options.itemId };\n } else if (options.itemSuppliedId != null) {\n return { type: 'supplied', data: options.itemSuppliedId };\n } else {\n throw new Error('Fly to must specify at least one option.');\n }\n }\n\n protected computeClippingPlanes(\n camera: FrameCamera.FrameCamera\n ): ClippingPlanes.ClippingPlanes {\n return ClippingPlanes.fromBoundingBoxAndLookAtCamera(\n this.boundingBox,\n camera\n );\n }\n\n /**\n * Repositions the camera by rotating its current position around an axis\n * defined at a specific world point.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n *\n * viewer.addEventListener('tap', async (event) => {\n * const scene = await viewer.scene();\n * const raycaster = scene.raycaster();\n *\n * const [hit] = await raycaster.hitItems(event.detail.position);\n *\n * if (hit != null) {\n * const camera = scene.camera();\n *\n * // Using the current `up` vector of the camera, rotate 45 degrees\n * // about the hit position with an animation of 1 second\n * await camera.rotateAroundAxisAtPoint(\n * Angle.toRadians(45),\n * hit.hitPoint,\n * camera.up,\n * ).render({ animation: { milliseconds: 1000 } });\n * }\n * });\n * ```\n *\n * @param angleInRadians The angle, in radians, to rotate.\n * @param point The point in world space to place the axis at.\n * @param axis A normalized vector to rotate around.\n */\n public abstract rotateAroundAxisAtPoint(\n angleInRadians: number,\n point: Vector3.Vector3,\n axis: Vector3.Vector3\n ): Camera;\n\n public abstract get position(): Vector3.Vector3;\n public abstract get lookAt(): Vector3.Vector3;\n public abstract get up(): Vector3.Vector3;\n public abstract get near(): number;\n public abstract get far(): number;\n public abstract get aspectRatio(): number;\n public abstract get viewVector(): Vector3.Vector3;\n\n /**\n * Shifts the position of the camera by the given delta.\n *\n * @param delta The number of units to shift the camera on the X, Y, and Z\n * axis.\n */\n public abstract moveBy(delta: Vector3.Vector3): Camera;\n\n /**\n * Updates the `position`, `lookAt` and/or `up` vectors of the camera. Each\n * vector can be omitted in the payload, and the resulting camera will keep\n * the previous `position`, `lookAt`, or `up` vectors.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector(\"vertex-viewer\");\n * const scene = await viewer.scene();\n * const camera = scene.camera();\n *\n * // Update the camera to place it at the origin\n * await camera\n * .update({\n * position: {\n * x: 0,\n * y: 0,\n * z: 0,\n * },\n * })\n * .render({ animation: { milliseconds: 1000 } });\n *\n * // Update the camera to look at the origin\n * await camera\n * .update({\n * lookAt: {\n * x: 0,\n * y: 0,\n * z: 0,\n * },\n * })\n * .render({ animation: { milliseconds: 1000 } });\n * ```\n *\n * @param camera The values to update the camera to.\n */\n public abstract update(camera: Partial<FrameCamera.FrameCamera>): Camera;\n\n /**\n * Returns a `FrameCameraBase` representation.\n */\n public abstract toFrameCamera(): FrameCameraBase;\n\n protected abstract updateFlyToOptions(\n flyToOptions?: FlyTo.FlyToOptions\n ): Camera;\n}\n\nexport class PerspectiveCamera\n extends Camera\n implements FrameCamera.PerspectiveFrameCamera\n{\n public constructor(\n stream: StreamApi,\n aspect: number,\n private perspectiveData: FrameCamera.PerspectiveFrameCamera,\n boundingBox: BoundingBox.BoundingBox,\n decodeFrame: FrameDecoder,\n flyToOptions?: FlyTo.FlyToOptions\n ) {\n super(\n stream,\n aspect,\n perspectiveData,\n boundingBox,\n decodeFrame,\n flyToOptions\n );\n }\n\n /**\n * Shifts the position of the camera by the given delta.\n *\n * @param delta The number of units to shift the camera on the X, Y, and Z\n * axis.\n */\n public moveBy(delta: Vector3.Vector3): Camera {\n return this.update({\n position: Vector3.add(this.position, delta),\n lookAt: Vector3.add(this.lookAt, delta),\n });\n }\n\n public rotateAroundAxisAtPoint(\n angleInRadians: number,\n point: Vector3.Vector3,\n axis: Vector3.Vector3\n ): Camera {\n return this.update({\n position: Vector3.rotateAboutAxis(\n angleInRadians,\n this.position,\n axis,\n point\n ),\n lookAt: Vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point),\n up: Vector3.rotateAboutAxis(\n angleInRadians,\n this.up,\n axis,\n Vector3.origin()\n ),\n });\n }\n\n public update(camera: Partial<FrameCamera.PerspectiveFrameCamera>): Camera {\n const fovY = camera.fovY ?? this.fovY;\n return new PerspectiveCamera(\n this.stream,\n this.aspect,\n { ...this.perspectiveData, ...camera, fovY },\n this.boundingBox,\n this.decodeFrame,\n this.flyToOptions\n );\n }\n\n public toFrameCamera(): FramePerspectiveCamera {\n return new FramePerspectiveCamera(\n this.position,\n this.lookAt,\n this.up,\n this.near,\n this.far,\n this.aspectRatio,\n this.fovY ?? 45\n );\n }\n\n public get viewVector(): Vector3.Vector3 {\n return Vector3.subtract(this.lookAt, this.position);\n }\n\n /**\n * The position vector for the camera, in world space coordinates.\n */\n public get position(): Vector3.Vector3 {\n return { ...this.perspectiveData.position };\n }\n\n /**\n * A normalized vector representing the up direction.\n */\n public get up(): Vector3.Vector3 {\n return { ...this.perspectiveData.up };\n }\n\n /**\n * A vector, in world space coordinates, of where the camera is pointed at.\n */\n public get lookAt(): Vector3.Vector3 {\n return { ...this.perspectiveData.lookAt };\n }\n\n /**\n * The camera's field of view.\n */\n public get fovY(): number | undefined {\n return this.perspectiveData.fovY;\n }\n\n /**\n * The aspect ratio of the camera.\n */\n public get aspectRatio(): number {\n return this.aspect;\n }\n\n /**\n * The camera's near clipping plane.\n */\n public get near(): number {\n const { near } = this.computeClippingPlanes(this.perspectiveData);\n return near;\n }\n\n /**\n * The camera's far clipping plane.\n */\n public get far(): number {\n const { far } = this.computeClippingPlanes(this.perspectiveData);\n return far;\n }\n\n protected updateFlyToOptions(\n flyToOptions?: FlyTo.FlyToOptions\n ): PerspectiveCamera {\n return new PerspectiveCamera(\n this.stream,\n this.aspect,\n this.perspectiveData,\n this.boundingBox,\n this.decodeFrame,\n flyToOptions\n );\n }\n}\n\nexport class OrthographicCamera\n extends Camera\n implements FrameCamera.OrthographicFrameCamera\n{\n public constructor(\n stream: StreamApi,\n aspect: number,\n private orthographicData: FrameCamera.OrthographicFrameCamera,\n boundingBox: BoundingBox.BoundingBox,\n decodeFrame: FrameDecoder,\n flyToOptions?: FlyTo.FlyToOptions\n ) {\n super(\n stream,\n aspect,\n orthographicData,\n boundingBox,\n decodeFrame,\n flyToOptions\n );\n }\n\n /**\n * Shifts the position of the camera by the given delta.\n *\n * @param delta The number of units to shift the camera on the X, Y, and Z\n * axis.\n */\n public moveBy(delta: Vector3.Vector3): Camera {\n // The rotation point should match the lookAt point when panning\n const updatedPoint = Vector3.add(this.lookAt, delta);\n return this.update({\n lookAt: updatedPoint,\n rotationPoint: updatedPoint,\n });\n }\n\n public rotateAroundAxisAtPoint(\n angleInRadians: number,\n point: Vector3.Vector3,\n axis: Vector3.Vector3\n ): Camera {\n const updatedLookAt = Vector3.rotateAboutAxis(\n angleInRadians,\n this.lookAt,\n axis,\n point\n );\n const updatedPosition = Vector3.rotateAboutAxis(\n angleInRadians,\n this.position,\n axis,\n point\n );\n const viewVector = constrainViewVector(\n Vector3.subtract(updatedLookAt, updatedPosition),\n BoundingSphere.create(this.boundingBox)\n );\n\n return this.update({\n viewVector: viewVector,\n lookAt: updatedLookAt,\n up: Vector3.rotateAboutAxis(\n angleInRadians,\n this.up,\n axis,\n Vector3.origin()\n ),\n });\n }\n\n public update(camera: Partial<FrameCamera.FrameCamera>): Camera {\n return new OrthographicCamera(\n this.stream,\n this.aspect,\n { ...this.orthographicData, ...camera },\n this.boundingBox,\n this.decodeFrame,\n this.flyToOptions\n );\n }\n\n public toFrameCamera(): FrameOrthographicCamera {\n const boundingSphere = BoundingSphere.create(this.boundingBox);\n const viewVector = constrainViewVector(this.viewVector, boundingSphere);\n const lookAt = updateLookAtRelativeToBoundingBoxCenter(\n this.lookAt,\n viewVector,\n boundingSphere.center\n );\n\n return new FrameOrthographicCamera(\n viewVector,\n lookAt,\n this.up,\n this.near,\n this.far,\n this.aspectRatio,\n this.fovHeight,\n this.rotationPoint\n );\n }\n\n public get viewVector(): Vector3.Vector3 {\n return { ...this.orthographicData.viewVector };\n }\n\n public get position(): Vector3.Vector3 {\n return Vector3.add(this.lookAt, Vector3.negate(this.viewVector));\n }\n\n /**\n * A vector, in world space coordinates, of where the camera should be rotated around.\n * Most interactions (like pan and zoom) will update lookAt and rotationPoint to be the same point.\n * However, rotation interactions will only update lookAt and not rotationPoint.\n */\n public get rotationPoint(): Vector3.Vector3 | undefined {\n const rotationPoint = this.orthographicData.rotationPoint;\n if (rotationPoint != null) {\n return rotationPoint;\n } else {\n return undefined;\n }\n }\n\n /**\n * A normalized vector representing the up direction.\n */\n public get up(): Vector3.Vector3 {\n return { ...this.orthographicData.up };\n }\n\n /**\n * A vector, in world space coordinates, of where the camera is pointed at.\n */\n public get lookAt(): Vector3.Vector3 {\n return { ...this.orthographicData.lookAt };\n }\n\n /**\n * The camera's field of view.\n */\n public get fovHeight(): number {\n return this.orthographicData.fovHeight;\n }\n\n /**\n * The aspect ratio of the camera.\n */\n public get aspectRatio(): number {\n return this.aspect;\n }\n\n /**\n * The camera's near clipping plane.\n */\n public get near(): number {\n const { near } = this.computeClippingPlanes(this.orthographicData);\n return near;\n }\n\n /**\n * The camera's far clipping plane.\n */\n public get far(): number {\n const { far } = this.computeClippingPlanes(this.orthographicData);\n return far;\n }\n\n protected updateFlyToOptions(\n flyToOptions?: FlyTo.FlyToOptions\n ): OrthographicCamera {\n return new OrthographicCamera(\n this.stream,\n this.aspect,\n this.orthographicData,\n this.boundingBox,\n this.decodeFrame,\n flyToOptions\n );\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { StreamApi } from '@vertexvis/stream-api';\n\nimport { CrossSectioning } from '../types';\n\n/**\n * The `CrossSectioner` class is here.\n */\nexport class CrossSectioner {\n public constructor(\n private stream: StreamApi,\n private data: CrossSectioning.CrossSectioning\n ) {}\n\n /**\n * Performs request on the stream to update the cross sectioning config.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector(\"vertex-viewer\");\n * const scene = await viewer.scene();\n * const crossSectioner = scene.crossSectioning();\n *\n * await scene.crossSectioning().update({\n * sectionPlanes: [\n * {\n * normal: {\n * x: 1,\n * y: 0,\n * z: 0,\n * },\n * offset: 0,\n * },\n * ],\n * highlightColor: Color.fromHexString(\"#ff0000\"),\n * lineWidth: 0.5,\n * });\n * ```\n *\n * @see {@link SectionPlane} for more information on the section planes.\n *\n * @see {@link CrossSectioning} for more information on the highlight color and\n * line width.\n *\n * @param crossSectioning The new cross sectioning.\n */\n public async update(\n crossSectioning: CrossSectioning.CrossSectioning\n ): Promise<\n vertexvis.protobuf.stream.IUpdateCrossSectioningResult | undefined\n > {\n const res = await this.stream.updateCrossSectioning(\n {\n crossSectioning: {\n sectionPlanes: crossSectioning.sectionPlanes,\n highlightColor: crossSectioning.highlightColor,\n lineWidth:\n crossSectioning?.lineWidth != null\n ? { value: crossSectioning.lineWidth }\n : null,\n },\n },\n true\n );\n\n return res.updateCrossSectioning || undefined;\n }\n\n public current(): CrossSectioning.CrossSectioning {\n return this.data;\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { UUID } from '@vertexvis/utils';\n\nimport { ColorMaterial } from './colorMaterial';\n\nexport type RepresentationId = UUID.UUID | 'empty' | 'entire-part';\n\ninterface ShowItemOperation {\n type: 'show';\n}\n\ninterface HideItemOperation {\n type: 'hide';\n}\n\ninterface SelectItemOperation {\n type: 'select';\n}\n\ninterface DeselectItemOperation {\n type: 'deselect';\n}\n\ninterface ClearItemOperation {\n type: 'clear-override';\n}\n\nexport interface ChangeMaterialOperation {\n type: 'change-material';\n material: ColorMaterial;\n}\n\nexport interface TransformOperation {\n type: 'change-transform';\n transform: vertexvis.protobuf.core.IMatrix4x4f;\n}\n\nexport interface ClearTransformOperation {\n type: 'clear-transform';\n cascade?: boolean;\n}\n\nexport interface ChangePhantomOperation {\n type: 'change-phantom';\n phantomState?: boolean;\n}\n\ninterface ClearPhantomOperation {\n type: 'clear-phantom';\n}\n\nexport interface ChangeEndItemOperation {\n type: 'change-end-item';\n endItemState?: boolean;\n}\n\ninterface ClearEndItemOperation {\n type: 'clear-end-item';\n}\n\ninterface ViewRenditionById {\n type: 'view-rendition-by-id';\n id: UUID.UUID;\n}\n\ninterface ViewRenditionBySuppliedId {\n type: 'view-rendition-by-supplied-id';\n suppliedId: string;\n}\n\ninterface ViewDefaultRendition {\n type: 'view-default-rendition';\n}\n\ninterface ClearRendition {\n type: 'clear-rendition';\n}\n\ninterface ViewRepresentation {\n type: 'view-representation';\n id: RepresentationId;\n}\n\ninterface ClearRepresentation {\n type: 'clear-representation';\n}\n\nexport type ItemOperation =\n | ShowItemOperation\n | HideItemOperation\n | SelectItemOperation\n | DeselectItemOperation\n | ChangeMaterialOperation\n | ClearItemOperation\n | TransformOperation\n | ClearTransformOperation\n | ChangePhantomOperation\n | ClearPhantomOperation\n | ChangeEndItemOperation\n | ClearEndItemOperation\n | ViewRenditionById\n | ViewRenditionBySuppliedId\n | ViewDefaultRendition\n | ClearRendition\n | ViewRepresentation\n | ClearRepresentation;\n\nexport interface SceneItemOperations<T> {\n materialOverride(color: ColorMaterial): T;\n show(): T;\n hide(): T;\n select(color: ColorMaterial): T;\n deselect(): T;\n clearMaterialOverrides(): T;\n clearTransforms(): T;\n setPhantom(phantomState?: boolean): T;\n clearPhantom(): T;\n setEndItem(endItemState?: boolean): T;\n clearEndItem(): T;\n viewRenditionById(id: UUID.UUID): T;\n viewRenditionBySuppliedId(id: string): T;\n viewDefaultRendition(): T;\n clearRendition(): T;\n viewRepresentation(id: RepresentationId): T;\n clearRepresentation(): T;\n}\n\n/**\n * A class to handle the building of operations for a scene.\n */\nexport class SceneOperationBuilder\n implements SceneItemOperations<SceneOperationBuilder>\n{\n public constructor(private operations: ItemOperation[] = []) {}\n\n /**\n * Constructs the scene operations and returns a definition describing each\n * operation.\n */\n public build(): ItemOperation[] {\n return this.operations.concat();\n }\n\n public materialOverride(material: ColorMaterial): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'change-material', material }])\n );\n }\n\n public show(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'show' }])\n );\n }\n\n public hide(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'hide' }])\n );\n }\n\n public select(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'select' }])\n );\n }\n\n public deselect(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'deselect' }])\n );\n }\n\n public clearMaterialOverrides(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'clear-override' }])\n );\n }\n\n public transform(\n matrix: vertexvis.protobuf.core.IMatrix4x4f\n ): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'change-transform', transform: matrix }])\n );\n }\n\n public clearTransforms(cascade = true): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'clear-transform', cascade }])\n );\n }\n\n public setPhantom(phantomState?: boolean): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'change-phantom', phantomState }])\n );\n }\n\n public clearPhantom(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'clear-phantom' }])\n );\n }\n\n public setEndItem(endItemState?: boolean): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'change-end-item', endItemState }])\n );\n }\n\n public clearEndItem(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'clear-end-item' }])\n );\n }\n\n public viewRenditionById(id: UUID.UUID): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'view-rendition-by-id', id }])\n );\n }\n\n public viewRenditionBySuppliedId(suppliedId: string): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([\n { type: 'view-rendition-by-supplied-id', suppliedId },\n ])\n );\n }\n\n public viewDefaultRendition(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'view-default-rendition' }])\n );\n }\n\n public clearRendition(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat([{ type: 'clear-rendition' }])\n );\n }\n\n public viewRepresentation(id: RepresentationId): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat({ type: 'view-representation', id })\n );\n }\n\n public clearRepresentation(): SceneOperationBuilder {\n return new SceneOperationBuilder(\n this.operations.concat({ type: 'clear-representation' })\n );\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { Point } from '@vertexvis/geometry';\nimport { StreamApi } from '@vertexvis/stream-api';\n\nimport { ImageScaleProvider } from './scene';\n\n/**\n * Optional raycaster options available on a hit request.\n */\nexport interface RaycasterOptions {\n includeMetadata: boolean;\n}\n\nexport interface RaycasterLike {\n hitItems(\n point: Point.Point,\n options?: RaycasterOptions\n ): Promise<vertexvis.protobuf.stream.IHitItemsResult | undefined>;\n}\n\n/**\n * The `Raycaster` class is here.\n */\nexport class Raycaster implements RaycasterLike {\n public constructor(\n private stream: StreamApi,\n private imageScaleProvider: ImageScaleProvider\n ) {}\n\n /**\n * Performs request on the stream to find items that intersect\n * the given point.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector(\"vertex-viewer\");\n *\n * viewer.addEventListener(\"tap\", async (event) => {\n * const scene = await viewer.scene();\n * const raycaster = scene.raycaster();\n *\n * // Query the scene for the item at the position of the `tap` event\n * const [hit] = await raycaster.hitItems(event.detail.position);\n *\n * if (hit != null) {\n * // If there was an item present at the position, select it\n * await scene.items((op) =>\n * op.where((q) => q.withItemId(hit.itemId.hex)).select()\n * );\n * }\n * });\n * ```\n *\n * @see {@link Scene.items} for more information on the operations that\n * can be performed on a hit result.\n *\n * @param point The point to cast from looking for intersections.\n * @param options Optional set of options for the request @see {@link RaycasterOptions}\n * for available options.\n */\n public async hitItems(\n point: Point.Point,\n options?: RaycasterOptions\n ): Promise<vertexvis.protobuf.stream.IHitItemsResult | undefined> {\n const scale = this.imageScaleProvider();\n const res = await this.stream.hitItems(\n {\n point: Point.scale(point, scale?.x || 1, scale?.y || 1),\n includeMetadata: options?.includeMetadata,\n },\n true\n );\n return res.hitItems || undefined;\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { StreamApi, toProtoDuration } from '@vertexvis/stream-api';\nimport { UUID } from '@vertexvis/utils';\n\nimport { FrameDecoder } from '../mappers';\nimport { DEFAULT_TIMEOUT_IN_MS } from '../stream/dispatcher';\nimport { SceneViewStateIdentifier } from '../types';\nimport { ApplySceneViewStateOptions, SceneViewStateFeature } from '.';\nimport { CameraRenderResult } from './cameraRenderResult';\nimport {\n buildSceneViewStateIdentifier,\n toPbSceneViewStateFeatures,\n} from './mapper';\n\nexport class SceneViewStateLoader {\n public constructor(\n private stream: StreamApi,\n private decodeFrame: FrameDecoder,\n public readonly sceneId: UUID.UUID,\n public readonly sceneViewId: UUID.UUID\n ) {}\n\n public async applySceneViewState(\n sceneViewStateId:\n | UUID.UUID\n | SceneViewStateIdentifier.SceneViewStateIdentifier,\n opts: ApplySceneViewStateOptions = {}\n ): Promise<vertexvis.protobuf.stream.ILoadSceneViewStateResult | undefined> {\n const pbIdField = buildSceneViewStateIdentifier(sceneViewStateId);\n\n await this.animateToSceneViewState(pbIdField, opts);\n\n return await this.stream.loadSceneViewState(\n {\n ...pbIdField,\n frameCorrelationId: opts.suppliedCorrelationId\n ? { value: opts.suppliedCorrelationId }\n : undefined,\n },\n true\n );\n }\n\n public async applyPartialSceneViewState(\n sceneViewStateId:\n | UUID.UUID\n | SceneViewStateIdentifier.SceneViewStateIdentifier,\n featuresToApply: SceneViewStateFeature[],\n opts: ApplySceneViewStateOptions = {}\n ): Promise<vertexvis.protobuf.stream.ILoadSceneViewStateResult | undefined> {\n const pbIdField = buildSceneViewStateIdentifier(sceneViewStateId);\n const pbFeatures = toPbSceneViewStateFeatures(featuresToApply);\n\n if (featuresToApply.includes('camera')) {\n await this.animateToSceneViewState(pbIdField, opts);\n }\n\n return await this.stream.loadSceneViewState(\n {\n ...pbIdField,\n frameCorrelationId: opts.suppliedCorrelationId\n ? { value: opts.suppliedCorrelationId }\n : undefined,\n sceneViewStateFeatureSubset: pbFeatures,\n },\n true\n );\n }\n\n private async animateToSceneViewState(\n identifier:\n | Pick<\n vertexvis.protobuf.stream.ILoadSceneViewStatePayload,\n 'sceneViewStateId'\n >\n | Pick<\n vertexvis.protobuf.stream.ILoadSceneViewStatePayload,\n 'sceneViewStateSuppliedId'\n >,\n opts: ApplySceneViewStateOptions\n ): Promise<void> {\n if (opts.animation != null) {\n const corrId = UUID.create();\n\n const flyToResult = await this.stream.flyTo(\n {\n sceneViewStateIdentifier: identifier,\n animation: {\n duration: toProtoDuration(opts.animation.milliseconds),\n },\n frameCorrelationId: {\n value: corrId,\n },\n },\n true\n );\n\n if (opts.waitForAnimation == null || opts.waitForAnimation) {\n const renderResult = new CameraRenderResult(\n this.stream,\n this.decodeFrame,\n {\n animationId: flyToResult.flyTo?.animationId?.hex ?? undefined,\n correlationId: corrId,\n },\n opts.animation.milliseconds + DEFAULT_TIMEOUT_IN_MS\n );\n\n await renderResult.onAnimationCompleted.once();\n }\n }\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { BoundingBox, Dimensions, Point } from '@vertexvis/geometry';\nimport { StreamApi } from '@vertexvis/stream-api';\nimport { UUID } from '@vertexvis/utils';\n\nimport { InvalidArgumentError, InvalidCameraError } from '../errors';\nimport { FrameDecoder } from '../mappers';\nimport { SceneViewStateIdentifier } from '../types';\nimport { Frame } from '../types/frame';\nimport {\n Camera,\n CameraRenderOptions,\n OrthographicCamera,\n PerspectiveCamera,\n} from '.';\nimport { ColorMaterial, fromHex } from './colorMaterial';\nimport { CrossSectioner } from './crossSectioner';\nimport { buildSceneOperation } from './mapper';\nimport {\n ItemOperation,\n RepresentationId,\n SceneItemOperations,\n SceneOperationBuilder,\n} from './operations';\nimport { QueryExpression, SceneItemQueryExecutor } from './queries';\nimport { Raycaster } from './raycaster';\nimport { SceneViewStateLoader } from './sceneViewStateLoader';\n\nexport interface SceneExecutionOptions {\n suppliedCorrelationId?: string;\n}\n\nexport interface ApplySceneViewStateOptions\n extends SceneExecutionOptions,\n CameraRenderOptions {\n waitForAnimation?: boolean;\n}\n\nexport interface ResetViewOptions {\n includeCamera?: boolean;\n suppliedCorrelationId?: string;\n}\n\n/**\n * A class that is responsible for building operations for a specific scene.\n * This executor requires a query, and expects `execute()` to be invoked in\n * order for the changes to take effect.\n */\nexport class SceneItemOperationsBuilder\n implements SceneItemOperations<SceneItemOperationsBuilder>\n{\n private builder: SceneOperationBuilder;\n\n public constructor(\n private query: QueryExpression,\n givenBuilder?: SceneOperationBuilder\n ) {\n this.builder =\n givenBuilder != null ? givenBuilder : new SceneOperationBuilder();\n }\n\n /**\n * Specifies that the items matching the query should have their default\n * material overridden to match the specified material.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Override the material for the item with the `item-uuid` ID to\n * // be red with an opacity of 0.5.\n * await scene.items((op) => [\n * op\n * .where((q) => q.withItemId('item-uuid'))\n * .materialOverride(ColorMaterial.create(255, 0, 0, 0.5)),\n * ]);\n *\n * // Override the material for the item with the `item-uuid` ID to\n * // be red with an opacity of 1.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).materialOverride('#ff0000'),\n * ]).execute();\n * ```\n */\n public materialOverride(\n color: ColorMaterial | string\n ): SceneItemOperationsBuilder {\n if (typeof color === 'string') {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.materialOverride(fromHex(color))\n );\n } else {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.materialOverride(color)\n );\n }\n }\n\n /**\n * Specifies that the items matching the query should be hidden.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).hide(),\n * ]).execute();\n * ```\n */\n public hide(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(this.query, this.builder.hide());\n }\n\n /**\n * Specifies that the items matching the query should be shown.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Show the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).show(),\n * ]).execute();\n * ```\n */\n public show(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(this.query, this.builder.show());\n }\n\n /**\n * Specifies that the items matching the query should be selected.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Select the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).select(),\n * ]).execute();\n * ```\n */\n public select(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(this.query, this.builder.select());\n }\n\n /**\n * Specifies that the items matching the query should be deselected.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Deselect the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).deselect(),\n * ]).execute();\n * ```\n */\n public deselect(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(this.query, this.builder.deselect());\n }\n\n /**\n * Specifies that the items matching the query should have any overridden\n * material removed.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Clear the overridden material on the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearMaterialOverrides(),\n * ]);\n * ```\n */\n public clearMaterialOverrides(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.clearMaterialOverrides()\n );\n }\n\n /**\n * Specifies that the items matching the query should have their\n * transformation matrix overridden to match the specified transformation\n * matrix.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Override the transformation matrix for the item with the `item-uuid` ID to\n * // move the element along the x-axis\n * await scene.items((op) => [\n * op\n * .where((q) => q.withItemId('item-uuid'))\n * .transform(Matrix4.makeTranslation(Vector3.create(100, 0, 0))),\n * ]);\n * ```\n */\n public transform(\n matrix: vertexvis.protobuf.core.IMatrix4x4f | number[]\n ): SceneItemOperationsBuilder {\n if (Array.isArray(matrix)) {\n if (matrix.length !== 16) {\n throw new InvalidArgumentError(\n 'Matrix provided must contain exactly 16 values (4x4).'\n );\n }\n\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.transform({\n r0: {\n x: matrix[0],\n y: matrix[1],\n z: matrix[2],\n w: matrix[3],\n },\n r1: {\n x: matrix[4],\n y: matrix[5],\n z: matrix[6],\n w: matrix[7],\n },\n r2: {\n x: matrix[8],\n y: matrix[9],\n z: matrix[10],\n w: matrix[11],\n },\n r3: {\n x: matrix[12],\n y: matrix[13],\n z: matrix[14],\n w: matrix[15],\n },\n })\n );\n } else {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.transform(matrix)\n );\n }\n }\n\n /**\n * Specifies that the items matching the query should have their overridden\n * transformation matrix removed. The `cascade` flag determines whether\n * children of the items matching the query should also have their overridden\n * transformation matrix removed, and defaults to `true`.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Clear the overridden the transformation matrix for the item with the `item-uuid` ID\n * // and do not cascade to preserve transformations on children\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearTransforms(false),\n * ]);\n *\n * // Clear the overridden the transformation matrix for the item with the `item-uuid` ID\n * // and cascade to clear overridden transformations on children\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearTransforms(true),\n * ]);\n * ```\n */\n public clearTransforms(cascade = true): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.clearTransforms(cascade)\n );\n }\n\n /**\n * Specifies that the items matching the query should have their phantom state\n * overridden to match the specified `phantomState` flag. If the\n * `phantomState` flag is not provided, it will default to `true`.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Mark the item with the `item-uuid` ID as phantom\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).setPhantom(true),\n * ]);\n *\n * // Unmark the item with the `item-uuid` ID as phantom\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).setPhantom(false),\n * ]);\n * ```\n */\n public setPhantom(phantomState?: boolean): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.setPhantom(phantomState)\n );\n }\n\n /**\n * Specifies that the items matching the query should have their overridden\n * phantom state removed.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Clear the overridden phantom state of the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearPhantom(),\n * ]);\n * ```\n */\n public clearPhantom(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.clearPhantom()\n );\n }\n\n /**\n * Specifies that the items matching the query should have their end item\n * state overridden to match the specified `endItemState` flag. If the\n * `endItemState` flag is not provided, it will default to `true`.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Mark the item with the `item-uuid` ID as an end item\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).setEndItem(true),\n * ]);\n *\n * // Unmark the item with the `item-uuid` ID as an end item\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).setEndItem(false),\n * ]);\n * ```\n *\n * @remarks\n * End item states do not propagate to children similar to other states like\n * other operations. I.e. calling setEndItem(false) on an item will cause it\n * to be unmarked as an end item, but any children where setEndItem(true) was\n * called previously will remain as end items.\n */\n public setEndItem(endItemState?: boolean): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.setEndItem(endItemState)\n );\n }\n\n /**\n * Specifies that the items matching the query should have their overridden\n * end item state removed.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Clear the overridden end item state of the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearEndItem(),\n * ]);\n * ```\n */\n public clearEndItem(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.clearEndItem()\n );\n }\n\n /**\n * Changes the rendition of an item matching the query. This operation only\n * applies to items that reference a revision that contains the given\n * rendition.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Switch the rendition of the matching item.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).viewRenditionById('rendition-uuid'),\n * ]);\n * ```\n */\n public viewRenditionById(id: UUID.UUID): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.viewRenditionById(id)\n );\n }\n\n /**\n * Changes the rendition of any item matching the query that contains a\n * rendition with the given supplied ID. This operation only applies to items\n * that reference a revision that contain a rendition with a matching supplied\n * ID.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Switch the rendition of the given item.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).viewRenditionBySuppliedId('rendition-supplied-id'),\n * ]);\n * ```\n */\n public viewRenditionBySuppliedId(\n suppliedId: string\n ): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.viewRenditionBySuppliedId(suppliedId)\n );\n }\n\n /**\n * Changes the rendition of items matching the query back to their revision's\n * default rendition. This operation only applies to items that reference a\n * revision.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Switch the rendition of the given item.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).viewDefaultRendition(),\n * ]);\n * ```\n */\n public viewDefaultRendition(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.viewDefaultRendition()\n );\n }\n\n /**\n * Clears the rendition of items matching the query, which will revert the\n * item back to the rendition used when creating the item.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Switch the rendition of the given item.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearRendition(),\n * ]);\n * ```\n */\n public clearRendition(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.clearRendition()\n );\n }\n\n /**\n * Changes the representation of items matching a query. This operation only\n * applies to items that reference a rendition with the given representation\n * ID.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Switch the rendition of the given item.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).viewRepresentation('rep-id'),\n * ]);\n * ```\n */\n public viewRepresentation(id: RepresentationId): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.viewRepresentation(id)\n );\n }\n\n /**\n * Clears the representation for items matching the query.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Switch the rendition of the given item.\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).clearRepresentation(),\n * ]);\n * ```\n */\n public clearRepresentation(): SceneItemOperationsBuilder {\n return new SceneItemOperationsBuilder(\n this.query,\n this.builder.clearRepresentation()\n );\n }\n\n /**\n * @internal\n */\n public build(): QueryOperation {\n return {\n query: this.query,\n operations: this.builder.build(),\n };\n }\n}\n\nexport interface QueryOperation {\n query: QueryExpression;\n operations: ItemOperation[];\n}\n\nexport class ItemsOperationExecutor {\n public constructor(\n private sceneViewId: UUID.UUID,\n private stream: StreamApi,\n private dimensions: Dimensions.Dimensions,\n private queryOperations: QueryOperation[]\n ) {}\n\n public async execute(\n executionOptions?: SceneExecutionOptions\n ): Promise<void> {\n const pbOperations = this.queryOperations.map((op) =>\n buildSceneOperation(op.query, op.operations, {\n dimensions: this.dimensions,\n })\n );\n const request = {\n sceneViewId: {\n hex: this.sceneViewId,\n },\n operations: pbOperations,\n suppliedCorrelationId:\n executionOptions?.suppliedCorrelationId != null\n ? {\n value: executionOptions?.suppliedCorrelationId,\n }\n : undefined,\n };\n\n await this.stream.createSceneAlteration(request);\n }\n}\n\nexport type TerminalItemOperationBuilder =\n | SceneItemOperationsBuilder\n | SceneItemOperationsBuilder[];\n\nexport type ImageScaleProvider = () => Point.Point | undefined;\n\n/**\n * The features of a scene view state that can be applied to the current scene\n */\nexport type SceneViewStateFeature =\n | 'camera'\n | 'cross_section'\n | 'material_overrides'\n | 'selection'\n | 'transforms'\n | 'visibility'\n | 'phantom';\n\n/**\n * A class that represents the `Scene` that has been loaded into the viewer. On\n * it, you can retrieve attributes of the scene, such as the camera. It also\n * contains methods for updating the scene and performing requests to rerender\n * the scene.\n */\nexport class Scene {\n private sceneViewStateLoader: SceneViewStateLoader;\n\n public constructor(\n private stream: StreamApi,\n private frame: Frame,\n private decodeFrame: FrameDecoder,\n private imageScaleProvider: ImageScaleProvider,\n private dimensions: Dimensions.Dimensions,\n public readonly sceneId: UUID.UUID,\n public readonly sceneViewId: UUID.UUID\n ) {\n this.sceneViewStateLoader = new SceneViewStateLoader(\n stream,\n decodeFrame,\n sceneId,\n sceneViewId\n );\n }\n\n /**\n * Applies the provided scene view state to the scene.\n */\n public async applySceneViewState(\n sceneViewStateId:\n | UUID.UUID\n | SceneViewStateIdentifier.SceneViewStateIdentifier,\n opts: ApplySceneViewStateOptions = {}\n ): Promise<vertexvis.protobuf.stream.ILoadSceneViewStateResult | undefined> {\n return await this.sceneViewStateLoader.applySceneViewState(\n sceneViewStateId,\n opts\n );\n }\n\n /**\n * Applies the specified features of the provided scene view state to the scene.\n */\n public async applyPartialSceneViewState(\n sceneViewStateId:\n | UUID.UUID\n | SceneViewStateIdentifier.SceneViewStateIdentifier,\n featuresToApply: SceneViewStateFeature[],\n opts: ApplySceneViewStateOptions = {}\n ): Promise<vertexvis.protobuf.stream.ILoadSceneViewStateResult | undefined> {\n return await this.sceneViewStateLoader.applyPartialSceneViewState(\n sceneViewStateId,\n featuresToApply,\n opts\n );\n }\n\n /**\n * Resets the view to its default state, with the ability to reset the camera to that of the base scene.\n */\n public async reset(\n opts: ResetViewOptions = {}\n ): Promise<vertexvis.protobuf.stream.IResetViewResult | undefined> {\n return await this.stream.resetSceneView(\n {\n includeCamera: opts.includeCamera,\n frameCorrelationId: opts.suppliedCorrelationId\n ? { value: opts.suppliedCorrelationId }\n : undefined,\n },\n true\n );\n }\n\n /**\n * Returns an executor that accepts a function as a parameter that contains one or many operations to apply\n * to the scene view. The operations will be applied transactionally.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Deselect everything, then select a specific item by ID\n * await scene.items(op => [\n * op.where(q => q.all()).deselect(),\n * op.where(q => q.withItemId('item-id')).select(),\n * ]).execute();\n * ```\n *\n * @see {@link RootQuery} for more information on available queries.\n *\n * @see {@link SceneItemOperationsBuilder} for more information on available operations.\n *\n * @param operations\n */\n public items(\n operations: (q: SceneItemQueryExecutor) => TerminalItemOperationBuilder\n ): ItemsOperationExecutor {\n const sceneOperations = operations(new SceneItemQueryExecutor());\n\n const ops = Array.isArray(sceneOperations)\n ? sceneOperations\n : [sceneOperations];\n const operationList = ops.reduce(\n (acc, builder: SceneItemOperationsBuilder) => acc.concat(builder.build()),\n [] as QueryOperation[]\n );\n return new ItemsOperationExecutor(\n this.sceneViewId,\n this.stream,\n this.dimensions,\n operationList\n );\n }\n\n /**\n * An instance of the current camera of the scene. The camera provides a number of\n * methods that can be used in combination with the `render` method to make programmatic\n * updates to the scene's camera.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n * const camera = scene.camera();\n *\n * // Fit the camera to the visible bounding box of the scene with a 1 second animation\n * await camera.viewAll().render({ animation: { milliseconds: 1000 } });\n * ```\n *\n * @see {@link Camera} for more information on available camera operations.\n */\n public camera(): Camera {\n const { scene } = this.frame;\n\n if (scene.camera.isOrthographic()) {\n return new OrthographicCamera(\n this.stream,\n Dimensions.aspectRatio(this.viewport()),\n {\n viewVector: scene.camera.viewVector,\n lookAt: scene.camera.lookAt,\n up: scene.camera.up,\n fovHeight: scene.camera.fovHeight,\n rotationPoint: scene.camera.lookAt,\n },\n this.frame.scene.boundingBox,\n this.decodeFrame\n );\n } else if (scene.camera.isPerspective()) {\n return new PerspectiveCamera(\n this.stream,\n Dimensions.aspectRatio(this.viewport()),\n {\n position: scene.camera.position,\n lookAt: scene.camera.lookAt,\n up: scene.camera.up,\n fovY: scene.camera.fovY,\n },\n this.frame.scene.boundingBox,\n this.decodeFrame\n );\n } else {\n throw new InvalidCameraError(\n 'Cannot retrieve camera. Scene has an unknown or invalid camera type.'\n );\n }\n }\n\n public isOrthographic(): boolean {\n const { scene } = this.frame;\n\n return scene.camera.isOrthographic();\n }\n\n /**\n * Returns the current visible BoundingBox for the scene.\n */\n public boundingBox(): BoundingBox.BoundingBox {\n return this.frame.scene.boundingBox;\n }\n\n /**\n * CrossSectioner to update cross sectioning planes and get current configuration.\n */\n public crossSectioning(): CrossSectioner {\n return new CrossSectioner(this.stream, this.frame.scene.crossSection);\n }\n\n /**\n * Raycaster to request items that intersect a point.\n */\n public raycaster(): Raycaster {\n return new Raycaster(this.stream, this.imageScaleProvider);\n }\n\n /**\n * The current viewport of the scene, in pixels.\n */\n public viewport(): Dimensions.Dimensions {\n return this.frame.dimensions;\n }\n\n /**\n * The current x and y scale of the rendered image.\n */\n public scale(): Point.Point {\n return this.imageScaleProvider() || Point.create(1, 1);\n }\n}\n","import { Point, Rectangle } from '@vertexvis/geometry';\n\nimport { SceneItemOperationsBuilder } from './scene';\n\ninterface AllQueryExpression {\n type: 'all';\n}\n\nexport interface SceneTreeRange {\n start: number;\n end: number;\n}\n\ninterface ItemQueryExpression {\n type: 'item-id' | 'supplied-id';\n value: string;\n}\n\nexport interface AndExpression {\n type: 'and';\n expressions: QueryExpression[];\n}\n\nexport interface OrExpression {\n type: 'or';\n expressions: QueryExpression[];\n}\n\ninterface SceneTreeRangeQueryExpression {\n type: 'scene-tree-range';\n range: SceneTreeRange;\n}\n\ninterface NotQueryExpression {\n type: 'not';\n query: QueryExpression;\n}\n\ninterface MetadataQueryExpression {\n type: 'metadata';\n filter: string;\n keys: string[];\n exactMatch: boolean;\n removeHiddenItems?: boolean;\n}\n\ninterface AllSelectedQueryExpression {\n type: 'all-selected';\n}\n\ninterface AllVisibleQueryExpression {\n type: 'all-visible';\n}\n\ninterface PointQueryExpression {\n type: 'point';\n point: Point.Point;\n}\n\ninterface VolumeIntersectionQueryExpression {\n type: 'volume-intersection';\n rectangle: Rectangle.Rectangle;\n exclusive: boolean;\n}\n\n/**\n * Represents the sum of all possible types of expressions.\n */\nexport type QueryExpression =\n | AllQueryExpression\n | ItemQueryExpression\n | AndExpression\n | OrExpression\n | SceneTreeRangeQueryExpression\n | PointQueryExpression\n | VolumeIntersectionQueryExpression\n | MetadataQueryExpression\n | AllSelectedQueryExpression\n | AllVisibleQueryExpression\n | NotQueryExpression;\n\n/**\n * An interface that represents a query is \"complete\" and can be turned into an\n * expression.\n */\nabstract class TerminalQuery {\n protected inverted: boolean;\n public constructor(inverted: boolean) {\n this.inverted = inverted;\n }\n\n public build(): QueryExpression {\n if (this.inverted) {\n return {\n type: 'not',\n query: this.queryExpressionBuilder(),\n };\n } else {\n return this.queryExpressionBuilder();\n }\n }\n\n public abstract queryExpressionBuilder(): QueryExpression;\n}\n\ninterface ItemQuery<N> {\n withItemId(id: string): N;\n\n withSuppliedId(id: string): N;\n}\n\ninterface BooleanQuery {\n and(): AndQuery;\n or(): OrQuery;\n}\n\nexport class RootQuery implements ItemQuery<SingleQuery> {\n public constructor(private inverted: boolean = false) {}\n\n /**\n * Specifies that the operation should be performed on all items in the scene.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Deselect all items in the scene\n * await scene.items((op) => [op.where((q) => q.all()).deselect()]).execute();\n * ```\n */\n public all(): AllQuery {\n return new AllQuery();\n }\n\n /**\n * Specifies that the operation should be performed on all items that do not match any following queries.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide all items that are not selected\n * await scene.items((op) => [op.where((q) => q.not().withSelected()).hide()]).execute();\n * ```\n */\n public not(): RootQuery {\n return new NotQuery(!this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item matching any one of the provided IDs.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide the item with the `item-uuid-1` ID and the `item-uuid-2` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemIds(['item-uuid-1', 'item-uuid-2'])).hide(),\n * ]).execute();\n * ```\n */\n public withItemIds(ids: string[]): BulkQuery {\n return new BulkQuery(ids, 'item-id', this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item matching any one of the provided custom supplied IDs.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide the item with the `item-supplied-id-1` supplied ID\n * // and the `item-supplied-id-2` supplied ID\n * await scene.items((op) => [\n * op\n * .where((q) => q.withItemIds(['item-supplied-id-1', 'item-supplied-id-2']))\n * .hide(),\n * ]).execute();\n * ```\n */\n public withSuppliedIds(ids: string[]): BulkQuery {\n return new BulkQuery(ids, 'supplied-id', this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item matching the provided ID.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide the item with the `item-uuid` ID\n * await scene.items((op) => [\n * op.where((q) => q.withItemId('item-uuid')).hide(),\n * ]).execute();\n * ```\n */\n public withItemId(id: string): SingleQuery {\n return new SingleQuery({ type: 'item-id', value: id }, this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item matching the provided custom supplied ID.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide the item with the `item-supplied-id` supplied ID\n * await scene.items((op) => [\n * op.where((q) => q.withSuppliedId('item-supplied-id')).hide(),\n * ]).execute();\n * ```\n */\n public withSuppliedId(id: string): SingleQuery {\n return new SingleQuery({ type: 'supplied-id', value: id }, this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on a range within the `<vertex-scene-tree>` component.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide all items from the 2nd row to the 5th row of the scene-tree\n * await scene.items((op) => [\n * op\n * .where((q) =>\n * q.withSceneTreeRange({\n * start: 2,\n * end: 5,\n * })\n * )\n * .hide(),\n * ]).execute();\n * ```\n */\n public withSceneTreeRange(range: SceneTreeRange): SceneTreeRangeQuery {\n return new SceneTreeRangeQuery(range, this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item that has a metadata value matching the\n * filter provided for any of the keys specified. Can optionally be set to perform an exactMatch,\n * which will require that the filter matches the value exactly.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide all items where the `PART_NAME_KEY` includes a value of `PartName`\n * await scene.items((op) => [\n * op.where((q) => q.withMetadata('PartName', ['PART_NAME_KEY'])).hide(),\n * ]).execute();\n *\n * // Hide all items where the `PART_NAME_KEY` has exactly a value of `PartName`\n * await scene.items((op) => [\n * op.where((q) => q.withMetadata('PartName', ['PART_NAME_KEY'], true)).hide(),\n * ]).execute();\n * ```\n */\n public withMetadata(\n filter: string,\n keys: string[],\n exactMatch: boolean,\n removeHiddenItems?: boolean\n ): MetadataQuery {\n return new MetadataQuery(\n filter,\n keys,\n exactMatch,\n this.inverted,\n removeHiddenItems\n );\n }\n\n /**\n * Specifies that the operation should be performed on any item that has been selected.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Hide all items that are selected\n * await scene.items((op) => [op.where((q) => q.withSelected()).hide()]).execute();\n * ```\n */\n public withSelected(): AllSelectedQuery {\n return new AllSelectedQuery(this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item that is visible.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Select all items that are visible\n * await scene.items((op) => [op.where((q) => q.withVisible()).select()]).execute();\n * ```\n */\n public withVisible(): AllVisibleQuery {\n return new AllVisibleQuery(this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on any item present at the provided `point` in the image.\n * This query operates on the item found at that `point` similar to using `withItemId` in combination with\n * `raycaster.hitItems`, which can be useful if the additional metadata from the `raycaster.hitItems`\n * method is not needed to eliminate a network request.\n *\n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n *\n * // Select the item present at the [100, 100] coordinate of the image\n * await scene.items((op) => [\n * op.where((q) => q.withPoint(Point.create(100, 100))).select(),\n * ]).execute();\n * ```\n */\n public withPoint(point: Point.Point): PointQuery {\n return new PointQuery(point, this.inverted);\n }\n\n /**\n * Specifies that the operation should be performed on items within the specified `rectangle` boundary \n * within the Viewer. The `exclusive` flag here determines whether items that intersect with the `rectangle`, \n * but are not contained should be included in the result.\n * \n * @example\n * ```typescript\n * const viewer = document.querySelector('vertex-viewer');\n * const scene = await viewer.scene();\n\n * // Select all items within the specified 100x100 region of the image\n * // excluding any elements that are not fully contained by the region\n * await scene.items((op) => [\n * op\n * .where((q) =>\n * q.withVolumeIntersection(\n * Rectangle.create(100, 100, 100, 100),\n * true\n * )\n * )\n * .hide(),\n * ]).execute();\n\n * // Select all items within the specified 100x100 region of the image\n * // including any elements that intersect with the region\n * await scene.items((op) => [\n * op\n * .where((q) =>\n * q.withVolumeIntersection(\n * Rectangle.create(100, 100, 100, 100),\n * false\n * )\n * )\n * .hide(),\n * ]).execute();\n * ```\n */\n public withVolumeIntersection(\n rectangle: Rectangle.Rectangle,\n exclusive?: boolean\n ): VolumeIntersectionQuery {\n return new VolumeIntersectionQuery(rectangle, this.inverted, exclusive);\n }\n}\n\nexport class NotQuery extends RootQuery {\n public constructor(inverted: boolean) {\n super(inverted);\n }\n}\n\nexport class AllQuery extends TerminalQuery {\n public constructor(inverted = false) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): QueryExpression {\n return { type: 'all' };\n }\n}\n\nexport class SceneTreeRangeQuery extends TerminalQuery {\n public constructor(private range: SceneTreeRange, inverted: boolean) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): SceneTreeRangeQueryExpression {\n return {\n type: 'scene-tree-range',\n range: this.range,\n };\n }\n}\n\nexport class MetadataQuery extends TerminalQuery {\n public constructor(\n private filter: string,\n private keys: string[],\n private exactMatch: boolean,\n inverted: boolean,\n private removeHiddenItems?: boolean\n ) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): MetadataQueryExpression {\n return {\n type: 'metadata',\n filter: this.filter,\n keys: this.keys,\n exactMatch: this.exactMatch,\n removeHiddenItems: this.removeHiddenItems,\n };\n }\n}\n\nexport class AllSelectedQuery extends TerminalQuery {\n public constructor(inverted: boolean) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): AllSelectedQueryExpression {\n return {\n type: 'all-selected',\n };\n }\n}\n\nexport class AllVisibleQuery extends TerminalQuery {\n public constructor(inverted: boolean) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): AllVisibleQueryExpression {\n return {\n type: 'all-visible',\n };\n }\n}\n\nexport class PointQuery extends TerminalQuery {\n public constructor(private point: Point.Point, inverted: boolean) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): PointQueryExpression {\n return {\n type: 'point',\n point: this.point,\n };\n }\n}\n\nexport class VolumeIntersectionQuery extends TerminalQuery {\n public constructor(\n private rectangle: Rectangle.Rectangle,\n inverted: boolean,\n private exclusive?: boolean\n ) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): VolumeIntersectionQueryExpression {\n return {\n type: 'volume-intersection',\n rectangle: this.rectangle,\n exclusive: !!this.exclusive,\n };\n }\n}\n\nexport class BulkQuery extends TerminalQuery {\n public constructor(\n private ids: string[],\n private type: 'item-id' | 'supplied-id',\n inverted: boolean\n ) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): QueryExpression {\n return {\n type: 'or',\n expressions: this.ids.map((id) => {\n return {\n type: this.type,\n value: id,\n };\n }),\n };\n }\n}\n\nclass SingleQuery extends TerminalQuery implements BooleanQuery {\n public constructor(private query: QueryExpression, inverted: boolean) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): QueryExpression {\n return { ...this.query };\n }\n\n public and(): AndQuery {\n return new AndQuery([this.query], this.inverted);\n }\n\n public or(): OrQuery {\n return new OrQuery([this.query], this.inverted);\n }\n}\n\nexport class OrQuery extends TerminalQuery implements ItemQuery<OrQuery> {\n public constructor(\n private expressions: QueryExpression[],\n inverted: boolean\n ) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): QueryExpression {\n return { type: 'or', expressions: [...this.expressions] };\n }\n\n public withItemId(id: string): OrQuery {\n return new OrQuery(\n [...this.expressions, { type: 'item-id', value: id }],\n this.inverted\n );\n }\n\n public withSuppliedId(id: string): OrQuery {\n return new OrQuery(\n [...this.expressions, { type: 'supplied-id', value: id }],\n this.inverted\n );\n }\n\n public or(): OrQuery {\n return this;\n }\n}\n\nexport class AndQuery extends TerminalQuery implements ItemQuery<AndQuery> {\n public constructor(\n private expressions: QueryExpression[],\n inverted: boolean\n ) {\n super(inverted);\n }\n\n public queryExpressionBuilder(): QueryExpression {\n return { type: 'and', expressions: [...this.expressions] };\n }\n\n public withItemId(id: string): AndQuery {\n return new AndQuery(\n [...this.expressions, { type: 'item-id', value: id }],\n this.inverted\n );\n }\n\n public withSuppliedId(id: string): AndQuery {\n return new AndQuery(\n [...this.expressions, { type: 'supplied-id', value: id }],\n this.inverted\n );\n }\n\n public and(): AndQuery {\n return this;\n }\n}\n\nexport class SceneItemQueryExecutor {\n public where(\n query: (q: RootQuery) => TerminalQuery\n ): SceneItemOperationsBuilder {\n const expression: QueryExpression = query(new RootQuery()).build();\n\n return new SceneItemOperationsBuilder(expression);\n }\n}\n"]}
@@ -1,5 +0,0 @@
1
- /*!
2
- * Copyright (c) 2024 Vertex Software LLC. All rights reserved.
3
- */
4
- import{r as t,c as i,h as s,H as n,g as e}from"./p-e541044a.js";import{p as o,v as h,c as r,f as a,r as c,b as l,w as u,d}from"./p-26198b53.js";import{S as f}from"./p-3f901c03.js";import{p,t as w,a as m,S as v,c as g,W as y}from"./p-a30a8324.js";import{m as b,b as C,E as P,a as T,c as I,o as S,u as D}from"./p-81d5a971.js";import{c as A}from"./p-5206da6c.js";import{u as j,c as E,C as k,W as x,S as O,V as M,d as R,e as B}from"./p-b33048e2.js";import{s as z,p as F,u as L}from"./p-dc590cd1.js";import{r as $,c as H,a as K}from"./p-ff0bd72b.js";import{l as N,m as V,n as W,o as q,j as U,u as _,t as J,p as X,q as Z,r as G,s as Y,x as Q,y as tt,z as it,B as st,C as nt,E as et}from"./p-762b8987.js";import{p as ot}from"./p-b7feec8b.js";import{C as ht}from"./p-be03d860.js";import{g as rt,c as at}from"./p-47b8b98d.js";import{E as ct}from"./p-d312d59a.js";import{V as lt}from"./p-f6f74387.js";import{B as ut,M as dt}from"./p-bf67f570.js";import{h as ft,g as pt,S as wt}from"./p-339774b3.js";import{w as mt}from"./p-208c7121.js";import"./p-d4d032c6.js";import"./p-88c19f38.js";import"./p-db5aed84.js";const vt=0;const gt=255;class yt{constructor(t){this.viewer=t;this.handleInteractionStarted=()=>{this.invalidateStencilBuffer();this.pendingInteractionFinished=new Promise((t=>{this.pendingInteractionFinishedResolver=t}))};this.handleInteractionFinished=()=>{var t;(t=this.pendingInteractionFinishedResolver)===null||t===void 0?void 0:t.call(this);this.pendingInteractionFinished=undefined;this.pendingInteractionFinishedResolver=undefined};this.invalidateStencilBuffer=()=>{this.pendingStencilBuffer=undefined};t.addEventListener("interactionStarted",this.handleInteractionStarted);t.addEventListener("interactionFinished",this.handleInteractionFinished);t.addEventListener("frameReceived",(()=>{this.invalidateStencilBuffer()}))}async fetch(){var t;const i=await this.viewer.isSceneReady();const s=i?await this.viewer.scene():undefined;const n=s!=null?s.crossSectioning().current().sectionPlanes.length>0||this.viewer.featureLines!=null:false;const e=(t=this.viewer.frame)===null||t===void 0?void 0:t.scene.camera;if(n&&this.viewer.stream!=null&&e!=null){const t=await this.viewer.stream.getStencilBuffer({includeDepthBuffer:true});const{stencilBuffer:i,depthBuffer:s,imageAttributes:n}=N(t);const[o,h]=await Promise.all([V(new Uint8Array(i)),V(new Uint8Array(s))]);return bt.fromPng(o,n,i,W.fromPng(h,e,n))}else return undefined}latest(){if(this.pendingStencilBuffer==null){this.pendingStencilBuffer=this.fetch()}return this.pendingStencilBuffer}async latestAfterInteraction(){await this.pendingInteractionFinished;return this.latest()}}class bt{constructor(t,i,s,n,e){this.imageAttr=t;this.imageBytes=i;this.pixelBytes=s;this.imageChannels=n;this.depthBuffer=e}static fromPng(t,i,s,n){if(!(t.data instanceof Uint8Array)){throw new Error("Expected stencil PNG to have depth of 8-bit")}else if(t.channels!==1){throw new Error("Expected stencil PNG to have 1 color channel")}else{return new bt(i,s,t.data,t.channels,n)}}getValue(t){const{width:i,height:s}=this.imageAttr.imageRect;const n=o.subtract(t,this.imageAttr.imageRect);const e=1/this.imageAttr.imageScale;const h=o.scale(n,e,e);if(h.x>=0&&h.y>=0&&h.x<i&&h.y<s){const t=Math.floor(h.x)+Math.floor(h.y)*i;const s=this.pixelBytes[t];return s}else return 0}hitTest(t){return this.getValue(t)!==vt}snapToNearestPixel(t,i,s=(()=>true)){const n=i*2;const e=o.create(t.x-i,t.y-i);const h=[];for(let r=0;r<n*n;r++){const a=r%n;const c=Math.floor(r/n);const l=o.add(e,{x:a,y:c});if(o.distance(l,t)<=i){const t=this.getValue(l);if(t===gt&&s(t)){h.push(l)}}}const r=h.sort(((i,s)=>o.distance(i,t)-o.distance(s,t)));const a=r[0];return a!=null?o.create(Math.floor(a.x)+.5,Math.floor(a.y)+.5):t}}function Ct(t){return t!=null&&t["then"]instanceof Function&&t["catch"]instanceof Function&&t["finally"]instanceof Function}function Pt(t){return new Promise((i=>setTimeout(i,t)))}const Tt=b.defineMapper(b.read(b.requiredProp("msb"),b.requiredProp("lsb")),(([t,i])=>C.fromMsbLsb(t,i)));const It=b.defineMapper(b.read(b.requiredProp("seconds"),b.requiredProp("nanos")),(([t,i])=>p({seconds:t,nanos:i})));const St=b.defineMapper(b.compose((t=>t.toObject()),b.read(b.mapRequiredProp("id",Tt),b.mapRequiredProp("createdAt",It),b.mapRequiredProp("modifiedAt",It),b.mapProp("name",q),b.mapProp("suppliedId",q))),(([t,i,s,n,e])=>({id:t,createdAt:i,modifiedAt:s,name:n,suppliedId:e})));const Dt=b.ifInvalidThrow(St);const At=b.defineMapper(b.compose((t=>t.toObject()),b.read(b.mapRequiredProp("id",Tt),b.mapRequiredProp("createdAt",It),b.mapRequiredProp("modifiedAt",It),b.mapProp("suppliedId",q),b.mapRequiredProp("data",(t=>{if(t.callout!=null){return Et(t.callout)}else if(t.customJson!=null){return kt(t.customJson)}else{throw new Error("Undefined or unknown annotation data.")}})))),(([t,i,s,n,e])=>({id:t,createdAt:i,modifiedAt:s,suppliedId:n,data:e})));const jt=b.ifInvalidThrow(At);const Et=b.defineMapper(b.read(b.mapRequiredProp("position",U),b.mapProp("icon",q),b.mapProp("primaryColor",q),b.mapProp("accentColor",q)),(([t,i,s,n])=>({type:"callout",position:t,icon:i,primaryColor:s,accentColor:n})));const kt=b.defineMapper(b.read(b.requiredProp("type"),b.mapRequiredProp("jsonData",(t=>JSON.parse(t)))),(([t,i])=>({type:"custom",jsonType:t,jsonData:i})));class xt{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s;this.onStateChange=new P}async addAnnotationSet(t){await $((async i=>{const s=this.deviceIdProvider();const n=await H(this.jwtProvider,s);const e=new z.CreateSceneViewAnnotationSetRequest;const o=new j.Uuid;o.setHex(t);e.setSceneAnnotationSetId(o);this.client.createSceneViewAnnotationSet(e,n,i)}));return this.fetch()}disconnect(){if(this.connection!=null){this.connection.dispose();this.connection=undefined}}connect(t=1e4){this.disconnect();const i=this.pollAnnotationState(t);this.connection={dispose:()=>i.abort()}}async fetch(t={}){const i=await this.fetchAnnotationSetsAsArray();const s=await this.fetchAnnotationsAsArray(i);const n=(await Promise.all(s)).reduce(((t,[i,s])=>({annotations:Object.assign(Object.assign({},t.annotations),{[i.id]:s})})),{annotations:{}});if(t.signal==null||!t.signal.aborted){this.updateState(n)}return n}async removeAnnotationSet(t){await $((async i=>{const s=this.deviceIdProvider();const n=await H(this.jwtProvider,s);const e=new z.DeleteSceneViewAnnotationSetRequest;const o=new j.Uuid;o.setHex(t);e.setSceneAnnotationSetId(o);this.client.deleteSceneViewAnnotationSet(e,n,i)}));return this.fetch()}pollAnnotationState(t){const i=new AbortController;const s=async t=>{await this.fetch({signal:i.signal});if(!i.signal.aborted){await Pt(t);await s(t)}};T.abort(i.signal,s(t));return i}fetchAnnotationSets(){return K((t=>async i=>{const s=this.deviceIdProvider();const n=await H(this.jwtProvider,s);const e=new z.ListSceneViewAnnotationSetsRequest;if(t!=null){const i=new F.Pager;i.setCursor(t);i.setLimit(100);e.setPage(i)}this.client.listSceneViewAnnotationSets(e,n,i)}),(t=>{var i;return(i=t.toObject().nextCursor)===null||i===void 0?void 0:i.next}))}async fetchAnnotationSetsAsArray(){return(await T.asArray(this.fetchAnnotationSets())).flatMap((t=>t.getSceneAnnotationSetsList())).map((t=>Dt(t)))}fetchAnnotations(t){return K((i=>async s=>{const n=this.deviceIdProvider();const e=await H(this.jwtProvider,n);const o=C.toMsbLsb(t);const h=new L.Uuid2l;h.setMsb(o.msb);h.setLsb(o.lsb);const r=new z.ListSceneAnnotationsRequest;r.setSceneAnnotationSetId(h);if(i!=null){const t=new F.Pager;t.setCursor(i);t.setLimit(100);r.setPage(t)}this.client.listSceneAnnotations(r,e,s)}),(t=>{var i;return(i=t.toObject().nextCursor)===null||i===void 0?void 0:i.next}))}fetchAnnotationsAsArray(t){const i=t.map((async t=>{const i=(await T.asArray(this.fetchAnnotations(t.id))).flatMap((t=>t.getSceneAnnotationsList())).map((t=>jt(t)));return[t,i]}));return Promise.all(i)}updateState(t){this.state=t;this.onStateChange.emit(t)}}class Ot{constructor(t,i,s){this.stream=t;this.configProvider=i;this.imageScaleProvider=s}predicate(t){return t.altKey&&!t.shiftKey}async fn(t){var i;const s=this.imageScaleProvider();const n=await this.stream.hitItems({point:o.scale(t.position,(s===null||s===void 0?void 0:s.x)||1,(s===null||s===void 0?void 0:s.y)||1)},true);if(((i=n.hitItems)===null||i===void 0?void 0:i.hits)!=null&&n.hitItems.hits.length>0){await this.stream.flyTo({itemId:n.hitItems.hits[0].itemId,animation:{duration:w(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit results found for fly to part [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}}class Mt{constructor(t,i,s,n,e,o,h,r,a,c,l){this.stream=t;this.cursors=i;this.getConfig=s;this.getScene=n;this.getFrame=e;this.getViewport=o;this.tapEmitter=h;this.doubleTapEmitter=r;this.longPressEmitter=a;this.interactionStartedEmitter=c;this.interactionFinishedEmitter=l;this.tap=this.tap.bind(this);this.doubleTap=this.doubleTap.bind(this);this.longPress=this.longPress.bind(this);this.emitTapEvent=this.emitTapEvent.bind(this)}addCursor(t,i){return this.cursors.add(t,i)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async getEntityTypeAtPoint(t){var i;const s=this.getViewport();const n=await((i=this.getFrame())===null||i===void 0?void 0:i.featureMap());if(n!=null){const i=s.transformPointToFrame(t,n);return n.getEntityType(i)}else{return ct.NO_GEOMETRY}}getRayFromPoint(t){const i=this.getViewport();const s=this.getFrame();if(s!=null){return i.transformPointToRay(t,s.image,s.scene.camera)}else throw new Error("Cannot get camera. Frame is undefined.")}async tap(t,i={},s=0){this.emitTapEvent(this.tapEmitter.emit,t,i,s)}async doubleTap(t,i={},s=0){this.emitTapEvent(this.doubleTapEmitter.emit,t,i,s)}async longPress(t,i={},s=0){this.emitTapEvent(this.longPressEmitter.emit,t,i,s)}async beginInteraction(){if(!this.isInteracting()){this.interactionStartedEmitter.emit();this.sceneLoadingPromise=this.getScene();this.currentCamera=(await this.sceneLoadingPromise).camera();this.sceneLoadingPromise=undefined;await this.stream.beginInteraction()}}async transformCamera(...t){var i;const s=t[0];const n=t[1];if(this.isInteracting()){const t=await this.getScene();const e=this.getViewport();const o=this.getFrame();const h=await(o===null||o===void 0?void 0:o.depthBuffer());this.currentCamera=this.currentCamera!=null&&e!=null&&o!=null?s({camera:this.currentCamera,viewport:e,scale:t.scale(),boundingBox:t.boundingBox(),frame:o,depthBuffer:h}):undefined;await((i=this.currentCamera)===null||i===void 0?void 0:i.render(n))}}async twistCamera(...t){return this.transformCamera((({camera:i,viewport:s})=>{const n=h.normalize(h.subtract(i.lookAt,i.position));if(t.length===1&&typeof t[0]==="number"){const s=r.toRadians(-t[0]);return i.rotateAroundAxis(s,n)}else if(t.length===1){const n=o.create(s.width/2,s.height/2);const e=r.toDegrees(r.fromPoints(n,t[0]));const a=this.lastAngle!=null?e-this.lastAngle:0;this.lastAngle=e;const c=h.normalize(h.subtract(i.lookAt,i.position));const l=r.toRadians(-a);return i.rotateAroundAxis(l,c)}return i}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,depthBuffer:e})=>{if(this.panData==null){const o=i.toFrameCamera();const h=o.direction;const r=n.transformPointToRay(t,s.image,o);const l=a.fromNormalAndCoplanarPoint(h,i.lookAt);const u=c.intersectPlane(r,l);if(u==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}const d=e!=null?this.getWorldPoint(t,e,u):u;const f=a.fromNormalAndCoplanarPoint(h,d);this.panData={hitPt:d,hitPlane:f,startingCamera:o}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const a=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(a,o);if(l!=null){const t=h.subtract(e,l);return i.update(r).moveBy(t)}}return i}))}async viewAll(){await(await this.getScene()).camera().viewAll().render()}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s,boundingBox:n})=>{const e=h.normalize(i.up);const o=h.normalize(h.subtract(i.lookAt,i.position));const r=h.cross(e,o);const a=h.cross(o,r);const c=h.normalize({x:t.x*r.x+t.y*a.x,y:t.x*r.y+t.y*a.y,z:t.x*r.z+t.y*a.z});const l=h.cross(c,o);const u=9.5*t.x/s.width;const d=9.5*t.y/s.height;const f=Math.abs(u)+Math.abs(d);return i.rotateAroundAxis(f,l)}))}async rotateCameraAtPoint(t,i){return this.transformCamera((({camera:s,viewport:n,boundingBox:e,depthBuffer:o})=>{if(this.worldRotationPoint==null){const t=l.center(e);this.worldRotationPoint=o!=null?this.getWorldPoint(i,o,t):s.lookAt}const r=h.normalize(s.up);const a=h.normalize(h.subtract(s.lookAt,s.position));const c=h.cross(r,a);const u=h.cross(a,c);const d=h.normalize({x:t.x*c.x+t.y*u.x,y:t.x*c.y+t.y*u.y,z:t.x*c.z+t.y*u.z});const f=h.cross(d,a);const p=9.5*t.x/n.width;const w=9.5*t.y/n.height;const m=Math.abs(p)+Math.abs(w);const v=s.rotateAroundAxisAtPoint(m,this.worldRotationPoint,f);return v.update({lookAt:h.add(h.scale(Math.abs(s.signedDistanceToBoundingBoxCenter())/h.magnitude(v.viewVector),v.viewVector),v.position)})}))}async zoomCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector;const e=h.normalize(n);const o=h.magnitude(n);const r=3*o*t/s.height;const a=h.add(i.position,h.scale(r,e));const c=i.update({position:a});return c}))}async pivotCamera(t,i){return this.transformCamera((({camera:s})=>{const{position:n,up:e,lookAt:o}=s;const a=h.normalize(e);const c=h.normalize(s.viewVector);const l=h.cross(a,c);const u=h.cross(c,l);const d=h.rotateAboutAxis(r.toRadians(t),o,l,n);const f=h.rotateAboutAxis(r.toRadians(i),d,u,n);return s.update(Object.assign(Object.assign({},s),{lookAt:f}))}))}async endInteraction(){await this.sceneLoadingPromise;if(this.isInteracting()){this.currentCamera=undefined;this.worldRotationPoint=undefined;this.panData=undefined;this.zoomData=undefined;this.resetLastAngle();this.interactionFinishedEmitter.emit();await this.stream.endInteraction()}}resetLastAngle(){this.lastAngle=undefined}isInteracting(){return this.currentCamera!=null}pixelThreshold(t){const i=this.isCoarseInputDevice(t)?this.getConfig().coarsePointerThreshold:this.getConfig().finePointerThreshold;return i*window.devicePixelRatio}async hitItems(t){var i;const s=await(await this.getScene()).raycaster().hitItems(t);return(i=s===null||s===void 0?void 0:s.hits)!==null&&i!==void 0?i:[]}emitTapEvent(t,i,s={},n=0){const{altKey:e=false,ctrlKey:o=false,metaKey:h=false,shiftKey:r=false}=s;t({position:i,altKey:e,ctrlKey:o,metaKey:h,shiftKey:r,buttons:n})}isCoarseInputDevice(t){return t||window.matchMedia("(pointer: coarse)").matches}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}class Rt extends Mt{constructor(t,i,s,n,e,o,h,r,a,c,l){super(t,i,s,n,e,o,h,r,a,c,l)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector;const e=h.normalize(i.up);const r=h.normalize(n);const a=o.scale(t,.5,.5);const c=h.magnitude(n);const l=a.x*c/s.width;const u=a.y*c/s.height;const d=h.cross(e,r);const f=h.cross(r,d);const p=h.add(h.scale(l,d),h.scale(u,f));return i.moveBy(p)}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,boundingBox:e})=>{if(this.panData==null){const e=i.toFrameCamera();const o=e.direction;const h=n.transformPointToRay(t,s.image,e);const r=a.fromNormalAndCoplanarPoint(o,i.lookAt);const l=c.intersectPlane(h,r);if(l==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}this.panData={hitPt:l,hitPlane:r,startingCamera:e}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const a=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(a,o);if(l!=null){const t=h.subtract(e,l);const s=h.add(r.lookAt,t);return i.update({lookAt:s,rotationPoint:s})}}return i}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:r,boundingBox:l})=>{if(this.orthographicZoomData==null||o.distance(t,this.orthographicZoomData.startingScreenPt)>2){const i=s.toFrameCamera();const o=i.direction;const h=n.transformPointToRay(t,e.image,i);const l=a.fromNormalAndCoplanarPoint(o,i.lookAt);const u=c.intersectPlane(h,l);if(u==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const d=r!=null?this.getWorldPoint(t,r,u):u;const f=a.fromNormalAndCoplanarPoint(o,d);this.orthographicZoomData={hitPt:d,hitPlane:f,startingScreenPt:t}}if(this.orthographicZoomData!=null){const{hitPt:t,hitPlane:e}=this.orthographicZoomData;const o=4*(s.fovHeight/n.height)*i;const r=Math.max(1,s.fovHeight-o);const c=a.projectPoint(e,s.lookAt);const l=h.scale((s.fovHeight-r)/s.fovHeight,h.subtract(t,c));const u=h.add(s.lookAt,l);return s.update({lookAt:u,rotationPoint:u,fovHeight:Math.max(1,s.fovHeight-o)})}return s}))}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s,boundingBox:n})=>{var e;const o=h.normalize(i.up);const r=h.normalize(h.subtract(i.lookAt,i.position));const a=h.cross(o,r);const c=h.cross(r,a);const u=h.normalize({x:t.x*a.x+t.y*c.x,y:t.x*a.y+t.y*c.y,z:t.x*a.z+t.y*c.z});const d=h.cross(u,r);const f=9.5*t.x/s.width;const p=9.5*t.y/s.height;const w=Math.abs(f)+Math.abs(p);const m=i.rotationPoint!=null&&((e=i.rotationPoint)===null||e===void 0?void 0:e.x)!=null?i.rotationPoint:i.lookAt;const v=i.rotateAroundAxisAtPoint(w,m,d);const g=_(v.lookAt,v.viewVector,l.center(n));return v.update({lookAt:g})}))}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}const Bt=.2;class zt extends Mt{constructor(t,i,s,n,e,o,h,r,a,c,l){super(t,i,s,n,e,o,h,r,a,c,l)}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{var n;const e=i.viewVector;const r=h.normalize(i.up);const a=h.normalize(e);const c=o.scale(t,.25,.25);const l=h.magnitude(e)*Math.tan((n=i.fovY)!==null&&n!==void 0?n:45);const u=c.x*l/s.width;const d=c.y/s.width*l;const f=h.cross(r,a);const p=h.cross(a,f);const w=h.add(h.scale(u,f),h.scale(d,p));return i.moveBy(w)}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:o,boundingBox:r})=>{const l=e.scene.camera;const u=l.direction;const d=s.toFrameCamera();const f=n.transformPointToRay(t,e.image,d);if(this.zoomData==null){const i=a.fromNormalAndCoplanarPoint(u,l.lookAt);const n=c.intersectPlane(f,i);if(n==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const e=o!=null?this.getWorldPoint(t,o,n):n;const h=a.fromNormalAndCoplanarPoint(u,e);this.zoomData={hitPt:e,hitPlane:h}}if(this.zoomData!=null){const{hitPlane:t}=this.zoomData;const{position:e,distance:o,isPastHitPlane:l,keepCurrent:u}=this.computeZoomDistances(i,s,n,r,f,this.zoomData);if(l&&!u){const t=c.create({origin:e,direction:h.normalize(s.viewVector)});return s.update({position:e,lookAt:c.at(t,o)})}else if(!u){return s.update({position:e,lookAt:a.projectPoint(t,e)})}}return s}))}walk(t){this.transformCamera((({camera:i,boundingBox:s})=>{const{position:n,up:e,lookAt:o}=i;const r=h.normalize(e);const a=h.normalize(i.viewVector);const c=Math.min(...h.toArray(l.lengths(s)));const u=h.scale(c,t);const d=h.cross(r,a);const f=h.cross(d,r);const p=h.scale(u.x,h.normalize(d));const w=h.scale(u.y,h.normalize(r));const m=h.scale(u.z,h.normalize(f));const v=h.negate(h.add(p,w,m));return i.update(Object.assign(Object.assign({},i),{position:h.add(n,v),lookAt:h.add(o,v)}))}))}computeZoomDistances(t,i,s,n,e,o){const r=this.getConfig();const{hitPt:a,hitPlane:l}=o;const u=r.useMinimumPerspectiveZoomDistance?this.computeZoomMinimumDistance(i,n):-1;const d=h.distance(i.position,a);const f=Math.max(u,d);const p=6*f*t/s.height;const w=c.at(e,p);const m=c.create({origin:w,direction:h.normalize(i.viewVector)});const v=c.intersectPlane(m,l);if(v==null&&r.useMinimumPerspectiveZoomDistance){const i=6*u*t/s.height;const n=c.at(e,i);return{position:n,distance:u,isPastHitPlane:true,keepCurrent:false}}else if(v==null){return{position:i.position,distance:f,isPastHitPlane:true,keepCurrent:true}}return{position:w,distance:f,isPastHitPlane:false,keepCurrent:false}}computeZoomMinimumDistance(t,i){const s=Math.abs(i.min.x)+Math.abs(i.max.x);const n=Math.abs(i.min.y)+Math.abs(i.max.y);const e=Math.abs(i.min.z)+Math.abs(i.max.z);const o=Math.max(s,n,e);const r=Math.abs(h.dot(h.normalize(t.viewVector),h.right()));const a=Math.abs(h.dot(h.normalize(t.viewVector),h.up()));const c=Math.abs(h.dot(h.normalize(t.viewVector),h.back()));const l=s*r;const u=n*a;const d=e*c;const f=o/s;const p=o/n;const w=o/e;return(l+u+d)/(f+p+w)*Bt}}class Ft{constructor(t,i,s,n){this.stream=t;this.configProvider=i;this.imageScaleProvider=s;this.sceneProvider=n}predicate(t){return t.altKey&&t.shiftKey}async fn(t){var i,s;const n=this.imageScaleProvider();const e=await this.stream.hitItems({point:o.scale(t.position,(n===null||n===void 0?void 0:n.x)||1,(n===null||n===void 0?void 0:n.y)||1)},true);if(((i=e.hitItems)===null||i===void 0?void 0:i.hits)!=null&&e.hitItems.hits.length>0&&e.hitItems.hits[0].hitPoint!=null){const i=await this.sceneProvider();const n=(await this.sceneProvider()).camera();const o=e.hitItems.hits[0];if(o.hitPoint!=null&&o.hitPoint.x!=null&&o.hitPoint.y!=null&&o.hitPoint.z!=null){const t=h.create(o.hitPoint.x,o.hitPoint.y,o.hitPoint.z);const s=await this.getLookAtPoint(i,t,n.viewVector);await this.stream.flyTo({camera:J(n.update({lookAt:s,rotationPoint:s}).toFrameCamera()),animation:{duration:w(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit position found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}, hit-id={${(s=o.itemId)===null||s===void 0?void 0:s.hex}}]`)}}else{console.debug(`No hit results found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}getLookAtPoint(t,i,s){if(t.isOrthographic()){return _(i,s,l.center(t.boundingBox()))}else{return i}}}class Lt{setPosition(t){this.currentPosition=t}getPosition(){return this.currentPosition}getType(){return this.type}beginDrag(t,i,s,n){}drag(t,i){}endDrag(t,i){if(this.currentPosition!=null){i.endInteraction();this.currentPosition=undefined}}zoom(t,i){}}class $t extends Lt{constructor(){super(...arguments);this.type="rotate"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCamera(n);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Ht extends Lt{constructor(){super(...arguments);this.type="rotate-point"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.startingPosition=i;s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.startingPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCameraAtPoint(n,this.startingPosition);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Kt extends Lt{constructor(t=1e3){super();this.interactionTimeout=t;this.type="zoom";this.didTransformBegin=false}beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.clientX,t.clientY);const i=n.getBoundingClientRect();const e=rt(t,i);this.startPt=e;s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.clientX,t.clientY);const n=o.subtract(s,this.currentPosition);if(this.startPt!=null){i.zoomCameraToPoint(this.startPt,n.y);this.currentPosition=s}}}endDrag(t,i){super.endDrag(t,i);this.stopInteractionTimer();this.didTransformBegin=false;this.startPt=undefined}zoom(t,i){this.operateWithTimer(i,(()=>i.zoomCamera(t)))}zoomToPoint(t,i,s){this.operateWithTimer(s,(()=>s.zoomCameraToPoint(t,i)))}beginInteraction(t){this.didTransformBegin=true;t.beginInteraction()}endInteraction(t){this.didTransformBegin=false;t.endInteraction()}resetInteractionTimer(t){this.stopInteractionTimer();this.startInteractionTimer(t)}startInteractionTimer(t){this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=undefined;this.endInteraction(t)}),this.interactionTimeout)}stopInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}operateWithTimer(t,i){if(!this.didTransformBegin){this.beginInteraction(t)}this.resetInteractionTimer(t);i()}}class Nt extends Lt{constructor(){super(...arguments);this.type="pan"}beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.canvasRect!=null){const s=rt(t,this.canvasRect);i.panCameraToScreenPoint(s);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Vt extends Lt{constructor(){super(...arguments);this.type="twist"}beginDrag(t,i,s,n){this.currentPosition=o.create(t.offsetX,t.offsetY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}drag(t,i){const s=rt(t,this.canvasRect);this.currentPosition=s;i.twistCamera(s)}endDrag(t,i){super.endDrag(t,i)}}class Wt extends Lt{constructor(){super(...arguments);this.type="pivot"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.pivotCamera(-.25*n.y,.25*n.x);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class qt extends ut{constructor(t,i=new $t,s=new Ht,n=new Kt,e=new Nt,o=new Vt,h=new Wt){super("mousedown","mouseup","mousemove",i,s,n,e,o,h,t)}}function Ut(t){window.requestAnimationFrame(t)}class _t{constructor(){this.previousFirstPoints=[];this.previousSecondPoints=[]}initialize(t,i){this.element=t;this.interactionApi=i}dispose(){this.element=undefined}beginTwoPointTouch(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i]}handleTwoPointTouchMove(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i];Ut((()=>{var t,i,s,n;if(this.previousFirstPoints.length>1&&this.previousSecondPoints.length>1&&this.previousFirstPoints.length===this.previousSecondPoints.length){const e=this.previousFirstPoints;const h=this.previousSecondPoints;this.previousFirstPoints=this.previousFirstPoints.slice(-1);this.previousSecondPoints=this.previousSecondPoints.slice(-1);const r=e.reduce(((t,i,s)=>{if(s<e.length-1){const n=e[s+1];const o=h[s];const r=h[s+1];return{deltas:[...t.deltas,this.computeDelta(i,o,n,r)],zooms:[...t.zooms,this.computeZoom(i,o,n,r)],angles:[...t.angles,this.computeAngle(i,o,n,r)]}}return t}),{deltas:[],zooms:[],angles:[]});const a=r.deltas.reduce(((t,i)=>o.add(t,i)),o.create());const c=r.zooms.reduce(((t,i)=>t+i),0);const l=r.angles.reduce(((t,i)=>t+i),0);const u=o.create((e[e.length-1].x+h[h.length-1].x)/2,(e[e.length-1].y+h[h.length-1].y)/2);(t=this.interactionApi)===null||t===void 0?void 0:t.beginInteraction();(i=this.interactionApi)===null||i===void 0?void 0:i.zoomCameraToPoint(u,c);(s=this.interactionApi)===null||s===void 0?void 0:s.panCameraByDelta(a);(n=this.interactionApi)===null||n===void 0?void 0:n.twistCamera(l)}}))}endTwoPointTouch(){this.previousFirstPoints=[];this.previousSecondPoints=[]}computeDelta(t,i,s,n){return o.add(o.subtract(s,t),o.subtract(n,i))}computeZoom(t,i,s,n){const e=o.distance(s,n)-o.distance(t,i);return e*.5}computeAngle(t,i,s,n){const e=u.create(o.subtract(t,i),o.subtract(s,n));return r.toDegrees(Math.atan2(u.determinant(e),u.dot(e)))}}class Jt extends _t{constructor(){super();this.touchPoints={};this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointerdown",this.handlePointerDown);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}handlePointerDown(t){const i=o.create(t.screenX,t.screenY);this.touchPoints=Object.assign(Object.assign({},this.touchPoints),{[t.pointerId]:i});const s=Object.keys(this.touchPoints);if(s.length===1){window.addEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointerup",this.handlePointerUp)}else if(s.length===2){this.beginTwoPointTouch(this.touchPoints[0],this.touchPoints[1])}}handlePointerMove(t){if(this.touchPoints[t.pointerId]!=null){this.touchPoints[t.pointerId]=o.create(t.screenX,t.screenY)}const i=Object.keys(this.touchPoints);if(i.length===2){const t=this.touchPoints[i[0]];const s=this.touchPoints[i[1]];this.handleTwoPointTouchMove(t,s)}}handlePointerUp(t){var i;delete this.touchPoints[t.pointerId];const s=Object.keys(this.touchPoints);if(s.length===1){(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction()}if(s.length===0){window.removeEventListener("pointermove",this.handlePointerMove);window.removeEventListener("pointerup",this.handlePointerUp)}this.endTwoPointTouch()}}class Xt extends dt{constructor(t,i=new $t,s=new Ht,n=new Kt,e=new Nt,o=new Vt,h=new Wt){super("pointerdown","pointerup","pointermove",i,s,n,e,o,h,t);this.touchPoints=new Set;this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}addEventListenersToElement(t){t.addEventListener(this.downEvent,this.handleDownEvent);t.addEventListener("wheel",this.handleMouseWheel,{passive:false});return{dispose:()=>{t.removeEventListener(this.downEvent,this.handleDownEvent);t.removeEventListener("wheel",this.handleMouseWheel)}}}handlePointerDown(t){this.downPosition=o.create(t.screenX,t.screenY);this.touchPoints.add(t.pointerId);if(this.touchPoints.size===1){window.addEventListener("pointerup",this.handlePointerUp)}if(this.touchPoints.size===2){this.disableIndividualInteractions=true}}handlePointerUp(t){this.touchPoints.delete(t.pointerId);if(this.touchPoints.size<2){this.disableIndividualInteractions=false}if(this.touchPoints.size===0){window.removeEventListener("pointerup",this.handlePointerUp)}}}class Zt{constructor(t,i,s,n){this.downEvent=t;this.upEvent=i;this.moveEvent=s;this.getConfig=n;this.handleDown=this.handleDown.bind(this);this.handleUp=this.handleUp.bind(this);this.handleMove=this.handleMove.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerEnd=this.handlePointerEnd.bind(this);this.clearPositions=this.clearPositions.bind(this);this.restartDoubleTapTimer=this.restartDoubleTapTimer.bind(this);this.clearDoubleTapTimer=this.clearDoubleTapTimer.bind(this);this.restartLongPressTimer=this.restartLongPressTimer.bind(this);this.clearLongPressTimer=this.clearLongPressTimer.bind(this);this.setPointerPositions=this.setPointerPositions.bind(this);this.emit=this.emit.bind(this)}dispose(){var t,i;(t=this.element)===null||t===void 0?void 0:t.removeEventListener(this.downEvent,this.handleDown);(i=this.element)===null||i===void 0?void 0:i.removeEventListener("touchstart",this.handleTouchStart);this.element=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer()}initialize(t,i){this.element=t;this.interactionApi=i;t.addEventListener(this.downEvent,this.handleDown);t.addEventListener("touchstart",this.handleTouchStart,{passive:true})}handleTouchStart(t){if(t.touches.length===1){this.setPointerPositions(o.create(t.touches[0].clientX,t.touches[0].clientY));this.restartLongPressTimer();window.addEventListener("touchend",this.handleTouchEnd);window.addEventListener("touchmove",this.handleTouchMove)}}handleTouchMove(t){if(t.touches.length>0){this.handlePointerMove(o.create(t.touches[0].clientX,t.touches[0].clientY),true)}}handleTouchEnd(t){if(this.pointerDownPosition!=null){window.removeEventListener("touchend",this.handleTouchEnd);window.removeEventListener("touchmove",this.handleTouchMove)}this.handlePointerEnd(this.pointerDownPosition)}handleDown(t){this.setPointerPositions(o.create(t.clientX,t.clientY));this.buttons=t.buttons;const i={altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey};this.restartLongPressTimer(i);window.addEventListener(this.upEvent,this.handleUp);window.addEventListener(this.moveEvent,this.handleMove)}handleMove(t){this.handlePointerMove(o.create(t.clientX,t.clientY),this.isTouch(t))}handleUp(t){if(this.pointerDownPosition!=null){window.removeEventListener(this.upEvent,this.handleUp);window.removeEventListener(this.moveEvent,this.handleMove)}this.handlePointerEnd(o.create(t.clientX,t.clientY),{altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey},this.buttons,this.isTouch(t));this.buttons=undefined}handlePointerMove(t,i){var s;const n=((s=this.interactionApi)===null||s===void 0?void 0:s.pixelThreshold(i))||2;if(this.pointerDownPosition!=null&&o.distance(t,this.pointerDownPosition)>=n&&this.interactionTimer==null){this.clearPositions()}}handlePointerEnd(t,i={},s=0,n=false){var e,o;if(t!=null){if(this.longPressTimer!=null){this.emit((e=this.interactionApi)===null||e===void 0?void 0:e.tap)(t,i,s)}if(this.doubleTapTimer!=null&&this.secondPointerDownPosition!=null){this.emit((o=this.interactionApi)===null||o===void 0?void 0:o.doubleTap)(t,i,s,this.secondPointerDownPosition);this.clearDoubleTapTimer()}}this.pointerDownPosition=undefined;this.clearLongPressTimer()}emit(t){return(i,s={},n=0,e,h=false)=>{var r;const a=e||this.pointerDownPosition;const c=((r=this.interactionApi)===null||r===void 0?void 0:r.pixelThreshold(h))||1;let l;if(this.interactionTimer!=null){l=this.getCanvasPosition(a||i)}else if(a!=null&&o.distance(a,i)<=c){l=this.getCanvasPosition(i)}if(l!=null&&t!=null){t(l,s,n)}}}getCanvasPosition(t){var i;const s=(i=this.element)===null||i===void 0?void 0:i.getBoundingClientRect();const n=s!=null?o.create(s.left,s.top):undefined;return n!=null?o.subtract(o.create(t.x,t.y),n):undefined}clearPositions(){this.pointerDownPosition=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer();this.clearInteractionTimer()}clearDoubleTapTimer(){if(this.doubleTapTimer!=null){window.clearTimeout(this.doubleTapTimer)}this.doubleTapTimer=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined}restartDoubleTapTimer(){this.clearDoubleTapTimer();this.doubleTapTimer=window.setTimeout((()=>this.clearDoubleTapTimer()),this.getConfig().events.doubleTapThreshold)}clearLongPressTimer(){if(this.longPressTimer!=null){window.clearTimeout(this.longPressTimer)}this.longPressTimer=undefined}restartLongPressTimer(t={}){this.clearLongPressTimer();this.longPressTimer=window.setTimeout((()=>{var i;if(this.pointerDownPosition){this.emit((i=this.interactionApi)===null||i===void 0?void 0:i.longPress)(this.pointerDownPosition,t,this.buttons)}this.clearLongPressTimer()}),this.getConfig().events.longPressThreshold)}restartInteractionTimer(){this.clearInteractionTimer();this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=undefined}),this.getConfig().interactions.interactionDelay)}clearInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}setPointerPositions(t){this.pointerDownPosition=t;this.restartInteractionTimer();if(this.firstPointerDownPosition==null){this.restartDoubleTapTimer();this.firstPointerDownPosition=t}else{this.secondPointerDownPosition=t}}isTouch(t){return window.PointerEvent!=null&&t instanceof PointerEvent?t.pointerType==="touch":false}}class Gt extends _t{constructor(){super();this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("touchstart",this.handleTouchStart);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("touchstart",this.handleTouchStart)}handleTouchStart(t){if(t.touches.length>=1){t.preventDefault();const i=t.touches[0];this.currentPosition1=o.create(i.screenX,i.screenY);if(t.touches[1]!=null){this.beginTwoPointTouch(this.currentPosition1,o.create(t.touches[1].screenX,t.touches[1].screenY))}window.addEventListener("touchmove",this.handleTouchMove,{passive:false});window.addEventListener("touchend",this.handleTouchEnd)}}handleTouchMove(t){t.preventDefault();if(t.touches.length===1){this.handleOnePointTouchMove(t.touches[0])}else if(t.touches.length===2){const i=o.create(t.touches[0].clientX,t.touches[0].clientY);const s=o.create(t.touches[1].clientX,t.touches[1].clientY);this.handleTwoPointTouchMove(i,s)}}handleTouchEnd(t){var i;t.preventDefault();(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction();this.isInteracting=false;window.removeEventListener("touchmove",this.handleTouchMove);window.removeEventListener("touchend",this.handleTouchEnd);this.endTwoPointTouch()}handleOnePointTouchMove(t){var i,s,n;const e=o.create(t.screenX,t.screenY);if(this.currentPosition1!=null){const t=o.subtract(e,this.currentPosition1);const h=((i=this.interactionApi)===null||i===void 0?void 0:i.pixelThreshold(true))||2;if(o.distance(e,this.currentPosition1)>=h||this.isInteracting){(s=this.interactionApi)===null||s===void 0?void 0:s.beginInteraction();(n=this.interactionApi)===null||n===void 0?void 0:n.rotateCamera(t);this.isInteracting=true}}this.currentPosition1=e}}class Yt{constructor(t,i=window.performance){this.name=t;this.perf=i;this.measures=new Set;this.nextId=0}clearMeasurements(){this.perf.clearMeasures(this.name)}measure(t){if(Ct(t)){const i=this.begin();return t.finally((()=>this.end(i)))}else if(typeof t==="function"){const i=this.begin();const s=t();this.end(i);return s}else{throw new Error("Input must be a function or Promise")}}takeMeasurements(){const t=this.perf.getEntriesByName(this.name);this.clearMeasurements();return t}takeLastMeasurement(){const t=this.takeMeasurements();return t[t.length-1]}begin(){const t=`${this.name}-${this.nextId++}`;this.measures.add(t);this.perf.mark(t);return t}end(t){this.perf.measure(this.name,t);this.perf.clearMarks(t);this.measures.delete(t)}}const Qt=new Yt("paint_time");function ti(t){return new Promise(((i,s)=>{const n=new Blob([t]);const e=URL.createObjectURL(n);const o=new Image;o.addEventListener("load",(()=>{i({image:o,dispose:()=>undefined});URL.revokeObjectURL(e)}));o.addEventListener("error",(()=>{s(new E("Failed to load image data"));URL.revokeObjectURL(e)}));o.src=e}))}async function ii(t){const i=new Blob([t]);const s=await window.createImageBitmap(i);return{image:s,dispose:()=>s.close()}}function si(t){if(window.createImageBitmap!=null){return ii(t)}else{return ti(t)}}const ni=1e3;function ei(t,i){const s=i.viewport.calculateDrawRect(i.frame.image);i.canvas.clearRect(0,0,i.canvasDimensions.width,i.canvasDimensions.height);i.canvas.drawImage(t.image,s.x,s.y,s.width,s.height)}function oi(t,i){const s=t.takeMeasurements();if(s.length>0){i(s)}}function hi(t,i,s,n,e=ni){let o;let h=0;let r;let a=[];function c(){h++;if(o==null){o=setInterval((()=>{oi(t,n);if(h===0){u()}}),e)}}function l(){h--}function u(){if(o!=null){clearInterval(o);o=undefined}}if(s){setInterval((()=>{if(r!=null){if(a.length===5){a=[...a.slice(1),r]}else{a.push(r)}const t=a.reduce(((t,i)=>t+i))/a.length;console.debug(`Paint rate: ${r}fps`);console.debug(`Paint rate (avg): ${t}`);r=undefined}}),1e3)}return s=>{c();return t.measure((async()=>{const t=await i(s);r=r==null?1:r+1;return t})).finally((()=>l()))}}function ri(){let t=[];function i(i){if(i!=null){const s=i.copy({correlationIds:[...i.correlationIds,...t.filter((t=>!i.correlationIds.includes(t)))]});t=[];return s}return i}function s(){let t=-1;return async i=>{if(i.frame.sequenceNumber>t){const s=await si(i.frame.image.imageBytes);t=i.frame.sequenceNumber;return s}}}function n(){let t=-1;return async(i,s)=>{var n;if(s!=null&&i.frame.sequenceNumber>t){t=i.frame.sequenceNumber;(n=i.beforeDraw)===null||n===void 0?void 0:n.call(i);ei(s,i);s.dispose();return i.frame}s===null||s===void 0?void 0:s.dispose()}}const e=s();const o=n();return async s=>{var n,h;const r=(h=(n=s.predicate)===null||n===void 0?void 0:n.call(s))!==null&&h!==void 0?h:true;t=[...t,...s.frame.correlationIds];if(r){return e(s).then((t=>o(s,t).then(i)))}}}function ai(t){return i=>{var s;const n=(s=i.request.requestId)===null||s===void 0?void 0:s.value;if(n!=null){t(n)(i)}}}function ci(t){return i=>{const{drawFrame:s}=i.request;if(s!=null){t(s)(i)}}}const li=1*60;function ui(t){let i=false;return s=>{const n=t();if(n!=null){const t=n.remoteTime(new Date(Date.now()));const e=w(s,t);const o=p(e).getTime();if(o>=0){return e}else{if(!i){console.warn(`Possible erroneous send to receive timing. Muting for ${li}s. [sent-at=${s.toISOString()}, received-at=${t.toISOString()}, remote-time=${n.knownRemoteTime.toISOString()}]`);i=true;setTimeout((()=>i=false),li*1e3)}return undefined}}}}function di(t,i){const s=ui(i);return ai((i=>ci((n=>n=>{const e=p(n.sentAtTime);if(e!=null){t.replyResult(i,{drawFrame:{sendToReceiveDuration:s(e)}})}}))))}var fi;(function(t){t["DEVICE_ID"]="vertexvis:device-id"})(fi||(fi={}));function pi(t,i,s=window.localStorage){const n=s.getItem(t);if(n!=null){const e=Object.assign(Object.assign({},JSON.parse(n)),i);s.setItem(t,JSON.stringify(e))}else{s.setItem(t,JSON.stringify(i))}}function wi(t,i,s=window.localStorage){const n=s.getItem(t);if(n!=null){return i(JSON.parse(n))}}var mi=function t(i,s){if(i===s)return true;if(i&&s&&typeof i=="object"&&typeof s=="object"){if(i.constructor!==s.constructor)return false;var n,e,o;if(Array.isArray(i)){n=i.length;if(n!=s.length)return false;for(e=n;e--!==0;)if(!t(i[e],s[e]))return false;return true}if(i.constructor===RegExp)return i.source===s.source&&i.flags===s.flags;if(i.valueOf!==Object.prototype.valueOf)return i.valueOf()===s.valueOf();if(i.toString!==Object.prototype.toString)return i.toString()===s.toString();o=Object.keys(i);n=o.length;if(n!==Object.keys(s).length)return false;for(e=n;e--!==0;)if(!Object.prototype.hasOwnProperty.call(s,o[e]))return false;for(e=n;e--!==0;){var h=o[e];if(!t(i[h],s[h]))return false}return true}return i!==i&&s!==s};class vi extends m{constructor(t,i={}){var s,n,e,o,h;super(t,{loggingEnabled:i.loggingEnabled});this.state={type:"disconnected"};this.stateChanged=new P;this.dimensions=d.create(0,0);this.streamAttributes={};this.enableTemporalRefinement=(s=i.enableTemporalRefinement)!==null&&s!==void 0?s:true;this.frameBgColor=I.create(255,255,255);this.config=ot("platprod");this.options={tokenRefreshOffsetInSeconds:(n=i.tokenRefreshOffsetInSeconds)!==null&&n!==void 0?n:30,offlineThresholdInSeconds:(e=i.offlineThresholdInSeconds)!==null&&e!==void 0?e:30,loadTimeoutInSeconds:(o=i.loadTimeoutInSeconds)!==null&&o!==void 0?o:15,enableTemporalRefinement:(h=i.enableTemporalRefinement)!==null&&h!==void 0?h:true}}getState(){return this.state}disconnect(){if(this.state.type!=="disconnected"&&this.state.type!=="connection-failed"){console.debug("Disconnecting websocket");this.state.connection.dispose();this.updateState({type:"disconnected"})}}async load(t,i,s,n=ot("platprod")){this.clientId=i;this.deviceId=s;this.config=n;if(this.state.type==="disconnected"){return this.loadIfDisconnected(t)}else if(this.state.type==="connection-failed"){return this.loadIfDisconnected(t)}else if(this.state.type==="reconnecting"){return this.loadIfConnectingOrConnected(t,this.state)}else if(this.state.type==="connecting"){return this.loadIfConnectingOrConnected(t,this.state)}else{return this.loadIfConnectingOrConnected(t,this.state)}}update(t){this.frameBgColor=t.frameBgColor?t.frameBgColor:this.frameBgColor;if(t.dimensions!=null&&!mi(t.dimensions,this.dimensions)){this.dimensions=t.dimensions;this.ifState("connected",(()=>this.updateDimensions({dimensions:this.getDimensions()})))}if(t.streamAttributes!=null&&!mi(this.streamAttributes,t.streamAttributes)){this.streamAttributes=t.streamAttributes;this.ifState("connected",(()=>this.updateStream({streamAttributes:gi(this.streamAttributes)})))}if(t.enableTemporalRefinement!=null&&t.enableTemporalRefinement!==this.enableTemporalRefinement){this.enableTemporalRefinement=t.enableTemporalRefinement;if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}}async loadIfConnectingOrConnected(t,i){var s;const{resource:n,subResource:e}=i.resource;const o=ft(t);const h=!S.isEqual(n,o.resource);const r=!S.isEqual(e,o.subResource);const a=i.type==="connecting"||i.type==="reconnecting";const c=i.type==="connected";const l=o.queries.find((t=>t.type==="supplied-id"));if(h||a&&r){this.disconnect();return this.loadIfDisconnected(t)}else if(c&&r&&((s=o.subResource)===null||s===void 0?void 0:s.type)==="scene-view-state"){const t=Object.assign(Object.assign({},o.subResource.id!=null?{sceneViewStateId:{hex:o.subResource.id}}:{}),l!=null?{sceneViewStateSuppliedId:{value:l.id}}:{});await this.loadSceneViewState(t);this.updateState(Object.assign(Object.assign({},i),{resource:o}))}}async loadIfDisconnected(t){try{await this.connectWithNewStream(ft(t))}catch(t){if(t instanceof k){this.updateState({type:"connection-failed",message:`Cannot load scene. ${t.message}`,error:t})}else if(t instanceof v){this.updateState({type:"connection-failed",message:`Cannot load scene. Stream request failed to start stream.`,error:t})}else{this.updateState({type:"connection-failed",message:`Cannot load scene for unknown reason. See console logs.`,error:t})}throw t}}connectWithNewStream(t){return this.openWebsocketStream(t,"connecting",(()=>this.requestNewStream(t)))}connectToExistingStream(t){return this.openWebsocketStream(t.resource,"reconnecting",(()=>this.requestReconnectStream(t)),{maxRetries:Number.POSITIVE_INFINITY})}async openWebsocketStream(t,i,s,{maxRetries:n=3}={}){const e=Ci(Pi(this.config,t.resource,this.clientId,this.deviceId));console.debug(`Initiating WS connection [uri=${e.url}]`);const o=new AbortController;const h=bi(this.config);this.updateState({type:i,resource:t,connection:{dispose:()=>{this.dispose();o.abort()}}});const r=await T.abort(o.signal,T.retry((()=>this.connect(e,h)),{maxRetries:n,delaysInMs:vi.WS_RECONNECT_DELAYS})).catch((t=>{throw new x("Websocket connection failed.",t instanceof Error?t:undefined)}));if(!r.aborted){return this.requestNewOrExistingStream(t,r.result,s)}else{this.updateState({type:"disconnected"})}}async requestNewOrExistingStream(t,i,s){const n=this.requestClock();const e=await s();console.debug(`Stream connected [stream-id=${e.streamId}, scene-id=${e.sceneId}, scene-view-id=${e.sceneViewId}]`);const o=this.onRequest((t=>{const i=t.request.drawFrame;if(i!=null){const t=G(e.worldOrientation)(i);if(this.state.type==="connected"){if(t.depthBufferBytes!=null||this.state.frame.temporalRefinementCorrelationId!==t.temporalRefinementCorrelationId){this.updateState(Object.assign(Object.assign({},this.state),{frame:t,fallbackDepthBufferBytes:t.depthBufferBytes}))}else{this.updateState(Object.assign(Object.assign({},this.state),{frame:t.copy({depthBufferBytes:this.state.fallbackDepthBufferBytes})}))}}}}));const h=this.reconnectWhenNeeded();const r=this.refreshTokenWhenExpired(e.token);const a=this.acknowledgeFrameRequests();const c=e.frame==null?await this.waitForFrame(e.worldOrientation,this.options.loadTimeoutInSeconds):e.frame;const l=await n;console.debug(`Synchronized clocks [local-time=${l.knownLocalTime.toISOString()}, remote-time=${l.knownRemoteTime.toISOString()}]`);this.updateState({type:"connected",connection:{dispose:()=>{h.dispose();o.dispose();r.dispose();a.dispose();i.dispose()}},resource:t,streamId:e.streamId,deviceId:e.deviceId,sceneId:e.sceneId,sceneViewId:e.sceneViewId,worldOrientation:e.worldOrientation,token:e.token,frame:c,clock:l,fallbackDepthBufferBytes:undefined})}async requestNewStream(t){var i,s;const n=t.queries.find((t=>t.type==="supplied-id"));const e=Y(await this.startStream({streamKey:{value:t.resource.id},dimensions:this.getDimensions(),frameBackgroundColor:yi(this.frameBgColor),clientSupportsTemporalRefinement:this.enableTemporalRefinement,streamAttributes:gi(this.streamAttributes),sceneViewStateId:((i=t.subResource)===null||i===void 0?void 0:i.type)==="scene-view-state"&&t.subResource.id!=null?{hex:t.subResource.id}:undefined,sceneViewStateSuppliedId:((s=t.subResource)===null||s===void 0?void 0:s.type)==="scene-view-state"&&n!=null?{value:n.id}:undefined}));return{resource:t,streamId:e.streamId,sceneId:e.sceneId,sceneViewId:e.sceneViewId,deviceId:e.sessionId,token:e.token,worldOrientation:e.worldOrientation,frame:undefined,fallbackDepthBufferBytes:undefined}}async requestReconnectStream(t){const i=Q(await this.reconnect({streamId:{hex:t.streamId},dimensions:this.getDimensions(),frameBackgroundColor:yi(this.frameBgColor),streamAttributes:gi(this.streamAttributes),clientSupportsTemporalRefinement:this.enableTemporalRefinement}));return Object.assign(Object.assign({},t),{token:i.token})}async requestClock(){const t=tt(await this.syncTime({requestTime:g()}));return new pt(t)}reconnectWhenNeeded(){const t=this.onClose((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}));const i=this.onRequest((t=>{const i=t.request.gracefulReconnection!=null;if(i&&this.state.type==="connected"){console.debug("Received request for graceful reconnect. Closing connection and attempting reconnect.");this.closeAndReconnect(this.state)}}));const s=this.reconnectWhenOffline();return{dispose:()=>{t.dispose();i.dispose();s.dispose()}}}refreshTokenWhenExpired(t){let i;const s=t=>{const{tokenRefreshOffsetInSeconds:n}=this.options;const e=t.remainingTimeInMs(n);i=window.setTimeout((async()=>{const t=await this.refreshToken();const i=it(t);s(i);if(this.state.type==="connected"){this.updateState(Object.assign(Object.assign({},this.state),{token:i}))}}),e)};s(t);return{dispose:()=>clearTimeout(i)}}reconnectWhenOffline(){let t;const i=()=>window.clearTimeout(t);const s=()=>{i();const s=this.options.offlineThresholdInSeconds;console.debug(`Detected that host is offline. Will attempt reconnect in ${s}s.`);t=window.setTimeout((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}),s*1e3)};const n=()=>{console.debug("Detected that host is online.");i()};const e=()=>s();window.addEventListener("offline",e);window.addEventListener("online",n);return{dispose:()=>{i();window.removeEventListener("offline",s);window.removeEventListener("online",i)}}}closeAndReconnect(t){t.connection.dispose();return this.connectToExistingStream(t)}async waitForFrame(t,i){let s;try{return await T.timeout(i*1e3,new Promise((i=>{s=this.onRequest((n=>{try{const e=n.request.drawFrame;if(e!=null){const s=G(t)(e);i(s)}}finally{s===null||s===void 0?void 0:s.dispose()}}))})))}catch(t){throw new O(`Frame timed out after ${i/1e3}s`,t instanceof Error?t:undefined)}finally{s===null||s===void 0?void 0:s.dispose()}}acknowledgeFrameRequests(){return this.onRequest(di(this,(()=>this.state.type==="connected"?this.state.clock:undefined)))}updateState(t){if(this.state!==t){this.state=t;this.stateChanged.emit(this.state)}}getDimensions(){if(d.area(this.dimensions)===0){return d.create(1,1)}return this.dimensions}ifState(t,i){if(this.state.type===t){return i()}}onStateChanged(t){return this.stateChanged.on(t)}}vi.WS_RECONNECT_DELAYS=[0,1e3,1e3,5e3];const gi=b.ifInvalidThrow(X);const yi=b.ifInvalidThrow(Z);function bi(t){return{EXPERIMENTAL_frameDelivery:Object.assign(Object.assign({},t.EXPERIMENTAL_frameDelivery),{rateLimitingEnabled:t.flags.throttleFrameDelivery}),EXPERIMENTAL_adaptiveRendering:Object.assign(Object.assign({},t.EXPERIMENTAL_adaptiveRendering),{enabled:t.flags.adaptiveRendering}),EXPERIMENTAL_qualityOfService:Object.assign({},t.EXPERIMENTAL_qualityOfService)}}function Ci(t){return{url:D.toString(t),protocols:["ws.vertexvis.com"]}}function Pi(t,i,s,n){if(s!=null){return D.appendPath(D.toString(D.parseAndAddParams("/ws",{clientId:s,deviceId:n})),D.parse(t.network.renderingHost))}else{return D.appendPath(`/stream-keys/${i.id}/session`,D.parse(t.network.renderingHost))}}const Ti=15e3;function Ii(t){return t.getBoundingClientRect()}function Si(t,i){const s=window.getComputedStyle(t);const n=s.getPropertyValue(i);return n!==""?n:undefined}const Di=":host{--image-background:var(--image-background);--viewer-background:var(--viewer-background);display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}.enable-pointer-events{touch-action:none}.viewer-container{width:100%;height:100%;overflow:hidden}.error-message{position:absolute;top:50%;width:100%;transform:translateY(-50%);text-align:center}";const Ai=class{constructor(s){t(this,s);this.tap=i(this,"tap",7);this.doubletap=i(this,"doubletap",7);this.longpress=i(this,"longpress",7);this.frameReceived=i(this,"frameReceived",7);this.frameDrawn=i(this,"frameDrawn",7);this.tokenExpired=i(this,"tokenExpired",7);this.connectionChange=i(this,"connectionChange",7);this.sceneReady=i(this,"sceneReady",7);this.sceneChanged=i(this,"sceneChanged",7);this.interactionStarted=i(this,"interactionStarted",7);this.interactionFinished=i(this,"interactionFinished",7);this.cameraTypeChanged=i(this,"cameraTypeChanged",7);this.annotationStateChanged=i(this,"annotationStateChanged",7);this.deviceIdChange=i(this,"deviceIdChange",7);this.dimensionschange=i(this,"dimensionschange",7);this.configEnv="platprod";this.cameraControls=true;this.cameraType="perspective";this.keyboardControls=true;this.rotateAroundTapPoint=true;this.phantom={opacity:.1};this.noDefaultLights=false;this.enableTemporalRefinement=true;this.experimentalRenderingOptions="";this.resizeDebounce=100;this.stencilBuffer=new yt(this.hostElement);this.viewport=lt.fromDimensions(d.create(0,0));this.stateMap={cursorManager:new ht,streamState:{type:"disconnected"}};this.interactionHandlers=[];this.defaultInteractionHandlerDisposables=[];this.tapKeyInteractions=[];this.defaultTapKeyInteractions=[];this.internalFrameDrawnDispatcher=new P;this.handleElementResize=this.handleElementResize.bind(this)}componentWillLoad(){var t;this.updateResolvedConfig();this.calculateComponentDimensions();this.resizeObserver=new ResizeObserver(this.handleElementResize);this.registerSlotChangeListeners();const i=this.getResolvedConfig();const s=new f(i.network.sceneViewHost);this.annotations=new xt(s,(()=>this.token),(()=>this.deviceId));this.annotations.onStateChange.on((t=>this.annotationStateChanged.emit(t)));this.stream=(t=this.stream)!==null&&t!==void 0?t:new vi(new y,{loggingEnabled:i.flags.logWsMessages,enableTemporalRefinement:this.enableTemporalRefinement});this.addStreamListeners();this.updateStreamAttributes();this.stateMap.cursorManager.onChanged.on((()=>this.handleCursorChanged()))}async componentDidLoad(){var t;this.interactionApi=this.createInteractionApi();if(this.canvasContainerElement!=null){(t=this.resizeObserver)===null||t===void 0?void 0:t.observe(this.canvasContainerElement)}if(this.src!=null){this.load(this.src).catch((t=>{console.error("Error loading scene",t)}))}await this.initializeDefaultInteractionHandlers();this.injectViewerApi()}render(){var t;return s(n,null,s("div",{ref:t=>this.viewerContainerElement=t,class:"viewer-container",style:{cursor:at((t=this.cursor)!==null&&t!==void 0?t:"")},onContextMenu:t=>t.preventDefault()},s("div",{ref:t=>this.canvasContainerElement=t,class:A("canvas-container",{"enable-pointer-events ":window.PointerEvent!=null})},s("canvas",{ref:t=>{this.canvasElement=t;this.stateMap.interactionTarget=t},class:"canvas"}),this.errorMessage!=null?s("div",{class:"error-message"},this.errorMessage):null),s("slot",null)))}async dispatchFrameDrawn(t){this.frame=t;this.internalFrameDrawnDispatcher.emit(t);this.frameDrawn.emit(t)}async registerInteractionHandler(t){this.interactionHandlers.push(t);this.initializeInteractionHandler(t);return{dispose:()=>{const i=this.interactionHandlers.indexOf(t);if(i!==-1){this.interactionHandlers[i].dispose();this.interactionHandlers.splice(i,1)}}}}async registerTapKeyInteraction(t){this.tapKeyInteractions=[...this.tapKeyInteractions,t]}async getInteractionTarget_DEPRECATED(){if(this.stateMap.interactionTarget!=null){return this.stateMap.interactionTarget}else throw new Error("Interaction target is undefined.")}async addCursor(t,i){return this.stateMap.cursorManager.add(t,i)}async getInteractionHandlers(){return this.interactionHandlers}async getKeyInteractions(){return this.tapKeyInteractions}async getBaseInteractionHandler(){return this.baseInteractionHandler}async getJwt(){return this.token}handleSrcChanged(t){if(t!=null){this.load(t)}else{this.unload()}}handleCameraControlsChanged(){this.initializeDefaultCameraInteractionHandlers()}handleKeyboardControlsChanged(){this.initializeDefaultKeyboardInteractionHandlers()}handleRotateAboutTapPointChanged(){var t,i;this.updateStreamAttributes();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}else{(i=this.baseInteractionHandler)===null||i===void 0?void 0:i.setPrimaryInteractionType("rotate")}}handleCameraTypeChanged(t,i){if(t!==i){this.updateCameraType()}}handleDepthBuffersChanged(){this.updateStreamAttributes()}handlePhantomChanged(){this.updateStreamAttributes()}handleNoDefaultLightsChanged(){this.updateStreamAttributes()}handleExperimentalRenderingOptionsChanged(){this.updateStreamAttributes()}handleEnableTemporalRefinementChanged(){this.updateEnableTemporalRefinement()}handleFeatureLinesChanged(){this.updateStreamAttributes()}handleSelectionHighlightingChanged(){this.updateStreamAttributes()}handleFeatureHighlightingChanged(){this.updateStreamAttributes()}handleFeatureMapsChanged(){this.updateStreamAttributes()}handleConfigChanged(){this.updateResolvedConfig()}handleConfigEnvChanged(){this.updateResolvedConfig()}async load(t){var i,s;if(this.stream!=null&&this.dimensions!=null){const{EXPERIMENTAL_annotationPollingIntervalInMs:n}=this.getResolvedConfig();this.calculateComponentDimensions();this.stream.update({streamAttributes:this.getStreamAttributes(),config:ot(this.configEnv,this.config),dimensions:this.dimensions,frameBgColor:this.getBackgroundColor()});await((i=this.stream)===null||i===void 0?void 0:i.load(t,this.clientId,this.getDeviceId(),this.getResolvedConfig()));this.sceneReady.emit();if(n!==undefined){(s=this.annotations)===null||s===void 0?void 0:s.connect(n)}}else{throw new M("Cannot load scene. Viewer has not been initialized.")}}async unload(){var t;if(this.stream!=null){(t=this.annotations)===null||t===void 0?void 0:t.disconnect();this.stream.disconnect();this.frame=undefined;this.errorMessage=undefined}if(this.canvasElement!=null){const t=this.canvasElement.getContext("2d");if(t!=null){t.clearRect(0,0,this.canvasElement.width,this.canvasElement.height)}}}async scene(){return this.createScene()}async isSceneReady(){return this.stateMap.streamState.type==="connected"}async handleTapEvent(t){this.tapKeyInteractions.filter((i=>i.predicate(t.detail))).forEach((i=>i.fn(t.detail)))}emitConnectionChange(t){this.connectionChange.emit(t)}handleElementResize(t){const i=t.length>0&&this.dimensions!=null&&!d.isEqual(t[0].contentRect,this.viewport);if(i){if(this.resizeTimer!=null){clearTimeout(this.resizeTimer);this.resizeTimer=undefined}if(!this.isResizing){this.resizeTimer=setTimeout((()=>{this.isResizing=true;this.isResizeUpdate=true;this.recalculateComponentDimensions()}),this.resizeDebounce)}}}registerSlotChangeListeners(){this.mutationObserver=new MutationObserver((t=>this.injectViewerApi()));this.mutationObserver.observe(this.hostElement,{childList:true,subtree:true});this.styleObserver=new MutationObserver((t=>this.syncViewerStyles()));this.styleObserver.observe(this.hostElement,{attributes:true,attributeFilter:["style"]})}injectViewerApi(){function t(t){return Array.from(t.querySelectorAll("*"))}const i=t(this.hostElement);i.filter((t=>t.nodeName.startsWith("VERTEX-"))).reduce(((i,s)=>[...i,s,...t(s)]),[]).forEach((t=>{t.viewer=this.hostElement}))}syncViewerStyles(){var t;const i=this.getBackgroundColor();(t=this.stream)===null||t===void 0?void 0:t.update({frameBgColor:i,streamAttributes:this.getStreamAttributes()})}calculateComponentDimensions(){var t;const i=2073600;const s=this.getBounds();if((s===null||s===void 0?void 0:s.width)!=null&&(s===null||s===void 0?void 0:s.height)!=null){const n=d.create(s.width,s.height);const e=d.scaleFit(i,n);this.hostDimensions=n;this.dimensions=e!=null?d.create(e.width,e.height):undefined;this.viewport=lt.fromDimensions((t=this.getCanvasDimensions())!==null&&t!==void 0?t:d.create(0,0))}}recalculateComponentDimensions(){var t;if(this.isResizing){this.calculateComponentDimensions();this.isResizing=false;if(((t=this.stream)===null||t===void 0?void 0:t.getState().type)==="connected"){this.updateDimensions(this.dimensions)}}}reportPerformance(t){if(this.stateMap.streamState.type==="connected"){const i={timings:t.map((t=>({receiveToPaintDuration:w(t.duration)})))};this.getStream().recordPerformance(i,false)}}addStreamListeners(){this.stateMap.streamListeners=this.getStream().stateChanged.on((t=>{this.handleStreamStateChanged(this.stateMap.streamState,t)}))}handleStreamStateChanged(t,i){this.stateMap.streamState=i;if(i.type==="connecting"){this.handleConnecting(t,i)}else if(i.type==="connected"){this.handleConnected(t,i)}else if(i.type==="connection-failed"){this.handleConnectionFailed(t,i)}else if(i.type==="disconnected"){this.handleDisconnected(t,i)}}handleConnecting(t,i){if(t.type!=="connecting"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"connecting"})}}handleConnected(t,i){var s;this.token=i.token.token;if(t.type!=="connected"){this.errorMessage=undefined;this.canvasRenderer=hi(Qt,ri(),this.getResolvedConfig().flags.logFrameRate,(t=>this.reportPerformance(t)));this.emitConnectionChange({status:"connected",jwt:i.token.token});this.deviceIdChange.emit(i.deviceId)}if(((s=this.frame)===null||s===void 0?void 0:s.getId())!==i.frame.getId()){this.updateFrame(i.frame)}this.updateDimensions(this.dimensions)}handleConnectionFailed(t,i){if(t.type!=="connection-failed"){this.token=undefined;this.errorMessage=i.message;this.emitConnectionChange({status:"connection-failed",errorMessage:i.message})}}handleDisconnected(t,i){if(t.type!=="disconnected"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"disconnected"})}}updateDimensions(t){var i;(i=this.stream)===null||i===void 0?void 0:i.update({dimensions:t});this.dimensionschange.emit(t)}async updateFrame(t){var i;const s=this.getCanvasDimensions();if(this.canvasElement!=null&&s!=null&&((i=this.frame)===null||i===void 0?void 0:i.getId())!==t.getId()){const i=this.canvasElement.getContext("2d");if(i!=null){const n=this.frame;this.frame=st(t,n);this.updateInteractionApi(n);const e={canvas:i,canvasDimensions:s,dimensions:this.dimensions,frame:this.frame,viewport:this.viewport,beforeDraw:()=>{this.updateCanvasDimensions(s);this.isResizeUpdate=false},predicate:()=>{if(this.isResizeUpdate){return this.dimensions==null||d.isEqual(this.dimensions,e.frame.image.imageAttr.frameDimensions)}return true}};this.frameReceived.emit(this.frame);if(this.frame.scene.hasChanged){this.sceneChanged.emit()}const o=await this.canvasRenderer(e);if(o!=null){this.updateViewerBackground();this.dispatchFrameDrawn(o)}}}}updateViewerBackground(){const t=this.getBackgroundColor();mt((()=>{var i,s;(i=this.viewerContainerElement)===null||i===void 0?void 0:i.style.setProperty("background",t!=null?I.toHexString(t):"#ffffff");(s=this.canvasContainerElement)===null||s===void 0?void 0:s.style.setProperty("background",t!=null?I.toHexString(t):"#ffffff")}))}async initializeDefaultInteractionHandlers(){var t;await this.initializeDefaultCameraInteractionHandlers();await this.initializeDefaultTapInteractionHandler();this.initializeDefaultKeyboardInteractionHandlers();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}}clearDefaultCameraInteractionHandlers(){this.defaultInteractionHandlerDisposables.forEach((t=>t.dispose()));this.defaultInteractionHandlerDisposables=[]}clearDefaultKeyboardInteractions(){this.defaultTapKeyInteractions.forEach((t=>{const i=this.tapKeyInteractions.indexOf(t);if(i!==-1){this.tapKeyInteractions.splice(i,1)}}));this.tapKeyInteractions=[]}async initializeDefaultCameraInteractionHandlers(){var t,i;this.clearDefaultCameraInteractionHandlers();if(this.cameraControls){if(window.PointerEvent!=null){this.baseInteractionHandler=(t=this.baseInteractionHandler)!==null&&t!==void 0?t:new Xt((()=>this.getResolvedConfig()));const i=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Jt);this.defaultInteractionHandlerDisposables=[i,s]}else{this.baseInteractionHandler=(i=this.baseInteractionHandler)!==null&&i!==void 0?i:new qt((()=>this.getResolvedConfig()));const t=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Gt);this.defaultInteractionHandlerDisposables=[t,s]}}}initializeDefaultKeyboardInteractionHandlers(){var t;this.clearDefaultKeyboardInteractions();if(this.keyboardControls&&this.stream!=null){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setDefaultKeyboardControls(this.keyboardControls);const i=new Ot(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()));const s=new Ft(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()),(()=>this.createScene()));this.registerTapKeyInteraction(i);this.registerTapKeyInteraction(s);this.defaultTapKeyInteractions=[i,s]}}async initializeDefaultTapInteractionHandler(){if(this.tapHandlerDisposable==null){if(window.PointerEvent!=null){const t=new Zt("pointerdown","pointerup","pointermove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}else{const t=new Zt("mousedown","mouseup","mousemove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}}}initializeInteractionHandler(t){if(this.stateMap.interactionTarget==null){throw new R("Cannot initialize interaction handler. Interaction target is undefined.")}if(this.interactionApi==null){throw new R("Cannot initialize interaction handler. Interaction APi is undefined.")}t.initialize(this.stateMap.interactionTarget,this.interactionApi)}createInteractionApi(){if(this.stream==null){throw new B("Cannot create interaction API. Component has not been initialized.")}return this.frame==null||this.frame.scene.camera.isPerspective()?new zt(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished):new Rt(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished)}handleCursorChanged(){window.requestAnimationFrame((()=>{this.cursor=this.stateMap.cursorManager.getActiveCursor()}))}async createScene(){const t=await this.waitForConnectedState();const{frame:i,sceneId:s,sceneViewId:n,worldOrientation:e}=t;return new wt(this.getStream(),i,G(e),(()=>this.getImageScale()),this.viewport,s,n)}getBackgroundColor(){if(this.canvasContainerElement!=null){const t=Si(this.hostElement,"--image-background");const i=Si(this.hostElement,"--viewer-background");const s=t!==null&&t!==void 0?t:i;return s!=null?I.fromCss(s):I.create(255,255,255)}}getBounds(){return Ii(this.hostElement)}getCanvasDimensions(){return this.getResolvedConfig().flags.letterboxFrames?this.dimensions:this.hostDimensions}getImageScale(){const t=this.getCanvasDimensions();if(this.dimensions!=null&&t!=null){return o.create(this.dimensions.width/t.width,this.dimensions.height/t.height)}}getStreamAttributes(){return{depthBuffers:this.getDepthBufferStreamAttributesValue(),phantom:this.phantom,noDefaultLights:this.noDefaultLights,featureLines:this.featureLines,featureHighlighting:this.featureHighlighting,featureMaps:this.featureMaps,experimentalRenderingOptions:this.experimentalRenderingOptions,selectionHighlighting:this.selectionHighlighting,frames:{frameBackgroundColor:this.getBackgroundColor()}}}updateCanvasDimensions(t){if(this.canvasElement!=null){this.canvasElement.width=t.width;this.canvasElement.height=t.height}}updateStreamAttributes(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({streamAttributes:this.getStreamAttributes()})}updateEnableTemporalRefinement(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({enableTemporalRefinement:this.enableTemporalRefinement})}updateInteractionApi(t){if(this.frame!=null){const i=(t==null||t.scene.camera.isPerspective())&&this.frame.scene.camera.isOrthographic();const s=(t==null||t.scene.camera.isOrthographic())&&this.frame.scene.camera.isPerspective();if(i||s){this.interactionApi=this.createInteractionApi();this.cameraType=this.frame.scene.camera.isPerspective()?"perspective":"orthographic";this.cameraTypeChanged.emit(this.cameraType);this.interactionHandlers.forEach((t=>this.initializeInteractionHandler(t)))}}}updateCameraType(){var t,i;if(this.frame!=null){if(this.cameraType==="orthographic"&&this.frame.scene.camera.isPerspective()){(t=this.stream)===null||t===void 0?void 0:t.replaceCamera({camera:J(nt(this.frame.scene.camera,this.frame.scene.boundingBox))})}else if(this.cameraType==="perspective"&&this.frame.scene.camera.isOrthographic()){(i=this.stream)===null||i===void 0?void 0:i.replaceCamera({camera:J(et(this.frame.scene.camera))})}}}getDepthBufferStreamAttributesValue(){var t;const i=(t=this.depthBuffers)!==null&&t!==void 0?t:this.rotateAroundTapPoint?"final":undefined;return i}updateResolvedConfig(){this.resolvedConfig=ot(this.configEnv,this.config)}getResolvedConfig(){return ji("Resolved config is undefined",(()=>this.resolvedConfig))}getStream(){return ji("Stream is undefined",(()=>this.stream))}getDeviceId(){if(this.deviceId==null){try{this.deviceId=wi(fi.DEVICE_ID,(t=>t["device-id"]))}catch(t){console.warn("Cannot read device ID. Local storage is not supported.")}if(this.deviceId==null){this.deviceId=C.create();try{pi(fi.DEVICE_ID,{["device-id"]:this.deviceId})}catch(t){console.warn("Cannot write device ID. Local storage is not supported.")}}}return this.deviceId}async waitForConnectedState(){if(this.stateMap.streamState.type!=="connected"){console.debug("Stream was not in a connected state. Waiting for successful connection.");return new Promise(((t,i)=>{const s=this.getStream().onStateChanged((i=>{if(i.type==="connected"){t(i)}}));setTimeout((()=>{s.dispose();i(new Error("Timed out waiting for connected state."))}),Ti)}))}return this.stateMap.streamState}get hostElement(){return e(this)}static get watchers(){return{src:["handleSrcChanged"],cameraControls:["handleCameraControlsChanged"],keyboardControls:["handleKeyboardControlsChanged"],rotateAroundTapPoint:["handleRotateAboutTapPointChanged"],cameraType:["handleCameraTypeChanged"],depthBuffers:["handleDepthBuffersChanged"],phantom:["handlePhantomChanged"],noDefaultLights:["handleNoDefaultLightsChanged"],experimentalRenderingOptions:["handleExperimentalRenderingOptionsChanged"],enableTemporalRefinement:["handleEnableTemporalRefinementChanged"],featureLines:["handleFeatureLinesChanged"],selectionHighlighting:["handleSelectionHighlightingChanged"],featureHighlighting:["handleFeatureHighlightingChanged"],featureMaps:["handleFeatureMapsChanged"],config:["handleConfigChanged"],configEnv:["handleConfigEnvChanged"]}}};function ji(t,i){const s=i();if(s!=null){return s}else throw new Error(t)}Ai.style=Di;export{Ai as vertex_viewer};
5
- //# sourceMappingURL=p-b8dfa0c1.entry.js.map