pccv_front/public/autodesk/extensions/Section/Section.min.js
2025-08-29 11:44:29 +08:00

18 lines
66 KiB
JavaScript

/*!
* LMV v7.99.1
*
* Copyright 2024 Autodesk, Inc.
* All rights reserved.
*
* This computer source code and related instructions and comments are the
* unpublished confidential and proprietary information of Autodesk, Inc.
* and are protected under Federal copyright and state trade secret law.
* They may not be disclosed to, copied or used by any third party without
* the prior written consent of Autodesk, Inc.
*
* Autodesk Viewer SDK Usage Limitations:
*
* The Autodesk Viewer SDK JavaScript must be delivered from an
* Autodesk-hosted URL.
*/(()=>{var t={3412:(t,e,n)=>{"use strict";n.d(e,{A:()=>r});var i=n(1354),o=n.n(i),a=n(6314),s=n.n(a)()(o());s.push([t.id,".sectionPanel{line-height:14px;text-align:left;z-index:10}.section-horizontal-divider{height:1px;border-top:1px solid rgba(200,200,200,.8)}.section-submenu-select{display:block;position:relative;width:calc(100% - 40px);padding:10px 20px 0px 20px;opacity:.3}.section-panel:hover .section-submenu-select{opacity:.8}.section-submenu-selectlabel{position:relative;display:inline-block;padding-right:20px;padding-bottom:4px}.section-restart{margin:10px 20px 15px 20px;padding:6px 10px 6px 10px;width:calc(100% - 55px);cursor:pointer}.docking-panel:hover .section-restart{background-color:rgba(255,255,255,.12)}.docking-panel .section-restart:hover{background-color:rgba(166,194,255,.7);-webkit-transition:all .2s ease;-moz-transition:all .2s ease;-ms-transition:all .2s ease;-o-transition:all .2s ease;transition:all .2s ease}","",{version:3,sources:["webpack://./extensions/Section/Section.css"],names:[],mappings:"AAAA,cAAc,gBAAgB,CAAC,eAAe,CAAC,UAAU,CAAC,4BAA4B,UAAU,CAAC,yCAAyC,CAAC,wBAAwB,aAAa,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,UAAU,CAAC,6CAA6C,UAAU,CAAC,6BAA6B,iBAAiB,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,iBAAiB,0BAA0B,CAAC,yBAAyB,CAAC,uBAAuB,CAAC,cAAc,CAAC,sCAAsC,sCAAsC,CAAC,sCAAsC,qCAAqC,CAAC,+BAA+B,CAAC,4BAA4B,CAAC,2BAA2B,CAAC,0BAA0B,CAAC,uBAAuB",sourcesContent:[".sectionPanel{line-height:14px;text-align:left;z-index:10}.section-horizontal-divider{height:1px;border-top:1px solid rgba(200,200,200,.8)}.section-submenu-select{display:block;position:relative;width:calc(100% - 40px);padding:10px 20px 0px 20px;opacity:.3}.section-panel:hover .section-submenu-select{opacity:.8}.section-submenu-selectlabel{position:relative;display:inline-block;padding-right:20px;padding-bottom:4px}.section-restart{margin:10px 20px 15px 20px;padding:6px 10px 6px 10px;width:calc(100% - 55px);cursor:pointer}.docking-panel:hover .section-restart{background-color:rgba(255,255,255,.12)}.docking-panel .section-restart:hover{background-color:rgba(166,194,255,.7);-webkit-transition:all .2s ease;-moz-transition:all .2s ease;-ms-transition:all .2s ease;-o-transition:all .2s ease;transition:all .2s ease}"],sourceRoot:""}]);const r=s},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,a){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var r=0;r<this.length;r++){var c=this[r][0];null!=c&&(s[c]=!0)}for(var l=0;l<t.length;l++){var h=[].concat(t[l]);i&&s[h[0]]||(void 0!==a&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=a),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),a="/*# ".concat(o," */");return[e].concat([a]).join("\n")}return[e].join("\n")}},1873:(t,e,n)=>{var i=n(9325).Symbol;t.exports=i},2552:(t,e,n)=>{var i=n(1873),o=n(659),a=n(9350),s=i?i.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?o(t):a(t)}},4128:(t,e,n)=>{var i=n(1800),o=/^\s+/;t.exports=function(t){return t?t.slice(0,i(t)+1).replace(o,""):t}},4840:(t,e,n)=>{var i="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;t.exports=i},659:(t,e,n)=>{var i=n(1873),o=Object.prototype,a=o.hasOwnProperty,s=o.toString,r=i?i.toStringTag:void 0;t.exports=function(t){var e=a.call(t,r),n=t[r];try{t[r]=void 0;var i=!0}catch(t){}var o=s.call(t);return i&&(e?t[r]=n:delete t[r]),o}},9350:t=>{var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}},9325:(t,e,n)=>{var i=n(4840),o="object"==typeof self&&self&&self.Object===Object&&self,a=i||o||Function("return this")();t.exports=a},1800:t=>{var e=/\s/;t.exports=function(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}},8221:(t,e,n)=>{var i=n(3805),o=n(124),a=n(9374),s=Math.max,r=Math.min;t.exports=function(t,e,n){var c,l,h,u,p,E,d=0,m=!1,f=!1,v=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function T(e){var n=c,i=l;return c=l=void 0,d=e,u=t.apply(i,n)}function w(t){var n=t-E;return void 0===E||n>=e||n<0||f&&t-d>=h}function y(){var t=o();if(w(t))return g(t);p=setTimeout(y,function(t){var n=e-(t-E);return f?r(n,h-(t-d)):n}(t))}function g(t){return p=void 0,v&&c?T(t):(c=l=void 0,u)}function R(){var t=o(),n=w(t);if(c=arguments,l=this,E=t,n){if(void 0===p)return function(t){return d=t,p=setTimeout(y,e),m?T(t):u}(E);if(f)return clearTimeout(p),p=setTimeout(y,e),T(E)}return void 0===p&&(p=setTimeout(y,e)),u}return e=a(e)||0,i(n)&&(m=!!n.leading,h=(f="maxWait"in n)?s(a(n.maxWait)||0,e):h,v="trailing"in n?!!n.trailing:v),R.cancel=function(){void 0!==p&&clearTimeout(p),d=0,c=E=l=p=void 0},R.flush=function(){return void 0===p?u:g(o())},R}},3805:t=>{t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},346:t=>{t.exports=function(t){return null!=t&&"object"==typeof t}},4394:(t,e,n)=>{var i=n(2552),o=n(346);t.exports=function(t){return"symbol"==typeof t||o(t)&&"[object Symbol]"==i(t)}},124:(t,e,n)=>{var i=n(9325);t.exports=function(){return i.Date.now()}},9374:(t,e,n)=>{var i=n(4128),o=n(3805),a=n(4394),s=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(a(t))return NaN;if(o(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=o(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=i(t);var n=r.test(t);return n||c.test(t)?l(t.slice(2),n?2:8):s.test(t)?NaN:+t}},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var a={},s=[],r=0;r<t.length;r++){var c=t[r],l=i.base?c[0]+i.base:c[0],h=a[l]||0,u="".concat(l," ").concat(h);a[l]=h+1;var p=n(u),E={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==p)e[p].references++,e[p].updater(E);else{var d=o(E,i);i.byIndex=r,e.splice(r,0,{identifier:u,updater:d,references:1})}s.push(u)}return s}function o(t,e){var n=e.domAPI(e);n.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var a=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<a.length;s++){var r=n(a[s]);e[r].references--}for(var c=i(t,o),l=0;l<a.length;l++){var h=n(a[l]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}a=c}}},7659:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var a=n.sourceMap;a&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var a=e[i]={id:i,exports:{}};return t[i](a,a.exports,n),a.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{SectionExtension:()=>x});const t=n(8221);var e=null,o=Autodesk.Viewing.Private,a=function(n,i){var a,s,r=n.impl,c=["section"],l=!1,h=!1,u=!1,p=!0,E=i.tintColor,d=i.tintIntensity,m=isNaN(i.gizmoOffsetRight)?200:i.gizmoOffsetRight,f=isNaN(i.gizmoOffsetLeft)?80:i.gizmoOffsetLeft,v=isNaN(i.gizmoOffsetTop)?80:i.gizmoOffsetTop,T=isNaN(i.gizmoOffsetBottom)?80:i.gizmoOffsetBottom,w=new THREE.Vector3,y=new THREE.Vector3,g=[],R=[],x=[],M="",H="gizmo",b=null,A=!1,P=!0,S=[0,1,1,3,3,2,2,0],C=2653930,V=!0;let B,k,z,I,O=new THREE.Vector3;function X(t){B=t,k=B.clone().invert(),z=(new THREE.Matrix3).getNormalMatrix(B),I=(new THREE.Matrix3).getNormalMatrix(k)}function Y(){var t,e;let n=new THREE.Matrix4;const i=null===(t=r.get3DModels()[0])||void 0===t?void 0:t.getData();if(i&&null!==(e=i.loadOptions)&&void 0!==e&&e.applyRefPoint&&i.refPointTransform){const t=i.refPointTransform,e=new THREE.Vector3,o=new THREE.Quaternion,a=new THREE.Vector3;t.decompose(e,o,a),n.makeRotationFromQuaternion(o)}return n}X(Y());const G=t(((t,e,n)=>{o.analytics.track("viewer.section",{from:t,type:e,action:n})}),2e3);function _(){r.invalidate(!1,!1,!0)}function L(){j(),a&&a.update(),s&&s.update()}function j(){if(!a||!a.object)return;let t=function(t){const e=r.worldToClient(t),n=r.getCanvasBoundingClientRect();let i=(new THREE.Vector3).copy(e);return e.x<f?i.x=f:e.x>n.width-m&&(i.x=n.width-m),e.y<v?i.y=v:e.y>n.height-T&&(i.y=n.height-T),i.x!==e.x||i.y!==e.y?i:void 0}(a.position);if(t){const e=THREE.TransformControls.intersectObjects(t.x,t.y,[a.object],r.camera,!1);e&&(a.object.getWorldPosition(w),y.copy(e.point).sub(w),a.setGizmoOffset(y))}}function N(){l&&1===R.length&&(J(!0),L(),F((new THREE.Plane).setComponents(R[0].x,R[0].y,R[0].z,R[0].w)))}function Z(t){let{objectsMoved:e}=t;e&&N()}!function(){class t extends THREE.MeshBasicMaterial{constructor(t){super(),this.depthTest=!1,this.depthWrite=!1,this.side=THREE.FrontSide,this.transparent=!0,this.setValues(t),this.oldColor=this.color.clone(),this.oldOpacity=this.opacity,this.highlight=function(t){t?(this.color.setRGB(1,230/255,3/255),this.opacity=1):(this.color.copy(this.oldColor),this.opacity=this.oldOpacity)}}}class e extends THREE.LineBasicMaterial{constructor(t){super(),this.depthTest=!1,this.depthWrite=!1,this.transparent=!0,this.linewidth=1,this.setValues(t),this.oldColor=this.color.clone(),this.oldOpacity=this.opacity,this.highlight=function(t){t?(this.color.setRGB(1,230/255,3/255),this.opacity=1):(this.color.copy(this.oldColor),this.opacity=this.oldOpacity)}}}var n=function(t,e,n){const i=[];n=n||1;for(var o=0;o<=64*n;++o)"x"==e&&i.push(new THREE.Vector3(0,Math.cos(o/32*Math.PI),Math.sin(o/32*Math.PI)).multiplyScalar(t)),"y"==e&&i.push(new THREE.Vector3(Math.cos(o/32*Math.PI),0,Math.sin(o/32*Math.PI)).multiplyScalar(t)),"z"==e&&i.push(new THREE.Vector3(Math.sin(o/32*Math.PI),Math.cos(o/32*Math.PI),0).multiplyScalar(t));return(new THREE.BufferGeometry).setFromPoints(i)},i=function(t,e,n,i,o,a){return new THREE.CylinderBufferGeometry(t,e,n,i,o,a).applyMatrix4((new THREE.Matrix4).makeTranslation(0,.5,0))},o=function(t){const e=[];return"X"===t?e.push(new THREE.Vector3(0,0,0),new THREE.Vector3(1,0,0)):"Y"===t?e.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0)):"Z"===t&&e.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,1)),(new THREE.BufferGeometry).setFromPoints(e)};class a extends THREE.Object3D{constructor(t){super();var e=this;this.init=function(){this.handles=new THREE.Object3D,this.pickers=new THREE.Object3D,this.planes=new THREE.Object3D,this.highlights=new THREE.Object3D,this.hemiPicker=new THREE.Object3D,this.subPickers=new THREE.Object3D,this.add(this.handles),this.add(this.pickers),this.add(this.planes),this.add(this.highlights),this.add(this.hemiPicker),this.add(this.subPickers);var t=new THREE.PlaneBufferGeometry(50,50,2,2),e=new THREE.MeshBasicMaterial({wireframe:!0});e.side=THREE.DoubleSide;var n={XY:new THREE.Mesh(t,e),YZ:new THREE.Mesh(t,e),XZ:new THREE.Mesh(t,e),XYZE:new THREE.Mesh(t,e)};for(var i in this.activePlane=n.XYZE,n.YZ.rotation.set(0,Math.PI/2,0),n.XZ.rotation.set(-Math.PI/2,0,0),n)n[i].name=i,this.planes.add(n[i]),this.planes[i]=n[i],n[i].visible=!1;this.setupGizmos(),this.activeMode="",this.traverse((function(t){if(t instanceof THREE.Mesh){t.updateMatrix();const e=t.geometry.clone();e.applyMatrix4(t.matrix),t.geometry=e,t.position.set(0,0,0),t.rotation.set(0,0,0),t.scale.set(1,1,1)}}))},this.hide=function(){this.traverse((function(t){t.visible=!1}))},this.show=function(){this.traverse((function(t){t.visible=!0,t.parent!=e.pickers&&t.parent!=e.hemiPicker||(t.visible=!1),t.parent==e.planes&&(t.visible=!1)})),this.activePlane.visible=!1},this.highlight=function(t){this.traverse((function(e){e.material&&e.material.highlight&&(e.name==t?e.material.highlight(!0):e.material.highlight(!1))}))},this.setupGizmos=function(){var e=function(t,e){for(var n in t)for(var i=t[n].length;i--;){var o=t[n][i][0],a=t[n][i][1],s=t[n][i][2],r=t[n][i][3];o.name=n,a&&o.position.set(a[0],a[1],a[2]),s&&o.rotation.set(s[0],s[1],s[2]),r&&(o.visble=r),e.add(o)}};if(this.setHandlePickerGizmos(),t)for(var n=Object.keys(this.handleGizmos),i=0;i<n.length;i++){var o=n[i];-1===t.indexOf(o)&&(delete this.handleGizmos[o],delete this.pickerGizmos[o],delete this.hemiPickerGizmos[o])}e(this.handleGizmos,this.handles),e(this.pickerGizmos,this.pickers),e(this.highlightGizmos,this.highlights),e(this.hemiPickerGizmos,this.hemiPicker),e(this.subPickerGizmos,this.subPickers),this.hide(),this.show()}}update(t,e){var n=new THREE.Vector3(0,0,0),i=new THREE.Vector3(0,1,0),o=new THREE.Matrix4;this.traverse((function(a){a.name&&(-1!=a.name.search("E")?a.quaternion.setFromRotationMatrix(o.lookAt(e,n,i)):-1==a.name.search("X")&&-1==a.name.search("Y")&&-1==a.name.search("Z")||a.quaternion.setFromEuler(t))}))}}THREE.TransformGizmo=a,THREE.TransformGizmoTranslate=class extends a{constructor(n){super(n),this.setHandlePickerGizmos=function(){var n=i(0,.05,.2,12,1,!1),a=o("X"),s=o("Y"),r=o("Z");this.handleGizmos={X:[[new THREE.Mesh(n,new t({color:15805484})),[.5,0,0],[0,0,-Math.PI/2]],[new THREE.Line(a,new e({color:15805484}))]],Y:[[new THREE.Mesh(n,new t({color:768011})),[0,.5,0]],[new THREE.Line(s,new e({color:768011}))]],Z:[[new THREE.Mesh(n,new t({color:2895089})),[0,0,.5],[Math.PI/2,0,0]],[new THREE.Line(r,new e({color:2895089}))]],XYZ:[[new THREE.Mesh(new THREE.OctahedronBufferGeometry(.1,0),new t({color:16777215,opacity:.25})),[0,0,0],[0,0,0]]],XY:[[new THREE.Mesh(new THREE.PlaneBufferGeometry(.29,.29),new t({color:16776960,opacity:.25})),[.15,.15,0]]],YZ:[[new THREE.Mesh(new THREE.PlaneBufferGeometry(.29,.29),new t({color:65535,opacity:.25})),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new THREE.Mesh(new THREE.PlaneBufferGeometry(.29,.29),new t({color:16711935,opacity:.25})),[.15,0,.15],[-Math.PI/2,0,0]]]},this.pickerGizmos={X:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.2,0,1,4,1,!1),new t({color:16711680,opacity:.25})),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.2,0,1,4,1,!1),new t({color:65280,opacity:.25})),[0,.6,0]]],Z:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.2,0,1,4,1,!1),new t({color:255,opacity:.25})),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new THREE.Mesh(new THREE.OctahedronBufferGeometry(.2,0),new t({color:16777215,opacity:.25}))]],XY:[[new THREE.Mesh(new THREE.PlaneBufferGeometry(.4,.4),new t({color:16776960,opacity:.25})),[.2,.2,0]]],YZ:[[new THREE.Mesh(new THREE.PlaneBufferGeometry(.4,.4),new t({color:65535,opacity:.25})),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new THREE.Mesh(new THREE.PlaneBufferGeometry(.4,.4),new t({color:16711935,opacity:.25})),[.2,0,.2],[-Math.PI/2,0,0]]]},this.hemiPickerGizmos={XYZ:[[new THREE.Mesh(new THREE.BoxBufferGeometry(1.2,1.2,1.2),new t({color:255})),[.5,.5,.5],null,!1]]}},this.setActivePlane=function(t,e,n){var i=new THREE.Matrix4;e.applyMatrix4(i.extractRotation(this.planes.XY.matrixWorld).invert()),"X"==t&&(this.activePlane=this.planes.XY,!n&&Math.abs(e.y)>Math.abs(e.z)&&(this.activePlane=this.planes.XZ)),"Y"==t&&(this.activePlane=this.planes.XY,!n&&Math.abs(e.x)>Math.abs(e.z)&&(this.activePlane=this.planes.YZ)),"Z"==t&&(this.activePlane=this.planes.XZ,!n&&Math.abs(e.x)>Math.abs(e.y)&&(this.activePlane=this.planes.YZ)),"XYZ"==t&&(this.activePlane=this.planes.XYZE),"XY"==t&&(this.activePlane=this.planes.XY),"YZ"==t&&(this.activePlane=this.planes.YZ),"XZ"==t&&(this.activePlane=this.planes.XZ),this.hide(),this.show()},this.init()}},THREE.TransformGizmoRotate=class extends a{constructor(i){super(i),this.setHandlePickerGizmos=function(){this.handleGizmos={RX:[[new THREE.Line(n(1,"x",.5),new e({color:16711680}))]],RY:[[new THREE.Line(n(1,"y",.5),new e({color:65280}))]],RZ:[[new THREE.Line(n(1,"z",.5),new e({color:255}))]],RE:[[new THREE.Line(n(1.25,"z",1),new e({color:65535}))]],RXYZE:[[new THREE.Line(n(1,"z",1),new e({color:16711935}))]]},this.pickerGizmos={RX:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.12,4,12,Math.PI),new t({color:16711680,opacity:.25})),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],RY:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.12,4,12,Math.PI),new t({color:65280,opacity:.25})),[0,0,0],[Math.PI/2,0,0]]],RZ:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.12,4,12,Math.PI),new t({color:255,opacity:.25})),[0,0,0],[0,0,-Math.PI/2]]],RE:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1.25,.12,2,24),new t({color:65535,opacity:.25}))]],RXYZE:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.12,2,24),new t({color:16711935,opacity:.25}))]]}},this.setActivePlane=function(t){"RE"==t&&(this.activePlane=this.planes.XYZE),"RX"==t&&(this.activePlane=this.planes.YZ),"RY"==t&&(this.activePlane=this.planes.XZ),"RZ"==t&&(this.activePlane=this.planes.XY),this.hide(),this.show()},this.update=function(t,e){THREE.TransformGizmo.prototype.update.apply(this,arguments);var n=new THREE.Matrix4,i=new THREE.Euler(0,0,1),o=new THREE.Quaternion,a=new THREE.Vector3(1,0,0),s=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,0,1),c=new THREE.Quaternion,l=new THREE.Quaternion,h=new THREE.Quaternion,u=e.clone();i.copy(this.planes.XY.rotation),o.setFromEuler(i),n.makeRotationFromQuaternion(o).invert(),u.applyMatrix4(n),this.traverse((function(t){o.setFromEuler(i),"RX"==t.name&&(c.setFromAxisAngle(a,Math.atan2(-u.y,u.z)),o.multiplyQuaternions(o,c),t.quaternion.copy(o)),"RY"==t.name&&(l.setFromAxisAngle(s,Math.atan2(u.x,u.z)),o.multiplyQuaternions(o,l),t.quaternion.copy(o)),"RZ"==t.name&&(h.setFromAxisAngle(r,Math.atan2(u.y,u.x)),o.multiplyQuaternions(o,h),t.quaternion.copy(o))}))},this.init()}},THREE.TransformGizmoTranslateRotate=class extends a{constructor(e){super(e);var n=this;this.setHandlePickerGizmos=function(){var e=i(0,.05,.2,12,1,!1),n=.15;this.handleGizmos={Z:[[new THREE.Mesh(e,new t({color:16777215})),[0,0,.25],[Math.PI/2,0,0]],[new THREE.Mesh(new THREE.CylinderBufferGeometry(.015,.015,.6,4,1,!1),new t({color:16777215})),[0,0,.5],[Math.PI/2,0,0]]],RX:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.015,12,60,.3*Math.PI),new t({color:16711680})),[0,0,0],[n*Math.PI,-Math.PI/2,0]],[new THREE.Mesh(new THREE.CylinderBufferGeometry(.05,.05,.015,60,1,!1),new t({color:16711680})),[0,0,1],[Math.PI/2,0,0]]],RY:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.015,12,60,.3*Math.PI),new t({color:255})),[0,0,0],[Math.PI/2,0,.35*Math.PI]],[new THREE.Mesh(new THREE.CylinderBufferGeometry(.05,.05,.01,60,1,!1),new t({color:255})),[0,0,1]]]},this.pickerGizmos={Z:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.12,.12,.65,4,1,!1),new t({color:255,opacity:.25})),[0,0,.5],[Math.PI/2,0,0]]],RX:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.12,4,12,.3*Math.PI),new t({color:16711680,opacity:.25})),[0,0,0],[n*Math.PI,-Math.PI/2,0]]],RY:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.12,4,12,.3*Math.PI),new t({color:255,opacity:.25})),[0,0,0],[Math.PI/2,0,.35*Math.PI]]]},this.subPickerGizmos={Z:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.12,.12,.65,4,1,!1),new t({color:255,opacity:.25})),[0,0,.5],[Math.PI/2,0,0]]]},this.highlightGizmos={Z:[],RX:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.02,12,60,2*Math.PI),new t({color:16711680,opacity:1})),[0,0,0],[0,-Math.PI/2,-Math.PI/2],!1]],RY:[[new THREE.Mesh(new THREE.TorusBufferGeometry(1,.02,12,60,2*Math.PI),new t({color:255,opacity:1})),[0,0,0],[Math.PI/2,0,0],!1]]},this.hemiPickerGizmos={XYZ:[[new THREE.Mesh(new THREE.SphereBufferGeometry(1.2,8,8,0,Math.PI),new t({color:255})),null,null,!1]]}},this.setActivePlane=function(t,e,n){if("translate"==this.activeMode){var i=new THREE.Matrix4;e.applyMatrix4(i.extractRotation(this.planes.XY.matrixWorld).invert()),"X"==t&&(this.activePlane=this.planes.XY,!n&&Math.abs(e.y)>Math.abs(e.z)&&(this.activePlane=this.planes.XZ)),"Y"==t&&(this.activePlane=this.planes.XY,!n&&Math.abs(e.x)>Math.abs(e.z)&&(this.activePlane=this.planes.YZ)),"Z"==t&&(this.activePlane=this.planes.XZ,!n&&Math.abs(e.x)>Math.abs(e.y)&&(this.activePlane=this.planes.YZ))}else"rotate"==this.activeMode&&("RX"==t&&(this.activePlane=this.planes.YZ),"RY"==t&&(this.activePlane=this.planes.XZ),"RZ"==t&&(this.activePlane=this.planes.XY));this.hide(),this.show()},this.update=function(t,e){if("translate"==this.activeMode)THREE.TransformGizmo.prototype.update.apply(this,arguments);else if("rotate"==this.activeMode){THREE.TransformGizmo.prototype.update.apply(this,arguments);var n=new THREE.Matrix4,i=new THREE.Euler(0,0,1),o=new THREE.Quaternion,a=new THREE.Vector3(1,0,0),s=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,0,1),c=new THREE.Quaternion,l=new THREE.Quaternion,h=new THREE.Quaternion,u=e.clone();i.copy(this.planes.XY.rotation),o.setFromEuler(i),n.makeRotationFromQuaternion(o).invert(),u.applyMatrix4(n),this.traverse((function(t){o.setFromEuler(i),"RX"==t.name&&(c.setFromAxisAngle(a,Math.atan2(-u.y,u.z)),o.multiplyQuaternions(o,c),t.quaternion.copy(o)),"RY"==t.name&&(l.setFromAxisAngle(s,Math.atan2(u.x,u.z)),o.multiplyQuaternions(o,l),t.quaternion.copy(o)),"RZ"==t.name&&(h.setFromAxisAngle(r,Math.atan2(u.y,u.x)),o.multiplyQuaternions(o,h),t.quaternion.copy(o))}))}},this.show=function(){this.traverse((function(t){(null==n.parent||n.parent.useAllPickers||t.parent!=n.handles)&&(t.visible=!0),t.material&&(t.material.opacity=t.material.oldOpacity),t.parent!=n.pickers&&t.parent!=n.hemiPicker&&t.parent!=n.subPickers||(t.visible=!1),t.parent!=n.planes&&t.parent!=n.highlights||(t.visible=!1)})),this.activePlane.visible=!1},this.highlight=function(t){this.traverse((function(e){e.material&&e.material.highlight&&(e.name==t?(e.parent!=n.highlights&&e.parent!=n.handles||(e.visible=!0),e.material.highlight(!0)):(e.material.highlight(!1),e.material.opacity=.1))}))},this.init()}},THREE.TransformGizmoScale=class extends a{constructor(n){super(n),this.setHandlePickerGizmos=function(){var n=i(.125,.125,.125),a=o("X"),s=o("Y"),r=o("Z");this.handleGizmos={X:[[new THREE.Mesh(n,new t({color:16711680})),[.5,0,0],[0,0,-Math.PI/2]],[new THREE.Line(a,new e({color:16711680}))]],Y:[[new THREE.Mesh(n,new t({color:65280})),[0,.5,0]],[new THREE.Line(s,new e({color:65280}))]],Z:[[new THREE.Mesh(n,new t({color:255})),[0,0,.5],[Math.PI/2,0,0]],[new THREE.Line(r,new e({color:255}))]],XYZ:[[new THREE.Mesh(new THREE.BoxBufferGeometry(.125,.125,.125),new t({color:16777215,opacity:.25}))]]},this.pickerGizmos={X:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.2,0,1,4,1,!1),new t({color:16711680,opacity:.25})),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.2,0,1,4,1,!1),new t({color:65280,opacity:.25})),[0,.6,0]]],Z:[[new THREE.Mesh(new THREE.CylinderBufferGeometry(.2,0,1,4,1,!1),new t({color:255,opacity:.25})),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new THREE.Mesh(new THREE.BoxBufferGeometry(.4,.4,.4),new t({color:16777215,opacity:.25}))]]}},this.setActivePlane=function(t,e,n){var i=new THREE.Matrix4;e.applyMatrix4(i.extractRotation(this.planes.XY.matrixWorld).invert()),"X"==t&&(this.activePlane=this.planes.XY,!n&&Math.abs(e.y)>Math.abs(e.z)&&(this.activePlane=this.planes.XZ)),"Y"==t&&(this.activePlane=this.planes.XY,!n&&Math.abs(e.x)>Math.abs(e.z)&&(this.activePlane=this.planes.YZ)),"Z"==t&&(this.activePlane=this.planes.XZ,!n&&Math.abs(e.x)>Math.abs(e.y)&&(this.activePlane=this.planes.YZ)),"XYZ"==t&&(this.activePlane=this.planes.XYZE),this.hide(),this.show()},this.init()}};const s=new THREE.Vector3,r=new THREE.Vector3,c=new THREE.Raycaster;class l extends THREE.Object3D{constructor(t,e,n,i){switch(super(),e=void 0!==e?e:document,this.gizmo={},n){case"translate":this.gizmo[n]=new THREE.TransformGizmoTranslate(i);break;case"rotate":this.gizmo[n]=new THREE.TransformGizmoRotate(i);break;case"transrotate":this.gizmo[n]=new THREE.TransformGizmoTranslateRotate(i);break;case"scale":this.gizmo[n]=new THREE.TransformGizmoScale(i)}if(this.add(this.gizmo[n]),this.gizmo[n].hide(),this.object=void 0,this.snap=null,this.snapDelta=0,this.space="world",this.size=1,this.axis=null,this.useAllPickers=!0,this.unitX=new THREE.Vector3(1,0,0),this.unitY=new THREE.Vector3(0,1,0),this.unitZ=new THREE.Vector3(0,0,1),this.normal=new THREE.Vector3(0,0,1),"transrotate"===n){var o,a=[new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,1)],s=(new THREE.BufferGeometry).setFromPoints(a),r=new THREE.LineBasicMaterial({color:0,linewidth:2,depthTest:!1});this.startLine=new THREE.Line(s,r),a=[new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,1)],s=(new THREE.BufferGeometry).setFromPoints(a),r=new THREE.LineBasicMaterial({color:16770563,linewidth:2,depthTest:!1}),this.endLine=new THREE.Line(s,r),a=[new THREE.Vector3(0,-1,0),new THREE.Vector3(0,1,0)],s=(new THREE.BufferGeometry).setFromPoints(a),r=new THREE.LineDashedMaterial({color:0,linewidth:1,depthTest:!1}),this.centerLine=new THREE.Line(s,r),(o=THREE.ImageUtils.loadTexture(Autodesk.Viewing.Private.getResourceUrl("res/textures/centerMarker_X.png"))).magFilter=o.minFilter=THREE.NearestFilter,s=new THREE.CircleBufferGeometry(.1,32),r=new THREE.MeshBasicMaterial({opacity:1,side:THREE.DoubleSide,transparent:!0,map:o}),this.centerMark=new THREE.Mesh(s,r),this.centerMark.rotation.set(Math.PI/2,0,0),this.ticks={},(o=THREE.ImageUtils.loadTexture(Autodesk.Viewing.Private.getResourceUrl("res/textures/cardinalPoint.png"))).magFilter=o.minFilter=THREE.NearestFilter,r=new THREE.MeshBasicMaterial({depthTest:!1,opacity:1,transparent:!0,side:THREE.DoubleSide,map:o});var c=.25;this.ticks.RX=new THREE.Object3D,s=new THREE.PlaneBufferGeometry(.12,c);var l=new THREE.Mesh(s,r);l.position.set(0,0,-1.275),l.rotation.set(Math.PI/2,Math.PI/2,0),this.ticks.RX.add(l),(l=l.clone()).position.set(0,1.275,0),l.rotation.set(0,Math.PI/2,0),this.ticks.RX.add(l),(l=l.clone()).position.set(0,0,1.275),l.rotation.set(0,Math.PI/2,Math.PI/2),this.ticks.RX.add(l),(l=l.clone()).position.set(0,-1.275,0),l.rotation.set(0,Math.PI/2,0),this.ticks.RX.add(l),this.ticks.RY=new THREE.Object3D,(l=l.clone()).position.set(0,0,-1.275),l.rotation.set(Math.PI/2,0,0),this.ticks.RY.add(l),(l=l.clone()).position.set(-1.275,0,0),l.rotation.set(Math.PI/2,0,Math.PI/2),this.ticks.RY.add(l),(l=l.clone()).position.set(0,0,1.275),l.rotation.set(Math.PI/2,0,0),this.ticks.RY.add(l),(l=l.clone()).position.set(1.275,0,0),l.rotation.set(Math.PI/2,0,Math.PI/2),this.ticks.RY.add(l)}var h=this,u=!1,p=n,E={type:"change"},d={type:"mouseDown"},m={type:"mouseUp",mode:p},f={type:"objectChange"},v=new THREE.Vector3,T=new THREE.Vector3,w=new THREE.Vector3,y=new THREE.Vector3,g=1;this.clientScale=1;var R=new THREE.Matrix4,x=new THREE.Vector3,M=new THREE.Matrix4,H=new THREE.Vector3,b=new THREE.Quaternion,A=new THREE.Vector3,P=new THREE.Vector3,S=new THREE.Vector3,C=new THREE.Quaternion,V=new THREE.Quaternion,B=new THREE.Quaternion,k=new THREE.Quaternion,z=new THREE.Quaternion,I=new THREE.Vector3,O=new THREE.Vector3,X=new THREE.Matrix4,Y=new THREE.Matrix4,G=new THREE.Vector3,_=new THREE.Vector3,L=new THREE.Euler,j=new THREE.Matrix4,N=new THREE.Vector3;function Z(e,n){return THREE.TransformControls.intersectObjects(e.canvasX,e.canvasY,n,t,!0)}new THREE.Euler,this.attach=function(t){h.object=t,this.gizmo[p].show(),h.update(),h.updateUnitVectors()},this.detach=function(t){h.object=void 0,this.axis=null,this.gizmo[p].hide()},this.setMode=function(t){"scale"==(p=t||p)&&(h.space="local"),this.gizmo[p].show(),this.update(),h.dispatchEvent(E)},this.getPicker=function(){return h.gizmo[p].hemiPicker.children},this.setPosition=function(t){this.object.position.copy(t),this.update()},this.setNormal=function(t){b.setFromUnitVectors(this.normal,t),this.unitX.applyQuaternion(b),this.unitY.applyQuaternion(b),this.unitZ.applyQuaternion(b),this.normal.copy(t),this.object&&this.object.quaternion.multiply(b),this.update()},this.setRotation=function(t){this.object&&(this.object.quaternion.setFromRotationMatrix(t),this.update(),this.updateUnitVectors())},this.setSnap=function(t,e){h.snap=t,h.snapDelta=e},this.setSize=function(t){h.size=t,this.update(),h.dispatchEvent(E)},this.setSpace=function(t){h.space=t,this.update(),h.dispatchEvent(E)},this.update=function(n){if(void 0!==h.object){var i;if(h.object.updateMatrixWorld(),_.setFromMatrixPosition(h.object.matrixWorld),L.setFromRotationMatrix(M.extractRotation(h.object.matrixWorld)),t.updateMatrixWorld(),N.setFromMatrixPosition(t.matrixWorld),this.position.copy(_),this.gizmoOffset&&this.position.add(this.gizmoOffset),this.updateMatrixWorld(),this.quaternion.setFromEuler(L),this.normal.set(0,0,1),this.normal.applyEuler(L),t.isPerspective){var o=this.position.distanceTo(N);i=2*Math.tan(t.fov*Math.PI/360)*o}else i=t.top-t.bottom;var a=e.getBoundingClientRect();g=100*this.clientScale*i/a.height,this.scale.set(g,g,g),n&&this.gizmo[p].highlight(h.axis)}},this.setGizmoOffset=function(t){this.gizmoOffset=t||new THREE.Vector3(0,0,0),this.update()},this.updateUnitVectors=function(){this.unitX.set(1,0,0),this.unitY.set(0,1,0),this.unitZ.set(0,0,1),this.unitX.applyEuler(L),this.unitY.applyEuler(L),this.unitZ.applyEuler(L)},this.showRotationGizmos=function(t){for(var e=this.gizmo[p].handles.children,n=0;n<e.length;n++){var i=e[n];i.visible=!0,-1!==i.name.search("R")&&(i.visible=t)}this.useAllPickers=t},this.highlight=function(){this.gizmo[p].highlight(this.axis||"Z")},this.onPointerHover=function(t){if(void 0===h.object||!0===u)return!1;var e=Z(t,h.useAllPickers?h.gizmo[p].pickers.children:h.gizmo[p].subPickers.children),n=null,i="";return e&&(i=-1!=(n=e.object.name).search("R")?"rotate":"translate"),h.axis!==n&&(h.axis=n,h.gizmo[p].activeMode=i,h.update(!0),h.dispatchEvent(E)),null===h.axis&&h.gizmo[p].show(),!!e},this.isDragging=function(){return u},this.onPointerDown=function(e){if(void 0===h.object||!0===u)return!1;var n=e;if("touch"===e.pointerType){var i=null,o="";(a=Z(n,h.useAllPickers?h.gizmo[p].pickers.children:h.gizmo[p].subPickers.children))&&(o=-1!=(i=a.object.name).search("R")?"rotate":"translate"),h.axis!==i&&(h.axis=i,h.gizmo[p].activeMode=o)}var a=null;if((0===n.button||-1===n.button||void 0===n.button)&&(a=Z(n,h.useAllPickers?h.gizmo[p].pickers.children:h.gizmo[p].subPickers.children))){h.dispatchEvent(d),h.axis=a.object.name,h.update(),x.copy(t.position).sub(_).normalize(),t.isPerspective||t.getWorldDirection(x),h.gizmo[p].setActivePlane(h.axis,x,"local"===h.space);var s=Z(n,[h.gizmo[p].activePlane]);if(s&&T.copy(s.point),I.copy(h.object.position),O.copy(h.object.scale),X.extractRotation(h.object.matrix),j.extractRotation(h.object.matrixWorld),h.object.parent?(Y.extractRotation(h.object.parent.matrixWorld),G.setFromMatrixScale(M.copy(h.object.parent.matrixWorld).invert())):(Y.extractRotation(h.object.matrixWorld),G.setFromMatrixScale(M.copy(h.object.matrixWorld).invert())),"transrotate"===p&&"rotate"===h.gizmo[p].activeMode){{const t=h.startLine.geometry.getAttribute("position");t.setXYZ(0,0,0,0),t.setXYZ(1,0,0,1),t.applyMatrix4(h.matrixWorld),t.needsUpdate=!0,h.parent.add(h.startLine)}var r=h.object.geometry.getAttribute("position"),c=(new THREE.Vector3).fromBufferAttribute(r,0).applyMatrix4(h.object.matrixWorld),l=(new THREE.Vector3).fromBufferAttribute(r,1).applyMatrix4(h.object.matrixWorld),E=(new THREE.Vector3).fromBufferAttribute(r,2).applyMatrix4(h.object.matrixWorld),m=(new THREE.Vector3).fromBufferAttribute(r,3).applyMatrix4(h.object.matrixWorld);const t=h.centerLine.geometry.getAttribute("position");if("RX"===h.axis){c.lerp(E,.5),l.lerp(m,.5);var f=c.distanceTo(l);h.centerLine.material.dashSize=f/15,h.centerLine.material.gapSize=f/30,t.setXYZ(0,c.x,c.y,c.z),t.setXYZ(1,l.x,l.y,l.z)}else c.lerp(l,.5),E.lerp(m,.5),f=c.distanceTo(E),h.centerLine.material.dashSize=f/15,h.centerLine.material.gapSize=f/30,t.setXYZ(0,c.x,c.y,c.z),t.setXYZ(1,E.x,E.y,E.z);h.centerLine.computeLineDistances(),t.needsUpdate=!0,h.parent.add(h.centerLine),h.ticks[h.axis].position.copy(h.position),h.ticks[h.axis].quaternion.copy(h.quaternion),h.ticks[h.axis].scale.copy(h.scale),h.parent.add(h.ticks[h.axis])}}return u=!0,!!a},this.onPointerMove=function(t){if(void 0===h.object||null===h.axis||!1===u)return!1;var e=Z(t,[h.gizmo[p].activePlane]);e&&v.copy(e.point);var n=h.gizmo[p].activeMode;if("translate"==n)v.sub(T),v.multiply(G),"local"==h.space&&(v.applyMatrix4(M.copy(j).invert()),-1==h.axis.search("X")&&(v.x=0),-1==h.axis.search("Y")&&(v.y=0),-1==h.axis.search("Z")&&(v.z=0),v.applyMatrix4(X),h.object.position.copy(I),h.object.position.add(v)),"world"!=h.space&&-1==h.axis.search("XYZ")||(A.copy(this.unitX),P.copy(this.unitY),S.copy(this.unitZ),H.set(0,0,0),-1!=h.axis.search("X")&&(A.multiplyScalar(v.dot(this.unitX)),H.add(A)),-1!=h.axis.search("Y")&&(P.multiplyScalar(v.dot(this.unitY)),H.add(P)),-1!=h.axis.search("Z")&&(S.multiplyScalar(v.dot(this.unitZ)),H.add(S)),v.copy(H),v.applyMatrix4(M.copy(Y).invert()),h.object.position.copy(I),h.object.position.add(v));else if("scale"==n)v.sub(T),v.multiply(G),"local"==h.space&&("XYZ"==h.axis?(g=1+v.y/50,h.object.scale.x=O.x*g,h.object.scale.y=O.y*g,h.object.scale.z=O.z*g):(v.applyMatrix4(M.copy(j).invert()),"X"==h.axis&&(h.object.scale.x=O.x*(1+v.x/50)),"Y"==h.axis&&(h.object.scale.y=O.y*(1+v.y/50)),"Z"==h.axis&&(h.object.scale.z=O.z*(1+v.z/50))));else if("rotate"==n){if(v.sub(_),v.multiply(G),H.copy(T).sub(_),H.multiply(G),"RE"==h.axis){M.copy(R).invert(),v.applyMatrix4(M),H.applyMatrix4(M),w.set(Math.atan2(v.z,v.y),Math.atan2(v.x,v.z),Math.atan2(v.y,v.x)),y.set(Math.atan2(H.z,H.y),Math.atan2(H.x,H.z),Math.atan2(H.y,H.x)),b.setFromRotationMatrix(M.copy(Y).invert());var i=w.z-y.z;if(null!==h.snap){var o=Math.round(i/h.snap)*h.snap;Math.abs(o-i)<h.snapDelta&&(i=o)}z.setFromAxisAngle(x,i),C.setFromRotationMatrix(j),b.multiplyQuaternions(b,z),b.multiplyQuaternions(b,C),h.object.quaternion.copy(b)}else if("RXYZE"==h.axis){var a=v.clone().cross(H).normalize();b.setFromRotationMatrix(M.copy(Y).invert());var s=-v.clone().angleTo(H);null!==h.snap&&(o=Math.round(s/h.snap)*h.snap,Math.abs(o-s)<h.snapDelta&&(s=o)),V.setFromAxisAngle(a,s),C.setFromRotationMatrix(j),b.multiplyQuaternions(b,V),b.multiplyQuaternions(b,C),h.object.quaternion.copy(b)}else if("local"==h.space){M.copy(j).invert(),v.applyMatrix4(M),H.applyMatrix4(M);var r=v.dot(this.unitX),c=v.dot(this.unitY),l=v.dot(this.unitZ),d=H.dot(this.unitX),m=H.dot(this.unitY),L=H.dot(this.unitZ);w.set(Math.atan2(l,c),Math.atan2(r,l),Math.atan2(c,r)),y.set(Math.atan2(L,m),Math.atan2(d,L),Math.atan2(m,d));var N=w.x-y.x,D=w.y-y.y;i=w.z-y.z,null!==h.snap&&(-1!=h.axis.search("X")&&(o=Math.round(N/h.snap)*h.snap,Math.abs(o-N)<h.snapDelta&&(N=o)),-1!=h.axis.search("Y")&&(o=Math.round(D/h.snap)*h.snap,Math.abs(o-D)<h.snapDelta&&(D=o)),-1!=h.axis.search("Z")&&(o=Math.round(i/h.snap)*h.snap,Math.abs(o-i)<h.snapDelta&&(i=o))),V.setFromAxisAngle(this.unitX,N),B.setFromAxisAngle(this.unitY,D),k.setFromAxisAngle(this.unitZ,i),C.setFromRotationMatrix(X),"RX"==h.axis&&C.multiplyQuaternions(C,V),"RY"==h.axis&&C.multiplyQuaternions(C,B),"RZ"==h.axis&&C.multiplyQuaternions(C,k),h.object.quaternion.copy(C)}else"world"==h.space&&(r=v.dot(this.unitX),c=v.dot(this.unitY),l=v.dot(this.unitZ),d=H.dot(this.unitX),m=H.dot(this.unitY),L=H.dot(this.unitZ),w.set(Math.atan2(l,c),Math.atan2(r,l),Math.atan2(c,r)),y.set(Math.atan2(L,m),Math.atan2(d,L),Math.atan2(m,d)),b.setFromRotationMatrix(M.copy(Y).invert()),N=w.x-y.x,D=w.y-y.y,i=w.z-y.z,null!==h.snap&&(-1!=h.axis.search("X")&&(o=Math.round(N/h.snap)*h.snap,Math.abs(o-N)<h.snapDelta&&(N=o)),-1!=h.axis.search("Y")&&(o=Math.round(D/h.snap)*h.snap,Math.abs(o-D)<h.snapDelta&&(D=o)),-1!=h.axis.search("Z")&&(o=Math.round(i/h.snap)*h.snap,Math.abs(o-i)<h.snapDelta&&(i=o))),V.setFromAxisAngle(this.unitX,N),B.setFromAxisAngle(this.unitY,D),k.setFromAxisAngle(this.unitZ,i),C.setFromRotationMatrix(j),"RX"==h.axis&&b.multiplyQuaternions(b,V),"RY"==h.axis&&b.multiplyQuaternions(b,B),"RZ"==h.axis&&b.multiplyQuaternions(b,k),b.multiplyQuaternions(b,C),h.object.quaternion.copy(b));"transrotate"===p&&(h.add(h.endLine),h.add(h.centerMark))}return h.object.matrixAutoUpdate=!0,h.update(!0),h.dispatchEvent(E),h.dispatchEvent(f),!!e},this.onPointerUp=function(t){return u&&null!==h.axis&&(m.mode=p,h.dispatchEvent(m)),u=!1,this.gizmo[p].show(),this.updateUnitVectors(),"transrotate"===p&&"rotate"===this.gizmo[p].activeMode&&(this.remove(this.endLine),this.remove(this.centerMark),this.parent.remove(this.centerLine),this.parent.remove(this.startLine),this.parent.remove(this.ticks[this.axis])),!1}}static intersectObjects(t,e,n,i,o){var a=t/i.clientWidth*2-1,l=-e/i.clientHeight*2+1;i.isPerspective?(s.set(a,l,.5),s.unproject(i),c.set(i.position,s.sub(i.position).normalize())):(s.set(a,l,-1),s.unproject(i),r.set(0,0,-1),c.set(s,r.transformDirection(i.matrixWorld)));var h=c.intersectObjects(n,o);return h[0]?h[0]:null}}THREE.TransformControls=l}(),function(){if(e)return;const t=new THREE.Vector3,n=new THREE.Matrix3;class i extends THREE.Mesh{constructor(t,e,n){super(t,e,!1),this.plane=n,this.planeVec=new THREE.Vector4(n.normal.x,n.normal.y,n.normal.z,n.constant),this.connectivity=[],this.outline=null}update(){this.updateMatrixWorld(),this.plane.normal.set(0,0,1);var e=this.plane.normal;e.applyMatrix3(n.getNormalMatrix(this.matrixWorld));var i=-1*this.getWorldPosition(t).dot(e);this.planeVec.set(e.x,e.y,e.z,i),this.plane.constant=i}}e=i}();var D=new o.FragmentIterator({delay:50});function F(t){if(!V)return;const e=Autodesk.Viewing.Extensions.CompGeom;r.sceneAfter.skipDepthTarget=!0,ut();var n=new THREE.Object3D;n.name="section3D",r.scene.add(n);var i=new THREE.Object3D;i.name="section2D",r.sceneAfter.add(i);var a=e.makePlaneBasis(t),s=a.clone().invert(),c=r.matman().create2DMaterial(null,{skipCircles:!0,skipEllipticals:!0,isScreenSpace:!0,noIdOutput:!0},!1,!1),l=r.matman().findMaterial(null,c);l.transparent=!0,l.depthTest=!0,l.polygonOffset=!0,l.polygonOffsetFactor=-1,l.polygonOffsetUnits=.1,l.cutplanes=U,l.doNotCut=!0;var h,u=new THREE.Box3,p=r.modelQueue().getModels().filter((t=>!t.getDoNotCut())),m=[];const f=new THREE.Matrix4;D.start(p,(function(c,p,v,T){var w=v.getFragmentList();if(w.isFragVisible(c)&&(w.getWorldBounds(c,u),e.xBoxPlane(t,u))){const n=w.getGeometry(c),i=w.getMaterial(c);n&&!n.is2d&&!n.isLines&&i.cutplanes&&(h=i,w.getWorldMatrix(c,f),e.xMeshPlane(t,{geometry:n,matrixWorld:f,fragId:c},m))}if(T){if(m.length){var y=new THREE.Box3;e.convertToPlaneCoords(a,m,y);var g=new o.VertexBufferBuilder(!1,8*m.length),R=function(t){return t&&t.color||new THREE.Color(16777215)}(h),x=0|.25*R.r*255.5,M=0|.25*R.g*255.5,H=4278190080|(0|.25*R.b*255.5)<<16|M<<8|x,b=new e.EdgeSet(m,y,1e-6*y.getSize(new THREE.Vector3).length());b.snapEdges(),b.sanitizeEdges(),b.stitchContours();var A=b.triangulate({skipOpenContour:!0});if(A){for(let t=0;t<A.contours.length;t++)for(var P=A.contours[t],S=1;S<P.length;S++){var C=A.pts[P[S-1]],V=A.pts[P[S]];g.addSegment(C.x,C.y,V.x,V.y,0,-2,H,p,0)}var B={mesh:g.toMesh()},k=o.BufferGeometryUtils.meshToGeometry(B);k.streamingDraw=!0,k.streamingIndex=!0;var z=new THREE.Mesh(k,l);if(z.matrix.copy(s),z.matrixAutoUpdate=!1,z.frustumCulled=!1,z.modelId=v.id,z.dbId=p,i.add(z),!A.triangulationFailed){var I=A.toPolygonMesh(h.packedNormals),O=r.matman().cloneMaterial(h,v);null!=O.prismType&&(O.defines={},O.defines[O.prismType.toUpperCase()]="","PrismWood"==O.prismType&&(O.defines.NO_UVW="")),O.packedNormals=h.packedNormals,O.mrtIdBuffer=h.mrtIdBuffer,O.mrtNormals=h.mrtNormals,O.cutplanes=U,O.side=THREE.FrontSide,O.depthTest=!0,O.map=null,O.bumpMap=null,O.normalMap=null,O.alphaMap=null,O.specularMap=null,O.transparent=!1,O.depthWrite=!0,O.hatchPattern=!0,O.needsUpdate=!0,O.doNotCut=!0;var X=(h.id+2)*Math.PI*.125,Y=Math.tan(X);O.hatchParams=new THREE.Vector2(Y,10),O.hatchTintColor=new THREE.Color(E.r,E.g,E.b),O.hatchTintIntensity=d;var G=new THREE.Mesh(I,O);G.matrix.copy(s),G.matrixAutoUpdate=!1,G.modelId=v.id,G.dbId=p,G.fragId=m.fragId,n.add(G)}}}m.length=0}}),(()=>{r.invalidate(!0,!0)}))}var W="Autodesk.Viewing.Extension.Section.SectionTool";r.setCutPlaneSetFor2DRendering(W);var U=[];function Q(t){function e(e){e&&e.traverse((function(e){e instanceof THREE.Mesh&&e.material&&(t?r.matman().adjustMaterialMRTSetting(e.material):e.material.needsUpdate=!0)}))}e(r.scene.getObjectByName("section3D")),e(r.sceneAfter.getObjectByName("section2D"))}function q(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;var o,a=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),t.normal);o=new THREE.PlaneBufferGeometry(i,i);var s=new THREE.MeshBasicMaterial({opacity:0,color:C,side:THREE.DoubleSide,depthTest:!1,depthWrite:!1,transparent:!0}),c=new e(o,s,t);const l=t.projectPoint(n,new THREE.Vector3);c.position.copy(l),c.quaternion.multiply(a);var h=r.currentLightPreset();h=Math.max(0,h);var u=Autodesk.Viewing.Private.LightPresets[h].bgColorGradient,p="rgb("+(255-u[0])+","+(255-u[1])+","+(255-u[2])+")",E=new THREE.LineBasicMaterial({color:p,linewidth:1,depthTest:!1,depthWrite:!1,transparent:!0}),d=c.geometry.getAttribute("position");const m=[];for(var f=0;f<S.length;f++)m.push((new THREE.Vector3).fromBufferAttribute(d,S[f]));const v=new THREE.Line((new THREE.BufferGeometry).setFromPoints(m),E);return c.add(v),c.outline=v,c}function J(t){K((function(n){if(n instanceof e){let e;if(n.connectivity.length>0){var i=n.matrixWorld.clone().invert();const t=new THREE.Vector3;e=n.geometry.getAttribute("position");for(let a=0;a<e.count;a++){var o=n.connectivity[a];null!==lt(n.plane,o[0],o[1],t)&&(t.applyMatrix4(i),e.setXYZ(a,t.x,t.y,t.z))}e.needsUpdate=!0,n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere()}else if(t){var a=r.getVisibleBounds(),s=2*a.getBoundingSphere(new THREE.Sphere).radius;const t=n.plane.projectPoint(a.getCenter(new THREE.Vector3),new THREE.Vector3);n.geometry=new THREE.PlaneBufferGeometry(s,s),n.position.copy(t),e=n.geometry.getAttribute("position")}if(e){for(let t=0;t<S.length;t++)n.outline.geometry.attributes.position.setXYZ(t,e.getX(S[t]),e.getY(S[t]),e.getZ(S[t]));n.outline.geometry.attributes.position.needsUpdate=!0}}}))}function K(t){for(var e=0;e<g.length;e++)g[e].traverse(t)}function $(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];K((function(t){t instanceof e&&t.update()})),1===R.length&&F((new THREE.Plane).setComponents(R[0].x,R[0].y,R[0].z,R[0].w)),r.setCutPlaneSet(W,R,t)}function tt(t){for(var e=0;e<g.length;e++)g[e].visible=t;p!==t&&_(),p=t}function et(t){t&&R.length>0&&(1===R.length&&F((new THREE.Plane).setComponents(R[0].x,R[0].y,R[0].z,R[0].w)),r.setCutPlaneSet(W,R)),tt(t)}function nt(t,e){t.attach(e),t.setPosition(e.position),t.visible=!0}function it(t){if(!a||!t)return!1;var e=function(t){var e=new THREE.Vector3,n=t.geometry;return n.computeBoundingBox(),e.x=(n.boundingBox.max.x+n.boundingBox.min.x)/2,e.y=(n.boundingBox.max.y+n.boundingBox.min.y)/2,e.z=(n.boundingBox.max.z+n.boundingBox.min.z)/2,t.localToWorld(e),e}(t).sub(t.getWorldPosition(new THREE.Vector3));return a.setGizmoOffset(e),!0}function ot(t,e){let n=function(t,e){return[new THREE.Vector3(t.min.x,t.min.y,t.min.z).applyMatrix4(e),new THREE.Vector3(t.min.x,t.min.y,t.max.z).applyMatrix4(e),new THREE.Vector3(t.min.x,t.max.y,t.min.z).applyMatrix4(e),new THREE.Vector3(t.min.x,t.max.y,t.max.z).applyMatrix4(e),new THREE.Vector3(t.max.x,t.min.y,t.min.z).applyMatrix4(e),new THREE.Vector3(t.max.x,t.min.y,t.max.z).applyMatrix4(e),new THREE.Vector3(t.max.x,t.max.y,t.min.z).applyMatrix4(e),new THREE.Vector3(t.max.x,t.max.y,t.max.z).applyMatrix4(e)]}(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:new THREE.Matrix4),i=Number.MIN_VALUE;for(let t=0;t<n.length;++t){const o=e.distanceToPoint(n[t]);o>i&&(i=o)}return i}this.setPlaneLocal=function(t){let e=t.clone().applyMatrix3(z).normalize();this.setPlane(e,void 0,!0,!0)},this.setPlane=function(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];var o=r.getVisibleBounds(),s=o.getCenter(new THREE.Vector3),c=new THREE.Group;c.applyMatrix4(B),c.updateMatrixWorld(),e||(e=this.getSectionDistance(t)),i&&function(t){return r.api.navigation.getEyeVector().dot(t)>0}(t)&&(t.negate(),e=-e),e=void 0!==e?e:-1*s.dot(t);var h=q(new THREE.Plane(t.clone().applyMatrix3(I).normalize(),e),s.clone().applyMatrix4(k),2*o.getBoundingSphere(new THREE.Sphere).radius);c.add(h),h.update(),R.push(h.planeVec),g.push(c),r.addOverlay(H,c),a&&(nt(a,h),h.material.opacity=0,it(h),a.showRotationGizmos(!0),x=a.getPicker()),$(n),l&&L()};var at,st,rt,ct,lt=(at=new THREE.Matrix3,st=new THREE.Vector3,rt=new THREE.Vector3,ct=new THREE.Vector3,function(t,e,n,i){at.set(t.normal.x,t.normal.y,t.normal.z,e.normal.x,e.normal.y,e.normal.z,n.normal.x,n.normal.y,n.normal.z);var o=at.determinant();return 0===o?null:(st.crossVectors(e.normal,n.normal).multiplyScalar(-t.constant),rt.crossVectors(n.normal,t.normal).multiplyScalar(-e.constant),ct.crossVectors(t.normal,e.normal).multiplyScalar(-n.constant),(i||new THREE.Vector3).copy(st).add(rt).add(ct).divideScalar(o))}),ht=function(t,e,n){return THREE.TransformControls.intersectObjects(t.canvasX,t.canvasY,e,r.camera,n)};function ut(){var t=r.scene.getObjectByName("section3D");t&&r.scene.remove(t);var e=r.sceneAfter.getObjectByName("section2D");e&&r.sceneAfter.remove(e)}this.isActive=function(){return l},this.getSectionDistance=function(t){var e=r.api.navigation.getEyeVector(),n=r.rayIntersect(new THREE.Ray(r.camera.position,e));return n&&n.intersectPoint&&-1*n.intersectPoint.dot(t)},this.setViewerSection=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];var e;this.clearSection(t);var n=r.getCutPlaneSet("__set_view");if(1===n.length){a.clientScale=1;var i=n[0];e=new THREE.Vector3(i.x,i.y,i.z);var o=i.w;this.setPlane(e,o,t),M="SET_VIEW_PLANE",r.setCutPlaneSet("__set_view",void 0,t)}},this.setSection=function(t){var e;this.clearSection(),a.clientScale=1;var n=r.getCutPlaneSet("__set_view");switch(1===n.length&&"BOX"!==t&&"OBJ_SET_VIEW_PLANE"!==t&&(t="SET_VIEW_PLANE"),t){case"X":e=new THREE.Vector3(1,0,0),this.setPlaneLocal(e);break;case"Y":e=new THREE.Vector3(0,1,0),this.setPlaneLocal(e);break;case"Z":e=new THREE.Vector3(0,0,1),this.setPlaneLocal(e);break;case"OBJ_SET_VIEW_PLANE":case"SET_VIEW_PLANE":var i=n[0];e=new THREE.Vector3(i.x,i.y,i.z),this.setPlane(e,i.w);break;case"OBJ_BOX":case"BOX":!function(t){var e,n,i=[new THREE.Vector3(1,0,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,0,1),new THREE.Vector3(-1,0,0),new THREE.Vector3(0,-1,0),new THREE.Vector3(0,0,-1)],o=[[[1,2],[1,5],[2,4],[4,5]],[[3,5],[0,5],[2,3],[0,2]],[[1,3],[0,1],[3,4],[0,4]],[[1,5],[1,2],[4,5],[2,4]],[[2,3],[0,2],[3,5],[0,5]],[[0,1],[3,1],[0,4],[3,4]]],c=new THREE.Group,l=r.getVisibleBounds(),h=new THREE.Box3(l.min,l.getCenter(new THREE.Vector3)),u=h.getCenter(new THREE.Vector3),p=[],E=[],d=!1;if(t&&6===t.length){for(let e=0;e<t.length;++e){let n=new THREE.Plane(new THREE.Vector3(t[e].x,t[e].y,t[e].z),t[e].w);n.applyMatrix4(k),p.push(n)}1-p[0].normal.x<=Number.EPSILON&&(u=(h=new THREE.Box3(new THREE.Vector3(p[3].constant,p[4].constant,p[5].constant),new THREE.Vector3(-p[0].constant,-p[1].constant,-p[2].constant))).getCenter(new THREE.Vector3).applyMatrix4(B),d=!0)}c.applyMatrix4(B),c.updateMatrixWorld();for(let t=0;t<i.length;t++){if(!d){let e=ot(h,n=(new THREE.Plane).setFromNormalAndCoplanarPoint(i[t],u.clone().applyMatrix4(k)),k);n.constant-=e,p.push(n)}e=q(p[t],u),c.add(e),E.push(e),e.update(),R.push(e.planeVec)}for(let t=0;t<E.length;t++){e=E[t];for(var m=o[t],f=0;f<m.length;f++){for(var v=[],T=m[f],w=0;w<T.length;w++)v.push(p[T[w]]);e.connectivity.push(v)}}g.push(c),r.addOverlay(H,c),$(),J(),n=g[0].children[0],nt(a,n),n.material.opacity=.25,it(n),nt(s,g[0]),a.showRotationGizmos(!1),x=a.getPicker().concat(s.getPicker());var y=new THREE.Vector3;null!==lt(p[0],p[1],p[2],y)&&s.setGizmoOffset(y.add((new THREE.Vector3).setFromMatrixPosition(B).negate()))}(n),a.clientScale=2,this.recomputePivot()}M=t,r.setCutPlaneSet("__set_view",void 0)},this.setSectionFromPlane=function(t){this.clearSection(),this.setPlane(new THREE.Vector3(t.x,t.y,t.z),t.w),M="",r.setCutPlaneSet("__set_view",void 0)},this.setActiveMode=function(t){M=t||""},this.setDisplaySectionHatches=function(t){V=t},this.clearCapMeshes=function(){ut()},this.updateCapMeshes=function(t,e){t&&(e||this.setPlane(t.normal,t.constant),F(t))},this.clearSection=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];for(a&&a.detach(),s&&s.detach();R.length>0;)R.pop();for(;g.length>0;){var e=g.pop();r.removeOverlay(H,e)}D.start(null),ut(),r.setCutPlaneSet(W,null,t)},this.isPlaneOn=function(){return p},this.showPlane=function(t){tt(t)},this.attachControl=function(t){a&&s&&(t?(nt(a,g[0].children[0]),a.highlight(),"BOX"===M&&nt(s,g[0])):(a.detach(),s.detach()))},this.resetSection=function(){this.setSection(M)},this.getNames=function(){return c},this.getName=function(){return c[0]},this.register=function(){},this.deregister=function(){this.clearSection(),A&&(r.removeOverlay(H,a),a.removeEventListener("change",_),a=null,r.removeOverlay(H,s),s.removeEventListener("change",_),s.removeEventListener("change",j),s=null,r.removeOverlayScene(H),n.removeEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT,L),n.removeEventListener(Autodesk.Viewing.ISOLATE_EVENT,N),n.removeEventListener(Autodesk.Viewing.HIDE_EVENT,N),n.removeEventListener(Autodesk.Viewing.SHOW_EVENT,N),n.removeEventListener(Autodesk.Viewing.MODEL_TRANSFORM_CHANGED_EVENT,N),n.removeEventListener(Autodesk.Viewing.FRAGMENTS_LOADED_EVENT,N),n.removeEventListener(Autodesk.Viewing.FRAGMENTS_UNLOADED_EVENT,N),n.removeEventListener(Autodesk.Viewing.SCENE_UPDATED_EVENT,Z),A=!1)},this.getPriority=function(){return 70},this.activate=function(){X(Y()),function(){if(A)return r.addOverlay(H,a),void r.addOverlay(H,s);(a=new THREE.TransformControls(r.camera,r.canvas,"transrotate")).addEventListener("change",_),a.setSnap(Math.PI/2,Math.PI/36),(s=new THREE.TransformControls(r.camera,r.canvas,"translate")).addEventListener("change",_),s.addEventListener("change",j),void 0===r.overlayScenes[H]&&r.createOverlayScene(H),r.addOverlay(H,a),r.addOverlay(H,s),n.addEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT,L),n.addEventListener(Autodesk.Viewing.ISOLATE_EVENT,N),n.addEventListener(Autodesk.Viewing.HIDE_EVENT,N),n.addEventListener(Autodesk.Viewing.SHOW_EVENT,N),n.addEventListener(Autodesk.Viewing.MODEL_TRANSFORM_CHANGED_EVENT,N),n.addEventListener(Autodesk.Viewing.FRAGMENTS_LOADED_EVENT,N),n.addEventListener(Autodesk.Viewing.FRAGMENTS_UNLOADED_EVENT,N),n.addEventListener(Autodesk.Viewing.SCENE_UPDATED_EVENT,Z),A=!0}(),l=!0,h=!1,P=!0,R=R||[],et(!0)},this.deactivate=function(){if(l=!1,h=!1,this.keepCutPlanesOnDeactivate){r.removeOverlay(H,a),r.removeOverlay(H,s);for(let t=0;t<g.length;t++)r.removeOverlay(H,g[t])}else D.start(null),ut(),et(!1),r.setCutPlaneSet(W);a.detach(),s.detach()},this.update=function(){return!1},this.handleSingleClick=function(t){var e,n=ht(t,null===(e=g[0])||void 0===e?void 0:e.children);if(g[0].children.forEach((function(t){t.material.opacity=0})),n){var i;const t=a.object;nt(a,n.object),a.highlight(),n.object.material.opacity=R.length>1?.25:0,(null===(i=g[0])||void 0===i?void 0:i.children.length)>1&&t!==n.object&&it(n.object),_(),j()}return!1},this.handleDoubleClick=function(){return!1},this.handleSingleTap=function(t){return this.handleSingleClick(t,0)},this.handleDoubleTap=function(){return!1},this.handleKeyDown=function(){return!1},this.handleKeyUp=function(){return!1},this.handleWheelInput=function(){return!1},this.handleButtonDown=function(t){return h=!0,!!s.onPointerDown(t)||a.onPointerDown(t)},this.handleButtonUp=function(t){return h=!1,u&&(u=!1,this.recomputePivot()),!!s.onPointerUp(t)||a.onPointerUp(t)},this.handleMouseMove=function(t){if(h){if(s.onPointerMove(t))return u=!0,$(),a.update(),G("Canvas","Box","translate"),!0;if(a.onPointerMove(t)){if(u=!0,$(),J(),M.includes("BOX"))G("Canvas","Box","transform");else{const t=-1!=a.axis.search("R")?"rotate":"translate";G("Canvas","Plane",t)}return!0}}if(s.visible=void 0!==s.object,"touch"!==t.pointerType){var e,n=t,i=ht(n,null===(e=g[0])||void 0===e?void 0:e.children);i&&(P=!1);var o=!!(P||i||ht(n,x,!0));a.visible=o,s.visible=s.visible&&o,tt(o)}return!!s.onPointerHover(t)||a.onPointerHover(t)},this.handleGesture=function(t){switch(t.type){case"dragstart":return b="drag",this.handleButtonDown(t,0);case"dragmove":return"drag"===b&&this.handleMouseMove(t);case"dragend":return"drag"===b&&(b=null,this.handleButtonUp(t,0))}return!1},this.handleBlur=function(){return!1},this.handleResize=function(){},this.handlePressHold=function(){return!1},this.recomputePivot=function(){var t=this.getSectionBoxValues(!0);if(t){var e=t.sectionBox;r.api.navigation.setPivotPoint(new THREE.Vector3(e[0]+.5*(e[3]-e[0]),e[1]+.5*(e[4]-e[1]),e[2]+.5*(e[5]-e[2])))}},this.getSectionBoxValues=function(t){var e=g[0];if(!e)return null;var n=e.children;if(n.length<6)return null;var i=n[0].position.x,o=n[1].position.y,a=n[2].position.z,s=n[3].position.x,c=n[4].position.y,l=n[5].position.z,h={x:0,y:0,z:0};return t||(h=r.model.getData().globalOffset||h),{sectionBox:[Math.min(s,i)+h.x,Math.min(o,c)+h.y,Math.min(a,l)+h.z,Math.max(s,i)+h.x,Math.max(o,c)+h.y,Math.max(a,l)+h.z],sectionBoxTransform:(new THREE.Matrix4).identity().toArray()}},this.getSectionPlaneValues=function(t){var e=g[0];if(!e)return null;var n=e.children;if(1!==n.length)return null;var i={x:0,y:0,z:0};t||(i=r.model.getData().globalOffset||i);var o=n[0].plane,a=o.constant-THREE.Vector3.prototype.dot.call(i,o.normal);return{sectionPlane:[o.normal.x,o.normal.y,o.normal.z,a]}},this.getSectionPlaneSet=function(){return r.getCutPlaneSet(W)},this.getSectionPlanes=function(){const t=r.getCutPlaneSet("__set_view");return t.length>0?t:r.getCutPlaneSet(W)},this.notifyCutplanesChanged=function(){var t=U.length;U.length=0;for(var e=r.getCutPlaneSets(),n=0;n<e.length;n++){var i=e[n];if(i!==W)for(var o=r.getCutPlaneSet(i),a=0;a<o.length;a++)U.push(o[a])}e.includes("__set_view")&&""!==M&&-1===M.indexOf("OBJ_")&&this.setViewerSection(!1),t!==U.length&&Q(!1)},this.notifyRenderOptionChanged=function(){Q(!0)},this.setSectionBox=function(t){if(!t)return!1;const e="OBJ_BOX";let n=t,i=t.transform;t.transform||(n=n.clone().applyMatrix4(k),i=B);const o=Autodesk.Viewing.Private.SceneMath.box2CutPlanes(n,i);return M=e,r.setCutPlaneSet("__set_view",o),this.setSection(e),!0},this.setSectionPlane=function(t,e){var n,i;let o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t||!e)return!1;const s="OBJ_SET_VIEW_PLANE",c=-1*e.dot(t),l=new THREE.Plane(t,c);M=s;const h=[new THREE.Vector4(l.normal.x,l.normal.y,l.normal.z,l.constant)];r.setCutPlaneSet("__set_view",h),this.setSection(s),null===(n=a)||void 0===n||n.showRotationGizmos(o);const u=e.clone().sub(g[0].children[0].getWorldPosition(O));return null===(i=a)||void 0===i||i.setGizmoOffset(u),!0}};var s=n(5072),r=n.n(s),c=n(7825),l=n.n(c),h=n(7659),u=n.n(h),p=n(5056),E=n.n(p),d=n(540),m=n.n(d),f=n(1113),v=n.n(f),T=n(3412),w={};w.styleTagTransform=v(),w.setAttributes=E(),w.insert=u().bind(null,"head"),w.domAPI=l(),w.insertStyleElement=m();r()(T.A,w);T.A&&T.A.locals&&T.A.locals;const y=Autodesk.Viewing.Private,g=Autodesk.Viewing.UI,R=y.analytics;var x=function(t,e){Autodesk.Viewing.Extension.call(this,t,e),this.viewer=t,this.name="section",this.modes=["x","y","z","box"],this.buttons={},this.onViewerSetView=this.onViewerSetView.bind(this),this._onCutPlanesChanged=this._onCutPlanesChanged.bind(this),this._onShowAll=this._onShowAll.bind(this)};x.prototype=Object.create(Autodesk.Viewing.Extension.prototype),x.prototype.constructor=x;var M=x.prototype;M.load=function(){var t=this,e=this.viewer;this.tool=new a(e,{tintColor:{r:1,g:1,b:0},tintIntensity:.2}),e.toolController.registerTool(this.tool,this.setActive.bind(this)),this.sectionStyle=null,this.supportedStyles=["X","Y","Z","BOX"],this.displaySectionHatches=this.displaySectionHatches.bind(this),this.viewer.prefs.addListeners(y.Prefs3D.DISPLAY_SECTION_HATCHES,this.displaySectionHatches),e.addEventListener(Autodesk.Viewing.SET_VIEW_EVENT,this.onViewerSetView),e.addEventListener(Autodesk.Viewing.CUTPLANES_CHANGE_EVENT,this._onCutPlanesChanged),e.addEventListener(Autodesk.Viewing.SHOW_ALL_EVENT,this._onShowAll),e.addEventListener(Autodesk.Viewing.RENDER_OPTION_CHANGED_EVENT,t.tool.notifyRenderOptionChanged),this.HOTKEYS_ID="Autodesk.Section.Hotkeys";var n=[{keycodes:[Autodesk.Viewing.KeyCode.ESCAPE],onRelease:function(){if(0===t.viewer.getAggregateSelection().length)return t.deactivate()}}];return e.getHotkeyManager().pushHotkeys(this.HOTKEYS_ID,n),this.viewer.registerContextMenuCallback("Autodesk.Section",((t,e)=>{!function(t,e,n){var i;if(!n.hasSelected)return;const o=t.viewer,a=o.getAggregateSelection();if(1===a.length&&a[0].model.is2d())return;const s=o.impl.selector.getSelectionBounds(),r={title:"Section",target:[]};r.target.push({title:"Section Box",target:()=>{t.setSectionBox(s),R.track("viewer.section",{from:"Contextual",type:"Box",action:"Enable"})}});const c=a.map((t=>t.selection)).flat(),l=new Array,h=o.model.getInstanceTree();if(!h)return;c.forEach((t=>{h.enumNodeChildren(t,(t=>{0===h.getChildCount(t)&&l.push(t)}),!0)}));const u=a.map((t=>t.model.id)),p=o.impl.hitTest(n.canvasX,n.canvasY,!1,l,u);if(null!=p&&null!==(i=p.face)&&void 0!==i&&i.normal&&p.model&&-1!==l.indexOf(p.dbId)){var E;const e=new THREE.Matrix4;null===(E=p.model.getFragmentList())||void 0===E||E.getWorldMatrix(p.fragId,e);const n=(new THREE.Matrix3).getNormalMatrix(e),i=p.face.normal.clone().applyMatrix3(n).normalize();r.target.push({title:"Section Plane",target:()=>{t.setSectionPlane(i,p.point,!1),R.track("viewer.section",{from:"Contextual",type:"Plane",action:"Enable"})}})}e.push(r)}(this,t,e)})),this.viewer.loadExtension("Autodesk.CompGeom")},M.unload=function(){var t=this.viewer;return t.unregisterContextMenuCallback("Autodesk.Section"),t.getHotkeyManager().popHotkeys(this.HOTKEYS_ID),this.destroyUI(),t.removeEventListener(Autodesk.Viewing.SET_VIEW_EVENT,this.onViewerSetView),t.removeEventListener(Autodesk.Viewing.CUTPLANES_CHANGE_EVENT,this._onCutPlanesChanged),t.removeEventListener(Autodesk.Viewing.SHOW_ALL_EVENT,this._onShowAll),t.removeEventListener(Autodesk.Viewing.RENDER_OPTION_CHANGED_EVENT,this.tool.notifyRenderOptionChanged),this.viewer.prefs.removeListeners(y.Prefs3D.DISPLAY_SECTION_HATCHES,this.displaySectionHatches),t.toolController.deregisterTool(this.tool),this.tool=null,!0},M.toggle=function(){if(this.isActive())this.enableSectionTool(!1);else{var t=this.sectionStyle||"X";this.setSectionStyle(t,!0)}return this.isActive()},M.getSectionStyle=function(){return this.sectionStyle},M.setSectionStyle=function(t,e){if(-1===this.supportedStyles.indexOf(t))return!1;var n=this.isActive(),i=this.sectionStyle!==t||!e;return this.sectionStyle=t,n&&i?this.tool.setSection(t):n||(this.enableSectionTool(!0),i?this.tool.setSection(t):this.tool.attachControl(!0)),!0},M.setSectionFromPlane=function(t){if(this.deactivate(),t)this.tool.setSectionFromPlane(t),this.tool.attachControl(!1),this.isActive()||this.tool.showPlane(!1);else{this.tool.clearSection();var e=this.viewer.toolController.setIsLocked(!1);this.enableSectionTool(!1),this.viewer.toolController.setIsLocked(e)}},M.getSectionPlanes=function(){return this.tool.getSectionPlanes()},M.enableSectionTool=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var n=this.viewer.toolController,i=this.tool.isActive();if(t&&!i)return n.activateTool("section"),this.sectionToolButton&&this.sectionToolButton.setState(Autodesk.Viewing.UI.Button.State.ACTIVE),!0;if(!t&&i){const t=this.tool.keepCutPlanesOnDeactivate;return this.tool.keepCutPlanesOnDeactivate=e,n.deactivateTool("section"),this.tool.keepCutPlanesOnDeactivate=t,this.sectionToolButton&&this.sectionToolButton.setState(Autodesk.Viewing.UI.Button.State.INACTIVE),!0}return t&&n.activateToolModality("section"),!1},M.getViewValues=function(t){var e=this.tool.getSectionBoxValues(t);if(e)return e;var n=this.tool.getSectionPlaneValues(t);return n||null},M.getState=function(t){const e=this.viewer.getFirstModel();if(e&&!e.is2d()){t.cutplanes=t.cutplanes||[];for(var n=this.tool.getSectionPlaneSet(),i=0;i<n.length;i++)t.cutplanes.push(n[i].toArray())}},M.restoreState=function(t){if(!t.cutplanes)return;const e=this.getSectionPlanes();return this.setSectionFromPlane(null),1===e.length&&this.setSectionFromPlane(e[0]),!0},M._onCutPlanesChanged=function(){this.tool.notifyCutplanesChanged()},M._onShowAll=function(){this.deactivate()},M.setSectionBox=function(t){var e;t&&(this.enableSectionTool(!0),this.tool.setSectionBox(t)?(this.activeStatus=!0,this.viewer.clearSelection(),this.mode="box",null===(e=this.buttons[this.mode])||void 0===e||e.setState(g.Button.State.ACTIVE)):this.enableSectionTool(!1))},M.setSectionPlane=function(t,e,n){var i;t&&e&&(this.enableSectionTool(!0),this.tool.setSectionPlane(t,e,n)?(this.activeStatus=!0,this.viewer.clearSelection(),this.mode=this.calculateNearestAxis(t),null===(i=this.buttons[this.mode])||void 0===i||i.setState(g.Button.State.ACTIVE)):this.enableSectionTool(!1))},M.calculateNearestAxis=function(t){const e=Math.abs(t.x),n=Math.abs(t.y),i=Math.abs(t.z);return e>=n&&e>=i?"x":n>e&&n>=i?"y":"z"},M.onViewerSetView=function(){this.deactivate()},M.onToolbarCreated=function(t){this.sectionToolButton=new g.ComboButton("toolbar-sectionTool"),this.sectionToolButton.setToolTip("Section analysis"),this.sectionToolButton.setIcon("adsk-icon-section-analysis"),this.createSubmenu(this.sectionToolButton);var e=t.getControl(Autodesk.Viewing.TOOLBAR.MODELTOOLSID);if(e){var n=e.getControl("toolbar-resetTool");n?e.addControl(this.sectionToolButton,{index:e.indexOf(n.getId())}):e.addControl(this.sectionToolButton,{index:0})}},M.createSubmenu=function(t){var e=this,n=this.viewer;function i(t,n){return e.buttons[n]=t,function(){var i=t.getState(),o=function(){t instanceof g.ComboButton==!1?e.activate(n):(e.enableSectionTool(!0),e.tool.attachControl(!0))};const a=-1!==n.toLowerCase().indexOf("box")?"Box":"Plane";i===g.Button.State.INACTIVE?(t.setState(g.Button.State.ACTIVE),Autodesk.Viewing.isMobileDevice()?setTimeout(o,1):o(),R.track("viewer.section",{from:"Toolbar",type:a,action:"Enable"})):i===g.Button.State.ACTIVE&&(t.setState(g.Button.State.INACTIVE),e.deactivate(),R.track("viewer.section",{from:"Toolbar",type:a,action:"Disable"})),e.sectionStyle=n.toUpperCase()}}function o(){var t,i=(t=new THREE.Vector3,function(e,n,i){return t.subVectors(e,n),t.lengthSq()<i}),o=new THREE.Vector3(1,0,0),a=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,0,1),r=n.autocam.getWorldRightVector(),c=n.autocam.getWorldUpVector(),l=n.autocam.getWorldFrontVector(),h=1e-4;i(c,o,h)?e.sectionYButton.setIcon("adsk-icon-plane-x"):i(c,s,h)?e.sectionYButton.setIcon("adsk-icon-plane-z"):e.sectionYButton.setIcon("adsk-icon-plane-y"),i(r,a,h)?e.sectionXButton.setIcon("adsk-icon-plane-y"):i(r,s,h)?e.sectionXButton.setIcon("adsk-icon-plane-z"):e.sectionXButton.setIcon("adsk-icon-plane-x"),i(l,o,h)?e.sectionZButton.setIcon("adsk-icon-plane-x"):i(l,a,h)?e.sectionZButton.setIcon("adsk-icon-plane-y"):e.sectionZButton.setIcon("adsk-icon-plane-z")}var a=this.sectionXButton=new g.Button("toolbar-sectionTool-x");a.setToolTip("Add X plane"),a.setIcon("adsk-icon-plane-x"),a.onClick=i(a,"x"),t.addControl(a);var s=this.sectionYButton=new g.Button("toolbar-sectionTool-y");s.setToolTip("Add Y plane"),s.setIcon("adsk-icon-plane-y"),s.onClick=i(s,"y"),t.addControl(s);var r=this.sectionZButton=new g.Button("toolbar-sectionTool-z");r.setToolTip("Add Z plane"),r.setIcon("adsk-icon-plane-z"),r.onClick=i(r,"z"),t.addControl(r);var c=this.sectionBoxButton=new g.Button("toolbar-sectionTool-box");c.setToolTip("Add box"),c.setIcon("adsk-icon-box"),c.onClick=i(c,"box"),t.addControl(c);const l=n.getFirstModel();null!=l&&l.is3d()?o():n.addEventListener(Autodesk.Viewing.MODEL_ADDED_EVENT,o,{once:!0})},M.destroyUI=function(){this.sectionToolButton&&(this.sectionToolButton.removeFromParent(),this.sectionToolButton=null,this.buttons={})},M.activate=function(t){if(!this.activeStatus||this.mode!==t){switch(this.enableSectionTool(!0),t){default:case"x":this.tool.setSection("X"),this.mode="x";break;case"y":this.tool.setSection("Y"),this.mode="y";break;case"z":this.tool.setSection("Z"),this.mode="z";break;case"box":this.tool.setSection("BOX"),this.mode="box"}return this.activeStatus=!0,!0}},M.deactivate=function(t){return!!this.activeStatus&&(this.tool.setActiveMode(""),this.enableSectionTool(!1,t),this.activeStatus=!1,!0)},M.displaySectionHatches=function(t){if(this.tool.setDisplaySectionHatches(t),this.activeStatus){const t=this.getSectionPlanes();this.tool.clearSection(),t.forEach((t=>{this.tool.updateCapMeshes((new THREE.Plane).setComponents(t.x,t.y,t.z,t.w))}))}},Autodesk.Viewing.theExtensionManager.registerExtension("Autodesk.Section",x)})(),Autodesk.Extensions.Section=i})();
//# sourceMappingURL=Section.min.js.map