@vertexvis/viewer 1.1.1-testing.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +5 -3
- package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js.map +1 -1
- package/dist/cjs/vertex-viewer-walk-mode-tool.cjs.entry.js +15 -11
- package/dist/cjs/vertex-viewer-walk-mode-tool.cjs.entry.js.map +1 -1
- package/dist/cjs/vertex-viewer.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer.cjs.entry.js.map +1 -1
- package/dist/collection/components/viewer/viewer.js +4 -4
- package/dist/collection/components/viewer/viewer.js.map +1 -1
- package/dist/collection/components/viewer-transform-widget/viewer-transform-widget.js +30 -4
- package/dist/collection/components/viewer-transform-widget/viewer-transform-widget.js.map +1 -1
- package/dist/collection/components/viewer-walk-mode-tool/viewer-walk-mode-tool.js +15 -11
- package/dist/collection/components/viewer-walk-mode-tool/viewer-walk-mode-tool.js.map +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-walk-mode-tool.js +1 -1
- package/dist/components/vertex-viewer-walk-mode-tool.js.map +1 -1
- package/dist/components/vertex-viewer.js +1 -1
- package/dist/components/vertex-viewer.js.map +1 -1
- package/dist/esm/vertex-viewer-transform-widget.entry.js +5 -3
- package/dist/esm/vertex-viewer-transform-widget.entry.js.map +1 -1
- package/dist/esm/vertex-viewer-walk-mode-tool.entry.js +15 -11
- package/dist/esm/vertex-viewer-walk-mode-tool.entry.js.map +1 -1
- package/dist/esm/vertex-viewer.entry.js +3 -3
- package/dist/esm/vertex-viewer.entry.js.map +1 -1
- package/dist/types/components/viewer/viewer.d.ts +1 -1
- package/dist/types/components/viewer-transform-widget/viewer-transform-widget.d.ts +5 -0
- package/dist/types/components/viewer-walk-mode-tool/viewer-walk-mode-tool.d.ts +4 -3
- package/dist/types/components.d.ts +7 -2
- package/dist/viewer/{p-fe47182d.entry.js → p-8e6d8e69.entry.js} +2 -2
- package/dist/viewer/{p-fe47182d.entry.js.map → p-8e6d8e69.entry.js.map} +1 -1
- package/dist/viewer/{p-3c5dd716.entry.js → p-d5499fe6.entry.js} +2 -2
- package/dist/viewer/p-d5499fe6.entry.js.map +1 -0
- package/dist/viewer/{p-12c199c0.entry.js → p-f6f57157.entry.js} +2 -2
- package/dist/viewer/p-f6f57157.entry.js.map +1 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +7 -7
- package/readme.md +4 -4
- package/dist/viewer/p-12c199c0.entry.js.map +0 -1
- package/dist/viewer/p-3c5dd716.entry.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as i,h as s,H as h,a as e}from"./p-CCVkga9Q.js";import{V as o,W as n,a as l}from"./p-ipyYHvea.js";import{v as a}from"./p-2UsvOTHJ.js";import"./p-CDM7zNn0.js";import"./p-CG9AChtV.js";function d(t){return t instanceof Element}class r{constructor(t){this.model=t;this.pressed={};this.handleKeyUp=async t=>{const i=t.key.toLocaleLowerCase();this.pressed=Object.keys(this.pressed).filter((t=>t!==i)).reduce(((t,i)=>({...t,[i]:true})),{});if(Object.keys(this.pressed).length===0&&this.interval!=null){this.endInteraction()}};this.endInteraction=async()=>{var t;this.clearInterval();await((t=this.api)===null||t===void 0?void 0:t.endInteraction())};this.handleKeyDown=this.handleKeyDown.bind(this);this.handleKeyUp=this.handleKeyUp.bind(this);this.handleEnabledChange=this.handleEnabledChange.bind(this);this.restartInteraction=this.restartInteraction.bind(this);this.updateCamera=this.updateCamera.bind(this);this.handlers={[o.MOVE_DOWN]:this.moveDown.bind(this),[o.MOVE_UP]:this.moveUp.bind(this),[o.PIVOT_DOWN]:this.pivotDown.bind(this),[o.PIVOT_LEFT]:this.pivotLeft.bind(this),[o.PIVOT_RIGHT]:this.pivotRight.bind(this),[o.PIVOT_UP]:this.pivotUp.bind(this),[o.WALK_BACKWARD]:this.walkBackward.bind(this),[o.WALK_FORWARD]:this.walkForward.bind(this),[o.WALK_LEFT]:this.walkLeft.bind(this),[o.WALK_RIGHT]:this.walkRight.bind(this)};this.enabledChangeDisposable=this.model.onEnabledChange(this.handleEnabledChange);this.keyBindingsChangeDisposable=this.model.onKeyBindingsChange(this.restartInteraction);this.configurationChangeDisposable=this.model.onConfigurationChange(this.restartInteraction)}dispose(){var t,i,s;this.disable();(t=this.enabledChangeDisposable)===null||t===void 0?void 0:t.dispose();(i=this.keyBindingsChangeDisposable)===null||i===void 0?void 0:i.dispose();(s=this.configurationChangeDisposable)===null||s===void 0?void 0:s.dispose();window.removeEventListener("keydown",this.handleKeyDown);window.removeEventListener("keyup",this.handleKeyUp)}initialize(t,i){this.api=i;this.handleEnabledChange(this.model.getEnabled())}enable(){this.disable();window.addEventListener("keydown",this.handleKeyDown);window.addEventListener("keyup",this.handleKeyUp)}disable(){window.removeEventListener("keydown",this.handleKeyDown);window.removeEventListener("keyup",this.handleKeyUp)}handleKeyDown(t){const i=t.key.toLowerCase();const s=d(t.target)&&this.model.isElementExcluded(t.target);if(!t.repeat&&!s){this.pressed={...this.pressed,[i]:true};this.tryBeginInteraction()}}handleEnabledChange(t){if(t){this.enable()}else{this.disable()}}restartInteraction(){this.clearInterval();this.tryBeginInteraction()}tryBeginInteraction(){if(Object.keys(this.pressed).length>0&&this.someOperationMatches()){this.beginInteraction()}}beginInteraction(){var t,i;if(!((t=this.api)===null||t===void 0?void 0:t.isInteracting())){(i=this.api)===null||i===void 0?void 0:i.beginInteraction()}if(this.interval==null){this.interval=setInterval(this.updateCamera,this.model.getKeyboardRepeatInterval())}}clearInterval(){if(this.interval!=null){clearInterval(this.interval);this.interval=undefined}}updateCamera(){Object.keys(this.handlers).forEach((t=>{const i=t;if(this.model.operationMatches(i,this.pressed)){this.handlers[i]()}}))}someOperationMatches(){return Object.keys(this.handlers).some((t=>this.model.operationMatches(t,this.pressed)))}pivotLeft(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(0,this.model.getKeyboardPivotDegrees())}pivotRight(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(0,-this.model.getKeyboardPivotDegrees())}pivotUp(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(-this.model.getKeyboardPivotDegrees(),0)}pivotDown(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(this.model.getKeyboardPivotDegrees(),0)}walkForward(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.forward()))}walkBackward(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.back()))}walkLeft(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.left()))}walkRight(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.right()))}moveUp(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.down()))}moveDown(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.up()))}relativeWalkSpeed(){return this.model.getKeyboardWalkSpeed()/500}}const v=()=>`:host{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}`;const u=class{constructor(s){t(this,s);this.controllerChanged=i(this,"controllerChanged");this.model=new n;this.enabled=true;this.stateMap={}}componentWillLoad(){this.setupController();this.setupInteractionHandler()}async componentDidLoad(){await this.ensureTeleportToolConfigured();this.updateTeleportTool();await this.setPivotInteractionMode()}connectedCallback(){this.setupInteractionHandler();this.setPivotInteractionMode()}disconnectedCallback(){this.clearInteractionHandler();this.resetInteractionMode()}handleEnabledChanged(){var t;(t=this.controller)===null||t===void 0?void 0:t.setEnabled(this.enabled);this.toggleInteractionMode()}handleViewerChanged(){this.clearInteractionHandler();this.setupInteractionHandler();this.updateTeleportTool();this.toggleInteractionMode()}handleTeleportModeChanged(){this.updateTeleportTool()}handleControllerChanged(){this.updateTeleportTool();this.controllerChanged.emit(this.controller)}handleModelChanged(){this.setupController();this.clearInteractionHandler();this.setupInteractionHandler()}render(){return s(h,{key:"
|
|
5
|
-
//# sourceMappingURL=p-
|
|
4
|
+
import{r as t,c as i,h as s,H as h,a as e}from"./p-CCVkga9Q.js";import{V as o,W as n,a as l}from"./p-ipyYHvea.js";import{v as a}from"./p-2UsvOTHJ.js";import"./p-CDM7zNn0.js";import"./p-CG9AChtV.js";function d(t){return t instanceof Element}class r{constructor(t){this.model=t;this.pressed={};this.handleKeyUp=async t=>{const i=t.key.toLocaleLowerCase();this.pressed=Object.keys(this.pressed).filter((t=>t!==i)).reduce(((t,i)=>({...t,[i]:true})),{});if(Object.keys(this.pressed).length===0&&this.interval!=null){this.endInteraction()}};this.endInteraction=async()=>{var t;this.clearInterval();await((t=this.api)===null||t===void 0?void 0:t.endInteraction())};this.handleKeyDown=this.handleKeyDown.bind(this);this.handleKeyUp=this.handleKeyUp.bind(this);this.handleEnabledChange=this.handleEnabledChange.bind(this);this.restartInteraction=this.restartInteraction.bind(this);this.updateCamera=this.updateCamera.bind(this);this.handlers={[o.MOVE_DOWN]:this.moveDown.bind(this),[o.MOVE_UP]:this.moveUp.bind(this),[o.PIVOT_DOWN]:this.pivotDown.bind(this),[o.PIVOT_LEFT]:this.pivotLeft.bind(this),[o.PIVOT_RIGHT]:this.pivotRight.bind(this),[o.PIVOT_UP]:this.pivotUp.bind(this),[o.WALK_BACKWARD]:this.walkBackward.bind(this),[o.WALK_FORWARD]:this.walkForward.bind(this),[o.WALK_LEFT]:this.walkLeft.bind(this),[o.WALK_RIGHT]:this.walkRight.bind(this)};this.enabledChangeDisposable=this.model.onEnabledChange(this.handleEnabledChange);this.keyBindingsChangeDisposable=this.model.onKeyBindingsChange(this.restartInteraction);this.configurationChangeDisposable=this.model.onConfigurationChange(this.restartInteraction)}dispose(){var t,i,s;this.disable();(t=this.enabledChangeDisposable)===null||t===void 0?void 0:t.dispose();(i=this.keyBindingsChangeDisposable)===null||i===void 0?void 0:i.dispose();(s=this.configurationChangeDisposable)===null||s===void 0?void 0:s.dispose();window.removeEventListener("keydown",this.handleKeyDown);window.removeEventListener("keyup",this.handleKeyUp)}initialize(t,i){this.api=i;this.handleEnabledChange(this.model.getEnabled())}enable(){this.disable();window.addEventListener("keydown",this.handleKeyDown);window.addEventListener("keyup",this.handleKeyUp)}disable(){window.removeEventListener("keydown",this.handleKeyDown);window.removeEventListener("keyup",this.handleKeyUp)}handleKeyDown(t){const i=t.key.toLowerCase();const s=d(t.target)&&this.model.isElementExcluded(t.target);if(!t.repeat&&!s){this.pressed={...this.pressed,[i]:true};this.tryBeginInteraction()}}handleEnabledChange(t){if(t){this.enable()}else{this.disable()}}restartInteraction(){this.clearInterval();this.tryBeginInteraction()}tryBeginInteraction(){if(Object.keys(this.pressed).length>0&&this.someOperationMatches()){this.beginInteraction()}}beginInteraction(){var t,i;if(!((t=this.api)===null||t===void 0?void 0:t.isInteracting())){(i=this.api)===null||i===void 0?void 0:i.beginInteraction()}if(this.interval==null){this.interval=setInterval(this.updateCamera,this.model.getKeyboardRepeatInterval())}}clearInterval(){if(this.interval!=null){clearInterval(this.interval);this.interval=undefined}}updateCamera(){Object.keys(this.handlers).forEach((t=>{const i=t;if(this.model.operationMatches(i,this.pressed)){this.handlers[i]()}}))}someOperationMatches(){return Object.keys(this.handlers).some((t=>this.model.operationMatches(t,this.pressed)))}pivotLeft(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(0,this.model.getKeyboardPivotDegrees())}pivotRight(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(0,-this.model.getKeyboardPivotDegrees())}pivotUp(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(-this.model.getKeyboardPivotDegrees(),0)}pivotDown(){var t;(t=this.api)===null||t===void 0?void 0:t.pivotCamera(this.model.getKeyboardPivotDegrees(),0)}walkForward(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.forward()))}walkBackward(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.back()))}walkLeft(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.left()))}walkRight(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.right()))}moveUp(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.down()))}moveDown(){var t;(t=this.api)===null||t===void 0?void 0:t.walk(a.scale(this.relativeWalkSpeed(),a.up()))}relativeWalkSpeed(){return this.model.getKeyboardWalkSpeed()/500}}const v=()=>`:host{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}`;const u=class{constructor(s){t(this,s);this.controllerChanged=i(this,"controllerChanged");this.model=new n;this.enabled=true;this.stateMap={};this.initialized=false}async componentWillLoad(){this.setupController();await this.setupInteractionHandler();this.initialized=true}async componentDidLoad(){await this.ensureTeleportToolConfigured();this.updateTeleportTool();await this.setPivotInteractionMode()}async connectedCallback(){if(this.initialized){await this.setupInteractionHandler();await this.setPivotInteractionMode()}}async disconnectedCallback(){this.clearInteractionHandler();await this.resetInteractionMode()}handleEnabledChanged(){var t;(t=this.controller)===null||t===void 0?void 0:t.setEnabled(this.enabled);this.toggleInteractionMode()}handleViewerChanged(){this.clearInteractionHandler();this.setupInteractionHandler();this.updateTeleportTool();this.toggleInteractionMode()}handleTeleportModeChanged(){this.updateTeleportTool()}handleControllerChanged(){this.updateTeleportTool();this.controllerChanged.emit(this.controller)}handleModelChanged(){this.setupController();this.clearInteractionHandler();this.setupInteractionHandler()}render(){return s(h,{key:"5e65721572b7affda44f4b74baa1d96ad31154ae"},s("slot",{key:"d3f9594035209606bd95d61f2b7d036f05295a74",name:"teleport-tool",onSlotchange:async()=>{await this.ensureTeleportToolConfigured();this.updateTeleportTool()}}))}setupController(){if(this.controller==null){this.controller=new l(this.model);this.controllerChanged.emit(this.controller)}else{this.controller.updateModel(this.model)}}clearInteractionHandler(){var t,i;(t=this.interactionHandlerDisposable)===null||t===void 0?void 0:t.dispose();this.interactionHandlerDisposable=undefined;(i=this.interactionHandler)===null||i===void 0?void 0:i.dispose();this.interactionHandler=undefined}async setupInteractionHandler(){var t;if(this.interactionHandler==null){this.interactionHandler=new r(this.model);this.interactionHandlerDisposable=await((t=this.viewer)===null||t===void 0?void 0:t.registerInteractionHandler(this.interactionHandler))}}async ensureTeleportToolConfigured(){var t,i,s;if(this.hostEl!=null){const h=(i=(t=this.hostEl)===null||t===void 0?void 0:t.querySelector('vertex-viewer-teleport-tool[slot="teleport-tool"]'))!==null&&i!==void 0?i:undefined;const e=(h===null||h===void 0?void 0:h.tagName)==="VERTEX-VIEWER-TELEPORT-TOOL"?h:undefined;if(e!=null){this.stateMap.teleportTool=e}else{this.stateMap.teleportTool=document.createElement("vertex-viewer-teleport-tool");this.stateMap.teleportTool.slot="teleport-tool";(s=this.hostEl)===null||s===void 0?void 0:s.appendChild(this.stateMap.teleportTool)}}}updateTeleportTool(){if(this.stateMap.teleportTool!=null){this.stateMap.teleportTool.viewer=this.viewer;this.stateMap.teleportTool.controller=this.controller;this.stateMap.teleportTool.model=this.model;this.stateMap.teleportTool.mode=this.teleportMode}}async toggleInteractionMode(){if(this.enabled){await this.setPivotInteractionMode()}else{await this.resetInteractionMode()}}async setPivotInteractionMode(){var t;const i=await((t=this.viewer)===null||t===void 0?void 0:t.getBaseInteractionHandler());if(this.enabled&&i!=null){const t=i.getPrimaryInteractionType();this.stateMap.previousPrimaryInteractionType=t==="pivot"?this.stateMap.previousPrimaryInteractionType:t;i.setPrimaryInteractionType("pivot")}}async resetInteractionMode(){var t;const i=await((t=this.viewer)===null||t===void 0?void 0:t.getBaseInteractionHandler());if(i!=null&&i.getPrimaryInteractionType()==="pivot"&&this.stateMap.previousPrimaryInteractionType!=null){i.setPrimaryInteractionType(this.stateMap.previousPrimaryInteractionType);this.stateMap.previousPrimaryInteractionType=undefined}}get hostEl(){return e(this)}static get watchers(){return{enabled:[{handleEnabledChanged:0}],viewer:[{handleViewerChanged:0}],teleportMode:[{handleTeleportModeChanged:0}],controller:[{handleControllerChanged:0}],model:[{handleModelChanged:0}]}}};u.style=v();export{u as vertex_viewer_walk_mode_tool};
|
|
5
|
+
//# sourceMappingURL=p-d5499fe6.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["targetIsElement","target","Element","WalkInteractionHandler","constructor","model","this","pressed","handleKeyUp","async","event","key","toLocaleLowerCase","Object","keys","filter","k","reduce","length","interval","endInteraction","clearInterval","_a","api","handleKeyDown","bind","handleEnabledChange","restartInteraction","updateCamera","handlers","ViewerWalkModeOperation","MOVE_DOWN","moveDown","MOVE_UP","moveUp","PIVOT_DOWN","pivotDown","PIVOT_LEFT","pivotLeft","PIVOT_RIGHT","pivotRight","PIVOT_UP","pivotUp","WALK_BACKWARD","walkBackward","WALK_FORWARD","walkForward","WALK_LEFT","walkLeft","WALK_RIGHT","walkRight","enabledChangeDisposable","onEnabledChange","keyBindingsChangeDisposable","onKeyBindingsChange","configurationChangeDisposable","onConfigurationChange","dispose","disable","_b","_c","window","removeEventListener","initialize","_","getEnabled","enable","addEventListener","toLowerCase","exclude","isElementExcluded","repeat","tryBeginInteraction","enabled","someOperationMatches","beginInteraction","isInteracting","setInterval","getKeyboardRepeatInterval","undefined","forEach","op","operationMatches","some","pivotCamera","getKeyboardPivotDegrees","walk","Vector3","scale","relativeWalkSpeed","forward","back","left","right","down","up","getKeyboardWalkSpeed","viewerWalkModeToolCss","ViewerWalkModeTool","hostRef","WalkModeModel","stateMap","initialized","componentWillLoad","setupController","setupInteractionHandler","componentDidLoad","ensureTeleportToolConfigured","updateTeleportTool","setPivotInteractionMode","connectedCallback","disconnectedCallback","clearInteractionHandler","resetInteractionMode","handleEnabledChanged","controller","setEnabled","toggleInteractionMode","handleViewerChanged","handleTeleportModeChanged","handleControllerChanged","controllerChanged","emit","handleModelChanged","render","h","Host","name","onSlotchange","WalkModeController","updateModel","interactionHandlerDisposable","interactionHandler","viewer","registerInteractionHandler","hostEl","slotted","querySelector","slottedTeleportTool","tagName","teleportTool","document","createElement","slot","appendChild","mode","teleportMode","baseInteractionHandler","getBaseInteractionHandler","interactionType","getPrimaryInteractionType","previousPrimaryInteractionType","setPrimaryInteractionType"],"sources":["src/lib/walk-mode/dom.ts","src/lib/walk-mode/interactions.ts","src/components/viewer-walk-mode-tool/viewer-walk-mode-tool.css?tag=vertex-viewer-walk-mode-tool&encapsulation=shadow","src/components/viewer-walk-mode-tool/viewer-walk-mode-tool.tsx"],"sourcesContent":["export function targetIsElement(target: EventTarget | null): target is Element {\n return target instanceof Element;\n}\n","import { Vector3 } from '@vertexvis/geometry';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { InteractionApiPerspective, InteractionHandler } from '../interactions';\nimport { targetIsElement } from './dom';\nimport { ViewerWalkModeOperation, WalkModeModel } from './model';\n\nexport class WalkInteractionHandler implements InteractionHandler {\n private api?: InteractionApiPerspective;\n\n private interval?: NodeJS.Timeout;\n private pressed: Record<string, boolean> = {};\n private handlers: Record<ViewerWalkModeOperation, VoidFunction>;\n\n private enabledChangeDisposable?: Disposable;\n private keyBindingsChangeDisposable?: Disposable;\n private configurationChangeDisposable?: Disposable;\n\n public constructor(private model: WalkModeModel) {\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleKeyUp = this.handleKeyUp.bind(this);\n this.handleEnabledChange = this.handleEnabledChange.bind(this);\n this.restartInteraction = this.restartInteraction.bind(this);\n this.updateCamera = this.updateCamera.bind(this);\n\n this.handlers = {\n [ViewerWalkModeOperation.MOVE_DOWN]: this.moveDown.bind(this),\n [ViewerWalkModeOperation.MOVE_UP]: this.moveUp.bind(this),\n [ViewerWalkModeOperation.PIVOT_DOWN]: this.pivotDown.bind(this),\n [ViewerWalkModeOperation.PIVOT_LEFT]: this.pivotLeft.bind(this),\n [ViewerWalkModeOperation.PIVOT_RIGHT]: this.pivotRight.bind(this),\n [ViewerWalkModeOperation.PIVOT_UP]: this.pivotUp.bind(this),\n [ViewerWalkModeOperation.WALK_BACKWARD]: this.walkBackward.bind(this),\n [ViewerWalkModeOperation.WALK_FORWARD]: this.walkForward.bind(this),\n [ViewerWalkModeOperation.WALK_LEFT]: this.walkLeft.bind(this),\n [ViewerWalkModeOperation.WALK_RIGHT]: this.walkRight.bind(this),\n };\n\n this.enabledChangeDisposable = this.model.onEnabledChange(\n this.handleEnabledChange,\n );\n this.keyBindingsChangeDisposable = this.model.onKeyBindingsChange(\n this.restartInteraction,\n );\n this.configurationChangeDisposable = this.model.onConfigurationChange(\n this.restartInteraction,\n );\n }\n\n public dispose(): void {\n this.disable();\n this.enabledChangeDisposable?.dispose();\n this.keyBindingsChangeDisposable?.dispose();\n this.configurationChangeDisposable?.dispose();\n\n window.removeEventListener('keydown', this.handleKeyDown);\n window.removeEventListener('keyup', this.handleKeyUp);\n }\n\n public initialize(_: HTMLElement, api: InteractionApiPerspective): void {\n this.api = api;\n\n this.handleEnabledChange(this.model.getEnabled());\n }\n\n public enable(): void {\n this.disable();\n\n window.addEventListener('keydown', this.handleKeyDown);\n window.addEventListener('keyup', this.handleKeyUp);\n }\n\n public disable(): void {\n window.removeEventListener('keydown', this.handleKeyDown);\n window.removeEventListener('keyup', this.handleKeyUp);\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n const key = event.key.toLowerCase();\n\n const exclude =\n targetIsElement(event.target) &&\n this.model.isElementExcluded(event.target);\n\n if (!event.repeat && !exclude) {\n this.pressed = { ...this.pressed, [key]: true };\n\n this.tryBeginInteraction();\n }\n }\n\n private handleKeyUp = async (event: KeyboardEvent): Promise<void> => {\n const key = event.key.toLocaleLowerCase();\n\n this.pressed = Object.keys(this.pressed)\n .filter((k) => k !== key)\n .reduce((pressed, k) => ({ ...pressed, [k]: true }), {});\n\n if (Object.keys(this.pressed).length === 0 && this.interval != null) {\n this.endInteraction();\n }\n };\n\n private handleEnabledChange(enabled: boolean): void {\n if (enabled) {\n this.enable();\n } else {\n this.disable();\n }\n }\n\n private restartInteraction(): void {\n this.clearInterval();\n this.tryBeginInteraction();\n }\n\n private tryBeginInteraction(): void {\n if (Object.keys(this.pressed).length > 0 && this.someOperationMatches()) {\n this.beginInteraction();\n }\n }\n\n private beginInteraction(): void {\n if (!this.api?.isInteracting()) {\n this.api?.beginInteraction();\n }\n\n if (this.interval == null) {\n this.interval = setInterval(\n this.updateCamera,\n this.model.getKeyboardRepeatInterval(),\n );\n }\n }\n\n private endInteraction = async (): Promise<void> => {\n this.clearInterval();\n await this.api?.endInteraction();\n };\n\n private clearInterval(): void {\n if (this.interval != null) {\n clearInterval(this.interval);\n this.interval = undefined;\n }\n }\n\n private updateCamera(): void {\n Object.keys(this.handlers).forEach((key) => {\n const op = key as ViewerWalkModeOperation;\n\n if (this.model.operationMatches(op, this.pressed)) {\n this.handlers[op]();\n }\n });\n }\n\n private someOperationMatches(): boolean {\n return Object.keys(this.handlers).some((op) =>\n this.model.operationMatches(op as ViewerWalkModeOperation, this.pressed),\n );\n }\n\n private pivotLeft(): void {\n this.api?.pivotCamera(0, this.model.getKeyboardPivotDegrees());\n }\n\n private pivotRight(): void {\n this.api?.pivotCamera(0, -this.model.getKeyboardPivotDegrees());\n }\n\n private pivotUp(): void {\n this.api?.pivotCamera(-this.model.getKeyboardPivotDegrees(), 0);\n }\n\n private pivotDown(): void {\n this.api?.pivotCamera(this.model.getKeyboardPivotDegrees(), 0);\n }\n\n private walkForward(): void {\n this.api?.walk(Vector3.scale(this.relativeWalkSpeed(), Vector3.forward()));\n }\n\n private walkBackward(): void {\n this.api?.walk(Vector3.scale(this.relativeWalkSpeed(), Vector3.back()));\n }\n\n private walkLeft(): void {\n this.api?.walk(Vector3.scale(this.relativeWalkSpeed(), Vector3.left()));\n }\n\n private walkRight(): void {\n this.api?.walk(Vector3.scale(this.relativeWalkSpeed(), Vector3.right()));\n }\n\n private moveUp(): void {\n this.api?.walk(Vector3.scale(this.relativeWalkSpeed(), Vector3.down()));\n }\n\n private moveDown(): void {\n this.api?.walk(Vector3.scale(this.relativeWalkSpeed(), Vector3.up()));\n }\n\n private relativeWalkSpeed(): number {\n return this.model.getKeyboardWalkSpeed() / 500;\n }\n}\n",":host {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n pointer-events: none;\n}\n","import {\n Component,\n Element,\n Event,\n EventEmitter,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n h,\n Host,\n JSX,\n Prop,\n Watch,\n} from '@stencil/core';\nimport { Disposable } from '@vertexvis/utils';\n\nimport { InteractionType } from '../../lib/interactions/baseInteractionHandler';\nimport { WalkModeController } from '../../lib/walk-mode/controller';\nimport { WalkInteractionHandler } from '../../lib/walk-mode/interactions';\nimport { ViewerTeleportMode, WalkModeModel } from '../../lib/walk-mode/model';\n\ninterface StateMap {\n teleportTool?: HTMLVertexViewerTeleportToolElement;\n previousPrimaryInteractionType?: InteractionType;\n}\n\n/**\n * The `<vertex-viewer-walk-mode-tool>` allows for additional interactions\n * intended for walking through a model instead of orbiting a model.\n */\n@Component({\n tag: 'vertex-viewer-walk-mode-tool',\n styleUrl: 'viewer-walk-mode-tool.css',\n shadow: true,\n})\nexport class ViewerWalkModeTool {\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 `WalkModeController` responsible for controlling `KeyBinding`s and excluded\n * elements, as well as updating the `WalkModeModel` with various configuration\n * settings.\n */\n @Prop({ mutable: true })\n public controller?: WalkModeController;\n\n /**\n * The `WalkModeModel` responsible for tracking configuration and emitting\n * events for interaction handlers to respond to.\n */\n @Prop({ mutable: true })\n public model: WalkModeModel = new WalkModeModel();\n\n /**\n * The type of teleportation to perform when clicking. This value is passed through\n * to a `<vertex-viewer-teleport-tool>`'s mode attribute.\n *\n * `teleport` - the camera's `position` is moved to the location of the hit result\n * constrained by the plane represented by the camera's current `position` and `up`\n * vectors.\n *\n * `teleport-and-align` - the camera's `position`, `lookAt`, and `up` vectors are updated\n * to align to the plane represented by the hit result's position and normal.\n *\n * `teleport-toward` - the camera's `position` is moved a fixed distance toward the location of the\n * hit result constrained by the plane represented by the camera's current `position` and `up`\n * vectors.\n *\n * `undefined` - no teleportation will occur when clicking.\n *\n * Defaults to `undefined`.\n */\n @Prop()\n public teleportMode?: ViewerTeleportMode;\n\n /**\n * Determines whether the interaction handlers for this tool should respond to events.\n * When set to `true`, the default viewer interaction mode will be overridden to use the\n * `pivot` camera interaction type, keyboard controls for movement will be added, and\n * setting the `teleportMode` will enable the tool.\n *\n * Defaults to `true`.\n */\n @Prop()\n public enabled = true;\n\n /**\n * Event emitted when the `WalkModeController` associated with this tool changes.\n */\n @Event()\n public controllerChanged!: EventEmitter<WalkModeController>;\n\n @Element()\n private hostEl?: HTMLElement;\n\n private interactionHandlerDisposable?: Disposable;\n private interactionHandler?: WalkInteractionHandler;\n\n private stateMap: StateMap = {};\n\n private initialized = false;\n\n /**\n * @ignore\n */\n protected async componentWillLoad(): Promise<void> {\n this.setupController();\n await this.setupInteractionHandler();\n\n this.initialized = true;\n }\n\n /**\n * @ignore\n */\n protected async componentDidLoad(): Promise<void> {\n await this.ensureTeleportToolConfigured();\n this.updateTeleportTool();\n await this.setPivotInteractionMode();\n }\n\n /**\n * @ignore\n */\n protected async connectedCallback(): Promise<void> {\n if (this.initialized) {\n await this.setupInteractionHandler();\n await this.setPivotInteractionMode();\n }\n }\n\n /**\n * @ignore\n */\n protected async disconnectedCallback(): Promise<void> {\n this.clearInteractionHandler();\n await this.resetInteractionMode();\n }\n\n /**\n * @ignore\n */\n @Watch('enabled')\n protected handleEnabledChanged(): void {\n this.controller?.setEnabled(this.enabled);\n this.toggleInteractionMode();\n }\n\n /**\n * @ignore\n */\n @Watch('viewer')\n protected handleViewerChanged(): void {\n this.clearInteractionHandler();\n this.setupInteractionHandler();\n this.updateTeleportTool();\n this.toggleInteractionMode();\n }\n\n /**\n * @ignore\n */\n @Watch('teleportMode')\n protected handleTeleportModeChanged(): void {\n this.updateTeleportTool();\n }\n\n /**\n * @ignore\n */\n @Watch('controller')\n protected handleControllerChanged(): void {\n this.updateTeleportTool();\n this.controllerChanged.emit(this.controller);\n }\n\n /**\n * @ignore\n */\n @Watch('model')\n protected handleModelChanged(): void {\n this.setupController();\n this.clearInteractionHandler();\n this.setupInteractionHandler();\n }\n\n protected render(): JSX.Element {\n return (\n <Host>\n <slot\n name=\"teleport-tool\"\n onSlotchange={async () => {\n await this.ensureTeleportToolConfigured();\n this.updateTeleportTool();\n }}\n ></slot>\n </Host>\n );\n }\n\n private setupController(): void {\n if (this.controller == null) {\n this.controller = new WalkModeController(this.model);\n this.controllerChanged.emit(this.controller);\n } else {\n this.controller.updateModel(this.model);\n }\n }\n\n private clearInteractionHandler(): void {\n this.interactionHandlerDisposable?.dispose();\n this.interactionHandlerDisposable = undefined;\n this.interactionHandler?.dispose();\n this.interactionHandler = undefined;\n }\n\n private async setupInteractionHandler(): Promise<void> {\n if (this.interactionHandler == null) {\n this.interactionHandler = new WalkInteractionHandler(this.model);\n\n this.interactionHandlerDisposable =\n await this.viewer?.registerInteractionHandler(this.interactionHandler);\n }\n }\n\n private async ensureTeleportToolConfigured(): Promise<void> {\n if (this.hostEl != null) {\n const slotted: Element | undefined =\n this.hostEl?.querySelector(\n 'vertex-viewer-teleport-tool[slot=\"teleport-tool\"]',\n ) ?? undefined;\n const slottedTeleportTool =\n slotted?.tagName === 'VERTEX-VIEWER-TELEPORT-TOOL'\n ? (slotted as HTMLVertexViewerTeleportToolElement)\n : undefined;\n\n if (slottedTeleportTool != null) {\n this.stateMap.teleportTool = slottedTeleportTool;\n } else {\n this.stateMap.teleportTool = document.createElement(\n 'vertex-viewer-teleport-tool',\n );\n this.stateMap.teleportTool.slot = 'teleport-tool';\n\n this.hostEl?.appendChild(this.stateMap.teleportTool);\n }\n }\n }\n\n private updateTeleportTool(): void {\n if (this.stateMap.teleportTool != null) {\n this.stateMap.teleportTool.viewer = this.viewer;\n this.stateMap.teleportTool.controller = this.controller;\n this.stateMap.teleportTool.model = this.model;\n this.stateMap.teleportTool.mode = this.teleportMode;\n }\n }\n\n private async toggleInteractionMode(): Promise<void> {\n if (this.enabled) {\n await this.setPivotInteractionMode();\n } else {\n await this.resetInteractionMode();\n }\n }\n\n private async setPivotInteractionMode(): Promise<void> {\n const baseInteractionHandler =\n await this.viewer?.getBaseInteractionHandler();\n\n if (this.enabled && baseInteractionHandler != null) {\n const interactionType =\n baseInteractionHandler.getPrimaryInteractionType();\n this.stateMap.previousPrimaryInteractionType =\n interactionType === 'pivot'\n ? this.stateMap.previousPrimaryInteractionType\n : interactionType;\n baseInteractionHandler.setPrimaryInteractionType('pivot');\n }\n }\n\n private async resetInteractionMode(): Promise<void> {\n const baseInteractionHandler =\n await this.viewer?.getBaseInteractionHandler();\n\n if (\n baseInteractionHandler != null &&\n baseInteractionHandler.getPrimaryInteractionType() === 'pivot' &&\n this.stateMap.previousPrimaryInteractionType != null\n ) {\n baseInteractionHandler.setPrimaryInteractionType(\n this.stateMap.previousPrimaryInteractionType,\n );\n this.stateMap.previousPrimaryInteractionType = undefined;\n }\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{h as i,r as t,c as s,H as n,a as o}from"./p-CCVkga9Q.js";import{p as l,v as h,r as e,b as r,a,m as d,h as u,g as v,q as c,e as f,c as w}from"./p-2UsvOTHJ.js";import{c as p}from"./p-Dw4-tG-V.js";import{w as x,r as g}from"./p-BxtKMwBH.js";import{T as y}from"./p-C12jtCFb.js";import{A as m,D as b}from"./p-Wih3EFqe.js";import"./p-BAhfr1Nx.js";import{E as z}from"./p-CDM7zNn0.js";import{d as T,T as C,R as D,e as R,r as A,s as j,x as P,A as E,b as S,y as N,z as O,f as H,g as U,h as F,i as I,j as $}from"./p-DjB7w-5_.js";import"./p-CG9AChtV.js";import"./p-DqArvEOV.js";import"./p-BT9d9jRt.js";import"./p-CeZe0Qql.js";function B(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function M(i,t){return t!=null?l.create(i.x-t.left,i.y-t.top):undefined}function q(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=e.at(e.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function k(i,t,s,n,o,l){return d.multiply(_(t,s,n,o,l),i)}function _(i,t,s,n,o){const l=new b(n);const e=new m(o);const r=()=>e.convertFrom(t-s);const a=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return d.makeTranslation(h.create(a(),0,0));case"y-translate":return d.makeTranslation(h.create(0,a(),0));case"z-translate":return d.makeTranslation(h.create(0,0,a()));case"x-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.left(),r())));case"y-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.down(),r())));case"z-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.forward(),r())));default:return d.makeIdentity()}}function J(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 b(n);const e=new m(o);const r=()=>d.makeRotation(c.fromMatrixRotation(t));const v=()=>d.multiply(d.invert(s),t);const f=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(v()),r());const w=()=>u.fromRotationMatrix(d.multiply(s,r()),J(i));switch(i){case"x-translate":return l.convertWorldValueToReal(f().x);case"y-translate":return l.convertWorldValueToReal(f().y);case"z-translate":return l.convertWorldValueToReal(f().z);case"x-rotate":return e.convertTo(a.normalizeRadians(w().x));case"y-rotate":return e.convertTo(a.normalizeRadians(w().y));case"z-rotate":return e.convertTo(a.normalizeRadians(w().z));default:return 0}}function K(i,t,s,n,o,l){return L(i,h.subtract(s,t),n,o,l)}function L(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 Q(i,t,h.create(0,0,1));case"xz-translate":return Q(i,t,h.create(0,1,0));case"yz-translate":return Q(i,t,h.create(1,0,0));case"x-rotate":return X(i,s,h.right(),n);case"y-rotate":return X(i,s,h.up(),n);case"z-rotate":return X(i,s,h.forward(),n);default:return i}}function X(i,t,s,n){const o=Z(i,t,s);const l=c.fromAxisAngle(o,n);const h=d.transpose(d.makeRotation(l));return d.multiply(h,i)}function Z(i,t,s){const n=d.makeRotation(c.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function G(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const r=d.makeTranslation(e);return d.multiply(i,r)}function Q(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const u=r.projectPoint(a,t);const v=h.add(u,h.scale(a.constant,a.normal));const f=d.makeTranslation(v);return d.multiply(i,f)}function Y(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=v.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const h=v.topLeft(n);const e=l.add(h,l.create(n.width,0));const r=v.bottomRight(n);const a=l.subtract(r,l.create(n.width,0));const d=l.scale(o.reduce(((i,t)=>l.add(i,t)),l.create()),1/o.length,1/o.length);const u=[e,a,r].reduce(((i,t)=>l.distance(d,t)<l.distance(d,i)?t:i),h);switch(u){case h:return{point:u,placement:"top-left"};case e:return{point:u,placement:"top-right"};case a:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function W(i,t,s,n,o,l){const h=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(h&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=a.toDegrees(i);const h=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=h-t;const e=a.toRadians(s);return e+n}else{const i=a.toRadians(h);return i+n}}else{return s}}const ii=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:h},e)=>{const r=ni(n,s!==null&&s!==void 0?s:f.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...r,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},e,i("div",{class:"widget-input units"},h.unit.abbreviatedName))};const ti=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:h,onBlur:e,onUndo:r})=>{const a=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){h===null||h===void 0?void 0:h()}else if(i.key==="z"&&t&&r){i.preventDefault();r()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:a,onKeyDown:d,onBlur:e,"aria-label":"Transform widget input"})};function si(i,t){return Math.min(i,Math.max(0,t))}function ni(i,t,s,n,o=5){const{width:l,height:h}=i.dimensions;const e=t.width+o;const r=t.height+o;function a(i){return`${i}px`}switch(n){case"top-left":return{right:a(si(l-e,l-s.x)),bottom:a(si(h-r,h-s.y))};case"top-right":return{left:a(si(l-e,s.x)),bottom:a(si(h-r,h-s.y))};case"bottom-left":return{right:a(si(l-e,l-s.x)),top:a(si(h-r,s.y))};case"bottom-right":default:return{left:a(si(l-e,s.x)),top:a(si(h-r,s.y))}}}function oi(i,t,s=3,n=1,o=1){return ei(i,t,h.back(),h.up(),s,n,o)}function li(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.up(),s,n,o)}function ei(i,t,s,n,o,l=1,r=1){const u=h.multiplyByTransformMatrixRowMajor(h.add(s,n),d.makeRotation(c.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,d.makeRotation(c.fromMatrixRotation(i)));const f=h.multiplyByTransformMatrixRowMajor(n,d.makeRotation(c.fromMatrixRotation(i)));const w=10*r**.25;const p=h.fromMatrixPosition(i);const x=h.add(p,h.scale(o*w,u));const g=e.create({origin:x,direction:v});const y=e.create({origin:x,direction:f});const m=h.cross(v,f);const b=h.rotateAboutAxis(a.toRadians(45),e.at(y,-(o*l)),m,x);const z=h.rotateAboutAxis(a.toRadians(45),e.at(g,o*l),m,x);const C=h.rotateAboutAxis(a.toRadians(45),e.at(y,o*l),m,x);const D=h.rotateAboutAxis(a.toRadians(45),e.at(g,-(o*l)),m,x);return new T(h.dot(v,t.direction)!==-1&&h.dot(f,t.direction)!==-1,b,D,z,C,h.multiplyByTransformMatrixColumnMajor(b,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(D,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return ai(i,t,s,n)}return false}function ai(i,t,s,n){return di([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||di([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function di(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 r=h.subtract(i[2],i[0]);const a=w.epsilon((o=w.fromVectors([l.direction,l.origin,e,r]))!==null&&o!==void 0?o:w.create(e,r));const d=h.cross(l.direction,r);const u=h.dot(e,d);if(!(Math.abs(u)>=a)){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 p=h.dot(l.direction,f)/u;if(p<0||c+p>1){return false}const x=h.dot(r,f)/u;return!Number.isNaN(x)&&(x>0||t.scene.camera.isOrthographic())}return false}class ui extends D{constructor(i,t={},s={}){var n,o,l,h,e,r,a,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 z;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=(h=t.colors)===null||h===void 0?void 0:h.hovered;this.outlineColor=(e=t.colors)===null||e===void 0?void 0:e.outline;this.disabledAxis.xTranslation=(r=s.xTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.yTranslation=(a=s.yTranslation)!==null&&a!==void 0?a: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&&v.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,h,e,r,a,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=(h=i.outline)!==null&&h!==void 0?h:this.outlineColor;(e=this.xArrow)===null||e===void 0?void 0:e.updateFillColor(this.getXTranslationColor(),true);(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.getYTranslationColor(),true);(a=this.zArrow)===null||a===void 0?void 0:a.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,h,e,r,a,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);(h=this.zRotation)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(e=this.zxRotationLine)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(r=this.zyRotationLine)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.zRotation);(a=this.xArrow)===null||a===void 0?void 0:a.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,h,e,r,a;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);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor(this.hoveredArrowFillColor)}else if(((e=this.hoveredElement)===null||e===void 0?void 0:e.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor);(a=this.zArrow)===null||a===void 0?void 0:a.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,h,e,r,a,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((h=this.xArrow)===null||h===void 0?void 0:h.initialFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor((r=this.zArrow)===null||r===void 0?void 0:r.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.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=R(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f;this.reglCommand=A({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=j(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",P(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",oi(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 E(w,"x-axis",S(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",N(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",li(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new E(w,"y-axis",S(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",O(i,t.scene.camera,p,(a=this.customization.scalars)===null||a===void 0?void 0:a.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new E(w,"z-axis",S(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",H(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",U(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",F(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,r,a;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=I(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=I(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=I(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=I(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=I(s.scene.camera,this.zRotation,(r=this.xArrow)===null||r===void 0?void 0:r.points.worldTip,d);const p=I(s.scene.camera,this.zRotation,(a=this.yArrow)===null||a===void 0?void 0:a.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,r,a,d,u,v,c,f,w,p,x,g,y,m,b,z,T,C,D,R,A,j,E,$,B,M;const q=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(P(i,t.scene.camera,q,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(S(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(oi(i,t.scene.camera,q,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(N(i,t.scene.camera,q,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation));(a=this.yAxis)===null||a===void 0?void 0:a.updatePoints(S(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(li(i,t.scene.camera,q,(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(O(i,t.scene.camera,q,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(S(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,q,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(x=this.customization.scalars)===null||x===void 0?void 0:x.zTranslation));(g=this.xyRotationLine)===null||g===void 0?void 0:g.updatePoints(I(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,q));(m=this.xzRotationLine)===null||m===void 0?void 0:m.updatePoints(I(t.scene.camera,this.xRotation,(b=this.zArrow)===null||b===void 0?void 0:b.points.worldTip,q));(z=this.yxRotationLine)===null||z===void 0?void 0:z.updatePoints(I(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,q));(C=this.yzRotationLine)===null||C===void 0?void 0:C.updatePoints(I(t.scene.camera,this.yRotation,(D=this.zArrow)===null||D===void 0?void 0:D.points.worldTip,q));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(I(t.scene.camera,this.zRotation,(A=this.xArrow)===null||A===void 0?void 0:A.points.worldTip,q));(j=this.zyRotationLine)===null||j===void 0?void 0:j.updatePoints(I(t.scene.camera,this.zRotation,(E=this.yArrow)===null||E===void 0?void 0:E.points.worldTip,q));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(H(i,t.scene.camera,q,($=this.customization.scalars)===null||$===void 0?void 0:$.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(U(i,t.scene.camera,q,(B=this.customization.scalars)===null||B===void 0?void 0:B.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(F(i,t.scene.camera,q,(M=this.customization.scalars)===null||M===void 0?void 0:M.yzTranslation))}}}const vi=()=>`: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 ci=class{constructor(i){t(this,i);this.positionChanged=s(this,"positionChanged");this.rotationChanged=s(this,"rotationChanged");this.interactionEnded=s(this,"interactionEnded");this.interactionStarted=s(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;g((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{g((()=>{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=M(l.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 h=M(l.create(i.clientX,i.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=h!=null?a.fromPoints(e,h):0;this.lastWorldPosition=q(h,(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=M(l.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const e=q(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(e!=null&&o!=null&&h!=null){const i=a.fromPoints(h,o);const t=W(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,e,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=e;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=M(l.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=a.normalizeRadians(s+a.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=k(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new ui(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=>{g((()=>{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=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Y(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=u.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 b(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:d.makeIdentity();const s=d.transpose(d.makeRotation(c.fromMatrixRotation(t)));const n=d.makeTranslation(i);return d.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.makeRotation(c.fromMatrixRotation(t));const n=d.makeRotation(c.fromEuler(i));const o=d.multiply(s,t);return d.multiply(d.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){B(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=d.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.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 y(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:u.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&d.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,o,l,h,e;return i(n,{key:"fdc062cb3cafa311baca827e03a765052e1ab2c8"},i("canvas",{key:"c6c9d413e971ef3db3b3eed7e9ff6c8387fff1d1",ref:i=>{this.canvasRef=i},class:p("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&&((o=this.viewer)===null||o===void 0?void 0:o.viewport)&&i(ii,{key:"7eb3550df7db8c95f3597d1bd8d7b05c70e11696",ref:i=>{var t,s;if(i!=null){(t=this.inputResizeObserver)===null||t===void 0?void 0:t.observe(i)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputWrapperRef=i},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.placement,displayUnit:this.getDisplayedUnits()},i(ti,{key:"84e2ff6825856c6d5f0ffff1771861ed6087bedb",ref:i=>{this.inputRef=i},identifier:(h=(l=this.dragging)===null||l===void 0?void 0:l.identifier)!==null&&h!==void 0?h:(e=this.lastDragged)===null||e===void 0?void 0:e.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(d.multiply(d.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return o(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}]}}};ci.style=vi();export{ci as vertex_viewer_transform_widget};
|
|
5
|
-
//# sourceMappingURL=p-
|
|
4
|
+
import{h as i,r as t,c as s,H as n,a as o}from"./p-CCVkga9Q.js";import{p as l,v as h,r as e,b as r,a,m as d,h as u,g as v,q as c,e as f,c as w}from"./p-2UsvOTHJ.js";import{c as p}from"./p-Dw4-tG-V.js";import{w as x,r as g}from"./p-BxtKMwBH.js";import{T as y}from"./p-C12jtCFb.js";import{A as m,D as z}from"./p-Wih3EFqe.js";import"./p-BAhfr1Nx.js";import{E as b}from"./p-CDM7zNn0.js";import{d as T,T as C,R as D,e as R,r as A,s as j,x as P,A as E,b as S,y as N,z as O,f as H,g as U,h as F,i as I,j as $}from"./p-DjB7w-5_.js";import"./p-CG9AChtV.js";import"./p-DqArvEOV.js";import"./p-BT9d9jRt.js";import"./p-CeZe0Qql.js";function B(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function M(i,t){return t!=null?l.create(i.x-t.left,i.y-t.top):undefined}function q(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=e.at(e.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function k(i,t,s,n,o,l){return d.multiply(_(t,s,n,o,l),i)}function _(i,t,s,n,o){const l=new z(n);const e=new m(o);const r=()=>e.convertFrom(t-s);const a=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return d.makeTranslation(h.create(a(),0,0));case"y-translate":return d.makeTranslation(h.create(0,a(),0));case"z-translate":return d.makeTranslation(h.create(0,0,a()));case"x-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.left(),r())));case"y-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.down(),r())));case"z-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.forward(),r())));default:return d.makeIdentity()}}function J(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 r=()=>d.makeRotation(c.fromMatrixRotation(t));const v=()=>d.multiply(d.invert(s),t);const f=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(v()),r());const w=()=>u.fromRotationMatrix(d.multiply(s,r()),J(i));switch(i){case"x-translate":return l.convertWorldValueToReal(f().x);case"y-translate":return l.convertWorldValueToReal(f().y);case"z-translate":return l.convertWorldValueToReal(f().z);case"x-rotate":return e.convertTo(a.normalizeRadians(w().x));case"y-rotate":return e.convertTo(a.normalizeRadians(w().y));case"z-rotate":return e.convertTo(a.normalizeRadians(w().z));default:return 0}}function K(i,t,s,n,o,l){return L(i,h.subtract(s,t),n,o,l)}function L(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 Q(i,t,h.create(0,0,1));case"xz-translate":return Q(i,t,h.create(0,1,0));case"yz-translate":return Q(i,t,h.create(1,0,0));case"x-rotate":return X(i,s,h.right(),n);case"y-rotate":return X(i,s,h.up(),n);case"z-rotate":return X(i,s,h.forward(),n);default:return i}}function X(i,t,s,n){const o=Z(i,t,s);const l=c.fromAxisAngle(o,n);const h=d.transpose(d.makeRotation(l));return d.multiply(h,i)}function Z(i,t,s){const n=d.makeRotation(c.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function G(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const r=d.makeTranslation(e);return d.multiply(i,r)}function Q(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const u=r.projectPoint(a,t);const v=h.add(u,h.scale(a.constant,a.normal));const f=d.makeTranslation(v);return d.multiply(i,f)}function Y(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=v.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const h=v.topLeft(n);const e=l.add(h,l.create(n.width,0));const r=v.bottomRight(n);const a=l.subtract(r,l.create(n.width,0));const d=l.scale(o.reduce(((i,t)=>l.add(i,t)),l.create()),1/o.length,1/o.length);const u=[e,a,r].reduce(((i,t)=>l.distance(d,t)<l.distance(d,i)?t:i),h);switch(u){case h:return{point:u,placement:"top-left"};case e:return{point:u,placement:"top-right"};case a:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function W(i,t,s,n,o,l){const h=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(h&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=a.toDegrees(i);const h=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=h-t;const e=a.toRadians(s);return e+n}else{const i=a.toRadians(h);return i+n}}else{return s}}const ii=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:h},e)=>{const r=ni(n,s!==null&&s!==void 0?s:f.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...r,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},e,i("div",{class:"widget-input units"},h.unit.abbreviatedName))};const ti=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:h,onBlur:e,onUndo:r})=>{const a=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){h===null||h===void 0?void 0:h()}else if(i.key==="z"&&t&&r){i.preventDefault();r()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:a,onKeyDown:d,onBlur:e,"aria-label":"Transform widget input"})};function si(i,t){return Math.min(i,Math.max(0,t))}function ni(i,t,s,n,o=5){const{width:l,height:h}=i.dimensions;const e=t.width+o;const r=t.height+o;function a(i){return`${i}px`}switch(n){case"top-left":return{right:a(si(l-e,l-s.x)),bottom:a(si(h-r,h-s.y))};case"top-right":return{left:a(si(l-e,s.x)),bottom:a(si(h-r,h-s.y))};case"bottom-left":return{right:a(si(l-e,l-s.x)),top:a(si(h-r,s.y))};case"bottom-right":default:return{left:a(si(l-e,s.x)),top:a(si(h-r,s.y))}}}function oi(i,t,s=3,n=1,o=1){return ei(i,t,h.back(),h.up(),s,n,o)}function li(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.up(),s,n,o)}function ei(i,t,s,n,o,l=1,r=1){const u=h.multiplyByTransformMatrixRowMajor(h.add(s,n),d.makeRotation(c.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,d.makeRotation(c.fromMatrixRotation(i)));const f=h.multiplyByTransformMatrixRowMajor(n,d.makeRotation(c.fromMatrixRotation(i)));const w=10*r**.25;const p=h.fromMatrixPosition(i);const x=h.add(p,h.scale(o*w,u));const g=e.create({origin:x,direction:v});const y=e.create({origin:x,direction:f});const m=h.cross(v,f);const z=h.rotateAboutAxis(a.toRadians(45),e.at(y,-(o*l)),m,x);const b=h.rotateAboutAxis(a.toRadians(45),e.at(g,o*l),m,x);const C=h.rotateAboutAxis(a.toRadians(45),e.at(y,o*l),m,x);const D=h.rotateAboutAxis(a.toRadians(45),e.at(g,-(o*l)),m,x);return new T(h.dot(v,t.direction)!==-1&&h.dot(f,t.direction)!==-1,z,D,b,C,h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(D,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(b,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return ai(i,t,s,n)}return false}function ai(i,t,s,n){return di([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||di([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function di(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 r=h.subtract(i[2],i[0]);const a=w.epsilon((o=w.fromVectors([l.direction,l.origin,e,r]))!==null&&o!==void 0?o:w.create(e,r));const d=h.cross(l.direction,r);const u=h.dot(e,d);if(!(Math.abs(u)>=a)){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 p=h.dot(l.direction,f)/u;if(p<0||c+p>1){return false}const x=h.dot(r,f)/u;return!Number.isNaN(x)&&(x>0||t.scene.camera.isOrthographic())}return false}class ui extends D{constructor(i,t={},s={}){var n,o,l,h,e,r,a,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 b;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=(h=t.colors)===null||h===void 0?void 0:h.hovered;this.outlineColor=(e=t.colors)===null||e===void 0?void 0:e.outline;this.disabledAxis.xTranslation=(r=s.xTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.yTranslation=(a=s.yTranslation)!==null&&a!==void 0?a: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&&v.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,h,e,r,a,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=(h=i.outline)!==null&&h!==void 0?h:this.outlineColor;(e=this.xArrow)===null||e===void 0?void 0:e.updateFillColor(this.getXTranslationColor(),true);(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.getYTranslationColor(),true);(a=this.zArrow)===null||a===void 0?void 0:a.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,h,e,r,a,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);(h=this.zRotation)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(e=this.zxRotationLine)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(r=this.zyRotationLine)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.zRotation);(a=this.xArrow)===null||a===void 0?void 0:a.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,h,e,r,a;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);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor(this.hoveredArrowFillColor)}else if(((e=this.hoveredElement)===null||e===void 0?void 0:e.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor);(a=this.zArrow)===null||a===void 0?void 0:a.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,h,e,r,a,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((h=this.xArrow)===null||h===void 0?void 0:h.initialFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor((r=this.zArrow)===null||r===void 0?void 0:r.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.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=R(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f;this.reglCommand=A({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=j(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",P(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",oi(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 E(w,"x-axis",S(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",N(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",li(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new E(w,"y-axis",S(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",O(i,t.scene.camera,p,(a=this.customization.scalars)===null||a===void 0?void 0:a.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new E(w,"z-axis",S(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",H(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",U(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",F(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,r,a;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=I(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=I(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=I(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=I(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=I(s.scene.camera,this.zRotation,(r=this.xArrow)===null||r===void 0?void 0:r.points.worldTip,d);const p=I(s.scene.camera,this.zRotation,(a=this.yArrow)===null||a===void 0?void 0:a.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,r,a,d,u,v,c,f,w,p,x,g,y,m,z,b,T,C,D,R,A,j,E,$,B,M;const q=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(P(i,t.scene.camera,q,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(S(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(oi(i,t.scene.camera,q,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(N(i,t.scene.camera,q,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation));(a=this.yAxis)===null||a===void 0?void 0:a.updatePoints(S(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(li(i,t.scene.camera,q,(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(O(i,t.scene.camera,q,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(S(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,q,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(x=this.customization.scalars)===null||x===void 0?void 0:x.zTranslation));(g=this.xyRotationLine)===null||g===void 0?void 0:g.updatePoints(I(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,q));(m=this.xzRotationLine)===null||m===void 0?void 0:m.updatePoints(I(t.scene.camera,this.xRotation,(z=this.zArrow)===null||z===void 0?void 0:z.points.worldTip,q));(b=this.yxRotationLine)===null||b===void 0?void 0:b.updatePoints(I(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,q));(C=this.yzRotationLine)===null||C===void 0?void 0:C.updatePoints(I(t.scene.camera,this.yRotation,(D=this.zArrow)===null||D===void 0?void 0:D.points.worldTip,q));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(I(t.scene.camera,this.zRotation,(A=this.xArrow)===null||A===void 0?void 0:A.points.worldTip,q));(j=this.zyRotationLine)===null||j===void 0?void 0:j.updatePoints(I(t.scene.camera,this.zRotation,(E=this.yArrow)===null||E===void 0?void 0:E.points.worldTip,q));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(H(i,t.scene.camera,q,($=this.customization.scalars)===null||$===void 0?void 0:$.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(U(i,t.scene.camera,q,(B=this.customization.scalars)===null||B===void 0?void 0:B.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(F(i,t.scene.camera,q,(M=this.customization.scalars)===null||M===void 0?void 0:M.yzTranslation))}}}const vi=()=>`: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 ci=class{constructor(i){t(this,i);this.positionChanged=s(this,"positionChanged");this.rotationChanged=s(this,"rotationChanged");this.interactionEnded=s(this,"interactionEnded");this.interactionFinished=s(this,"interactionFinished");this.interactionStarted=s(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;g((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{g((()=>{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=M(l.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 h=M(l.create(i.clientX,i.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=h!=null?a.fromPoints(e,h):0;this.lastWorldPosition=q(h,(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=M(l.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const e=q(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(e!=null&&o!=null&&h!=null){const i=a.fromPoints(h,o);const t=W(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,e,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=e;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=M(l.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.interactionFinished.emit(i);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=a.normalizeRadians(s+a.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=k(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new ui(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=>{g((()=>{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=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Y(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=u.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:d.makeIdentity();const s=d.transpose(d.makeRotation(c.fromMatrixRotation(t)));const n=d.makeTranslation(i);return d.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.makeRotation(c.fromMatrixRotation(t));const n=d.makeRotation(c.fromEuler(i));const o=d.multiply(s,t);return d.multiply(d.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){B(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=d.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.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 y(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:u.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&d.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,o,l,h,e;return i(n,{key:"c4ef21d563cf166d295df66a72991cce59e9f4c0"},i("canvas",{key:"f49149eaca7d896caed2cbfaa7c9e4339d3274b8",ref:i=>{this.canvasRef=i},class:p("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&&((o=this.viewer)===null||o===void 0?void 0:o.viewport)&&i(ii,{key:"152315ac7daa0e294187de477d4a1c01f83fc57d",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(ti,{key:"00225e42c3b18e02d8b5e08973fcb9edd89cf3b8",ref:i=>{this.inputRef=i},identifier:(h=(l=this.dragging)===null||l===void 0?void 0:l.identifier)!==null&&h!==void 0?h:(e=this.lastDragged)===null||e===void 0?void 0:e.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(d.multiply(d.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return o(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}]}}};ci.style=vi();export{ci as vertex_viewer_transform_widget};
|
|
5
|
+
//# sourceMappingURL=p-f6f57157.entry.js.map
|