@vertexvis/viewer 1.0.0-testing.3 → 1.0.0-testing.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{config-CBFIZ5gy.js → config-C1xbl3Qa.js} +3 -3
- package/dist/cjs/{config-CBFIZ5gy.js.map → config-C1xbl3Qa.js.map} +1 -1
- package/dist/cjs/{entities-CAphDi6v.js → entities-D6AUMclh.js} +4 -4
- package/dist/cjs/{entities-CAphDi6v.js.map → entities-D6AUMclh.js.map} +1 -1
- package/dist/cjs/{geometry_pb-DW53co_-.js → geometry_pb-Ctp-Gcjm.js} +3 -3
- package/dist/cjs/{geometry_pb-DW53co_-.js.map → geometry_pb-Ctp-Gcjm.js.map} +1 -1
- package/dist/cjs/index.cjs.js +5 -5
- package/dist/cjs/{queries-uJfbbPWV.js → queries-CZmukyhu.js} +4 -4
- package/dist/cjs/{queries-uJfbbPWV.js.map → queries-CZmukyhu.js.map} +1 -1
- package/dist/cjs/{regl-component-CF41rUUv.js → regl-component-DOa8eHGy.js} +3 -3
- package/dist/cjs/{regl-component-CF41rUUv.js.map → regl-component-DOa8eHGy.js.map} +1 -1
- package/dist/cjs/{representation_pb-u7t5FI12.js → representation_pb-BrMsFavQ.js} +3 -3
- package/dist/cjs/{representation_pb-u7t5FI12.js.map → representation_pb-BrMsFavQ.js.map} +1 -1
- package/dist/cjs/{streamAttributes-BX291dI6.js → streamAttributes-DQm8yx7F.js} +6 -4
- package/dist/cjs/streamAttributes-DQm8yx7F.js.map +1 -0
- 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 +1 -1
- package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +2 -2
- package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +4 -4
- package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +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 +27 -7
- package/dist/cjs/vertex-viewer.cjs.entry.js.map +1 -1
- package/dist/collection/lib/meters.js +15 -1
- package/dist/collection/lib/meters.js.map +1 -1
- package/dist/collection/lib/storage.js +8 -2
- package/dist/collection/lib/storage.js.map +1 -1
- package/dist/collection/workers/png-decoder-pool.js +4 -2
- package/dist/collection/workers/png-decoder-pool.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-BhgrvpJL.js → p-BLSuslo8.js} +2 -2
- package/dist/components/{p-D7rQku5u.js → p-Bmj32MLp.js} +2 -2
- package/dist/components/{p-MYlndA6B.js → p-Bo49wgwt.js} +2 -2
- package/dist/components/{p-BjcO9U8D.js → p-BvOB1WAv.js} +2 -2
- package/dist/components/{p-DSeOWYJ_.js → p-BygjJ1WP.js} +2 -2
- package/dist/components/{p-CJuOe1O1.js → p-CGpWfqFr.js} +2 -2
- package/dist/components/{p-uwvTj3Cw.js → p-CHQ7ZKZd.js} +2 -2
- package/dist/components/{p-Lx4iaHhY.js → p-CYhNWr6k.js} +2 -2
- package/dist/components/{p-JSB7V_jW.js → p-DLV-gg65.js} +2 -2
- package/dist/components/{p-JSB7V_jW.js.map → p-DLV-gg65.js.map} +1 -1
- package/dist/components/{p-DyPaZtSF.js → p-gFMW2KYT.js} +2 -2
- package/dist/components/vertex-scene-tree-table-cell.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-measurement-precise.js.map +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/components/vertex-viewer.js.map +1 -1
- package/dist/esm/{config-_vT0BdS-.js → config-BrYuY-7v.js} +3 -3
- package/dist/esm/{config-_vT0BdS-.js.map → config-BrYuY-7v.js.map} +1 -1
- package/dist/esm/{entities-8QCEsVRy.js → entities-DxpPFj9w.js} +4 -4
- package/dist/esm/{entities-8QCEsVRy.js.map → entities-DxpPFj9w.js.map} +1 -1
- package/dist/esm/{geometry_pb-Dj0yGTFi.js → geometry_pb-BLGp5Nq8.js} +3 -3
- package/dist/esm/{geometry_pb-Dj0yGTFi.js.map → geometry_pb-BLGp5Nq8.js.map} +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.mjs +5 -5
- package/dist/esm/{queries-W4aeN1vv.js → queries-Coo1RH5H.js} +4 -4
- package/dist/esm/{queries-W4aeN1vv.js.map → queries-Coo1RH5H.js.map} +1 -1
- package/dist/esm/{regl-component-Rio5LpoO.js → regl-component-B30675op.js} +3 -3
- package/dist/esm/{regl-component-Rio5LpoO.js.map → regl-component-B30675op.js.map} +1 -1
- package/dist/esm/{representation_pb-CCDsiQtg.js → representation_pb-DYkJtHQo.js} +3 -3
- package/dist/esm/{representation_pb-CCDsiQtg.js.map → representation_pb-DYkJtHQo.js.map} +1 -1
- package/dist/esm/{streamAttributes-DhQVsxJf.js → streamAttributes-Cfp9UX5m.js} +6 -4
- package/dist/esm/streamAttributes-Cfp9UX5m.js.map +1 -0
- 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 +1 -1
- package/dist/esm/vertex-viewer-measurement-distance.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-line_2.entry.js +2 -2
- package/dist/esm/vertex-viewer-measurement-precise.entry.js +4 -4
- package/dist/esm/vertex-viewer-pin-group.entry.js +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 +27 -7
- package/dist/esm/vertex-viewer.entry.js.map +1 -1
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/{p-baec8489.entry.js → p-0287e1ba.entry.js} +2 -2
- package/dist/viewer/{p-2bd6cd13.entry.js → p-380e0112.entry.js} +2 -2
- package/dist/viewer/{p-101825c2.entry.js → p-40d90c6e.entry.js} +2 -2
- package/dist/viewer/{p-317da1b6.entry.js → p-6a546084.entry.js} +2 -2
- package/dist/viewer/p-7189eb18.entry.js +5 -0
- package/dist/viewer/p-7189eb18.entry.js.map +1 -0
- package/dist/viewer/{p-807aa9d0.entry.js → p-72fa9fba.entry.js} +2 -2
- package/dist/viewer/{p-0bf39fff.entry.js → p-81391d86.entry.js} +2 -2
- package/dist/viewer/{p-5VxzXVFc.js → p-B7mOY-Vi.js} +2 -2
- package/dist/viewer/{p-5VxzXVFc.js.map → p-B7mOY-Vi.js.map} +1 -1
- package/dist/viewer/{p-B9AGwrOP.js → p-CVRW2Plt.js} +2 -2
- package/dist/viewer/{p-B9AGwrOP.js.map → p-CVRW2Plt.js.map} +1 -1
- package/dist/viewer/{p-C0bm56qJ.js → p-CrcoZmKt.js} +2 -2
- package/dist/viewer/p-CrcoZmKt.js.map +1 -0
- package/dist/viewer/{p-BNiP3SE7.js → p-DKKHW33X.js} +2 -2
- package/dist/viewer/{p-BNiP3SE7.js.map → p-DKKHW33X.js.map} +1 -1
- package/dist/viewer/p-F9YPK1I7.js +5 -0
- package/dist/viewer/{p-DOMCeSTr.js.map → p-F9YPK1I7.js.map} +1 -1
- package/dist/viewer/p-Nk8SgPHE.js +5 -0
- package/dist/viewer/{p-CrwKMz5f.js.map → p-Nk8SgPHE.js.map} +1 -1
- package/dist/viewer/{p-BoFi-Uyu.js → p-_19YlCN5.js} +2 -2
- package/dist/viewer/{p-BoFi-Uyu.js.map → p-_19YlCN5.js.map} +1 -1
- package/dist/viewer/{p-dd2f92e3.entry.js → p-c7eb05ec.entry.js} +2 -2
- package/dist/viewer/{p-fade0dba.entry.js → p-c9d71f1e.entry.js} +2 -2
- package/dist/viewer/{p-49b9bba2.entry.js → p-d50b2449.entry.js} +2 -2
- package/dist/viewer/{p-0fa89933.entry.js → p-e80260d3.entry.js} +2 -2
- package/dist/viewer/{p-71c08a04.entry.js → p-fc082185.entry.js} +2 -2
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +8 -7
- package/dist/cjs/streamAttributes-BX291dI6.js.map +0 -1
- package/dist/esm/streamAttributes-DhQVsxJf.js.map +0 -1
- package/dist/viewer/p-C0bm56qJ.js.map +0 -1
- package/dist/viewer/p-CrwKMz5f.js +0 -5
- package/dist/viewer/p-DOMCeSTr.js +0 -5
- package/dist/viewer/p-ea736bd1.entry.js +0 -5
- package/dist/viewer/p-ea736bd1.entry.js.map +0 -1
- /package/dist/components/{p-BhgrvpJL.js.map → p-BLSuslo8.js.map} +0 -0
- /package/dist/components/{p-D7rQku5u.js.map → p-Bmj32MLp.js.map} +0 -0
- /package/dist/components/{p-MYlndA6B.js.map → p-Bo49wgwt.js.map} +0 -0
- /package/dist/components/{p-BjcO9U8D.js.map → p-BvOB1WAv.js.map} +0 -0
- /package/dist/components/{p-DSeOWYJ_.js.map → p-BygjJ1WP.js.map} +0 -0
- /package/dist/components/{p-CJuOe1O1.js.map → p-CGpWfqFr.js.map} +0 -0
- /package/dist/components/{p-uwvTj3Cw.js.map → p-CHQ7ZKZd.js.map} +0 -0
- /package/dist/components/{p-Lx4iaHhY.js.map → p-CYhNWr6k.js.map} +0 -0
- /package/dist/components/{p-DyPaZtSF.js.map → p-gFMW2KYT.js.map} +0 -0
- /package/dist/viewer/{p-baec8489.entry.js.map → p-0287e1ba.entry.js.map} +0 -0
- /package/dist/viewer/{p-2bd6cd13.entry.js.map → p-380e0112.entry.js.map} +0 -0
- /package/dist/viewer/{p-101825c2.entry.js.map → p-40d90c6e.entry.js.map} +0 -0
- /package/dist/viewer/{p-317da1b6.entry.js.map → p-6a546084.entry.js.map} +0 -0
- /package/dist/viewer/{p-807aa9d0.entry.js.map → p-72fa9fba.entry.js.map} +0 -0
- /package/dist/viewer/{p-0bf39fff.entry.js.map → p-81391d86.entry.js.map} +0 -0
- /package/dist/viewer/{p-dd2f92e3.entry.js.map → p-c7eb05ec.entry.js.map} +0 -0
- /package/dist/viewer/{p-fade0dba.entry.js.map → p-c9d71f1e.entry.js.map} +0 -0
- /package/dist/viewer/{p-49b9bba2.entry.js.map → p-d50b2449.entry.js.map} +0 -0
- /package/dist/viewer/{p-0fa89933.entry.js.map → p-e80260d3.entry.js.map} +0 -0
- /package/dist/viewer/{p-71c08a04.entry.js.map → p-fc082185.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{t as e,p as t,H as s,h as i,e as n}from"./p-DmsAWRoU.js";import{s as r}from"./p-BHLZLTUV.js";import{p as
|
|
4
|
+
import{t as e,p as t,H as s,h as i,e as n}from"./p-DmsAWRoU.js";import{s as r}from"./p-BHLZLTUV.js";import{p as o}from"./p-Bo49wgwt.js";import{a,M as l}from"./p-CGpWfqFr.js";import"./p-DJFjBgT7.js";import"./p-Bmj32MLp.js";import"./p-zTYgyBoa.js";import{E as h}from"./p-DLV-gg65.js";import{M as d}from"./p-BlP9GdkV.js";import{M as m}from"./p-BgzShg1O.js";import{p as u}from"./p-Tvs4yxd5.js";import{a as p}from"./p-Bn7QEZYW.js";import{g as c}from"./p-BSYTUXcE.js";import{E as v}from"./p-CFus3r7d.js";import{d as w}from"./p-Xr7Oa6iw.js";import{d as f}from"./p-BvOB1WAv.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?a.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 g=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}`;const C=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:"2113569601821e742598eae47086b8bbd9198257"},i("vertex-viewer-measurement-overlays",{key:"d5ad40dd490ee2f6e1bddf5190c08907d706e0b9",viewer:this.viewer,measurementOverlays:this.measurementOverlays}))}setupController(){var e;const t=o(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:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return g()}},[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:0}],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),C)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){w()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){f()}break}}))}M();const b=C;const E=M;export{b as VertexViewerMeasurementPrecise,E as defineCustomElement};
|
|
5
5
|
//# sourceMappingURL=vertex-viewer-measurement-precise.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MeasurementInteractionHandler","elementRect","this","rectObserver","rect","constructor","controller","measurableEntityTypes","ElementRectObserver","handlePointerMove","async","event","isMeasurableEntityUnderPointer","clearCursor","addCursor","measurementWithArrowCursor","handlePointerDown","ifNoInteraction","measureEntityUnderPointer","clearEntities","initialize","element","api","observe","addEventListener","dispose","disconnect","_a","measurementInteraction","_b","removeEventListener","_c","undefined","cursor","ifInitialized","pt","getMouseClientPosition","type","getEntityTypeAtPoint","includes","hit","hitItems","entity","MeasurementEntity","fromHit","addEntity","f","Error","startPos","Point","create","clientX","clientY","didInteract","handleMouseMove","pos","dis","distance","handleMouseUp","window","viewerMeasurementPreciseCss","ViewerMeasurementPrecise","__stencil_proxyCustomElement","HTMLElement","registerHost","measurementModel","MeasurementModel","measurementOverlays","MeasurementOverlayManager","EntityType","PRECISE_SURFACE","IMPRECISE_SURFACE","configEnv","connectedCallback","setupInteractionHandler","componentWillLoad","setupController","disconnectedCallback","clearInteractionHandler","handleMeasurableEntityTypesChanged","handleMeasurementControllerChanged","handleMeasurementModelChanged","handleViewerChanged","render","h","Host","key","viewer","config","parseAndValidateConfig","client","SceneViewAPIClient","network","sceneViewHost","measurementController","MeasurementController","token","deviceId","registeredInteractionHandler","then","handler","registerInteractionHandler"],"sources":["src/lib/measurement/interactions.ts","src/components/viewer-measurement-precise/viewer-measurement-precise.css?tag=vertex-viewer-measurement-precise&encapsulation=shadow","src/components/viewer-measurement-precise/viewer-measurement-precise.tsx"],"sourcesContent":["import { Point } from '@vertexvis/geometry';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { Cursor, measurementWithArrowCursor } from '../cursors';\nimport { getMouseClientPosition } from '../dom';\nimport { ElementRectObserver } from '../elementRectObserver';\nimport { InteractionApi, InteractionHandler } from '../interactions';\nimport { EntityType } from '../types';\nimport { MeasurementController } from './controller';\nimport { MeasurementEntity } from './entities';\n\nexport class MeasurementInteractionHandler implements InteractionHandler {\n private controller: MeasurementController;\n private measurableEntityTypes: EntityType[];\n\n private element?: HTMLElement;\n private api?: InteractionApi;\n\n private cursor?: Disposable;\n private measurementInteraction?: InteractionHandler;\n\n private rectObserver = new ElementRectObserver();\n private get elementRect(): DOMRect | undefined {\n return this.rectObserver.rect;\n }\n\n public constructor(\n controller: MeasurementController,\n measurableEntityTypes: EntityType[]\n ) {\n this.controller = controller;\n this.measurableEntityTypes = measurableEntityTypes;\n }\n\n public initialize(element: HTMLElement, api: InteractionApi): void {\n this.element = element;\n this.api = api;\n\n this.rectObserver.observe(element);\n\n element.addEventListener('pointermove', this.handlePointerMove);\n element.addEventListener('pointerdown', this.handlePointerDown);\n }\n\n public dispose(): void {\n this.rectObserver.disconnect();\n this.measurementInteraction?.dispose();\n this.clearCursor();\n\n this.element?.removeEventListener('pointermove', this.handlePointerMove);\n this.element?.removeEventListener('pointerdown', this.handlePointerDown);\n\n this.element = undefined;\n this.api = undefined;\n }\n\n private addCursor(cursor: Cursor): void {\n this.cursor = this.ifInitialized(({ api }) => api.addCursor(cursor));\n }\n\n private clearCursor(): void {\n this.cursor?.dispose();\n this.cursor = undefined;\n }\n\n private handlePointerMove = async (event: PointerEvent): Promise<void> => {\n if (await this.isMeasurableEntityUnderPointer(event)) {\n this.clearCursor();\n this.addCursor(measurementWithArrowCursor);\n } else {\n this.clearCursor();\n }\n };\n\n private handlePointerDown = (event: PointerEvent): void => {\n this.ifNoInteraction(event, async () => {\n if (await this.isMeasurableEntityUnderPointer(event)) {\n this.measureEntityUnderPointer(event);\n } else {\n await this.controller.clearEntities();\n }\n });\n };\n\n private async isMeasurableEntityUnderPointer(\n event: PointerEvent\n ): Promise<boolean> {\n const pt = getMouseClientPosition(event, this.elementRect);\n const type = await this.api?.getEntityTypeAtPoint(pt);\n return type != null && this.measurableEntityTypes.includes(type);\n }\n\n private measureEntityUnderPointer(event: PointerEvent): void {\n this.ifInitialized(async ({ api }) => {\n const pt = getMouseClientPosition(event, this.elementRect);\n const [hit] = await api.hitItems(pt);\n const entity = hit != null ? MeasurementEntity.fromHit(hit) : undefined;\n\n if (entity != null) {\n await this.controller.addEntity(entity);\n } else {\n await this.controller.clearEntities();\n }\n });\n }\n\n protected ifInitialized<R>(\n f: (data: { element: HTMLElement; api: InteractionApi }) => R\n ): R {\n if (this.element != null && this.api != null) {\n return f({ element: this.element, api: this.api });\n } else {\n throw new Error('Measurement interaction handler not initialized.');\n }\n }\n\n protected ifNoInteraction(\n event: PointerEvent,\n f: () => void | Promise<void>\n ): void {\n const startPos = Point.create(event.clientX, event.clientY);\n let didInteract = false;\n\n const handleMouseMove = (event: PointerEvent): void => {\n const pos = Point.create(event.clientX, event.clientY);\n const dis = Point.distance(startPos, pos);\n didInteract = dis > 2;\n };\n\n const handleMouseUp = (): void => {\n window.removeEventListener('pointermove', handleMouseMove);\n window.removeEventListener('pointerup', handleMouseUp);\n\n if (!didInteract) {\n f();\n }\n };\n\n window.addEventListener('pointermove', handleMouseMove);\n window.addEventListener('pointerup', handleMouseUp);\n }\n}\n",":host {\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n pointer-events: none;\n}\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Component, h, Host, JSX, Prop, State, Watch } from '@stencil/core';\nimport { SceneViewAPIClient } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb_service';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { parseAndValidateConfig, PartialConfig } from '../../lib/config';\nimport { Environment } from '../../lib/environment';\nimport {\n MeasurementController,\n MeasurementModel,\n MeasurementOverlayManager,\n} from '../../lib/measurement';\nimport { MeasurementInteractionHandler } from '../../lib/measurement/interactions';\nimport { EntityType } from '../../lib/types';\n\n@Component({\n tag: 'vertex-viewer-measurement-precise',\n styleUrl: 'viewer-measurement-precise.css',\n shadow: true,\n})\nexport class ViewerMeasurementPrecise {\n /**\n * The model that contains the entities and outcomes from performing precise\n * measurements.\n */\n @Prop()\n public measurementModel: MeasurementModel = new MeasurementModel();\n\n /**\n * The manager that is responsible for measurement overlays to present by this\n * component.\n */\n @Prop()\n public measurementOverlays: MeasurementOverlayManager =\n new MeasurementOverlayManager();\n\n /**\n * The controller that is responsible for performing measurements and updating\n * the model.\n */\n @Prop({ mutable: true })\n public measurementController?: MeasurementController;\n\n /**\n * @internal\n *\n * An internal property that can be used to opt-in to performing measurements\n * on other types of entities.\n */\n @Prop()\n public measurableEntityTypes: EntityType[] = [\n EntityType.PRECISE_SURFACE,\n EntityType.IMPRECISE_SURFACE,\n ];\n\n /**\n * The viewer that this component is bound to. This is automatically assigned\n * if added to the light-dom of a parent viewer element.\n */\n @Prop()\n public viewer?: HTMLVertexViewerElement;\n\n /**\n * The environment that will be used to request measurement results.\n */\n @Prop()\n public configEnv: Environment = 'platprod';\n\n /**\n * An optional configuration to setup network configuration of measurement\n * endpoints.\n */\n @Prop()\n public config?: PartialConfig | string;\n\n private registeredInteractionHandler?: Promise<Disposable>;\n\n /**\n * @ignore\n */\n protected connectedCallback(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n protected componentWillLoad(): void {\n this.setupController();\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n protected disconnectedCallback(): void {\n this.clearInteractionHandler();\n }\n\n /**\n * @ignore\n */\n @Watch('measurableEntityTypes')\n protected handleMeasurableEntityTypesChanged(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n @Watch('measurementController')\n protected handleMeasurementControllerChanged(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n @Watch('measurementModel')\n protected handleMeasurementModelChanged(): void {\n this.setupController();\n }\n\n /**\n * @ignore\n */\n @Watch('viewer')\n protected handleViewerChanged(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n protected render(): JSX.Element {\n return (\n <Host>\n <vertex-viewer-measurement-overlays\n viewer={this.viewer}\n measurementOverlays={this.measurementOverlays}\n />\n </Host>\n );\n }\n\n private setupController(): void {\n const config = parseAndValidateConfig(this.configEnv, this.config);\n const client = new SceneViewAPIClient(config.network.sceneViewHost);\n this.measurementController = new MeasurementController(\n this.measurementModel,\n client,\n () => this.viewer?.token,\n this.viewer?.deviceId\n );\n }\n\n private clearInteractionHandler(): void {\n this.registeredInteractionHandler?.then((handler) => handler.dispose());\n this.registeredInteractionHandler = undefined;\n }\n\n private setupInteractionHandler(): void {\n this.clearInteractionHandler();\n\n if (this.measurementController != null) {\n this.registeredInteractionHandler =\n this.viewer?.registerInteractionHandler(\n new MeasurementInteractionHandler(\n this.measurementController,\n this.measurableEntityTypes\n )\n );\n }\n }\n}\n"],"mappings":";;;qkBAWaA,EAWX,eAAYC,GACV,OAAOC,KAAKC,aAAaC,I,CAG3B,WAAAC,CACEC,EACAC,GAPML,KAAAC,aAAe,IAAIK,EA4CnBN,KAAAO,kBAAoBC,MAAOC,IACjC,SAAUT,KAAKU,+BAA+BD,GAAQ,CACpDT,KAAKW,cACLX,KAAKY,UAAUC,E,KACV,CACLb,KAAKW,a,GAIDX,KAAAc,kBAAqBL,IAC3BT,KAAKe,gBAAgBN,GAAOD,UAC1B,SAAUR,KAAKU,+BAA+BD,GAAQ,CACpDT,KAAKgB,0BAA0BP,E,KAC1B,OACCT,KAAKI,WAAWa,e,IAExB,EAnDFjB,KAAKI,WAAaA,EAClBJ,KAAKK,sBAAwBA,C,CAGxB,UAAAa,CAAWC,EAAsBC,GACtCpB,KAAKmB,QAAUA,EACfnB,KAAKoB,IAAMA,EAEXpB,KAAKC,aAAaoB,QAAQF,GAE1BA,EAAQG,iBAAiB,cAAetB,KAAKO,mBAC7CY,EAAQG,iBAAiB,cAAetB,KAAKc,kB,CAGxC,OAAAS,G,UACLvB,KAAKC,aAAauB,cAClBC,EAAAzB,KAAK0B,0BAAsB,MAAAD,SAAA,SAAAA,EAAEF,UAC7BvB,KAAKW,eAELgB,EAAA3B,KAAKmB,WAAO,MAAAQ,SAAA,SAAAA,EAAEC,oBAAoB,cAAe5B,KAAKO,oBACtDsB,EAAA7B,KAAKmB,WAAO,MAAAU,SAAA,SAAAA,EAAED,oBAAoB,cAAe5B,KAAKc,mBAEtDd,KAAKmB,QAAUW,UACf9B,KAAKoB,IAAMU,S,CAGL,SAAAlB,CAAUmB,GAChB/B,KAAK+B,OAAS/B,KAAKgC,eAAc,EAAGZ,SAAUA,EAAIR,UAAUmB,I,CAGtD,WAAApB,G,OACNc,EAAAzB,KAAK+B,UAAM,MAAAN,SAAA,SAAAA,EAAEF,UACbvB,KAAK+B,OAASD,S,CAsBR,oCAAMpB,CACZD,G,MAEA,MAAMwB,EAAKC,EAAuBzB,EAAOT,KAAKD,aAC9C,MAAMoC,SAAaV,EAAAzB,KAAKoB,OAAG,MAAAK,SAAA,SAAAA,EAAEW,qBAAqBH,IAClD,OAAOE,GAAQ,MAAQnC,KAAKK,sBAAsBgC,SAASF,E,CAGrD,yBAAAnB,CAA0BP,GAChCT,KAAKgC,eAAcxB,OAASY,UAC1B,MAAMa,EAAKC,EAAuBzB,EAAOT,KAAKD,aAC9C,MAAOuC,SAAalB,EAAImB,SAASN,GACjC,MAAMO,EAASF,GAAO,KAAOG,EAAkBC,QAAQJ,GAAOR,UAE9D,GAAIU,GAAU,KAAM,OACZxC,KAAKI,WAAWuC,UAAUH,E,KAC3B,OACCxC,KAAKI,WAAWa,e,KAKlB,aAAAe,CACRY,GAEA,GAAI5C,KAAKmB,SAAW,MAAQnB,KAAKoB,KAAO,KAAM,CAC5C,OAAOwB,EAAE,CAAEzB,QAASnB,KAAKmB,QAASC,IAAKpB,KAAKoB,K,KACvC,CACL,MAAM,IAAIyB,MAAM,mD,EAIV,eAAA9B,CACRN,EACAmC,GAEA,MAAME,EAAWC,EAAMC,OAAOvC,EAAMwC,QAASxC,EAAMyC,SACnD,IAAIC,EAAc,MAElB,MAAMC,EAAmB3C,IACvB,MAAM4C,EAAMN,EAAMC,OAAOvC,EAAMwC,QAASxC,EAAMyC,SAC9C,MAAMI,EAAMP,EAAMQ,SAAST,EAAUO,GACrCF,EAAcG,EAAM,CAAC,EAGvB,MAAME,EAAgB,KACpBC,OAAO7B,oBAAoB,cAAewB,GAC1CK,OAAO7B,oBAAoB,YAAa4B,GAExC,IAAKL,EAAa,CAChBP,G,GAIJa,OAAOnC,iBAAiB,cAAe8B,GACvCK,OAAOnC,iBAAiB,YAAakC,E,EC3IzC,MAAME,EAA8B,IAAM,2F,MCoB7BC,EAAwBC,EAAA,MAAAD,UAAAE,EALrC,WAAA1D,CAAA2D,G,kEAWS9D,KAAA+D,iBAAqC,IAAIC,EAOzChE,KAAAiE,oBACL,IAAIC,EAgBClE,KAAAK,sBAAsC,CAC3C8D,EAAWC,gBACXD,EAAWE,mBAcNrE,KAAAsE,UAAyB,UA4GjC,CA9FW,iBAAAC,GACRvE,KAAKwE,yB,CAMG,iBAAAC,GACRzE,KAAK0E,kBACL1E,KAAKwE,yB,CAMG,oBAAAG,GACR3E,KAAK4E,yB,CAOG,kCAAAC,GACR7E,KAAKwE,yB,CAOG,kCAAAM,GACR9E,KAAKwE,yB,CAOG,6BAAAO,GACR/E,KAAK0E,iB,CAOG,mBAAAM,GACRhF,KAAKwE,yB,CAMG,MAAAS,GACR,OACEC,EAACC,EAAI,CAAAC,IAAA,4CACHF,EAAA,sCAAAE,IAAA,2CACEC,OAAQrF,KAAKqF,OACbpB,oBAAqBjE,KAAKiE,sB,CAM1B,eAAAS,G,MACN,MAAMY,EAASC,EAAuBvF,KAAKsE,UAAWtE,KAAKsF,QAC3D,MAAME,EAAS,IAAIC,qBAAmBH,EAAOI,QAAQC,eACrD3F,KAAK4F,sBAAwB,IAAIC,EAC/B7F,KAAK+D,iBACLyB,GACA,KAAK,IAAA/D,EAAC,OAAAA,EAAAzB,KAAKqF,UAAM,MAAA5D,SAAA,SAAAA,EAAEqE,KAAK,IACxBrE,EAAAzB,KAAKqF,UAAM,MAAA5D,SAAA,SAAAA,EAAEsE,S,CAIT,uBAAAnB,G,OACNnD,EAAAzB,KAAKgG,gCAA4B,MAAAvE,SAAA,SAAAA,EAAEwE,MAAMC,GAAYA,EAAQ3E,YAC7DvB,KAAKgG,6BAA+BlE,S,CAG9B,uBAAA0C,G,MACNxE,KAAK4E,0BAEL,GAAI5E,KAAK4F,uBAAyB,KAAM,CACtC5F,KAAKgG,8BACHvE,EAAAzB,KAAKqF,UAAM,MAAA5D,SAAA,SAAAA,EAAE0E,2BACX,IAAIrG,EACFE,KAAK4F,sBACL5F,KAAKK,uB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["MeasurementInteractionHandler","elementRect","this","rectObserver","rect","constructor","controller","measurableEntityTypes","ElementRectObserver","handlePointerMove","async","event","isMeasurableEntityUnderPointer","clearCursor","addCursor","measurementWithArrowCursor","handlePointerDown","ifNoInteraction","measureEntityUnderPointer","clearEntities","initialize","element","api","observe","addEventListener","dispose","disconnect","_a","measurementInteraction","_b","removeEventListener","_c","undefined","cursor","ifInitialized","pt","getMouseClientPosition","type","getEntityTypeAtPoint","includes","hit","hitItems","entity","MeasurementEntity","fromHit","addEntity","f","Error","startPos","Point","create","clientX","clientY","didInteract","handleMouseMove","pos","dis","distance","handleMouseUp","window","viewerMeasurementPreciseCss","ViewerMeasurementPrecise","__stencil_proxyCustomElement","HTMLElement","registerHost","measurementModel","MeasurementModel","measurementOverlays","MeasurementOverlayManager","EntityType","PRECISE_SURFACE","IMPRECISE_SURFACE","configEnv","connectedCallback","setupInteractionHandler","componentWillLoad","setupController","disconnectedCallback","clearInteractionHandler","handleMeasurableEntityTypesChanged","handleMeasurementControllerChanged","handleMeasurementModelChanged","handleViewerChanged","render","h","Host","key","viewer","config","parseAndValidateConfig","client","SceneViewAPIClient","network","sceneViewHost","measurementController","MeasurementController","token","deviceId","registeredInteractionHandler","then","handler","registerInteractionHandler"],"sources":["src/lib/measurement/interactions.ts","src/components/viewer-measurement-precise/viewer-measurement-precise.css?tag=vertex-viewer-measurement-precise&encapsulation=shadow","src/components/viewer-measurement-precise/viewer-measurement-precise.tsx"],"sourcesContent":["import { Point } from '@vertexvis/geometry';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { Cursor, measurementWithArrowCursor } from '../cursors';\nimport { getMouseClientPosition } from '../dom';\nimport { ElementRectObserver } from '../elementRectObserver';\nimport { InteractionApi, InteractionHandler } from '../interactions';\nimport { EntityType } from '../types';\nimport { MeasurementController } from './controller';\nimport { MeasurementEntity } from './entities';\n\nexport class MeasurementInteractionHandler implements InteractionHandler {\n private controller: MeasurementController;\n private measurableEntityTypes: EntityType[];\n\n private element?: HTMLElement;\n private api?: InteractionApi;\n\n private cursor?: Disposable;\n private measurementInteraction?: InteractionHandler;\n\n private rectObserver = new ElementRectObserver();\n private get elementRect(): DOMRect | undefined {\n return this.rectObserver.rect;\n }\n\n public constructor(\n controller: MeasurementController,\n measurableEntityTypes: EntityType[]\n ) {\n this.controller = controller;\n this.measurableEntityTypes = measurableEntityTypes;\n }\n\n public initialize(element: HTMLElement, api: InteractionApi): void {\n this.element = element;\n this.api = api;\n\n this.rectObserver.observe(element);\n\n element.addEventListener('pointermove', this.handlePointerMove);\n element.addEventListener('pointerdown', this.handlePointerDown);\n }\n\n public dispose(): void {\n this.rectObserver.disconnect();\n this.measurementInteraction?.dispose();\n this.clearCursor();\n\n this.element?.removeEventListener('pointermove', this.handlePointerMove);\n this.element?.removeEventListener('pointerdown', this.handlePointerDown);\n\n this.element = undefined;\n this.api = undefined;\n }\n\n private addCursor(cursor: Cursor): void {\n this.cursor = this.ifInitialized(({ api }) => api.addCursor(cursor));\n }\n\n private clearCursor(): void {\n this.cursor?.dispose();\n this.cursor = undefined;\n }\n\n private handlePointerMove = async (event: PointerEvent): Promise<void> => {\n if (await this.isMeasurableEntityUnderPointer(event)) {\n this.clearCursor();\n this.addCursor(measurementWithArrowCursor);\n } else {\n this.clearCursor();\n }\n };\n\n private handlePointerDown = (event: PointerEvent): void => {\n this.ifNoInteraction(event, async () => {\n if (await this.isMeasurableEntityUnderPointer(event)) {\n this.measureEntityUnderPointer(event);\n } else {\n await this.controller.clearEntities();\n }\n });\n };\n\n private async isMeasurableEntityUnderPointer(\n event: PointerEvent\n ): Promise<boolean> {\n const pt = getMouseClientPosition(event, this.elementRect);\n const type = await this.api?.getEntityTypeAtPoint(pt);\n return type != null && this.measurableEntityTypes.includes(type);\n }\n\n private measureEntityUnderPointer(event: PointerEvent): void {\n this.ifInitialized(async ({ api }) => {\n const pt = getMouseClientPosition(event, this.elementRect);\n const [hit] = await api.hitItems(pt);\n const entity = hit != null ? MeasurementEntity.fromHit(hit) : undefined;\n\n if (entity != null) {\n await this.controller.addEntity(entity);\n } else {\n await this.controller.clearEntities();\n }\n });\n }\n\n protected ifInitialized<R>(\n f: (data: { element: HTMLElement; api: InteractionApi }) => R\n ): R {\n if (this.element != null && this.api != null) {\n return f({ element: this.element, api: this.api });\n } else {\n throw new Error('Measurement interaction handler not initialized.');\n }\n }\n\n protected ifNoInteraction(\n event: PointerEvent,\n f: () => void | Promise<void>\n ): void {\n const startPos = Point.create(event.clientX, event.clientY);\n let didInteract = false;\n\n const handleMouseMove = (event: PointerEvent): void => {\n const pos = Point.create(event.clientX, event.clientY);\n const dis = Point.distance(startPos, pos);\n didInteract = dis > 2;\n };\n\n const handleMouseUp = (): void => {\n window.removeEventListener('pointermove', handleMouseMove);\n window.removeEventListener('pointerup', handleMouseUp);\n\n if (!didInteract) {\n f();\n }\n };\n\n window.addEventListener('pointermove', handleMouseMove);\n window.addEventListener('pointerup', handleMouseUp);\n }\n}\n",":host {\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n pointer-events: none;\n}\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Component, h, Host, JSX, Prop, State, Watch } from '@stencil/core';\nimport { SceneViewAPIClient } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb_service';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { parseAndValidateConfig, PartialConfig } from '../../lib/config';\nimport { Environment } from '../../lib/environment';\nimport {\n MeasurementController,\n MeasurementModel,\n MeasurementOverlayManager,\n} from '../../lib/measurement';\nimport { MeasurementInteractionHandler } from '../../lib/measurement/interactions';\nimport { EntityType } from '../../lib/types';\n\n@Component({\n tag: 'vertex-viewer-measurement-precise',\n styleUrl: 'viewer-measurement-precise.css',\n shadow: true,\n})\nexport class ViewerMeasurementPrecise {\n /**\n * The model that contains the entities and outcomes from performing precise\n * measurements.\n */\n @Prop()\n public measurementModel: MeasurementModel = new MeasurementModel();\n\n /**\n * The manager that is responsible for measurement overlays to present by this\n * component.\n */\n @Prop()\n public measurementOverlays: MeasurementOverlayManager =\n new MeasurementOverlayManager();\n\n /**\n * The controller that is responsible for performing measurements and updating\n * the model.\n */\n @Prop({ mutable: true })\n public measurementController?: MeasurementController;\n\n /**\n * @internal\n *\n * An internal property that can be used to opt-in to performing measurements\n * on other types of entities.\n */\n @Prop()\n public measurableEntityTypes: EntityType[] = [\n EntityType.PRECISE_SURFACE,\n EntityType.IMPRECISE_SURFACE,\n ];\n\n /**\n * The viewer that this component is bound to. This is automatically assigned\n * if added to the light-dom of a parent viewer element.\n */\n @Prop()\n public viewer?: HTMLVertexViewerElement;\n\n /**\n * The environment that will be used to request measurement results.\n */\n @Prop()\n public configEnv: Environment = 'platprod';\n\n /**\n * An optional configuration to setup network configuration of measurement\n * endpoints.\n */\n @Prop()\n public config?: PartialConfig | string;\n\n private registeredInteractionHandler?: Promise<Disposable>;\n\n /**\n * @ignore\n */\n protected connectedCallback(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n protected componentWillLoad(): void {\n this.setupController();\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n protected disconnectedCallback(): void {\n this.clearInteractionHandler();\n }\n\n /**\n * @ignore\n */\n @Watch('measurableEntityTypes')\n protected handleMeasurableEntityTypesChanged(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n @Watch('measurementController')\n protected handleMeasurementControllerChanged(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n @Watch('measurementModel')\n protected handleMeasurementModelChanged(): void {\n this.setupController();\n }\n\n /**\n * @ignore\n */\n @Watch('viewer')\n protected handleViewerChanged(): void {\n this.setupInteractionHandler();\n }\n\n /**\n * @ignore\n */\n protected render(): JSX.Element {\n return (\n <Host>\n <vertex-viewer-measurement-overlays\n viewer={this.viewer}\n measurementOverlays={this.measurementOverlays}\n />\n </Host>\n );\n }\n\n private setupController(): void {\n const config = parseAndValidateConfig(this.configEnv, this.config);\n const client = new SceneViewAPIClient(config.network.sceneViewHost);\n this.measurementController = new MeasurementController(\n this.measurementModel,\n client,\n () => this.viewer?.token,\n this.viewer?.deviceId\n );\n }\n\n private clearInteractionHandler(): void {\n this.registeredInteractionHandler?.then((handler) => handler.dispose());\n this.registeredInteractionHandler = undefined;\n }\n\n private setupInteractionHandler(): void {\n this.clearInteractionHandler();\n\n if (this.measurementController != null) {\n this.registeredInteractionHandler =\n this.viewer?.registerInteractionHandler(\n new MeasurementInteractionHandler(\n this.measurementController,\n this.measurableEntityTypes\n )\n );\n }\n }\n}\n"],"mappings":";;;gkBAWaA,EAWX,eAAYC,GACV,OAAOC,KAAKC,aAAaC,I,CAG3B,WAAAC,CACEC,EACAC,GAPML,KAAAC,aAAe,IAAIK,EA4CnBN,KAAAO,kBAAoBC,MAAOC,IACjC,SAAUT,KAAKU,+BAA+BD,GAAQ,CACpDT,KAAKW,cACLX,KAAKY,UAAUC,E,KACV,CACLb,KAAKW,a,GAIDX,KAAAc,kBAAqBL,IAC3BT,KAAKe,gBAAgBN,GAAOD,UAC1B,SAAUR,KAAKU,+BAA+BD,GAAQ,CACpDT,KAAKgB,0BAA0BP,E,KAC1B,OACCT,KAAKI,WAAWa,e,IAExB,EAnDFjB,KAAKI,WAAaA,EAClBJ,KAAKK,sBAAwBA,C,CAGxB,UAAAa,CAAWC,EAAsBC,GACtCpB,KAAKmB,QAAUA,EACfnB,KAAKoB,IAAMA,EAEXpB,KAAKC,aAAaoB,QAAQF,GAE1BA,EAAQG,iBAAiB,cAAetB,KAAKO,mBAC7CY,EAAQG,iBAAiB,cAAetB,KAAKc,kB,CAGxC,OAAAS,G,UACLvB,KAAKC,aAAauB,cAClBC,EAAAzB,KAAK0B,0BAAsB,MAAAD,SAAA,SAAAA,EAAEF,UAC7BvB,KAAKW,eAELgB,EAAA3B,KAAKmB,WAAO,MAAAQ,SAAA,SAAAA,EAAEC,oBAAoB,cAAe5B,KAAKO,oBACtDsB,EAAA7B,KAAKmB,WAAO,MAAAU,SAAA,SAAAA,EAAED,oBAAoB,cAAe5B,KAAKc,mBAEtDd,KAAKmB,QAAUW,UACf9B,KAAKoB,IAAMU,S,CAGL,SAAAlB,CAAUmB,GAChB/B,KAAK+B,OAAS/B,KAAKgC,eAAc,EAAGZ,SAAUA,EAAIR,UAAUmB,I,CAGtD,WAAApB,G,OACNc,EAAAzB,KAAK+B,UAAM,MAAAN,SAAA,SAAAA,EAAEF,UACbvB,KAAK+B,OAASD,S,CAsBR,oCAAMpB,CACZD,G,MAEA,MAAMwB,EAAKC,EAAuBzB,EAAOT,KAAKD,aAC9C,MAAMoC,SAAaV,EAAAzB,KAAKoB,OAAG,MAAAK,SAAA,SAAAA,EAAEW,qBAAqBH,IAClD,OAAOE,GAAQ,MAAQnC,KAAKK,sBAAsBgC,SAASF,E,CAGrD,yBAAAnB,CAA0BP,GAChCT,KAAKgC,eAAcxB,OAASY,UAC1B,MAAMa,EAAKC,EAAuBzB,EAAOT,KAAKD,aAC9C,MAAOuC,SAAalB,EAAImB,SAASN,GACjC,MAAMO,EAASF,GAAO,KAAOG,EAAkBC,QAAQJ,GAAOR,UAE9D,GAAIU,GAAU,KAAM,OACZxC,KAAKI,WAAWuC,UAAUH,E,KAC3B,OACCxC,KAAKI,WAAWa,e,KAKlB,aAAAe,CACRY,GAEA,GAAI5C,KAAKmB,SAAW,MAAQnB,KAAKoB,KAAO,KAAM,CAC5C,OAAOwB,EAAE,CAAEzB,QAASnB,KAAKmB,QAASC,IAAKpB,KAAKoB,K,KACvC,CACL,MAAM,IAAIyB,MAAM,mD,EAIV,eAAA9B,CACRN,EACAmC,GAEA,MAAME,EAAWC,EAAMC,OAAOvC,EAAMwC,QAASxC,EAAMyC,SACnD,IAAIC,EAAc,MAElB,MAAMC,EAAmB3C,IACvB,MAAM4C,EAAMN,EAAMC,OAAOvC,EAAMwC,QAASxC,EAAMyC,SAC9C,MAAMI,EAAMP,EAAMQ,SAAST,EAAUO,GACrCF,EAAcG,EAAM,CAAC,EAGvB,MAAME,EAAgB,KACpBC,OAAO7B,oBAAoB,cAAewB,GAC1CK,OAAO7B,oBAAoB,YAAa4B,GAExC,IAAKL,EAAa,CAChBP,G,GAIJa,OAAOnC,iBAAiB,cAAe8B,GACvCK,OAAOnC,iBAAiB,YAAakC,E,EC3IzC,MAAME,EAA8B,IAAM,2F,MCoB7BC,EAAwBC,EAAA,MAAAD,UAAAE,EALrC,WAAA1D,CAAA2D,G,kEAWS9D,KAAA+D,iBAAqC,IAAIC,EAOzChE,KAAAiE,oBACL,IAAIC,EAgBClE,KAAAK,sBAAsC,CAC3C8D,EAAWC,gBACXD,EAAWE,mBAcNrE,KAAAsE,UAAyB,UA4GjC,CA9FW,iBAAAC,GACRvE,KAAKwE,yB,CAMG,iBAAAC,GACRzE,KAAK0E,kBACL1E,KAAKwE,yB,CAMG,oBAAAG,GACR3E,KAAK4E,yB,CAOG,kCAAAC,GACR7E,KAAKwE,yB,CAOG,kCAAAM,GACR9E,KAAKwE,yB,CAOG,6BAAAO,GACR/E,KAAK0E,iB,CAOG,mBAAAM,GACRhF,KAAKwE,yB,CAMG,MAAAS,GACR,OACEC,EAACC,EAAI,CAAAC,IAAA,4CACHF,EAAA,sCAAAE,IAAA,2CACEC,OAAQrF,KAAKqF,OACbpB,oBAAqBjE,KAAKiE,sB,CAM1B,eAAAS,G,MACN,MAAMY,EAASC,EAAuBvF,KAAKsE,UAAWtE,KAAKsF,QAC3D,MAAME,EAAS,IAAIC,qBAAmBH,EAAOI,QAAQC,eACrD3F,KAAK4F,sBAAwB,IAAIC,EAC/B7F,KAAK+D,iBACLyB,GACA,KAAK,IAAA/D,EAAC,OAAAA,EAAAzB,KAAKqF,UAAM,MAAA5D,SAAA,SAAAA,EAAEqE,KAAK,IACxBrE,EAAAzB,KAAKqF,UAAM,MAAA5D,SAAA,SAAAA,EAAEsE,S,CAIT,uBAAAnB,G,OACNnD,EAAAzB,KAAKgG,gCAA4B,MAAAvE,SAAA,SAAAA,EAAEwE,MAAMC,GAAYA,EAAQ3E,YAC7DvB,KAAKgG,6BAA+BlE,S,CAG9B,uBAAA0C,G,MACNxE,KAAK4E,0BAEL,GAAI5E,KAAK4F,uBAAyB,KAAM,CACtC5F,KAAKgG,8BACHvE,EAAAzB,KAAKqF,UAAM,MAAA5D,SAAA,SAAAA,EAAE0E,2BACX,IAAIrG,EACFE,KAAK4F,sBACL5F,KAAKK,uB","ignoreList":[]}
|
|
@@ -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-BygjJ1WP.js";const t=o;const p=s;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-DmsAWRoU.js";import{a as o,d as l,P as r}from"./p-CtymEaB-.js";import{p as h}from"./p-Tvs4yxd5.js";import{b as d}from"./p-BZtylp5V.js";import{l as a,p as u}from"./p-Bn7QEZYW.js";import{g as v}from"./p-BSYTUXcE.js";import{E as c}from"./p-CFus3r7d.js";import{E as p}from"./p-JSB7V_jW.js";import{P as f}from"./p-Ccd2Gd94.js";import{g as m}from"./p-Bg-uS9BH.js";import{d as w}from"./p-x3bWmPis.js";import{d as C}from"./p-Lx4iaHhY.js";import{d as b}from"./p-nGQgu0fu.js";import{d as y}from"./p-DSeOWYJ_.js";import{d as g}from"./p-cA2Urxsr.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:"311442b0cc3d62c485b81526fde10692b560af93"},s("vertex-viewer-dom-renderer",{key:"e4fe9d022a717db444590a6c2d2239d233bbe2ce",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 E(){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}}))}E();const k=j;const B=E;export{k as VertexViewerPinTool,B as defineCustomElement};
|
|
4
|
+
import{t as i,p as t,H as e,h as s,e as n}from"./p-DmsAWRoU.js";import{a as o,d as l,P as r}from"./p-CtymEaB-.js";import{p as h}from"./p-Tvs4yxd5.js";import{b as d}from"./p-BZtylp5V.js";import{l as a,p as u}from"./p-Bn7QEZYW.js";import{g as v}from"./p-BSYTUXcE.js";import{E as c}from"./p-CFus3r7d.js";import{E as p}from"./p-DLV-gg65.js";import{P as f}from"./p-Ccd2Gd94.js";import{g as m}from"./p-Bg-uS9BH.js";import{d as w}from"./p-x3bWmPis.js";import{d as C}from"./p-CYhNWr6k.js";import{d as b}from"./p-nGQgu0fu.js";import{d as y}from"./p-BygjJ1WP.js";import{d as g}from"./p-cA2Urxsr.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:"311442b0cc3d62c485b81526fde10692b560af93"},s("vertex-viewer-dom-renderer",{key:"e4fe9d022a717db444590a6c2d2239d233bbe2ce",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 E(){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}}))}E();const k=j;const B=E;export{k as VertexViewerPinTool,B 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-DmsAWRoU.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-Tvs4yxd5.js";import{c as g}from"./p-C6gMOKYg.js";import{w as x,r as y}from"./p-Ss6piqGD.js";import{T as b}from"./p-B6pxBmYG.js";import{A as m,D as z}from"./p-JSB7V_jW.js";import{E as T}from"./p-BZtylp5V.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 F,z as H,f as N,g as O,h as j,i as M,j as $}from"./p-BhgrvpJL.js";function k(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 J(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 _(i,t,s,n,o,l){return u.multiply(i,q(t,s,n,o,l))}function q(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.makeRotation(f.fromAxisAngle(h.left(),a()));case"y-rotate":return u.makeRotation(f.fromAxisAngle(h.down(),a()));case"z-rotate":return u.makeRotation(f.fromAxisAngle(h.forward(),a()));default:return u.makeIdentity()}}function L(i){switch(i){case"x-rotate":return"xyz";case"y-rotate":return"yzx";case"z-rotate":return"zxy";default:return"xyz"}}function V(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(t,u.invert(s));const c=()=>h.transformMatrix(h.fromMatrixPosition(r()),u.invert(a()));const w=()=>v.fromRotationMatrix(u.multiply(u.invert(a()),s),L(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 K(i,t,s,n,o,l){return X(i,h.subtract(s,t),n,o,l)}function X(i,t,s,n,o){switch(o){case"x-translate":return G(i,t,h.right());case"y-translate":return G(i,t,h.up());case"z-translate":return G(i,t,h.back());case"xy-translate":return W(i,t,h.create(0,0,1));case"xz-translate":return W(i,t,h.create(0,1,0));case"yz-translate":return W(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.makeRotation(l);return u.multiply(i,e)}function Z(i,t,s){const n=u.makeRotation(f.fromMatrixRotation(i));const o=h.transformMatrix(s,n);const l=h.transformMatrix(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function G(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.transformMatrix(n,o);const e=h.project(t,l);const a=u.makeTranslation(e);return u.multiply(a,i)}function W(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.transformMatrix(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(c,i)}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=parseFloat(i.target.value);if(!isNaN(t)){o===null||o===void 0?void 0:o(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.transformMatrix(h.add(s,n),u.makeRotation(f.fromMatrixRotation(i)));const v=h.transformMatrix(s,u.makeRotation(f.fromMatrixRotation(i)));const c=h.transformMatrix(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.transformMatrix(m,t.projectionViewMatrix),h.transformMatrix(C,t.projectionViewMatrix),h.transformMatrix(z,t.projectionViewMatrix),h.transformMatrix(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!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",F(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",N(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=M(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=M(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=M(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=M(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=M(s.scene.camera,this.zRotation,(a=this.xArrow)===null||a===void 0?void 0:a.points.worldTip,d);const p=M(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,S,E,I,$,k;const B=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(A(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(F(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(M(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(M(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(M(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(M(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(M(t.scene.camera,this.zRotation,(P=this.xArrow)===null||P===void 0?void 0:P.points.worldTip,B));(S=this.zyRotationLine)===null||S===void 0?void 0:S.updatePoints(M(t.scene.camera,this.zRotation,(E=this.yArrow)===null||E===void 0?void 0:E.points.worldTip,B));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(N(i,t.scene.camera,B,(I=this.customization.scalars)===null||I===void 0?void 0:I.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(O(i,t.scene.camera,B,($=this.customization.scalars)===null||$===void 0?void 0:$.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(j(i,t.scene.camera,B,(k=this.customization.scalars)===null||k===void 0?void 0:k.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=J(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=J(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=_(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(this.currentTransform,u.invert(this.startingTransform))));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=V(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=`${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.makeRotation(f.fromMatrixRotation(t));const n=u.makeTranslation(i);return u.multiply(n,s)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:u.makeIdentity();const s=u.invert(u.makeRotation(f.fromMatrixRotation(t)));const n=u.makeRotation(f.fromEuler(i));const o=u.multiply(t,s);return u.multiply(o,n)};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){k(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(s,this.currentTransform);(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:"cf84e5bc2f1ab1878b131f3cd9be1548a5c82646"},i("canvas",{key:"255699b0cb6a07ab8be50f0c81e0b7df5feb9719",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:"5fa899a22f96025973a53defc673e9e9650d5ef4",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:"db03509252b8e72fb975337274e693cc4d0bebf1",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=K(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(this.currentTransform,u.invert(this.startingTransform)))}}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-DmsAWRoU.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-Tvs4yxd5.js";import{c as g}from"./p-C6gMOKYg.js";import{w as x,r as y}from"./p-Ss6piqGD.js";import{T as b}from"./p-B6pxBmYG.js";import{A as m,D as z}from"./p-DLV-gg65.js";import{E as T}from"./p-BZtylp5V.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 F,z as H,f as N,g as O,h as M,i as $,j}from"./p-BLSuslo8.js";function k(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 L(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 q(i,t,s,n,o,l){return u.multiply(i,V(t,s,n,o,l))}function V(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.makeRotation(f.fromAxisAngle(h.left(),a()));case"y-rotate":return u.makeRotation(f.fromAxisAngle(h.down(),a()));case"z-rotate":return u.makeRotation(f.fromAxisAngle(h.forward(),a()));default:return u.makeIdentity()}}function _(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(t,u.invert(s));const c=()=>h.transformMatrix(h.fromMatrixPosition(r()),u.invert(a()));const w=()=>v.fromRotationMatrix(u.multiply(u.invert(a()),s),_(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 K(i,t,s,n,o,l){return X(i,h.subtract(s,t),n,o,l)}function X(i,t,s,n,o){switch(o){case"x-translate":return G(i,t,h.right());case"y-translate":return G(i,t,h.up());case"z-translate":return G(i,t,h.back());case"xy-translate":return W(i,t,h.create(0,0,1));case"xz-translate":return W(i,t,h.create(0,1,0));case"yz-translate":return W(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.makeRotation(l);return u.multiply(i,e)}function Z(i,t,s){const n=u.makeRotation(f.fromMatrixRotation(i));const o=h.transformMatrix(s,n);const l=h.transformMatrix(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function G(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.transformMatrix(n,o);const e=h.project(t,l);const a=u.makeTranslation(e);return u.multiply(a,i)}function W(i,t,s){const n=h.normalize(s);const o=u.makeRotation(f.fromMatrixRotation(i));const l=h.transformMatrix(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(c,i)}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=parseFloat(i.target.value);if(!isNaN(t)){o===null||o===void 0?void 0:o(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.transformMatrix(h.add(s,n),u.makeRotation(f.fromMatrixRotation(i)));const v=h.transformMatrix(s,u.makeRotation(f.fromMatrixRotation(i)));const c=h.transformMatrix(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.transformMatrix(m,t.projectionViewMatrix),h.transformMatrix(C,t.projectionViewMatrix),h.transformMatrix(z,t.projectionViewMatrix),h.transformMatrix(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!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",F(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",N(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",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=$(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=$(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=$(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=$(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=$(s.scene.camera,this.zRotation,(a=this.xArrow)===null||a===void 0?void 0:a.points.worldTip,d);const p=$(s.scene.camera,this.zRotation,(r=this.yArrow)===null||r===void 0?void 0:r.points.worldTip,d);if(u!=null){this.xyRotationLine=new j(i,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new j(i,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new j(i,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new j(i,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new j(i,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new j(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,j,k;const B=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(A(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(F(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($(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($(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($(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($(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($(t.scene.camera,this.zRotation,(P=this.xArrow)===null||P===void 0?void 0:P.points.worldTip,B));(S=this.zyRotationLine)===null||S===void 0?void 0:S.updatePoints($(t.scene.camera,this.zRotation,(E=this.yArrow)===null||E===void 0?void 0:E.points.worldTip,B));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(N(i,t.scene.camera,B,(I=this.customization.scalars)===null||I===void 0?void 0:I.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(O(i,t.scene.camera,B,(j=this.customization.scalars)===null||j===void 0?void 0:j.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(M(i,t.scene.camera,B,(k=this.customization.scalars)===null||k===void 0?void 0:k.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(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=L(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=q(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(this.currentTransform,u.invert(this.startingTransform))));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=`${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.makeRotation(f.fromMatrixRotation(t));const n=u.makeTranslation(i);return u.multiply(n,s)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:u.makeIdentity();const s=u.invert(u.makeRotation(f.fromMatrixRotation(t)));const n=u.makeRotation(f.fromEuler(i));const o=u.multiply(t,s);return u.multiply(o,n)};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){k(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(s,this.currentTransform);(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:"cf84e5bc2f1ab1878b131f3cd9be1548a5c82646"},i("canvas",{key:"255699b0cb6a07ab8be50f0c81e0b7df5feb9719",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:"5fa899a22f96025973a53defc673e9e9650d5ef4",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:"db03509252b8e72fb975337274e693cc4d0bebf1",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=K(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(this.currentTransform,u.invert(this.startingTransform)))}}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
|