@vertexvis/viewer 1.1.1-canary.6 → 1.1.1-testing.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{config-Ca0seD16.js → config-qhB9yOkD.js} +3 -3
- package/dist/cjs/{config-Ca0seD16.js.map → config-qhB9yOkD.js.map} +1 -1
- package/dist/cjs/{entities-CBN2BJKd.js → entities-OgE3KKMo.js} +4 -4
- package/dist/cjs/{entities-CBN2BJKd.js.map → entities-OgE3KKMo.js.map} +1 -1
- package/dist/cjs/{geometry_pb-DS0HM8ls.js → geometry_pb-CJZxK0hh.js} +3 -3
- package/dist/cjs/{geometry_pb-DS0HM8ls.js.map → geometry_pb-CJZxK0hh.js.map} +1 -1
- package/dist/cjs/index.cjs.js +5 -5
- package/dist/cjs/{png-decoder-Dt3IOAnw.js → png-decoder-BTtMRfiW.js} +23 -32
- package/dist/cjs/png-decoder-BTtMRfiW.js.map +1 -0
- package/dist/cjs/{queries-B4oPQ5xP.js → queries-DvkzwhnO.js} +4 -4
- package/dist/cjs/{queries-B4oPQ5xP.js.map → queries-DvkzwhnO.js.map} +1 -1
- package/dist/cjs/{regl-component-DDHBbHhG.js → regl-component-Ctuzdy_i.js} +3 -3
- package/dist/cjs/{regl-component-DDHBbHhG.js.map → regl-component-Ctuzdy_i.js.map} +1 -1
- package/dist/cjs/{representation_pb-_-8GOu4g.js → representation_pb-Cb20_8yP.js} +3 -3
- package/dist/cjs/{representation_pb-_-8GOu4g.js.map → representation_pb-Cb20_8yP.js.map} +1 -1
- package/dist/cjs/{streamAttributes-D4FScmnu.js → streamAttributes-BOGFM4R7.js} +3 -3
- package/dist/cjs/{streamAttributes-D4FScmnu.js.map → streamAttributes-BOGFM4R7.js.map} +1 -1
- package/dist/cjs/tslib.es6-BqRXrZGq.js +40 -0
- package/dist/cjs/{tslib.es6-Bu5Kp4WX.js.map → tslib.es6-BqRXrZGq.js.map} +1 -1
- package/dist/cjs/vertex-scene-tree-notification-banner_4.cjs.entry.js +1 -1
- package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js +1 -1
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-dom-element_2.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer-hit-result-indicator.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +1 -1
- package/dist/cjs/vertex-viewer.cjs.entry.js +4 -4
- package/dist/components/index.js +1 -1
- package/dist/components/{p-Tfg7jao4.js → p-B1EwHtiU.js} +2 -2
- package/dist/components/p-C-NyjLsm.js +5 -0
- package/dist/components/p-C-NyjLsm.js.map +1 -0
- package/dist/components/{p-Be_EPOMu.js → p-CNDZjNd7.js} +2 -2
- package/dist/components/{p-BNanw3eX.js → p-C_5cRYhA.js} +2 -2
- package/dist/components/{p-C-Mdlx-o.js → p-CkYfi_b3.js} +2 -2
- package/dist/components/{p-BQQxciHe.js → p-Dks3EzBM.js} +2 -2
- package/dist/components/{p-DCxPi7ft.js → p-IbLMJcql.js} +2 -2
- package/dist/components/{p-B3jZXFq2.js → p-XydgrVf-.js} +2 -2
- package/dist/components/p-Z7U3o7I4.js +5 -0
- package/dist/components/{p-Cta7kB-G.js → p-ZzS5zTnx.js} +2 -2
- package/dist/components/p-fKH0aLlq.js +5 -0
- package/dist/components/p-fKH0aLlq.js.map +1 -0
- package/dist/components/{p-C6BUwWB4.js → p-hMIHFP5Q.js} +2 -2
- package/dist/components/{p-DpQErze2.js → p-sPEu8FHr.js} +2 -2
- package/dist/components/vertex-scene-tree-table-cell.js +1 -1
- package/dist/components/vertex-scene-tree-table-layout.js +1 -1
- package/dist/components/vertex-scene-tree.js +1 -1
- package/dist/components/vertex-viewer-dom-renderer.js +1 -1
- package/dist/components/vertex-viewer-hit-result-indicator.js +1 -1
- package/dist/components/vertex-viewer-measurement-details.js +1 -1
- package/dist/components/vertex-viewer-measurement-distance.js +1 -1
- package/dist/components/vertex-viewer-measurement-overlays.js +1 -1
- package/dist/components/vertex-viewer-measurement-precise.js +1 -1
- package/dist/components/vertex-viewer-pin-group.js +1 -1
- package/dist/components/vertex-viewer-pin-tool.js +1 -1
- package/dist/components/vertex-viewer-transform-widget.js +1 -1
- package/dist/components/vertex-viewer-transform-widget.js.map +1 -1
- package/dist/components/vertex-viewer-view-cube.js +1 -1
- package/dist/components/vertex-viewer.js +1 -1
- package/dist/esm/{config-BHITDQif.js → config-Dukl2tlT.js} +3 -3
- package/dist/esm/{config-BHITDQif.js.map → config-Dukl2tlT.js.map} +1 -1
- package/dist/esm/{entities-Cj9Pt10J.js → entities-2kVCQNVh.js} +4 -4
- package/dist/esm/{entities-Cj9Pt10J.js.map → entities-2kVCQNVh.js.map} +1 -1
- package/dist/esm/{geometry_pb-EePgefLR.js → geometry_pb-CAxktHWj.js} +3 -3
- package/dist/esm/{geometry_pb-EePgefLR.js.map → geometry_pb-CAxktHWj.js.map} +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/{png-decoder-gMslGChA.js → png-decoder-Dx1E5Sod.js} +23 -32
- package/dist/esm/png-decoder-Dx1E5Sod.js.map +1 -0
- package/dist/esm/{queries-CEfTZHMm.js → queries-DM84n6se.js} +4 -4
- package/dist/esm/{queries-CEfTZHMm.js.map → queries-DM84n6se.js.map} +1 -1
- package/dist/esm/{regl-component-DXn0jg5S.js → regl-component-D-Wlx_GA.js} +3 -3
- package/dist/esm/{regl-component-DXn0jg5S.js.map → regl-component-D-Wlx_GA.js.map} +1 -1
- package/dist/esm/{representation_pb-DdXEMKrs.js → representation_pb-ZzJjYuoD.js} +3 -3
- package/dist/esm/{representation_pb-DdXEMKrs.js.map → representation_pb-ZzJjYuoD.js.map} +1 -1
- package/dist/esm/{streamAttributes-BZnxWMmW.js → streamAttributes-C2mLVHk_.js} +3 -3
- package/dist/esm/{streamAttributes-BZnxWMmW.js.map → streamAttributes-C2mLVHk_.js.map} +1 -1
- package/dist/esm/tslib.es6-C-NyjLsm.js +40 -0
- package/dist/esm/{tslib.es6-BzyVljQN.js.map → tslib.es6-C-NyjLsm.js.map} +1 -1
- package/dist/esm/vertex-scene-tree-notification-banner_4.entry.js +1 -1
- package/dist/esm/vertex-scene-tree-table-cell.entry.js +1 -1
- package/dist/esm/vertex-scene-tree.entry.js +2 -2
- package/dist/esm/vertex-viewer-dom-element_2.entry.js +1 -1
- package/dist/esm/vertex-viewer-hit-result-indicator.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-details.entry.js +3 -3
- package/dist/esm/vertex-viewer-measurement-distance.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-line_2.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-precise.entry.js +4 -4
- package/dist/esm/vertex-viewer-pin-group.entry.js +3 -3
- package/dist/esm/vertex-viewer-transform-widget.entry.js +2 -2
- package/dist/esm/vertex-viewer-view-cube.entry.js +1 -1
- package/dist/esm/vertex-viewer.entry.js +4 -4
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/{p-ad4c1175.entry.js → p-08b86996.entry.js} +2 -2
- package/dist/viewer/{p-b4bbbebf.entry.js → p-10c40a5e.entry.js} +2 -2
- package/dist/viewer/{p-ef596c04.entry.js → p-17e47830.entry.js} +2 -2
- package/dist/viewer/{p-ec49e818.entry.js → p-195297bb.entry.js} +2 -2
- package/dist/viewer/{p-994602a4.entry.js → p-37a7cbe4.entry.js} +2 -2
- package/dist/viewer/{p-9dd4a49a.entry.js → p-484e6990.entry.js} +2 -2
- package/dist/viewer/{p-ffd28212.entry.js → p-4a3a05c7.entry.js} +2 -2
- package/dist/viewer/{p-210f1777.entry.js → p-515eefc1.entry.js} +2 -2
- package/dist/viewer/{p-bfe38f9b.entry.js → p-91b6f9de.entry.js} +2 -2
- package/dist/viewer/{p-c46bf3b1.entry.js → p-9386f89b.entry.js} +2 -2
- package/dist/viewer/{p-75EpAVwy.js → p-Bi9f5zZC.js} +2 -2
- package/dist/viewer/{p-75EpAVwy.js.map → p-Bi9f5zZC.js.map} +1 -1
- package/dist/viewer/p-C-NyjLsm.js +5 -0
- package/dist/viewer/{p-BzyVljQN.js.map → p-C-NyjLsm.js.map} +1 -1
- package/dist/viewer/{p-CT1PhiRV.js → p-CD3U7s8H.js} +2 -2
- package/dist/viewer/{p-CT1PhiRV.js.map → p-CD3U7s8H.js.map} +1 -1
- package/dist/viewer/{p-BFQ1Tt4Y.js → p-Dl2B5rCE.js} +2 -2
- package/dist/viewer/{p-BFQ1Tt4Y.js.map → p-Dl2B5rCE.js.map} +1 -1
- package/dist/{components/p-CMBmMRkF.js → viewer/p-Dt9-9vSd.js} +2 -2
- package/dist/viewer/{p-BIj2SAwD.js.map → p-Dt9-9vSd.js.map} +1 -1
- package/dist/viewer/{p-CT3sclrO.js → p-P0ZprdA-.js} +2 -2
- package/dist/viewer/{p-CT3sclrO.js.map → p-P0ZprdA-.js.map} +1 -1
- package/dist/viewer/{p-2bb26337.entry.js → p-ae4ec0a8.entry.js} +2 -2
- package/dist/viewer/{p-e00839cd.entry.js → p-d709a094.entry.js} +2 -2
- package/dist/viewer/{p-7cb94735.entry.js → p-ef02ec4c.entry.js} +2 -2
- package/dist/viewer/p-fKH0aLlq.js +5 -0
- package/dist/viewer/p-fKH0aLlq.js.map +1 -0
- package/dist/viewer/{p-BnXUpT0J.js → p-fXz1xKOD.js} +2 -2
- package/dist/viewer/{p-BnXUpT0J.js.map → p-fXz1xKOD.js.map} +1 -1
- package/dist/viewer/{p-D4OO4AF0.js → p-vWHX2QSb.js} +2 -2
- package/dist/viewer/{p-D4OO4AF0.js.map → p-vWHX2QSb.js.map} +1 -1
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +32 -32
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/png-decoder-Dt3IOAnw.js.map +0 -1
- package/dist/cjs/tslib.es6-Bu5Kp4WX.js +0 -92
- package/dist/components/p-BzyVljQN.js +0 -5
- package/dist/components/p-BzyVljQN.js.map +0 -1
- package/dist/components/p-DaLbXlOV.js +0 -5
- package/dist/components/p-DaLbXlOV.js.map +0 -1
- package/dist/esm/index.mjs +0 -106
- package/dist/esm/loader.mjs +0 -16
- package/dist/esm/png-decoder-gMslGChA.js.map +0 -1
- package/dist/esm/tslib.es6-BzyVljQN.js +0 -88
- package/dist/index.cjs +0 -1
- package/dist/viewer/p-BIj2SAwD.js +0 -5
- package/dist/viewer/p-BzyVljQN.js +0 -5
- package/dist/viewer/p-DaLbXlOV.js +0 -5
- package/dist/viewer/p-DaLbXlOV.js.map +0 -1
- package/loader/index.cjs +0 -4
- /package/dist/components/{p-Tfg7jao4.js.map → p-B1EwHtiU.js.map} +0 -0
- /package/dist/components/{p-Be_EPOMu.js.map → p-CNDZjNd7.js.map} +0 -0
- /package/dist/components/{p-BNanw3eX.js.map → p-C_5cRYhA.js.map} +0 -0
- /package/dist/components/{p-C-Mdlx-o.js.map → p-CkYfi_b3.js.map} +0 -0
- /package/dist/components/{p-BQQxciHe.js.map → p-Dks3EzBM.js.map} +0 -0
- /package/dist/components/{p-DCxPi7ft.js.map → p-IbLMJcql.js.map} +0 -0
- /package/dist/components/{p-B3jZXFq2.js.map → p-XydgrVf-.js.map} +0 -0
- /package/dist/components/{p-CMBmMRkF.js.map → p-Z7U3o7I4.js.map} +0 -0
- /package/dist/components/{p-Cta7kB-G.js.map → p-ZzS5zTnx.js.map} +0 -0
- /package/dist/components/{p-C6BUwWB4.js.map → p-hMIHFP5Q.js.map} +0 -0
- /package/dist/components/{p-DpQErze2.js.map → p-sPEu8FHr.js.map} +0 -0
- /package/dist/viewer/{p-ad4c1175.entry.js.map → p-08b86996.entry.js.map} +0 -0
- /package/dist/viewer/{p-b4bbbebf.entry.js.map → p-10c40a5e.entry.js.map} +0 -0
- /package/dist/viewer/{p-ef596c04.entry.js.map → p-17e47830.entry.js.map} +0 -0
- /package/dist/viewer/{p-ec49e818.entry.js.map → p-195297bb.entry.js.map} +0 -0
- /package/dist/viewer/{p-994602a4.entry.js.map → p-37a7cbe4.entry.js.map} +0 -0
- /package/dist/viewer/{p-9dd4a49a.entry.js.map → p-484e6990.entry.js.map} +0 -0
- /package/dist/viewer/{p-ffd28212.entry.js.map → p-4a3a05c7.entry.js.map} +0 -0
- /package/dist/viewer/{p-210f1777.entry.js.map → p-515eefc1.entry.js.map} +0 -0
- /package/dist/viewer/{p-bfe38f9b.entry.js.map → p-91b6f9de.entry.js.map} +0 -0
- /package/dist/viewer/{p-c46bf3b1.entry.js.map → p-9386f89b.entry.js.map} +0 -0
- /package/dist/viewer/{p-2bb26337.entry.js.map → p-ae4ec0a8.entry.js.map} +0 -0
- /package/dist/viewer/{p-e00839cd.entry.js.map → p-d709a094.entry.js.map} +0 -0
- /package/dist/viewer/{p-7cb94735.entry.js.map → p-ef02ec4c.entry.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{h as t,t as e,p as i,H as n,d as s,e as r}from"./p-Bb32XUUS.js";import{v as a,a as o,p as h,l}from"./p-B8a9KIE8.js";import{m as d}from"./p-DIaJIPQu.js";import{b as c,g as u}from"./p-CpvtUGnF.js";import"./p-C-Mdlx-o.js";import"./p-FRKLa468.js";import"./p-ux1ckSDN.js";import"./p-B4qVkXXt.js";import{o as m,D as v}from"./p-Be_EPOMu.js";import{M as p}from"./p-DAU4efKm.js";import{M as w}from"./p-2lW8AfSs.js";import{m as f}from"./p-EHuPJ1mC.js";import{V as g}from"./p-D3hmsz_I.js";import{E as b,m as y}from"./p-IVh_3-KN.js";import{d as C,g as E}from"./p-B3jZXFq2.js";import{c as P}from"./p-C6gMOKYg.js";import{d as M}from"./p-CaMZxfAH.js";const x=16;const k=10;function I(t){return t.getBoundingClientRect()}class D{constructor(t,e,i,n){this.stencil=t;this.depthBuffer=e;this.viewport=i;this.camera=n}hitTest(t){const e=this.viewport.transformPointToFrame(t,this.depthBuffer);if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);return this.stencil.hitTest(i)||this.depthBuffer.hitTest(e)}else{return this.depthBuffer.hitTest(e)}}snapToNearestPixel(t,e){if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);const n=this.stencil.snapToNearestPixel(i,e);return this.viewport.transformPointToViewport(n,this.stencil)}else{return t}}transformPointToWorld(t,{ignoreHitTest:e=false}={}){const i=this.pickDepthBuffer(t);if(i!=null){return this.viewport.transformPointToWorldSpace(t,i)}else if(e){return this.viewport.transformPointToWorldSpace(t,this.depthBuffer)}}pickDepthBuffer(t){if(this.stencil!=null){const e=this.viewport.transformPointToFrame(t,this.stencil);if(this.stencil.hitTest(e)){return this.stencil.depthBuffer}}const e=this.viewport.transformPointToFrame(t,this.depthBuffer);return this.depthBuffer.hitTest(e)?this.depthBuffer:undefined}}class j{constructor(t){this.model=t}newMeasurement(t,e){const i=e.hitTester().transformPointToWorld(t);return i!=null?new S(t,i,this.model):undefined}editMeasurement(t){const e=this.model.getMeasurement();if(e==null){throw new Error("Cannot edit measurement. Measurement is empty.")}return t==="start"?new B(e,this.model):new V(e,this.model)}clearIndicator(){this.model.setIndicator(undefined)}moveIndicator(t,e){const i=e.hitTester().transformPointToWorld(t);this.model.setIndicator(i);return i!=null}}class A{constructor(){this.measurementChanged=new b;this.indicatorChanged=new b}static empty(){return new A}getMeasurement(){return this.measurement}setMeasurement(t){if(this.measurement!==t){this.measurement=t;this.measurementChanged.emit(t)}}setMeasurementFromValues(t,e,i){if(t!=null&&e!=null){const n=i?O(t,e):T(t,e);this.setMeasurement(n)}else{this.setMeasurement(undefined)}}onMeasurementChanged(t){return this.measurementChanged.on(t)}getIndicator(){return this.indicator}setIndicator(t){if(this.indicator!==t){this.indicator=t;this.indicatorChanged.emit(t)}}onIndicatorChanged(t){return this.indicatorChanged.on(t)}}class S{constructor(t,e,i){this.pt=t;this.world=e;this.model=i;this.hitWorldValid=true;this.preventUpdate=false}fetchStartIfMissing(t){if(this.pendingStart==null){this.pendingStart=this.fetchStart(t)}}async fetchStart(t){const e=await t.raycaster();const i=await H(e,this.pt);if(i==null){const e=t.hitTester().transformPointToWorld(this.pt);this.hitWorld=e;this.hitWorldValid=false}else{this.hitWorld=i;this.hitWorldValid=true}}update(t,e){var i;if(!this.preventUpdate){this.fetchStartIfMissing(e);const n=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const s=e.hitTester().hitTest(t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;if(n==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!this.hitWorldValid||!s){this.model.setIndicator(n);this.setMeasurement(T(r,n))}else{this.model.setIndicator(n);this.setMeasurement(O(r,n))}}}async finish(t,e){var i;this.preventUpdate=true;this.fetchStartIfMissing(e);await this.pendingStart;this.model.setIndicator(undefined);const n=await e.raycaster();const s=await H(n,t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;this.preventUpdate=false;if(s==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete new measurement interaction. End point is empty.")}return this.setMeasurement(T(r,i))}else if(!this.hitWorldValid){return this.setMeasurement(T(r,s))}else{return this.setMeasurement(O(r,s))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class L{constructor(t,e){this.measurement=t;this.model=e}update(t,e){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const n=e.hitTester().hitTest(t);if(i==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!n){this.model.setIndicator(i);this.setMeasurement(this.getInvalidMeasurement(i))}else{this.model.setIndicator(i);this.setMeasurement(this.getValidMeasurement(i))}}async finish(t,e){const i=await e.raycaster();const n=await H(i,t);this.model.setIndicator(undefined);if(n==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete edit measurement interaction. End point is empty.")}return this.setMeasurement(this.getInvalidMeasurement(i))}else{return this.setMeasurement(this.getValidMeasurement(n))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class B extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return T(t,this.measurement.end)}getValidMeasurement(t){return O(t,this.measurement.end)}}class V extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return T(this.measurement.start,t)}getValidMeasurement(t){return O(this.measurement.start,t)}}async function H(t,e){var i;const n=await t.hitItems(e);const[s]=(i=n===null||n===void 0?void 0:n.hits)!==null&&i!==void 0?i:[];if((s===null||s===void 0?void 0:s.hitPoint)!=null){const t=m(s.hitPoint);if(y.isInvalid(t)){throw new Error(`Invalid hit response [${t.errors.join(",")}]`)}return t}else return undefined}function O(t,e){return{start:t,end:e,distance:a.distance(t,e),valid:true}}function T(t,e){return{start:t,end:e,valid:false}}const U=({startPt:e,endPt:i,centerPt:n,indicatorPt:s,distance:r,anchorLabelOffset:a,lineCapLength:l,linePointerEvents:d,hideStartAnchor:u,hideEndAnchor:m,onStartAnchorPointerDown:v,onEndAnchorPointerDown:p})=>{const w=e!=null&&i!=null?o.fromPoints(e,i):undefined;const f=w!=null&&e!=null&&a!=null?h.add(e,h.polar(-a,w)):undefined;const g=w!=null&&i!=null&&a!=null?h.add(i,h.polar(a,w)):undefined;return t("div",null,e!=null&&i!=null&&t("vertex-viewer-measurement-line",{class:P("line",{"hide-start-line-cap":u,"hide-end-line-cap":m}),start:e,end:i,capLength:l,pointerEvents:d}),!u&&e!=null&&t("div",{id:"start-anchor",class:"anchor anchor-start",style:{transform:c(e)},onPointerDown:v},t("slot",{name:"start-anchor"},t("div",{class:"anchor-placeholder"}))),!u&&f&&t("div",{class:"anchor-label anchor-label-start",style:{transform:c(f)}},t("slot",{name:"start-label"})),!m&&i!=null&&t("div",{id:"end-anchor",class:"anchor anchor-end",style:{transform:c(i)},onPointerDown:p},t("slot",{name:"end-anchor"},t("div",{class:"anchor-placeholder"}))),!m&&g&&t("div",{class:"anchor-label anchor-label-end",style:{transform:c(g)}},t("slot",{name:"end-label"})),n!=null&&t("div",{id:"label",class:"distance-label",style:{transform:c(n)}},r),s!=null&&t("div",{class:"indicator",style:{transform:c(s)}},t("slot",{name:"indicator"},t("div",{class:"indicator-placeholder"}))))};const F=()=>`:host{--viewer-measurement-distance-accent-color:var(--neutral-900);--viewer-measurement-distance-contrast-color:var(--white);--viewer-measurement-distance-invalid-accent-color:var(--red-600);--viewer-measurement-distance-invalid-contrast-color:var(--white);--viewer-measurement-distance-line-stroke-width:1.25px;--viewer-measurement-distance-line-fill-width:2px;--viewer-measurement-distance-distance-border:1px solid var(--viewer-measurement-distance-accent-color);--viewer-measurement-distance-distance-border-radius:0.25rem;--viewer-measurement-distance-distance-padding:0.375rem 0.5rem;color:var(--viewer-measurement-distance-accent-color);font-size:0.75rem;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}:host([invalid]:not([invalid='false'])){--viewer-measurement-distance-accent-color:var( --viewer-measurement-distance-invalid-accent-color ) !important;--viewer-measurement-distance-contrast-color:var( --viewer-measurement-distance-invalid-contrast-color ) !important}.line{--viewer-measurement-line-stroke:var( --viewer-measurement-distance-contrast-color );--viewer-measurement-line-stroke-opacity:0.75;--viewer-measurement-line-stroke-width:var( --viewer-measurement-distance-line-stroke-width );--viewer-measurement-line-fill:var( --viewer-measurement-distance-accent-color );--viewer-measurement-line-fill-width:var( --viewer-measurement-distance-line-fill-width );position:absolute;width:100%;height:100%}.anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host([interacting-anchor='start']) .anchor-start,:host([interacting-anchor='start']) .anchor-label-start{visibility:hidden}.hide-start-line-cap,:host([interacting-anchor='start']) .line{--viewer-measurement-line-start-cap-visibility:hidden}:host([interacting-anchor='end']) .anchor-end,:host([interacting-anchor='end']) .anchor-label-end{visibility:hidden}.hide-end-line-cap,:host([interacting-anchor='end']) .line{--viewer-measurement-line-end-cap-visibility:hidden}.anchor-label{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host(:not([mode=''])){cursor:inherit}:host(:not([mode=''])) .anchor{cursor:move}:host([mode='']) .anchor{visibility:hidden}.anchor-placeholder{background:var(--viewer-measurement-distance-contrast-color);width:12px;height:12px;border-radius:50%;box-sizing:border-box}:host(:not([mode=''])) .anchor-placeholder{border:2px solid var(--viewer-measurement-distance-accent-color);background:var(--viewer-measurement-distance-contrast-color)}:host([mode='']) .distance-label{color:var(--viewer-measurement-distance-contrast-color);background:var(--viewer-measurement-distance-accent-color)}.distance-label{position:absolute;background:var(--viewer-measurement-distance-contrast-color);border:var(--viewer-measurement-distance-distance-border);border-radius:var(--viewer-measurement-distance-distance-border-radius);padding:var(--viewer-measurement-distance-distance-padding);pointer-events:auto}.indicator{position:absolute}.indicator-placeholder{background:var(--viewer-measurement-distance-accent-color);border:1px solid var(--viewer-measurement-distance-contrast-color);width:6px;height:6px;border-radius:50%;box-sizing:border-box}`;const z=3;const J=i(class e extends n{constructor(t){super();if(t!==false){this.__registerHost()}this.__attachShadow();this.editBegin=s(this,"editBegin");this.editEnd=s(this,"editEnd");this.showAxisReferenceLines=false;this.snapDistance=x;this.units="millimeters";this.fractionalDigits=2;this.anchorLabelOffset=20;this.lineCapLength=k;this.mode="";this.interactingAnchor="none";this.invalid=false;this.measurementModel=new p;this.viewport=new g(0,0);this.interactionCount=0;this.invalidateStateCounter=0;this.stateMap={};this.measurementUnits=new v(this.units);this.model=A.empty();this.controller=new j(this.model);this.overlays=new w;this.isUserInteractingWithModel=false;this.handleFrameDrawn=()=>{this.invalidateState()};this.clearIndicator=()=>{this.controller.clearIndicator()};this.updateStartAnchor=async t=>{await this.getStencilBuffer();if(this.interactionCount===0){const e=u(t,this.elementBounds);const i=this.snapPoint(e,t);await this.updateIndicator(i)}};this.newMeasurement=t=>{if(this.interactionCount===0&&t.button===0){const e=t=>{const e=()=>{window.removeEventListener("pointerup",i);window.removeEventListener("pointermove",n)};const i=async()=>{e();t()};const n=t=>{if(t.buttons>0){e()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",i)};const i=t=>{let e=h.create(0,0);const i=i=>{const n=h.distance(e,u(i,this.elementBounds));if(n>=z){t()}};const n=()=>{window.removeEventListener("pointermove",i);window.removeEventListener("pointerup",s)};const s=()=>n();const r=t=>{e=u(t,this.elementBounds);window.addEventListener("pointermove",i);window.addEventListener("pointerup",s)};window.addEventListener("pointerdown",r);return{dispose:()=>window.removeEventListener("pointerdown",r)}};const n=()=>{const t=i((()=>{var t;this.isUserInteractingWithModel=true;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}));const e=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",s);t.dispose()};const n=this.createInteractionMoveHandler();const s=async t=>{var i;if(t.button===0){if(this.isUserInteractingWithModel){this.isUserInteractingWithModel=false}else{const n=this.getHitProvider();if(n!=null){const s=u(t,this.elementBounds);const r=this.snapPoint(s,t);await((i=this.interaction)===null||i===void 0?void 0:i.finish(r,n));e();this.updateMeasurementPropsFromModel();this.endEditing()}}}};this.beginEditing("replace","end");this.newInteractionHandler={dispose:e};window.addEventListener("pointermove",n);window.addEventListener("pointerup",s)};const s=this.getHitProvider();if(s!=null){const i=u(t,this.elementBounds);const r=this.snapPoint(i,t);this.interaction=this.controller.newMeasurement(r,s);if(this.interaction!=null){e(n)}}}}}async computeElementMetrics(){var t,e,i;const n=(t=this.hostEl.shadowRoot)===null||t===void 0?void 0:t.getElementById("start-anchor");const s=(e=this.hostEl.shadowRoot)===null||e===void 0?void 0:e.getElementById("end-anchor");const r=(i=this.hostEl.shadowRoot)===null||i===void 0?void 0:i.getElementById("label");if(n!=null&&s!=null&&r!=null){return{startAnchor:n.getBoundingClientRect(),endAnchor:s.getBoundingClientRect(),label:r.getBoundingClientRect()}}else{return undefined}}connectedCallback(){this.setDepthBuffers()}disconnectedCallback(){var t,e;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose();(e=this.newInteractionHandler)===null||e===void 0?void 0:e.dispose();this.resetDepthBuffers()}async componentWillLoad(){this.updatePropsFromJson();this.model.setMeasurementFromValues(this.start,this.end,!this.invalid);await this.getStencilBuffer();this.updateViewport();this.setDepthBuffers();await this.handleViewerChanged(this.viewer);await this.handleModeChanged();await this.computePropsAndState();this.model.onIndicatorChanged((t=>{this.indicatorPt=t}))}componentDidLoad(){const t=new ResizeObserver((()=>this.updateViewport()));t.observe(this.hostEl)}async componentWillUpdate(){await this.computePropsAndState()}render(){return t(r,{key:"58113224139c37a54bf9329ed27e6a8983d5cccd"},this.showAxisReferenceLines&&t("vertex-viewer-measurement-overlays",{key:"d2166c4a965761f472f5b3323844d82980baa29f",measurementOverlays:this.overlays,viewer:this.viewer}),this.renderMeasurement())}renderMeasurement(){const e=this.computeElementPositions();const{startPt:i,endPt:n,labelPt:s,indicatorPt:r,hideStart:a,hideEnd:o}=e;const h=this.formatDistance(this.distance);if(this.mode==="edit"||this.mode==="replace"){return t(U,{startPt:i,endPt:n,centerPt:s,indicatorPt:r,distance:h,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,hideStartAnchor:a,hideEndAnchor:o,onStartAnchorPointerDown:this.handleEditAnchor("start"),onEndAnchorPointerDown:this.handleEditAnchor("end")})}else{return t(U,{startPt:i,endPt:n,centerPt:s,indicatorPt:this.indicatorPt,distance:h,hideStartAnchor:a,hideEndAnchor:o,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,linePointerEvents:"painted"})}}async handleViewerChanged(t,e){if(e!=null){e.removeEventListener("frameDrawn",this.handleFrameDrawn);await this.removeInteractionListeners(e)}if(t!=null){t.addEventListener("frameDrawn",this.handleFrameDrawn);await this.addInteractionListeners(t)}}handleUnitsChanged(){this.measurementUnits=new v(this.units)}handleCameraChanged(){this.updateCamera()}async handleModeChanged(){var t;if(this.mode===""){(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}if(this.viewer!=null){await this.removeInteractionListeners(this.viewer);await this.addInteractionListeners(this.viewer)}}handleStartChanged(){this.updateInteractionModel()}handleEndChanged(){this.updateInteractionModel()}handleInvalidChanged(){this.updateInteractionModel()}async computePropsAndState(){this.updateCamera();await this.updateDepthBuffer();this.updateMeasurementPropsFromModel();this.updateOverlays()}updateOverlays(){var t;(t=this.overlay)===null||t===void 0?void 0:t.dispose();if(this.showAxisReferenceLines&&this.interactionCount===0&&!this.invalid&&this.start!=null&&this.end!=null){this.overlay=this.overlays.addDistanceVector(this.start,this.end)}}async setCursor(t){var e,i;(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose();if(!this.isUserInteractingWithModel){this.stateMap.hoverCursor=await((i=this.viewer)===null||i===void 0?void 0:i.addCursor(t))}}computeElementPositions(){if(this.mode==="replace"){return this.computeReplaceElementPositions()}else{return this.computeEditOrViewElementPositions()}}computeEditOrViewElementPositions(){const t=this.model.getMeasurement();if(this.internalCamera!=null&&t!=null){return this.computeLineElementPositions(l.create(t))}else{return{}}}computeReplaceElementPositions(){if(this.internalCamera!=null){const t=this.model.getMeasurement();const e=t!=null?this.computeLineElementPositions(l.create(t)):{};const i=this.indicatorPt!=null?{indicatorPt:this.viewport.transformWorldToViewport(this.indicatorPt,this.internalCamera.projectionViewMatrix)}:{};return{...e,...i}}else{return{}}}computeLineElementPositions(t){if(this.internalCamera!=null){return E(t,this.interactingAnchor,{viewport:this.viewport,camera:this.internalCamera})}else{return{}}}updateCamera(){var t,e;this.internalCamera=this.camera||((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.scene.camera)}async updateDepthBuffer(){var t,e;this.stateMap.depthBuffer=await((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.depthBuffer())}updateViewport(){const t=I(this.hostEl);this.viewport=new g(t.width,t.height);this.elementBounds=t}updatePropsFromJson(){var t,e;this.start=K((t=this.startJson)!==null&&t!==void 0?t:this.start);this.end=K((e=this.endJson)!==null&&e!==void 0?e:this.end)}updateInteractionModel(){this.model.setMeasurementFromValues(this.start,this.end,!this.invalid)}invalidateState(){this.invalidateStateCounter=this.invalidateStateCounter+1}async addInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();if(this.mode==="replace"){e.addEventListener("pointermove",this.updateStartAnchor);e.addEventListener("pointerdown",this.newMeasurement);e.addEventListener("pointerleave",this.clearIndicator)}}async removeInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();e.removeEventListener("pointermove",this.updateStartAnchor);e.removeEventListener("pointerdown",this.newMeasurement);e.removeEventListener("pointerleave",this.clearIndicator)}handleEditAnchor(t){if(this.mode==="edit"||this.mode==="replace"){const e=this.createInteractionMoveHandler();const i=async t=>{var n;const s=this.getHitProvider();if(s!=null){window.removeEventListener("pointermove",e);window.removeEventListener("pointerup",i);const r=u(t,this.elementBounds);const a=this.snapPoint(r,t);await((n=this.interaction)===null||n===void 0?void 0:n.finish(a,s));this.updateMeasurementPropsFromModel();this.endEditing()}};return async n=>{await this.getStencilBuffer();if(n.button===0){this.beginEditing("edit",t);this.interaction=this.controller.editMeasurement(t);window.addEventListener("pointermove",e);window.addEventListener("pointerup",i)}}}}createInteractionMoveHandler(){return async t=>{var e;const i=this.getHitProvider();if(this.elementBounds!=null&&i!=null){t.preventDefault();await this.getStencilBuffer();const n=u(t,this.elementBounds);const s=this.snapPoint(n,t);(e=this.interaction)===null||e===void 0?void 0:e.update(s,i);this.updateMeasurementPropsFromModel()}}}async getStencilBuffer(){var t;const e=await((t=this.viewer)===null||t===void 0?void 0:t.stencilBuffer.latestAfterInteraction());this.stateMap.stencil=e}snapPoint(t,e){const i=this.getHitProvider();if(i!=null&&!e.shiftKey){const e=Math.max(0,this.snapDistance);return i.hitTester().snapToNearestPixel(t,e)}return t}formatDistance(t){const e=t!=null?this.measurementUnits.convertWorldValueToReal(t):undefined;if(this.labelFormatter!=null){return this.labelFormatter(e)}else{const t=this.measurementUnits.unit.abbreviatedName;return e==null?"---":`~${e.toFixed(this.fractionalDigits)} ${t}`}}beginEditing(t,e){if(this.interactionCount===0){this.interactingAnchor=e;this.editBegin.emit({type:t,anchor:e})}this.interactionCount=this.interactionCount+1}endEditing(){if(this.interactionCount===1){const t=this.model.getMeasurement();this.interactingAnchor="none";this.updateMeasurementModel();if(t!=null){this.editEnd.emit(t)}}this.interactionCount=this.interactionCount-1}updateMeasurementModel(){this.measurementModel.clearOutcome();if(!this.invalid&&this.start!=null&&this.end!=null){this.measurementModel.setOutcome({isApproximate:true,results:[f(this.start,this.end)]})}}getHitProvider(){if(this.hitProvider==null){const t=this.getHitTester();const e=this.viewer;if(e!=null&&t!=null){return{hitTester:()=>t,raycaster:async()=>(await e.scene()).raycaster()}}}else return this.hitProvider}getHitTester(){const{stencil:t,depthBuffer:e}=this.stateMap;if(e!=null){return new D(t,e,this.viewport,this.internalCamera)}}updateMeasurementPropsFromModel(){const t=this.model.getMeasurement();this.start=t===null||t===void 0?void 0:t.start;this.end=t===null||t===void 0?void 0:t.end;this.distance=t===null||t===void 0?void 0:t.distance;this.invalid=t!=null&&!t.valid}async updateIndicator(t){var e;const i=this.getHitProvider();const n=i==null||!this.controller.moveIndicator(t,i);if(n){(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose()}else{await this.setCursor(d)}}setDepthBuffers(){if(this.mode!=null&&this.viewer!=null&&this.viewer.depthBuffers==null){this.stateMap.shouldClearDepthBuffers=true;this.viewer.depthBuffers="final"}}resetDepthBuffers(){if(this.stateMap.shouldClearDepthBuffers&&this.viewer!=null){this.viewer.depthBuffers=undefined;this.stateMap.shouldClearDepthBuffers=undefined}}get hostEl(){return this}static get watchers(){return{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:1}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}}static get style(){return F()}},[1,"vertex-viewer-measurement-distance",{start:[1040],startJson:[1,"start-json"],end:[1040],endJson:[1,"end-json"],distance:[1026],showAxisReferenceLines:[4,"show-axis-reference-lines"],snapDistance:[2,"snap-distance"],units:[1],fractionalDigits:[2,"fractional-digits"],labelFormatter:[16],anchorLabelOffset:[2,"anchor-label-offset"],lineCapLength:[2,"line-cap-length"],mode:[513],interactingAnchor:[1537,"interacting-anchor"],invalid:[1540],camera:[16],hitProvider:[16],indicatorPt:[1040],viewer:[16],measurementModel:[16],viewport:[32],elementBounds:[32],interactionCount:[32],internalCamera:[32],invalidateStateCounter:[32],stateMap:[32],measurementUnits:[32],computeElementMetrics:[64]},undefined,{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:1}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}]);function K(t){return typeof t==="string"?a.fromJson(t):t}function R(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-distance","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-distance":if(!customElements.get(e(t))){customElements.define(e(t),J)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){M()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){C()}break}}))}R();const W=J;const X=R;export{W as VertexViewerMeasurementDistance,X as defineCustomElement};
|
|
4
|
+
import{h as t,t as e,p as i,H as n,d as s,e as r}from"./p-Bb32XUUS.js";import{v as a,a as o,p as h,l}from"./p-B8a9KIE8.js";import{m as d}from"./p-DIaJIPQu.js";import{b as c,g as u}from"./p-CpvtUGnF.js";import"./p-CkYfi_b3.js";import"./p-FRKLa468.js";import"./p-ux1ckSDN.js";import"./p-B4qVkXXt.js";import{o as m,D as v}from"./p-CNDZjNd7.js";import{M as p}from"./p-DAU4efKm.js";import{M as w}from"./p-2lW8AfSs.js";import{m as f}from"./p-EHuPJ1mC.js";import{V as g}from"./p-D3hmsz_I.js";import{E as b,m as y}from"./p-IVh_3-KN.js";import{d as C,g as E}from"./p-XydgrVf-.js";import{c as P}from"./p-C6gMOKYg.js";import{d as M}from"./p-CaMZxfAH.js";const x=16;const k=10;function D(t){return t.getBoundingClientRect()}class I{constructor(t,e,i,n){this.stencil=t;this.depthBuffer=e;this.viewport=i;this.camera=n}hitTest(t){const e=this.viewport.transformPointToFrame(t,this.depthBuffer);if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);return this.stencil.hitTest(i)||this.depthBuffer.hitTest(e)}else{return this.depthBuffer.hitTest(e)}}snapToNearestPixel(t,e){if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);const n=this.stencil.snapToNearestPixel(i,e);return this.viewport.transformPointToViewport(n,this.stencil)}else{return t}}transformPointToWorld(t,{ignoreHitTest:e=false}={}){const i=this.pickDepthBuffer(t);if(i!=null){return this.viewport.transformPointToWorldSpace(t,i)}else if(e){return this.viewport.transformPointToWorldSpace(t,this.depthBuffer)}}pickDepthBuffer(t){if(this.stencil!=null){const e=this.viewport.transformPointToFrame(t,this.stencil);if(this.stencil.hitTest(e)){return this.stencil.depthBuffer}}const e=this.viewport.transformPointToFrame(t,this.depthBuffer);return this.depthBuffer.hitTest(e)?this.depthBuffer:undefined}}class j{constructor(t){this.model=t}newMeasurement(t,e){const i=e.hitTester().transformPointToWorld(t);return i!=null?new S(t,i,this.model):undefined}editMeasurement(t){const e=this.model.getMeasurement();if(e==null){throw new Error("Cannot edit measurement. Measurement is empty.")}return t==="start"?new V(e,this.model):new B(e,this.model)}clearIndicator(){this.model.setIndicator(undefined)}moveIndicator(t,e){const i=e.hitTester().transformPointToWorld(t);this.model.setIndicator(i);return i!=null}}class A{constructor(){this.measurementChanged=new b;this.indicatorChanged=new b}static empty(){return new A}getMeasurement(){return this.measurement}setMeasurement(t){if(this.measurement!==t){this.measurement=t;this.measurementChanged.emit(t)}}setMeasurementFromValues(t,e,i){if(t!=null&&e!=null){const n=i?T(t,e):O(t,e);this.setMeasurement(n)}else{this.setMeasurement(undefined)}}onMeasurementChanged(t){return this.measurementChanged.on(t)}getIndicator(){return this.indicator}setIndicator(t){if(this.indicator!==t){this.indicator=t;this.indicatorChanged.emit(t)}}onIndicatorChanged(t){return this.indicatorChanged.on(t)}}class S{constructor(t,e,i){this.pt=t;this.world=e;this.model=i;this.hitWorldValid=true;this.preventUpdate=false}fetchStartIfMissing(t){if(this.pendingStart==null){this.pendingStart=this.fetchStart(t)}}async fetchStart(t){const e=await t.raycaster();const i=await H(e,this.pt);if(i==null){const e=t.hitTester().transformPointToWorld(this.pt);this.hitWorld=e;this.hitWorldValid=false}else{this.hitWorld=i;this.hitWorldValid=true}}update(t,e){var i;if(!this.preventUpdate){this.fetchStartIfMissing(e);const n=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const s=e.hitTester().hitTest(t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;if(n==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!this.hitWorldValid||!s){this.model.setIndicator(n);this.setMeasurement(O(r,n))}else{this.model.setIndicator(n);this.setMeasurement(T(r,n))}}}async finish(t,e){var i;this.preventUpdate=true;this.fetchStartIfMissing(e);await this.pendingStart;this.model.setIndicator(undefined);const n=await e.raycaster();const s=await H(n,t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;this.preventUpdate=false;if(s==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete new measurement interaction. End point is empty.")}return this.setMeasurement(O(r,i))}else if(!this.hitWorldValid){return this.setMeasurement(O(r,s))}else{return this.setMeasurement(T(r,s))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class L{constructor(t,e){this.measurement=t;this.model=e}update(t,e){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const n=e.hitTester().hitTest(t);if(i==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!n){this.model.setIndicator(i);this.setMeasurement(this.getInvalidMeasurement(i))}else{this.model.setIndicator(i);this.setMeasurement(this.getValidMeasurement(i))}}async finish(t,e){const i=await e.raycaster();const n=await H(i,t);this.model.setIndicator(undefined);if(n==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete edit measurement interaction. End point is empty.")}return this.setMeasurement(this.getInvalidMeasurement(i))}else{return this.setMeasurement(this.getValidMeasurement(n))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class V extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return O(t,this.measurement.end)}getValidMeasurement(t){return T(t,this.measurement.end)}}class B extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return O(this.measurement.start,t)}getValidMeasurement(t){return T(this.measurement.start,t)}}async function H(t,e){var i;const n=await t.hitItems(e);const[s]=(i=n===null||n===void 0?void 0:n.hits)!==null&&i!==void 0?i:[];if((s===null||s===void 0?void 0:s.hitPoint)!=null){const t=m(s.hitPoint);if(y.isInvalid(t)){throw new Error(`Invalid hit response [${t.errors.join(",")}]`)}return t}else return undefined}function T(t,e){return{start:t,end:e,distance:a.distance(t,e),valid:true}}function O(t,e){return{start:t,end:e,valid:false}}const U=({startPt:e,endPt:i,centerPt:n,indicatorPt:s,distance:r,anchorLabelOffset:a,lineCapLength:l,linePointerEvents:d,hideStartAnchor:u,hideEndAnchor:m,onStartAnchorPointerDown:v,onEndAnchorPointerDown:p})=>{const w=e!=null&&i!=null?o.fromPoints(e,i):undefined;const f=w!=null&&e!=null&&a!=null?h.add(e,h.polar(-a,w)):undefined;const g=w!=null&&i!=null&&a!=null?h.add(i,h.polar(a,w)):undefined;return t("div",null,e!=null&&i!=null&&t("vertex-viewer-measurement-line",{class:P("line",{"hide-start-line-cap":u,"hide-end-line-cap":m}),start:e,end:i,capLength:l,pointerEvents:d}),!u&&e!=null&&t("div",{id:"start-anchor",class:"anchor anchor-start",style:{transform:c(e)},onPointerDown:v},t("slot",{name:"start-anchor"},t("div",{class:"anchor-placeholder"}))),!u&&f&&t("div",{class:"anchor-label anchor-label-start",style:{transform:c(f)}},t("slot",{name:"start-label"})),!m&&i!=null&&t("div",{id:"end-anchor",class:"anchor anchor-end",style:{transform:c(i)},onPointerDown:p},t("slot",{name:"end-anchor"},t("div",{class:"anchor-placeholder"}))),!m&&g&&t("div",{class:"anchor-label anchor-label-end",style:{transform:c(g)}},t("slot",{name:"end-label"})),n!=null&&t("div",{id:"label",class:"distance-label",style:{transform:c(n)}},r),s!=null&&t("div",{class:"indicator",style:{transform:c(s)}},t("slot",{name:"indicator"},t("div",{class:"indicator-placeholder"}))))};const F=()=>`:host{--viewer-measurement-distance-accent-color:var(--neutral-900);--viewer-measurement-distance-contrast-color:var(--white);--viewer-measurement-distance-invalid-accent-color:var(--red-600);--viewer-measurement-distance-invalid-contrast-color:var(--white);--viewer-measurement-distance-line-stroke-width:1.25px;--viewer-measurement-distance-line-fill-width:2px;--viewer-measurement-distance-distance-border:1px solid var(--viewer-measurement-distance-accent-color);--viewer-measurement-distance-distance-border-radius:0.25rem;--viewer-measurement-distance-distance-padding:0.375rem 0.5rem;color:var(--viewer-measurement-distance-accent-color);font-size:0.75rem;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}:host([invalid]:not([invalid='false'])){--viewer-measurement-distance-accent-color:var( --viewer-measurement-distance-invalid-accent-color ) !important;--viewer-measurement-distance-contrast-color:var( --viewer-measurement-distance-invalid-contrast-color ) !important}.line{--viewer-measurement-line-stroke:var( --viewer-measurement-distance-contrast-color );--viewer-measurement-line-stroke-opacity:0.75;--viewer-measurement-line-stroke-width:var( --viewer-measurement-distance-line-stroke-width );--viewer-measurement-line-fill:var( --viewer-measurement-distance-accent-color );--viewer-measurement-line-fill-width:var( --viewer-measurement-distance-line-fill-width );position:absolute;width:100%;height:100%}.anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host([interacting-anchor='start']) .anchor-start,:host([interacting-anchor='start']) .anchor-label-start{visibility:hidden}.hide-start-line-cap,:host([interacting-anchor='start']) .line{--viewer-measurement-line-start-cap-visibility:hidden}:host([interacting-anchor='end']) .anchor-end,:host([interacting-anchor='end']) .anchor-label-end{visibility:hidden}.hide-end-line-cap,:host([interacting-anchor='end']) .line{--viewer-measurement-line-end-cap-visibility:hidden}.anchor-label{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host(:not([mode=''])){cursor:inherit}:host(:not([mode=''])) .anchor{cursor:move}:host([mode='']) .anchor{visibility:hidden}.anchor-placeholder{background:var(--viewer-measurement-distance-contrast-color);width:12px;height:12px;border-radius:50%;box-sizing:border-box}:host(:not([mode=''])) .anchor-placeholder{border:2px solid var(--viewer-measurement-distance-accent-color);background:var(--viewer-measurement-distance-contrast-color)}:host([mode='']) .distance-label{color:var(--viewer-measurement-distance-contrast-color);background:var(--viewer-measurement-distance-accent-color)}.distance-label{position:absolute;background:var(--viewer-measurement-distance-contrast-color);border:var(--viewer-measurement-distance-distance-border);border-radius:var(--viewer-measurement-distance-distance-border-radius);padding:var(--viewer-measurement-distance-distance-padding);pointer-events:auto}.indicator{position:absolute}.indicator-placeholder{background:var(--viewer-measurement-distance-accent-color);border:1px solid var(--viewer-measurement-distance-contrast-color);width:6px;height:6px;border-radius:50%;box-sizing:border-box}`;const z=3;const J=i(class e extends n{constructor(t){super();if(t!==false){this.__registerHost()}this.__attachShadow();this.editBegin=s(this,"editBegin");this.editEnd=s(this,"editEnd");this.showAxisReferenceLines=false;this.snapDistance=x;this.units="millimeters";this.fractionalDigits=2;this.anchorLabelOffset=20;this.lineCapLength=k;this.mode="";this.interactingAnchor="none";this.invalid=false;this.measurementModel=new p;this.viewport=new g(0,0);this.interactionCount=0;this.invalidateStateCounter=0;this.stateMap={};this.measurementUnits=new v(this.units);this.model=A.empty();this.controller=new j(this.model);this.overlays=new w;this.isUserInteractingWithModel=false;this.handleFrameDrawn=()=>{this.invalidateState()};this.clearIndicator=()=>{this.controller.clearIndicator()};this.updateStartAnchor=async t=>{await this.getStencilBuffer();if(this.interactionCount===0){const e=u(t,this.elementBounds);const i=this.snapPoint(e,t);await this.updateIndicator(i)}};this.newMeasurement=t=>{if(this.interactionCount===0&&t.button===0){const e=t=>{const e=()=>{window.removeEventListener("pointerup",i);window.removeEventListener("pointermove",n)};const i=async()=>{e();t()};const n=t=>{if(t.buttons>0){e()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",i)};const i=t=>{let e=h.create(0,0);const i=i=>{const n=h.distance(e,u(i,this.elementBounds));if(n>=z){t()}};const n=()=>{window.removeEventListener("pointermove",i);window.removeEventListener("pointerup",s)};const s=()=>n();const r=t=>{e=u(t,this.elementBounds);window.addEventListener("pointermove",i);window.addEventListener("pointerup",s)};window.addEventListener("pointerdown",r);return{dispose:()=>window.removeEventListener("pointerdown",r)}};const n=()=>{const t=i((()=>{var t;this.isUserInteractingWithModel=true;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}));const e=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",s);t.dispose()};const n=this.createInteractionMoveHandler();const s=async t=>{var i;if(t.button===0){if(this.isUserInteractingWithModel){this.isUserInteractingWithModel=false}else{const n=this.getHitProvider();if(n!=null){const s=u(t,this.elementBounds);const r=this.snapPoint(s,t);await((i=this.interaction)===null||i===void 0?void 0:i.finish(r,n));e();this.updateMeasurementPropsFromModel();this.endEditing()}}}};this.beginEditing("replace","end");this.newInteractionHandler={dispose:e};window.addEventListener("pointermove",n);window.addEventListener("pointerup",s)};const s=this.getHitProvider();if(s!=null){const i=u(t,this.elementBounds);const r=this.snapPoint(i,t);this.interaction=this.controller.newMeasurement(r,s);if(this.interaction!=null){e(n)}}}}}async computeElementMetrics(){var t,e,i;const n=(t=this.hostEl.shadowRoot)===null||t===void 0?void 0:t.getElementById("start-anchor");const s=(e=this.hostEl.shadowRoot)===null||e===void 0?void 0:e.getElementById("end-anchor");const r=(i=this.hostEl.shadowRoot)===null||i===void 0?void 0:i.getElementById("label");if(n!=null&&s!=null&&r!=null){return{startAnchor:n.getBoundingClientRect(),endAnchor:s.getBoundingClientRect(),label:r.getBoundingClientRect()}}else{return undefined}}connectedCallback(){this.setDepthBuffers()}disconnectedCallback(){var t,e;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose();(e=this.newInteractionHandler)===null||e===void 0?void 0:e.dispose();this.resetDepthBuffers()}async componentWillLoad(){this.updatePropsFromJson();this.model.setMeasurementFromValues(this.start,this.end,!this.invalid);await this.getStencilBuffer();this.updateViewport();this.setDepthBuffers();await this.handleViewerChanged(this.viewer);await this.handleModeChanged();await this.computePropsAndState();this.model.onIndicatorChanged((t=>{this.indicatorPt=t}))}componentDidLoad(){const t=new ResizeObserver((()=>this.updateViewport()));t.observe(this.hostEl)}async componentWillUpdate(){await this.computePropsAndState()}render(){return t(r,{key:"58113224139c37a54bf9329ed27e6a8983d5cccd"},this.showAxisReferenceLines&&t("vertex-viewer-measurement-overlays",{key:"d2166c4a965761f472f5b3323844d82980baa29f",measurementOverlays:this.overlays,viewer:this.viewer}),this.renderMeasurement())}renderMeasurement(){const e=this.computeElementPositions();const{startPt:i,endPt:n,labelPt:s,indicatorPt:r,hideStart:a,hideEnd:o}=e;const h=this.formatDistance(this.distance);if(this.mode==="edit"||this.mode==="replace"){return t(U,{startPt:i,endPt:n,centerPt:s,indicatorPt:r,distance:h,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,hideStartAnchor:a,hideEndAnchor:o,onStartAnchorPointerDown:this.handleEditAnchor("start"),onEndAnchorPointerDown:this.handleEditAnchor("end")})}else{return t(U,{startPt:i,endPt:n,centerPt:s,indicatorPt:this.indicatorPt,distance:h,hideStartAnchor:a,hideEndAnchor:o,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,linePointerEvents:"painted"})}}async handleViewerChanged(t,e){if(e!=null){e.removeEventListener("frameDrawn",this.handleFrameDrawn);await this.removeInteractionListeners(e)}if(t!=null){t.addEventListener("frameDrawn",this.handleFrameDrawn);await this.addInteractionListeners(t)}}handleUnitsChanged(){this.measurementUnits=new v(this.units)}handleCameraChanged(){this.updateCamera()}async handleModeChanged(){var t;if(this.mode===""){(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}if(this.viewer!=null){await this.removeInteractionListeners(this.viewer);await this.addInteractionListeners(this.viewer)}}handleStartChanged(){this.updateInteractionModel()}handleEndChanged(){this.updateInteractionModel()}handleInvalidChanged(){this.updateInteractionModel()}async computePropsAndState(){this.updateCamera();await this.updateDepthBuffer();this.updateMeasurementPropsFromModel();this.updateOverlays()}updateOverlays(){var t;(t=this.overlay)===null||t===void 0?void 0:t.dispose();if(this.showAxisReferenceLines&&this.interactionCount===0&&!this.invalid&&this.start!=null&&this.end!=null){this.overlay=this.overlays.addDistanceVector(this.start,this.end)}}async setCursor(t){var e,i;(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose();if(!this.isUserInteractingWithModel){this.stateMap.hoverCursor=await((i=this.viewer)===null||i===void 0?void 0:i.addCursor(t))}}computeElementPositions(){if(this.mode==="replace"){return this.computeReplaceElementPositions()}else{return this.computeEditOrViewElementPositions()}}computeEditOrViewElementPositions(){const t=this.model.getMeasurement();if(this.internalCamera!=null&&t!=null){return this.computeLineElementPositions(l.create(t))}else{return{}}}computeReplaceElementPositions(){if(this.internalCamera!=null){const t=this.model.getMeasurement();const e=t!=null?this.computeLineElementPositions(l.create(t)):{};const i=this.indicatorPt!=null?{indicatorPt:this.viewport.transformWorldToViewport(this.indicatorPt,this.internalCamera.projectionViewMatrix)}:{};return{...e,...i}}else{return{}}}computeLineElementPositions(t){if(this.internalCamera!=null){return E(t,this.interactingAnchor,{viewport:this.viewport,camera:this.internalCamera})}else{return{}}}updateCamera(){var t,e;this.internalCamera=this.camera||((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.scene.camera)}async updateDepthBuffer(){var t,e;this.stateMap.depthBuffer=await((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.depthBuffer())}updateViewport(){const t=D(this.hostEl);this.viewport=new g(t.width,t.height);this.elementBounds=t}updatePropsFromJson(){var t,e;this.start=K((t=this.startJson)!==null&&t!==void 0?t:this.start);this.end=K((e=this.endJson)!==null&&e!==void 0?e:this.end)}updateInteractionModel(){this.model.setMeasurementFromValues(this.start,this.end,!this.invalid)}invalidateState(){this.invalidateStateCounter=this.invalidateStateCounter+1}async addInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();if(this.mode==="replace"){e.addEventListener("pointermove",this.updateStartAnchor);e.addEventListener("pointerdown",this.newMeasurement);e.addEventListener("pointerleave",this.clearIndicator)}}async removeInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();e.removeEventListener("pointermove",this.updateStartAnchor);e.removeEventListener("pointerdown",this.newMeasurement);e.removeEventListener("pointerleave",this.clearIndicator)}handleEditAnchor(t){if(this.mode==="edit"||this.mode==="replace"){const e=this.createInteractionMoveHandler();const i=async t=>{var n;const s=this.getHitProvider();if(s!=null){window.removeEventListener("pointermove",e);window.removeEventListener("pointerup",i);const r=u(t,this.elementBounds);const a=this.snapPoint(r,t);await((n=this.interaction)===null||n===void 0?void 0:n.finish(a,s));this.updateMeasurementPropsFromModel();this.endEditing()}};return async n=>{await this.getStencilBuffer();if(n.button===0){this.beginEditing("edit",t);this.interaction=this.controller.editMeasurement(t);window.addEventListener("pointermove",e);window.addEventListener("pointerup",i)}}}}createInteractionMoveHandler(){return async t=>{var e;const i=this.getHitProvider();if(this.elementBounds!=null&&i!=null){t.preventDefault();await this.getStencilBuffer();const n=u(t,this.elementBounds);const s=this.snapPoint(n,t);(e=this.interaction)===null||e===void 0?void 0:e.update(s,i);this.updateMeasurementPropsFromModel()}}}async getStencilBuffer(){var t;const e=await((t=this.viewer)===null||t===void 0?void 0:t.stencilBuffer.latestAfterInteraction());this.stateMap.stencil=e}snapPoint(t,e){const i=this.getHitProvider();if(i!=null&&!e.shiftKey){const e=Math.max(0,this.snapDistance);return i.hitTester().snapToNearestPixel(t,e)}return t}formatDistance(t){const e=t!=null?this.measurementUnits.convertWorldValueToReal(t):undefined;if(this.labelFormatter!=null){return this.labelFormatter(e)}else{const t=this.measurementUnits.unit.abbreviatedName;return e==null?"---":`~${e.toFixed(this.fractionalDigits)} ${t}`}}beginEditing(t,e){if(this.interactionCount===0){this.interactingAnchor=e;this.editBegin.emit({type:t,anchor:e})}this.interactionCount=this.interactionCount+1}endEditing(){if(this.interactionCount===1){const t=this.model.getMeasurement();this.interactingAnchor="none";this.updateMeasurementModel();if(t!=null){this.editEnd.emit(t)}}this.interactionCount=this.interactionCount-1}updateMeasurementModel(){this.measurementModel.clearOutcome();if(!this.invalid&&this.start!=null&&this.end!=null){this.measurementModel.setOutcome({isApproximate:true,results:[f(this.start,this.end)]})}}getHitProvider(){if(this.hitProvider==null){const t=this.getHitTester();const e=this.viewer;if(e!=null&&t!=null){return{hitTester:()=>t,raycaster:async()=>(await e.scene()).raycaster()}}}else return this.hitProvider}getHitTester(){const{stencil:t,depthBuffer:e}=this.stateMap;if(e!=null){return new I(t,e,this.viewport,this.internalCamera)}}updateMeasurementPropsFromModel(){const t=this.model.getMeasurement();this.start=t===null||t===void 0?void 0:t.start;this.end=t===null||t===void 0?void 0:t.end;this.distance=t===null||t===void 0?void 0:t.distance;this.invalid=t!=null&&!t.valid}async updateIndicator(t){var e;const i=this.getHitProvider();const n=i==null||!this.controller.moveIndicator(t,i);if(n){(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose()}else{await this.setCursor(d)}}setDepthBuffers(){if(this.mode!=null&&this.viewer!=null&&this.viewer.depthBuffers==null){this.stateMap.shouldClearDepthBuffers=true;this.viewer.depthBuffers="final"}}resetDepthBuffers(){if(this.stateMap.shouldClearDepthBuffers&&this.viewer!=null){this.viewer.depthBuffers=undefined;this.stateMap.shouldClearDepthBuffers=undefined}}get hostEl(){return this}static get watchers(){return{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:1}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}}static get style(){return F()}},[1,"vertex-viewer-measurement-distance",{start:[1040],startJson:[1,"start-json"],end:[1040],endJson:[1,"end-json"],distance:[1026],showAxisReferenceLines:[4,"show-axis-reference-lines"],snapDistance:[2,"snap-distance"],units:[1],fractionalDigits:[2,"fractional-digits"],labelFormatter:[16],anchorLabelOffset:[2,"anchor-label-offset"],lineCapLength:[2,"line-cap-length"],mode:[513],interactingAnchor:[1537,"interacting-anchor"],invalid:[1540],camera:[16],hitProvider:[16],indicatorPt:[1040],viewer:[16],measurementModel:[16],viewport:[32],elementBounds:[32],interactionCount:[32],internalCamera:[32],invalidateStateCounter:[32],stateMap:[32],measurementUnits:[32],computeElementMetrics:[64]},undefined,{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:1}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}]);function K(t){return typeof t==="string"?a.fromJson(t):t}function N(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-distance","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-distance":if(!customElements.get(e(t))){customElements.define(e(t),J)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){M()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){C()}break}}))}N();const R=J;const W=N;export{R as VertexViewerMeasurementDistance,W as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-measurement-distance.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{V as o,d as s}from"./p-
|
|
4
|
+
import{V as o,d as s}from"./p-XydgrVf-.js";const r=o;const t=s;export{r as VertexViewerMeasurementOverlays,t as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-measurement-overlays.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{t as e,p as t,H as s,h as i,e as n}from"./p-Bb32XUUS.js";import{s as r}from"./p-B2_E6tqs.js";import{p as a}from"./p-
|
|
4
|
+
import{t as e,p as t,H as s,h as i,e as n}from"./p-Bb32XUUS.js";import{s as r}from"./p-B2_E6tqs.js";import{p as a}from"./p-sPEu8FHr.js";import{a as o,M as l}from"./p-IbLMJcql.js";import"./p-B4qVkXXt.js";import"./p-CkYfi_b3.js";import"./p-FRKLa468.js";import{E as h}from"./p-CNDZjNd7.js";import{M as d}from"./p-DAU4efKm.js";import{M as m}from"./p-2lW8AfSs.js";import{p as u}from"./p-B8a9KIE8.js";import{a as p}from"./p-DIaJIPQu.js";import{g as c}from"./p-CpvtUGnF.js";import{E as v}from"./p-CFus3r7d.js";import{d as f}from"./p-CaMZxfAH.js";import{d as w}from"./p-XydgrVf-.js";class y{get elementRect(){return this.rectObserver.rect}constructor(e,t){this.rectObserver=new v;this.handlePointerMove=async e=>{if(await this.isMeasurableEntityUnderPointer(e)){this.clearCursor();this.addCursor(p)}else{this.clearCursor()}};this.handlePointerDown=e=>{this.ifNoInteraction(e,(async()=>{if(await this.isMeasurableEntityUnderPointer(e)){this.measureEntityUnderPointer(e)}else{await this.controller.clearEntities()}}))};this.controller=e;this.measurableEntityTypes=t}initialize(e,t){this.element=e;this.api=t;this.rectObserver.observe(e);e.addEventListener("pointermove",this.handlePointerMove);e.addEventListener("pointerdown",this.handlePointerDown)}dispose(){var e,t,s;this.rectObserver.disconnect();(e=this.measurementInteraction)===null||e===void 0?void 0:e.dispose();this.clearCursor();(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointermove",this.handlePointerMove);(s=this.element)===null||s===void 0?void 0:s.removeEventListener("pointerdown",this.handlePointerDown);this.element=undefined;this.api=undefined}addCursor(e){this.cursor=this.ifInitialized((({api:t})=>t.addCursor(e)))}clearCursor(){var e;(e=this.cursor)===null||e===void 0?void 0:e.dispose();this.cursor=undefined}async isMeasurableEntityUnderPointer(e){var t;const s=c(e,this.elementRect);const i=await((t=this.api)===null||t===void 0?void 0:t.getEntityTypeAtPoint(s));return i!=null&&this.measurableEntityTypes.includes(i)}measureEntityUnderPointer(e){this.ifInitialized((async({api:t})=>{const s=c(e,this.elementRect);const[i]=await t.hitItems(s);const n=i!=null?o.fromHit(i):undefined;if(n!=null){await this.controller.addEntity(n)}else{await this.controller.clearEntities()}}))}ifInitialized(e){if(this.element!=null&&this.api!=null){return e({element:this.element,api:this.api})}else{throw new Error("Measurement interaction handler not initialized.")}}ifNoInteraction(e,t){const s=u.create(e.clientX,e.clientY);let i=false;const n=e=>{const t=u.create(e.clientX,e.clientY);const n=u.distance(s,t);i=n>2};const r=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",r);if(!i){t()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",r)}}const C=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}`;const b=t(class e extends s{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.measurementModel=new d;this.measurementOverlays=new m;this.measurableEntityTypes=[h.PRECISE_SURFACE,h.IMPRECISE_SURFACE];this.configEnv="platprod"}connectedCallback(){this.setupInteractionHandler()}componentWillLoad(){this.setupController();this.setupInteractionHandler()}disconnectedCallback(){this.clearInteractionHandler()}handleMeasurableEntityTypesChanged(){this.setupInteractionHandler()}handleMeasurementControllerChanged(){this.setupInteractionHandler()}handleMeasurementModelChanged(){this.setupController()}handleViewerChanged(){this.setupInteractionHandler()}render(){return i(n,{key:"191b29e7710d24dc5462b10bf5fc947de5facf6c"},i("vertex-viewer-measurement-overlays",{key:"9da7740e1f54c300f6a76a7dc516054e40bbed05",viewer:this.viewer,measurementOverlays:this.measurementOverlays}))}setupController(){var e;const t=a(this.configEnv,this.config);const s=new r.SceneViewAPIClient(t.network.sceneViewHost);this.measurementController=new l(this.measurementModel,s,(()=>{var e;return(e=this.viewer)===null||e===void 0?void 0:e.token}),(e=this.viewer)===null||e===void 0?void 0:e.deviceId)}clearInteractionHandler(){var e;(e=this.registeredInteractionHandler)===null||e===void 0?void 0:e.then((e=>e.dispose()));this.registeredInteractionHandler=undefined}setupInteractionHandler(){var e;this.clearInteractionHandler();if(this.measurementController!=null){this.registeredInteractionHandler=(e=this.viewer)===null||e===void 0?void 0:e.registerInteractionHandler(new y(this.measurementController,this.measurableEntityTypes))}}static get watchers(){return{measurableEntityTypes:[{handleMeasurableEntityTypesChanged:0}],measurementController:[{handleMeasurementControllerChanged:0}],measurementModel:[{handleMeasurementModelChanged:1}],viewer:[{handleViewerChanged:0}]}}static get style(){return C()}},[1,"vertex-viewer-measurement-precise",{measurementModel:[16],measurementOverlays:[16],measurementController:[1040],measurableEntityTypes:[16],viewer:[16],configEnv:[1,"config-env"],config:[1]},undefined,{measurableEntityTypes:[{handleMeasurableEntityTypesChanged:0}],measurementController:[{handleMeasurementControllerChanged:0}],measurementModel:[{handleMeasurementModelChanged:1}],viewer:[{handleViewerChanged:0}]}]);function M(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-precise","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-precise":if(!customElements.get(e(t))){customElements.define(e(t),b)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){f()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){w()}break}}))}M();const g=b;const E=M;export{g as VertexViewerMeasurementPrecise,E as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-measurement-precise.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{V as
|
|
4
|
+
import{V as s,d as o}from"./p-Dks3EzBM.js";const t=s;const p=o;export{t as VertexViewerPinGroup,p as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-pin-group.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{t as i,p as t,H as e,h as s,e as n}from"./p-Bb32XUUS.js";import{a as o,d as l,P as r}from"./p-D6cvvwQH.js";import{p as h}from"./p-B8a9KIE8.js";import{b as d}from"./p-IVh_3-KN.js";import{l as a,p as u}from"./p-DIaJIPQu.js";import{g as v}from"./p-CpvtUGnF.js";import{E as c}from"./p-CFus3r7d.js";import{E as p}from"./p-Be_EPOMu.js";import{P as f}from"./p-hMVkLxR1.js";import{g as m}from"./p-Bg-uS9BH.js";import{d as w}from"./p-D76H_kzM.js";import{d as C}from"./p-Cta7kB-G.js";import{d as b}from"./p-Bkm6H5uq.js";import{d as y}from"./p-BQQxciHe.js";import{d as g}from"./p-Dqy4SWfO.js";class x{get elementRect(){return this.rectObserver.rect}constructor(i,t,e){this.rectObserver=new c;this.droppableSurfaces=[p.PRECISE_SURFACE,p.IMPRECISE_SURFACE,p.GENERIC_GEOMETRY];this.handlePointerMove=async i=>{const t=await this.isDroppableSurface(i);const e=this.controller.getDraggable();if(e!=null&&t){this.handleDrag(e,i)}if(this.controller.getDraggable()==null&&this.controller.getToolMode()==="edit"&&t){this.addCursor(this.getCursorType())}else{this.clearCursor()}};this.handleDrag=async(i,t)=>{const e=v(t,this.elementRect);const s=await this.getWorldPositionForPoint(e);if(s!=null){this.controller.updateDraggable({...i,lastPoint:e},s)}};this.handlePointerDown=async i=>{const t=t=>{const s=h.distance(h.create(i.clientX,t.clientY),h.create(t.clientX,t.clientY));if(s<=2&&i.buttons!==2){if(this.controller.getToolMode()==="edit"){const t=v(i,this.elementRect);this.handlePlacePin(t)}}e()};const e=()=>{window.removeEventListener("pointerup",t)};window.addEventListener("pointerup",t);return{dispose:e}};this.handlePointerUp=async()=>{const i=this.controller.getDraggable();const t=i===null||i===void 0?void 0:i.lastPoint;this.controller.setDraggable(undefined);if(t!=null&&i!=null){this.ifInitialized((async({api:e})=>{var s,n,o,l,r,h;const[d]=await e.hitItems(t);if((d===null||d===void 0?void 0:d.hitPoint)!=null&&((s=d===null||d===void 0?void 0:d.hitPoint)===null||s===void 0?void 0:s.x)!=null&&((n=d===null||d===void 0?void 0:d.hitPoint)===null||n===void 0?void 0:n.y)!=null&&((o=d===null||d===void 0?void 0:d.hitPoint)===null||o===void 0?void 0:o.z)!=null){this.controller.updateDraggable({...i,lastPoint:t},{x:(l=d===null||d===void 0?void 0:d.hitPoint)===null||l===void 0?void 0:l.x,y:d===null||d===void 0?void 0:d.hitPoint.y,z:d===null||d===void 0?void 0:d.hitPoint.z},(h=(r=d===null||d===void 0?void 0:d.partId)===null||r===void 0?void 0:r.hex)!==null&&h!==void 0?h:undefined)}}))}};this.controller=i;this.xOffset=t;this.yOffset=e}initialize(i,t){this.element=i;this.api=t;this.rectObserver.observe(i);i.addEventListener("pointermove",this.handlePointerMove);i.addEventListener("pointerdown",this.handlePointerDown);window.addEventListener("pointerup",this.handlePointerUp)}dispose(){var i,t;this.rectObserver.disconnect();this.clearCursor();(i=this.element)===null||i===void 0?void 0:i.removeEventListener("pointermove",this.handlePointerMove);(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointerdown",this.handlePointerDown);window.removeEventListener("pointerup",this.handlePointerUp);this.element=undefined;this.api=undefined}async getWorldPositionForPoint(i){return this.ifInitialized((async({api:t})=>{const e=await t.getWorldPointFromViewport(i);return e}))}async handlePlacePin(i,t){this.ifInitialized((async({api:e})=>{var s,n,l,r,h,a;const[u]=await e.hitItems(i);if((u===null||u===void 0?void 0:u.hitPoint)!=null&&this.elementRect!=null){if((u===null||u===void 0?void 0:u.hitPoint)!=null&&(u===null||u===void 0?void 0:u.hitPoint.x)!=null&&(u===null||u===void 0?void 0:u.hitPoint.y)!=null&&(u===null||u===void 0?void 0:u.hitPoint.z)!=null){const e=t!=null?t.id:d.create();const v=this.controller.getStyleAttributes()!=null?{style:this.controller.getStyleAttributes()}:undefined;switch(this.controller.getToolType()){case"pin-icon":this.controller.setPin({type:"icon",id:e,worldPosition:{x:(s=u===null||u===void 0?void 0:u.hitPoint)===null||s===void 0?void 0:s.x,y:u===null||u===void 0?void 0:u.hitPoint.y,z:u===null||u===void 0?void 0:u.hitPoint.z},partId:(l=(n=u===null||u===void 0?void 0:u.itemId)===null||n===void 0?void 0:n.hex)!==null&&l!==void 0?l:undefined,attributes:v});break;case"pin-text":const d=t==null;const c=o(i,this.elementRect,d,this.xOffset,this.yOffset);this.controller.setPin({type:"text",id:e,worldPosition:{x:(r=u===null||u===void 0?void 0:u.hitPoint)===null||r===void 0?void 0:r.x,y:u===null||u===void 0?void 0:u.hitPoint.y,z:u===null||u===void 0?void 0:u.hitPoint.z},partId:(a=(h=u===null||u===void 0?void 0:u.itemId)===null||h===void 0?void 0:h.hex)!==null&&a!==void 0?a:undefined,label:{point:c},attributes:v});this.controller.setSelectedPinId(e);break}}}else{this.controller.setSelectedPinId()}}))}getCursorType(){switch(this.controller.getToolType()){case"pin-icon":return u;case"pin-text":return a}}addCursor(i){this.clearCursor();this.cursor=this.ifInitialized((({api:t})=>t.addCursor(i)))}async isDroppableSurface(i){var t;const e=v(i,this.elementRect);const s=await((t=this.api)===null||t===void 0?void 0:t.getEntityTypeAtPoint(e));return s!=null&&this.droppableSurfaces.includes(s)}ifInitialized(i){if(this.element!=null&&this.api!=null){return i({element:this.element,api:this.api})}else{throw new Error("Pins interaction handler not initialized.")}}clearCursor(){var i;(i=this.cursor)===null||i===void 0?void 0:i.dispose();this.cursor=undefined}}const P=()=>`:host{position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none;--viewer-pin-tool-initial-label-offset-x:20;--viewer-pin-tool-initial-label-offset-y:20}`;const j=t(class i extends e{constructor(i){super();if(i!==false){this.__registerHost()}this.__attachShadow();this.pinModel=new f;this.tool="pin-icon";this.mode="view";this.pins=[];this.stateMap={};this.handleSetProjectionMatrix=()=>{var i,t;this.projectionViewMatrix=(t=(i=this.viewer)===null||i===void 0?void 0:i.frame)===null||t===void 0?void 0:t.scene.camera.projectionViewMatrix}}watchModeChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setToolMode(this.mode);this.setupInteractionHandler();if(this.mode==="edit"){this.setFeatureMaps();this.setCameraAndKeyboardControls()}else{this.resetFeatureMaps();this.resetCameraAndKeyboardControls()}}watchTypeChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setToolType(this.tool);this.setupInteractionHandler()}watchAccentColorChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setAccentColor(this.accentColor);this.setupInteractionHandler()}watchPrimaryColorChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setPrimaryColor(this.primaryColor);this.setupInteractionHandler()}watchPinsChange(){if(this.pins.length>0){this.setDepthBuffers();this.setFeatureMaps()}else{this.resetDepthBuffers();this.resetFeatureMaps()}}connectedCallback(){this.setupInteractionHandler();this.setDepthBuffers();this.setFeatureMaps();this.setCameraAndKeyboardControls()}componentWillLoad(){this.updateViewport();this.setupController();this.setupInteractionHandler();this.setDepthBuffers();this.setFeatureMaps();this.setCameraAndKeyboardControls();this.pinModel.onEntitiesChanged((i=>{this.pins=i}));this.pinModel.onSelectionChange((i=>{this.selectedPinId=i}));this.handleViewerChanged(this.viewer,undefined)}componentDidLoad(){this.resizeObserver=new ResizeObserver((()=>this.updateViewport()));this.resizeObserver.observe(this.hostEl)}disconnectedCallback(){this.clearInteractionHandler();this.clearModelListeners();this.resetDepthBuffers();this.resetFeatureMaps();this.resetCameraAndKeyboardControls()}handleViewerChanged(i,t){this.setupInteractionHandler();this.setDepthBuffers();this.setFeatureMaps();this.setCameraAndKeyboardControls();if(t!=null){t.removeEventListener("frameDrawn",this.handleSetProjectionMatrix)}if(i!=null){i.addEventListener("frameDrawn",this.handleSetProjectionMatrix)}this.handleSetProjectionMatrix()}render(){return s(n,{key:"ce2867d4a624dabf607b9de837e73a0a0c40eaf9"},s("vertex-viewer-dom-renderer",{key:"7d2dc3d75ca1818ba7b9b292ccbe1db7ac5c7ac8",viewer:this.viewer,drawMode:"2d"},this.pins.map((i=>s("vertex-viewer-pin-group",{id:`pin-group-${i.id}`,"data-is-dom-group-element":true,pin:i,elementBounds:this.elementBounds,pinModel:this.pinModel,pinController:this.pinController,projectionViewMatrix:this.projectionViewMatrix,selected:this.selectedPinId===i.id})))))}setupController(){const i=this.accentColor||this.primaryColor?{accentColor:this.accentColor,primaryColor:this.primaryColor}:undefined;this.pinController=new r(this.pinModel,this.mode,this.tool,i)}clearInteractionHandler(){var i;(i=this.registeredInteractionHandler)===null||i===void 0?void 0:i.then((i=>i.dispose()));this.registeredInteractionHandler=undefined}setupInteractionHandler(){var i;const t=window.getComputedStyle(this.hostEl);const e=t.getPropertyValue("--viewer-pin-tool-initial-label-offset-x").trim();const s=Number.isFinite(Number.parseInt(e))?Number.parseInt(e):20;const n=t.getPropertyValue("--viewer-pin-tool-initial-label-offset-y").trim();const o=Number.isFinite(Number.parseInt(n))?Number.parseInt(n):20;this.clearInteractionHandler();if(this.pinController!=null){this.registeredInteractionHandler=(i=this.viewer)===null||i===void 0?void 0:i.registerInteractionHandler(new x(this.pinController,s,o))}}clearModelListeners(){var i,t,e;(i=this.onEntitiesChangedHandler)===null||i===void 0?void 0:i.dispose();this.onEntitiesChangedHandler=undefined;(t=this.onEntityAddedHandler)===null||t===void 0?void 0:t.dispose();this.onEntityAddedHandler=undefined;(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect()}updateViewport(){this.elementBounds=m(this.hostEl)}setDepthBuffers(){if(this.pins.length>0&&this.viewer!=null&&this.viewer.depthBuffers==null){this.stateMap.shouldClearDepthBuffers=true;this.viewer.depthBuffers="final"}}resetDepthBuffers(){if(this.stateMap.shouldClearDepthBuffers&&this.viewer!=null){this.viewer.depthBuffers=undefined;this.stateMap.shouldClearDepthBuffers=undefined}}setFeatureMaps(){if((this.pins.length>0||this.mode==="edit")&&this.viewer!=null&&this.viewer.featureMaps==null){this.stateMap.shouldClearFeatureMaps=true;this.viewer.featureMaps="final"}}resetFeatureMaps(){if(this.stateMap.shouldClearFeatureMaps&&this.viewer!=null){this.viewer.featureMaps=undefined;this.stateMap.shouldClearFeatureMaps=undefined}}setCameraAndKeyboardControls(){if(this.mode==="edit"&&this.viewer!=null){if(this.viewer.cameraControls){this.stateMap.shouldClearCameraControls=true;this.viewer.cameraControls=false}if(this.viewer.keyboardControls){this.stateMap.shouldClearKeyboardControls=true;this.viewer.keyboardControls=false}}}resetCameraAndKeyboardControls(){if(this.viewer!=null){if(this.stateMap.shouldClearCameraControls){this.viewer.cameraControls=true;this.stateMap.shouldClearCameraControls=undefined}if(this.stateMap.shouldClearKeyboardControls){this.viewer.keyboardControls=true;this.stateMap.shouldClearKeyboardControls=undefined}}}get hostEl(){return this}static get watchers(){return{mode:[{watchModeChange:0}],tool:[{watchTypeChange:0}],accentColor:[{watchAccentColorChange:0}],primaryColor:[{watchPrimaryColorChange:0}],pins:[{watchPinsChange:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return P()}},[1,"vertex-viewer-pin-tool",{pinController:[1040],pinModel:[16],viewer:[16],tool:[1025],mode:[1025],primaryColor:[1025,"primary-color"],accentColor:[1025,"accent-color"],pins:[32],selectedPinId:[32],elementBounds:[32],projectionViewMatrix:[32]},undefined,{mode:[{watchModeChange:0}],tool:[{watchTypeChange:0}],accentColor:[{watchAccentColorChange:0}],primaryColor:[{watchPrimaryColorChange:0}],pins:[{watchPinsChange:0}],viewer:[{handleViewerChanged:0}]}]);function k(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-pin-tool","vertex-viewer-dom-element","vertex-viewer-dom-renderer","vertex-viewer-icon","vertex-viewer-pin-group","vertex-viewer-pin-label","vertex-viewer-pin-label-line"];t.forEach((t=>{switch(t){case"vertex-viewer-pin-tool":if(!customElements.get(i(t))){customElements.define(i(t),j)}break;case"vertex-viewer-dom-element":if(!customElements.get(i(t))){w()}break;case"vertex-viewer-dom-renderer":if(!customElements.get(i(t))){C()}break;case"vertex-viewer-icon":if(!customElements.get(i(t))){b()}break;case"vertex-viewer-pin-group":if(!customElements.get(i(t))){y()}break;case"vertex-viewer-pin-label":if(!customElements.get(i(t))){l()}break;case"vertex-viewer-pin-label-line":if(!customElements.get(i(t))){g()}break}}))}k();const E=j;const M=k;export{E as VertexViewerPinTool,M as defineCustomElement};
|
|
4
|
+
import{t as i,p as t,H as e,h as s,e as n}from"./p-Bb32XUUS.js";import{a as o,d as l,P as r}from"./p-D6cvvwQH.js";import{p as h}from"./p-B8a9KIE8.js";import{b as d}from"./p-IVh_3-KN.js";import{l as a,p as u}from"./p-DIaJIPQu.js";import{g as v}from"./p-CpvtUGnF.js";import{E as c}from"./p-CFus3r7d.js";import{E as p}from"./p-CNDZjNd7.js";import{P as f}from"./p-hMVkLxR1.js";import{g as m}from"./p-Bg-uS9BH.js";import{d as w}from"./p-D76H_kzM.js";import{d as C}from"./p-ZzS5zTnx.js";import{d as b}from"./p-Bkm6H5uq.js";import{d as y}from"./p-Dks3EzBM.js";import{d as g}from"./p-Dqy4SWfO.js";class x{get elementRect(){return this.rectObserver.rect}constructor(i,t,e){this.rectObserver=new c;this.droppableSurfaces=[p.PRECISE_SURFACE,p.IMPRECISE_SURFACE,p.GENERIC_GEOMETRY];this.handlePointerMove=async i=>{const t=await this.isDroppableSurface(i);const e=this.controller.getDraggable();if(e!=null&&t){this.handleDrag(e,i)}if(this.controller.getDraggable()==null&&this.controller.getToolMode()==="edit"&&t){this.addCursor(this.getCursorType())}else{this.clearCursor()}};this.handleDrag=async(i,t)=>{const e=v(t,this.elementRect);const s=await this.getWorldPositionForPoint(e);if(s!=null){this.controller.updateDraggable({...i,lastPoint:e},s)}};this.handlePointerDown=async i=>{const t=t=>{const s=h.distance(h.create(i.clientX,t.clientY),h.create(t.clientX,t.clientY));if(s<=2&&i.buttons!==2){if(this.controller.getToolMode()==="edit"){const t=v(i,this.elementRect);this.handlePlacePin(t)}}e()};const e=()=>{window.removeEventListener("pointerup",t)};window.addEventListener("pointerup",t);return{dispose:e}};this.handlePointerUp=async()=>{const i=this.controller.getDraggable();const t=i===null||i===void 0?void 0:i.lastPoint;this.controller.setDraggable(undefined);if(t!=null&&i!=null){this.ifInitialized((async({api:e})=>{var s,n,o,l,r,h;const[d]=await e.hitItems(t);if((d===null||d===void 0?void 0:d.hitPoint)!=null&&((s=d===null||d===void 0?void 0:d.hitPoint)===null||s===void 0?void 0:s.x)!=null&&((n=d===null||d===void 0?void 0:d.hitPoint)===null||n===void 0?void 0:n.y)!=null&&((o=d===null||d===void 0?void 0:d.hitPoint)===null||o===void 0?void 0:o.z)!=null){this.controller.updateDraggable({...i,lastPoint:t},{x:(l=d===null||d===void 0?void 0:d.hitPoint)===null||l===void 0?void 0:l.x,y:d===null||d===void 0?void 0:d.hitPoint.y,z:d===null||d===void 0?void 0:d.hitPoint.z},(h=(r=d===null||d===void 0?void 0:d.partId)===null||r===void 0?void 0:r.hex)!==null&&h!==void 0?h:undefined)}}))}};this.controller=i;this.xOffset=t;this.yOffset=e}initialize(i,t){this.element=i;this.api=t;this.rectObserver.observe(i);i.addEventListener("pointermove",this.handlePointerMove);i.addEventListener("pointerdown",this.handlePointerDown);window.addEventListener("pointerup",this.handlePointerUp)}dispose(){var i,t;this.rectObserver.disconnect();this.clearCursor();(i=this.element)===null||i===void 0?void 0:i.removeEventListener("pointermove",this.handlePointerMove);(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointerdown",this.handlePointerDown);window.removeEventListener("pointerup",this.handlePointerUp);this.element=undefined;this.api=undefined}async getWorldPositionForPoint(i){return this.ifInitialized((async({api:t})=>{const e=await t.getWorldPointFromViewport(i);return e}))}async handlePlacePin(i,t){this.ifInitialized((async({api:e})=>{var s,n,l,r,h,a;const[u]=await e.hitItems(i);if((u===null||u===void 0?void 0:u.hitPoint)!=null&&this.elementRect!=null){if((u===null||u===void 0?void 0:u.hitPoint)!=null&&(u===null||u===void 0?void 0:u.hitPoint.x)!=null&&(u===null||u===void 0?void 0:u.hitPoint.y)!=null&&(u===null||u===void 0?void 0:u.hitPoint.z)!=null){const e=t!=null?t.id:d.create();const v=this.controller.getStyleAttributes()!=null?{style:this.controller.getStyleAttributes()}:undefined;switch(this.controller.getToolType()){case"pin-icon":this.controller.setPin({type:"icon",id:e,worldPosition:{x:(s=u===null||u===void 0?void 0:u.hitPoint)===null||s===void 0?void 0:s.x,y:u===null||u===void 0?void 0:u.hitPoint.y,z:u===null||u===void 0?void 0:u.hitPoint.z},partId:(l=(n=u===null||u===void 0?void 0:u.itemId)===null||n===void 0?void 0:n.hex)!==null&&l!==void 0?l:undefined,attributes:v});break;case"pin-text":const d=t==null;const c=o(i,this.elementRect,d,this.xOffset,this.yOffset);this.controller.setPin({type:"text",id:e,worldPosition:{x:(r=u===null||u===void 0?void 0:u.hitPoint)===null||r===void 0?void 0:r.x,y:u===null||u===void 0?void 0:u.hitPoint.y,z:u===null||u===void 0?void 0:u.hitPoint.z},partId:(a=(h=u===null||u===void 0?void 0:u.itemId)===null||h===void 0?void 0:h.hex)!==null&&a!==void 0?a:undefined,label:{point:c},attributes:v});this.controller.setSelectedPinId(e);break}}}else{this.controller.setSelectedPinId()}}))}getCursorType(){switch(this.controller.getToolType()){case"pin-icon":return u;case"pin-text":return a}}addCursor(i){this.clearCursor();this.cursor=this.ifInitialized((({api:t})=>t.addCursor(i)))}async isDroppableSurface(i){var t;const e=v(i,this.elementRect);const s=await((t=this.api)===null||t===void 0?void 0:t.getEntityTypeAtPoint(e));return s!=null&&this.droppableSurfaces.includes(s)}ifInitialized(i){if(this.element!=null&&this.api!=null){return i({element:this.element,api:this.api})}else{throw new Error("Pins interaction handler not initialized.")}}clearCursor(){var i;(i=this.cursor)===null||i===void 0?void 0:i.dispose();this.cursor=undefined}}const P=()=>`:host{position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none;--viewer-pin-tool-initial-label-offset-x:20;--viewer-pin-tool-initial-label-offset-y:20}`;const j=t(class i extends e{constructor(i){super();if(i!==false){this.__registerHost()}this.__attachShadow();this.pinModel=new f;this.tool="pin-icon";this.mode="view";this.pins=[];this.stateMap={};this.handleSetProjectionMatrix=()=>{var i,t;this.projectionViewMatrix=(t=(i=this.viewer)===null||i===void 0?void 0:i.frame)===null||t===void 0?void 0:t.scene.camera.projectionViewMatrix}}watchModeChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setToolMode(this.mode);this.setupInteractionHandler();if(this.mode==="edit"){this.setFeatureMaps();this.setCameraAndKeyboardControls()}else{this.resetFeatureMaps();this.resetCameraAndKeyboardControls()}}watchTypeChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setToolType(this.tool);this.setupInteractionHandler()}watchAccentColorChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setAccentColor(this.accentColor);this.setupInteractionHandler()}watchPrimaryColorChange(){var i;(i=this.pinController)===null||i===void 0?void 0:i.setPrimaryColor(this.primaryColor);this.setupInteractionHandler()}watchPinsChange(){if(this.pins.length>0){this.setDepthBuffers();this.setFeatureMaps()}else{this.resetDepthBuffers();this.resetFeatureMaps()}}connectedCallback(){this.setupInteractionHandler();this.setDepthBuffers();this.setFeatureMaps();this.setCameraAndKeyboardControls()}componentWillLoad(){this.updateViewport();this.setupController();this.setupInteractionHandler();this.setDepthBuffers();this.setFeatureMaps();this.setCameraAndKeyboardControls();this.pinModel.onEntitiesChanged((i=>{this.pins=i}));this.pinModel.onSelectionChange((i=>{this.selectedPinId=i}));this.handleViewerChanged(this.viewer,undefined)}componentDidLoad(){this.resizeObserver=new ResizeObserver((()=>this.updateViewport()));this.resizeObserver.observe(this.hostEl)}disconnectedCallback(){this.clearInteractionHandler();this.clearModelListeners();this.resetDepthBuffers();this.resetFeatureMaps();this.resetCameraAndKeyboardControls()}handleViewerChanged(i,t){this.setupInteractionHandler();this.setDepthBuffers();this.setFeatureMaps();this.setCameraAndKeyboardControls();if(t!=null){t.removeEventListener("frameDrawn",this.handleSetProjectionMatrix)}if(i!=null){i.addEventListener("frameDrawn",this.handleSetProjectionMatrix)}this.handleSetProjectionMatrix()}render(){return s(n,{key:"ce2867d4a624dabf607b9de837e73a0a0c40eaf9"},s("vertex-viewer-dom-renderer",{key:"7d2dc3d75ca1818ba7b9b292ccbe1db7ac5c7ac8",viewer:this.viewer,drawMode:"2d"},this.pins.map((i=>s("vertex-viewer-pin-group",{id:`pin-group-${i.id}`,"data-is-dom-group-element":true,pin:i,elementBounds:this.elementBounds,pinModel:this.pinModel,pinController:this.pinController,projectionViewMatrix:this.projectionViewMatrix,selected:this.selectedPinId===i.id})))))}setupController(){const i=this.accentColor||this.primaryColor?{accentColor:this.accentColor,primaryColor:this.primaryColor}:undefined;this.pinController=new r(this.pinModel,this.mode,this.tool,i)}clearInteractionHandler(){var i;(i=this.registeredInteractionHandler)===null||i===void 0?void 0:i.then((i=>i.dispose()));this.registeredInteractionHandler=undefined}setupInteractionHandler(){var i;const t=window.getComputedStyle(this.hostEl);const e=t.getPropertyValue("--viewer-pin-tool-initial-label-offset-x").trim();const s=Number.isFinite(Number.parseInt(e))?Number.parseInt(e):20;const n=t.getPropertyValue("--viewer-pin-tool-initial-label-offset-y").trim();const o=Number.isFinite(Number.parseInt(n))?Number.parseInt(n):20;this.clearInteractionHandler();if(this.pinController!=null){this.registeredInteractionHandler=(i=this.viewer)===null||i===void 0?void 0:i.registerInteractionHandler(new x(this.pinController,s,o))}}clearModelListeners(){var i,t,e;(i=this.onEntitiesChangedHandler)===null||i===void 0?void 0:i.dispose();this.onEntitiesChangedHandler=undefined;(t=this.onEntityAddedHandler)===null||t===void 0?void 0:t.dispose();this.onEntityAddedHandler=undefined;(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect()}updateViewport(){this.elementBounds=m(this.hostEl)}setDepthBuffers(){if(this.pins.length>0&&this.viewer!=null&&this.viewer.depthBuffers==null){this.stateMap.shouldClearDepthBuffers=true;this.viewer.depthBuffers="final"}}resetDepthBuffers(){if(this.stateMap.shouldClearDepthBuffers&&this.viewer!=null){this.viewer.depthBuffers=undefined;this.stateMap.shouldClearDepthBuffers=undefined}}setFeatureMaps(){if((this.pins.length>0||this.mode==="edit")&&this.viewer!=null&&this.viewer.featureMaps==null){this.stateMap.shouldClearFeatureMaps=true;this.viewer.featureMaps="final"}}resetFeatureMaps(){if(this.stateMap.shouldClearFeatureMaps&&this.viewer!=null){this.viewer.featureMaps=undefined;this.stateMap.shouldClearFeatureMaps=undefined}}setCameraAndKeyboardControls(){if(this.mode==="edit"&&this.viewer!=null){if(this.viewer.cameraControls){this.stateMap.shouldClearCameraControls=true;this.viewer.cameraControls=false}if(this.viewer.keyboardControls){this.stateMap.shouldClearKeyboardControls=true;this.viewer.keyboardControls=false}}}resetCameraAndKeyboardControls(){if(this.viewer!=null){if(this.stateMap.shouldClearCameraControls){this.viewer.cameraControls=true;this.stateMap.shouldClearCameraControls=undefined}if(this.stateMap.shouldClearKeyboardControls){this.viewer.keyboardControls=true;this.stateMap.shouldClearKeyboardControls=undefined}}}get hostEl(){return this}static get watchers(){return{mode:[{watchModeChange:0}],tool:[{watchTypeChange:0}],accentColor:[{watchAccentColorChange:0}],primaryColor:[{watchPrimaryColorChange:0}],pins:[{watchPinsChange:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return P()}},[1,"vertex-viewer-pin-tool",{pinController:[1040],pinModel:[16],viewer:[16],tool:[1025],mode:[1025],primaryColor:[1025,"primary-color"],accentColor:[1025,"accent-color"],pins:[32],selectedPinId:[32],elementBounds:[32],projectionViewMatrix:[32]},undefined,{mode:[{watchModeChange:0}],tool:[{watchTypeChange:0}],accentColor:[{watchAccentColorChange:0}],primaryColor:[{watchPrimaryColorChange:0}],pins:[{watchPinsChange:0}],viewer:[{handleViewerChanged:0}]}]);function k(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-pin-tool","vertex-viewer-dom-element","vertex-viewer-dom-renderer","vertex-viewer-icon","vertex-viewer-pin-group","vertex-viewer-pin-label","vertex-viewer-pin-label-line"];t.forEach((t=>{switch(t){case"vertex-viewer-pin-tool":if(!customElements.get(i(t))){customElements.define(i(t),j)}break;case"vertex-viewer-dom-element":if(!customElements.get(i(t))){w()}break;case"vertex-viewer-dom-renderer":if(!customElements.get(i(t))){C()}break;case"vertex-viewer-icon":if(!customElements.get(i(t))){b()}break;case"vertex-viewer-pin-group":if(!customElements.get(i(t))){y()}break;case"vertex-viewer-pin-label":if(!customElements.get(i(t))){l()}break;case"vertex-viewer-pin-label-line":if(!customElements.get(i(t))){g()}break}}))}k();const E=j;const M=k;export{E as VertexViewerPinTool,M as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-pin-tool.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{h as i,t,p as s,H as n,d as o,e as l}from"./p-Bb32XUUS.js";import{p as e,v as h,r as a,b as r,a as d,m as u,h as v,g as c,q as f,e as w,c as p}from"./p-B8a9KIE8.js";import{c as g}from"./p-C6gMOKYg.js";import{w as x,r as y}from"./p-Cd7kap5W.js";import{T as b}from"./p-IU78UvWI.js";import{A as m,D as z}from"./p-Be_EPOMu.js";import{E as T}from"./p-IVh_3-KN.js";import{d as D,T as C,R,e as P,r as E,s as S,x as I,A,b as U,y as N,z as H,f as O,g as F,h as M,i as k,j as $}from"./p-BNanw3eX.js";function j(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function B(i,t){return t!=null?e.create(i.x-t.left,i.y-t.top):undefined}function _(i,t,s,n){const o=n!=null?h.fromMatrixPosition(n):undefined;if(i!=null&&t!=null&&s!=null&&o!=null){const n=s.transformPointToRay(i,t.image,t.scene.camera);if(t.scene.camera.isOrthographic()){const i=a.at(a.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return a.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return a.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function K(i,t,s,n,o,l){return u.multiply(X(t,s,n,o,l),i)}function X(i,t,s,n,o){const l=new z(n);const e=new m(o);const a=()=>e.convertFrom(t-s);const r=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return u.makeTranslation(h.create(r(),0,0));case"y-translate":return u.makeTranslation(h.create(0,r(),0));case"z-translate":return u.makeTranslation(h.create(0,0,r()));case"x-rotate":return u.transpose(u.makeRotation(f.fromAxisAngle(h.left(),a())));case"y-rotate":return u.transpose(u.makeRotation(f.fromAxisAngle(h.down(),a())));case"z-rotate":return u.transpose(u.makeRotation(f.fromAxisAngle(h.forward(),a())));default:return u.makeIdentity()}}function q(i){switch(i){case"x-rotate":return"xyz";case"y-rotate":return"yzx";case"z-rotate":return"zxy";default:return"xyz"}}function J(i,t,s,n,o){const l=new z(n);const e=new m(o);const a=()=>u.makeRotation(f.fromMatrixRotation(t));const r=()=>u.multiply(u.invert(s),t);const c=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(r()),a());const w=()=>v.fromRotationMatrix(u.multiply(s,a()),q(i));switch(i){case"x-translate":return l.convertWorldValueToReal(c().x);case"y-translate":return l.convertWorldValueToReal(c().y);case"z-translate":return l.convertWorldValueToReal(c().z);case"x-rotate":return e.convertTo(d.normalizeRadians(w().x));case"y-rotate":return e.convertTo(d.normalizeRadians(w().y));case"z-rotate":return e.convertTo(d.normalizeRadians(w().z));default:return 0}}function L(i,t,s,n,o,l){return V(i,h.subtract(s,t),n,o,l)}function V(i,t,s,n,o){switch(o){case"x-translate":return Z(i,t,h.right());case"y-translate":return Z(i,t,h.up());case"z-translate":return Z(i,t,h.back());case"xy-translate":return G(i,t,h.create(0,0,1));case"xz-translate":return G(i,t,h.create(0,1,0));case"yz-translate":return G(i,t,h.create(1,0,0));case"x-rotate":return Y(i,s,h.right(),n);case"y-rotate":return Y(i,s,h.up(),n);case"z-rotate":return Y(i,s,h.forward(),n);default:return i}}function Y(i,t,s,n){const o=W(i,t,s);const l=f.fromAxisAngle(o,n);const e=u.transpose(u.makeRotation(l));return u.multiply(e,i)}function W(i,t,s){const n=u.makeRotation(f.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function Z(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const a=u.makeTranslation(e);return u.multiply(i,a)}function G(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const d=r.projectPoint(a,t);const v=h.add(d,h.scale(a.constant,a.normal));const c=u.makeTranslation(v);return u.multiply(i,c)}function Q(i,t,s){if(s.length===0){throw new Error("Unable to compute input position. At least one shape point must be provided.")}const n=c.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const l=c.topLeft(n);const h=e.add(l,e.create(n.width,0));const a=c.bottomRight(n);const r=e.subtract(a,e.create(n.width,0));const d=e.scale(o.reduce(((i,t)=>e.add(i,t)),e.create()),1/o.length,1/o.length);const u=[h,r,a].reduce(((i,t)=>e.distance(d,t)<e.distance(d,i)?t:i),l);switch(u){case l:return{point:u,placement:"top-left"};case h:return{point:u,placement:"top-right"};case r:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function ii(i,t,s,n,o,l){const e=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(e&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=d.toDegrees(i);const e=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=e-t;const h=d.toRadians(s);return h+n}else{const i=d.toRadians(e);return i+n}}else{return s}}const ti=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:e},h)=>{const a=oi(n,s!==null&&s!==void 0?s:w.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...a,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},h,i("div",{class:"widget-input units"},e.unit.abbreviatedName))};const si=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:e,onBlur:h,onUndo:a})=>{const r=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){e===null||e===void 0?void 0:e()}else if(i.key==="z"&&t&&a){i.preventDefault();a()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:r,onKeyDown:d,onBlur:h})};function ni(i,t){return Math.min(i,Math.max(0,t))}function oi(i,t,s,n,o=5){const{width:l,height:e}=i.dimensions;const h=t.width+o;const a=t.height+o;function r(i){return`${i}px`}switch(n){case"top-left":return{right:r(ni(l-h,l-s.x)),bottom:r(ni(e-a,e-s.y))};case"top-right":return{left:r(ni(l-h,s.x)),bottom:r(ni(e-a,e-s.y))};case"bottom-left":return{right:r(ni(l-h,l-s.x)),top:r(ni(e-a,s.y))};case"bottom-right":default:return{left:r(ni(l-h,s.x)),top:r(ni(e-a,s.y))}}}function li(i,t,s=3,n=1,o=1){return ai(i,t,h.back(),h.up(),s,n,o)}function ei(i,t,s=3,n=1,o=1){return ai(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ai(i,t,h.right(),h.up(),s,n,o)}function ai(i,t,s,n,o,l=1,e=1){const r=h.multiplyByTransformMatrixRowMajor(h.add(s,n),u.makeRotation(f.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,u.makeRotation(f.fromMatrixRotation(i)));const c=h.multiplyByTransformMatrixRowMajor(n,u.makeRotation(f.fromMatrixRotation(i)));const w=10*e**.25;const p=h.fromMatrixPosition(i);const g=h.add(p,h.scale(o*w,r));const x=a.create({origin:g,direction:v});const y=a.create({origin:g,direction:c});const b=h.cross(v,c);const m=h.rotateAboutAxis(d.toRadians(45),a.at(y,-(o*l)),b,g);const z=h.rotateAboutAxis(d.toRadians(45),a.at(x,o*l),b,g);const T=h.rotateAboutAxis(d.toRadians(45),a.at(y,o*l),b,g);const C=h.rotateAboutAxis(d.toRadians(45),a.at(x,-(o*l)),b,g);return new D(h.dot(v,t.direction)!==-1&&h.dot(c,t.direction)!==-1,m,C,z,T,h.multiplyByTransformMatrixColumnMajor(m,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(T,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return di(i,t,s,n)}return false}function di(i,t,s,n){return ui([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||ui([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function ui(i,t,s,n){var o;if(i.length===3){const l=s.transformPointToRay(n,t.image,t.scene.camera);const e=h.subtract(i[1],i[0]);const a=h.subtract(i[2],i[0]);const r=p.epsilon((o=p.fromVectors([l.direction,l.origin,e,a]))!==null&&o!==void 0?o:p.create(e,a));const d=h.cross(l.direction,a);const u=h.dot(e,d);if(!(Math.abs(u)>=r)){return false}const v=h.subtract(l.origin,i[0]);const c=h.dot(v,d)/u;if(c<0||c>1){return false}const f=h.cross(v,e);const w=h.dot(l.direction,f)/u;if(w<0||c+w>1){return false}const g=h.dot(a,f)/u;return!Number.isNaN(g)&&(g>0||t.scene.camera.isOrthographic())}return false}class vi extends R{constructor(i,t={},s={}){var n,o,l,e,h,a,r,d,u,v,c,f,w,p;super(i);this.customization=t;this.disabledAxis={xTranslation:false,yTranslation:false,zTranslation:false,xyTranslation:false,xzTranslation:false,yzTranslation:false,xRotation:false,yRotation:false,zRotation:false};this.axisLines=[];this.rotationLines=[];this.translationMeshes=[];this.rotationMeshes=[];this.hoveredChanged=new T;this.xArrowFillColor=(n=t.colors)===null||n===void 0?void 0:n.xArrow;this.yArrowFillColor=(o=t.colors)===null||o===void 0?void 0:o.yArrow;this.zArrowFillColor=(l=t.colors)===null||l===void 0?void 0:l.zArrow;this.hoveredArrowFillColor=(e=t.colors)===null||e===void 0?void 0:e.hovered;this.outlineColor=(h=t.colors)===null||h===void 0?void 0:h.outline;this.disabledAxis.xTranslation=(a=s.xTranslation)!==null&&a!==void 0?a:false;this.disabledAxis.yTranslation=(r=s.yTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.zTranslation=(d=s.zTranslation)!==null&&d!==void 0?d:false;this.disabledAxis.xyTranslation=(u=s.xyTranslation)!==null&&u!==void 0?u:false;this.disabledAxis.xzTranslation=(v=s.xzTranslation)!==null&&v!==void 0?v:false;this.disabledAxis.yzTranslation=(c=s.yzTranslation)!==null&&c!==void 0?c:false;this.disabledAxis.xRotation=(f=s.xRotation)!==null&&f!==void 0?f:false;this.disabledAxis.yRotation=(w=s.yRotation)!==null&&w!==void 0?w:false;this.disabledAxis.zRotation=(p=s.zRotation)!==null&&p!==void 0?p:false}dispose(){var i;(i=this.reglFrameDisposable)===null||i===void 0?void 0:i.cancel()}getDrawableElements(){return this.drawableElements}getFullBounds(){return this.fullBounds}boundsContainsPoint(i){return this.interactiveBounds!=null&&this.frame!=null&&c.containsPoints(this.interactiveBounds,i)}updateDisabledAxis(i){this.disabledAxis={...this.disabledAxis,...i};this.updateDisabledOnDrawables()}updateCursor(i){this.cursor=i;if(i!=null&&this.frame!=null){this.updateHovered()}else{this.clearHovered()}}updateTransform(i){var t;this.transform=i;if(i!=null&&this.frame!=null){this.updateAndDraw()}else{this.clear();(t=this.reglFrameDisposable)===null||t===void 0?void 0:t.cancel();this.reglFrameDisposable=undefined}}updateColors(i={}){var t,s,n,o,l,e,h,a,r,d,u,v,c,f,w,p;this.xArrowFillColor=(t=i.xArrow)!==null&&t!==void 0?t:this.xArrowFillColor;this.yArrowFillColor=(s=i.yArrow)!==null&&s!==void 0?s:this.yArrowFillColor;this.zArrowFillColor=(n=i.zArrow)!==null&&n!==void 0?n:this.zArrowFillColor;this.twoAxesSquareFillColor=(o=i.twoAxesSquare)!==null&&o!==void 0?o:this.twoAxesSquareFillColor;this.hoveredArrowFillColor=(l=i.hovered)!==null&&l!==void 0?l:this.hoveredArrowFillColor;this.outlineColor=(e=i.outline)!==null&&e!==void 0?e:this.outlineColor;(h=this.xArrow)===null||h===void 0?void 0:h.updateFillColor(this.getXTranslationColor(),true);(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor(this.getYTranslationColor(),true);(r=this.zArrow)===null||r===void 0?void 0:r.updateFillColor(this.getZTranslationColor(),true);(d=this.xRotation)===null||d===void 0?void 0:d.updateFillColor(this.getXRotationColor(),true);(u=this.yRotation)===null||u===void 0?void 0:u.updateFillColor(this.getYRotationColor(),true);(v=this.zRotation)===null||v===void 0?void 0:v.updateFillColor(this.getZRotationColor(),true);(c=this.xyTranslation)===null||c===void 0?void 0:c.updateFillColor(this.getTwoAxesTranslationColor(),true);(f=this.xzTranslation)===null||f===void 0?void 0:f.updateFillColor(this.getTwoAxesTranslationColor(),true);(w=this.yzTranslation)===null||w===void 0?void 0:w.updateFillColor(this.getTwoAxesTranslationColor(),true);(p=this.hoveredElement)===null||p===void 0?void 0:p.updateFillColor(this.hoveredArrowFillColor)}updateScalars(i){this.customization={...this.customization,scalars:i};if(this.transform!=null&&this.frame!=null){this.updateElements(this.transform,this.frame)}}onHoveredChanged(i){return this.hoveredChanged.on(i)}updateDisabledOnDrawables(){var i,t,s,n,o,l,e,h,a,r,d,u,v,c,f;(i=this.xRotation)===null||i===void 0?void 0:i.setDisabled(this.disabledAxis.xRotation);(t=this.xyRotationLine)===null||t===void 0?void 0:t.setDisabled(this.disabledAxis.xRotation);(s=this.xzRotationLine)===null||s===void 0?void 0:s.setDisabled(this.disabledAxis.xRotation);(n=this.yRotation)===null||n===void 0?void 0:n.setDisabled(this.disabledAxis.yRotation);(o=this.yzRotationLine)===null||o===void 0?void 0:o.setDisabled(this.disabledAxis.yRotation);(l=this.yxRotationLine)===null||l===void 0?void 0:l.setDisabled(this.disabledAxis.yRotation);(e=this.zRotation)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(h=this.zxRotationLine)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(a=this.zyRotationLine)===null||a===void 0?void 0:a.setDisabled(this.disabledAxis.zRotation);(r=this.xArrow)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.xTranslation);(d=this.yArrow)===null||d===void 0?void 0:d.setDisabled(this.disabledAxis.yTranslation);(u=this.zArrow)===null||u===void 0?void 0:u.setDisabled(this.disabledAxis.zTranslation);(v=this.xyTranslation)===null||v===void 0?void 0:v.setDisabled(this.disabledAxis.xyTranslation);(c=this.xzTranslation)===null||c===void 0?void 0:c.setDisabled(this.disabledAxis.xzTranslation);(f=this.yzTranslation)===null||f===void 0?void 0:f.setDisabled(this.disabledAxis.yzTranslation);this.updateColors()}updateHovered(){var i,t,s,n,o,l,e,h,a,r;const d=this.hoveredElement;const u=this.frame;if(u!=null){this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((i=>i.points.valid&&!i.isDisabled())).find((i=>this.cursor!=null?ri(i,u,this.viewport,this.cursor):false));if(this.hoveredElement!==d){this.hoveredChanged.emit(this.hoveredElement);(i=this.hoveredElement)===null||i===void 0?void 0:i.updateFillColor(this.hoveredArrowFillColor);this.clearFillColorOfPreviouslyHovered(d);if(((t=this.hoveredElement)===null||t===void 0?void 0:t.identifier)==="xy-translate"){(s=this.xArrow)===null||s===void 0?void 0:s.updateFillColor(this.hoveredArrowFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor(this.hoveredArrowFillColor)}else if(((o=this.hoveredElement)===null||o===void 0?void 0:o.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor(this.hoveredArrowFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor(this.hoveredArrowFillColor)}else if(((h=this.hoveredElement)===null||h===void 0?void 0:h.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor(this.hoveredArrowFillColor);(r=this.zArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor)}}}}clearHovered(){const i=this.hoveredElement;this.hoveredElement=undefined;if(this.hoveredElement!==i){this.hoveredChanged.emit(this.hoveredElement);this.clearFillColorOfPreviouslyHovered(i)}}clearFillColorOfPreviouslyHovered(i){var t,s,n,o,l,e,h,a,r,d,u,v;i===null||i===void 0?void 0:i.updateFillColor(i===null||i===void 0?void 0:i.initialFillColor);if((i===null||i===void 0?void 0:i.identifier)==="xy-translate"){(t=this.xArrow)===null||t===void 0?void 0:t.updateFillColor((s=this.xArrow)===null||s===void 0?void 0:s.initialFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor((o=this.yArrow)===null||o===void 0?void 0:o.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor((e=this.xArrow)===null||e===void 0?void 0:e.initialFillColor);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor((a=this.zArrow)===null||a===void 0?void 0:a.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor((d=this.yArrow)===null||d===void 0?void 0:d.initialFillColor);(u=this.zArrow)===null||u===void 0?void 0:u.updateFillColor((v=this.zArrow)===null||v===void 0?void 0:v.initialFillColor)}}hasData(){return this.transform!=null}createOrUpdateElements(){if(this.transform!=null&&this.frame!=null){if(this.xArrow==null||this.yArrow==null||this.zArrow==null){this.createElements(this.transform,this.frame)}else{this.updateElements(this.transform,this.frame)}this.interactiveBounds=P(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=P(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,a,r,d,u,v,c,f;this.reglCommand=E({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=S(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",I(i,t.scene.camera,p,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation),this.outlineColor,this.getXTranslationColor());this.xRotation=new C(w,"x-rotate",li(i,t.scene.camera,p,(n=this.customization.scalars)===null||n===void 0?void 0:n.xRotation,(o=this.customization.scalars)===null||o===void 0?void 0:o.xTranslation),this.outlineColor,this.getXRotationColor());this.xAxis=new A(w,"x-axis",U(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",N(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",ei(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(a=this.customization.scalars)===null||a===void 0?void 0:a.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new A(w,"y-axis",U(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",H(i,t.scene.camera,p,(r=this.customization.scalars)===null||r===void 0?void 0:r.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new A(w,"z-axis",U(i,t.scene.camera,this.zArrow),this.outlineColor,this.getZTranslationColor());this.zRotation=new C(w,"z-rotate",hi(i,t.scene.camera,p,(d=this.customization.scalars)===null||d===void 0?void 0:d.zRotation,(u=this.customization.scalars)===null||u===void 0?void 0:u.zTranslation),this.outlineColor,this.getZRotationColor());this.xyTranslation=new C(w,"xy-translate",O(i,t.scene.camera,p,(v=this.customization.scalars)===null||v===void 0?void 0:v.xyTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.xzTranslation=new C(w,"xz-translate",F(i,t.scene.camera,p,(c=this.customization.scalars)===null||c===void 0?void 0:c.xzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.yzTranslation=new C(w,"yz-translate",M(i,t.scene.camera,p,(f=this.customization.scalars)===null||f===void 0?void 0:f.yzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.createRotationLines(w,i,t);this.axisLines=[this.xAxis,this.yAxis,this.zAxis];this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow,this.xyTranslation,this.xzTranslation,this.yzTranslation];this.rotationMeshes=[this.xRotation,this.yRotation,this.zRotation];this.updateDisabledOnDrawables();this.availableElements=[...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes]}getXRotationColor(){return this.xArrowFillColor}getYRotationColor(){return this.yArrowFillColor}getZRotationColor(){return this.zArrowFillColor}getXTranslationColor(){return this.xArrowFillColor}getYTranslationColor(){return this.yArrowFillColor}getZTranslationColor(){return this.zArrowFillColor}getTwoAxesTranslationColor(){return this.twoAxesSquareFillColor}createRotationLines(i,t,s){var n,o,l,e,a,r;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=k(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=k(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=k(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=k(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=k(s.scene.camera,this.zRotation,(a=this.xArrow)===null||a===void 0?void 0:a.points.worldTip,d);const p=k(s.scene.camera,this.zRotation,(r=this.yArrow)===null||r===void 0?void 0:r.points.worldTip,d);if(u!=null){this.xyRotationLine=new $(i,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new $(i,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new $(i,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new $(i,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new $(i,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new $(i,"zy-rotation-line",p,this.outlineColor)}this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((i=>i!=null))}updateElements(i,t){var s,n,o,l,e,a,r,d,u,v,c,f,w,p,g,x,y,b,m,z,T,D,C,R,P,E,S,A,$,j;const B=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(I(i,t.scene.camera,B,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(U(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(li(i,t.scene.camera,B,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(N(i,t.scene.camera,B,(a=this.customization.scalars)===null||a===void 0?void 0:a.yTranslation));(r=this.yAxis)===null||r===void 0?void 0:r.updatePoints(U(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(ei(i,t.scene.camera,B,(u=this.customization.scalars)===null||u===void 0?void 0:u.yRotation,(v=this.customization.scalars)===null||v===void 0?void 0:v.yTranslation));if(this.zArrow!=null){this.zArrow.updatePoints(H(i,t.scene.camera,B,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(U(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,B,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(g=this.customization.scalars)===null||g===void 0?void 0:g.zTranslation));(x=this.xyRotationLine)===null||x===void 0?void 0:x.updatePoints(k(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,B));(b=this.xzRotationLine)===null||b===void 0?void 0:b.updatePoints(k(t.scene.camera,this.xRotation,(m=this.zArrow)===null||m===void 0?void 0:m.points.worldTip,B));(z=this.yxRotationLine)===null||z===void 0?void 0:z.updatePoints(k(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,B));(D=this.yzRotationLine)===null||D===void 0?void 0:D.updatePoints(k(t.scene.camera,this.yRotation,(C=this.zArrow)===null||C===void 0?void 0:C.points.worldTip,B));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(k(t.scene.camera,this.zRotation,(P=this.xArrow)===null||P===void 0?void 0:P.points.worldTip,B));(E=this.zyRotationLine)===null||E===void 0?void 0:E.updatePoints(k(t.scene.camera,this.zRotation,(S=this.yArrow)===null||S===void 0?void 0:S.points.worldTip,B));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(O(i,t.scene.camera,B,(A=this.customization.scalars)===null||A===void 0?void 0:A.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(F(i,t.scene.camera,B,($=this.customization.scalars)===null||$===void 0?void 0:$.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(M(i,t.scene.camera,B,(j=this.customization.scalars)===null||j===void 0?void 0:j.yzTranslation))}}}const ci=()=>`:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-transform-widget-x-axis-arrow-color:var(--x-axis-color);--viewer-transform-widget-y-axis-arrow-color:var(--y-axis-color);--viewer-transform-widget-z-axis-arrow-color:var(--z-axis-color);--viewer-transform-widget-two-axes-square-color:var(--two-axes-color);--viewer-transform-widget-hovered-arrow-color:#ffff00;--viewer-transform-widget-input-width:8em}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}.widget-input.wrapper{position:absolute;pointer-events:auto;display:flex;align-items:center;border:1px solid #444444;border-radius:4px;width:var(--viewer-transform-widget-input-width);text-align:center;background-color:white;box-sizing:border-box}.widget-input.units{position:relative;width:25%;height:100%;padding:0 0.25rem;font-size:0.8125rem;color:#444444}input.widget-input{position:relative;text-align:center;box-sizing:border-box;width:75%;height:100%;outline:none;border-width:0 1px 0 0;border-color:#444444;border-radius:2px 0 0 2px;font-size:0.875rem;color:#444444}input.widget-input.x-translate,input.widget-input.x-rotate{border-left:5px solid var(--viewer-transform-widget-x-axis-arrow-color)}input.widget-input.y-translate,input.widget-input.y-rotate{border-left:5px solid var(--viewer-transform-widget-y-axis-arrow-color)}input.widget-input.z-translate,input.widget-input.z-rotate{border-left:5px solid var(--viewer-transform-widget-z-axis-arrow-color)}input.widget-input:disabled{color:#888888}input.widget-input:focus{outline:none}`;const fi=s(class t extends n{constructor(i){super();if(i!==false){this.__registerHost()}this.__attachShadow();this.positionChanged=o(this,"positionChanged");this.rotationChanged=o(this,"rotationChanged");this.interactionEnded=o(this,"interactionEnded");this.interactionStarted=o(this,"interactionStarted");this.xRotationDisabled=false;this.yRotationDisabled=false;this.zRotationDisabled=false;this.xTranslationDisabled=false;this.yTranslationDisabled=false;this.zTranslationDisabled=false;this.xyTranslationDisabled=false;this.xzTranslationDisabled=false;this.yzTranslationDisabled=false;this.showInputs=true;this.distanceUnit="millimeters";this.angleUnit="degrees";this.decimalPlaces=1;this.rotationSnapKey="shift";this.translationHandleScalar=1;this.rotationHandleScalar=1;this.interactionThrottle=75;this.EXPERIMENTAL_undoKeybindings=false;this.inputValue=0;this.isEndingTransform=false;this.inputShouldFocus=false;this.xArrowColor="#ea3324";this.yArrowColor="#4faf32";this.zArrowColor="#0000ff";this.twoAxesSquareColor="#e0e0e0";this.hoveredColor="#ffff00";this.lastAngle=0;this.handleHoveredDrawableChanged=i=>{this.hovered=i};this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()};this.handleViewerDimensionsChange=()=>{x((()=>{if(this.viewer!=null&&this.canvasRef!=null){this.canvasRef.width=this.viewer.viewport.width;this.canvasRef.height=this.viewer.viewport.height;this.updateCanvasBounds(this.canvasRef)}}))};this.handleResize=()=>{if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef)}};this.handleInputResize=()=>{if(this.inputWrapperRef!=null){const i=this.inputWrapperRef;y((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{y((()=>{const i=window.getComputedStyle(this.hostEl);this.xArrowColor=i.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim();this.yArrowColor=i.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim();this.zArrowColor=i.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim();this.twoAxesSquareColor=i.getPropertyValue("--viewer-transform-widget-two-axes-square-color").trim();this.hoveredColor=i.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim();this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor})}))};this.handlePointerMove=i=>{if(this.dragging==null){const t=B(e.create(i.clientX,i.clientY),this.getCanvasBounds());const s=this.getTransformWidget();if(t!=null&&s.boundsContainsPoint(t)){s.updateCursor(t)}else{s.updateCursor(undefined);this.hovered=undefined}}};this.handleBeginDrag=async i=>{var t,s,n;const o=this.getCanvasBounds();if(this.hovered!=null&&o!=null&&this.viewer!=null&&this.position!=null&&this.viewer.frame!=null){this.dragging=this.hovered;if(this.dragging.identifier!==((t=this.lastDragged)===null||t===void 0?void 0:t.identifier)){this.inputValue=0;this.dragStartTransform=this.currentTransform;this.updateInputPosition();this.updateInputValue()}this.lastDragged=undefined;const l=B(e.create(i.clientX,i.clientY),o);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=l!=null?d.fromPoints(h,l):0;this.lastWorldPosition=_(l,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);this.interactionStarted.emit();window.removeEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointermove",this.handleDragWithTimer);window.addEventListener("pointerup",this.handleEndTransform)}};this.handleDragWithTimer=async i=>{if(i!=null){i.preventDefault();this.lastMouseEvent=i}if(this.interactionTimer==null){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.handleDrag();this.lastMouseEvent=undefined}),this.interactionThrottle)}};this.handleDrag=async()=>{var i,t,s;const n=this.getCanvasBounds();if(this.dragging!=null&&this.lastWorldPosition!=null&&n!=null&&this.viewer!=null&&this.viewer.frame!=null&&this.position!=null&&this.lastMouseEvent!=null){await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());const o=B(e.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const l=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const h=_(o,(t=this.viewer)===null||t===void 0?void 0:t.frame,(s=this.viewer)===null||s===void 0?void 0:s.viewport,this.currentTransform);if(h!=null&&o!=null&&l!=null){const i=d.fromPoints(l,o);const t=ii(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,h,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=h;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=B(e.create(i.clientX,i.clientY),this.getCanvasBounds());const o=this.getTransformWidget();this.lastDragged=this.dragging;this.dragging=undefined;this.lastWorldPosition=undefined;this.lastAngle=0;this.updateInputPosition();this.updateInputValue();o.updateCursor(n);o.updateTransform(this.currentTransform);this.beginEndTransform();window.removeEventListener("pointermove",this.handleDragWithTimer);window.removeEventListener("pointerup",this.handleEndTransform);try{const i=(t=this.controller)===null||t===void 0?void 0:t.getCurrentDelta();await((s=this.controller)===null||s===void 0?void 0:s.endTransform());this.interactionEnded.emit(i)}catch(i){console.error("Failed to end transform interaction",i)}window.addEventListener("pointermove",this.handlePointerMove);this.completeEndTransform()};this.handleInputStep=async i=>{if(this.inputValue!=null&&this.lastInputValue!=null){if(this.isModifyingAngleUnits()){const t=new m(this.angleUnit);const s=t.convertFrom(this.lastInputValue);const n=d.normalizeRadians(s+d.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=K(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(u.multiply(u.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new vi(i,{colors:{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor},scalars:{xTranslation:n,yTranslation:n,zTranslation:n,xyTranslation:o,xzTranslation:o,yzTranslation:o,xRotation:o,yRotation:o,zRotation:o}});if(this.rotation!=null){this.currentTransform=this.getTransformForNewRotation(this.rotation);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(this.position!=null){this.currentTransform=this.getTransformForNewPosition(this.position);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(((s=this.viewer)===null||s===void 0?void 0:s.frame)!=null){this.widget.updateFrame(this.viewer.frame,true)}this.handleSettingDisabledAxis();this.hoveredChangeDisposable=this.widget.onHoveredChanged(this.handleHoveredDrawableChanged);return this.widget};this.updateCanvasBounds=i=>{y((()=>{this.canvasBounds=i.getBoundingClientRect();this.getTransformWidget().updateDimensions(i)}))};this.updateInputValue=()=>{var i,t,s;const n=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const o=(n===null||n===void 0?void 0:n.identifier)==="xy-translate"||(n===null||n===void 0?void 0:n.identifier)==="xz-translate"||(n===null||n===void 0?void 0:n.identifier)==="yz-translate";if(n!=null&&this.currentTransform!=null&&this.dragStartTransform!=null&&!o){this.lastInputValue=this.inputValue;this.inputValue=J(n.identifier,this.currentTransform,this.dragStartTransform,this.distanceUnit,this.angleUnit);if(this.inputRef!=null){const i=(s=(t=this.getDisplayedDistance())!==null&&t!==void 0?t:this.getDisplayedAngle())!==null&&s!==void 0?s:0;const n=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Q(this.viewer.viewport,t,s.points.toArray()):undefined}else if(n){this.inputPosition=undefined}};this.beginEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:true,yRotation:true,zRotation:true,xTranslation:true,yTranslation:true,zTranslation:true,xyTranslation:true,xzTranslation:true,yzTranslation:true});this.isEndingTransform=true};this.completeEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled});this.isEndingTransform=false;this.inputShouldFocus=true;if(this.currentTransform!=null){this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=v.fromRotationMatrix(this.currentTransform)}};this.isModifyingAngleUnits=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;return!!(n===null||n===void 0?void 0:n.includes("rotate"))};this.getTranslationScalar=()=>{if(this.translationHandleScalar>0){return this.translationHandleScalar}console.warn("Invalid value provided for translation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getRotationScalar=()=>{if(this.rotationHandleScalar>0){return this.rotationHandleScalar}console.warn("Invalid value provided for rotation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getDisplayedUnits=()=>{if(this.isModifyingAngleUnits()){return new m(this.angleUnit)}return new z(this.distanceUnit)};this.getDisplayedAngle=()=>{if(this.isModifyingAngleUnits()){return this.inputValue}};this.getDisplayedDistance=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;if(n===null||n===void 0?void 0:n.includes("translate")){return this.inputValue}};this.getTransformForNewPosition=i=>{if(i!=null){const t=this.currentTransform!=null?this.currentTransform:u.makeIdentity();const s=u.transpose(u.makeRotation(f.fromMatrixRotation(t)));const n=u.makeTranslation(i);return u.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:u.makeIdentity();const s=u.makeRotation(f.fromMatrixRotation(t));const n=u.makeRotation(f.fromEuler(i));const o=u.multiply(s,t);return u.multiply(u.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){j(this.inputRef);this.inputShouldFocus=false}}async EXPERIMENTAL_undo(){var i,t;const s=await((i=this.controller)===null||i===void 0?void 0:i.EXPERIMENTAL_undoTransform());if(this.currentTransform!=null&&s!=null){this.currentTransform=u.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=v.fromRotationMatrix(this.currentTransform)}}handleViewerChanged(i,t){var s;t===null||t===void 0?void 0:t.removeEventListener("frameDrawn",this.handleViewerFrameDrawn);t===null||t===void 0?void 0:t.removeEventListener("dimensionschange",this.handleViewerDimensionsChange);i===null||i===void 0?void 0:i.addEventListener("frameDrawn",this.handleViewerFrameDrawn);i===null||i===void 0?void 0:i.addEventListener("dimensionschange",this.handleViewerDimensionsChange);if((i===null||i===void 0?void 0:i.stream)!=null){(s=this.controller)===null||s===void 0?void 0:s.dispose();this.controller=new b(i.stream)}}handleDisabledPropertyChanged(){var i;(i=this.widget)===null||i===void 0?void 0:i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}handleTransformHandleScalarChanged(){var i;const t=this.getTranslationScalar();const s=this.getRotationScalar();(i=this.widget)===null||i===void 0?void 0:i.updateScalars({xTranslation:t,yTranslation:t,zTranslation:t,xyTranslation:s,xzTranslation:s,yzTranslation:s,xRotation:s,yRotation:s,zRotation:s})}handleRotationChanged(i,t){var s;const n=i!==null&&i!==void 0?i:v.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&u.isIdentity(this.currentTransform)){this.currentTransform=undefined;this.startingTransform=this.currentTransform}(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);console.debug(`Updating widget rotation [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);this.rotationChanged.emit(i)}handlePositionChanged(i,t){var s,n;this.currentTransform=this.getTransformForNewPosition(i);this.startingTransform=this.currentTransform;console.debug(`Updating widget position [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);if(i==null){this.lastDragged=undefined;this.inputPosition=undefined;(n=this.controller)===null||n===void 0?void 0:n.clearTransform()}this.positionChanged.emit(i)}handleInputFormattingChanged(){this.updateInputValue();this.lastInputValue=this.inputValue}render(){var t,s,n,o,e,h;return i(l,{key:"fdc062cb3cafa311baca827e03a765052e1ab2c8"},i("canvas",{key:"c6c9d413e971ef3db3b3eed7e9ff6c8387fff1d1",ref:i=>{this.canvasRef=i},class:g("widget",{hovered:this.hovered!=null}),tabindex:"0",width:(t=this.viewer)===null||t===void 0?void 0:t.viewport.width,height:(s=this.viewer)===null||s===void 0?void 0:s.viewport.height,onPointerDown:this.handleBeginDrag,onKeyDown:this.handleKeyDown}),this.showInputs&&this.inputPosition&&((n=this.viewer)===null||n===void 0?void 0:n.viewport)&&i(ti,{key:"7eb3550df7db8c95f3597d1bd8d7b05c70e11696",ref:i=>{var t,s;if(i!=null){(t=this.inputResizeObserver)===null||t===void 0?void 0:t.observe(i)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputWrapperRef=i},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.placement,displayUnit:this.getDisplayedUnits()},i(si,{key:"84e2ff6825856c6d5f0ffff1771861ed6087bedb",ref:i=>{this.inputRef=i},identifier:(e=(o=this.dragging)===null||o===void 0?void 0:o.identifier)!==null&&e!==void 0?e:(h=this.lastDragged)===null||h===void 0?void 0:h.identifier,disabled:this.isEndingTransform,onChange:this.handleInputChange,onIncrement:()=>this.handleInputStep(1),onDecrement:()=>this.handleInputStep(-1),onBlur:()=>{this.inputShouldFocus=false},onUndo:this.EXPERIMENTAL_undoKeybindings?()=>this.EXPERIMENTAL_undo():undefined})))}transform(i,t,s){var n,o;if(this.position!=null&&this.startingTransform!=null&&this.currentTransform!=null&&this.dragging!=null&&this.viewer!=null&&this.viewer.frame!=null){this.currentTransform=L(this.currentTransform,i,t,(n=this.viewer)===null||n===void 0?void 0:n.frame.scene.camera.viewVector,s,this.dragging.identifier);this.getTransformWidget().updateTransform(this.currentTransform);(o=this.controller)===null||o===void 0?void 0:o.updateTransform(u.multiply(u.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return this}static get watchers(){return{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}}static get style(){return ci()}},[1,"vertex-viewer-transform-widget",{viewer:[16],position:[1040],rotation:[1040],controller:[1040],xRotationDisabled:[1028,"x-rotation-disabled"],yRotationDisabled:[1028,"y-rotation-disabled"],zRotationDisabled:[1028,"z-rotation-disabled"],xTranslationDisabled:[1028,"x-translation-disabled"],yTranslationDisabled:[1028,"y-translation-disabled"],zTranslationDisabled:[1028,"z-translation-disabled"],xyTranslationDisabled:[1028,"xy-translation-disabled"],xzTranslationDisabled:[1028,"xz-translation-disabled"],yzTranslationDisabled:[1028,"yz-translation-disabled"],showInputs:[4,"show-inputs"],distanceUnit:[1,"distance-unit"],angleUnit:[1,"angle-unit"],decimalPlaces:[2,"decimal-places"],rotationSnapDegrees:[2,"rotation-snap-degrees"],rotationSnapKey:[1,"rotation-snap-key"],translationHandleScalar:[2,"translation-handle-scalar"],rotationHandleScalar:[2,"rotation-handle-scalar"],interactionThrottle:[2,"interaction-throttle"],EXPERIMENTAL_undoKeybindings:[4,"e-x-p-e-r-i-m-e-n-t-a-l_undo-keybindings"],hovered:[1040],inputPosition:[32],inputValue:[32],isEndingTransform:[32],inputShouldFocus:[32],EXPERIMENTAL_undo:[64]},undefined,{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}]);function wi(){if(typeof customElements==="undefined"){return}const i=["vertex-viewer-transform-widget"];i.forEach((i=>{switch(i){case"vertex-viewer-transform-widget":if(!customElements.get(t(i))){customElements.define(t(i),fi)}break}}))}wi();const pi=fi;const gi=wi;export{pi as VertexViewerTransformWidget,gi as defineCustomElement};
|
|
4
|
+
import{h as i,t,p as s,H as n,d as o,e as l}from"./p-Bb32XUUS.js";import{p as e,v as h,r as a,b as r,a as d,m as u,h as v,g as c,q as f,e as w,c as p}from"./p-B8a9KIE8.js";import{c as g}from"./p-C6gMOKYg.js";import{w as x,r as y}from"./p-Cd7kap5W.js";import{T as b}from"./p-IU78UvWI.js";import{A as m,D as z}from"./p-CNDZjNd7.js";import{E as T}from"./p-IVh_3-KN.js";import{d as D,T as C,R,e as P,r as S,s as E,x as A,A as I,b as U,y as N,z as H,f as F,g as O,h as j,i as k,j as M}from"./p-C_5cRYhA.js";function $(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function _(i,t){return t!=null?e.create(i.x-t.left,i.y-t.top):undefined}function K(i,t,s,n){const o=n!=null?h.fromMatrixPosition(n):undefined;if(i!=null&&t!=null&&s!=null&&o!=null){const n=s.transformPointToRay(i,t.image,t.scene.camera);if(t.scene.camera.isOrthographic()){const i=a.at(a.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return a.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return a.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function B(i,t,s,n,o,l){return u.multiply(X(t,s,n,o,l),i)}function X(i,t,s,n,o){const l=new z(n);const e=new m(o);const a=()=>e.convertFrom(t-s);const r=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return u.makeTranslation(h.create(r(),0,0));case"y-translate":return u.makeTranslation(h.create(0,r(),0));case"z-translate":return u.makeTranslation(h.create(0,0,r()));case"x-rotate":return u.transpose(u.makeRotation(f.fromAxisAngle(h.left(),a())));case"y-rotate":return u.transpose(u.makeRotation(f.fromAxisAngle(h.down(),a())));case"z-rotate":return u.transpose(u.makeRotation(f.fromAxisAngle(h.forward(),a())));default:return u.makeIdentity()}}function q(i){switch(i){case"x-rotate":return"xyz";case"y-rotate":return"yzx";case"z-rotate":return"zxy";default:return"xyz"}}function J(i,t,s,n,o){const l=new z(n);const e=new m(o);const a=()=>u.makeRotation(f.fromMatrixRotation(t));const r=()=>u.multiply(u.invert(s),t);const c=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(r()),a());const w=()=>v.fromRotationMatrix(u.multiply(s,a()),q(i));switch(i){case"x-translate":return l.convertWorldValueToReal(c().x);case"y-translate":return l.convertWorldValueToReal(c().y);case"z-translate":return l.convertWorldValueToReal(c().z);case"x-rotate":return e.convertTo(d.normalizeRadians(w().x));case"y-rotate":return e.convertTo(d.normalizeRadians(w().y));case"z-rotate":return e.convertTo(d.normalizeRadians(w().z));default:return 0}}function L(i,t,s,n,o,l){return V(i,h.subtract(s,t),n,o,l)}function V(i,t,s,n,o){switch(o){case"x-translate":return W(i,t,h.right());case"y-translate":return W(i,t,h.up());case"z-translate":return W(i,t,h.back());case"xy-translate":return G(i,t,h.create(0,0,1));case"xz-translate":return G(i,t,h.create(0,1,0));case"yz-translate":return G(i,t,h.create(1,0,0));case"x-rotate":return Y(i,s,h.right(),n);case"y-rotate":return Y(i,s,h.up(),n);case"z-rotate":return Y(i,s,h.forward(),n);default:return i}}function Y(i,t,s,n){const o=Z(i,t,s);const l=f.fromAxisAngle(o,n);const e=u.transpose(u.makeRotation(l));return u.multiply(e,i)}function Z(i,t,s){const n=u.makeRotation(f.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function W(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const a=u.makeTranslation(e);return u.multiply(i,a)}function G(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const d=r.projectPoint(a,t);const v=h.add(d,h.scale(a.constant,a.normal));const c=u.makeTranslation(v);return u.multiply(i,c)}function Q(i,t,s){if(s.length===0){throw new Error("Unable to compute input position. At least one shape point must be provided.")}const n=c.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const l=c.topLeft(n);const h=e.add(l,e.create(n.width,0));const a=c.bottomRight(n);const r=e.subtract(a,e.create(n.width,0));const d=e.scale(o.reduce(((i,t)=>e.add(i,t)),e.create()),1/o.length,1/o.length);const u=[h,r,a].reduce(((i,t)=>e.distance(d,t)<e.distance(d,i)?t:i),l);switch(u){case l:return{point:u,placement:"top-left"};case h:return{point:u,placement:"top-right"};case r:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function ii(i,t,s,n,o,l){const e=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(e&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=d.toDegrees(i);const e=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=e-t;const h=d.toRadians(s);return h+n}else{const i=d.toRadians(e);return i+n}}else{return s}}const ti=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:e},h)=>{const a=oi(n,s!==null&&s!==void 0?s:w.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...a,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},h,i("div",{class:"widget-input units"},e.unit.abbreviatedName))};const si=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:e,onBlur:h,onUndo:a})=>{const r=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){e===null||e===void 0?void 0:e()}else if(i.key==="z"&&t&&a){i.preventDefault();a()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:r,onKeyDown:d,onBlur:h})};function ni(i,t){return Math.min(i,Math.max(0,t))}function oi(i,t,s,n,o=5){const{width:l,height:e}=i.dimensions;const h=t.width+o;const a=t.height+o;function r(i){return`${i}px`}switch(n){case"top-left":return{right:r(ni(l-h,l-s.x)),bottom:r(ni(e-a,e-s.y))};case"top-right":return{left:r(ni(l-h,s.x)),bottom:r(ni(e-a,e-s.y))};case"bottom-left":return{right:r(ni(l-h,l-s.x)),top:r(ni(e-a,s.y))};case"bottom-right":default:return{left:r(ni(l-h,s.x)),top:r(ni(e-a,s.y))}}}function li(i,t,s=3,n=1,o=1){return ai(i,t,h.back(),h.up(),s,n,o)}function ei(i,t,s=3,n=1,o=1){return ai(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ai(i,t,h.right(),h.up(),s,n,o)}function ai(i,t,s,n,o,l=1,e=1){const r=h.multiplyByTransformMatrixRowMajor(h.add(s,n),u.makeRotation(f.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,u.makeRotation(f.fromMatrixRotation(i)));const c=h.multiplyByTransformMatrixRowMajor(n,u.makeRotation(f.fromMatrixRotation(i)));const w=10*e**.25;const p=h.fromMatrixPosition(i);const g=h.add(p,h.scale(o*w,r));const x=a.create({origin:g,direction:v});const y=a.create({origin:g,direction:c});const b=h.cross(v,c);const m=h.rotateAboutAxis(d.toRadians(45),a.at(y,-(o*l)),b,g);const z=h.rotateAboutAxis(d.toRadians(45),a.at(x,o*l),b,g);const T=h.rotateAboutAxis(d.toRadians(45),a.at(y,o*l),b,g);const C=h.rotateAboutAxis(d.toRadians(45),a.at(x,-(o*l)),b,g);return new D(h.dot(v,t.direction)!==-1&&h.dot(c,t.direction)!==-1,m,C,z,T,h.multiplyByTransformMatrixColumnMajor(m,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(T,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return di(i,t,s,n)}return false}function di(i,t,s,n){return ui([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||ui([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function ui(i,t,s,n){var o;if(i.length===3){const l=s.transformPointToRay(n,t.image,t.scene.camera);const e=h.subtract(i[1],i[0]);const a=h.subtract(i[2],i[0]);const r=p.epsilon((o=p.fromVectors([l.direction,l.origin,e,a]))!==null&&o!==void 0?o:p.create(e,a));const d=h.cross(l.direction,a);const u=h.dot(e,d);if(!(Math.abs(u)>=r)){return false}const v=h.subtract(l.origin,i[0]);const c=h.dot(v,d)/u;if(c<0||c>1){return false}const f=h.cross(v,e);const w=h.dot(l.direction,f)/u;if(w<0||c+w>1){return false}const g=h.dot(a,f)/u;return!Number.isNaN(g)&&(g>0||t.scene.camera.isOrthographic())}return false}class vi extends R{constructor(i,t={},s={}){var n,o,l,e,h,a,r,d,u,v,c,f,w,p;super(i);this.customization=t;this.disabledAxis={xTranslation:false,yTranslation:false,zTranslation:false,xyTranslation:false,xzTranslation:false,yzTranslation:false,xRotation:false,yRotation:false,zRotation:false};this.axisLines=[];this.rotationLines=[];this.translationMeshes=[];this.rotationMeshes=[];this.hoveredChanged=new T;this.xArrowFillColor=(n=t.colors)===null||n===void 0?void 0:n.xArrow;this.yArrowFillColor=(o=t.colors)===null||o===void 0?void 0:o.yArrow;this.zArrowFillColor=(l=t.colors)===null||l===void 0?void 0:l.zArrow;this.hoveredArrowFillColor=(e=t.colors)===null||e===void 0?void 0:e.hovered;this.outlineColor=(h=t.colors)===null||h===void 0?void 0:h.outline;this.disabledAxis.xTranslation=(a=s.xTranslation)!==null&&a!==void 0?a:false;this.disabledAxis.yTranslation=(r=s.yTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.zTranslation=(d=s.zTranslation)!==null&&d!==void 0?d:false;this.disabledAxis.xyTranslation=(u=s.xyTranslation)!==null&&u!==void 0?u:false;this.disabledAxis.xzTranslation=(v=s.xzTranslation)!==null&&v!==void 0?v:false;this.disabledAxis.yzTranslation=(c=s.yzTranslation)!==null&&c!==void 0?c:false;this.disabledAxis.xRotation=(f=s.xRotation)!==null&&f!==void 0?f:false;this.disabledAxis.yRotation=(w=s.yRotation)!==null&&w!==void 0?w:false;this.disabledAxis.zRotation=(p=s.zRotation)!==null&&p!==void 0?p:false}dispose(){var i;(i=this.reglFrameDisposable)===null||i===void 0?void 0:i.cancel()}getDrawableElements(){return this.drawableElements}getFullBounds(){return this.fullBounds}boundsContainsPoint(i){return this.interactiveBounds!=null&&this.frame!=null&&c.containsPoints(this.interactiveBounds,i)}updateDisabledAxis(i){this.disabledAxis={...this.disabledAxis,...i};this.updateDisabledOnDrawables()}updateCursor(i){this.cursor=i;if(i!=null&&this.frame!=null){this.updateHovered()}else{this.clearHovered()}}updateTransform(i){var t;this.transform=i;if(i!=null&&this.frame!=null){this.updateAndDraw()}else{this.clear();(t=this.reglFrameDisposable)===null||t===void 0?void 0:t.cancel();this.reglFrameDisposable=undefined}}updateColors(i={}){var t,s,n,o,l,e,h,a,r,d,u,v,c,f,w,p;this.xArrowFillColor=(t=i.xArrow)!==null&&t!==void 0?t:this.xArrowFillColor;this.yArrowFillColor=(s=i.yArrow)!==null&&s!==void 0?s:this.yArrowFillColor;this.zArrowFillColor=(n=i.zArrow)!==null&&n!==void 0?n:this.zArrowFillColor;this.twoAxesSquareFillColor=(o=i.twoAxesSquare)!==null&&o!==void 0?o:this.twoAxesSquareFillColor;this.hoveredArrowFillColor=(l=i.hovered)!==null&&l!==void 0?l:this.hoveredArrowFillColor;this.outlineColor=(e=i.outline)!==null&&e!==void 0?e:this.outlineColor;(h=this.xArrow)===null||h===void 0?void 0:h.updateFillColor(this.getXTranslationColor(),true);(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor(this.getYTranslationColor(),true);(r=this.zArrow)===null||r===void 0?void 0:r.updateFillColor(this.getZTranslationColor(),true);(d=this.xRotation)===null||d===void 0?void 0:d.updateFillColor(this.getXRotationColor(),true);(u=this.yRotation)===null||u===void 0?void 0:u.updateFillColor(this.getYRotationColor(),true);(v=this.zRotation)===null||v===void 0?void 0:v.updateFillColor(this.getZRotationColor(),true);(c=this.xyTranslation)===null||c===void 0?void 0:c.updateFillColor(this.getTwoAxesTranslationColor(),true);(f=this.xzTranslation)===null||f===void 0?void 0:f.updateFillColor(this.getTwoAxesTranslationColor(),true);(w=this.yzTranslation)===null||w===void 0?void 0:w.updateFillColor(this.getTwoAxesTranslationColor(),true);(p=this.hoveredElement)===null||p===void 0?void 0:p.updateFillColor(this.hoveredArrowFillColor)}updateScalars(i){this.customization={...this.customization,scalars:i};if(this.transform!=null&&this.frame!=null){this.updateElements(this.transform,this.frame)}}onHoveredChanged(i){return this.hoveredChanged.on(i)}updateDisabledOnDrawables(){var i,t,s,n,o,l,e,h,a,r,d,u,v,c,f;(i=this.xRotation)===null||i===void 0?void 0:i.setDisabled(this.disabledAxis.xRotation);(t=this.xyRotationLine)===null||t===void 0?void 0:t.setDisabled(this.disabledAxis.xRotation);(s=this.xzRotationLine)===null||s===void 0?void 0:s.setDisabled(this.disabledAxis.xRotation);(n=this.yRotation)===null||n===void 0?void 0:n.setDisabled(this.disabledAxis.yRotation);(o=this.yzRotationLine)===null||o===void 0?void 0:o.setDisabled(this.disabledAxis.yRotation);(l=this.yxRotationLine)===null||l===void 0?void 0:l.setDisabled(this.disabledAxis.yRotation);(e=this.zRotation)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(h=this.zxRotationLine)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(a=this.zyRotationLine)===null||a===void 0?void 0:a.setDisabled(this.disabledAxis.zRotation);(r=this.xArrow)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.xTranslation);(d=this.yArrow)===null||d===void 0?void 0:d.setDisabled(this.disabledAxis.yTranslation);(u=this.zArrow)===null||u===void 0?void 0:u.setDisabled(this.disabledAxis.zTranslation);(v=this.xyTranslation)===null||v===void 0?void 0:v.setDisabled(this.disabledAxis.xyTranslation);(c=this.xzTranslation)===null||c===void 0?void 0:c.setDisabled(this.disabledAxis.xzTranslation);(f=this.yzTranslation)===null||f===void 0?void 0:f.setDisabled(this.disabledAxis.yzTranslation);this.updateColors()}updateHovered(){var i,t,s,n,o,l,e,h,a,r;const d=this.hoveredElement;const u=this.frame;if(u!=null){this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((i=>i.points.valid&&!i.isDisabled())).find((i=>this.cursor!=null?ri(i,u,this.viewport,this.cursor):false));if(this.hoveredElement!==d){this.hoveredChanged.emit(this.hoveredElement);(i=this.hoveredElement)===null||i===void 0?void 0:i.updateFillColor(this.hoveredArrowFillColor);this.clearFillColorOfPreviouslyHovered(d);if(((t=this.hoveredElement)===null||t===void 0?void 0:t.identifier)==="xy-translate"){(s=this.xArrow)===null||s===void 0?void 0:s.updateFillColor(this.hoveredArrowFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor(this.hoveredArrowFillColor)}else if(((o=this.hoveredElement)===null||o===void 0?void 0:o.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor(this.hoveredArrowFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor(this.hoveredArrowFillColor)}else if(((h=this.hoveredElement)===null||h===void 0?void 0:h.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor(this.hoveredArrowFillColor);(r=this.zArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor)}}}}clearHovered(){const i=this.hoveredElement;this.hoveredElement=undefined;if(this.hoveredElement!==i){this.hoveredChanged.emit(this.hoveredElement);this.clearFillColorOfPreviouslyHovered(i)}}clearFillColorOfPreviouslyHovered(i){var t,s,n,o,l,e,h,a,r,d,u,v;i===null||i===void 0?void 0:i.updateFillColor(i===null||i===void 0?void 0:i.initialFillColor);if((i===null||i===void 0?void 0:i.identifier)==="xy-translate"){(t=this.xArrow)===null||t===void 0?void 0:t.updateFillColor((s=this.xArrow)===null||s===void 0?void 0:s.initialFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor((o=this.yArrow)===null||o===void 0?void 0:o.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor((e=this.xArrow)===null||e===void 0?void 0:e.initialFillColor);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor((a=this.zArrow)===null||a===void 0?void 0:a.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor((d=this.yArrow)===null||d===void 0?void 0:d.initialFillColor);(u=this.zArrow)===null||u===void 0?void 0:u.updateFillColor((v=this.zArrow)===null||v===void 0?void 0:v.initialFillColor)}}hasData(){return this.transform!=null}createOrUpdateElements(){if(this.transform!=null&&this.frame!=null){if(this.xArrow==null||this.yArrow==null||this.zArrow==null){this.createElements(this.transform,this.frame)}else{this.updateElements(this.transform,this.frame)}this.interactiveBounds=P(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=P(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,a,r,d,u,v,c,f;this.reglCommand=S({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=E(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",A(i,t.scene.camera,p,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation),this.outlineColor,this.getXTranslationColor());this.xRotation=new C(w,"x-rotate",li(i,t.scene.camera,p,(n=this.customization.scalars)===null||n===void 0?void 0:n.xRotation,(o=this.customization.scalars)===null||o===void 0?void 0:o.xTranslation),this.outlineColor,this.getXRotationColor());this.xAxis=new I(w,"x-axis",U(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",N(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",ei(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(a=this.customization.scalars)===null||a===void 0?void 0:a.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new I(w,"y-axis",U(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",H(i,t.scene.camera,p,(r=this.customization.scalars)===null||r===void 0?void 0:r.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new I(w,"z-axis",U(i,t.scene.camera,this.zArrow),this.outlineColor,this.getZTranslationColor());this.zRotation=new C(w,"z-rotate",hi(i,t.scene.camera,p,(d=this.customization.scalars)===null||d===void 0?void 0:d.zRotation,(u=this.customization.scalars)===null||u===void 0?void 0:u.zTranslation),this.outlineColor,this.getZRotationColor());this.xyTranslation=new C(w,"xy-translate",F(i,t.scene.camera,p,(v=this.customization.scalars)===null||v===void 0?void 0:v.xyTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.xzTranslation=new C(w,"xz-translate",O(i,t.scene.camera,p,(c=this.customization.scalars)===null||c===void 0?void 0:c.xzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.yzTranslation=new C(w,"yz-translate",j(i,t.scene.camera,p,(f=this.customization.scalars)===null||f===void 0?void 0:f.yzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.createRotationLines(w,i,t);this.axisLines=[this.xAxis,this.yAxis,this.zAxis];this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow,this.xyTranslation,this.xzTranslation,this.yzTranslation];this.rotationMeshes=[this.xRotation,this.yRotation,this.zRotation];this.updateDisabledOnDrawables();this.availableElements=[...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes]}getXRotationColor(){return this.xArrowFillColor}getYRotationColor(){return this.yArrowFillColor}getZRotationColor(){return this.zArrowFillColor}getXTranslationColor(){return this.xArrowFillColor}getYTranslationColor(){return this.yArrowFillColor}getZTranslationColor(){return this.zArrowFillColor}getTwoAxesTranslationColor(){return this.twoAxesSquareFillColor}createRotationLines(i,t,s){var n,o,l,e,a,r;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=k(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=k(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=k(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=k(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=k(s.scene.camera,this.zRotation,(a=this.xArrow)===null||a===void 0?void 0:a.points.worldTip,d);const p=k(s.scene.camera,this.zRotation,(r=this.yArrow)===null||r===void 0?void 0:r.points.worldTip,d);if(u!=null){this.xyRotationLine=new M(i,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new M(i,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new M(i,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new M(i,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new M(i,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new M(i,"zy-rotation-line",p,this.outlineColor)}this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((i=>i!=null))}updateElements(i,t){var s,n,o,l,e,a,r,d,u,v,c,f,w,p,g,x,y,b,m,z,T,D,C,R,P,S,E,I,M,$;const _=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(A(i,t.scene.camera,_,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(U(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(li(i,t.scene.camera,_,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(N(i,t.scene.camera,_,(a=this.customization.scalars)===null||a===void 0?void 0:a.yTranslation));(r=this.yAxis)===null||r===void 0?void 0:r.updatePoints(U(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(ei(i,t.scene.camera,_,(u=this.customization.scalars)===null||u===void 0?void 0:u.yRotation,(v=this.customization.scalars)===null||v===void 0?void 0:v.yTranslation));if(this.zArrow!=null){this.zArrow.updatePoints(H(i,t.scene.camera,_,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(U(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,_,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(g=this.customization.scalars)===null||g===void 0?void 0:g.zTranslation));(x=this.xyRotationLine)===null||x===void 0?void 0:x.updatePoints(k(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,_));(b=this.xzRotationLine)===null||b===void 0?void 0:b.updatePoints(k(t.scene.camera,this.xRotation,(m=this.zArrow)===null||m===void 0?void 0:m.points.worldTip,_));(z=this.yxRotationLine)===null||z===void 0?void 0:z.updatePoints(k(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,_));(D=this.yzRotationLine)===null||D===void 0?void 0:D.updatePoints(k(t.scene.camera,this.yRotation,(C=this.zArrow)===null||C===void 0?void 0:C.points.worldTip,_));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(k(t.scene.camera,this.zRotation,(P=this.xArrow)===null||P===void 0?void 0:P.points.worldTip,_));(S=this.zyRotationLine)===null||S===void 0?void 0:S.updatePoints(k(t.scene.camera,this.zRotation,(E=this.yArrow)===null||E===void 0?void 0:E.points.worldTip,_));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(F(i,t.scene.camera,_,(I=this.customization.scalars)===null||I===void 0?void 0:I.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(O(i,t.scene.camera,_,(M=this.customization.scalars)===null||M===void 0?void 0:M.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(j(i,t.scene.camera,_,($=this.customization.scalars)===null||$===void 0?void 0:$.yzTranslation))}}}const ci=()=>`:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-transform-widget-x-axis-arrow-color:var(--x-axis-color);--viewer-transform-widget-y-axis-arrow-color:var(--y-axis-color);--viewer-transform-widget-z-axis-arrow-color:var(--z-axis-color);--viewer-transform-widget-two-axes-square-color:var(--two-axes-color);--viewer-transform-widget-hovered-arrow-color:#ffff00;--viewer-transform-widget-input-width:8em}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}.widget-input.wrapper{position:absolute;pointer-events:auto;display:flex;align-items:center;border:1px solid #444444;border-radius:4px;width:var(--viewer-transform-widget-input-width);text-align:center;background-color:white;box-sizing:border-box}.widget-input.units{position:relative;width:25%;height:100%;padding:0 0.25rem;font-size:0.8125rem;color:#444444}input.widget-input{position:relative;text-align:center;box-sizing:border-box;width:75%;height:100%;outline:none;border-width:0 1px 0 0;border-color:#444444;border-radius:2px 0 0 2px;font-size:0.875rem;color:#444444}input.widget-input.x-translate,input.widget-input.x-rotate{border-left:5px solid var(--viewer-transform-widget-x-axis-arrow-color)}input.widget-input.y-translate,input.widget-input.y-rotate{border-left:5px solid var(--viewer-transform-widget-y-axis-arrow-color)}input.widget-input.z-translate,input.widget-input.z-rotate{border-left:5px solid var(--viewer-transform-widget-z-axis-arrow-color)}input.widget-input:disabled{color:#888888}input.widget-input:focus{outline:none}`;const fi=s(class t extends n{constructor(i){super();if(i!==false){this.__registerHost()}this.__attachShadow();this.positionChanged=o(this,"positionChanged");this.rotationChanged=o(this,"rotationChanged");this.interactionEnded=o(this,"interactionEnded");this.interactionStarted=o(this,"interactionStarted");this.xRotationDisabled=false;this.yRotationDisabled=false;this.zRotationDisabled=false;this.xTranslationDisabled=false;this.yTranslationDisabled=false;this.zTranslationDisabled=false;this.xyTranslationDisabled=false;this.xzTranslationDisabled=false;this.yzTranslationDisabled=false;this.showInputs=true;this.distanceUnit="millimeters";this.angleUnit="degrees";this.decimalPlaces=1;this.rotationSnapKey="shift";this.translationHandleScalar=1;this.rotationHandleScalar=1;this.interactionThrottle=75;this.EXPERIMENTAL_undoKeybindings=false;this.inputValue=0;this.isEndingTransform=false;this.inputShouldFocus=false;this.xArrowColor="#ea3324";this.yArrowColor="#4faf32";this.zArrowColor="#0000ff";this.twoAxesSquareColor="#e0e0e0";this.hoveredColor="#ffff00";this.lastAngle=0;this.handleHoveredDrawableChanged=i=>{this.hovered=i};this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()};this.handleViewerDimensionsChange=()=>{x((()=>{if(this.viewer!=null&&this.canvasRef!=null){this.canvasRef.width=this.viewer.viewport.width;this.canvasRef.height=this.viewer.viewport.height;this.updateCanvasBounds(this.canvasRef)}}))};this.handleResize=()=>{if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef)}};this.handleInputResize=()=>{if(this.inputWrapperRef!=null){const i=this.inputWrapperRef;y((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{y((()=>{const i=window.getComputedStyle(this.hostEl);this.xArrowColor=i.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim();this.yArrowColor=i.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim();this.zArrowColor=i.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim();this.twoAxesSquareColor=i.getPropertyValue("--viewer-transform-widget-two-axes-square-color").trim();this.hoveredColor=i.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim();this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor})}))};this.handlePointerMove=i=>{if(this.dragging==null){const t=_(e.create(i.clientX,i.clientY),this.getCanvasBounds());const s=this.getTransformWidget();if(t!=null&&s.boundsContainsPoint(t)){s.updateCursor(t)}else{s.updateCursor(undefined);this.hovered=undefined}}};this.handleBeginDrag=async i=>{var t,s,n;const o=this.getCanvasBounds();if(this.hovered!=null&&o!=null&&this.viewer!=null&&this.position!=null&&this.viewer.frame!=null){this.dragging=this.hovered;if(this.dragging.identifier!==((t=this.lastDragged)===null||t===void 0?void 0:t.identifier)){this.inputValue=0;this.dragStartTransform=this.currentTransform;this.updateInputPosition();this.updateInputValue()}this.lastDragged=undefined;const l=_(e.create(i.clientX,i.clientY),o);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=l!=null?d.fromPoints(h,l):0;this.lastWorldPosition=K(l,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);this.interactionStarted.emit();window.removeEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointermove",this.handleDragWithTimer);window.addEventListener("pointerup",this.handleEndTransform)}};this.handleDragWithTimer=async i=>{if(i!=null){i.preventDefault();this.lastMouseEvent=i}if(this.interactionTimer==null){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.handleDrag();this.lastMouseEvent=undefined}),this.interactionThrottle)}};this.handleDrag=async()=>{var i,t,s;const n=this.getCanvasBounds();if(this.dragging!=null&&this.lastWorldPosition!=null&&n!=null&&this.viewer!=null&&this.viewer.frame!=null&&this.position!=null&&this.lastMouseEvent!=null){await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());const o=_(e.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const l=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const h=K(o,(t=this.viewer)===null||t===void 0?void 0:t.frame,(s=this.viewer)===null||s===void 0?void 0:s.viewport,this.currentTransform);if(h!=null&&o!=null&&l!=null){const i=d.fromPoints(l,o);const t=ii(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,h,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=h;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=_(e.create(i.clientX,i.clientY),this.getCanvasBounds());const o=this.getTransformWidget();this.lastDragged=this.dragging;this.dragging=undefined;this.lastWorldPosition=undefined;this.lastAngle=0;this.updateInputPosition();this.updateInputValue();o.updateCursor(n);o.updateTransform(this.currentTransform);this.beginEndTransform();window.removeEventListener("pointermove",this.handleDragWithTimer);window.removeEventListener("pointerup",this.handleEndTransform);try{const i=(t=this.controller)===null||t===void 0?void 0:t.getCurrentDelta();await((s=this.controller)===null||s===void 0?void 0:s.endTransform());this.interactionEnded.emit(i)}catch(i){console.error("Failed to end transform interaction",i)}window.addEventListener("pointermove",this.handlePointerMove);this.completeEndTransform()};this.handleInputStep=async i=>{if(this.inputValue!=null&&this.lastInputValue!=null){if(this.isModifyingAngleUnits()){const t=new m(this.angleUnit);const s=t.convertFrom(this.lastInputValue);const n=d.normalizeRadians(s+d.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=B(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(u.multiply(u.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new vi(i,{colors:{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor},scalars:{xTranslation:n,yTranslation:n,zTranslation:n,xyTranslation:o,xzTranslation:o,yzTranslation:o,xRotation:o,yRotation:o,zRotation:o}});if(this.rotation!=null){this.currentTransform=this.getTransformForNewRotation(this.rotation);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(this.position!=null){this.currentTransform=this.getTransformForNewPosition(this.position);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(((s=this.viewer)===null||s===void 0?void 0:s.frame)!=null){this.widget.updateFrame(this.viewer.frame,true)}this.handleSettingDisabledAxis();this.hoveredChangeDisposable=this.widget.onHoveredChanged(this.handleHoveredDrawableChanged);return this.widget};this.updateCanvasBounds=i=>{y((()=>{this.canvasBounds=i.getBoundingClientRect();this.getTransformWidget().updateDimensions(i)}))};this.updateInputValue=()=>{var i,t,s;const n=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const o=(n===null||n===void 0?void 0:n.identifier)==="xy-translate"||(n===null||n===void 0?void 0:n.identifier)==="xz-translate"||(n===null||n===void 0?void 0:n.identifier)==="yz-translate";if(n!=null&&this.currentTransform!=null&&this.dragStartTransform!=null&&!o){this.lastInputValue=this.inputValue;this.inputValue=J(n.identifier,this.currentTransform,this.dragStartTransform,this.distanceUnit,this.angleUnit);if(this.inputRef!=null){const i=(s=(t=this.getDisplayedDistance())!==null&&t!==void 0?t:this.getDisplayedAngle())!==null&&s!==void 0?s:0;const n=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Q(this.viewer.viewport,t,s.points.toArray()):undefined}else if(n){this.inputPosition=undefined}};this.beginEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:true,yRotation:true,zRotation:true,xTranslation:true,yTranslation:true,zTranslation:true,xyTranslation:true,xzTranslation:true,yzTranslation:true});this.isEndingTransform=true};this.completeEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled});this.isEndingTransform=false;this.inputShouldFocus=true;if(this.currentTransform!=null){this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=v.fromRotationMatrix(this.currentTransform)}};this.isModifyingAngleUnits=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;return!!(n===null||n===void 0?void 0:n.includes("rotate"))};this.getTranslationScalar=()=>{if(this.translationHandleScalar>0){return this.translationHandleScalar}console.warn("Invalid value provided for translation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getRotationScalar=()=>{if(this.rotationHandleScalar>0){return this.rotationHandleScalar}console.warn("Invalid value provided for rotation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getDisplayedUnits=()=>{if(this.isModifyingAngleUnits()){return new m(this.angleUnit)}return new z(this.distanceUnit)};this.getDisplayedAngle=()=>{if(this.isModifyingAngleUnits()){return this.inputValue}};this.getDisplayedDistance=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;if(n===null||n===void 0?void 0:n.includes("translate")){return this.inputValue}};this.getTransformForNewPosition=i=>{if(i!=null){const t=this.currentTransform!=null?this.currentTransform:u.makeIdentity();const s=u.transpose(u.makeRotation(f.fromMatrixRotation(t)));const n=u.makeTranslation(i);return u.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:u.makeIdentity();const s=u.makeRotation(f.fromMatrixRotation(t));const n=u.makeRotation(f.fromEuler(i));const o=u.multiply(s,t);return u.multiply(u.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){$(this.inputRef);this.inputShouldFocus=false}}async EXPERIMENTAL_undo(){var i,t;const s=await((i=this.controller)===null||i===void 0?void 0:i.EXPERIMENTAL_undoTransform());if(this.currentTransform!=null&&s!=null){this.currentTransform=u.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=v.fromRotationMatrix(this.currentTransform)}}handleViewerChanged(i,t){var s;t===null||t===void 0?void 0:t.removeEventListener("frameDrawn",this.handleViewerFrameDrawn);t===null||t===void 0?void 0:t.removeEventListener("dimensionschange",this.handleViewerDimensionsChange);i===null||i===void 0?void 0:i.addEventListener("frameDrawn",this.handleViewerFrameDrawn);i===null||i===void 0?void 0:i.addEventListener("dimensionschange",this.handleViewerDimensionsChange);if((i===null||i===void 0?void 0:i.stream)!=null){(s=this.controller)===null||s===void 0?void 0:s.dispose();this.controller=new b(i.stream)}}handleDisabledPropertyChanged(){var i;(i=this.widget)===null||i===void 0?void 0:i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}handleTransformHandleScalarChanged(){var i;const t=this.getTranslationScalar();const s=this.getRotationScalar();(i=this.widget)===null||i===void 0?void 0:i.updateScalars({xTranslation:t,yTranslation:t,zTranslation:t,xyTranslation:s,xzTranslation:s,yzTranslation:s,xRotation:s,yRotation:s,zRotation:s})}handleRotationChanged(i,t){var s;const n=i!==null&&i!==void 0?i:v.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&u.isIdentity(this.currentTransform)){this.currentTransform=undefined;this.startingTransform=this.currentTransform}(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);console.debug(`Updating widget rotation [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);this.rotationChanged.emit(i)}handlePositionChanged(i,t){var s,n;this.currentTransform=this.getTransformForNewPosition(i);this.startingTransform=this.currentTransform;console.debug(`Updating widget position [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);if(i==null){this.lastDragged=undefined;this.inputPosition=undefined;(n=this.controller)===null||n===void 0?void 0:n.clearTransform()}this.positionChanged.emit(i)}handleInputFormattingChanged(){this.updateInputValue();this.lastInputValue=this.inputValue}render(){var t,s,n,o,e,h;return i(l,{key:"fdc062cb3cafa311baca827e03a765052e1ab2c8"},i("canvas",{key:"c6c9d413e971ef3db3b3eed7e9ff6c8387fff1d1",ref:i=>{this.canvasRef=i},class:g("widget",{hovered:this.hovered!=null}),tabindex:"0",width:(t=this.viewer)===null||t===void 0?void 0:t.viewport.width,height:(s=this.viewer)===null||s===void 0?void 0:s.viewport.height,onPointerDown:this.handleBeginDrag,onKeyDown:this.handleKeyDown}),this.showInputs&&this.inputPosition&&((n=this.viewer)===null||n===void 0?void 0:n.viewport)&&i(ti,{key:"7eb3550df7db8c95f3597d1bd8d7b05c70e11696",ref:i=>{var t,s;if(i!=null){(t=this.inputResizeObserver)===null||t===void 0?void 0:t.observe(i)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputWrapperRef=i},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.placement,displayUnit:this.getDisplayedUnits()},i(si,{key:"84e2ff6825856c6d5f0ffff1771861ed6087bedb",ref:i=>{this.inputRef=i},identifier:(e=(o=this.dragging)===null||o===void 0?void 0:o.identifier)!==null&&e!==void 0?e:(h=this.lastDragged)===null||h===void 0?void 0:h.identifier,disabled:this.isEndingTransform,onChange:this.handleInputChange,onIncrement:()=>this.handleInputStep(1),onDecrement:()=>this.handleInputStep(-1),onBlur:()=>{this.inputShouldFocus=false},onUndo:this.EXPERIMENTAL_undoKeybindings?()=>this.EXPERIMENTAL_undo():undefined})))}transform(i,t,s){var n,o;if(this.position!=null&&this.startingTransform!=null&&this.currentTransform!=null&&this.dragging!=null&&this.viewer!=null&&this.viewer.frame!=null){this.currentTransform=L(this.currentTransform,i,t,(n=this.viewer)===null||n===void 0?void 0:n.frame.scene.camera.viewVector,s,this.dragging.identifier);this.getTransformWidget().updateTransform(this.currentTransform);(o=this.controller)===null||o===void 0?void 0:o.updateTransform(u.multiply(u.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return this}static get watchers(){return{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}}static get style(){return ci()}},[1,"vertex-viewer-transform-widget",{viewer:[16],position:[1040],rotation:[1040],controller:[1040],xRotationDisabled:[1028,"x-rotation-disabled"],yRotationDisabled:[1028,"y-rotation-disabled"],zRotationDisabled:[1028,"z-rotation-disabled"],xTranslationDisabled:[1028,"x-translation-disabled"],yTranslationDisabled:[1028,"y-translation-disabled"],zTranslationDisabled:[1028,"z-translation-disabled"],xyTranslationDisabled:[1028,"xy-translation-disabled"],xzTranslationDisabled:[1028,"xz-translation-disabled"],yzTranslationDisabled:[1028,"yz-translation-disabled"],showInputs:[4,"show-inputs"],distanceUnit:[1,"distance-unit"],angleUnit:[1,"angle-unit"],decimalPlaces:[2,"decimal-places"],rotationSnapDegrees:[2,"rotation-snap-degrees"],rotationSnapKey:[1,"rotation-snap-key"],translationHandleScalar:[2,"translation-handle-scalar"],rotationHandleScalar:[2,"rotation-handle-scalar"],interactionThrottle:[2,"interaction-throttle"],EXPERIMENTAL_undoKeybindings:[4,"e-x-p-e-r-i-m-e-n-t-a-l_undo-keybindings"],hovered:[1040],inputPosition:[32],inputValue:[32],isEndingTransform:[32],inputShouldFocus:[32],EXPERIMENTAL_undo:[64]},undefined,{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}]);function wi(){if(typeof customElements==="undefined"){return}const i=["vertex-viewer-transform-widget"];i.forEach((i=>{switch(i){case"vertex-viewer-transform-widget":if(!customElements.get(t(i))){customElements.define(t(i),fi)}break}}))}wi();const pi=fi;const gi=wi;export{pi as VertexViewerTransformWidget,gi as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-transform-widget.js.map
|