@vertexvis/viewer 0.21.0-testing.0 → 0.21.0-testing.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +36 -38
  3. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js.map +1 -1
  4. package/dist/cjs/viewer.cjs.js +1 -1
  5. package/dist/collection/components/viewer-transform-widget/util.js +4 -4
  6. package/dist/collection/components/viewer-transform-widget/util.js.map +1 -1
  7. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget-components.js +15 -13
  8. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget-components.js.map +1 -1
  9. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget.css +4 -8
  10. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget.js +34 -20
  11. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget.js.map +1 -1
  12. package/dist/components/vertex-viewer-transform-widget.js +37 -38
  13. package/dist/components/vertex-viewer-transform-widget.js.map +1 -1
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/loader.mjs +1 -1
  16. package/dist/esm/vertex-viewer-transform-widget.entry.js +36 -38
  17. package/dist/esm/vertex-viewer-transform-widget.entry.js.map +1 -1
  18. package/dist/esm/viewer.js +1 -1
  19. package/dist/types/components/viewer-transform-widget/util.d.ts +4 -3
  20. package/dist/types/components/viewer-transform-widget/viewer-transform-widget.d.ts +7 -3
  21. package/dist/types/components.d.ts +8 -0
  22. package/dist/viewer/p-24b66b64.entry.js +5 -0
  23. package/dist/viewer/p-24b66b64.entry.js.map +1 -0
  24. package/dist/viewer/viewer.esm.js +1 -1
  25. package/dist/viewer/viewer.esm.js.map +1 -1
  26. package/package.json +7 -7
  27. package/dist/viewer/p-ff7e05fe.entry.js +0 -5
  28. package/dist/viewer/p-ff7e05fe.entry.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"names":["getDynamicImportFunction","namespace","replace","patchBrowser","scriptElm","Array","from","doc","querySelectorAll","find","s","RegExp","NAMESPACE","test","src","getAttribute","importMeta","opts","resourcesUrl","URL","href","win","location","patchDynamicImport","customElements","__sc_import_viewer","then","promiseResolve","base","orgScriptElm","importFunctionName","Function","Math","random","e","moduleMap","Map","url","mod","get","script","createElement","type","crossOrigin","createObjectURL","Blob","Promise","resolve","onload","m","remove","set","head","appendChild","options","globalScripts","bootstrapLazy","JSON","parse"],"mappings":";;;4HAKA,MAAMA,EAA4BC,GAAc,eAAeA,EAAUC,QAAQ,QAAS,OAC1F,MAAMC,EAAe,KAyBjB,MAAMC,EACAC,MAAMC,KAAKC,EAAIC,iBAAiB,WAAWC,MAAMC,GAAM,IAAIC,OAAO,IAAKC,4BAAoCC,KAAKH,EAAEI,MAChHJ,EAAEK,aAAa,4BAA8BH,IAErD,MAAMI,EAAa,GACnB,MAAMC,EAA6D,GAenE,GAAuBD,IAAe,GAAI,CACtCC,EAAKC,aAAe,IAAIC,IAAI,IAAKH,GAAYI,SAEG,CAChDH,EAAKC,aAAe,IAAIC,IAAI,IAAK,IAAIA,IAAIf,EAAUW,aAAa,uBAAyBX,EAAUU,IAAKO,EAAIC,SAASF,OAAOA,KAC/F,CACzBG,EAAmBN,EAAKC,aAAcd,GAE1C,IAAgCiB,EAAIG,eAAgB,CAGhD,OAAOC,mBAA+C,mBAAYC,MAAK,IAAMT,KAGrF,OAAOU,EAAeV,IAE1B,MAAMM,EAAqB,CAACK,EAAMC,KAC9B,MAAMC,EAAqB9B,EAAyBY,GACpD,IAKIS,EAAIS,GAAsB,IAAIC,SAAS,IAAK,sBAAsBC,KAAKC,YAE3E,MAAOC,GAIH,MAAMC,EAAY,IAAIC,IACtBf,EAAIS,GAAuBhB,IACvB,MAAMuB,EAAM,IAAIlB,IAAIL,EAAKc,GAAMR,KAC/B,IAAIkB,EAAMH,EAAUI,IAAIF,GACxB,IAAKC,EAAK,CACN,MAAME,EAASjC,EAAIkC,cAAc,UACjCD,EAAOE,KAAO,SACdF,EAAOG,YAAcd,EAAac,YAClCH,EAAO1B,IAAMK,IAAIyB,gBAAgB,IAAIC,KAAK,CAAC,uBAAuBR,cAAgBP,YAA8B,CAC5GY,KAAM,4BAEVJ,EAAM,IAAIQ,SAASC,IACfP,EAAOQ,OAAS,KACZD,EAAQ1B,EAAIS,GAAoBmB,GAChCT,EAAOU,aAGff,EAAUgB,IAAId,EAAKC,GACnB/B,EAAI6C,KAAKC,YAAYb,GAEzB,OAAOF,KCjGnBnC,IAAeuB,MAAK4B,IAClBC,IACA,OAAOC,EAAcC,KAAAC,MAAA,mtVAAuCJ","sourcesContent":["/*\n Stencil Client Patch Browser v2.16.1 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@stencil/core';\nconst getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\\s|-/g, '_')}`;\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n if (BUILD.cssVarShim) {\n // shim css vars\n plt.$cssShim$ = win.__cssshim;\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n if (BUILD.profile && !performance.mark) {\n // not all browsers support performance.mark/measure (Safari 10)\n // because the mark/measure APIs are designed to write entries to a buffer in the browser that does not exist,\n // simply stub the implementations out.\n // TODO(STENCIL-323): Remove this patch when support for older browsers is removed (breaking)\n // @ts-ignore\n performance.mark = performance.measure = () => {\n /*noop*/\n };\n performance.getEntriesByName = () => [];\n }\n // @ts-ignore\n const scriptElm = BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? scriptElm['data-opts'] || {} : {};\n if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {\n // Safari < v11 support: This IF is true if it's Safari below v11.\n // This fn cannot use async/await since Safari didn't support it until v11,\n // however, Safari 10 did support modules. Safari 10 also didn't support \"nomodule\",\n // so both the ESM file and nomodule file would get downloaded. Only Safari\n // has 'onbeforeload' in the script, and \"history.scrollRestoration\" was added\n // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.\n // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.\n return {\n then() {\n /* promise noop */\n },\n };\n }\n if (!BUILD.safari10 && importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n }\n else if (BUILD.dynamicImportShim || BUILD.safari10) {\n opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;\n if (BUILD.dynamicImportShim) {\n patchDynamicImport(opts.resourcesUrl, scriptElm);\n }\n if (BUILD.dynamicImportShim && !win.customElements) {\n // module support, but no custom elements support (Old Edge)\n // @ts-ignore\n return import(/* webpackChunkName: \"polyfills-dom\" */ './dom.js').then(() => opts);\n }\n }\n return promiseResolve(opts);\n};\nconst patchDynamicImport = (base, orgScriptElm) => {\n const importFunctionName = getDynamicImportFunction(NAMESPACE);\n try {\n // test if this browser supports dynamic imports\n // There is a caching issue in V8, that breaks using import() in Function\n // By generating a random string, we can workaround it\n // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info\n win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);\n }\n catch (e) {\n // this shim is specifically for browsers that do support \"esm\" imports\n // however, they do NOT support \"dynamic\" imports\n // basically this code is for old Edge, v18 and below\n const moduleMap = new Map();\n win[importFunctionName] = (src) => {\n const url = new URL(src, base).href;\n let mod = moduleMap.get(url);\n if (!mod) {\n const script = doc.createElement('script');\n script.type = 'module';\n script.crossOrigin = orgScriptElm.crossOrigin;\n script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {\n type: 'application/javascript',\n }));\n mod = new Promise((resolve) => {\n script.onload = () => {\n resolve(win[importFunctionName].m);\n script.remove();\n };\n });\n moduleMap.set(url, mod);\n doc.head.appendChild(script);\n }\n return mod;\n };\n }\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","import { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"]}
1
+ {"version":3,"sources":["../../node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"names":["getDynamicImportFunction","namespace","replace","patchBrowser","scriptElm","Array","from","doc","querySelectorAll","find","s","RegExp","NAMESPACE","test","src","getAttribute","importMeta","opts","resourcesUrl","URL","href","win","location","patchDynamicImport","customElements","__sc_import_viewer","then","promiseResolve","base","orgScriptElm","importFunctionName","Function","Math","random","e","moduleMap","Map","url","mod","get","script","createElement","type","crossOrigin","createObjectURL","Blob","Promise","resolve","onload","m","remove","set","head","appendChild","options","globalScripts","bootstrapLazy","JSON","parse"],"mappings":";;;4HAKA,MAAMA,EAA4BC,GAAc,eAAeA,EAAUC,QAAQ,QAAS,OAC1F,MAAMC,EAAe,KAyBjB,MAAMC,EACAC,MAAMC,KAAKC,EAAIC,iBAAiB,WAAWC,MAAMC,GAAM,IAAIC,OAAO,IAAKC,4BAAoCC,KAAKH,EAAEI,MAChHJ,EAAEK,aAAa,4BAA8BH,IAErD,MAAMI,EAAa,GACnB,MAAMC,EAA6D,GAenE,GAAuBD,IAAe,GAAI,CACtCC,EAAKC,aAAe,IAAIC,IAAI,IAAKH,GAAYI,SAEG,CAChDH,EAAKC,aAAe,IAAIC,IAAI,IAAK,IAAIA,IAAIf,EAAUW,aAAa,uBAAyBX,EAAUU,IAAKO,EAAIC,SAASF,OAAOA,KAC/F,CACzBG,EAAmBN,EAAKC,aAAcd,GAE1C,IAAgCiB,EAAIG,eAAgB,CAGhD,OAAOC,mBAA+C,mBAAYC,MAAK,IAAMT,KAGrF,OAAOU,EAAeV,IAE1B,MAAMM,EAAqB,CAACK,EAAMC,KAC9B,MAAMC,EAAqB9B,EAAyBY,GACpD,IAKIS,EAAIS,GAAsB,IAAIC,SAAS,IAAK,sBAAsBC,KAAKC,YAE3E,MAAOC,GAIH,MAAMC,EAAY,IAAIC,IACtBf,EAAIS,GAAuBhB,IACvB,MAAMuB,EAAM,IAAIlB,IAAIL,EAAKc,GAAMR,KAC/B,IAAIkB,EAAMH,EAAUI,IAAIF,GACxB,IAAKC,EAAK,CACN,MAAME,EAASjC,EAAIkC,cAAc,UACjCD,EAAOE,KAAO,SACdF,EAAOG,YAAcd,EAAac,YAClCH,EAAO1B,IAAMK,IAAIyB,gBAAgB,IAAIC,KAAK,CAAC,uBAAuBR,cAAgBP,YAA8B,CAC5GY,KAAM,4BAEVJ,EAAM,IAAIQ,SAASC,IACfP,EAAOQ,OAAS,KACZD,EAAQ1B,EAAIS,GAAoBmB,GAChCT,EAAOU,aAGff,EAAUgB,IAAId,EAAKC,GACnB/B,EAAI6C,KAAKC,YAAYb,GAEzB,OAAOF,KCjGnBnC,IAAeuB,MAAK4B,IAClBC,IACA,OAAOC,EAAcC,KAAAC,MAAA,kvVAAuCJ","sourcesContent":["/*\n Stencil Client Patch Browser v2.16.1 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@stencil/core';\nconst getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\\s|-/g, '_')}`;\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n if (BUILD.cssVarShim) {\n // shim css vars\n plt.$cssShim$ = win.__cssshim;\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n if (BUILD.profile && !performance.mark) {\n // not all browsers support performance.mark/measure (Safari 10)\n // because the mark/measure APIs are designed to write entries to a buffer in the browser that does not exist,\n // simply stub the implementations out.\n // TODO(STENCIL-323): Remove this patch when support for older browsers is removed (breaking)\n // @ts-ignore\n performance.mark = performance.measure = () => {\n /*noop*/\n };\n performance.getEntriesByName = () => [];\n }\n // @ts-ignore\n const scriptElm = BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? scriptElm['data-opts'] || {} : {};\n if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {\n // Safari < v11 support: This IF is true if it's Safari below v11.\n // This fn cannot use async/await since Safari didn't support it until v11,\n // however, Safari 10 did support modules. Safari 10 also didn't support \"nomodule\",\n // so both the ESM file and nomodule file would get downloaded. Only Safari\n // has 'onbeforeload' in the script, and \"history.scrollRestoration\" was added\n // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.\n // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.\n return {\n then() {\n /* promise noop */\n },\n };\n }\n if (!BUILD.safari10 && importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n }\n else if (BUILD.dynamicImportShim || BUILD.safari10) {\n opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;\n if (BUILD.dynamicImportShim) {\n patchDynamicImport(opts.resourcesUrl, scriptElm);\n }\n if (BUILD.dynamicImportShim && !win.customElements) {\n // module support, but no custom elements support (Old Edge)\n // @ts-ignore\n return import(/* webpackChunkName: \"polyfills-dom\" */ './dom.js').then(() => opts);\n }\n }\n return promiseResolve(opts);\n};\nconst patchDynamicImport = (base, orgScriptElm) => {\n const importFunctionName = getDynamicImportFunction(NAMESPACE);\n try {\n // test if this browser supports dynamic imports\n // There is a caching issue in V8, that breaks using import() in Function\n // By generating a random string, we can workaround it\n // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info\n win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);\n }\n catch (e) {\n // this shim is specifically for browsers that do support \"esm\" imports\n // however, they do NOT support \"dynamic\" imports\n // basically this code is for old Edge, v18 and below\n const moduleMap = new Map();\n win[importFunctionName] = (src) => {\n const url = new URL(src, base).href;\n let mod = moduleMap.get(url);\n if (!mod) {\n const script = doc.createElement('script');\n script.type = 'module';\n script.crossOrigin = orgScriptElm.crossOrigin;\n script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {\n type: 'application/javascript',\n }));\n mod = new Promise((resolve) => {\n script.onload = () => {\n resolve(win[importFunctionName].m);\n script.remove();\n };\n });\n moduleMap.set(url, mod);\n doc.head.appendChild(script);\n }\n return mod;\n };\n }\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","import { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertexvis/viewer",
3
- "version": "0.21.0-testing.0",
3
+ "version": "0.21.0-testing.2",
4
4
  "description": "The Vertex SDK for viewing models.",
5
5
  "license": "MIT",
6
6
  "author": "Vertex Developers <support@vertexvis.com> (https://developer.vertexvis.com)",
@@ -50,12 +50,12 @@
50
50
  "@stencil/core": "^2.16.1",
51
51
  "@types/classnames": "^2.3.1",
52
52
  "@vertexvis/frame-streaming-protos": "^0.13.2",
53
- "@vertexvis/geometry": "0.21.0-testing.0",
54
- "@vertexvis/html-templates": "0.21.0-testing.0",
53
+ "@vertexvis/geometry": "0.21.0-testing.2",
54
+ "@vertexvis/html-templates": "0.21.0-testing.2",
55
55
  "@vertexvis/scene-tree-protos": "^0.1.20",
56
56
  "@vertexvis/scene-view-protos": "^0.2.1",
57
- "@vertexvis/stream-api": "0.21.0-testing.0",
58
- "@vertexvis/utils": "0.21.0-testing.0",
57
+ "@vertexvis/stream-api": "0.21.0-testing.2",
58
+ "@vertexvis/utils": "0.21.0-testing.2",
59
59
  "@vertexvis/web-workers": "^0.1.0",
60
60
  "camel-case": "^4.1.2",
61
61
  "classnames": "^2.3.1",
@@ -82,7 +82,7 @@
82
82
  "@vertexvis/eslint-config-vertexvis-typescript": "^0.5.0",
83
83
  "@vertexvis/rollup-plugin-web-workers": "^0.1.0",
84
84
  "@vertexvis/typescript-config-vertexvis": "1.1.0",
85
- "@vertexwebsdk/build": "0.21.0-testing.0",
85
+ "@vertexwebsdk/build": "0.21.0-testing.2",
86
86
  "abortcontroller-polyfill": "^1.7.3",
87
87
  "chance": "^1.1.8",
88
88
  "eslint": "^8.17.0",
@@ -97,5 +97,5 @@
97
97
  "typedoc": "^0.22.17",
98
98
  "typescript": "^4.5.4"
99
99
  },
100
- "gitHead": "fc83ca4f71121970cf787f423f713f35f8776584"
100
+ "gitHead": "b163207105e590e85fa37e0fb227d0e70e19ff3d"
101
101
  }
@@ -1,5 +0,0 @@
1
- /*!
2
- * Copyright (c) 2024 Vertex Software LLC. All rights reserved.
3
- */
4
- import{h as t,r as i,c as s,H as n,g as o}from"./p-e4ea1075.js";import{p as h,v as l,r as e,f as r,m as a,q as d,t as u,e as v,d as c,c as f,b as w}from"./p-64241313.js";import{c as p}from"./p-5206da6c.js";import{w as g,r as m}from"./p-de6e0a52.js";import{T as x}from"./p-dc03a747.js";import{D as b,A as y}from"./p-b1d6db57.js";import"./p-d312d59a.js";import{E as z}from"./p-fbf81eb8.js";import{d as C,T as D,R,e as T,r as j,s as O,x as P,A,b as $,y as N,z as E,f as S,g as U}from"./p-ad8fd026.js";import"./p-88c19f38.js";import"./p-ff3586b7.js";import"./p-97c819bc.js";function F(t,i){return i!=null?h.create(t.x-i.left,t.y-i.top):undefined}function J(t,i,s,n){const o=n!=null?l.fromMatrixPosition(n):undefined;if(t!=null&&i!=null&&s!=null&&o!=null){if(i.scene.camera.isOrthographic()){const n=s.transformPointToOrthographicRay(t,i.image,i.scene.camera);const h=e.at(e.create({origin:o,direction:i.scene.camera.direction}),l.magnitude(i.scene.camera.viewVector)*2);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(i.scene.camera.direction,h))}else{const n=s.transformPointToRay(t,i.image,i.scene.camera);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(i.scene.camera.direction,o))}}return undefined}function _(t,i,s,n="millimeters",o="degrees"){const h=new b(n);const e=new y(o);const r=()=>e.convertFrom(i-s);const u=()=>h.convertRealValueToWorld(i-s);switch(t){case"x-translate":return a.makeTranslation(l.create(u(),0,0));case"y-translate":return a.makeTranslation(l.create(0,u(),0));case"z-translate":return a.makeTranslation(l.create(0,0,u()));case"x-rotate":return a.makeRotation(d.fromAxisAngle(l.left(),r()));case"y-rotate":return a.makeRotation(d.fromAxisAngle(l.down(),r()));case"z-rotate":return a.makeRotation(d.fromAxisAngle(l.forward(),r()))}return a.makeIdentity()}function H(t,i,s,n="millimeters",o="degrees"){const h=new b(n);const e=new y(o);const r=()=>a.makeRotation(d.fromMatrixRotation(i));const v=()=>a.multiply(i,a.invert(s));const c=()=>l.transformMatrix(l.fromMatrixPosition(v()),a.invert(r()));const f=()=>u.create(l.transformMatrix(u.fromRotationMatrix(a.invert(v())),a.invert(r())));switch(t){case"x-translate":return h.convertWorldValueToReal(c().x);case"y-translate":return h.convertWorldValueToReal(c().y);case"z-translate":return h.convertWorldValueToReal(c().z);case"x-rotate":return e.convertTo(f().x);case"y-rotate":return e.convertTo(f().y);case"z-rotate":return e.convertTo(f().z)}return 0}function M(t,i,s,n,o,h){const e=l.subtract(s,i);switch(h){case"x-translate":{return a.multiply(t,k(t,l.right(),e))}case"y-translate":return a.multiply(t,k(t,l.up(),e));case"z-translate":return a.multiply(t,k(t,l.back(),e));case"x-rotate":return a.multiply(L(t,a.makeRotation(d.fromAxisAngle(I(t,n,l.right()),o))),t);case"y-rotate":return a.multiply(L(t,a.makeRotation(d.fromAxisAngle(I(t,n,l.up()),o))),t);case"z-rotate":return a.multiply(L(t,a.makeRotation(d.fromAxisAngle(I(t,n,l.forward()),o))),t);default:return t}}function I(t,i,s){const n=a.makeRotation(d.fromMatrixRotation(t));const o=l.transformMatrix(s,n);const h=l.transformMatrix(l.negate(s),n);return l.dot(i,o)>l.dot(i,h)?o:h}function k(t,i,s){const n=a.makeRotation(d.fromMatrixRotation(t));const o=l.transformMatrix(i,n);const h=l.multiply(o,s);return a.makeTranslation(l.scale(h.x+h.y+h.z,i))}function L(t,i){return a.multiply(a.multiply(a.makeTranslation(l.fromMatrixPosition(t)),i),a.makeTranslation(l.negate(l.fromMatrixPosition(t))))}function V(t,i,s){const n=v.pad(i,5);const o=s.map((i=>t.transformNdcPointToViewport(i)));const l=v.topLeft(n);const e=h.add(l,h.create(n.width,0));const r=v.bottomRight(n);const a=h.subtract(r,h.create(n.width,0));const d=h.scale(o.reduce(((t,i)=>h.add(t,i)),h.create()),1/o.length,1/o.length);const u=[e,a,r].reduce(((t,i)=>h.distance(d,i)<h.distance(d,t)?i:t),l);switch(u){case l:return{point:u,position:"top-left"};case e:return{point:u,position:"top-right"};case a:return{point:u,position:"bottom-left"};default:return{point:u,position:"bottom-right"}}}const X=({ref:i,bounds:s,viewport:n,point:o,placement:h,distance:l,angle:e,decimalPlaces:r,distanceUnit:a,angleUnit:d,onChange:u,onIncrement:v,onDecrement:f})=>{const w=new y(d);const p=new b(a);const g=l!=null?`${l.toFixed(r)} ${p.unit.abbreviatedName}`:`${e===null||e===void 0?void 0:e.toFixed(r)} ${w.unit.abbreviatedName}`;const m=Z(n,s!==null&&s!==void 0?s:c.create(100,30),o,h);const x=t=>{if(t.target!=null){const i=parseFloat(t.target.value);if(!isNaN(i)){u===null||u===void 0?void 0:u(parseFloat(t.target.value))}}};const z=t=>{if(t.key==="ArrowUp"){v===null||v===void 0?void 0:v()}else if(t.key==="ArrowDown"){f===null||f===void 0?void 0:f()}};return t("div",{class:"widget-input wrapper",style:Object.assign({},m),onKeyDown:z},t("input",{ref:i,class:"widget-input",type:"text",value:g,onChange:x}))};function Y(t,i){return Math.min(t,Math.max(0,i))}function Z(t,i,s,n){const{width:o,height:h}=t.dimensions;function l(t){return`${t}px`}switch(n){case"top-left":return{right:l(Y(o-i.width,o-s.x)),bottom:l(Y(h-i.height,h-s.y))};case"top-right":return{left:l(Y(o-i.width,s.x)),bottom:l(Y(h-i.height,h-s.y))};case"bottom-left":return{right:l(Y(o-i.width,o-s.x)),top:l(Y(h-i.height,s.y))};case"bottom-right":default:return{left:l(Y(o-i.width,s.x)),top:l(Y(h-i.height,s.y))}}}function q(t,i,s=3){return G(t,i,l.back(),l.up(),s)}function B(t,i,s=3){return G(t,i,l.right(),l.back(),s)}function K(t,i,s=3){return G(t,i,l.right(),l.up(),s)}function G(t,i,s,n,o){const h=l.transformMatrix(l.add(s,n),a.makeRotation(d.fromMatrixRotation(t)));const r=l.transformMatrix(s,a.makeRotation(d.fromMatrixRotation(t)));const u=l.transformMatrix(n,a.makeRotation(d.fromMatrixRotation(t)));const v=l.fromMatrixPosition(t);const c=l.add(v,l.scale(o*10,h));const w=e.create({origin:c,direction:r});const p=e.create({origin:c,direction:u});const g=l.cross(r,u);const m=l.rotateAboutAxis(f.toRadians(45),e.at(p,-o),g,c);const x=l.rotateAboutAxis(f.toRadians(45),e.at(w,o),g,c);const b=l.rotateAboutAxis(f.toRadians(45),e.at(p,o),g,c);const y=l.rotateAboutAxis(f.toRadians(45),e.at(w,-o),g,c);return new C(l.dot(r,i.direction)!==-1&&l.dot(u,i.direction)!==-1,m,y,x,b,l.transformMatrix(m,i.projectionViewMatrix),l.transformMatrix(y,i.projectionViewMatrix),l.transformMatrix(x,i.projectionViewMatrix),l.transformMatrix(b,i.projectionViewMatrix))}function Q(t,i,s,n){if(t instanceof D){return W(t,i,s,n)}return false}function W(t,i,s,n){return tt([t.points.worldLeft,t.points.worldRight,t.points.worldTip],i,s,n)||tt([t.points.worldLeft,t.points.worldRight,t.points.worldBase],i,s,n)}function tt(t,i,s,n){var o;if(t.length===3){const h=i.scene.camera.isOrthographic()?s.transformPointToOrthographicRay(n,i.image,i.scene.camera):s.transformPointToRay(n,i.image,i.scene.camera);const e=l.subtract(t[1],t[0]);const r=l.subtract(t[2],t[0]);const a=w.epsilon((o=w.fromVectors([h.direction,h.origin,e,r]))!==null&&o!==void 0?o:w.create(e,r));const d=l.cross(h.direction,r);const u=l.dot(e,d);if(!(Math.abs(u)>=a)){return false}const v=l.subtract(h.origin,t[0]);const c=l.dot(v,d)/u;if(c<0||c>1){return false}const f=l.cross(v,e);const p=l.dot(h.direction,f)/u;if(p<0||c+p>1){return false}const g=l.dot(r,f)/u;return!isNaN(g)&&(g>0||i.scene.camera.isOrthographic())}return false}class it extends R{constructor(t,i={},s={}){var n,o,h,l,e,r;super(t);this.disabledAxis={xTranslation:false,yTranslation:false,zTranslation:false,xRotation:false,yRotation:false,zRotation:false};this.axisLines=[];this.rotationLines=[];this.translationMeshes=[];this.rotationMeshes=[];this.hoveredChanged=new z;this.xArrowFillColor=i.xArrow;this.yArrowFillColor=i.yArrow;this.zArrowFillColor=i.zArrow;this.hoveredArrowFillColor=i.hovered;this.outlineColor=i.outline;this.disabledAxis.xTranslation=(n=s.xTranslation)!==null&&n!==void 0?n:false;this.disabledAxis.yTranslation=(o=s.yTranslation)!==null&&o!==void 0?o:false;this.disabledAxis.zTranslation=(h=s.zTranslation)!==null&&h!==void 0?h:false;this.disabledAxis.xRotation=(l=s.xRotation)!==null&&l!==void 0?l:false;this.disabledAxis.yRotation=(e=s.yRotation)!==null&&e!==void 0?e:false;this.disabledAxis.zRotation=(r=s.zRotation)!==null&&r!==void 0?r:false}dispose(){var t;(t=this.reglFrameDisposable)===null||t===void 0?void 0:t.cancel()}getDrawableElements(){return this.drawableElements}getFullBounds(){return this.fullBounds}boundsContainsPoint(t){return this.interactiveBounds!=null&&this.frame!=null&&v.containsPoints(this.interactiveBounds,t)}updateDisabledAxis(t){this.disabledAxis=Object.assign(Object.assign({},this.disabledAxis),t);this.updateDisabledOnDrawables()}updateCursor(t){this.cursor=t;if(t!=null&&this.frame!=null){this.updateHovered()}else{this.clearHovered()}}updateTransform(t){var i;this.transform=t;if(t!=null&&this.frame!=null){this.updateAndDraw()}else{this.clear();(i=this.reglFrameDisposable)===null||i===void 0?void 0:i.cancel();this.reglFrameDisposable=undefined}}updateColors(t={}){var i,s,n,o,h,l,e,r,a,d,u,v;this.xArrowFillColor=(i=t.xArrow)!==null&&i!==void 0?i:this.xArrowFillColor;this.yArrowFillColor=(s=t.yArrow)!==null&&s!==void 0?s:this.yArrowFillColor;this.zArrowFillColor=(n=t.zArrow)!==null&&n!==void 0?n:this.zArrowFillColor;this.hoveredArrowFillColor=(o=t.hovered)!==null&&o!==void 0?o:this.hoveredArrowFillColor;this.outlineColor=(h=t.outline)!==null&&h!==void 0?h:this.outlineColor;(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor(this.getXTranslationColor(),true);(e=this.yArrow)===null||e===void 0?void 0:e.updateFillColor(this.getYTranslationColor(),true);(r=this.zArrow)===null||r===void 0?void 0:r.updateFillColor(this.getZTranslationColor(),true);(a=this.xRotation)===null||a===void 0?void 0:a.updateFillColor(this.getXRotationColor(),true);(d=this.yRotation)===null||d===void 0?void 0:d.updateFillColor(this.getYRotationColor(),true);(u=this.zRotation)===null||u===void 0?void 0:u.updateFillColor(this.getZRotationColor(),true);(v=this.hoveredElement)===null||v===void 0?void 0:v.updateFillColor(this.hoveredArrowFillColor)}onHoveredChanged(t){return this.hoveredChanged.on(t)}updateDisabledOnDrawables(){var t,i,s,n,o,h,l,e,r,a,d,u;(t=this.xRotation)===null||t===void 0?void 0:t.setDisabled(this.disabledAxis.xRotation);(i=this.xyRotationLine)===null||i===void 0?void 0:i.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);(h=this.yxRotationLine)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.yRotation);(l=this.zRotation)===null||l===void 0?void 0:l.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);this.updateColors()}updateHovered(){var t;const i=this.hoveredElement;const s=this.frame;if(s!=null){this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((t=>t.points.valid&&!t.isDisabled())).find((t=>this.cursor!=null?Q(t,s,this.viewport,this.cursor):false));if(this.hoveredElement!==i){this.hoveredChanged.emit(this.hoveredElement);(t=this.hoveredElement)===null||t===void 0?void 0:t.updateFillColor(this.hoveredArrowFillColor);i===null||i===void 0?void 0:i.updateFillColor(i===null||i===void 0?void 0:i.initialFillColor)}}}clearHovered(){const t=this.hoveredElement;this.hoveredElement=undefined;if(this.hoveredElement!==t){this.hoveredChanged.emit(this.hoveredElement);t.updateFillColor(t.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=T(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=T(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(t,i){this.reglCommand=j({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:s}=O(this.reglCommand);const n=this.computeTriangleSize(l.fromMatrixPosition(t),i);this.xArrow=new D(s,"x-translate",P(t,i.scene.camera,n),this.outlineColor,this.getXTranslationColor());this.xRotation=new D(s,"x-rotate",q(t,i.scene.camera,n),this.outlineColor,this.getXRotationColor());this.xAxis=new A(s,"x-axis",$(t,i.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new D(s,"y-translate",N(t,i.scene.camera,n),this.outlineColor,this.getYTranslationColor());this.yRotation=new D(s,"y-rotate",B(t,i.scene.camera,n),this.outlineColor,this.getYRotationColor());this.yAxis=new A(s,"y-axis",$(t,i.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new D(s,"z-translate",E(t,i.scene.camera,n),this.outlineColor,this.getZTranslationColor());this.zAxis=new A(s,"z-axis",$(t,i.scene.camera,this.zArrow),this.outlineColor,this.getZTranslationColor());this.zRotation=new D(s,"z-rotate",K(t,i.scene.camera,n),this.outlineColor,this.getZRotationColor());this.createRotationLines(s,t,i);this.axisLines=[this.xAxis,this.yAxis,this.zAxis];this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow];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}createRotationLines(t,i,s){var n,o,h,e,r,a;const d=this.computeTriangleSize(l.fromMatrixPosition(i),s);const u=S(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=S(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=S(s.scene.camera,this.yRotation,(h=this.xArrow)===null||h===void 0?void 0:h.points.worldTip,d);const f=S(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=S(s.scene.camera,this.zRotation,(r=this.xArrow)===null||r===void 0?void 0:r.points.worldTip,d);const p=S(s.scene.camera,this.zRotation,(a=this.yArrow)===null||a===void 0?void 0:a.points.worldTip,d);if(u!=null){this.xyRotationLine=new U(t,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new U(t,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new U(t,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new U(t,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new U(t,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new U(t,"zy-rotation-line",p,this.outlineColor)}this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((t=>t!=null))}updateElements(t,i){var s,n,o,h,e,r,a,d,u,v,c,f,w,p,g,m,x,b;const y=this.computeTriangleSize(l.fromMatrixPosition(t),i);if(this.xArrow!=null){this.xArrow.updatePoints(P(t,i.scene.camera,y));(s=this.xAxis)===null||s===void 0?void 0:s.updatePoints($(t,i.scene.camera,this.xArrow))}(n=this.xRotation)===null||n===void 0?void 0:n.updatePoints(q(t,i.scene.camera,y));if(this.yArrow!=null){this.yArrow.updatePoints(N(t,i.scene.camera,y));(o=this.yAxis)===null||o===void 0?void 0:o.updatePoints($(t,i.scene.camera,this.yArrow))}(h=this.yRotation)===null||h===void 0?void 0:h.updatePoints(B(t,i.scene.camera,y));if(this.zArrow!=null){this.zArrow.updatePoints(E(t,i.scene.camera,y));(e=this.zAxis)===null||e===void 0?void 0:e.updatePoints($(t,i.scene.camera,this.zArrow))}(r=this.zRotation)===null||r===void 0?void 0:r.updatePoints(K(t,i.scene.camera,y));(a=this.xyRotationLine)===null||a===void 0?void 0:a.updatePoints(S(i.scene.camera,this.xRotation,(d=this.yArrow)===null||d===void 0?void 0:d.points.worldTip,y));(u=this.xzRotationLine)===null||u===void 0?void 0:u.updatePoints(S(i.scene.camera,this.xRotation,(v=this.zArrow)===null||v===void 0?void 0:v.points.worldTip,y));(c=this.yxRotationLine)===null||c===void 0?void 0:c.updatePoints(S(i.scene.camera,this.yRotation,(f=this.xArrow)===null||f===void 0?void 0:f.points.worldTip,y));(w=this.yzRotationLine)===null||w===void 0?void 0:w.updatePoints(S(i.scene.camera,this.yRotation,(p=this.zArrow)===null||p===void 0?void 0:p.points.worldTip,y));(g=this.zxRotationLine)===null||g===void 0?void 0:g.updatePoints(S(i.scene.camera,this.zRotation,(m=this.xArrow)===null||m===void 0?void 0:m.points.worldTip,y));(x=this.zyRotationLine)===null||x===void 0?void 0:x.updatePoints(S(i.scene.camera,this.zRotation,(b=this.yArrow)===null||b===void 0?void 0:b.points.worldTip,y))}}const st=":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-hovered-arrow-color:#ffff00;--viewer-transform-widget-input-width:7em}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}.widget-input.wrapper{position:absolute;box-sizing:border-box;pointer-events:auto;display:flex;border:1px solid #cccccc;width:var(--viewer-transform-widget-input-width)}input.widget-input{text-align:center;border:none;width:100%}.widget-input.left-step,.widget-input.right-step{display:flex;align-items:center;padding:0;background-color:white;border:none}";const nt=class{constructor(t){i(this,t);this.positionChanged=s(this,"positionChanged",7);this.rotationChanged=s(this,"rotationChanged",7);this.interactionEnded=s(this,"interactionEnded",7);this.interactionStarted=s(this,"interactionStarted",7);this.xRotationDisabled=false;this.yRotationDisabled=false;this.zRotationDisabled=false;this.xTranslationDisabled=false;this.yTranslationDisabled=false;this.zTranslationDisabled=false;this.distanceUnit="millimeters";this.angleUnit="degrees";this.decimalPlaces=1;this.xArrowColor="#ea3324";this.yArrowColor="#4faf32";this.zArrowColor="#0000ff";this.hoveredColor="#ffff00";this.lastAngle=0;this.handleHoveredDrawableChanged=t=>{this.hovered=t};this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()};this.handleViewerDimensionsChange=()=>{g((()=>{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=()=>{console.log(this.inputRef);if(this.inputRef!=null){const t=this.inputRef;m((()=>{this.inputBounds=t.getBoundingClientRect();console.log(this.inputBounds)}))}};this.handleStyleChange=()=>{m((()=>{const t=window.getComputedStyle(this.hostEl);this.xArrowColor=t.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim();this.yArrowColor=t.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim();this.zArrowColor=t.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim();this.hoveredColor=t.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim();this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,hovered:this.hoveredColor})}))};this.handlePointerMove=t=>{if(this.dragging==null){const i=F(h.create(t.clientX,t.clientY),this.getCanvasBounds());const s=this.getTransformWidget();if(i!=null&&s.boundsContainsPoint(i)){s.updateCursor(i)}else{s.updateCursor(undefined);this.hovered=undefined}}};this.handleBeginDrag=async t=>{var i,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!==((i=this.lastDragged)===null||i===void 0?void 0:i.identifier)){this.dragStartTransform=this.currentTransform}this.lastDragged=undefined;const l=F(h.create(t.clientX,t.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=l!=null?f.fromPoints(e,l):0;this.lastWorldPosition=J(l,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);this.interactionStarted.emit();window.removeEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointermove",this.handleDrag);window.addEventListener("pointerup",this.handleEndTransform)}};this.handleDrag=async t=>{var i,s,n;t.preventDefault();const o=this.getCanvasBounds();if(this.dragging!=null&&this.lastWorldPosition!=null&&o!=null&&this.viewer!=null&&this.viewer.frame!=null&&this.position!=null){await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());const l=F(h.create(t.clientX,t.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const r=J(l,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);if(r!=null&&l!=null&&e!=null){const t=f.fromPoints(e,l);this.transform(this.lastWorldPosition,r,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=r;this.lastAngle=t}}};this.handleEndTransform=async t=>{var i,s;const n=F(h.create(t.clientX,t.clientY),this.getCanvasBounds());const o=this.getTransformWidget();this.lastDragged=this.dragging;this.dragging=undefined;this.lastWorldPosition=undefined;this.position=this.currentTransform!=null?l.fromMatrixPosition(this.currentTransform):this.position;this.lastAngle=0;this.updateInputPosition();this.updateInputValue();o.updateCursor(n);o.updateTransform(this.currentTransform);o.updateDisabledAxis({xRotation:true,yRotation:true,zRotation:true,xTranslation:true,yTranslation:true,zTranslation:true});window.removeEventListener("pointermove",this.handleDrag);window.removeEventListener("pointerup",this.handleEndTransform);try{const t=(i=this.controller)===null||i===void 0?void 0:i.getCurrentDelta();await((s=this.controller)===null||s===void 0?void 0:s.endTransform());this.interactionEnded.emit(t)}catch(t){console.error("Failed to end transform interaction",t)}window.addEventListener("pointermove",this.handlePointerMove);this.getTransformWidget().updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled})};this.handleInputIncrement=()=>{if(this.inputValue!=null&&this.lastInputValue!=null){this.inputValue=this.lastInputValue+1;console.log(this.inputValue);this.handleInputChange(this.inputValue)}};this.handleInputDecrement=()=>{if(this.inputValue!=null&&this.lastInputValue!=null){this.inputValue=this.lastInputValue-1;this.handleInputChange(this.inputValue)}};this.handleInputChange=async t=>{var i,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.transformCurrent(_(this.lastDragged.identifier,t,this.lastInputValue,this.distanceUnit,this.angleUnit));this.lastInputValue=t;await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(a.multiply(this.currentTransform,a.invert(this.startingTransform))));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced((()=>{this.position=this.currentTransform!=null?l.fromMatrixPosition(this.currentTransform):this.position})))}};this.updatePropsFromViewer=()=>{const{frame:t}=this.viewer||{};if(t!=null){const i=this.getTransformWidget();i.updateFrame(t,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=t=>{var i,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((i=this.viewer)===null||i===void 0?void 0:i.frame)!=null}]`);this.widget=new it(t,{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,hovered:this.hoveredColor});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=t=>{m((()=>{this.canvasBounds=t.getBoundingClientRect();this.getTransformWidget().updateDimensions(t)}))};this.updateInputValue=()=>{var t;const i=(t=this.dragging)!==null&&t!==void 0?t:this.lastDragged;if(i!=null&&this.currentTransform!=null&&this.dragStartTransform!=null){this.lastInputValue=this.inputValue;this.inputValue=H(i.identifier,this.currentTransform,this.dragStartTransform,this.distanceUnit,this.angleUnit)}};this.transformCurrent=t=>{this.currentTransform=this.currentTransform!=null?a.multiply(this.currentTransform,t):t};this.updateInputPosition=()=>{var t,i;const s=this.getTransformWidget();const n=s.getFullBounds();const o=(t=this.dragging)!==null&&t!==void 0?t:this.lastDragged;if(((i=this.viewer)===null||i===void 0?void 0:i.frame)!=null&&this.position!=null&&o!=null&&n!=null){this.inputPosition=V(this.viewer.viewport,n,o.points.toArray())}};this.getDisplayedAngle=()=>{var t,i,s;const n=(i=(t=this.dragging)===null||t===void 0?void 0:t.identifier)!==null&&i!==void 0?i:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;if(n===null||n===void 0?void 0:n.includes("rotate")){return this.inputValue}};this.getDisplayedDistance=()=>{var t,i,s;const n=(i=(t=this.dragging)===null||t===void 0?void 0:t.identifier)!==null&&i!==void 0?i:(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=t=>{if(t!=null){const i=this.currentTransform!=null?this.currentTransform:a.makeIdentity();const s=a.makeRotation(d.fromMatrixRotation(i));const n=a.makeTranslation(t);return a.multiply(n,s)}};this.getTransformForNewRotation=t=>{const i=this.currentTransform!=null?this.currentTransform:a.makeIdentity();const s=a.invert(a.makeRotation(d.fromMatrixRotation(i)));const n=a.makeRotation(d.fromEuler(t));const o=a.multiply(i,s);return a.multiply(o,n)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange();this.handleInputResize()}disconnectedCallback(){var t,i,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(t=this.canvasResizeObserver)===null||t===void 0?void 0:t.disconnect();(i=this.inputResizeObserver)===null||i===void 0?void 0:i.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()}handleViewerChanged(t,i){var s;i===null||i===void 0?void 0:i.removeEventListener("frameDrawn",this.handleViewerFrameDrawn);i===null||i===void 0?void 0:i.removeEventListener("dimensionschange",this.handleViewerDimensionsChange);t===null||t===void 0?void 0:t.addEventListener("frameDrawn",this.handleViewerFrameDrawn);t===null||t===void 0?void 0:t.addEventListener("dimensionschange",this.handleViewerDimensionsChange);if((t===null||t===void 0?void 0:t.stream)!=null){(s=this.controller)===null||s===void 0?void 0:s.dispose();this.controller=new x(t.stream)}}handleDisabledPropertyChanged(){var t;(t=this.widget)===null||t===void 0?void 0:t.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled})}handleRotationChanged(t,i){var s;const n=t!==null&&t!==void 0?t:u.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(t==null&&this.currentTransform!=null&&a.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(i)}, current=${JSON.stringify(t)}]`);this.rotationChanged.emit(t)}handlePositionChanged(t,i){var s,n;this.currentTransform=this.getTransformForNewPosition(t);this.startingTransform=this.currentTransform;console.debug(`Updating widget position [previous=${JSON.stringify(i)}, current=${JSON.stringify(t)}]`);(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);if(t==null){this.lastDragged=undefined;this.inputPosition=undefined;(n=this.controller)===null||n===void 0?void 0:n.clearTransform()}this.positionChanged.emit(t)}render(){var i,s,o;return t(n,null,t("canvas",{ref:t=>{this.canvasRef=t},class:p("widget",{hovered:this.hovered!=null}),width:(i=this.viewer)===null||i===void 0?void 0:i.viewport.width,height:(s=this.viewer)===null||s===void 0?void 0:s.viewport.height,onPointerDown:this.handleBeginDrag}),this.inputPosition&&this.inputValue!=null&&((o=this.viewer)===null||o===void 0?void 0:o.viewport)&&t(X,{ref:t=>{var i,s;if(t!=null){(i=this.inputResizeObserver)===null||i===void 0?void 0:i.observe(t)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputRef=t},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.position,angle:this.getDisplayedAngle(),distance:this.getDisplayedDistance(),decimalPlaces:this.decimalPlaces,distanceUnit:this.distanceUnit,angleUnit:this.angleUnit,onChange:this.handleInputChange,onIncrement:this.handleInputIncrement,onDecrement:this.handleInputDecrement}))}transform(t,i,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=M(this.currentTransform,t,i,(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(a.multiply(this.currentTransform,a.invert(this.startingTransform)))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get currentRotation(){if(this.currentTransform!=null){return a.makeRotation(d.fromMatrixRotation(this.currentTransform))}return a.makeIdentity()}get hostEl(){return o(this)}static get watchers(){return{viewer:["handleViewerChanged"],xTranslationDisabled:["handleDisabledPropertyChanged"],yTranslationDisabled:["handleDisabledPropertyChanged"],zTranslationDisabled:["handleDisabledPropertyChanged"],xRotationDisabled:["handleDisabledPropertyChanged"],yRotationDisabled:["handleDisabledPropertyChanged"],zRotationDisabled:["handleDisabledPropertyChanged"],rotation:["handleRotationChanged"],position:["handlePositionChanged"]}}};nt.style=st;export{nt as vertex_viewer_transform_widget};
5
- //# sourceMappingURL=p-ff7e05fe.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["src/components/viewer-transform-widget/util.ts","src/components/viewer-transform-widget/viewer-transform-widget-components.tsx","src/lib/transforms/axis-rotation.ts","src/lib/transforms/hits.ts","src/components/viewer-transform-widget/widget.ts","src/components/viewer-transform-widget/viewer-transform-widget.css?tag=vertex-viewer-transform-widget&encapsulation=shadow","src/components/viewer-transform-widget/viewer-transform-widget.tsx"],"names":["convertPointToCanvas","point","bounds","Point","create","x","left","y","top","undefined","convertCanvasPointToWorld","frame","viewport","transform","position","Vector3","fromMatrixPosition","scene","camera","isOrthographic","ray","transformPointToOrthographicRay","image","offsetPoint","Ray","at","origin","direction","magnitude","viewVector","intersectPlane","Plane","fromNormalAndCoplanarPoint","transformPointToRay","computeInputTransform","identifier","value","lastValue","distanceUnit","angleUnit","units","DistanceUnits","angles","AngleUnits","rotation","convertFrom","convertRealValueToWorld","Matrix4","makeTranslation","makeRotation","Quaternion","fromAxisAngle","down","forward","makeIdentity","computeInputDisplayValue","current","start","fromMatrixRotation","transformDiff","multiply","invert","relativeTranslationDiff","transformMatrix","relativeRotationDiff","Euler","fromRotationMatrix","convertWorldValueToReal","z","convertTo","computeUpdatedTransform","previous","next","angle","delta","subtract","computeTranslation","right","up","back","computeRotation","computeRotationAxis","axis","rotatedAxis","rotatedNegatedAxis","negate","dot","rotatedDelta","scale","computeInputPosition","shapePoints","paddedBounds","Rectangle","pad","canvasPoints","map","sp","transformNdcPointToViewport","topLeft","topRight","add","width","bottomRight","bottomLeft","center","reduce","sum","pt","length","closestPoint","closest","distance","TransformWidgetInput","ref","placement","decimalPlaces","onChange","onIncrement","onDecrement","displayValue","toFixed","unit","abbreviatedName","inputPlacement","computeInputPlacement","Dimensions","handleChange","event","target","parsed","parseFloat","isNaN","handleKeyDown","key","h","class","style","Object","assign","onKeyDown","type","constrainTo","dimension","Math","min","max","inputDimensions","height","dimensions","toCssLength","bottom","xAxisRotationPositions","widgetTransform","triangleSize","computeRotationNdcValues","yAxisRotationPositions","zAxisRotationPositions","xDirection","yDirection","transformedDirection","transformedX","transformedY","basePosition","xRay","yRay","rotationAxis","cross","base","rotateAboutAxis","Angle","toRadians","TriangleMeshPoints","projectionViewMatrix","testDrawable","drawable","TriangleMesh","testTriangleMesh","mesh","testTriangle","points","worldLeft","worldRight","worldTip","worldBase","edge1","edge2","epsilon","BoundingBox","_a","fromVectors","p","det","abs","t","u","q","v","r","TransformWidget","ReglComponent","[object Object]","canvasElement","colors","initialDisabledAxes","super","this","disabledAxis","xTranslation","yTranslation","zTranslation","xRotation","yRotation","zRotation","axisLines","rotationLines","translationMeshes","rotationMeshes","hoveredChanged","EventDispatcher","xArrowFillColor","xArrow","yArrowFillColor","yArrow","zArrowFillColor","zArrow","hoveredArrowFillColor","hovered","outlineColor","outline","_b","_c","_d","_e","_f","reglFrameDisposable","cancel","drawableElements","fullBounds","interactiveBounds","containsPoints","updateDisabledOnDrawables","cursor","updateHovered","clearHovered","updateAndDraw","clear","updateFillColor","getXTranslationColor","_g","getYTranslationColor","_h","getZTranslationColor","_j","getXRotationColor","_k","getYRotationColor","_l","getZRotationColor","_m","hoveredElement","listener","on","setDisabled","xyRotationLine","xzRotationLine","yzRotationLine","yxRotationLine","zxRotationLine","zyRotationLine","updateColors","previousHovered","currentFrame","filter","el","valid","isDisabled","find","m","emit","initialFillColor","createElements","updateElements","computeDrawable2dBounds","reglCommand","regl","canvas","extensions","createShape","shapeBuilder","computeTriangleSize","xAxisArrowPositions","xAxis","AxisLine","axisPositions","yAxisArrowPositions","yAxis","zAxisArrowPositions","zAxis","createRotationLines","availableElements","xyRotationLinePoints","rotationAxisPositions","xzRotationLinePoints","yxRotationLinePoints","yzRotationLinePoints","zxRotationLinePoints","zyRotationLinePoints","RotationLine","l","updatePoints","_o","_p","_q","_r","_s","_t","viewerTransformWidgetCss","ViewerTransformWidget","hostRef","xRotationDisabled","yRotationDisabled","zRotationDisabled","xTranslationDisabled","yTranslationDisabled","zTranslationDisabled","xArrowColor","yArrowColor","zArrowColor","hoveredColor","lastAngle","handleHoveredDrawableChanged","handleViewerFrameDrawn","updatePropsFromViewer","handleViewerDimensionsChange","writeDOM","viewer","canvasRef","updateCanvasBounds","handleResize","handleInputResize","console","log","inputRef","inputElement","readDOM","inputBounds","getBoundingClientRect","handleStyleChange","hostStyles","window","getComputedStyle","hostEl","getPropertyValue","trim","getTransformWidget","handlePointerMove","dragging","canvasPoint","clientX","clientY","getCanvasBounds","widget","boundsContainsPoint","updateCursor","handleBeginDrag","async","canvasBounds","lastDragged","dragStartTransform","currentTransform","currentCanvas","widgetCenter","transformWorldToViewport","fromPoints","lastWorldPosition","interactionStarted","removeEventListener","addEventListener","handleDrag","handleEndTransform","preventDefault","controller","beginTransform","currentWorld","updateInputPosition","updateInputValue","updateTransform","updateDisabledAxis","getCurrentDelta","endTransform","interactionEnded","e","error","handleInputIncrement","inputValue","lastInputValue","handleInputChange","handleInputDecrement","startingTransform","transformCurrent","endTransformDebounced","updateFrame","setupTransformWidget","debug","JSON","stringify","getTransformForNewRotation","getTransformForNewPosition","handleSettingDisabledAxis","hoveredChangeDisposable","onHoveredChanged","updateDimensions","widgetBounds","getFullBounds","inputPosition","toArray","getDisplayedAngle","draggingIdentifier","includes","getDisplayedDistance","newPosition","c","currentRotation","newRotationEuler","oldRotation","newRotation","fromEuler","oldTranslation","Error","canvasResizeObserver","ResizeObserver","inputResizeObserver","hostStyleObserver","MutationObserver","observe","attributes","attributeFilter","handleViewerChanged","disconnect","dispose","newViewer","oldViewer","stream","TransformController","rotationToApply","isIdentity","rotationChanged","oldPosition","clearTransform","positionChanged","Host","classNames","onPointerDown","unobserve","warn"],"mappings":";;;mkBAyBgBA,EACdC,EACAC,GAEA,OAAOA,GAAU,KACbC,EAAMC,OAAOH,EAAMI,EAAIH,EAAOI,KAAML,EAAMM,EAAIL,EAAOM,KACrDC,mBAGUC,EACdT,EACAU,EACAC,EACAC,GAEA,MAAMC,EACJD,GAAa,KAAOE,EAAQC,mBAAmBH,GAAaJ,UAE9D,GAAIR,GAAS,MAAQU,GAAS,MAAQC,GAAY,MAAQE,GAAY,KAAM,CAC1E,GAAIH,EAAMM,MAAMC,OAAOC,iBAAkB,CACvC,MAAMC,EAAMR,EAASS,gCACnBpB,EACAU,EAAMW,MACNX,EAAMM,MAAMC,QAId,MAAMK,EAAcC,EAAIC,GACtBD,EAAIpB,OAAO,CACTsB,OAAQZ,EACRa,UAAWhB,EAAMM,MAAMC,OAAOS,YAEhCZ,EAAQa,UAAUjB,EAAMM,MA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\n Quaternion,\n Ray,\n Rectangle,\n Vector3,\n} from '@vertexvis/geometry';\n\nimport {\n AngleUnits,\n AngleUnitType,\n DistanceUnits,\n DistanceUnitType,\n Frame,\n Viewport,\n} from '../../lib/types';\n\nexport interface PointAndPosition {\n point: Point.Point;\n position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n}\n\nexport function convertPointToCanvas(\n point: Point.Point,\n bounds?: DOMRect\n): Point.Point | undefined {\n return bounds != null\n ? Point.create(point.x - bounds.left, point.y - bounds.top)\n : undefined;\n}\n\nexport function convertCanvasPointToWorld(\n point?: Point.Point,\n frame?: Frame,\n viewport?: Viewport,\n transform?: Matrix4.Matrix4\n): Vector3.Vector3 | undefined {\n const position =\n transform != null ? Vector3.fromMatrixPosition(transform) : undefined;\n\n if (point != null && frame != null && viewport != null && position != null) {\n if (frame.scene.camera.isOrthographic()) {\n const ray = viewport.transformPointToOrthographicRay(\n point,\n frame.image,\n frame.scene.camera\n );\n // Offset the point to past the bounding sphere of the model to\n // adjust the position plane location.\n const offsetPoint = Ray.at(\n Ray.create({\n origin: position,\n direction: frame.scene.camera.direction,\n }),\n Vector3.magnitude(frame.scene.camera.viewVector) * 2\n );\n\n return Ray.intersectPlane(\n ray,\n Plane.fromNormalAndCoplanarPoint(\n frame.scene.camera.direction,\n offsetPoint\n )\n );\n } else {\n const ray = viewport.transformPointToRay(\n point,\n frame.image,\n frame.scene.camera\n );\n\n return Ray.intersectPlane(\n ray,\n Plane.fromNormalAndCoplanarPoint(frame.scene.camera.direction, position)\n );\n }\n }\n return undefined;\n}\n\nexport function computeInputTransform(\n identifier: string,\n value: number,\n lastValue: number,\n distanceUnit: DistanceUnitType = 'millimeters',\n angleUnit: AngleUnitType = 'degrees'\n): Matrix4.Matrix4 {\n const units = new DistanceUnits(distanceUnit);\n const angles = new AngleUnits(angleUnit);\n\n const rotation = (): number => angles.convertFrom(value - lastValue);\n const position = (): number =>\n units.convertRealValueToWorld(value - lastValue);\n\n switch (identifier) {\n case 'x-translate':\n return Matrix4.makeTranslation(Vector3.create(position(), 0, 0));\n case 'y-translate':\n return Matrix4.makeTranslation(Vector3.create(0, position(), 0));\n case 'z-translate':\n return Matrix4.makeTranslation(Vector3.create(0, 0, position()));\n case 'x-rotate':\n return Matrix4.makeRotation(\n Quaternion.fromAxisAngle(Vector3.left(), rotation())\n );\n case 'y-rotate':\n return Matrix4.makeRotation(\n Quaternion.fromAxisAngle(Vector3.down(), rotation())\n );\n case 'z-rotate':\n return Matrix4.makeRotation(\n Quaternion.fromAxisAngle(Vector3.forward(), rotation())\n );\n }\n return Matrix4.makeIdentity();\n}\n\nexport function computeInputDisplayValue(\n identifier: string,\n current: Matrix4.Matrix4,\n start: Matrix4.Matrix4,\n distanceUnit: DistanceUnitType = 'millimeters',\n angleUnit: AngleUnitType = 'degrees'\n): number {\n const units = new DistanceUnits(distanceUnit);\n const angles = new AngleUnits(angleUnit);\n\n const rotation = (): Matrix4.Matrix4 =>\n Matrix4.makeRotation(Quaternion.fromMatrixRotation(current));\n const transformDiff = (): Matrix4.Matrix4 =>\n Matrix4.multiply(current, Matrix4.invert(start));\n const relativeTranslationDiff = (): Vector3.Vector3 =>\n Vector3.transformMatrix(\n Vector3.fromMatrixPosition(transformDiff()),\n Matrix4.invert(rotation())\n );\n const relativeRotationDiff = (): Euler.Euler =>\n Euler.create(\n Vector3.transformMatrix(\n Euler.fromRotationMatrix(Matrix4.invert(transformDiff())),\n Matrix4.invert(rotation())\n )\n );\n\n switch (identifier) {\n case 'x-translate':\n return units.convertWorldValueToReal(relativeTranslationDiff().x);\n case 'y-translate':\n return units.convertWorldValueToReal(relativeTranslationDiff().y);\n case 'z-translate':\n return units.convertWorldValueToReal(relativeTranslationDiff().z);\n case 'x-rotate':\n return angles.convertTo(relativeRotationDiff().x);\n case 'y-rotate':\n return angles.convertTo(relativeRotationDiff().y);\n case 'z-rotate':\n return angles.convertTo(relativeRotationDiff().z);\n }\n return 0;\n}\n\nexport function computeUpdatedTransform(\n current: Matrix4.Matrix4,\n previous: Vector3.Vector3,\n next: Vector3.Vector3,\n viewVector: Vector3.Vector3,\n angle: number,\n identifier: string\n): Matrix4.Matrix4 {\n const delta = Vector3.subtract(next, previous);\n\n switch (identifier) {\n case 'x-translate': {\n return Matrix4.multiply(\n current,\n computeTranslation(current, Vector3.right(), delta)\n );\n }\n case 'y-translate':\n return Matrix4.multiply(\n current,\n computeTranslation(current, Vector3.up(), delta)\n );\n case 'z-translate':\n return Matrix4.multiply(\n current,\n computeTranslation(current, Vector3.back(), delta)\n );\n case 'x-rotate':\n return Matrix4.multiply(\n computeRotation(\n current,\n Matrix4.makeRotation(\n Quaternion.fromAxisAngle(\n computeRotationAxis(current, viewVector, Vector3.right()),\n angle\n )\n )\n ),\n current\n );\n case 'y-rotate':\n return Matrix4.multiply(\n computeRotation(\n current,\n Matrix4.makeRotation(\n Quaternion.fromAxisAngle(\n computeRotationAxis(current, viewVector, Vector3.up()),\n angle\n )\n )\n ),\n current\n );\n case 'z-rotate':\n return Matrix4.multiply(\n computeRotation(\n current,\n Matrix4.makeRotation(\n Quaternion.fromAxisAngle(\n computeRotationAxis(current, viewVector, Vector3.forward()),\n angle\n )\n )\n ),\n current\n );\n default:\n return current;\n }\n}\n\nexport function computeRotationAxis(\n current: Matrix4.Matrix4,\n viewVector: Vector3.Vector3,\n axis: Vector3.Vector3\n): Vector3.Vector3 {\n const rotation = Matrix4.makeRotation(Quaternion.fromMatrixRotation(current));\n const rotatedAxis = Vector3.transformMatrix(axis, rotation);\n const rotatedNegatedAxis = Vector3.transformMatrix(\n Vector3.negate(axis),\n rotation\n );\n\n return Vector3.dot(viewVector, rotatedAxis) >\n Vector3.dot(viewVector, rotatedNegatedAxis)\n ? rotatedAxis\n : rotatedNegatedAxis;\n}\n\nexport function computeTranslation(\n current: Matrix4.Matrix4,\n axis: Vector3.Vector3,\n delta: Vector3.Vector3\n): Matrix4.Matrix4 {\n const rotation = Matrix4.makeRotation(Quaternion.fromMatrixRotation(current));\n const rotatedAxis = Vector3.transformMatrix(axis, rotation);\n const rotatedDelta = Vector3.multiply(rotatedAxis, delta);\n\n return Matrix4.makeTranslation(\n Vector3.scale(rotatedDelta.x + rotatedDelta.y + rotatedDelta.z, axis)\n );\n}\n\n/**\n * Computes a rotation Matrix4 by applying the rotation at the given position,\n * then translating it back to convert it to a world delta.\n * @param rotation\n * @param current\n * @returns\n */\nexport function computeRotation(\n current: Matrix4.Matrix4,\n delta: Matrix4.Matrix4\n): Matrix4.Matrix4 {\n return Matrix4.multiply(\n Matrix4.multiply(\n Matrix4.makeTranslation(Vector3.fromMatrixPosition(current)),\n delta\n ),\n Matrix4.makeTranslation(Vector3.negate(Vector3.fromMatrixPosition(current)))\n );\n}\n\nexport function computeInputPosition(\n viewport: Viewport,\n bounds: Rectangle.Rectangle,\n shapePoints: Point.Point[]\n): PointAndPosition {\n const paddedBounds = Rectangle.pad(bounds, 5);\n const canvasPoints = shapePoints.map((sp) =>\n viewport.transformNdcPointToViewport(sp)\n );\n\n const topLeft = Rectangle.topLeft(paddedBounds);\n const topRight = Point.add(topLeft, Point.create(paddedBounds.width, 0));\n const bottomRight = Rectangle.bottomRight(paddedBounds);\n const bottomLeft = Point.subtract(\n bottomRight,\n Point.create(paddedBounds.width, 0)\n );\n\n const center = Point.scale(\n canvasPoints.reduce((sum, pt) => Point.add(sum, pt), Point.create()),\n 1 / canvasPoints.length,\n 1 / canvasPoints.length\n );\n\n const closestPoint = [topRight, bottomLeft, bottomRight].reduce(\n (closest, pt) =>\n Point.distance(center, pt) < Point.distance(center, closest)\n ? pt\n : closest,\n topLeft\n );\n\n switch (closestPoint) {\n case topLeft:\n return { point: closestPoint, position: 'top-left' };\n case topRight:\n return { point: closestPoint, position: 'top-right' };\n case bottomLeft:\n return { point: closestPoint, position: 'bottom-left' };\n default:\n return { point: closestPoint, position: 'bottom-right' };\n }\n}\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { FunctionalComponent, h } from '@stencil/core';\nimport { Dimensions, Point } from '@vertexvis/geometry';\n\nimport {\n AngleUnits,\n AngleUnitType,\n DistanceUnits,\n DistanceUnitType,\n Viewport,\n} from '../../lib/types';\n\nexport type TransformWidgetInputPlacement =\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right';\n\nexport interface TransformWidgetInputProps {\n ref: (el?: HTMLInputElement) => void;\n bounds?: DOMRect;\n\n viewport: Viewport;\n point: Point.Point;\n placement: TransformWidgetInputPlacement;\n\n distance?: number;\n angle?: number;\n decimalPlaces: number;\n distanceUnit: DistanceUnitType;\n angleUnit: AngleUnitType;\n\n onChange?: (value: number) => void | Promise<void>;\n onIncrement?: VoidFunction;\n onDecrement?: VoidFunction;\n}\n\nexport const TransformWidgetInput: FunctionalComponent<\n TransformWidgetInputProps\n> = ({\n ref,\n bounds,\n viewport,\n point,\n placement,\n distance,\n angle,\n decimalPlaces,\n distanceUnit,\n angleUnit,\n onChange,\n onIncrement,\n onDecrement,\n}) => {\n const angles = new AngleUnits(angleUnit);\n const units = new DistanceUnits(distanceUnit);\n const displayValue =\n distance != null\n ? `${distance.toFixed(decimalPlaces)} ${units.unit.abbreviatedName}`\n : `${angle?.toFixed(decimalPlaces)} ${angles.unit.abbreviatedName}`;\n const inputPlacement = computeInputPlacement(\n viewport,\n bounds ?? Dimensions.create(100, 30),\n point,\n placement\n );\n\n const handleChange = (event: Event): void => {\n if (event.target != null) {\n const parsed = parseFloat((event.target as HTMLInputElement).value);\n\n if (!isNaN(parsed)) {\n onChange?.(parseFloat((event.target as HTMLInputElement).value));\n }\n }\n };\n\n const handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'ArrowUp') {\n onIncrement?.();\n } else if (event.key === 'ArrowDown') {\n onDecrement?.();\n }\n };\n\n return (\n <div\n class=\"widget-input wrapper\"\n style={{ ...inputPlacement }}\n onKeyDown={handleKeyDown}\n >\n <input\n ref={ref}\n class=\"widget-input\"\n type=\"text\"\n value={displayValue}\n onChange={handleChange}\n ></input>\n </div>\n );\n};\n\nfunction constrainTo(dimension: number, length: number): number {\n return Math.min(dimension, Math.max(0, length));\n}\n\ninterface InputPlacement {\n left?: string;\n right?: string;\n top?: string;\n bottom?: string;\n}\n\nfunction computeInputPlacement(\n viewport: Viewport,\n inputDimensions: Dimensions.Dimensions,\n point: Point.Point,\n placement: TransformWidgetInputPlacement\n): InputPlacement {\n const { width, height } = viewport.dimensions;\n\n function toCssLength(length: number): string {\n return `${length}px`;\n }\n\n switch (placement) {\n case 'top-left':\n return {\n right: toCssLength(\n constrainTo(width - inputDimensions.width, width - point.x)\n ),\n bottom: toCssLength(\n constrainTo(height - inputDimensions.height, height - point.y)\n ),\n };\n case 'top-right':\n return {\n left: toCssLength(constrainTo(width - inputDimensions.width, point.x)),\n bottom: toCssLength(\n constrainTo(height - inputDimensions.height, height - point.y)\n ),\n };\n case 'bottom-left':\n return {\n right: toCssLength(\n constrainTo(width - inputDimensions.width, width - point.x)\n ),\n top: toCssLength(constrainTo(height - inputDimensions.height, point.y)),\n };\n case 'bottom-right':\n default:\n return {\n left: toCssLength(constrainTo(width - inputDimensions.width, point.x)),\n top: toCssLength(constrainTo(height - inputDimensions.height, point.y)),\n };\n }\n}\n","import { Angle, Matrix4, Quaternion, Ray, Vector3 } from '@vertexvis/geometry';\n\nimport { FrameCameraBase } from '../types';\nimport { TriangleMeshPoints } from './mesh';\n\nexport function xAxisRotationPositions(\n widgetTransform: Matrix4.Matrix4,\n camera: FrameCameraBase,\n triangleSize = 3\n): TriangleMeshPoints {\n return computeRotationNdcValues(\n widgetTransform,\n camera,\n Vector3.back(),\n Vector3.up(),\n triangleSize\n );\n}\n\nexport function yAxisRotationPositions(\n widgetTransform: Matrix4.Matrix4,\n camera: FrameCameraBase,\n triangleSize = 3\n): TriangleMeshPoints {\n return computeRotationNdcValues(\n widgetTransform,\n camera,\n Vector3.right(),\n Vector3.back(),\n triangleSize\n );\n}\n\nexport function zAxisRotationPositions(\n widgetTransform: Matrix4.Matrix4,\n camera: FrameCameraBase,\n triangleSize = 3\n): TriangleMeshPoints {\n return computeRotationNdcValues(\n widgetTransform,\n camera,\n Vector3.right(),\n Vector3.up(),\n triangleSize\n );\n}\n\nfunction computeRotationNdcValues(\n widgetTransform: Matrix4.Matrix4,\n camera: FrameCameraBase,\n xDirection: Vector3.Vector3,\n yDirection: Vector3.Vector3,\n triangleSize: number\n): TriangleMeshPoints {\n const transformedDirection = Vector3.transformMatrix(\n Vector3.add(xDirection, yDirection),\n Matrix4.makeRotation(Quaternion.fromMatrixRotation(widgetTransform))\n );\n const transformedX = Vector3.transformMatrix(\n xDirection,\n Matrix4.makeRotation(Quaternion.fromMatrixRotation(widgetTransform))\n );\n const transformedY = Vector3.transformMatrix(\n yDirection,\n Matrix4.makeRotation(Quaternion.fromMatrixRotation(widgetTransform))\n );\n const basePosition = Vector3.fromMatrixPosition(widgetTransform);\n const position = Vector3.add(\n basePosition,\n Vector3.scale(triangleSize * 10, transformedDirection)\n );\n\n const xRay = Ray.create({\n origin: position,\n direction: transformedX,\n });\n const yRay = Ray.create({\n origin: position,\n direction: transformedY,\n });\n const rotationAxis = Vector3.cross(transformedX, transformedY);\n\n const base = Vector3.rotateAboutAxis(\n Angle.toRadians(45),\n Ray.at(yRay, -triangleSize),\n rotationAxis,\n position\n );\n const right = Vector3.rotateAboutAxis(\n Angle.toRadians(45),\n Ray.at(xRay, triangleSize),\n rotationAxis,\n position\n );\n const up = Vector3.rotateAboutAxis(\n Angle.toRadians(45),\n Ray.at(yRay, triangleSize),\n rotationAxis,\n position\n );\n const left = Vector3.rotateAboutAxis(\n Angle.toRadians(45),\n Ray.at(xRay, -triangleSize),\n rotationAxis,\n position\n );\n\n return new TriangleMeshPoints(\n Vector3.dot(transformedX, camera.direction) !== -1 &&\n Vector3.dot(transformedY, camera.direction) !== -1,\n base,\n left,\n right,\n up,\n Vector3.transformMatrix(base, camera.projectionViewMatrix),\n Vector3.transformMatrix(left, camera.projectionViewMatrix),\n Vector3.transformMatrix(right, camera.projectionViewMatrix),\n Vector3.transformMatrix(up, camera.projectionViewMatrix)\n );\n}\n","import { BoundingBox, Point, Vector3 } from '@vertexvis/geometry';\n\nimport { Frame, Viewport } from '../../lib/types';\nimport { Drawable } from './drawable';\nimport { TriangleMesh } from './mesh';\n\nexport function testDrawable(\n drawable: Drawable,\n frame: Frame,\n viewport: Viewport,\n point: Point.Point\n): boolean {\n if (drawable instanceof TriangleMesh) {\n return testTriangleMesh(drawable, frame, viewport, point);\n }\n return false;\n}\n\nexport function testTriangleMesh(\n mesh: TriangleMesh,\n frame: Frame,\n viewport: Viewport,\n point: Point.Point\n): boolean {\n return (\n testTriangle(\n [mesh.points.worldLeft, mesh.points.worldRight, mesh.points.worldTip],\n frame,\n viewport,\n point\n ) ||\n testTriangle(\n [mesh.points.worldLeft, mesh.points.worldRight, mesh.points.worldBase],\n frame,\n viewport,\n point\n )\n );\n}\n\n/**\n * Adapted from https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm.\n */\nexport function testTriangle(\n points: Vector3.Vector3[],\n frame: Frame,\n viewport: Viewport,\n point: Point.Point\n): boolean {\n if (points.length === 3) {\n const ray = frame.scene.camera.isOrthographic()\n ? viewport.transformPointToOrthographicRay(\n point,\n frame.image,\n frame.scene.camera\n )\n : viewport.transformPointToRay(point, frame.image, frame.scene.camera);\n\n const edge1 = Vector3.subtract(points[1], points[0]);\n const edge2 = Vector3.subtract(points[2], points[0]);\n\n const epsilon = BoundingBox.epsilon(\n BoundingBox.fromVectors([ray.direction, ray.origin, edge1, edge2]) ??\n BoundingBox.create(edge1, edge2)\n );\n\n const p = Vector3.cross(ray.direction, edge2);\n const det = Vector3.dot(edge1, p);\n\n // This check causes a `det` of NaN or 0 to return false\n // without needing to perform the subsequent calculations.\n if (!(Math.abs(det) >= epsilon)) {\n return false;\n }\n\n const t = Vector3.subtract(ray.origin, points[0]);\n const u = Vector3.dot(t, p) / det;\n\n if (u < 0 || u > 1) {\n return false;\n }\n\n const q = Vector3.cross(t, edge1);\n const v = Vector3.dot(ray.direction, q) / det;\n\n if (v < 0 || u + v > 1) {\n return false;\n }\n\n const r = Vector3.dot(edge2, q) / det;\n\n // Ignore the case where the computed hit position is negative\n // if in orthographic to correctly return hit results when close\n // to the camera.\n // TODO: revisit with https://vertexvis.atlassian.net/browse/PLAT-1549\n return !isNaN(r) && (r > 0 || frame.scene.camera.isOrthographic());\n }\n return false;\n}\n","import { Matrix4 } from '@vertexvis/geometry';\nimport { Point, Rectangle, Vector3 } from '@vertexvis/geometry';\nimport { Color, Disposable, EventDispatcher, Listener } from '@vertexvis/utils';\nimport regl from 'regl';\nimport shapeBuilder from 'regl-shape';\n\nimport {\n axisPositions,\n rotationAxisPositions,\n} from '../../lib/transforms/axis-lines';\nimport {\n xAxisRotationPositions,\n yAxisRotationPositions,\n zAxisRotationPositions,\n} from '../../lib/transforms/axis-rotation';\nimport {\n xAxisArrowPositions,\n yAxisArrowPositions,\n zAxisArrowPositions,\n} from '../../lib/transforms/axis-translation';\nimport {\n computeDrawable2dBounds,\n Drawable,\n} from '../../lib/transforms/drawable';\nimport { testDrawable } from '../../lib/transforms/hits';\nimport { AxisLine, RotationLine } from '../../lib/transforms/line';\nimport { TriangleMesh } from '../../lib/transforms/mesh';\nimport { CreateShape } from '../../lib/transforms/shape';\nimport { Frame } from '../../lib/types';\nimport { ReglComponent } from '../../lib/webgl/regl-component';\n\nexport interface DrawableElementColors {\n xArrow?: Color.Color | string;\n yArrow?: Color.Color | string;\n zArrow?: Color.Color | string;\n hovered?: Color.Color | string;\n outline?: Color.Color | string;\n}\n\nexport interface DisabledAxis {\n xRotation: boolean;\n yRotation: boolean;\n zRotation: boolean;\n xTranslation: boolean;\n yTranslation: boolean;\n zTranslation: boolean;\n}\n\nexport class TransformWidget extends ReglComponent {\n private cursor?: Point.Point;\n\n private xAxis?: AxisLine;\n private yAxis?: AxisLine;\n private zAxis?: AxisLine;\n private xArrow?: TriangleMesh;\n private yArrow?: TriangleMesh;\n private zArrow?: TriangleMesh;\n private xRotation?: TriangleMesh;\n private xyRotationLine?: RotationLine;\n private xzRotationLine?: RotationLine;\n private yRotation?: TriangleMesh;\n private yxRotationLine?: RotationLine;\n private yzRotationLine?: RotationLine;\n private zRotation?: TriangleMesh;\n private zxRotationLine?: RotationLine;\n private zyRotationLine?: RotationLine;\n\n private disabledAxis: DisabledAxis = {\n xTranslation: false,\n yTranslation: false,\n zTranslation: false,\n xRotation: false,\n yRotation: false,\n zRotation: false,\n };\n\n private axisLines: AxisLine[] = [];\n private rotationLines: RotationLine[] = [];\n private translationMeshes: TriangleMesh[] = [];\n private rotationMeshes: TriangleMesh[] = [];\n private hoveredElement?: Drawable;\n\n private transform?: Matrix4.Matrix4;\n private interactiveBounds?: Rectangle.Rectangle;\n private fullBounds?: Rectangle.Rectangle;\n\n private hoveredChanged = new EventDispatcher<Drawable | undefined>();\n\n private xArrowFillColor?: Color.Color | string;\n private yArrowFillColor?: Color.Color | string;\n private zArrowFillColor?: Color.Color | string;\n\n private hoveredArrowFillColor?: Color.Color | string;\n private outlineColor?: Color.Color | string;\n\n public constructor(\n canvasElement: HTMLCanvasElement,\n colors: DrawableElementColors = {},\n initialDisabledAxes: Partial<DisabledAxis> = {}\n ) {\n super(canvasElement);\n\n this.xArrowFillColor = colors.xArrow;\n this.yArrowFillColor = colors.yArrow;\n this.zArrowFillColor = colors.zArrow;\n this.hoveredArrowFillColor = colors.hovered;\n this.outlineColor = colors.outline;\n\n this.disabledAxis.xTranslation = initialDisabledAxes.xTranslation ?? false;\n this.disabledAxis.yTranslation = initialDisabledAxes.yTranslation ?? false;\n this.disabledAxis.zTranslation = initialDisabledAxes.zTranslation ?? false;\n this.disabledAxis.xRotation = initialDisabledAxes.xRotation ?? false;\n this.disabledAxis.yRotation = initialDisabledAxes.yRotation ?? false;\n this.disabledAxis.zRotation = initialDisabledAxes.zRotation ?? false;\n }\n\n public dispose(): void {\n this.reglFrameDisposable?.cancel();\n }\n\n /**\n * @internal - visible for testing\n */\n public getDrawableElements(): Drawable[] {\n return this.drawableElements;\n }\n\n public getFullBounds(): Rectangle.Rectangle | undefined {\n return this.fullBounds;\n }\n\n public boundsContainsPoint(point: Point.Point): boolean {\n return (\n this.interactiveBounds != null &&\n this.frame != null &&\n Rectangle.containsPoints(this.interactiveBounds, point)\n );\n }\n\n public updateDisabledAxis(axis: Partial<DisabledAxis>): void {\n this.disabledAxis = {\n ...this.disabledAxis,\n ...axis,\n };\n this.updateDisabledOnDrawables();\n }\n\n public updateCursor(cursor?: Point.Point): void {\n this.cursor = cursor;\n\n if (cursor != null && this.frame != null) {\n this.updateHovered();\n } else {\n this.clearHovered();\n }\n }\n\n public updateTransform(transform?: Matrix4.Matrix4): void {\n this.transform = transform;\n\n if (transform != null && this.frame != null) {\n this.updateAndDraw();\n } else {\n this.clear();\n this.reglFrameDisposable?.cancel();\n this.reglFrameDisposable = undefined;\n }\n }\n\n public updateColors(colors: DrawableElementColors = {}): void {\n this.xArrowFillColor = colors.xArrow ?? this.xArrowFillColor;\n this.yArrowFillColor = colors.yArrow ?? this.yArrowFillColor;\n this.zArrowFillColor = colors.zArrow ?? this.zArrowFillColor;\n this.hoveredArrowFillColor = colors.hovered ?? this.hoveredArrowFillColor;\n this.outlineColor = colors.outline ?? this.outlineColor;\n\n this.xArrow?.updateFillColor(this.getXTranslationColor(), true);\n this.yArrow?.updateFillColor(this.getYTranslationColor(), true);\n this.zArrow?.updateFillColor(this.getZTranslationColor(), true);\n this.xRotation?.updateFillColor(this.getXRotationColor(), true);\n this.yRotation?.updateFillColor(this.getYRotationColor(), true);\n this.zRotation?.updateFillColor(this.getZRotationColor(), true);\n this.hoveredElement?.updateFillColor(this.hoveredArrowFillColor);\n }\n\n public onHoveredChanged(\n listener: Listener<Drawable | undefined>\n ): Disposable {\n return this.hoveredChanged.on(listener);\n }\n\n private updateDisabledOnDrawables(): void {\n this.xRotation?.setDisabled(this.disabledAxis.xRotation);\n this.xyRotationLine?.setDisabled(this.disabledAxis.xRotation);\n this.xzRotationLine?.setDisabled(this.disabledAxis.xRotation);\n\n this.yRotation?.setDisabled(this.disabledAxis.yRotation);\n this.yzRotationLine?.setDisabled(this.disabledAxis.yRotation);\n this.yxRotationLine?.setDisabled(this.disabledAxis.yRotation);\n\n this.zRotation?.setDisabled(this.disabledAxis.zRotation);\n this.zxRotationLine?.setDisabled(this.disabledAxis.zRotation);\n this.zyRotationLine?.setDisabled(this.disabledAxis.zRotation);\n\n this.xArrow?.setDisabled(this.disabledAxis.xTranslation);\n this.yArrow?.setDisabled(this.disabledAxis.yTranslation);\n this.zArrow?.setDisabled(this.disabledAxis.zTranslation);\n\n this.updateColors();\n }\n\n private updateHovered(): void {\n const previousHovered = this.hoveredElement;\n const currentFrame = this.frame;\n\n if (currentFrame != null) {\n this.hoveredElement = [...this.translationMeshes, ...this.rotationMeshes]\n .filter((el) => el.points.valid && !el.isDisabled())\n .find((m) =>\n this.cursor != null\n ? testDrawable(m, currentFrame, this.viewport, this.cursor)\n : false\n );\n\n if (this.hoveredElement !== previousHovered) {\n this.hoveredChanged.emit(this.hoveredElement);\n this.hoveredElement?.updateFillColor(this.hoveredArrowFillColor);\n previousHovered?.updateFillColor(previousHovered?.initialFillColor);\n }\n }\n }\n\n private clearHovered(): void {\n const previousHovered = this.hoveredElement;\n this.hoveredElement = undefined;\n\n if (this.hoveredElement !== previousHovered) {\n this.hoveredChanged.emit(this.hoveredElement);\n previousHovered.updateFillColor(previousHovered.initialFillColor);\n }\n }\n\n protected hasData(): boolean {\n return this.transform != null;\n }\n\n protected createOrUpdateElements(): void {\n if (this.transform != null && this.frame != null) {\n if (this.xArrow == null || this.yArrow == null || this.zArrow == null) {\n this.createElements(this.transform, this.frame);\n } else {\n this.updateElements(this.transform, this.frame);\n }\n\n this.interactiveBounds = computeDrawable2dBounds(\n this.viewport,\n ...this.rotationMeshes,\n ...this.translationMeshes\n );\n this.fullBounds = computeDrawable2dBounds(\n this.viewport,\n ...this.rotationMeshes,\n ...this.translationMeshes,\n ...this.axisLines\n );\n }\n }\n\n private createElements(transform: Matrix4.Matrix4, frame: Frame): void {\n this.reglCommand = regl({\n canvas: this.canvasElement,\n extensions: 'angle_instanced_arrays',\n });\n const { createShape } = shapeBuilder(this.reglCommand);\n\n const triangleSize = this.computeTriangleSize(\n Vector3.fromMatrixPosition(transform),\n frame\n );\n\n this.xArrow = new TriangleMesh(\n createShape,\n 'x-translate',\n xAxisArrowPositions(transform, frame.scene.camera, triangleSize),\n this.outlineColor,\n this.getXTranslationColor()\n );\n\n this.xRotation = new TriangleMesh(\n createShape,\n 'x-rotate',\n xAxisRotationPositions(transform, frame.scene.camera, triangleSize),\n this.outlineColor,\n this.getXRotationColor()\n );\n this.xAxis = new AxisLine(\n createShape,\n 'x-axis',\n axisPositions(transform, frame.scene.camera, this.xArrow),\n this.outlineColor,\n this.getXTranslationColor()\n );\n this.yArrow = new TriangleMesh(\n createShape,\n 'y-translate',\n yAxisArrowPositions(transform, frame.scene.camera, triangleSize),\n this.outlineColor,\n this.getYTranslationColor()\n );\n\n this.yRotation = new TriangleMesh(\n createShape,\n 'y-rotate',\n yAxisRotationPositions(transform, frame.scene.camera, triangleSize),\n this.outlineColor,\n this.getYRotationColor()\n );\n this.yAxis = new AxisLine(\n createShape,\n 'y-axis',\n axisPositions(transform, frame.scene.camera, this.yArrow),\n this.outlineColor,\n this.getYTranslationColor()\n );\n this.zArrow = new TriangleMesh(\n createShape,\n 'z-translate',\n zAxisArrowPositions(transform, frame.scene.camera, triangleSize),\n this.outlineColor,\n this.getZTranslationColor()\n );\n this.zAxis = new AxisLine(\n createShape,\n 'z-axis',\n axisPositions(transform, frame.scene.camera, this.zArrow),\n this.outlineColor,\n this.getZTranslationColor()\n );\n this.zRotation = new TriangleMesh(\n createShape,\n 'z-rotate',\n zAxisRotationPositions(transform, frame.scene.camera, triangleSize),\n this.outlineColor,\n this.getZRotationColor()\n );\n\n this.createRotationLines(createShape, transform, frame);\n\n this.axisLines = [this.xAxis, this.yAxis, this.zAxis];\n this.translationMeshes = [this.xArrow, this.yArrow, this.zArrow];\n this.rotationMeshes = [this.xRotation, this.yRotation, this.zRotation];\n this.updateDisabledOnDrawables();\n\n this.availableElements = [\n ...this.axisLines,\n ...this.rotationLines,\n ...this.translationMeshes,\n ...this.rotationMeshes,\n ];\n }\n\n private getXRotationColor(): Color.Color | string | undefined {\n return this.xArrowFillColor;\n }\n\n private getYRotationColor(): Color.Color | string | undefined {\n return this.yArrowFillColor;\n }\n\n private getZRotationColor(): Color.Color | string | undefined {\n return this.zArrowFillColor;\n }\n\n private getXTranslationColor(): Color.Color | string | undefined {\n return this.xArrowFillColor;\n }\n\n private getYTranslationColor(): Color.Color | string | undefined {\n return this.yArrowFillColor;\n }\n\n private getZTranslationColor(): Color.Color | string | undefined {\n return this.zArrowFillColor;\n }\n\n private createRotationLines(\n createShape: CreateShape,\n transform: Matrix4.Matrix4,\n frame: Frame\n ): void {\n const triangleSize = this.computeTriangleSize(\n Vector3.fromMatrixPosition(transform),\n frame\n );\n\n const xyRotationLinePoints = rotationAxisPositions(\n frame.scene.camera,\n this.xRotation,\n this.yArrow?.points.worldTip,\n triangleSize\n );\n const xzRotationLinePoints = rotationAxisPositions(\n frame.scene.camera,\n this.xRotation,\n this.zArrow?.points.worldTip,\n triangleSize\n );\n const yxRotationLinePoints = rotationAxisPositions(\n frame.scene.camera,\n this.yRotation,\n this.xArrow?.points.worldTip,\n triangleSize\n );\n const yzRotationLinePoints = rotationAxisPositions(\n frame.scene.camera,\n this.yRotation,\n this.zArrow?.points.worldTip,\n triangleSize\n );\n const zxRotationLinePoints = rotationAxisPositions(\n frame.scene.camera,\n this.zRotation,\n this.xArrow?.points.worldTip,\n triangleSize\n );\n const zyRotationLinePoints = rotationAxisPositions(\n frame.scene.camera,\n this.zRotation,\n this.yArrow?.points.worldTip,\n triangleSize\n );\n\n if (xyRotationLinePoints != null) {\n this.xyRotationLine = new RotationLine(\n createShape,\n 'xy-rotation-line',\n xyRotationLinePoints,\n this.outlineColor\n );\n }\n if (xzRotationLinePoints != null) {\n this.xzRotationLine = new RotationLine(\n createShape,\n 'xz-rotation-line',\n xzRotationLinePoints,\n this.outlineColor\n );\n }\n if (yxRotationLinePoints != null) {\n this.yxRotationLine = new RotationLine(\n createShape,\n 'yx-rotation-line',\n yxRotationLinePoints,\n this.outlineColor\n );\n }\n if (yzRotationLinePoints != null) {\n this.yzRotationLine = new RotationLine(\n createShape,\n 'yz-rotation-line',\n yzRotationLinePoints,\n this.outlineColor\n );\n }\n if (zxRotationLinePoints != null) {\n this.zxRotationLine = new RotationLine(\n createShape,\n 'zx-rotation-line',\n zxRotationLinePoints,\n this.outlineColor\n );\n }\n if (zyRotationLinePoints != null) {\n this.zyRotationLine = new RotationLine(\n createShape,\n 'zy-rotation-line',\n zyRotationLinePoints,\n this.outlineColor\n );\n }\n\n this.rotationLines = [\n this.xyRotationLine,\n this.xzRotationLine,\n this.yxRotationLine,\n this.yzRotationLine,\n this.zxRotationLine,\n this.zyRotationLine,\n ].filter((l) => l != null) as RotationLine[];\n }\n\n private updateElements(transform: Matrix4.Matrix4, frame: Frame): void {\n const triangleSize = this.computeTriangleSize(\n Vector3.fromMatrixPosition(transform),\n frame\n );\n\n if (this.xArrow != null) {\n this.xArrow.updatePoints(\n xAxisArrowPositions(transform, frame.scene.camera, triangleSize)\n );\n this.xAxis?.updatePoints(\n axisPositions(transform, frame.scene.camera, this.xArrow)\n );\n }\n this.xRotation?.updatePoints(\n xAxisRotationPositions(transform, frame.scene.camera, triangleSize)\n );\n\n if (this.yArrow != null) {\n this.yArrow.updatePoints(\n yAxisArrowPositions(transform, frame.scene.camera, triangleSize)\n );\n this.yAxis?.updatePoints(\n axisPositions(transform, frame.scene.camera, this.yArrow)\n );\n }\n this.yRotation?.updatePoints(\n yAxisRotationPositions(transform, frame.scene.camera, triangleSize)\n );\n\n if (this.zArrow != null) {\n this.zArrow.updatePoints(\n zAxisArrowPositions(transform, frame.scene.camera, triangleSize)\n );\n this.zAxis?.updatePoints(\n axisPositions(transform, frame.scene.camera, this.zArrow)\n );\n }\n this.zRotation?.updatePoints(\n zAxisRotationPositions(transform, frame.scene.camera, triangleSize)\n );\n\n this.xyRotationLine?.updatePoints(\n rotationAxisPositions(\n frame.scene.camera,\n this.xRotation,\n this.yArrow?.points.worldTip,\n triangleSize\n )\n );\n this.xzRotationLine?.updatePoints(\n rotationAxisPositions(\n frame.scene.camera,\n this.xRotation,\n this.zArrow?.points.worldTip,\n triangleSize\n )\n );\n this.yxRotationLine?.updatePoints(\n rotationAxisPositions(\n frame.scene.camera,\n this.yRotation,\n this.xArrow?.points.worldTip,\n triangleSize\n )\n );\n this.yzRotationLine?.updatePoints(\n rotationAxisPositions(\n frame.scene.camera,\n this.yRotation,\n this.zArrow?.points.worldTip,\n triangleSize\n )\n );\n this.zxRotationLine?.updatePoints(\n rotationAxisPositions(\n frame.scene.camera,\n this.zRotation,\n this.xArrow?.points.worldTip,\n triangleSize\n )\n );\n this.zyRotationLine?.updatePoints(\n rotationAxisPositions(\n frame.scene.camera,\n this.zRotation,\n this.yArrow?.points.worldTip,\n triangleSize\n )\n );\n }\n}\n",":host {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n /**\n * @prop --viewer-transform-widget-x-axis-arrow-color: A CSS color for the arrow\n * at the end of the X axis on this widget. Defaults to `#ea3324`.\n */\n --viewer-transform-widget-x-axis-arrow-color: var(--x-axis-color);\n\n /**\n * @prop --viewer-transform-widget-y-axis-arrow-color: A CSS color for the arrow\n * at the end of the Y axis on this widget. Defaults to `#4faf32`.\n */\n --viewer-transform-widget-y-axis-arrow-color: var(--y-axis-color);\n\n /**\n * @prop --viewer-transform-widget-z-axis-arrow-color: A CSS color for the arrow\n * at the end of the Z axis on this widget. Defaults to `#0000ff`.\n */\n --viewer-transform-widget-z-axis-arrow-color: var(--z-axis-color);\n\n\n /**\n * @prop --viewer-transform-widget-hovered-arrow-color: A CSS color for the arrow\n * when it is hovered. Defaults to `#ffff00`.\n */\n --viewer-transform-widget-hovered-arrow-color: #ffff00;\n\n /**\n * @prop --viewer-transform-widget-input-width: A CSS length for the width of the\n * input displayed near the handles. Defaults to `7em`.\n */\n --viewer-transform-widget-input-width: 7em;\n}\n\n.widget {\n position: absolute;\n top: 0;\n left: 0;\n}\n\n.widget.hovered {\n pointer-events: auto;\n}\n\n.widget-input.wrapper {\n position: absolute;\n box-sizing: border-box;\n pointer-events: auto;\n display: flex;\n border: 1px solid #cccccc;\n width: var(--viewer-transform-widget-input-width);\n}\n\ninput.widget-input {\n text-align: center;\n border: none;\n width: 100%;\n}\n\n.widget-input.left-step,\n.widget-input.right-step {\n display: flex;\n align-items: center;\n padding: 0;\n background-color: white;\n border: none;\n}","import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport {\n Angle,\n Euler,\n Matrix4,\n Point,\n Quaternion,\n Vector3,\n} from '@vertexvis/geometry';\nimport { Color, Disposable } from '@vertexvis/utils';\nimport classNames from 'classnames';\n\nimport { readDOM, writeDOM } from '../../lib/stencil';\nimport { TransformController } from '../../lib/transforms/controller';\nimport { Drawable } from '../../lib/transforms/drawable';\nimport { AngleUnitType, DistanceUnitType } from '../../lib/types';\nimport {\n computeInputDisplayValue,\n computeInputPosition,\n computeInputTransform,\n computeUpdatedTransform,\n convertCanvasPointToWorld,\n convertPointToCanvas,\n PointAndPosition,\n} from './util';\nimport { TransformWidgetInput } from './viewer-transform-widget-components';\nimport { TransformWidget } from './widget';\n\n@Component({\n tag: 'vertex-viewer-transform-widget',\n styleUrl: 'viewer-transform-widget.css',\n shadow: true,\n})\nexport class ViewerTransformWidget {\n /**\n * An event that is emitted when the position of the widget changes.\n */\n @Event({ bubbles: true })\n public positionChanged!: EventEmitter<Vector3.Vector3 | undefined>;\n\n /**\n * An event that is emitted when the rotation of the widget changes.\n */\n @Event({ bubbles: true })\n public rotationChanged!: EventEmitter<Euler.Euler | undefined>;\n\n /**\n * An event that is emitted when the interaction has ended\n */\n @Event({ bubbles: true })\n public interactionEnded!: EventEmitter<Matrix4.Matrix4 | undefined>;\n\n /**\n * An event that is emitted an interaction with the widget has started\n */\n @Event({ bubbles: true })\n public interactionStarted!: EventEmitter<void>;\n\n /**\n * The viewer to connect to transforms. If nested within a <vertex-viewer>,\n * this property will be populated automatically.\n */\n @Prop()\n public viewer?: HTMLVertexViewerElement;\n\n /**\n * The starting position of this transform widget. This position will be updated\n * as transforms occur. Setting this value to `undefined` will remove the widget.\n */\n @Prop({ mutable: true })\n public position?: Vector3.Vector3;\n\n /**\n * The starting angle for the transform widget. This rotation will be updated\n * as the rotations occur.\n */\n @Prop({ mutable: true })\n public rotation?: Euler.Euler;\n\n /**\n * The controller that is responsible for performing transforms.\n */\n @Prop({ mutable: true })\n public controller?: TransformController;\n\n /**\n * Determines whether or not the x-rotation is disabled on the widget\n */\n @Prop({ mutable: true })\n public xRotationDisabled = false;\n\n /**\n * Determines whether or not the y-rotation is disabled on the widget\n */\n @Prop({ mutable: true })\n public yRotationDisabled = false;\n\n /**\n * Determines whether or not the z-rotation is disabled on the widget\n */\n @Prop({ mutable: true })\n public zRotationDisabled = false;\n\n /**\n * Determines whether or not the x-translation is disabled on the widget\n */\n @Prop({ mutable: true })\n public xTranslationDisabled = false;\n\n /**\n * Determines whether or not the y-translation is disabled on the widget\n */\n @Prop({ mutable: true })\n public yTranslationDisabled = false;\n\n /**\n * Determines whether or not the z-translation is disabled on the widget\n */\n @Prop({ mutable: true })\n public zTranslationDisabled = false;\n\n /**\n * The unit to show for translation inputs. Defaults to `millimeters`.\n *\n * @see DistanceUnitType\n */\n @Prop()\n public distanceUnit: DistanceUnitType = 'millimeters';\n\n /**\n * The unit to show for rotation inputs. Defaults to `degrees`.\n *\n * @see AngleUnitType\n */\n @Prop()\n public angleUnit: AngleUnitType = 'degrees';\n\n /**\n * The number of decimal places to show in the input. Defaults to `1`.\n */\n @Prop()\n public decimalPlaces = 1;\n\n /**\n * @internal\n * @ignore\n *\n * Visible for testing.\n */\n @Prop({ mutable: true })\n public hovered?: Drawable;\n\n @State()\n protected inputPosition?: PointAndPosition;\n\n @State()\n protected inputValue?: number;\n\n @Element()\n private hostEl!: HTMLElement;\n\n private startingTransform?: Matrix4.Matrix4;\n private currentTransform?: Matrix4.Matrix4;\n private dragStartTransform?: Matrix4.Matrix4;\n\n private xArrowColor: Color.Color | string = '#ea3324';\n private yArrowColor: Color.Color | string = '#4faf32';\n private zArrowColor: Color.Color | string = '#0000ff';\n private hoveredColor: Color.Color | string = '#ffff00';\n\n private widget?: TransformWidget;\n private lastDragged?: Drawable;\n private dragging?: Drawable;\n private lastAngle = 0;\n private lastWorldPosition?: Vector3.Vector3;\n private lastInputValue?: number;\n\n private canvasBounds?: DOMRect;\n private inputBounds?: DOMRect;\n private canvasResizeObserver?: ResizeObserver;\n private inputResizeObserver?: ResizeObserver;\n private hostStyleObserver?: MutationObserver;\n private canvasRef?: HTMLCanvasElement;\n private inputRef?: HTMLInputElement;\n\n private hoveredChangeDisposable?: Disposable;\n\n protected componentDidLoad(): void {\n window.addEventListener('pointermove', this.handlePointerMove);\n\n this.canvasResizeObserver = new ResizeObserver(this.handleResize);\n this.inputResizeObserver = new ResizeObserver(this.handleInputResize);\n this.hostStyleObserver = new MutationObserver(this.handleStyleChange);\n\n if (this.canvasRef != null) {\n this.canvasResizeObserver.observe(this.canvasRef);\n\n this.setupTransformWidget(this.canvasRef);\n }\n\n this.hostStyleObserver.observe(this.hostEl, {\n attributes: true,\n attributeFilter: ['style'],\n });\n\n this.handleViewerChanged(this.viewer, undefined);\n this.handleStyleChange();\n this.handleInputResize();\n }\n\n protected disconnectedCallback(): void {\n window.removeEventListener('pointermove', this.handlePointerMove);\n\n this.canvasResizeObserver?.disconnect();\n this.inputResizeObserver?.disconnect();\n this.hostStyleObserver?.disconnect();\n\n this.hoveredChangeDisposable?.dispose();\n this.widget?.dispose();\n }\n\n /**\n * @ignore\n */\n @Watch('viewer')\n protected handleViewerChanged(\n newViewer?: HTMLVertexViewerElement,\n oldViewer?: HTMLVertexViewerElement\n ): void {\n oldViewer?.removeEventListener('frameDrawn', this.handleViewerFrameDrawn);\n oldViewer?.removeEventListener(\n 'dimensionschange',\n this.handleViewerDimensionsChange\n );\n newViewer?.addEventListener('frameDrawn', this.handleViewerFrameDrawn);\n newViewer?.addEventListener(\n 'dimensionschange',\n this.handleViewerDimensionsChange\n );\n\n if (newViewer?.stream != null) {\n this.controller?.dispose();\n this.controller = new TransformController(newViewer.stream);\n }\n }\n\n /**\n * @ignore\n */\n @Watch('xTranslationDisabled')\n @Watch('yTranslationDisabled')\n @Watch('zTranslationDisabled')\n @Watch('xRotationDisabled')\n @Watch('yRotationDisabled')\n @Watch('zRotationDisabled')\n protected handleDisabledPropertyChanged(): void {\n this.widget?.updateDisabledAxis({\n xRotation: this.xRotationDisabled,\n yRotation: this.yRotationDisabled,\n zRotation: this.zRotationDisabled,\n\n xTranslation: this.xTranslationDisabled,\n yTranslation: this.yTranslationDisabled,\n zTranslation: this.zTranslationDisabled,\n });\n }\n\n /**\n * @ignore\n */\n @Watch('rotation')\n protected handleRotationChanged(\n newRotation?: Euler.Euler,\n oldRotation?: Euler.Euler\n ): void {\n const rotationToApply = newRotation ?? Euler.create();\n\n this.currentTransform = this.getTransformForNewRotation(rotationToApply);\n this.startingTransform = this.currentTransform;\n\n // If the removal of the previous rotation above results in an identity matrix,\n // clear the transformation on the widget to prevent it from appearing at the origin.\n if (\n newRotation == null &&\n this.currentTransform != null &&\n Matrix4.isIdentity(this.currentTransform)\n ) {\n this.currentTransform = undefined;\n this.startingTransform = this.currentTransform;\n }\n\n this.widget?.updateTransform(this.currentTransform);\n\n console.debug(\n `Updating widget rotation [previous=${JSON.stringify(\n oldRotation\n )}, current=${JSON.stringify(newRotation)}]`\n );\n\n this.rotationChanged.emit(newRotation);\n }\n\n /**\n * @ignore\n */\n @Watch('position')\n protected handlePositionChanged(\n newPosition?: Vector3.Vector3,\n oldPosition?: Vector3.Vector3\n ): void {\n this.currentTransform = this.getTransformForNewPosition(newPosition);\n this.startingTransform = this.currentTransform;\n\n console.debug(\n `Updating widget position [previous=${JSON.stringify(\n oldPosition\n )}, current=${JSON.stringify(newPosition)}]`\n );\n this.widget?.updateTransform(this.currentTransform);\n\n if (newPosition == null) {\n this.lastDragged = undefined;\n this.inputPosition = undefined;\n this.controller?.clearTransform();\n }\n\n this.positionChanged.emit(newPosition);\n }\n\n public render(): h.JSX.IntrinsicElements {\n return (\n <Host>\n <canvas\n ref={(el) => {\n this.canvasRef = el;\n }}\n class={classNames('widget', {\n hovered: this.hovered != null,\n })}\n width={this.viewer?.viewport.width}\n height={this.viewer?.viewport.height}\n onPointerDown={this.handleBeginDrag}\n />\n\n {this.inputPosition &&\n this.inputValue != null &&\n this.viewer?.viewport && (\n <TransformWidgetInput\n ref={(el) => {\n if (el != null) {\n this.inputResizeObserver?.observe(el);\n } else if (this.inputRef != null) {\n this.inputResizeObserver?.unobserve(this.inputRef);\n }\n this.inputRef = el;\n }}\n bounds={this.inputBounds}\n viewport={this.viewer.viewport}\n point={this.inputPosition.point}\n placement={this.inputPosition.position}\n angle={this.getDisplayedAngle()}\n distance={this.getDisplayedDistance()}\n decimalPlaces={this.decimalPlaces}\n distanceUnit={this.distanceUnit}\n angleUnit={this.angleUnit}\n onChange={this.handleInputChange}\n onIncrement={this.handleInputIncrement}\n onDecrement={this.handleInputDecrement}\n />\n )}\n </Host>\n );\n }\n\n private handleHoveredDrawableChanged = (drawable?: Drawable): void => {\n this.hovered = drawable;\n };\n\n private handleViewerFrameDrawn = (): void => {\n this.updatePropsFromViewer();\n };\n\n private handleViewerDimensionsChange = (): void => {\n writeDOM(() => {\n if (this.viewer != null && this.canvasRef != null) {\n this.canvasRef.width = this.viewer.viewport.width;\n this.canvasRef.height = this.viewer.viewport.height;\n\n this.updateCanvasBounds(this.canvasRef);\n }\n });\n };\n\n private handleResize = (): void => {\n if (this.canvasRef != null) {\n this.updateCanvasBounds(this.canvasRef);\n }\n };\n\n private handleInputResize = (): void => {\n console.log(this.inputRef);\n if (this.inputRef != null) {\n const inputElement = this.inputRef;\n\n readDOM(() => {\n this.inputBounds = inputElement.getBoundingClientRect();\n console.log(this.inputBounds);\n });\n }\n };\n\n private handleStyleChange = (): void => {\n readDOM(() => {\n const hostStyles = window.getComputedStyle(this.hostEl);\n\n this.xArrowColor = hostStyles\n .getPropertyValue('--viewer-transform-widget-x-axis-arrow-color')\n .trim();\n this.yArrowColor = hostStyles\n .getPropertyValue('--viewer-transform-widget-y-axis-arrow-color')\n .trim();\n this.zArrowColor = hostStyles\n .getPropertyValue('--viewer-transform-widget-z-axis-arrow-color')\n .trim();\n this.hoveredColor = hostStyles\n .getPropertyValue('--viewer-transform-widget-hovered-arrow-color')\n .trim();\n\n this.getTransformWidget().updateColors({\n xArrow: this.xArrowColor,\n yArrow: this.yArrowColor,\n zArrow: this.zArrowColor,\n hovered: this.hoveredColor,\n });\n });\n };\n\n private handlePointerMove = (event: PointerEvent): void => {\n if (this.dragging == null) {\n const canvasPoint = convertPointToCanvas(\n Point.create(event.clientX, event.clientY),\n this.getCanvasBounds()\n );\n const widget = this.getTransformWidget();\n\n if (canvasPoint != null && widget.boundsContainsPoint(canvasPoint)) {\n widget.updateCursor(canvasPoint);\n } else {\n widget.updateCursor(undefined);\n this.hovered = undefined;\n }\n }\n };\n\n private handleBeginDrag = async (event: PointerEvent): Promise<void> => {\n const canvasBounds = this.getCanvasBounds();\n\n if (\n this.hovered != null &&\n canvasBounds != null &&\n this.viewer != null &&\n this.position != null &&\n this.viewer.frame != null\n ) {\n this.dragging = this.hovered;\n\n if (this.dragging.identifier !== this.lastDragged?.identifier) {\n this.dragStartTransform = this.currentTransform;\n }\n this.lastDragged = undefined;\n\n const currentCanvas = convertPointToCanvas(\n Point.create(event.clientX, event.clientY),\n canvasBounds\n );\n const widgetCenter = this.viewer.viewport.transformWorldToViewport(\n this.position,\n this.viewer.frame.scene.camera.projectionViewMatrix\n );\n\n this.lastAngle =\n currentCanvas != null\n ? Angle.fromPoints(widgetCenter, currentCanvas)\n : 0;\n\n this.lastWorldPosition = convertCanvasPointToWorld(\n currentCanvas,\n this.viewer?.frame,\n this.viewer?.viewport,\n this.currentTransform\n );\n\n this.interactionStarted.emit();\n\n window.removeEventListener('pointermove', this.handlePointerMove);\n window.addEventListener('pointermove', this.handleDrag);\n window.addEventListener('pointerup', this.handleEndTransform);\n }\n };\n\n private handleDrag = async (event: PointerEvent): Promise<void> => {\n // Prevent selection of text and interaction with view cube while dragging the widget\n event.preventDefault();\n\n const canvasBounds = this.getCanvasBounds();\n\n if (\n this.dragging != null &&\n this.lastWorldPosition != null &&\n canvasBounds != null &&\n this.viewer != null &&\n this.viewer.frame != null &&\n this.position != null\n ) {\n // Begin the transform on the first `pointermove` event as opposed to the\n // `pointerdown` to prevent accidental no-op transforms (identity matrix).\n await this.controller?.beginTransform();\n\n const currentCanvas = convertPointToCanvas(\n Point.create(event.clientX, event.clientY),\n canvasBounds\n );\n const widgetCenter = this.viewer.viewport.transformWorldToViewport(\n this.position,\n this.viewer.frame.scene.camera.projectionViewMatrix\n );\n\n const currentWorld = convertCanvasPointToWorld(\n currentCanvas,\n this.viewer?.frame,\n this.viewer?.viewport,\n this.currentTransform\n );\n\n if (\n currentWorld != null &&\n currentCanvas != null &&\n widgetCenter != null\n ) {\n const angle = Angle.fromPoints(widgetCenter, currentCanvas);\n\n this.transform(\n this.lastWorldPosition,\n currentWorld,\n angle - this.lastAngle\n );\n\n this.updateInputPosition();\n this.updateInputValue();\n\n this.lastWorldPosition = currentWorld;\n this.lastAngle = angle;\n }\n }\n };\n\n private handleEndTransform = async (event: PointerEvent): Promise<void> => {\n const canvasPoint = convertPointToCanvas(\n Point.create(event.clientX, event.clientY),\n this.getCanvasBounds()\n );\n const widget = this.getTransformWidget();\n this.lastDragged = this.dragging;\n\n this.dragging = undefined;\n this.lastWorldPosition = undefined;\n this.position =\n this.currentTransform != null\n ? Vector3.fromMatrixPosition(this.currentTransform)\n : this.position;\n this.lastAngle = 0;\n\n this.updateInputPosition();\n this.updateInputValue();\n\n widget.updateCursor(canvasPoint);\n widget.updateTransform(this.currentTransform);\n\n widget.updateDisabledAxis({\n xRotation: true,\n yRotation: true,\n zRotation: true,\n xTranslation: true,\n yTranslation: true,\n zTranslation: true,\n });\n\n window.removeEventListener('pointermove', this.handleDrag);\n window.removeEventListener('pointerup', this.handleEndTransform);\n\n try {\n const delta = this.controller?.getCurrentDelta();\n\n await this.controller?.endTransform();\n\n this.interactionEnded.emit(delta);\n } catch (e) {\n console.error('Failed to end transform interaction', e);\n }\n\n window.addEventListener('pointermove', this.handlePointerMove);\n\n this.getTransformWidget().updateDisabledAxis({\n xRotation: this.xRotationDisabled,\n yRotation: this.yRotationDisabled,\n zRotation: this.zRotationDisabled,\n\n xTranslation: this.xTranslationDisabled,\n yTranslation: this.yTranslationDisabled,\n zTranslation: this.zTranslationDisabled,\n });\n };\n\n private handleInputIncrement = (): void => {\n if (this.inputValue != null && this.lastInputValue != null) {\n this.inputValue = this.lastInputValue + 1;\n console.log(this.inputValue);\n this.handleInputChange(this.inputValue);\n }\n };\n\n private handleInputDecrement = (): void => {\n if (this.inputValue != null && this.lastInputValue != null) {\n this.inputValue = this.lastInputValue - 1;\n this.handleInputChange(this.inputValue);\n }\n };\n\n private handleInputChange = async (value: number): Promise<void> => {\n if (\n this.lastDragged != null &&\n this.currentTransform != null &&\n this.startingTransform != null &&\n this.lastInputValue != null\n ) {\n this.transformCurrent(\n computeInputTransform(\n this.lastDragged.identifier,\n value,\n this.lastInputValue,\n this.distanceUnit,\n this.angleUnit\n )\n );\n\n this.lastInputValue = value;\n\n await this.controller?.beginTransform();\n this.getTransformWidget().updateTransform(this.currentTransform);\n await this.controller?.updateTransform(\n Matrix4.multiply(\n this.currentTransform,\n Matrix4.invert(this.startingTransform)\n )\n );\n this.updateInputPosition();\n await this.controller?.endTransformDebounced(() => {\n this.position =\n this.currentTransform != null\n ? Vector3.fromMatrixPosition(this.currentTransform)\n : this.position;\n });\n }\n };\n\n private updatePropsFromViewer = (): void => {\n const { frame } = this.viewer || {};\n\n if (frame != null) {\n const widget = this.getTransformWidget();\n\n widget.updateFrame(frame, this.dragging == null);\n this.updateInputPosition();\n }\n };\n\n private transform(\n previous: Vector3.Vector3,\n next: Vector3.Vector3,\n angle: number\n ): void {\n if (\n this.position != null &&\n this.startingTransform != null &&\n this.currentTransform != null &&\n this.dragging != null &&\n this.viewer != null &&\n this.viewer.frame != null\n ) {\n this.currentTransform = computeUpdatedTransform(\n this.currentTransform,\n previous,\n next,\n this.viewer?.frame.scene.camera.viewVector,\n angle,\n this.dragging.identifier\n );\n\n this.getTransformWidget().updateTransform(this.currentTransform);\n this.controller?.updateTransform(\n Matrix4.multiply(\n this.currentTransform,\n Matrix4.invert(this.startingTransform)\n )\n );\n }\n }\n\n private handleSettingDisabledAxis(): void {\n if (this.widget) {\n this.widget.updateDisabledAxis({\n xRotation: this.xRotationDisabled,\n yRotation: this.yRotationDisabled,\n zRotation: this.zRotationDisabled,\n xTranslation: this.xTranslationDisabled,\n yTranslation: this.yTranslationDisabled,\n zTranslation: this.zTranslationDisabled,\n });\n } else {\n console.warn('Cannot set disabled values - no widget defined');\n }\n }\n\n private setupTransformWidget = (\n canvasRef: HTMLCanvasElement\n ): TransformWidget => {\n console.debug(\n `Initializing transform widget. [initial-position=${JSON.stringify(\n this.position\n )}, has-initial-frame=${this.viewer?.frame != null}]`\n );\n\n this.widget = new TransformWidget(canvasRef, {\n xArrow: this.xArrowColor,\n yArrow: this.yArrowColor,\n zArrow: this.zArrowColor,\n hovered: this.hoveredColor,\n });\n\n if (this.rotation != null) {\n this.currentTransform = this.getTransformForNewRotation(this.rotation);\n this.startingTransform = this.currentTransform;\n this.widget.updateTransform(this.currentTransform);\n }\n\n if (this.position != null) {\n this.currentTransform = this.getTransformForNewPosition(this.position);\n this.startingTransform = this.currentTransform;\n this.widget.updateTransform(this.currentTransform);\n }\n if (this.viewer?.frame != null) {\n this.widget.updateFrame(this.viewer.frame, true);\n }\n\n this.handleSettingDisabledAxis();\n\n this.hoveredChangeDisposable = this.widget.onHoveredChanged(\n this.handleHoveredDrawableChanged\n );\n\n return this.widget;\n };\n\n private updateCanvasBounds = (canvasElement: HTMLCanvasElement): void => {\n readDOM(() => {\n this.canvasBounds = canvasElement.getBoundingClientRect();\n\n this.getTransformWidget().updateDimensions(canvasElement);\n });\n };\n\n private get currentRotation(): Matrix4.Matrix4 {\n if (this.currentTransform != null) {\n return Matrix4.makeRotation(\n Quaternion.fromMatrixRotation(this.currentTransform)\n );\n }\n return Matrix4.makeIdentity();\n }\n\n private updateInputValue = (): void => {\n const dragging = this.dragging ?? this.lastDragged;\n if (\n dragging != null &&\n this.currentTransform != null &&\n this.dragStartTransform != null\n ) {\n this.lastInputValue = this.inputValue;\n\n this.inputValue = computeInputDisplayValue(\n dragging.identifier,\n this.currentTransform,\n this.dragStartTransform,\n this.distanceUnit,\n this.angleUnit\n );\n }\n };\n\n private transformCurrent = (transform: Matrix4.Matrix4): void => {\n this.currentTransform =\n this.currentTransform != null\n ? Matrix4.multiply(this.currentTransform, transform)\n : transform;\n };\n\n private updateInputPosition = (): void => {\n const widget = this.getTransformWidget();\n const widgetBounds = widget.getFullBounds();\n const dragging = this.dragging ?? this.lastDragged;\n if (\n this.viewer?.frame != null &&\n this.position != null &&\n dragging != null &&\n widgetBounds != null\n ) {\n this.inputPosition = computeInputPosition(\n this.viewer.viewport,\n widgetBounds,\n dragging.points.toArray()\n );\n }\n };\n\n private getDisplayedAngle = (): number | undefined => {\n const draggingIdentifier =\n this.dragging?.identifier ?? this.lastDragged?.identifier;\n if (draggingIdentifier?.includes('rotate')) {\n return this.inputValue;\n }\n };\n\n private getDisplayedDistance = (): number | undefined => {\n const draggingIdentifier =\n this.dragging?.identifier ?? this.lastDragged?.identifier;\n if (draggingIdentifier?.includes('translate')) {\n return this.inputValue;\n }\n };\n\n private getTransformForNewPosition = (\n newPosition?: Vector3.Vector3\n ): Matrix4.Matrix4 | undefined => {\n if (newPosition != null) {\n const c =\n this.currentTransform != null\n ? this.currentTransform\n : Matrix4.makeIdentity();\n\n const currentRotation = Matrix4.makeRotation(\n Quaternion.fromMatrixRotation(c)\n );\n const position = Matrix4.makeTranslation(newPosition);\n\n return Matrix4.multiply(position, currentRotation);\n }\n };\n\n private getTransformForNewRotation = (\n newRotationEuler: Euler.Euler\n ): Matrix4.Matrix4 | undefined => {\n const c =\n this.currentTransform != null\n ? this.currentTransform\n : Matrix4.makeIdentity();\n\n const oldRotation = Matrix4.invert(\n Matrix4.makeRotation(Quaternion.fromMatrixRotation(c))\n );\n\n const newRotation = Matrix4.makeRotation(\n Quaternion.fromEuler(newRotationEuler)\n );\n const oldTranslation = Matrix4.multiply(c, oldRotation);\n\n return Matrix4.multiply(oldTranslation, newRotation);\n };\n\n private getCanvasBounds = (): DOMRect | undefined => {\n if (this.canvasBounds != null) {\n return this.canvasBounds;\n } else if (this.canvasRef != null) {\n this.updateCanvasBounds(this.canvasRef);\n return this.canvasBounds;\n }\n };\n\n private getTransformWidget = (): TransformWidget => {\n if (this.widget == null && this.canvasRef != null) {\n return this.setupTransformWidget(this.canvasRef);\n } else if (this.widget != null) {\n return this.widget;\n } else {\n throw new Error(\n 'Transform widget was not initialized. The canvas element may not have been initialized.'\n );\n }\n };\n}\n"]}