@vertexvis/viewer 0.10.2-canary.7 → 0.11.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.
- package/dist/cjs/{browser.esm-ae55f058.js → browser.esm-17419694.js} +25 -25
- package/dist/cjs/{bundle.esm-c457ad4d.js → bundle.esm-b79513ef.js} +231 -207
- package/dist/cjs/{constants-4277684a.js → constants-1d65ed39.js} +1 -1
- package/dist/cjs/{cursors-b93b43ef.js → cursors-8aaf500f.js} +1 -1
- package/dist/cjs/{dom-cdb50ebc.js → dom-40804039.js} +1 -1
- package/dist/cjs/index.cjs.js +8 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{markup-3dac4cef.js → markup-e84a143f.js} +11 -2
- package/dist/cjs/{measurement-b494bf55.js → measurement-4579193b.js} +2 -2
- package/dist/cjs/{orientation-42cc9e8d.js → orientation-09d0f3ef.js} +14 -7
- package/dist/cjs/{png-decoder-2add73dd.js → png-decoder-97ea96ba.js} +3 -3
- package/dist/cjs/{scene-23a0a330.js → scene-4397373a.js} +28524 -2446
- package/dist/cjs/{utils-6933381f.js → utils-414e6cfe.js} +2 -2
- package/dist/cjs/utils-440f0f7d.js +61 -0
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +6 -5
- package/dist/cjs/vertex-viewer-dom-element_3.cjs.entry.js +4 -4
- package/dist/cjs/{vertex-viewer-markup-arrow_2.cjs.entry.js → vertex-viewer-markup-arrow_3.cjs.entry.js} +267 -4
- package/dist/cjs/vertex-viewer-markup-tool.cjs.entry.js +43 -9
- package/dist/cjs/vertex-viewer-markup.cjs.entry.js +25 -5
- package/dist/cjs/vertex-viewer-measurement-distance_2.cjs.entry.js +8 -8
- package/dist/cjs/vertex-viewer-measurement-tool.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-measurements.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer.cjs.entry.js +141 -48
- package/dist/cjs/viewer.cjs.js +1 -1
- package/dist/cjs/{viewport-e69f8223.js → viewport-fc405a48.js} +31 -7
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/scene-tree/scene-tree.js +3 -2
- package/dist/collection/components/viewer/viewer.js +28 -3
- package/dist/collection/components/viewer-markup/utils.js +65 -1
- package/dist/collection/components/viewer-markup/viewer-markup.js +72 -16
- package/dist/collection/components/viewer-markup-circle/utils.js +2 -55
- package/dist/collection/components/viewer-markup-circle/viewer-markup-circle.js +4 -4
- package/dist/collection/components/viewer-markup-freeform.tsx/utils.js +10 -0
- package/dist/collection/components/viewer-markup-freeform.tsx/viewer-markup-freeform.css +157 -0
- package/dist/collection/components/viewer-markup-freeform.tsx/viewer-markup-freeform.js +413 -0
- package/dist/collection/components/viewer-markup-tool/viewer-markup-tool.js +63 -9
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance-components.js +1 -1
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance.js +2 -2
- package/dist/collection/lib/cursors.js +1 -1
- package/dist/collection/lib/interactions/baseInteractionHandler.js +5 -4
- package/dist/collection/lib/interactions/flyToPartKeyInteraction.js +1 -1
- package/dist/collection/lib/interactions/interactionApi.js +101 -22
- package/dist/collection/lib/interactions/mouseInteractions.js +17 -15
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js +2 -2
- package/dist/collection/lib/mappers.js +4 -3
- package/dist/collection/lib/scenes/camera.js +8 -2
- package/dist/collection/lib/scenes/operations.js +1 -1
- package/dist/collection/lib/scenes/scene.js +5 -2
- package/dist/collection/lib/types/frame.js +8 -2
- package/dist/collection/lib/types/markup.js +9 -1
- package/dist/collection/lib/types/stencilBuffer.js +2 -2
- package/dist/collection/lib/types/viewport.js +32 -8
- package/dist/collection/testing/fixtures.js +2 -1
- package/dist/esm/{browser.esm-7dbdf78a.js → browser.esm-e4fb17dc.js} +25 -25
- package/dist/esm/{bundle.esm-590d2273.js → bundle.esm-d891316f.js} +232 -208
- package/dist/esm/{constants-083f6b2c.js → constants-037e417f.js} +1 -1
- package/dist/esm/{cursors-39294365.js → cursors-00835249.js} +1 -1
- package/dist/esm/{dom-43682375.js → dom-d0877f90.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/{markup-3ce3dccd.js → markup-9b29aa94.js} +11 -3
- package/dist/esm/{measurement-78bd27fc.js → measurement-8430d5d6.js} +2 -2
- package/dist/esm/{orientation-c3e2af18.js → orientation-bb34b652.js} +14 -7
- package/dist/esm/{png-decoder-dfb97536.js → png-decoder-c4745070.js} +3 -3
- package/dist/esm/{scene-30ac6229.js → scene-72760305.js} +28532 -2454
- package/dist/esm/utils-5fe43b8a.js +52 -0
- package/dist/esm/{utils-b857bd7c.js → utils-f8e0baf7.js} +2 -2
- package/dist/esm/vertex-scene-tree.entry.js +6 -5
- package/dist/esm/vertex-viewer-dom-element_3.entry.js +4 -4
- package/dist/esm/{vertex-viewer-markup-arrow_2.entry.js → vertex-viewer-markup-arrow_3.entry.js} +267 -5
- package/dist/esm/vertex-viewer-markup-tool.entry.js +43 -9
- package/dist/esm/vertex-viewer-markup.entry.js +25 -5
- package/dist/esm/vertex-viewer-measurement-distance_2.entry.js +8 -8
- package/dist/esm/vertex-viewer-measurement-tool.entry.js +5 -5
- package/dist/esm/vertex-viewer-measurements.entry.js +5 -5
- package/dist/esm/vertex-viewer-view-cube.entry.js +3 -3
- package/dist/esm/vertex-viewer.entry.js +141 -48
- package/dist/esm/viewer.js +1 -1
- package/dist/esm/{viewport-8fea0743.js → viewport-d6f5cd7b.js} +31 -7
- package/dist/types/components/viewer/viewer.d.ts +4 -0
- package/dist/types/components/viewer-markup/utils.d.ts +8 -0
- package/dist/types/components/viewer-markup/viewer-markup.d.ts +13 -6
- package/dist/types/components/viewer-markup-circle/utils.d.ts +1 -4
- package/dist/types/components/viewer-markup-freeform.tsx/utils.d.ts +3 -0
- package/dist/types/components/viewer-markup-freeform.tsx/viewer-markup-freeform.d.ts +116 -0
- package/dist/types/components/viewer-markup-tool/viewer-markup-tool.d.ts +13 -1
- package/dist/types/components.d.ts +107 -10
- package/dist/types/lib/interactions/interactionApi.d.ts +22 -6
- package/dist/types/lib/interactions/mouseInteractions.d.ts +7 -6
- package/dist/types/lib/scenes/camera.d.ts +5 -1
- package/dist/types/lib/scenes/scene.d.ts +1 -1
- package/dist/types/lib/types/frame.d.ts +4 -1
- package/dist/types/lib/types/markup.d.ts +12 -1
- package/dist/types/lib/types/viewport.d.ts +17 -0
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/p-012fb54f.js +4 -0
- package/dist/viewer/{p-3dc15d99.entry.js → p-117324c0.entry.js} +1 -1
- package/dist/viewer/{p-1ee75110.entry.js → p-1c772ec1.entry.js} +1 -1
- package/dist/viewer/p-1f8a238b.js +4 -0
- package/dist/viewer/p-21e8510d.js +4 -0
- package/dist/viewer/{p-e3105f9a.entry.js → p-3c2aff67.entry.js} +1 -1
- package/dist/viewer/p-5389e9d4.js +4 -0
- package/dist/viewer/p-59d075d4.js +17 -0
- package/dist/viewer/{p-5b078339.js → p-62c6f482.js} +1 -1
- package/dist/viewer/p-640cb5f8.js +18 -0
- package/dist/viewer/p-68aaf1f8.entry.js +4 -0
- package/dist/viewer/{p-05b2444e.js → p-75682963.js} +1 -1
- package/dist/viewer/{p-4183c421.entry.js → p-79c45c02.entry.js} +1 -1
- package/dist/viewer/p-835e158e.js +4 -0
- package/dist/viewer/p-8c255868.entry.js +4 -0
- package/dist/viewer/{p-f4a492e1.js → p-9faabd97.js} +1 -1
- package/dist/viewer/p-b122ee39.js +4 -0
- package/dist/viewer/p-b36b3d1a.js +4 -0
- package/dist/viewer/{p-7c71db57.entry.js → p-bc9e6919.entry.js} +1 -1
- package/dist/viewer/{p-f090a3f3.entry.js → p-c818c80e.entry.js} +1 -1
- package/dist/viewer/{p-e96bc9a2.js → p-d42a482c.js} +1 -1
- package/dist/viewer/p-f43e8cc2.entry.js +4 -0
- package/dist/viewer/p-f75436be.entry.js +4 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +18 -16
- package/readme.md +6 -6
- package/dist/cjs/utils-96f244e1.js +0 -104
- package/dist/esm/utils-a550c58f.js +0 -96
- package/dist/viewer/p-11bdd2c4.js +0 -4
- package/dist/viewer/p-14182324.entry.js +0 -4
- package/dist/viewer/p-2768474e.js +0 -4
- package/dist/viewer/p-2e11803d.js +0 -4
- package/dist/viewer/p-6d4ab5fc.js +0 -17
- package/dist/viewer/p-964642c6.js +0 -4
- package/dist/viewer/p-9e856d0a.entry.js +0 -4
- package/dist/viewer/p-a717d9ff.js +0 -4
- package/dist/viewer/p-a9434d8e.entry.js +0 -4
- package/dist/viewer/p-af806858.js +0 -4
- package/dist/viewer/p-b5c350a7.js +0 -4
- package/dist/viewer/p-d912dd24.js +0 -18
- package/dist/viewer/p-f6d75616.entry.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import{h as o,r,c as e,H as t,g as n}from"./p-c9d8a379.js";import{i,p as s,f as a,g as h}from"./p-d912dd24.js";import{g as d}from"./p-05b2444e.js";import{p as c,c as l,b as u,t as w,d as p}from"./p-2768474e.js";import{c as b}from"./p-f482325b.js";import"./p-112455b1.js";const v=({id:r,rotation:e,name:t,point:n,onPointerDown:i},s)=>o("div",{id:r,class:"bounds-anchor-position",style:{top:`${n.y}px`,left:`${n.x}px`},onPointerDown:i},o("div",{class:"bounds-anchor",style:{transform:`rotateZ(${null!=e?e:0}deg)`}},o("slot",{name:t},s))),m=({id:r})=>o("filter",{id:r,filterUnits:"userSpaceOnUse"},o("feGaussianBlur",{in:"SourceAlpha",stdDeviation:"2"}),o("feOffset",{dx:"0",dy:"1",result:"offsetblur"}),o("feFlood",{"flood-color":"#000000","flood-opacity":"0.25"}),o("feComposite",{in2:"offsetblur",operator:"in"}),o("feMerge",null,o("feMergeNode",null),o("feMergeNode",{in:"SourceGraphic"}))),g=({start:r,end:e,onStartAnchorPointerDown:t,onCenterAnchorPointerDown:n,onEndAnchorPointerDown:a})=>{const h=i.normalize(i.toDegrees(i.fromPoints(r,e))-270),d=s.create((r.x+e.x)/2,(r.y+e.y)/2);return o("div",{class:"bounds-container"},o(v,{id:"bounding-box-1d-start-anchor",name:"start-anchor",rotation:h,point:r,onPointerDown:t},o("div",{class:b("bounds-default-anchor","bounds-cap-anchor")})),o(v,{id:"bounding-box-1d-end-anchor",name:"end-anchor",rotation:h,point:e,onPointerDown:a},o("div",{class:b("bounds-default-anchor","bounds-cap-anchor")})),o(v,{id:"bounding-box-1d-center-anchor",name:"center-anchor",point:d,onPointerDown:n},o("div",{class:b("bounds-default-anchor","bounds-center-anchor")})))};function f(o,r){switch(r){case"top-left":return s.create(o.x,o.y);case"top":return s.create(o.x+o.width/2,o.y);case"top-right":return s.create(o.x+o.width,o.y);case"right":return s.create(o.x+o.width,o.y+o.height/2);case"bottom-right":return s.create(o.x+o.width,o.y+o.height);case"bottom":return s.create(o.x+o.width/2,o.y+o.height);case"bottom-left":return s.create(o.x,o.y+o.height);case"left":return s.create(o.x,o.y+o.height/2);case"center":return h.center(o)}}function k(o){return Math.min(o.width,o.height)}function x(o,r){const e=k(r);return s.add(s.scale(o,e,e),a.center(r))}function D(o,r){const e=k(r);return a.scale(e,e,o)}function P(o,r){const e=function(o){return 1/k(o)}(r);return s.scale(s.subtract(o,a.center(r)),e,e)}function y(o){return o.getBoundingClientRect()}const A=class{constructor(o){r(this,o),this.editBegin=e(this,"editBegin",7),this.editEnd=e(this,"editEnd",7),this.editCancel=e(this,"editCancel",7),this.mode="",this.editAnchor="end",this.editStartPoint=o=>{this.editAnchor="start",this.startMarkup(o)},this.editCenterPoint=o=>{this.editAnchor="center",this.startMarkup(o)},this.editEndPoint=o=>{this.editAnchor="end",this.startMarkup(o)},this.updatePoints=o=>{if(null!=this.elementBounds){const r=P(d(o,this.elementBounds),this.elementBounds);if("start"===this.editAnchor)this.start=r;else if("end"===this.editAnchor)this.end=r;else if(null!=this.start&&null!=this.end){const o=s.create((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2),e=o.x-r.x,t=o.y-r.y;this.start=s.create(this.start.x-e,this.start.y-t),this.end=s.create(this.end.x-e,this.end.y-t)}}},this.startMarkup=o=>{var r;""!==this.mode&&null!=this.elementBounds&&(this.start=null!==(r=this.start)&&void 0!==r?r:P(d(o,this.elementBounds),this.elementBounds),this.editBegin.emit(),this.addDrawingInteractionListeners())},this.endMarkup=()=>{""!==this.mode&&null!=this.end?this.editEnd.emit():(this.start=void 0,this.editCancel.emit()),this.removeDrawingInteractionListeners()}}componentWillLoad(){this.updateViewport(),this.handleViewerChanged(this.viewer),this.updatePointsFromProps()}componentDidLoad(){this.updatePointsFromProps(),new ResizeObserver((()=>this.updateViewport())).observe(this.hostEl)}async dispose(){null!=this.viewer&&this.removeInteractionListeners(this.viewer),this.removeDrawingInteractionListeners()}handleViewerChanged(o,r){null!=r&&this.removeInteractionListeners(r),null!=o&&this.addInteractionListeners(o)}handleStartJsonChange(){this.updatePointsFromProps()}handleEndJsonChange(){this.updatePointsFromProps()}updateViewport(){const o=y(this.hostEl);this.elementBounds=o}updatePointsFromProps(){this.start=this.start||c(this.startJson),this.end=this.end||c(this.endJson)}render(){if(null!=this.start&&null!=this.end&&null!=this.elementBounds){const r=x(this.start,this.elementBounds),e=x(this.end,this.elementBounds),n=l(r,e);return o(t,null,o("svg",{class:"svg"},o("defs",null,o(m,{id:"arrow-shadow"})),o("g",{filter:"url(#arrow-shadow)"},o("polygon",{id:"arrow-head",class:"head",points:u(n)}),o("line",{id:"arrow-line",class:"line",x1:r.x,y1:r.y,x2:n.base.x,y2:n.base.y}),"edit"===this.mode&&o("line",{id:"bounding-box-1d-line",class:"bounds-line",x1:r.x,y1:r.y,x2:e.x,y2:e.y}))),"edit"===this.mode&&o(g,{start:r,end:e,onStartAnchorPointerDown:this.editStartPoint,onCenterAnchorPointerDown:this.editCenterPoint,onEndAnchorPointerDown:this.editEndPoint}))}return o(t,null,o("div",{class:"create-overlay",onPointerDown:o=>this.startMarkup(o)}))}async addInteractionListeners(o){const r=await o.getInteractionTarget();"create"===this.mode&&r.addEventListener("pointerdown",this.startMarkup)}async addDrawingInteractionListeners(){""!==this.mode&&(window.addEventListener("pointermove",this.updatePoints),window.addEventListener("pointerup",this.endMarkup))}async removeInteractionListeners(o){(await o.getInteractionTarget()).removeEventListener("pointerdown",this.startMarkup)}async removeDrawingInteractionListeners(){window.removeEventListener("pointermove",this.updatePoints),window.removeEventListener("pointerup",this.endMarkup)}get hostEl(){return n(this)}static get watchers(){return{viewer:["handleViewerChanged"],start:["handleStartJsonChange"],end:["handleEndJsonChange"]}}};A.style=":host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-markup-arrow-line-stroke-color:var(--red-800);--viewer-markup-arrow-line-stroke-width:4;--viewer-markup-arrow-head-stroke-color:var(--red-800);--viewer-markup-arrow-head-stroke-width:4;--viewer-markup-arrow-head-fill-color:var(--red-800);--viewer-markup-arrow-head-fill-opacity:1;--viewer-markup-arrow-bounds-cap-border-color:var(--blue-400);--viewer-markup-arrow-bounds-cap-border-width:1px;--viewer-markup-arrow-bounds-cap-background-color:white;--viewer-markup-arrow-bounds-center-anchor-border-color:white;--viewer-markup-arrow-bounds-center-anchor-border-width:1px;--viewer-markup-arrow-bounds-center-anchor-background-color:var(--blue-400);--viewer-markup-arrow-bounds-outline-width:1px;--viewer-markup-arrow-bounds-outline-color:var(--blue-400);--viewer-markup-arrow-bounds-anchor-width:9px;--viewer-markup-arrow-bounds-anchor-height:9px}.svg{pointer-events:none;width:100%;height:100%}.create-overlay{pointer-events:auto;position:absolute;left:0;top:0;width:100%;height:100%;cursor:crosshair}.line{pointer-events:auto;stroke:var(--viewer-markup-arrow-line-stroke-color);stroke-width:var(--viewer-markup-arrow-line-stroke-width);cursor:default}.head{pointer-events:auto;stroke:var(--viewer-markup-arrow-head-stroke-color);stroke-width:var(--viewer-markup-arrow-head-stroke-width);fill:var(--viewer-markup-arrow-head-fill-color);fill-opacity:var(--viewer-markup-arrow-head-fill-opacity);cursor:default}.bounds-line{pointer-events:auto;stroke:var(--viewer-markup-arrow-bounds-outline-color);stroke-width:var(--viewer-markup-arrow-bounds-outline-width)}.bounds-container{pointer-events:none;position:absolute;width:100%;height:100%;top:0;left:0;overflow:hidden}.bounds-anchor-position{position:absolute;transform:translate(-50%, -50%)}.bounds-anchor{pointer-events:auto;cursor:default;user-select:none}.bounds-default-anchor{width:var(--viewer-markup-arrow-bounds-anchor-width);height:var(--viewer-markup-arrow-bounds-anchor-height);box-sizing:border-box;box-shadow:0 0 2px rgba(0, 0, 0, 0.3)}.bounds-center-anchor{border-radius:100%;border-width:var(--viewer-markup-arrow-bounds-center-anchor-border-width);border-color:var(--viewer-markup-arrow-bounds-center-anchor-border-color);border-style:solid;background-color:var(--viewer-markup-arrow-bounds-center-anchor-background-color)}.bounds-cap-anchor{border-width:var(--viewer-markup-arrow-bounds-cap-border-width);border-color:var(--viewer-markup-arrow-bounds-cap-border-color);border-style:solid;background-color:var(--viewer-markup-arrow-bounds-cap-background-color)}";const L=({bounds:r,onTopLeftAnchorPointerDown:e,onLeftAnchorPointerDown:t,onTopRightAnchorPointerDown:n,onRightAnchorPointerDown:i,onBottomLeftAnchorPointerDown:s,onBottomAnchorPointerDown:a,onBottomRightAnchorPointerDown:d,onTopAnchorPointerDown:c,onCenterAnchorPointerDown:l})=>{const u=h.pad(r,6),w=h.center(u);return o("div",{class:"bounds-container"},o("div",{class:"bounds-outline",style:{top:`${u.y}px`,left:`${u.x}px`,width:`${u.width}px`,height:`${u.height}px`}}),o(v,{id:"bounding-box-2d-top-left-anchor",name:"top-left-anchor",point:f(u,"top-left"),onPointerDown:e},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-left-anchor",name:"left-anchor",point:f(u,"left"),onPointerDown:t},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-top-right-anchor",name:"top-right-anchor",point:f(u,"top-right"),onPointerDown:n},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-right-anchor",name:"right-anchor",point:f(u,"right"),onPointerDown:i},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-bottom-left-anchor",name:"bottom-left-anchor",point:f(u,"bottom-left"),onPointerDown:s},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-bottom-anchor",name:"bottom-anchor",point:f(u,"bottom"),onPointerDown:a},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-bottom-right-anchor",name:"bottom-right-anchor",point:f(u,"bottom-right"),onPointerDown:d},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-top-anchor",name:"top-anchor",point:f(u,"top"),onPointerDown:c},o("div",{class:b("bounds-default-anchor","bounds-edge-anchor")})),o(v,{id:"bounding-box-2d-center-anchor",name:"center-anchor",point:w,onPointerDown:l},o("div",{class:b("bounds-default-anchor","bounds-center-anchor")})))},C=class{constructor(o){r(this,o),this.editBegin=e(this,"editBegin",7),this.editEnd=e(this,"editEnd",7),this.editCancel=e(this,"editCancel",7),this.mode="",this.editAnchor="bottom-right",this.updateEditAnchor=(o,r)=>{this.resizeBounds=this.bounds,this.editAnchor=r,this.startMarkup(o)},this.updatePoints=o=>{var r;if(null!=this.bounds&&null!=this.startPosition&&null!=this.elementBounds){const e=P(d(o,this.elementBounds),this.elementBounds);this.bounds=w(null!==(r=this.resizeBounds)&&void 0!==r?r:this.bounds,this.startPosition,e,this.editAnchor,o.shiftKey)}},this.startMarkup=o=>{var r;if(""!==this.mode&&null!=this.elementBounds){const e=P(d(o,this.elementBounds),this.elementBounds);this.startPosition=e,this.bounds=null!==(r=this.bounds)&&void 0!==r?r:h.create(e.x,e.y,0,0),this.resizeBounds=this.bounds,this.editBegin.emit(),this.addDrawingInteractionListeners()}},this.endMarkup=()=>{var o,r;""!==this.mode&&null!=this.bounds&&(null===(o=this.bounds)||void 0===o?void 0:o.width)>0&&(null===(r=this.bounds)||void 0===r?void 0:r.height)>0?(this.editAnchor="bottom-right",this.editEnd.emit()):(this.bounds=void 0,this.editCancel.emit()),this.removeDrawingInteractionListeners()}}componentWillLoad(){this.updateViewport(),this.handleViewerChanged(this.viewer),this.updateBoundsFromProps()}componentDidLoad(){this.updateBoundsFromProps(),new ResizeObserver((()=>this.updateViewport())).observe(this.hostEl)}async dispose(){null!=this.viewer&&this.removeInteractionListeners(this.viewer),this.removeDrawingInteractionListeners()}handleViewerChanged(o,r){null!=r&&this.removeInteractionListeners(r),null!=o&&this.addInteractionListeners(o)}handleBoundsJsonChange(){this.updateBoundsFromProps()}updateViewport(){const o=y(this.hostEl);this.elementBounds=o}updateBoundsFromProps(){var o;this.bounds=null!==(o=this.bounds)&&void 0!==o?o:p(this.boundsJson)}render(){if(null!=this.bounds&&null!=this.elementBounds){const r=function(o,r){const e=x(o,r),t=D(o,r);return h.fromPointAndDimensions(e,t)}(this.bounds,this.elementBounds),e=h.center(r);return o(t,null,o("svg",{class:"svg"},o("defs",null,o(m,{id:"circle-shadow"})),o("g",{filter:"url(#circle-shadow)"},o("ellipse",{class:"ellipse",cx:e.x,cy:e.y,rx:r.width/2,ry:r.height/2,stroke:"#000ff0","stroke-width":4,fill:"none"}))),"edit"===this.mode&&o(L,{bounds:r,onTopLeftAnchorPointerDown:o=>this.updateEditAnchor(o,"top-left"),onTopRightAnchorPointerDown:o=>this.updateEditAnchor(o,"top-right"),onTopAnchorPointerDown:o=>this.updateEditAnchor(o,"top"),onBottomLeftAnchorPointerDown:o=>this.updateEditAnchor(o,"bottom-left"),onBottomRightAnchorPointerDown:o=>this.updateEditAnchor(o,"bottom-right"),onBottomAnchorPointerDown:o=>this.updateEditAnchor(o,"bottom"),onLeftAnchorPointerDown:o=>this.updateEditAnchor(o,"left"),onRightAnchorPointerDown:o=>this.updateEditAnchor(o,"right"),onCenterAnchorPointerDown:o=>this.updateEditAnchor(o,"center")}))}return o(t,null,o("div",{class:"create-overlay",onPointerDown:o=>this.startMarkup(o)}))}async addInteractionListeners(o){const r=await o.getInteractionTarget();"create"===this.mode&&r.addEventListener("pointerdown",this.startMarkup)}async addDrawingInteractionListeners(){""!==this.mode&&(window.addEventListener("pointermove",this.updatePoints),window.addEventListener("pointerup",this.endMarkup))}async removeInteractionListeners(o){(await o.getInteractionTarget()).removeEventListener("pointerdown",this.startMarkup)}async removeDrawingInteractionListeners(){window.removeEventListener("pointermove",this.updatePoints),window.removeEventListener("pointerup",this.endMarkup)}get hostEl(){return n(this)}static get watchers(){return{viewer:["handleViewerChanged"],bounds:["handleBoundsJsonChange"]}}};C.style=":host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-markup-circle-ellipse-stroke-color:var(--red-700);--viewer-markup-circle-ellipse-stroke-width:4;--viewer-markup-circle-ellipse-fill-color:none;--viewer-markup-circle-ellipse-fill-opacity:0;--viewer-markup-circle-bounds-outline-border-color:var(--blue-400);--viewer-markup-circle-bounds-outline-border-width:1px;--viewer-markup-circle-bounds-edge-anchor-border-color:var(--blue-400);--viewer-markup-circle-bounds-edge-anchor-border-width:1px;--viewer-markup-circle-bounds-edge-anchor-background-color:white;--viewer-markup-circle-bounds-center-anchor-border-color:white;--viewer-markup-circle-bounds-center-anchor-border-width:1px;--viewer-markup-circle-bounds-center-anchor-background-color:var(--blue-400);--viewer-markup-circle-bounds-anchor-width:9px;--viewer-markup-circle-bounds-anchor-height:9px}.svg{pointer-events:none;width:100%;height:100%}.create-overlay{pointer-events:auto;position:absolute;left:0;top:0;width:100%;height:100%;cursor:crosshair}.ellipse{pointer-events:auto;stroke:var(--viewer-markup-circle-ellipse-stroke-color);stroke-width:var(--viewer-markup-circle-ellipse-stroke-width);fill:var(--viewer-markup-circle-ellipse-fill-color);fill-opacity:var(--viewer-markup-circle-ellipse-fill-opacity);cursor:default}.bounds-container{pointer-events:none;position:absolute;width:100%;height:100%;top:0;left:0;overflow:hidden}.bounds-outline{position:absolute;border-width:var(--viewer-markup-circle-bounds-outline-border-width);border-color:var(--viewer-markup-circle-bounds-outline-border-color);border-style:solid;box-shadow:0 0 3px rgba(0, 0, 0, 0.3)}.bounds-anchor-position{position:absolute;transform:translate(-50%, -50%)}.bounds-anchor{pointer-events:auto;cursor:default;user-select:none}.bounds-default-anchor{width:var(--viewer-markup-circle-bounds-anchor-width);height:var(--viewer-markup-circle-bounds-anchor-height);box-sizing:border-box;box-shadow:0 0 2px rgba(0, 0, 0, 0.3)}.bounds-center-anchor{border-radius:100%;border-width:var(--viewer-markup-circle-bounds-center-anchor-border-width);border-color:var(--viewer-markup-circle-bounds-center-anchor-border-color);border-style:solid;background-color:var(--viewer-markup-circle-bounds-center-anchor-background-color)}.bounds-edge-anchor{border-width:var(--viewer-markup-circle-bounds-edge-anchor-border-width);border-color:var(--viewer-markup-circle-bounds-edge-anchor-border-color);border-style:solid;background-color:var(--viewer-markup-circle-bounds-edge-anchor-background-color)}";export{A as vertex_viewer_markup_arrow,C as vertex_viewer_markup_circle}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import{p as s,g as r}from"./p-d912dd24.js";import{a as o}from"./p-6d4ab5fc.js";class a{constructor(r){var a,i,l;this.start=null!==(a=r.start)&&void 0!==a?a:s.create(),this.end=null!==(i=r.end)&&void 0!==i?i:s.create(),this.id=null!==(l=r.id)&&void 0!==l?l:`arrow-markup--${o.create()}`}}class i{constructor(s){var a,i;this.bounds=null!==(a=s.bounds)&&void 0!==a?a:r.create(0,0,0,0),this.id=null!==(i=s.id)&&void 0!==i?i:`circle-markup--${o.create()}`}}export{a as A,i as C}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 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-c9d8a379.js";import{a as h,g as o,p as r}from"./p-e96bc9a2.js";import{v as a,i as l,p as u,e as c,h as d,r as v,l as w,f}from"./p-d912dd24.js";import{c as m}from"./p-f482325b.js";import{u as p,E as g,o as b,b as y}from"./p-6d4ab5fc.js";import{I as C,t as T,b as x,p as E,d as I,W as S,v as P,e as D,f as O,V as k,C as z,g as M,h as R,a as j,i as F,j as A,k as B,m as L,S as K}from"./p-964642c6.js";import{S as $,m as N,d as W}from"./p-b5c350a7.js";import{V as U}from"./p-11bdd2c4.js";import{g as V,c as q}from"./p-05b2444e.js";import{C as G}from"./p-f4a492e1.js";import"./p-112455b1.js";var J,H=[],_="ResizeObserver loop completed with undelivered notifications.";!function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(J||(J={}));var X,Y=function(t){return Object.freeze(t)},Q=function(t,i){this.inlineSize=t,this.blockSize=i,Y(this)},Z=function(){function t(t,i,s,n){return this.x=t,this.y=i,this.width=s,this.height=n,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Y(this)}return t.prototype.toJSON=function(){var t=this;return{x:t.x,y:t.y,top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}},t.fromRect=function(i){return new t(i.x,i.y,i.width,i.height)},t}(),tt=function(t){return t instanceof SVGElement&&"getBBox"in t},it=function(t){if(tt(t)){var i=t.getBBox();return!i.width&&!i.height}return!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},st=function(t){var i,s;if(t instanceof Element)return!0;var n=null===(s=null===(i=t)||void 0===i?void 0:i.ownerDocument)||void 0===s?void 0:s.defaultView;return!!(n&&t instanceof n.Element)},nt="undefined"!=typeof window?window:{},et=new WeakMap,ht=/auto|scroll/,ot=/^tb|vertical/,rt=/msie|trident/i.test(nt.navigator&&nt.navigator.userAgent),at=function(t){return parseFloat(t||"0")},lt=function(t,i,s){return void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=!1),new Q((s?i:t)||0,(s?t:i)||0)},ut=Y({devicePixelContentBoxSize:lt(),borderBoxSize:lt(),contentBoxSize:lt(),contentRect:new Z(0,0,0,0)}),ct=function(t,i){if(void 0===i&&(i=!1),et.has(t)&&!i)return et.get(t);if(it(t))return et.set(t,ut),ut;var s=getComputedStyle(t),n=tt(t)&&t.ownerSVGElement&&t.getBBox(),e=!rt&&"border-box"===s.boxSizing,h=ot.test(s.writingMode||""),o=!n&&ht.test(s.overflowY||""),r=!n&&ht.test(s.overflowX||""),a=n?0:at(s.paddingTop),l=n?0:at(s.paddingRight),u=n?0:at(s.paddingBottom),c=n?0:at(s.paddingLeft),d=n?0:at(s.borderTopWidth),v=n?0:at(s.borderRightWidth),w=n?0:at(s.borderBottomWidth),f=c+l,m=a+u,p=(n?0:at(s.borderLeftWidth))+v,g=d+w,b=r?t.offsetHeight-g-t.clientHeight:0,y=o?t.offsetWidth-p-t.clientWidth:0,C=e?f+p:0,T=e?m+g:0,x=n?n.width:at(s.width)-C-y,E=n?n.height:at(s.height)-T-b,I=x+f+y+p,S=E+m+b+g,P=Y({devicePixelContentBoxSize:lt(Math.round(x*devicePixelRatio),Math.round(E*devicePixelRatio),h),borderBoxSize:lt(I,S,h),contentBoxSize:lt(x,E,h),contentRect:new Z(c,a,x,E)});return et.set(t,P),P},dt=function(t,i,s){var n=ct(t,s),e=n.borderBoxSize,h=n.contentBoxSize,o=n.devicePixelContentBoxSize;switch(i){case J.DEVICE_PIXEL_CONTENT_BOX:return o;case J.BORDER_BOX:return e;default:return h}},vt=function(t){var i=ct(t);this.target=t,this.contentRect=i.contentRect,this.borderBoxSize=Y([i.borderBoxSize]),this.contentBoxSize=Y([i.contentBoxSize]),this.devicePixelContentBoxSize=Y([i.devicePixelContentBoxSize])},wt=function(t){if(it(t))return 1/0;for(var i=0,s=t.parentNode;s;)i+=1,s=s.parentNode;return i},ft=function(){var t=1/0,i=[];H.forEach((function(s){if(0!==s.activeTargets.length){var n=[];s.activeTargets.forEach((function(i){var s=new vt(i.target),e=wt(i.target);n.push(s),i.lastReportedSize=dt(i.target,i.observedBox),e<t&&(t=e)})),i.push((function(){s.callback.call(s.observer,n,s.observer)})),s.activeTargets.splice(0,s.activeTargets.length)}}));for(var s=0,n=i;s<n.length;s++)(0,n[s])();return t},mt=function(t){H.forEach((function(i){i.activeTargets.splice(0,i.activeTargets.length),i.skippedTargets.splice(0,i.skippedTargets.length),i.observationTargets.forEach((function(s){s.isActive()&&(wt(s.target)>t?i.activeTargets.push(s):i.skippedTargets.push(s))}))}))},pt=[],gt=0,bt={attributes:!0,characterData:!0,childList:!0,subtree:!0},yt=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Ct=function(t){return void 0===t&&(t=0),Date.now()+t},Tt=!1,xt=new(function(){function t(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return t.prototype.run=function(t){var i=this;if(void 0===t&&(t=250),!Tt){Tt=!0;var s,n=Ct(t);s=function(){var s=!1;try{s=function(){var t,i=0;for(mt(i);H.some((function(t){return t.activeTargets.length>0}));)i=ft(),mt(i);return H.some((function(t){return t.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?t=new ErrorEvent("error",{message:_}):((t=document.createEvent("Event")).initEvent("error",!1,!1),t.message=_),window.dispatchEvent(t)),i>0}()}finally{if(Tt=!1,t=n-Ct(),!gt)return;s?i.run(1e3):t>0?i.run(t):i.start()}},function(t){if(!X){var i=0,s=document.createTextNode("");new MutationObserver((function(){return pt.splice(0).forEach((function(t){return t()}))})).observe(s,{characterData:!0}),X=function(){s.textContent=""+(i?i--:i++)}}pt.push(t),X()}((function(){requestAnimationFrame(s)}))}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var t=this,i=function(){return t.observer&&t.observer.observe(document.body,bt)};document.body?i():nt.addEventListener("DOMContentLoaded",i)},t.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),yt.forEach((function(i){return nt.addEventListener(i,t.listener,!0)})))},t.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),yt.forEach((function(i){return nt.removeEventListener(i,t.listener,!0)})),this.stopped=!0)},t}()),Et=function(t){!gt&&t>0&&xt.start(),!(gt+=t)&&xt.stop()},It=function(){function t(t,i){this.target=t,this.observedBox=i||J.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var t,i=dt(this.target,this.observedBox,!0);return tt(t=this.target)||function(t){switch(t.tagName){case"INPUT":if("image"!==t.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(t)||"inline"!==getComputedStyle(t).display||(this.lastReportedSize=i),this.lastReportedSize.inlineSize!==i.inlineSize||this.lastReportedSize.blockSize!==i.blockSize},t}(),St=function(t,i){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=i},Pt=new WeakMap,Dt=function(t,i){for(var s=0;s<t.length;s+=1)if(t[s].target===i)return s;return-1},Ot=function(){function t(){}return t.connect=function(t,i){var s=new St(t,i);Pt.set(t,s)},t.observe=function(t,i,s){var n=Pt.get(t),e=0===n.observationTargets.length;Dt(n.observationTargets,i)<0&&(e&&H.push(n),n.observationTargets.push(new It(i,s&&s.box)),Et(1),xt.schedule())},t.unobserve=function(t,i){var s=Pt.get(t),n=Dt(s.observationTargets,i);n>=0&&(1===s.observationTargets.length&&H.splice(H.indexOf(s),1),s.observationTargets.splice(n,1),Et(-1))},t.disconnect=function(t){var i=this,s=Pt.get(t);s.observationTargets.slice().forEach((function(s){return i.unobserve(t,s.target)})),s.activeTargets.splice(0,s.activeTargets.length)},t}(),kt=function(){function t(t){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof t)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");Ot.connect(this,t)}return t.prototype.observe=function(t,i){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!st(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Ot.observe(this,t,i)},t.prototype.unobserve=function(t){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!st(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Ot.unobserve(this,t)},t.prototype.disconnect=function(){Ot.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();class zt{constructor(t,i){this.stream=t,this.configProvider=i,this.commands={}}register(t,i,s){return this.commands[t]={factory:i,thisArg:s},{dispose:()=>delete this.commands[t]}}execute(t,...i){const s=this.getCommandDefinition(t);if(null!=s){const t=s.factory.apply(s.thisArg,i);return new Promise((i=>{i(t({stream:this.stream,config:this.configProvider()}))}))}throw new Error(`Command not registered for \`${t}\``)}getCommandDefinition(t){return this.commands[t]}}class Mt{constructor(t,i,s,n,e,h,o,r,a,l){this.stream=t,this.getConfig=i,this.getScene=s,this.getFrame=n,this.getViewport=e,this.tapEmitter=h,this.doubleTapEmitter=o,this.longPressEmitter=r,this.interactionStartedEmitter=a,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)}getRayFromPoint(t){const i=this.getViewport(),s=this.getFrame();if(null!=s)return i.transformPointToRay(t,s.image,s.scene.camera);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(){this.isInteracting()||(this.interactionStartedEmitter.emit(),this.currentCamera=this.getScene().camera(),await this.stream.beginInteraction())}async transformCamera(t){var i;if(this.isInteracting()){const s=this.getScene();this.currentCamera=null!=this.currentCamera?t({camera:this.currentCamera,viewport:s.viewport(),scale:s.scale(),boundingBox:s.boundingBox()}):void 0,await(null===(i=this.currentCamera)||void 0===i?void 0:i.render())}}async twistCamera(...t){return this.transformCamera((({camera:i,viewport:s})=>{const n=a.normalize(a.subtract(i.lookAt,i.position));if(1===t.length&&"number"==typeof t[0]){const s=l.toRadians(-t[0]);return i.rotateAroundAxis(s,n)}if(1===t.length){const n=u.create(s.width/2,s.height/2),e=l.fromPointsInDegrees(n,t[0]),h=null!=this.lastAngle?e-this.lastAngle:0;this.lastAngle=e;const o=a.normalize(a.subtract(i.lookAt,i.position)),r=l.toRadians(-h);return i.rotateAroundAxis(r,o)}return i}))}async panCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector(),e=a.normalize(i.up),h=a.normalize(n),o=a.magnitude(n)*Math.tan(i.fovY),r=t.x*o/s.width,l=t.y/s.width*o,u=a.cross(e,h),c=a.cross(h,u),d=a.add(a.scale(r,u),a.scale(l,c));return i.moveBy(d)}))}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=a.normalize(i.up),e=a.normalize(a.subtract(i.lookAt,i.position)),h=a.cross(n,e),o=a.cross(e,h),r=a.normalize({x:t.x*h.x+t.y*o.x,y:t.x*h.y+t.y*o.y,z:t.x*h.z+t.y*o.z}),l=a.cross(r,e),u=3*Math.PI*t.x/s.width,c=3*Math.PI*t.y/s.height,d=Math.abs(u)+Math.abs(c);return i.rotateAroundAxis(d,l)}))}async rotateCameraAtPoint(t,i){const s=this.getFrame(),n=await(null==s?void 0:s.depthBuffer());return this.transformCamera((({camera:s,viewport:e,boundingBox:h})=>{if(null==this.worldRotationPoint){const t=c.center(h);this.worldRotationPoint=null!=n?this.getWorldRotationPoint(i,n,t):s.lookAt}const o=a.normalize(s.up),r=a.normalize(a.subtract(s.lookAt,s.position)),l=a.cross(o,r),u=a.cross(r,l),d=a.normalize({x:t.x*l.x+t.y*u.x,y:t.x*l.y+t.y*u.y,z:t.x*l.z+t.y*u.z}),v=a.cross(d,r),w=3*Math.PI*t.x/e.width,f=3*Math.PI*t.y/e.height,m=Math.abs(w)+Math.abs(f),p=s.rotateAroundAxisAtPoint(m,this.worldRotationPoint,v);return p.update({lookAt:a.add(a.scale(s.distanceToBoundingBoxCenter()/a.magnitude(p.viewVector()),p.viewVector()),p.position)})}))}async zoomCamera(t,i){return this.transformCamera((({camera:s,viewport:n})=>{const e=s.viewVector(),h=a.normalize(e),o=d.create({normal:h}),r=null!=i?v.intersectPlane(i,o):void 0,l=null!=r?a.subtract(r,s.position):e,u=a.normalize(l),c=a.magnitude(l),w=a.add(s.position,a.scale(3*c*t/n.height,u)),f=d.projectPoint(o,w);return s.update({position:w,lookAt:f})}))}async endInteraction(){this.isInteracting()&&(this.currentCamera=void 0,this.worldRotationPoint=void 0,this.resetLastAngle(),this.interactionFinishedEmitter.emit(),await this.stream.endInteraction())}resetLastAngle(){this.lastAngle=void 0}isInteracting(){return null!=this.currentCamera}pixelThreshold(t){return(this.isCoarseInputDevice(t)?this.getConfig().coarsePointerThreshold:this.getConfig().finePointerThreshold)*window.devicePixelRatio}emitTapEvent(t,i,s={},n=0){const{altKey:e=!1,ctrlKey:h=!1,metaKey:o=!1,shiftKey:r=!1}=s;t({position:i,altKey:e,ctrlKey:h,metaKey:o,shiftKey:r,buttons:n})}isCoarseInputDevice(t){return t||window.matchMedia("(pointer: coarse)").matches}getWorldRotationPoint(t,i,s){const n=this.getViewport(),e=n.transformPointToFrame(t,i);return i.isDepthAtFarPlane(e)?n.transformPointToWorldSpace(t,i):s}}const Rt=[.2,.15,.25,.25,.15];class jt{constructor(t,i,s,n,e,h,o,r,a){this.downEvent=t,this.upEvent=i,this.moveEvent=s,this.rotateInteraction=n,this.rotatePointInteraction=e,this.zoomInteraction=h,this.panInteraction=o,this.twistInteraction=r,this.getConfig=a,this.primaryInteraction=this.rotateInteraction,this.isDragging=!1,this.keyboardControls=!1,this.disableIndividualInteractions=!1,this.primaryInteractionTypeChange=new g,this.handleDownEvent=this.handleDownEvent.bind(this),this.handleMouseWheel=this.handleMouseWheel.bind(this),this.handleWindowMove=this.handleWindowMove.bind(this),this.handleWindowUp=this.handleWindowUp.bind(this)}initialize(t,i){this.element=t,this.interactionApi=i,t.addEventListener(this.downEvent,this.handleDownEvent),t.addEventListener("wheel",this.handleMouseWheel)}dispose(){var t,i;null===(t=this.element)||void 0===t||t.removeEventListener(this.downEvent,this.handleDownEvent),null===(i=this.element)||void 0===i||i.removeEventListener("wheel",this.handleMouseWheel),this.element=void 0}onPrimaryInteractionTypeChange(t){return this.primaryInteractionTypeChange.on(t)}setCurrentInteractionType(t){var i;switch(t){case"rotate":this.currentInteraction=this.rotateInteraction;break;case"zoom":this.currentInteraction=this.zoomInteraction;break;case"pan":this.currentInteraction=this.panInteraction;break;case"twist":this.currentInteraction=this.twistInteraction;break;case"rotate-point":this.currentInteraction=this.rotatePointInteraction;break;default:this.currentInteraction=void 0}if(this.draggingInteraction){const t=this.draggingInteraction.getPosition();this.draggingInteraction=this.currentInteraction||this.primaryInteraction,null===(i=this.interactionApi)||void 0===i||i.resetLastAngle(),this.draggingInteraction.setPosition(t)}}getPrimaryInteractionType(){return this.primaryInteraction.getType()}getCurrentInteractionType(){return(this.currentInteraction||this.primaryInteraction).getType()}setPrimaryInteractionType(t){switch(t){case"rotate":this.primaryInteraction=this.rotateInteraction;break;case"rotate-point":this.primaryInteraction=this.rotatePointInteraction;break;case"zoom":this.primaryInteraction=this.zoomInteraction;break;case"pan":this.primaryInteraction=this.panInteraction}this.primaryInteractionTypeChange.emit()}setDefaultKeyboardControls(t){this.keyboardControls=t}handleDownEvent(t){this.interactionTimer=window.setTimeout((()=>{this.downPosition=u.create(t.screenX,t.screenY),this.downPositionCanvas=this.getCanvasPosition(t),this.interactionTimer=void 0,null!=this.lastMoveEvent&&this.handleWindowMove(this.lastMoveEvent)}),this.getConfig().interactions.interactionDelay),window.addEventListener(this.moveEvent,this.handleWindowMove),window.addEventListener(this.upEvent,this.handleWindowUp)}handleWindowMove(t){if(null==this.interactionTimer){if(this.disableIndividualInteractions)return;const i=u.create(t.screenX,t.screenY),s=null!=this.interactionApi?this.interactionApi.pixelThreshold(this.isTouch(t)):2;null!=this.downPosition&&u.distance(i,this.downPosition)>=s&&!this.isDragging&&(this.beginDrag(t),this.isDragging=!0),this.isDragging&&this.drag(t)}this.lastMoveEvent=t}async handleWindowUp(t){this.isDragging&&(this.endDrag(t),this.isDragging=!1),null!=this.interactionTimer&&(window.clearTimeout(this.interactionTimer),this.interactionTimer=void 0),window.removeEventListener(this.moveEvent,this.handleWindowMove),window.removeEventListener(this.upEvent,this.handleWindowUp),this.lastMoveEvent=void 0}beginDrag(t){this.keyboardControls&&t.metaKey&&t.shiftKey&&(this.currentInteraction=this.rotatePointInteraction),1===t.buttons?this.draggingInteraction=this.currentInteraction||this.primaryInteraction:2===t.buttons&&(this.draggingInteraction=this.panInteraction),null!=this.draggingInteraction&&null!=this.interactionApi&&(this.zoomInteraction.endDrag(t,this.interactionApi),this.draggingInteraction.beginDrag(t,this.downPositionCanvas||u.create(t.clientX,t.clientY),this.interactionApi,this.element))}drag(t){this.currentInteraction=this.keyboardControls&&t.altKey&&t.shiftKey?this.twistInteraction:void 0,this.draggingInteraction=this.currentInteraction||this.draggingInteraction||this.primaryInteraction,null!=this.draggingInteraction&&null!=this.interactionApi&&this.draggingInteraction.drag(t,this.interactionApi)}endDrag(t){null!=this.draggingInteraction&&null!=this.interactionApi&&(this.draggingInteraction.endDrag(t,this.interactionApi),this.draggingInteraction=void 0)}handleMouseWheel(t){if(t.preventDefault(),null!=this.element&&null!=this.interactionApi){const i=-this.wheelDeltaToPixels(t.deltaY,t.deltaMode)/10,s=this.element.getBoundingClientRect(),n=V(t,s),e=this.interactionApi.getRayFromPoint(n);Rt.forEach(((t,s)=>{window.setTimeout((()=>{null!=this.interactionApi&&this.zoomInteraction.zoomOnRay(i*t,e,this.interactionApi)}),2*s)}))}}wheelDeltaToPixels(t,i){null==this.computedBodyStyle&&(this.computedBodyStyle=window.getComputedStyle(document.body));const s=null==this.computedBodyStyle.fontSize||""===this.computedBodyStyle.fontSize||isNaN(parseFloat(this.computedBodyStyle.fontSize))?19.2:1.2*parseFloat(this.computedBodyStyle.fontSize);return 1===i?null==this.computedBodyStyle.lineHeight||""===this.computedBodyStyle.lineHeight||isNaN(parseFloat(this.computedBodyStyle.lineHeight))?t*s:t*parseFloat(this.computedBodyStyle.lineHeight):2===i?null==this.computedBodyStyle.height||""===this.computedBodyStyle.height||isNaN(parseFloat(this.computedBodyStyle.height))?t*window.innerHeight:t*parseFloat(this.computedBodyStyle.height):t}getCanvasPosition(t){var i;const s=null===(i=this.element)||void 0===i?void 0:i.getBoundingClientRect(),n=null!=s?u.create(s.left,s.top):void 0;return null!=n?u.subtract(u.create(t.clientX,t.clientY),n):void 0}isTouch(t){return null!=window.PointerEvent&&t instanceof PointerEvent&&"touch"===t.pointerType}}class Ft{setPosition(t){this.currentPosition=t}getPosition(){return this.currentPosition}getType(){return this.type}beginDrag(t,i,s,n){}drag(t,i){}endDrag(t,i){null!=this.currentPosition&&(i.endInteraction(),this.currentPosition=void 0)}zoom(t,i){}}class At extends Ft{constructor(){super(...arguments),this.type="rotate"}beginDrag(t,i,s){null==this.currentPosition&&(this.currentPosition=u.create(t.screenX,t.screenY),s.beginInteraction())}drag(t,i){if(null!=this.currentPosition){const s=u.create(t.screenX,t.screenY),n=u.subtract(s,this.currentPosition);i.rotateCamera(n),this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Bt extends Ft{constructor(){super(...arguments),this.type="rotate-point"}beginDrag(t,i,s){null==this.currentPosition&&(this.currentPosition=u.create(t.screenX,t.screenY),this.startingPosition=i,s.beginInteraction())}drag(t,i){if(null!=this.currentPosition&&null!=this.startingPosition){const s=u.create(t.screenX,t.screenY),n=u.subtract(s,this.currentPosition);i.rotateCameraAtPoint(n,this.startingPosition),this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Lt extends Ft{constructor(t=1e3){super(),this.interactionTimeout=t,this.type="zoom",this.didTransformBegin=!1}beginDrag(t,i,s,n){if(null==this.currentPosition){this.currentPosition=u.create(t.screenX,t.screenY);const i=null==n?void 0:n.getBoundingClientRect(),e=V(t,i);this.startRay=s.getRayFromPoint(e),s.beginInteraction()}}drag(t,i){if(null!=this.currentPosition){const s=u.create(t.screenX,t.screenY),n=u.subtract(s,this.currentPosition);i.zoomCamera(n.y,this.startRay),this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i),this.stopInteractionTimer(),this.didTransformBegin=!1,this.startRay=void 0}zoom(t,i){this.operateWithTimer(i,(()=>i.zoomCamera(t)))}zoomOnRay(t,i,s){this.operateWithTimer(s,(()=>s.zoomCamera(t,i)))}beginInteraction(t){this.didTransformBegin=!0,t.beginInteraction()}endInteraction(t){this.didTransformBegin=!1,t.endInteraction()}resetInteractionTimer(t){this.stopInteractionTimer(),this.startInteractionTimer(t)}startInteractionTimer(t){this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=void 0,this.endInteraction(t)}),this.interactionTimeout)}stopInteractionTimer(){null!=this.interactionTimer&&(window.clearTimeout(this.interactionTimer),this.interactionTimer=void 0)}operateWithTimer(t,i){this.didTransformBegin||this.beginInteraction(t),this.resetInteractionTimer(t),i()}}class Kt extends Ft{constructor(){super(...arguments),this.type="pan"}beginDrag(t,i,s){null==this.currentPosition&&(this.currentPosition=u.create(t.screenX,t.screenY),s.beginInteraction())}drag(t,i){if(null!=this.currentPosition){const s=u.create(t.screenX,t.screenY),n=u.subtract(s,this.currentPosition);i.panCamera(n),this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class $t extends Ft{constructor(){super(...arguments),this.type="twist"}beginDrag(t,i,s){this.currentPosition=u.create(t.screenX,t.screenY),s.beginInteraction()}drag(t,i){const s=u.create(t.screenX,t.screenY);this.currentPosition=s,i.twistCamera(s)}endDrag(t,i){super.endDrag(t,i)}}class Nt extends jt{constructor(t,i=new At,s=new Bt,n=new Lt,e=new Kt,h=new $t){super("mousedown","mouseup","mousemove",i,s,n,e,h,t)}}class Wt{initialize(t,i){this.element=t,this.interactionApi=i}dispose(){this.element=void 0}handleTwoPointTouchMove(t,i){var s,n,e,h;if(null!=this.currentPosition1&&null!=this.currentPosition2){const o=u.scale(u.add(u.subtract(t,this.currentPosition1),u.subtract(i,this.currentPosition2)),.25,.25),r=.5*(u.distance(t,i)-u.distance(this.currentPosition1,this.currentPosition2)),a=w.create(u.subtract(this.currentPosition1,this.currentPosition2),u.subtract(t,i)),c=l.toDegrees(Math.atan2(w.determinant(a),w.dot(a)));null===(s=this.interactionApi)||void 0===s||s.beginInteraction(),null===(n=this.interactionApi)||void 0===n||n.zoomCamera(r),null===(e=this.interactionApi)||void 0===e||e.panCamera(o),null===(h=this.interactionApi)||void 0===h||h.twistCamera(c)}this.currentPosition1=t,this.currentPosition2=i}}class Ut extends Wt{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;null===(t=this.element)||void 0===t||t.removeEventListener("pointerdown",this.handlePointerDown),super.dispose()}initialize(t,i){super.initialize(t,i),t.addEventListener("pointerdown",this.handlePointerDown)}handlePointerDown(t){const i=u.create(t.screenX,t.screenY);this.touchPoints=Object.assign(Object.assign({},this.touchPoints),{[t.pointerId]:i}),1===Object.keys(this.touchPoints).length&&(window.addEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointerup",this.handlePointerUp))}handlePointerMove(t){null!=this.touchPoints[t.pointerId]&&(this.touchPoints[t.pointerId]=u.create(t.screenX,t.screenY));const i=Object.keys(this.touchPoints);2===i.length&&this.handleTwoPointTouchMove(this.touchPoints[i[0]],this.touchPoints[i[1]])}handlePointerUp(t){var i;delete this.touchPoints[t.pointerId];const s=Object.keys(this.touchPoints);1===s.length&&(null===(i=this.interactionApi)||void 0===i||i.endInteraction(),this.currentPosition1=void 0,this.currentPosition2=void 0),0===s.length&&(window.removeEventListener("pointermove",this.handlePointerMove),window.removeEventListener("pointerup",this.handlePointerUp))}}class Vt extends jt{constructor(t){super("pointerdown","pointerup","pointermove",new At,new Bt,new Lt,new Kt,new $t,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)}handlePointerDown(t){this.downPosition=u.create(t.screenX,t.screenY),this.touchPoints.add(t.pointerId),1===this.touchPoints.size&&window.addEventListener("pointerup",this.handlePointerUp),2===this.touchPoints.size&&(this.disableIndividualInteractions=!0)}handlePointerUp(t){this.touchPoints.delete(t.pointerId),this.touchPoints.size<2&&(this.disableIndividualInteractions=!1),0===this.touchPoints.size&&window.removeEventListener("pointerup",this.handlePointerUp)}}class qt extends Wt{constructor(){super(),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this)}dispose(){var t;null===(t=this.element)||void 0===t||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){const i=t.touches[0],s=t.touches[1];this.currentPosition1=u.create(i.screenX,i.screenY),this.currentPosition2=null!=s?u.create(s.screenX,s.screenY):void 0,window.addEventListener("touchmove",this.handleTouchMove,{passive:!1}),window.addEventListener("touchend",this.handleTouchEnd)}}handleTouchMove(t){if(1===t.touches.length)this.handleOnePointTouchMove(t.touches[0]);else if(2===t.touches.length){const i=u.create(t.touches[0].clientX,t.touches[0].clientY),s=u.create(t.touches[1].clientX,t.touches[1].clientY);this.handleTwoPointTouchMove(i,s)}}handleTouchEnd(t){var i;null===(i=this.interactionApi)||void 0===i||i.endInteraction(),this.isInteracting=!1,window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd)}handleOnePointTouchMove(t){var i,s,n;const e=u.create(t.screenX,t.screenY);if(null!=this.currentPosition1){const t=u.subtract(e,this.currentPosition1),h=(null===(i=this.interactionApi)||void 0===i?void 0:i.pixelThreshold(!0))||2;(u.distance(e,this.currentPosition1)>=h||this.isInteracting)&&(null===(s=this.interactionApi)||void 0===s||s.beginInteraction(),null===(n=this.interactionApi)||void 0===n||n.rotateCamera(t),this.isInteracting=!0)}this.currentPosition1=e}}class Gt{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;null===(t=this.element)||void 0===t||t.removeEventListener(this.downEvent,this.handleDown),null===(i=this.element)||void 0===i||i.removeEventListener("touchstart",this.handleTouchStart),this.element=void 0,this.clearDoubleTapTimer(),this.clearLongPressTimer()}initialize(t,i){this.element=t,this.interactionApi=i,t.addEventListener(this.downEvent,this.handleDown),t.addEventListener("touchstart",this.handleTouchStart)}handleTouchStart(t){1===t.touches.length&&(this.setPointerPositions(u.create(t.touches[0].clientX,t.touches[0].clientY)),this.restartLongPressTimer(),window.addEventListener("touchend",this.handleTouchEnd),window.addEventListener("touchmove",this.handleTouchMove))}handleTouchMove(t){t.touches.length>0&&this.handlePointerMove(u.create(t.touches[0].clientX,t.touches[0].clientY),!0)}handleTouchEnd(t){null!=this.pointerDownPosition&&(window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchmove",this.handleTouchMove)),this.handlePointerEnd(this.pointerDownPosition)}handleDown(t){this.setPointerPositions(u.create(t.clientX,t.clientY)),this.buttons=t.buttons,this.restartLongPressTimer({altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}),window.addEventListener(this.upEvent,this.handleUp),window.addEventListener(this.moveEvent,this.handleMove)}handleMove(t){this.handlePointerMove(u.create(t.clientX,t.clientY),this.isTouch(t))}handleUp(t){null!=this.pointerDownPosition&&(window.removeEventListener(this.upEvent,this.handleUp),window.removeEventListener(this.moveEvent,this.handleMove)),this.handlePointerEnd(u.create(t.clientX,t.clientY),{altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey},this.buttons,this.isTouch(t)),this.buttons=void 0}handlePointerMove(t,i){var s;const n=(null===(s=this.interactionApi)||void 0===s?void 0:s.pixelThreshold(i))||2;null!=this.pointerDownPosition&&u.distance(t,this.pointerDownPosition)>=n&&null==this.interactionTimer&&this.clearPositions()}handlePointerEnd(t,i={},s=0,n=!1){var e,h;null!=t&&(null!=this.longPressTimer&&this.emit(null===(e=this.interactionApi)||void 0===e?void 0:e.tap)(t,i,s),null!=this.doubleTapTimer&&null!=this.secondPointerDownPosition&&(this.emit(null===(h=this.interactionApi)||void 0===h?void 0:h.doubleTap)(t,i,s,this.secondPointerDownPosition),this.clearDoubleTapTimer())),this.pointerDownPosition=void 0,this.clearLongPressTimer()}emit(t){return(i,s={},n=0,e,h=!1)=>{var o;const r=e||this.pointerDownPosition,a=(null===(o=this.interactionApi)||void 0===o?void 0:o.pixelThreshold(h))||1;let l;null!=this.interactionTimer?l=this.getCanvasPosition(r||i):null!=r&&u.distance(r,i)<=a&&(l=this.getCanvasPosition(i)),null!=l&&null!=t&&t(l,s,n)}}getCanvasPosition(t){var i;const s=null===(i=this.element)||void 0===i?void 0:i.getBoundingClientRect(),n=null!=s?u.create(s.left,s.top):void 0;return null!=n?u.subtract(u.create(t.x,t.y),n):void 0}clearPositions(){this.pointerDownPosition=void 0,this.firstPointerDownPosition=void 0,this.secondPointerDownPosition=void 0,this.clearDoubleTapTimer(),this.clearLongPressTimer(),this.clearInteractionTimer()}clearDoubleTapTimer(){null!=this.doubleTapTimer&&window.clearTimeout(this.doubleTapTimer),this.doubleTapTimer=void 0,this.firstPointerDownPosition=void 0,this.secondPointerDownPosition=void 0}restartDoubleTapTimer(){this.clearDoubleTapTimer(),this.doubleTapTimer=window.setTimeout((()=>this.clearDoubleTapTimer()),this.getConfig().events.doubleTapThreshold)}clearLongPressTimer(){null!=this.longPressTimer&&window.clearTimeout(this.longPressTimer),this.longPressTimer=void 0}restartLongPressTimer(t={}){this.clearLongPressTimer(),this.longPressTimer=window.setTimeout((()=>{var i;this.pointerDownPosition&&this.emit(null===(i=this.interactionApi)||void 0===i?void 0:i.longPress)(this.pointerDownPosition,t,this.buttons),this.clearLongPressTimer()}),this.getConfig().events.longPressThreshold)}restartInteractionTimer(){this.clearInteractionTimer(),this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=void 0}),this.getConfig().interactions.interactionDelay)}clearInteractionTimer(){null!=this.interactionTimer&&(window.clearTimeout(this.interactionTimer),this.interactionTimer=void 0)}setPointerPositions(t){this.pointerDownPosition=t,this.restartInteractionTimer(),null==this.firstPointerDownPosition?(this.restartDoubleTapTimer(),this.firstPointerDownPosition=t):this.secondPointerDownPosition=t}isTouch(t){return null!=window.PointerEvent&&t instanceof PointerEvent&&"touch"===t.pointerType}}class Jt{constructor(t,i,s){this.stream=t,this.configProvider=i,this.imageScaleProvider=s}predicate(t){return!!t.altKey}async fn(t){var i;const s=this.imageScaleProvider(),n=await this.stream.hitItems({point:u.scale(t.position,(null==s?void 0:s.x)||1,(null==s?void 0:s.y)||1)},!0);null!=(null===(i=n.hitItems)||void 0===i?void 0:i.hits)&&n.hitItems.hits.length>0?await this.stream.flyTo({itemId:n.hitItems.hits[0].itemId,animation:{duration:T(this.configProvider().animation.durationMs)}}):console.debug(`No hit results found for fly to part [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}function Ht(t,i,s,n,e=1e3){let h,o,r=0,a=[];return s&&setInterval((()=>{if(null!=o){5===a.length?a=[...a.slice(1),o]:a.push(o);const t=a.reduce(((t,i)=>t+i))/a.length;console.debug(`Paint rate: ${o}fps`),console.debug(`Paint rate (avg): ${t}`),o=void 0}}),1e3),s=>(r++,null==h&&(h=window.setInterval((()=>{!function(t,i){const s=t.takeMeasurements();s.length>0&&i(s)}(t,n),0===r&&null!=h&&(window.clearInterval(h),h=void 0)}),e)),t.measure((async()=>{const t=await i(s);return o=null==o?1:o+1,t})).finally((()=>{r--})))}const _t=new class{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(null!=(i=t)&&i.then instanceof Function&&i.catch instanceof Function&&i.finally instanceof Function){const i=this.begin();return t.finally((()=>this.end(i)))}if("function"==typeof t){const i=this.begin(),s=t();return this.end(i),s}throw new Error("Input must be a function or Promise");var i}takeMeasurements(){const t=this.perf.getEntriesByName(this.name);return this.clearMeasurements(),t}takeLastMeasurement(){const t=this.takeMeasurements();return t[t.length-1]}begin(){const t=`${this.name}-${this.nextId++}`;return this.measures.add(t),this.perf.mark(t),t}end(t){this.perf.measure(this.name,t),this.perf.clearMarks(t),this.measures.delete(t)}}("paint_time");class Xt extends I{constructor(t=new S,i=!1,s=75e3,n=3e4){super(t,i),this.uninteractiveThreshold=s,this.offlineThreshold=n,this.handleOffline=this.handleOffline.bind(this),this.handleOnline=this.handleOnline.bind(this)}async connect(t,i={}){return window.addEventListener("offline",this.handleOffline),window.addEventListener("online",this.handleOnline),super.onRequest((()=>this.restartUninteractiveTimeout())),super.onResponse((()=>this.restartUninteractiveTimeout())),this.restartUninteractiveTimeout(),super.connect(t,i)}dispose(){window.removeEventListener("offline",this.handleOffline),window.removeEventListener("online",this.handleOnline),this.clearUninteractiveTimeout(),this.uninteractiveTimeout=void 0,this.clearOfflineTimeout(),this.offlineTimeout=void 0,super.dispose()}handleOffline(){this.restartOfflineTimeout()}handleOnline(){this.clearOfflineTimeout()}restartOfflineTimeout(){this.clearOfflineTimeout(),this.offlineTimeout=setTimeout((()=>{super.log("Disposing of StreamApi due to loss of network connection."),this.dispose()}),this.offlineThreshold)}clearOfflineTimeout(){null!=this.offlineTimeout&&clearTimeout(this.offlineTimeout)}restartUninteractiveTimeout(){this.clearUninteractiveTimeout(),this.uninteractiveTimeout=setTimeout((()=>{super.log("Disposing of StreamApi due to lack of interactivity."),this.dispose()}),this.uninteractiveThreshold)}clearUninteractiveTimeout(){null!=this.uninteractiveTimeout&&clearTimeout(this.uninteractiveTimeout)}}const Yt=t=>{var i,s,n,e,h,o,r,a,l,u,c;let d=P.protobuf.stream.FrameType.FRAME_TYPE_INVALID;switch(null===(i=t.depthBuffers)||void 0===i?void 0:i.frameType){case"final":d=P.protobuf.stream.FrameType.FRAME_TYPE_FINAL;break;case"all":d=P.protobuf.stream.FrameType.FRAME_TYPE_ALL}return Object.assign(Object.assign({},t),{depthBuffers:{enabled:Qt(null===(s=t.depthBuffers)||void 0===s?void 0:s.enabled),frameType:d},experimentalGhosting:{enabled:Qt(null===(n=t.experimentalGhosting)||void 0===n?void 0:n.enabled),opacity:"number"==typeof(null===(e=t.experimentalGhosting)||void 0===e?void 0:e.opacity)?{value:null===(h=t.experimentalGhosting)||void 0===h?void 0:h.opacity}:null===(o=t.experimentalGhosting)||void 0===o?void 0:o.opacity},featureLines:{lineWidth:null===(r=t.featureLines)||void 0===r?void 0:r.width,lineColor:(null===(a=t.featureLines)||void 0===a?void 0:a.color)?{r:null===(l=t.featureLines)||void 0===l?void 0:l.color.r,g:null===(u=t.featureLines)||void 0===u?void 0:u.color.g,b:null===(c=t.featureLines)||void 0===c?void 0:c.color.b}:null}})},Qt=t=>{if(null!=t)return"boolean"==typeof t?{value:t}:t},Zt=[0,1e3,1e3,5e3],ti=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.interactionStarted=i(this,"interactionStarted",7),this.interactionFinished=i(this,"interactionFinished",7),this.sessionidchange=i(this,"sessionidchange",7),this.dimensionschange=i(this,"dimensionschange",7),this.configEnv="platprod",this.cameraControls=!0,this.keyboardControls=!0,this.rotateAroundTapPoint=!0,this.experimentalGhostingOpacity=0,this.selectionMaterial=D,this.streamAttributes={},this.stencilBuffer=new $(this.hostElement),this.stateMap={cursorManager:new G},this.interactionHandlers=[],this.tapKeyInteractions=[],this.isStreamStarted=!1,this.internalFrameDrawnDispatcher=new g,this.handleElementResize=this.handleElementResize.bind(this),this.streamSessionId=this.sessionId}componentWillLoad(){this.updateResolvedConfig(),this.calculateComponentDimensions(),this.resizeObserver=new kt(this.handleElementResize),this.registerSlotChangeListeners();const t=new S;if(t.onClose((()=>this.handleWebSocketClose())),this.stream=new Xt(t,this.getResolvedConfig().flags.logWsMessages),this.setupStreamListeners(),this.commands=new zt(this.stream,(()=>this.getResolvedConfig())),this.commands.register("stream.connect",(t=>function({clientId:t,sessionId:i,resource:s}){return({stream:n,config:e})=>{if("stream-key"===s.type){const h=function(t,i,s,n){return p.appendPath(null!=s?p.toString(p.parseAndAddParams("/ws",{clientId:s,sessionId:n})):`/stream-keys/${i.id}/session`,p.parse(t.network.renderingHost))}(e,s,t,i),o={url:p.toString(h),protocols:["ws.vertexvis.com"]},r={EXPERIMENTAL_frameDelivery:Object.assign(Object.assign({},e.EXPERIMENTAL_frameDelivery),{rateLimitingEnabled:e.flags.throttleFrameDelivery}),EXPERIMENTAL_adaptiveRendering:Object.assign(Object.assign({},e.EXPERIMENTAL_adaptiveRendering),{enabled:e.flags.adaptiveRendering}),EXPERIMENTAL_qualityOfService:Object.assign({},e.EXPERIMENTAL_qualityOfService)};return n.connect(o,r)}throw new C(`Cannot load resource. Invalid type ${s.type}`)}}(t))),this.streamSessionId=this.sessionId,null==this.streamSessionId)try{this.streamSessionId=function(t,i){const s=window.localStorage.getItem("vertexvis:stream-sessions");if(null!=s)return i(JSON.parse(s))}(0,(t=>this.clientId?t[this.clientId]:void 0))}catch(t){}this.updateStreamAttributesProp(),this.stateMap.cursorManager.onChanged.on((()=>this.handleCursorChanged()))}componentDidLoad(){var t,i;if(this.interactionApi=this.createInteractionApi(),null!=this.src&&this.load(this.src),this.cameraControls)if(null!=window.PointerEvent){const t=new Gt("pointerdown","pointerup","pointermove",(()=>this.getResolvedConfig()));this.baseInteractionHandler=new Vt((()=>this.getResolvedConfig())),this.registerInteractionHandler(this.baseInteractionHandler),this.registerInteractionHandler(new Ut),this.registerInteractionHandler(t)}else{const t=new Gt("mousedown","mouseup","mousemove",(()=>this.getResolvedConfig()));this.baseInteractionHandler=new Nt((()=>this.getResolvedConfig())),this.registerInteractionHandler(this.baseInteractionHandler),this.registerInteractionHandler(new qt),this.registerInteractionHandler(t)}this.keyboardControls&&null!=this.stream&&(null===(t=this.baseInteractionHandler)||void 0===t||t.setDefaultKeyboardControls(this.keyboardControls),this.registerTapKeyInteraction(new Jt(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale())))),this.rotateAroundTapPoint&&(null===(i=this.baseInteractionHandler)||void 0===i||i.setPrimaryInteractionType("rotate-point")),this.injectViewerApi()}render(){var t;const i=this.getCanvasDimensions();return s(n,null,s("div",{class:"viewer-container",style:{cursor:q(null!==(t=this.cursor)&&void 0!==t?t:"")},onContextMenu:t=>t.preventDefault()},s("div",{ref:t=>this.containerElement=t,class:m("canvas-container",{"enable-pointer-events ":null!=window.PointerEvent})},s("canvas",{ref:t=>{this.canvasElement=t,this.stateMap.interactionTarget=t},class:"canvas",width:null!=i?i.width:0,height:null!=i?i.height:0}),null!=this.errorMessage?s("div",{class:"error-message"},this.errorMessage):null),s("slot",null)))}async registerCommand(t,i,s){return this.commands.register(t,i,s)}async dispatchFrameDrawn(t){this.lastFrame=t,this.frame=t,this.internalFrameDrawnDispatcher.emit(t),this.frameDrawn.emit(t)}async registerInteractionHandler(t){return this.interactionHandlers.push(t),this.initializeInteractionHandler(t),{dispose:()=>{const i=this.interactionHandlers.indexOf(t);-1!==i&&(this.interactionHandlers[i].dispose(),this.interactionHandlers.splice(i,1))}}}async registerTapKeyInteraction(t){this.tapKeyInteractions=[...this.tapKeyInteractions,t]}async getInteractionTarget(){if(null!=this.stateMap.interactionTarget)return this.stateMap.interactionTarget;throw new Error("Interaction target is undefined.")}async addCursor(t,i){return this.stateMap.cursorManager.add(t,i)}async getInteractionHandlers(){return this.interactionHandlers}async getBaseInteractionHandler(){return this.baseInteractionHandler}async getJwt(){return this.jwt}handleSrcChanged(t){null!=t?this.load(t):this.unload()}handleStreamAttributesChanged(t){this.isStreamStarted&&this.getStream().updateStream({streamAttributes:Yt(t)})}handleRotateAboutTapPointChanged(){var t,i;this.updateStreamAttributesProp(),this.rotateAroundTapPoint?null===(t=this.baseInteractionHandler)||void 0===t||t.setPrimaryInteractionType("rotate-point"):null===(i=this.baseInteractionHandler)||void 0===i||i.setPrimaryInteractionType("rotate")}handleDepthBuffersChanged(){this.updateStreamAttributesProp()}handleExperimentalGhostingOpacityChanged(){this.updateStreamAttributesProp()}handleFeatureLinesChanged(){this.updateStreamAttributesProp()}handleConfigChanged(){this.updateResolvedConfig()}handleConfigEnvChanged(){this.updateResolvedConfig()}async load(t){if(null==this.commands||null==this.dimensions)throw new k("Cannot load scene. Viewer has not been initialized.");{const{resource:i,queries:s}=null!=this.urn?O(this.urn):{},{resource:n,queries:e}=O(t),h=!b.isEqual(i,n),o=!b.isEqual(s,e),r=null!=e[0],a=await this.isSceneReady();if(this.urn=t,h||!a&&o)this.unload(),await this.connectStreamingClient(n,e[0]);else if(a&&o&&r){const t=await this.scene();await t.applySceneViewState(e[0].id)}}}async unload(){null!=this.streamDisposable&&(this.isStreamStarted=!1,this.streamId=void 0,this.streamDisposable.dispose(),this.lastFrame=void 0,this.frame=void 0,this.sceneViewId=void 0,this.clock=void 0,this.errorMessage=void 0,this.urn=void 0,this.stateMap.streamWorldOrientation=void 0)}async scene(){return this.createScene()}async isSceneReady(){return null!=this.lastFrame&&null!=this.sceneViewId}async handleTapEvent(t){this.tapKeyInteractions.filter((i=>i.predicate(t.detail))).forEach((i=>i.fn(t.detail)))}async handleWebSocketClose(){if(this.isStreamStarted&&(this.isStreamStarted=!1,null!=this.streamId&&null!=this.urn&&!this.isReconnecting)){const{resource:t}=O(this.urn);await this.reconnectWebSocket(t,this.streamId)}}async connectStreamingClient(t,i){try{this.streamDisposable=await this.connectStream(t),this.calculateComponentDimensions();const{startStream:s}=await this.getStream().startStream(Object.assign({streamKey:{value:t.id},dimensions:this.dimensions,frameBackgroundColor:this.getBackgroundColor(),streamAttributes:Yt(this.streamAttributes)},"scene-view-state"===(null==i?void 0:i.type)&&{sceneViewStateId:{hex:i.id}})),{streamId:n,sessionId:e,sceneViewId:h,jwt:o,worldOrientation:r}=s||{};if(this.jwt=o||void 0,this.emitConnectionChange({status:"connected",jwt:this.jwt||""}),null!=this.clientId&&null!=(null==e?void 0:e.hex)){this.streamSessionId=e.hex,this.sessionidchange.emit(this.streamSessionId);try{!function(t,i){const s=window.localStorage,n=s.getItem(t);if(null!=n){const e=Object.assign(Object.assign({},JSON.parse(n)),i);s.setItem(t,JSON.stringify(e))}else s.setItem(t,JSON.stringify(i))}("vertexvis:stream-sessions",{[this.clientId]:this.streamSessionId})}catch(t){}}null!=(null==h?void 0:h.hex)&&(this.sceneViewId=h.hex,this.isStreamStarted=!0),null!=(null==n?void 0:n.hex)&&(this.streamId=n.hex),this.stateMap.streamWorldOrientation=N(r),console.debug(`Stream connected [stream-id=${this.streamId}, scene-view-id=${this.sceneViewId}]`),await this.waitNextDrawnFrame(15e3),this.sceneReady.emit()}catch(t){if(this.emitConnectionChange({status:"disconnected"}),t instanceof z)throw t;if(null==this.lastFrame)throw this.errorMessage="Unable to establish connection to Vertex.",console.error("Failed to establish WS connection",t),new M(this.errorMessage,t instanceof Error?t:void 0)}}async connectStream(t){var i;null==this.clientId&&console.warn("Client ID not provided, using legacy path. A Client ID will be required in an upcoming release.");const s=await this.commands.execute("stream.connect",{clientId:this.clientId,sessionId:this.sessionId||this.streamSessionId,resource:t});return this.synchronizeTime(),this.canvasRenderer=Ht(_t,function(){let t;return async i=>{const s=i.frame.sequenceNumber,n=await(e=i.frame.image.imageBytes,null!=window.createImageBitmap?async function(t){const i=new Blob([t]),s=await window.createImageBitmap(i);return{image:s,dispose:()=>s.close()}}(e):(h=e,new Promise(((t,i)=>{const s=new Blob([h]),n=URL.createObjectURL(s),e=new Image;e.addEventListener("load",(()=>{t({image:e,dispose:()=>{}}),URL.revokeObjectURL(n)})),e.addEventListener("error",(()=>{i(new x("Failed to load image data")),URL.revokeObjectURL(n)})),e.src=n}))));var e,h;return(null==t||s>t)&&(t=s,function(t,i){const s=i.viewport.calculateDrawRect(i.frame.image);i.canvas.clearRect(0,0,i.dimensions.width,i.dimensions.height),i.canvas.drawImage(t.image,s.x,s.y,s.width,s.height)}(n,i)),n.dispose(),i.frame}}(),this.getResolvedConfig().flags.logFrameRate,(t=>this.reportPerformance(t))),null!=this.containerElement&&(null===(i=this.resizeObserver)||void 0===i||i.observe(this.containerElement)),s}async synchronizeTime(){var t;try{const i=await this.getStream().syncTime({requestTime:R()});if(null!=(null===(t=i.syncTime)||void 0===t?void 0:t.replyTime)){const t=E(i.syncTime.replyTime);null!=t&&(this.clock=new j(t),console.debug(`Synchronized time [local-time=${this.clock.knownLocalTime.toISOString()}, remote-time=${this.clock.knownRemoteTime.toISOString()}]`))}}catch(t){console.error("Failed to synchronize clock",t)}}async reconnectStreamingClient(t,i,s=!1){var n,e;try{null===(n=this.streamDisposable)||void 0===n||n.dispose(),this.clock=void 0,this.emitConnectionChange({status:"connecting"}),this.streamDisposable=await this.connectStream(t);const s=await this.getStream().reconnect({streamId:{hex:i},dimensions:this.dimensions,frameBackgroundColor:this.getBackgroundColor(),streamAttributes:Yt(this.streamAttributes)});this.isStreamStarted=!0,this.isReconnecting=!1,this.jwt=(null===(e=s.reconnect)||void 0===e?void 0:e.jwt)||void 0,this.emitConnectionChange({status:"connected",jwt:this.jwt||""}),console.debug(`Stream reconnected [stream-id=${this.streamId}, scene-view-id=${this.sceneViewId}]`)}catch(t){if(this.emitConnectionChange({status:"disconnected"}),t instanceof z)throw t;const i="Unable to establish connection to Vertex.";throw s||(this.errorMessage=this.errorMessage||i,console.error("Failed to establish WS connection",t)),new M(i,t instanceof Error?t:void 0)}}async reconnectWebSocket(t,i,s=0){try{await this.reconnectStreamingClient(t,i,!0)}catch(n){setTimeout((()=>this.reconnectWebSocket(t,i,s+1)),Zt[Math.min(s,Zt.length-1)])}}emitConnectionChange(t){this.connectionChange.emit(t)}handleElementResize(t){t.length>=0&&null!=this.dimensions&&!f.isEqual(t[0].contentRect,this.dimensions)&&!this.isResizing&&(this.isResizing=!0,window.requestAnimationFrame((()=>this.recalculateComponentDimensions())))}registerSlotChangeListeners(){this.mutationObserver=new MutationObserver((()=>this.injectViewerApi())),this.mutationObserver.observe(this.hostElement,{childList:!0,subtree:!0})}injectViewerApi(){function t(t){return Array.from(t.querySelectorAll("*"))}t(this.hostElement).filter((t=>t.nodeName.startsWith("VERTEX-"))).reduce(((i,s)=>[...i,s,...t(s)]),[]).forEach((t=>{t.viewer=this.hostElement}))}async handleStreamRequest(t){null!=t.drawFrame?this.handleFrame(t.drawFrame):null!=t.gracefulReconnection&&this.handleGracefulReconnect(t.gracefulReconnection)}handleGracefulReconnect(t){var i;if(null!=(null===(i=t.streamId)||void 0===i?void 0:i.hex)&&null!=this.urn){const{resource:i}=O(this.urn);this.isReconnecting=!0,this.reconnectStreamingClient(i,t.streamId.hex)}}async handleFrame(t){const i=this.getCanvasDimensions(),s=this.stateMap.streamWorldOrientation;if(null!=this.canvasElement&&null!=i&&null!=s){const n=this.canvasElement.getContext("2d");if(null!=n){this.frame=W(s)(t);const e={canvas:n,dimensions:i,frame:this.frame,viewport:U.fromDimensions(this.getCanvasDimensions()||f.create(0,0))};this.frameReceived.emit(this.frame);const h=await this.canvasRenderer(e);this.dispatchFrameDrawn(h)}}}waitNextDrawnFrame(t){const i=new Promise((t=>{const i=this.internalFrameDrawnDispatcher.on((s=>{t(s),i.dispose()}))}));return null!=t?y.timeout(t,i):i}calculateComponentDimensions(){const t=this.getBounds();if(null!=(null==t?void 0:t.width)&&null!=(null==t?void 0:t.height)){const i=f.create(t.width,t.height),s=f.scaleFit(2073600,i);this.hostDimensions=i,this.dimensions=null!=s?f.create(s.width,s.height):void 0}}recalculateComponentDimensions(){this.isResizing&&(this.calculateComponentDimensions(),this.isResizing=!1,this.dimensionschange.emit(this.dimensions),this.isStreamStarted&&this.getStream().updateDimensions({dimensions:this.dimensions}))}reportPerformance(t){if(this.isStreamStarted){const i={timings:t.map((t=>({receiveToPaintDuration:T(t.duration)})))};this.getStream().recordPerformance(i,!1)}}setupStreamListeners(){this.getStream().onRequest((t=>this.handleStreamRequest(t.request))),this.getStream().onRequest(function(t,i){const s=function(t){let i=!1;return s=>{const n=t();if(null!=n){const t=n.remoteTime(new Date(Date.now())),e=T(s,t);return E(e).getTime()>=0?e:void(i||(console.warn(`Possible erroneous send to receive timing. Muting for 60s. [sent-at=${s.toISOString()}, received-at=${t.toISOString()}, remote-time=${n.knownRemoteTime.toISOString()}]`),i=!0,setTimeout((()=>i=!1),6e4)))}}}(i);return n=i=>{return n=()=>n=>{const e=E(n.sentAtTime);null!=e&&t.replyResult(i,{drawFrame:{sendToReceiveDuration:s(e)}})},t=>{const{drawFrame:i}=t.request;null!=i&&n()(t)};var n},t=>{var i;const s=null===(i=t.request.requestId)||void 0===i?void 0:i.value;null!=s&&n(s)(t)};var n}(this.getStream(),(()=>this.clock)))}initializeInteractionHandler(t){if(null==this.stateMap.interactionTarget)throw new F("Cannot initialize interaction handler. Interaction target is undefined.");if(null==this.interactionApi)throw new F("Cannot initialize interaction handler. Interaction APi is undefined.");t.initialize(this.stateMap.interactionTarget,this.interactionApi)}createInteractionApi(){if(null==this.stream)throw new A("Cannot create interaction API. Component has not been initialized.");return new Mt(this.stream,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>U.fromDimensions(this.getCanvasDimensions()||f.create(0,0))),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished)}handleCursorChanged(){window.requestAnimationFrame((()=>{this.cursor=this.stateMap.cursorManager.getActiveCursor()}))}createScene(){if(null==this.frame||null==this.sceneViewId||null==this.stateMap.streamWorldOrientation)throw new B("Cannot create scene. Frame has not been rendered or stream not initialized.");const t="string"==typeof this.selectionMaterial?L(this.selectionMaterial):this.selectionMaterial;return new K(this.getStream(),this.frame,W(this.stateMap.streamWorldOrientation),(()=>this.getImageScale()),this.sceneViewId,t)}getBackgroundColor(){if(null!=this.containerElement)return h(this.containerElement)}getBounds(){return o(this.hostElement)}getCanvasDimensions(){return this.getResolvedConfig().flags.letterboxFrames?this.dimensions:this.hostDimensions}getImageScale(){const t=this.getCanvasDimensions();if(null!=this.dimensions&&null!=t)return u.create(this.dimensions.width/t.width,this.dimensions.height/t.height)}updateStreamAttributesProp(){const t=this.getDepthBufferStreamAttributesValue();this.streamAttributes={depthBuffers:{enabled:null!=t,frameType:t},experimentalGhosting:{enabled:this.experimentalGhostingOpacity>0,opacity:this.experimentalGhostingOpacity},featureLines:this.featureLines}}getDepthBufferStreamAttributesValue(){var t;return null!==(t=this.depthBuffers)&&void 0!==t?t:this.rotateAroundTapPoint?"final":void 0}updateResolvedConfig(){this.resolvedConfig=r(this.configEnv,this.config)}getResolvedConfig(){return ii("Resolved config is undefined",(()=>this.resolvedConfig))}getStream(){return ii("Stream is undefined",(()=>this.stream))}get hostElement(){return e(this)}static get watchers(){return{src:["handleSrcChanged"],streamAttributes:["handleStreamAttributesChanged"],rotateAroundTapPoint:["handleRotateAboutTapPointChanged"],depthBuffers:["handleDepthBuffersChanged"],experimentalGhostingOpacity:["handleExperimentalGhostingOpacityChanged"],featureLines:["handleFeatureLinesChanged"],config:["handleConfigChanged"],configEnv:["handleConfigEnvChanged"]}}};function ii(t,i){const s=i();if(null!=s)return s;throw new Error(t)}ti.style=":host{--image-background:var(--image-background);--viewer-background:var(--viewer-background);display:block;position:relative;width:300px;height:300px}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative;background:var(--image-background, var(--viewer-background, #ffffff))}.enable-pointer-events{touch-action:none}.viewer-container{width:100%;height:100%;overflow:hidden;background:var(--viewer-background, #ffffff)}.error-message{position:absolute;top:50%;width:100%;transform:translateY(-50%);text-align:center}";export{ti as vertex_viewer}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import{v as t}from"./p-d912dd24.js";import{a as s}from"./p-6d4ab5fc.js";class i{constructor(i){var r,o,a,e;this.start=null!==(r=i.start)&&void 0!==r?r:t.origin(),this.end=null!==(o=i.end)&&void 0!==o?o:t.origin(),this.invalid=null!==(a=i.invalid)&&void 0!==a&&a,this.id=null!==(e=i.id)&&void 0!==e?e:`measurement--${s.create()}`}getWorldDistance(){return t.distance(this.start,this.end)}getRealDistance(t){return t.translateRealValueToWorld(this.getWorldDistance())}}export{i as D}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import{m as t,c as e}from"./p-6d4ab5fc.js";import{e as s,v as i,f as n,p as r,r as o,m as a,g as h}from"./p-d912dd24.js";function c(t,e){const n=s.center(t),r=i.subtract(e.position,n),o=i.subtract(t.max,n),a=Math.abs(i.dot(i.subtract(e.lookAt,e.position),r))/i.magnitude(i.subtract(e.lookAt,e.position)),h=1.1*i.magnitude(o);let c=a+h,l=.01*c;if(l>a-h){if(l>1e3){const t=l-1e3;l=1e3,c-=t}}else l=a-h;return{far:c,near:l}}class l{constructor(t,e,s,i,n,r){this.camera=t,this.frameDimensions=e,this.imageRect=s,this.imageScale=i,this.data=n,this.imageDimensions=r}static fromPng(t,e,s,i,r){if(t.data instanceof Uint16Array)return new l(e,s,i,r,t.data,n.create(t.width,t.height));throw new Error("Expected depth PNG to have depth of 16-bit")}getLinearDepthAtPoint(t,e){const{near:s,far:i}=this.camera;return this.getNormalizedDepthAtPoint(t,e)*(i-s)+s}getNormalizedDepthAtPoint(t,e){const{width:s,height:i}=this.imageDimensions,n=r.subtract(t,this.imageRect),o=1/this.imageScale,a=r.scale(n,o,o);if(a.x>=0&&a.y>=0&&a.x<s&&a.y<i){const t=Math.floor(a.x)+Math.floor(a.y)*s,i=this.data[t],n=i===l.MAX_DEPTH_VALUE&&null!=e?e:i;return(null!=n?n:l.MAX_DEPTH_VALUE)/l.MAX_DEPTH_VALUE}return null!=e?e:1}isDepthAtFarPlane(t){return this.getNormalizedDepthAtPoint(t)<1}getWorldPoint(t,e,s){const n=this.getLinearDepthAtPoint(t,s),r=i.subtract(this.camera.lookAt,this.camera.position),a=o.at(e,this.camera.far),h=i.subtract(a,this.camera.position),c=i.dot(r,h)/(i.magnitude(r)*i.magnitude(h));return o.at(e,n/c)}isOccluded(t,e){const{position:s,direction:n,projectionViewMatrix:r}=this.camera,o=i.subtract(t,s),a=i.project(o,n),h=i.magnitude(a),c=i.transformMatrix(t,r),l=e.transformVectorToViewport(c),u=e.transformPointToFrame(l,this);return h>this.getLinearDepthAtPoint(u)}}let u,m;async function d(){return null==m&&(m=(null==u&&(console.debug("Loading PNG worker module"),u=async function(){return __sc_import_viewer("./p-2e11803d.js")}()),u).then((async({spawnPool:t})=>{const e=function(){var t;if("undefined"!=typeof window){const e=null!==(t=window.navigator.hardwareConcurrency)&&void 0!==t?t:8;return Math.ceil(e/4)}return 1}();return console.debug(`Spawning PNG worker pool [size=${e}]`),t({size:e})}))),m}l.MAX_DEPTH_VALUE=65535;const w=async t=>(await d()).queue((e=>e(t)));d();class f{constructor(t,e,s,i,n,r){this.correlationIds=t,this.sequenceNumber=e,this.dimensions=s,this.image=i,this.scene=n,this.depthBufferBytes=r}async depthBuffer(){return null==this.cachedDepthBuffer&&(this.cachedDepthBuffer=null!=this.depthBufferBytes?this.decodeDepthBuffer(this.depthBufferBytes):Promise.resolve(void 0)),this.cachedDepthBuffer}async decodeDepthBuffer(t){const e=await w(t);return l.fromPng(e,this.scene.camera,this.dimensions,this.image.imageRect,this.image.imageScale)}}class g{constructor(t,e,s,i){this.frameDimensions=t,this.imageRect=e,this.imageScale=s,this.imageBytes=i}}class p{constructor(t,e,s,i){this.camera=t,this.boundingBox=e,this.crossSection=s,this.worldOrientation=i}}class x{constructor(t,e,s,i,n,r,o){this.position=t,this.lookAt=e,this.up=s,this.near=i,this.far=n,this.aspectRatio=r,this.fovY=o}static fromBoundingBox(t,e,s){const{near:i,far:n}=c(e,t);return new x(t.position,t.lookAt,t.up,i,n,s,45)}computeCameraMatrices(){if(null==this.cameraMatrices){const t=a.makeLookAtView(this.position,this.lookAt,this.up),e=a.invert(t),s=a.makePerspective(this.near,this.far,this.fovY,this.aspectRatio),i=a.multiply(s,t);this.cameraMatrices={viewMatrix:t,worldMatrix:e,projectionMatrix:s,projectionViewMatrix:i}}return this.cameraMatrices}get direction(){return i.normalize(i.subtract(this.lookAt,this.position))}get worldMatrix(){return this.computeCameraMatrices().worldMatrix}get viewMatrix(){return this.computeCameraMatrices().viewMatrix}get projectionMatrix(){return this.computeCameraMatrices().projectionMatrix}get projectionViewMatrix(){return this.computeCameraMatrices().projectionViewMatrix}}class v{constructor(t){this.scale=t}translateWorldToReal(t){return t*this.scale}translateRealToWorld(t){return t/this.scale}}class b{constructor(t){this.unitType=t,this.unit=b.units[t]}translateWorldValueToReal(t){return this.unit.converter.translateWorldToReal(t)}translateRealValueToWorld(t){return this.unit.converter.translateRealToWorld(t)}translateWorldPointToReal(t){return{x:this.unit.converter.translateWorldToReal(t.x),y:this.unit.converter.translateWorldToReal(t.y),z:this.unit.converter.translateWorldToReal(t.z)}}translateRealPointToWorld(t){return{x:this.unit.converter.translateRealToWorld(t.x),y:this.unit.converter.translateRealToWorld(t.y),z:this.unit.converter.translateRealToWorld(t.z)}}}b.units={millimeters:{name:"Millimeters",abbreviatedName:"mm",converter:new class extends v{constructor(){super(1)}}},centimeters:{name:"Centimeters",abbreviatedName:"cm",converter:new class extends v{constructor(){super(.01)}}},meters:{name:"Meters",abbreviatedName:"m",converter:new class extends v{constructor(){super(.001)}}},inches:{name:"Inches",abbreviatedName:"in",converter:new class extends v{constructor(){super(1/25.4)}}},feet:{name:"Feet",abbreviatedName:"ft",converter:new class extends v{constructor(){super(1/(25.4*12))}}},yards:{name:"Yards",abbreviatedName:"yd",converter:new class extends v{constructor(){super(1/(25.4*12*3))}}}};class M{constructor(t,e){this.position=t,this.up=e}transformMatrix(t){const e=i.transformMatrix(this.position,t),s=i.transformMatrix(this.up,t);return new M(e,s)}}M.FRONT=new M(i.back(),i.up()),M.LEFT=new M(i.right(),i.up()),M.RIGHT=new M(i.left(),i.up()),M.BACK=new M(i.forward(),i.up()),M.TOP=new M(i.up(),i.forward()),M.BOTTOM=new M(i.down(),i.back()),M.TOP_FRONT_RIGHT=new M(i.add(i.back(),i.up(),i.left()),i.up()),M.TOP_FRONT_LEFT=new M(i.add(i.back(),i.up(),i.right()),i.up()),M.BOTTOM_FRONT_RIGHT=new M(i.add(i.back(),i.down(),i.left()),i.up()),M.BOTTOM_FRONT_LEFT=new M(i.add(i.back(),i.down(),i.right()),i.up()),M.TOP_BACK_LEFT=new M(i.add(i.forward(),i.up(),i.right()),i.up()),M.TOP_BACK_RIGHT=new M(i.add(i.forward(),i.up(),i.left()),i.up()),M.BOTTOM_BACK_LEFT=new M(i.add(i.forward(),i.down(),i.right()),i.up()),M.BOTTOM_BACK_RIGHT=new M(i.add(i.forward(),i.down(),i.left()),i.up()),M.TOP_FRONT=new M(i.add(i.back(),i.up()),i.up()),M.BOTTOM_FRONT=new M(i.add(i.back(),i.down()),i.up()),M.FRONT_RIGHT=new M(i.add(i.back(),i.left()),i.up()),M.FRONT_LEFT=new M(i.add(i.back(),i.right()),i.up()),M.TOP_BACK=new M(i.add(i.forward(),i.up()),i.up()),M.BOTTOM_BACK=new M(i.add(i.forward(),i.down()),i.up()),M.BACK_LEFT=new M(i.add(i.forward(),i.right()),i.up()),M.BACK_RIGHT=new M(i.add(i.forward(),i.left()),i.up()),M.TOP_LEFT=new M(i.add(i.up(),i.right()),i.up()),M.TOP_RIGHT=new M(i.add(i.up(),i.left()),i.up()),M.BOTTOM_LEFT=new M(i.add(i.down(),i.right()),i.up()),M.BOTTOM_RIGHT=new M(i.add(i.down(),i.left()),i.up());const y=t.defineMapper(t.read(t.requiredProp("r"),t.requiredProp("g"),t.requiredProp("b")),(([t,s,i])=>e.create(t,s,i))),P=t.defineMapper(t.read(t.requiredProp("x"),t.requiredProp("y"),t.requiredProp("z")),(([t,e,s])=>i.create(t,e,s))),A=t.defineMapper(t.read(t.requiredProp("xmin"),t.requiredProp("ymin"),t.requiredProp("zmin"),t.requiredProp("xmax"),t.requiredProp("ymax"),t.requiredProp("zmax")),(([t,e,n,r,o,a])=>s.create(i.create(t,e,n),i.create(r,o,a)))),B=t.defineMapper(t.read(t.requiredProp("width"),t.requiredProp("height")),(([t,e])=>n.create(t,e))),N=t.defineMapper(t.read(t.requiredProp("x"),t.requiredProp("y"),t.requiredProp("width"),t.requiredProp("height")),(([t,e,s,i])=>h.create(t,e,s,i))),R=t.defineMapper(t.read(t.mapProp("position",t.compose(t.required("position"),P)),t.mapProp("lookAt",t.compose(t.required("lookAt"),P)),t.mapProp("up",t.compose(t.required("up"),P))),(([t,e,s])=>({position:t,lookAt:e,up:s}))),j=t.defineMapper(t.read(t.mapProp("normal",t.compose(t.required("normal"),P)),t.requiredProp("offset")),(([t,e])=>({normal:t,offset:e}))),z=t.defineMapper(t.read(t.mapProp("frameDimensions",t.compose(t.required("frameDimensions"),B)),t.mapProp("imageRect",t.compose(t.required("imageRect"),N)),t.mapProp("scaleFactor",t.required("scaleFactor"))),(([t,e,s])=>({frameDimensions:t,imageRect:e,scaleFactor:s}))),D=t.defineMapper(t.read(t.mapProp("sectionPlanes",t.compose(t.required("sectionPlanes"),t.mapArray(j))),t.mapProp("highlightColor",t.ifDefined(y))),(([t,e])=>function(t={}){return{sectionPlanes:t.sectionPlanes||[],highlightColor:t.highlightColor}}({sectionPlanes:t,highlightColor:e||void 0}))),C=t.defineMapper(t.read(t.mapProp("imageAttributes",t.compose(t.required("imageAttributes"),z))),(([t])=>t)),F=t.defineMapper(t.read(C,t.mapProp("image",t.required("image"))),(([t,e])=>new g(t.frameDimensions,t.imageRect,t.scaleFactor,e))),W=t.defineMapper(t.read(t.mapProp("camera",t.compose(t.required("camera"),R)),t.mapProp("visibleBoundingBox",t.compose(t.required("visibleBoundingBox"),A)),t.mapProp("crossSectioning",t.compose(t.required("crossSectioning"),D))),(([t,e,s])=>({camera:t,boundingBox:e,crossSectioning:s}))),S=t.defineMapper(t.read(t.mapProp("sceneAttributes",t.compose(t.required("sceneAttributes"),W))),(([t])=>t)),T=t.defineMapper(t.read(S,C),(([t,e])=>x.fromBoundingBox(t.camera,t.boundingBox,n.aspectRatio(e.frameDimensions))));function k(e){return t.ifInvalidThrow(function(e){return t.defineMapper(t.read(t.mapProp("frameCorrelationIds",(t=>null!=t?t:[])),t.requiredProp("sequenceNumber"),t.compose(C,t.getProp("frameDimensions")),function(e){return t.defineMapper(t.read(S,T),(([t,s])=>new p(s,t.boundingBox,t.crossSectioning,e)))}(e),F,t.getProp("depthBuffer")),(([t,e,s,i,n,r])=>new f(t,e,s,n,i,(null==r?void 0:r.value)||void 0)))}(e))}const V=t.defineMapper(t.compose(t.required("orientation"),t.read(t.mapProp("up",t.compose(t.required("up"),P)),t.mapProp("front",t.compose(t.required("front"),P)))),(([t,e])=>new q(t,e))),E=t.ifInvalidThrow(V),G=t.defineMapper(t.read(t.mapRequiredProp("imageAttributes",z),t.requiredProp("stencilBuffer")),(([t,e])=>({imageAttributes:t,stencilBuffer:e}))),_=t.mapRequiredProp("stencilBuffer",G),I=t.ifInvalidThrow(_),L=e.create(0,0,0);class O{constructor(t){this.viewer=t,this.handleInteractionStarted=()=>{this.invalidateStencilBuffer(),this.pendingInteractionFinished=new Promise((t=>{this.pendingInteractionFinishedResolver=t}))},this.handleInteractionFinished=()=>{var t;null===(t=this.pendingInteractionFinishedResolver)||void 0===t||t.call(this),this.pendingInteractionFinished=void 0,this.pendingInteractionFinishedResolver=void 0},this.invalidateStencilBuffer=()=>{this.pendingStencilBuffer=void 0},t.addEventListener("interactionStarted",this.handleInteractionStarted),t.addEventListener("interactionFinished",this.handleInteractionFinished),t.addEventListener("frameReceived",(()=>{this.invalidateStencilBuffer()}))}async fetch(){const t=await this.viewer.isSceneReady()?await this.viewer.scene():void 0;if(null!=t&&(t.crossSectioning().current().sectionPlanes.length>0||null!=this.viewer.featureLines)&&null!=this.viewer.stream){const t=await this.viewer.stream.getStencilBuffer(!0),{stencilBuffer:e,imageAttributes:s}=I(t),i=await w(e);return U.fromPng(i,s.frameDimensions,s.imageRect,s.scaleFactor)}}latest(){return null==this.pendingStencilBuffer&&(this.pendingStencilBuffer=this.fetch()),this.pendingStencilBuffer}async latestAfterInteraction(){return await this.pendingInteractionFinished,this.latest()}}class U{constructor(t,e,s,i,n){this.frameDimensions=t,this.imageBytes=e,this.imageChannels=s,this.imageRect=i,this.imageScale=n}static fromPng(t,e,s,i){if(t.data instanceof Uint8Array)return new U(e,t.data,t.channels,s,i);throw new Error("Expected stencil PNG to have depth of 8-bit")}getColor(t){const{width:s,height:i}=this.imageRect,n=r.subtract(t,this.imageRect),o=1/this.imageScale,a=r.scale(n,o,o);if(a.x>=0&&a.y>=0&&a.x<s&&a.y<i){const t=(Math.floor(a.x)+Math.floor(a.y)*s)*this.imageChannels,i=e.create(this.imageBytes[t+0],this.imageBytes[t+1],this.imageBytes[t+2]);return function(t){return t.r===L.r&&t.g===L.g&&t.b===L.b}(i)?void 0:i}}getNearestPixel(t,e,s=(()=>!0)){const i=2*e,n=r.create(t.x-e,t.y-e),o=[];for(let a=0;a<i*i;a++){const h=a%i,c=Math.floor(a/i),l=r.add(n,{x:h,y:c});if(r.distance(l,t)<=e){const t=this.getColor(l);null!=t&&s(t)&&o.push(l)}}return o.sort(((e,s)=>r.distance(e,t)-r.distance(s,t)))[0]}}class q{constructor(t,e){this.y=t,this.z=e}get matrix(){const t=this.z,e=this.y,s=i.cross(e,t);return a.makeBasis(s,e,t)}}q.DEFAULT=new q(i.up(),i.back());export{f as F,b as M,q as O,O as S,g as a,p as b,x as c,k as d,M as e,c as f,E as m}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/*! *****************************************************************************
|
|
5
|
-
Copyright (c) Microsoft Corporation.
|
|
6
|
-
|
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
-
purpose with or without fee is hereby granted.
|
|
9
|
-
|
|
10
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
13
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
-
***************************************************************************** */
|
|
18
|
-
var n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function u(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(u.prototype=r.prototype,new u)}var r=function(){return(r=Object.assign||function(n){for(var t,r=1,u=arguments.length;r<u;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}).apply(this,arguments)};function u(n,t){var r={};for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&t.indexOf(u)<0&&(r[u]=n[u]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(u=Object.getOwnPropertySymbols(n);o<u.length;o++)t.indexOf(u[o])<0&&Object.prototype.propertyIsEnumerable.call(n,u[o])&&(r[u[o]]=n[u[o]])}return r}function o(n,t,r,u){return new(r||(r=Promise))((function(o,e){function i(n){try{c(u.next(n))}catch(n){e(n)}}function a(n){try{c(u.throw(n))}catch(n){e(n)}}function c(n){var t;n.done?o(n.value):(t=n.value,t instanceof r?t:new r((function(n){n(t)}))).then(i,a)}c((u=u.apply(n,t||[])).next())}))}function e(n,t){var r,u,o,e,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return e={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function a(e){return function(a){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,u&&(o=2&e[0]?u.return:e[0]?u.throw||((o=u.return)&&o.call(u),0):u.next)&&!(o=o.call(u,e[1])).done)return o;switch(u=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return i.label++,{value:e[1],done:!1};case 5:i.label++,u=e[1],e=[0];continue;case 7:e=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==e[0]&&2!==e[0])){i=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){i.label=e[1];break}if(6===e[0]&&i.label<o[1]){i.label=o[1],o=e;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(e);break}o[2]&&i.ops.pop(),i.trys.pop();continue}e=t.call(n,i)}catch(n){e=[6,n],u=0}finally{r=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,a])}}}function i(n,t){var r="function"==typeof Symbol&&n[Symbol.iterator];if(!r)return n;var u,o,e=r.call(n),i=[];try{for(;(void 0===t||t-- >0)&&!(u=e.next()).done;)i.push(u.value)}catch(n){o={error:n}}finally{try{u&&!u.done&&(r=e.return)&&r.call(e)}finally{if(o)throw o.error}}return i}function a(n,t,r){if(r||2===arguments.length)for(var u,o=0,e=t.length;o<e;o++)!u&&o in t||(u||(u=Array.prototype.slice.call(t,0,o)),u[o]=t[o]);return n.concat(u||Array.prototype.slice.call(t))}function c(n,t,r){return Math.max(t,Math.min(r,n))}function f(n,t,r){return(r=c(r,0,1))*(t-n)+n}function h(n,t){return void 0===n&&(n=0),void 0===t&&(t=0),{x:n,y:t}}function v(n,t){return{x:n.x-t.x,y:n.y-t.y}}function l(n,t){return{x:n.x+t.x,y:n.y+t.y}}function s(n,t){return n.x===t.x&&n.y===t.y}var d=Object.freeze({__proto__:null,create:h,polar:function(n,t){return h(Math.cos(t)*n,Math.sin(t)*n)},distance:function(n,t){var r=v(n,t);return Math.sqrt(r.x*r.x+r.y*r.y)},subtract:v,add:l,isEqual:s,lerp:function(n,t,r){return{x:f(n.x,t.x,r),y:f(n.y,t.y,r)}},negate:function(n){return h(-n.x,-n.y)},scale:function(n,t,r){return{x:n.x*t,y:n.y*r}},fromJson:function(n){var t=JSON.parse(n);return Array.isArray(t)?h(t[0],t[1]):h(t.x,t.y)}});function M(n){return(n+3600)%360}function y(n){return n*(180/Math.PI)}function m(n){return n*(Math.PI/180)}var x=Object.freeze({__proto__:null,fromPoints:function(n,t){var r=v(t,n);return Math.atan2(r.y,r.x)},fromPointsInDegrees:function(n,t){var r=v(t,n);return M(y(Math.atan2(r.y,r.x))-270)},normalize:M,toDegrees:y,toRadians:m});function _(n,t,r,u,o,e,i,a,c,f,h,v,l,s,d,M){return[n,o,c,l,t,e,f,s,r,i,h,d,u,a,v,M]}function z(n){return[1,0,0,0,0,1,0,0,0,0,1,0,n.x,n.y,n.z,1]}function b(n){var t=n.x,r=n.y,u=n.z,o=n.w,e=t+t,i=r+r,a=u+u,c=t*e,f=t*i,h=t*a,v=r*i,l=r*a,s=u*a,d=o*e,M=o*i,y=o*a;return[1-(v+s),f-y,h+M,0,f+y,1-(c+s),l-d,0,h-M,l+d,1-(c+v),0,0,0,0,1]}function p(n){return[n.x,0,0,0,0,n.y,0,0,0,0,n.z,0,0,0,0,1]}function w(n,t,r,u,o,e){return[2*o/(t-n),0,0,0,0,2*o/(r-u),0,0,(t+n)/(t-n),(r+u)/(r-u),-(e+o)/(e-o),-1,0,0,-2*e*o/(e-o),0]}function O(n,t){var r=n[0],u=n[4],o=n[8],e=n[12],i=n[1],a=n[5],c=n[9],f=n[13],h=n[2],v=n[6],l=n[10],s=n[14],d=n[3],M=n[7],y=n[11],m=n[15],x=t[0],_=t[4],z=t[8],b=t[12],p=t[1],w=t[5],O=t[9],j=t[13],g=t[2],k=t[6],A=t[10],S=t[14],P=t[3],T=t[7],q=t[11],J=t[15],R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return R[0]=r*x+u*p+o*g+e*P,R[4]=r*_+u*w+o*k+e*T,R[8]=r*z+u*O+o*A+e*q,R[12]=r*b+u*j+o*S+e*J,R[1]=i*x+a*p+c*g+f*P,R[5]=i*_+a*w+c*k+f*T,R[9]=i*z+a*O+c*A+f*q,R[13]=i*b+a*j+c*S+f*J,R[2]=h*x+v*p+l*g+s*P,R[6]=h*_+v*w+l*k+s*T,R[10]=h*z+v*O+l*A+s*q,R[14]=h*b+v*j+l*S+s*J,R[3]=d*x+M*p+y*g+m*P,R[7]=d*_+M*w+y*k+m*T,R[11]=d*z+M*O+y*A+m*q,R[15]=d*b+M*j+y*S+m*J,R}function j(n){return{m11:n[0],m12:n[4],m13:n[8],m14:n[12],m21:n[1],m22:n[5],m23:n[9],m24:n[13],m31:n[2],m32:n[6],m33:n[10],m34:n[14],m41:n[3],m42:n[7],m43:n[11],m44:n[15]}}var g=Object.freeze({__proto__:null,fromValues:_,fromObject:function(n){return _(n.m11,n.m12,n.m13,n.m14,n.m21,n.m22,n.m23,n.m24,n.m31,n.m32,n.m33,n.m34,n.m41,n.m42,n.m43,n.m44)},makeIdentity:function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},makeZero:function(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},makeTranslation:z,makeRotation:b,makeScale:p,makeTRS:function(n,t,r){var u=z(n),o=b(t),e=p(r);return O(O(u,o),e)},makeBasis:function(n,t,r){return[n.x,n.y,n.z,0,t.x,t.y,t.z,0,r.x,r.y,r.z,0,0,0,0,1]},makeRotationAxis:function(n,t){var r=Math.cos(t),u=Math.sin(t),o=1-r,e=n.x,i=n.y,a=n.z,c=o*e,f=o*i;return[c*e+r,c*i+u*a,c*a-u*i,0,c*i-u*a,f*i+r,f*a+u*e,0,c*a+u*i,f*a-u*e,o*a*a+r,0,0,0,0,1]},makeFrustum:w,makePerspective:function(n,t,r,u){var o=n*Math.tan(m(r/2)),e=o*u;return w(-e,e,o,-o,n,t)},makeLookAtView:function(n,t,r){var u=T(E(n,t)),o=T(R(r,u)),e=R(u,o),i=-D(o,n),a=-D(e,n),c=-D(u,n);return[o.x,e.x,u.x,0,o.y,e.y,u.y,0,o.z,e.z,u.z,0,i,a,c,1]},makeLookAt:function(n,t,r){var u=T(E(n,t)),o=T(R(r,u)),e=R(u,o);return[o.x,o.y,o.z,0,e.x,e.y,e.z,0,u.x,u.y,u.z,0,n.x,n.y,n.z,1]},invert:function(n){var t=n[0],r=n[1],u=n[2],o=n[3],e=n[4],i=n[5],a=n[6],c=n[7],f=n[8],h=n[9],v=n[10],l=n[11],s=n[12],d=n[13],M=n[14],y=n[15],m=t*i-r*e,x=t*a-u*e,_=t*c-o*e,z=r*a-u*i,b=r*c-o*i,p=u*c-o*a,w=f*d-h*s,O=f*M-v*s,j=f*y-l*s,g=h*M-v*d,k=h*y-l*d,A=v*y-l*M,S=m*A-x*k+_*g+z*j-b*O+p*w;return S?[(i*A-a*k+c*g)*(S=1/S),(u*k-r*A-o*g)*S,(d*p-M*b+y*z)*S,(v*b-h*p-l*z)*S,(a*j-e*A-c*O)*S,(t*A-u*j+o*O)*S,(M*_-s*p-y*x)*S,(f*p-v*_+l*x)*S,(e*k-i*j+c*w)*S,(r*j-t*k-o*w)*S,(s*b-d*_+y*m)*S,(h*_-f*b-l*m)*S,(i*O-e*g-a*w)*S,(t*g-r*O+u*w)*S,(d*x-s*z-M*m)*S,(f*z-h*x+v*m)*S]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},lookAt:function(n,t,u,o){var e=E(t,u);0===J(e)&&(e=r(r({},e),{z:1}));var i=R(o,e=T(e));0===J(i)&&(i=R(o,e=T(e=1===Math.abs(o.z)?r(r({},e),{x:e.x+1e-4}):r(r({},e),{z:e.z+1e-4}))));var c=R(e,i=T(i)),f=a([],n,!0);return f[0]=i.x,f[4]=c.x,f[8]=e.x,f[1]=i.y,f[5]=c.y,f[9]=e.y,f[2]=i.z,f[6]=c.z,f[10]=e.z,f},multiply:O,transpose:function(n){return[n[0],n[4],n[8],n[12],n[1],n[5],n[9],n[13],n[2],n[6],n[10],n[14],n[3],n[7],n[11],n[15]]},scale:function(n,t){var r=t.x,u=t.y,o=t.z,e=a([],n,!0);return e[0]*=r,e[4]*=u,e[8]*=o,e[1]*=r,e[5]*=u,e[9]*=o,e[2]*=r,e[6]*=u,e[10]*=o,e[3]*=r,e[7]*=u,e[11]*=o,e},position:function(n,t){var r=a([],n,!0);return r[12]=t[12],r[13]=t[13],r[14]=t[14],r},toObject:j,isType:function(n){return Array.isArray(n)&&16===n.length}});function k(){for(var n,t,r,u,o,e,i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return 1===i.length?{x:null!==(n=i[0].x)&&void 0!==n?n:0,y:null!==(t=i[0].y)&&void 0!==t?t:0,z:null!==(r=i[0].z)&&void 0!==r?r:0}:3===i.length?{x:null!==(u=i[0])&&void 0!==u?u:0,y:null!==(o=i[1])&&void 0!==o?o:0,z:null!==(e=i[2])&&void 0!==e?e:0}:{x:0,y:0,z:0}}function A(n){var t=j(n);return{x:Math.hypot(t.m11,t.m21,t.m31),y:Math.hypot(t.m12,t.m22,t.m32),z:Math.hypot(t.m13,t.m23,t.m33)}}function S(){return k(0,0,-1)}function P(){return k(0,0,0)}function T(n){var t=q(n);return{x:n.x/t,y:n.y/t,z:n.z/t}}function q(n){return Math.sqrt(J(n))}function J(n){return n.x*n.x+n.y*n.y+n.z*n.z}function R(n,t){return{x:n.y*t.z-n.z*t.y,y:n.z*t.x-n.x*t.z,z:n.x*t.y-n.y*t.x}}function F(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce((function(n,t){return{x:n.x+t.x,y:n.y+t.y,z:n.z+t.z}}),n)}function E(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce((function(n,t){return{x:n.x-t.x,y:n.y-t.y,z:n.z-t.z}}),n)}function N(n,t){return{x:t.x*n,y:t.y*n,z:t.z*n}}function D(n,t){return n.x*t.x+n.y*t.y+n.z*t.z}function L(n,t){var r=n.x,u=n.y,o=n.z,e=1/(t[3]*r+t[7]*u+t[11]*o+t[15]);return{x:(t[0]*r+t[4]*u+t[8]*o+t[12])*e,y:(t[1]*r+t[5]*u+t[9]*o+t[13])*e,z:(t[2]*r+t[6]*u+t[10]*o+t[14])*e}}function V(n,t){return Math.sqrt(I(n,t))}function I(n,t){var r=E(n,t),u=r.x,o=r.y,e=r.z;return u*u+o*o+e*e}function B(n,t){return k(Math.max(n.x,t.x),Math.max(n.y,t.y),Math.max(n.z,t.z))}function C(n,t){return k(Math.min(n.x,t.x),Math.min(n.y,t.y),Math.min(n.z,t.z))}function G(n,t,r){return{x:f(n.x,t.x,r),y:f(n.y,t.y,r),z:f(n.z,t.z,r)}}var Z=Object.freeze({__proto__:null,create:k,isValid:function(n){return[n.x,n.y,n.z].every((function(n){return isFinite(n)&&!isNaN(n)}))},fromMatrixScale:A,fromMatrixPosition:function(n){var t=j(n);return{x:t.m14,y:t.m24,z:t.m34}},fromJson:function(n){var t=JSON.parse(n);return Array.isArray(t)?k(t[0],t[1],t[2]):k(t.x,t.y,t.z)},fromArray:function(n,t){return void 0===t&&(t=0),k(n[t],n[t+1],n[t+2])},toArray:function(n){return[n.x,n.y,n.z]},right:function(){return k(1,0,0)},up:function(){return k(0,1,0)},forward:S,left:function(){return k(-1,0,0)},down:function(){return k(0,-1,0)},back:function(){return k(0,0,1)},origin:P,normalize:T,magnitude:q,magnitudeSquared:J,cross:R,add:F,subtract:E,multiply:function(n,t){return{x:n.x*t.x,y:n.y*t.y,z:n.z*t.z}},scale:N,dot:D,angleTo:function(n,t){var r=D(n,t)/(q(n)*q(t));return Math.acos(r)},project:function(n,t){return N(D(t,n)/q(t),t)},rotateAboutAxis:function(n,t,r,u){if(0!==n){var o=t.x,e=t.y,i=t.z,a=u.x,c=u.y,f=u.z,h=r.x,v=r.y,l=r.z;return{x:(a*(v*v+l*l)-h*(c*v+f*l-h*o-v*e-l*i))*(1-Math.cos(n))+o*Math.cos(n)+(-f*v+c*l-l*e+v*i)*Math.sin(n),y:(c*(h*h+l*l)-v*(a*h+f*l-h*o-v*e-l*i))*(1-Math.cos(n))+e*Math.cos(n)+(f*h-a*l+l*o-h*i)*Math.sin(n),z:(f*(h*h+v*v)-l*(a*h+c*v-h*o-v*e-l*i))*(1-Math.cos(n))+i*Math.cos(n)+(-c*h+a*v-v*o+h*e)*Math.sin(n)}}return t},transformMatrix:L,distance:V,distanceSquared:I,isEqual:function(n,t){return n.x===t.x&&n.y===t.y&&n.z===t.z},max:B,min:C,negate:function(n){return{x:-n.x,y:-n.y,z:-n.z}},lerp:G}),H=function(n,t){return{min:n,max:t}};function K(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var u=a([n],t,!0);return u.reduce((function(n,t){return H(C(n.min,t.min),B(n.max,t.max))}))}var Q=Object.freeze({__proto__:null,create:H,fromVectors:function(n){return K.apply(void 0,n.map((function(n){return H(n,n)})))},center:function(n){return N(.5,F(n.min,n.max))},union:K});function U(n,t,r,u){return{x:n,y:t,width:r,height:u}}function W(n,t){return U(n.x,n.y,t.width,t.height)}function X(n,t){var r=Math.min(n.width/t.width,n.height/t.height),u=cn(r,t);return W(v(tn(n),hn(u)),u)}function Y(n,t){var r=Math.max(n.width/t.width,n.height/t.height),u=cn(r,t);return W(v(tn(n),hn(u)),u)}function $(n,t){var r=Math.min(Math.sqrt(n/nn(t)),1),u=fn(cn(r,t));return W(v(tn(t),hn(u)),u)}function nn(n){return n.width*n.height}function tn(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}function rn(n){return h(n.x,n.y)}var un=Object.freeze({__proto__:null,create:U,fromDimensions:function(n){return U(0,0,n.width,n.height)},fromPointAndDimensions:W,fromPoints:function(n,t){var r=Math.min(n.x,t.x),u=Math.min(n.y,t.y);return U(r,u,Math.max(n.x,t.x)-r,Math.max(n.y,t.y)-u)},containFit:X,cropFit:Y,scaleFit:$,scale:function n(t,r,u){return null==u?n(t,r,r):U(t.x*r,t.y*u,t.width*r,t.height*u)},isEqual:function(n,t){return s(n,t)&&en(n,t)},offset:function(n,t){return W(l(rn(t),n),t)},area:nn,center:tn,topLeft:rn,bottomRight:function(n){return h(n.x+n.width,n.y+n.height)},isPortrait:function(n){return n.width<n.height},isLandscape:function(n){return n.width>n.height},isSquare:function(n){return n.width===n.height},pad:function(n,t){return U(n.x-t,n.y-t,n.width+2*t,n.height+2*t)},fromJson:function(n){var t=JSON.parse(n);return Array.isArray(t)?U(t[0],t[1],t[2],t[3]):U(t.x,t.y,t.width,t.height)}}),on=function(n,t){return{width:n,height:t}},en=function(n,t){return n.width===t.width&&n.height===t.height},an=function(n,t,r){return{width:r.width*n,height:r.height*t}},cn=function(n,t){return an(n,n,t)},fn=function(n){return{width:Math.floor(n.width),height:Math.floor(n.height)}},hn=function(n){return{x:n.width/2,y:n.height/2}};function vn(n,t){return void 0===t&&(t=h()),W(t,n)}var ln=Object.freeze({__proto__:null,create:on,square:function(n){return on(n,n)},isEqual:en,scale:an,proportionalScale:cn,trim:function(n,t){return{width:Math.min(n.width,t.width),height:Math.min(n.height,t.height)}},containFit:function(n,t){var r=X(vn(n),vn(t));return{width:r.width,height:r.height}},cropFit:function(n,t){var r=Y(vn(n),vn(t));return{width:r.width,height:r.height}},scaleFit:function(n,t){var r=$(n,vn(t));return{width:r.width,height:r.height}},round:function(n){return{width:Math.round(n.width),height:Math.round(n.height)}},floor:fn,center:hn,aspectRatio:function(n){return n.width/n.height},area:function(n){return n.width*n.height},fitToRatio:function(n,t){return t.width>=t.height*n?on(t.height*n,t.height):on(t.width,t.width/n)},toRectangle:vn});function sn(n){var t,r,u,o;return void 0===n&&(n={}),{x:null!==(t=n.x)&&void 0!==t?t:0,y:null!==(r=n.y)&&void 0!==r?r:0,z:null!==(u=n.z)&&void 0!==u?u:0,order:null!==(o=n.order)&&void 0!==o?o:"xyz"}}var dn=Object.freeze({__proto__:null,create:sn,fromDegrees:function(n){void 0===n&&(n={});var t=n.x,r=n.y,u=void 0===r?0:r,o=n.z,e=void 0===o?0:o,i=n.order;return sn({x:m(void 0===t?0:t),y:m(u),z:m(e),order:i})},fromRotationMatrix:function(n,t){void 0===t&&(t="xyz");var r=j(n),u=0,o=0,e=0;return"xyz"===t?(o=Math.asin(c(r.m13,-1,1)),Math.abs(r.m13)<.9999999?(u=Math.atan2(-r.m23,r.m33),e=Math.atan2(-r.m12,r.m11)):(u=Math.atan2(r.m32,r.m22),e=0)):"yxz"===t?(u=Math.asin(-c(r.m23,-1,1)),Math.abs(r.m23)<.9999999?(o=Math.atan2(r.m13,r.m33),e=Math.atan2(r.m21,r.m22)):(o=Math.atan2(-r.m31,r.m11),e=0)):"zxy"===t?(u=Math.asin(c(r.m32,-1,1)),Math.abs(r.m32)<.9999999?(o=Math.atan2(-r.m31,r.m33),e=Math.atan2(-r.m12,r.m22)):(o=0,e=Math.atan2(r.m21,r.m11))):"zyx"===t?(o=Math.asin(-c(r.m31,-1,1)),Math.abs(r.m31)<.9999999?(u=Math.atan2(r.m32,r.m33),e=Math.atan2(r.m21,r.m11)):(u=0,e=Math.atan2(-r.m12,r.m22))):"yzx"===t?(e=Math.asin(c(r.m21,-1,1)),Math.abs(r.m21)<.9999999?(u=Math.atan2(-r.m23,r.m22),o=Math.atan2(-r.m31,r.m11)):(u=0,o=Math.atan2(r.m13,r.m33))):"xzy"===t&&(e=Math.asin(-c(r.m12,-1,1)),Math.abs(r.m12)<.9999999?(u=Math.atan2(r.m32,r.m22),o=Math.atan2(r.m13,r.m11)):(u=Math.atan2(-r.m23,r.m33),o=0)),{x:u,y:o,z:e,order:t}},fromJson:function(n){var t=JSON.parse(n);if(Array.isArray(t)){var r=t[3];return{x:t[0],y:t[1],z:t[2],order:void 0===r?"xyz":r}}var u=t.order;return{x:t.x,y:t.y,z:t.z,order:void 0===u?"xyz":u}},isType:function(n){var t=n;return null!=t&&t.hasOwnProperty("x")&&t.hasOwnProperty("y")&&t.hasOwnProperty("z")&&t.hasOwnProperty("order")}});function Mn(n){return E(n.end,n.start)}var yn=Object.freeze({__proto__:null,create:function(n){var t,r;return void 0===n&&(n={}),{start:null!==(t=n.start)&&void 0!==t?t:P(),end:null!==(r=n.end)&&void 0!==r?r:P()}},center:function(n){return G(n.start,n.end,.5)},transformMatrix:function(n,t){return{start:L(n.start,t),end:L(n.end,t)}},distance:function(n){return V(n.start,n.end)},distanceSquared:function(n){return I(n.start,n.end)},direction:Mn}),mn=function(n,t,r,u,o,e){return void 0===n&&(n=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===u&&(u=1),void 0===o&&(o=0),void 0===e&&(e=0),{a:n,b:t,c:r,d:u,tx:o,ty:e}},xn=function(){return mn()},_n=function(n,t){var r=m(n),u=Math.cos(r),o=Math.sin(r);return mn(t.a*u+t.c*o,t.b*u+t.d*o,t.a*-o+t.c*u,t.b*-o+t.d*u,t.tx,t.ty)},zn=function(n,t,r){return mn(r.a,r.b,r.c,r.d,r.a*n+r.c*t+r.tx,r.b*n+r.d*t+r.ty)},bn=Object.freeze({__proto__:null,create:mn,identity:xn,translation:function(n,t){return zn(n,t,xn())},rotation:function(n){return _n(n,xn())},rotate:_n,translate:zn,transformPoint:function(n,t){return h(n.a*t.x+n.c*t.y+n.tx,n.b*t.x+n.d*t.y+n.ty)}}),pn=Object.freeze({__proto__:null,create:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return 2===n.length?{a:n[0].x,b:n[0].y,c:n[1].x,d:n[1].y}:4===n.length?{a:n[0],b:n[1],c:n[2],d:n[3]}:{a:0,b:0,c:0,d:0}},determinant:function(n){return n.a*n.d-n.b*n.c},dot:function(n){return n.a*n.c+n.b*n.d}});function wn(n,t){return D(n.normal,t)+n.constant}var On=Object.freeze({__proto__:null,create:function(n){return void 0===n&&(n={}),r({normal:P(),constant:0},n)},distanceToPoint:wn,intersectLine:function(n,t){var r=Mn(t),u=D(n.normal,r);if(0===u)return 0===wn(n,t.start)?t.start:void 0;var o=-(D(t.start,n.normal)+n.constant)/u;return o<0||o>1?void 0:F(t.start,N(o,r))},projectPoint:function(n,t){return F(t,N(-wn(n,t),n.normal))}});function jn(n){return void 0===n&&(n={}),r({x:0,y:0,z:0,w:1},n)}var gn=Object.freeze({__proto__:null,create:jn,fromJson:function(n){var t=JSON.parse(n);return Array.isArray(t)?jn({x:t[0],y:t[1],z:t[2],w:t[3]}):jn(t)},fromAxisAngle:function(n,t){var r=t/2,u=Math.sin(r);return{x:n.x*u,y:n.y*u,z:n.z*u,w:Math.cos(r)}},fromMatrixRotation:function(n){var t,r=j(n),u=A(n),o=1/u.x,e=1/u.y,i=1/u.z,a=r.m11*o,c=r.m21*e,f=r.m31*i,h=r.m12*o,v=r.m22*e,l=r.m32*i,s=r.m13*o,d=r.m23*e,M=r.m33*i,y=a+v+M;return y>0?{x:(l-d)/(t=2*Math.sqrt(y+1)),y:(s-f)/t,z:(c-h)/t,w:.25*t}:a>v&&a>M?{x:.25*(t=2*Math.sqrt(1+a-v-M)),y:(c+h)/t,z:(s+f)/t,w:t}:v>M?{x:(c+h)/(t=2*Math.sqrt(1+v-a-M)),y:.25*t,z:(l+d)/t,w:(s-f)/t}:{x:(s+f)/(t=2*Math.sqrt(1+M-a-v)),y:(l+d)/t,z:.25*t,w:(c-h)/t}},fromEuler:function(n){var t=n.x,r=n.y,u=n.z,o=n.order,e=Math.cos(t/2),i=Math.cos(r/2),a=Math.cos(u/2),c=Math.sin(t/2),f=Math.sin(r/2),h=Math.sin(u/2),v=0,l=0,s=0,d=0;switch(o){case"xyz":v=c*i*a+e*f*h,l=e*f*a-c*i*h,s=e*i*h+c*f*a,d=e*i*a-c*f*h;break;case"yxz":v=c*i*a+e*f*h,l=e*f*a-c*i*h,s=e*i*h-c*f*a,d=e*i*a+c*f*h;break;case"zxy":v=c*i*a-e*f*h,l=e*f*a+c*i*h,s=e*i*h+c*f*a,d=e*i*a-c*f*h;break;case"zyx":v=c*i*a-e*f*h,l=e*f*a+c*i*h,s=e*i*h-c*f*a,d=e*i*a+c*f*h;break;case"yzx":v=c*i*a+e*f*h,l=e*f*a+c*i*h,s=e*i*h-c*f*a,d=e*i*a-c*f*h;break;case"xzy":v=c*i*a-e*f*h,l=e*f*a-c*i*h,s=e*i*h+c*f*a,d=e*i*a+c*f*h}return{x:v,y:l,z:s,w:d}},multiply:function(n,t){return{x:n.x*t.w+n.w*t.x+n.y*t.z-n.z*t.y,y:n.y*t.w+n.w*t.y+n.z*t.x-n.x*t.z,z:n.z*t.w+n.w*t.z+n.x*t.y-n.y*t.x,w:n.w*t.w-n.x*t.x-n.y*t.y-n.z*t.z}},isType:function(n){var t=n;return null!=t&&t.hasOwnProperty("x")&&t.hasOwnProperty("y")&&t.hasOwnProperty("z")&&t.hasOwnProperty("w")}});function kn(n,t){return F(N(t,n.direction),n.origin)}function An(n,t){var r=D(t.normal,n.direction);if(0===r)return 0===wn(t,n.origin)?0:void 0;var u=-(D(n.origin,t.normal)+t.constant)/r;return u>=0?u:void 0}var Sn=Object.freeze({__proto__:null,create:function(n){var t,r;return void 0===n&&(n={}),{origin:null!==(t=n.origin)&&void 0!==t?t:P(),direction:null!==(r=n.direction)&&void 0!==r?r:S()}},at:kn,distanceToPlane:An,intersectPlane:function(n,t){var r=An(n,t);return null!=r?kn(n,r):void 0}});export{t as _,o as a,e as b,r as c,a as d,Q as e,ln as f,un as g,On as h,x as i,i as j,u as k,pn as l,g as m,bn as n,yn as o,d as p,gn as q,Sn as r,dn as s,Z as v}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**!
|
|
2
|
-
* Copyright (c) 2021 Vertex Software LLC. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import{r as e,c as t,h as a,H as r,g as n}from"./p-c9d8a379.js";import{s}from"./p-c738296e.js";import{A as i,C as o}from"./p-a717d9ff.js";import{i as l,a as d}from"./p-2768474e.js";import"./p-d912dd24.js";import"./p-6d4ab5fc.js";const h=class{constructor(a){e(this,a),this.markupAdded=t(this,"markupAdded",7),this.markupRemoved=t(this,"markupRemoved",7),this.tool="arrow",this.disabled=!1}async addMarkup(e){if(e instanceof i){const{start:t,end:a,id:r}=e,n=this.createArrowMarkupElement();return n.id=r,n.start=t,n.end=a,this.appendMarkupElement(n)}if(e instanceof o){const{bounds:t,id:a}=e,r=this.createCircleMarkupElement();return r.id=a,r.bounds=t,this.appendMarkupElement(r)}throw new Error(`Cannot add markup. Unknown type '${e}'.`)}async removeMarkup(e){const t=await this.getMarkupElement(e);return null!=t&&(t.remove(),this.markupRemoved.emit(t)),t}async getMarkupElements(){return Array.from(this.hostEl.children).filter((e=>l(e)||d(e)))}async getMarkupElement(e){return(await this.getMarkupElements()).find((t=>t.id===e))}async handleSelectedMarkupIdChanged(){(await this.getMarkupElements()).forEach((e=>{e.mode=e.id===this.selectedMarkupId?"edit":""}))}handleToolChanged(){this.updatePropsOnMarkupTool()}handleArrowTemplateIdChanged(){this.updatePropsOnMarkupTool()}handleCircleTemplateIdChanged(){this.updatePropsOnMarkupTool()}async handleViewerChanged(e){this.updatePropsOnMarkupTool(),this.updatePropsOnMarkups()}handleDisabledChanged(){this.updatePropsOnMarkupTool()}async handleMarkupEnd(e){const t=e;await this.addMarkup(t.detail),this.selectedMarkupId=t.detail.id}async handleMarkupEditCancel(){this.selectedMarkupId=void 0}async handleMarkupPointerDown(e){if(!this.disabled){const t=e.target,a=(await this.getMarkupElements()).find((e=>e===t));null!=(null==a?void 0:a.id)&&""!==(null==a?void 0:a.id)&&(this.selectedMarkupId=t.id)}}componentDidLoad(){this.updatePropsOnMarkupTool()}render(){return a(r,null,a("slot",null))}appendMarkupElement(e){return this.updatePropsOnMarkup(e),this.hostEl.appendChild(e),this.markupAdded.emit(e),e}createArrowMarkupElement(){if(null!=this.arrowTemplateId){const e=s(window.document.body,this.arrowTemplateId,l,(()=>console.warn(`Arrow template with ID ${this.arrowTemplateId} not found. Using default arrow element.`)),(()=>console.warn("Arrow template does not contain a vertex-viewer-markup-arrow. Using default arrow element.")));if(null!=e)return e}return document.createElement("vertex-viewer-markup-arrow")}createCircleMarkupElement(){if(null!=this.circleTemplateId){const e=s(window.document.body,this.circleTemplateId,d,(()=>console.warn(`Circle template with ID ${this.circleTemplateId} not found. Using default circle element.`)),(()=>console.warn("Circle template does not contain a vertex-viewer-markup-circle. Using default circle element.")));if(null!=e)return e}return document.createElement("vertex-viewer-markup-circle")}async updatePropsOnMarkups(){(await this.getMarkupElements()).forEach((e=>this.updatePropsOnMarkup(e)))}updatePropsOnMarkup(e){e.viewer=this.viewer,e.classList.add("viewer-markup__markup")}updatePropsOnMarkupTool(){const e=this.getMarkupTool();null!=e&&(e.disabled=this.disabled,e.arrowTemplateId=this.arrowTemplateId,e.circleTemplateId=this.circleTemplateId,e.tool=this.tool,e.viewer=this.viewer)}getMarkupTool(){return this.hostEl.querySelector("vertex-viewer-markup-tool")}get hostEl(){return n(this)}static get watchers(){return{selectedMarkupId:["handleSelectedMarkupIdChanged"],tool:["handleToolChanged"],arrowTemplateId:["handleArrowTemplateIdChanged"],circleTemplateId:["handleCircleTemplateIdChanged"],viewer:["handleViewerChanged"],disabled:["handleDisabledChanged"]}}};h.style=":host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}";export{h as vertex_viewer_markup}
|