@2112-lab/central-plant 0.1.4 → 0.1.5

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 (87) hide show
  1. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
  2. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
  3. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
  8. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
  12. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
  13. package/dist/cjs/src/analysis/analysis.js +560 -1
  14. package/dist/cjs/src/analysis/testing.js +958 -1
  15. package/dist/cjs/src/core/centralPlant.js +1149 -1
  16. package/dist/cjs/src/core/debugLogger.js +175 -1
  17. package/dist/cjs/src/core/mathUtils.js +574 -1
  18. package/dist/cjs/src/core/nameUtils.js +93 -1
  19. package/dist/cjs/src/data/export.js +716 -1
  20. package/dist/cjs/src/data/import.js +380 -1
  21. package/dist/cjs/src/data/numerics.js +522 -1
  22. package/dist/cjs/src/helpers/sceneHelper.js +572 -1
  23. package/dist/cjs/src/index.js +69 -1
  24. package/dist/cjs/src/managers/components/animationManager.js +123 -1
  25. package/dist/cjs/src/managers/components/componentManager.js +332 -1
  26. package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
  27. package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
  28. package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
  29. package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
  30. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
  31. package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
  32. package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
  33. package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
  34. package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
  35. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
  36. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
  37. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
  38. package/dist/cjs/src/managers/system/disposalManager.js +444 -1
  39. package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
  40. package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
  41. package/dist/cjs/src/rendering/modelPreloader.js +369 -1
  42. package/dist/cjs/src/rendering/rendering2D.js +631 -1
  43. package/dist/cjs/src/rendering/rendering3D.js +685 -1
  44. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
  45. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
  46. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
  47. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
  51. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
  54. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
  55. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
  56. package/dist/esm/src/analysis/analysis.js +536 -1
  57. package/dist/esm/src/analysis/testing.js +954 -1
  58. package/dist/esm/src/core/centralPlant.js +1144 -1
  59. package/dist/esm/src/core/debugLogger.js +167 -1
  60. package/dist/esm/src/core/mathUtils.js +570 -1
  61. package/dist/esm/src/core/nameUtils.js +87 -1
  62. package/dist/esm/src/data/export.js +712 -1
  63. package/dist/esm/src/data/import.js +356 -1
  64. package/dist/esm/src/data/numerics.js +518 -1
  65. package/dist/esm/src/helpers/sceneHelper.js +547 -1
  66. package/dist/esm/src/index.js +35 -1
  67. package/dist/esm/src/managers/components/animationManager.js +119 -1
  68. package/dist/esm/src/managers/components/componentManager.js +328 -1
  69. package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
  70. package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
  71. package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
  72. package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
  73. package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
  74. package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
  75. package/dist/esm/src/managers/environment/environmentManager.js +690 -1
  76. package/dist/esm/src/managers/environment/textureConfig.js +202 -1
  77. package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
  78. package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
  79. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
  80. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
  81. package/dist/esm/src/managers/system/disposalManager.js +440 -1
  82. package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
  83. package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
  84. package/dist/esm/src/rendering/modelPreloader.js +364 -1
  85. package/dist/esm/src/rendering/rendering2D.js +627 -1
  86. package/dist/esm/src/rendering/rendering3D.js +661 -1
  87. package/package.json +1 -1
@@ -1 +1,1807 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../../_virtual/_rollupPluginBabelHelpers.js"),i=require("three"),s=require("./TransformControls.js");function e(t){if(t&&t.t)return t;var i=Object.create(null);return t&&Object.keys(t).forEach(function(s){if("default"!==s){var e=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(i,s,e.get?e:{enumerable:!0,get:function(){return t[s]}})}}),i.default=t,Object.freeze(i)}var n=e(i),h=function(){return t.createClass(function i(s,e,n){var h=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;t.classCallCheck(this,i),this.scene=s,this.camera=e,this.renderer=n,this.orbitControls=h,this.transformControls=null,this.boundingBoxHelper=null,this.boundingBoxCache=new WeakMap,this.selectedObject=null,this.currentMode="translate",this.currentSpace="world",this.forceInvisible=!1,this.eventHandlers={keydown:null,click:null,transformStart:null,transformEnd:null,transforming:null},this.clickTiming={lastClickTime:0,lastClickedObject:null,doubleClickDelay:300},this.transformState={isTransforming:!1,initialTransform:null,currentTransform:null},this.config={size:1,enabled:!0,showX:!0,showY:!0,showZ:!0,snap:null,translationSnap:null,rotationSnap:null,scaleSnap:null,showBoundingBox:!0,boundingBoxColor:65280,useBoundingBoxSelection:!0},this.callbacks={onObjectSelect:null,onTransformStart:null,onTransform:null,onTransformEnd:null,onModeChange:null,onObjectRemoved:null},this.init()},[{key:"init",value:function(){this.createTransformControls(),this.setupEventListeners(),this.setupKeyboardControls()}},{key:"on",value:function(t){t.onObjectSelect&&(this.callbacks.onObjectSelect=t.onObjectSelect),t.onTransformStart&&(this.callbacks.onTransformStart=t.onTransformStart),t.onTransform&&(this.callbacks.onTransform=t.onTransform),t.onTransformEnd&&(this.callbacks.onTransformEnd=t.onTransformEnd),t.onModeChange&&(this.callbacks.onModeChange=t.onModeChange),t.onObjectRemoved&&(this.callbacks.onObjectRemoved=t.onObjectRemoved)}},{key:"createTransformControls",value:function(){this.transformControls=new s.TransformControls(this.camera,this.renderer.domElement),this.transformControls.setMode(this.currentMode),this.transformControls.setSpace(this.currentSpace),this.transformControls.setSize(this.config.size),this.transformControls.setDelay(this.clickTiming),this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ,this.transformControls.showXY=!1,this.transformControls.showYZ=!1,this.transformControls.showXZ=!1,this.transformControls.isTransformControls=!0,this.transformControls.userData={isTransformControls:!0},this.scene.add(this.transformControls),this.transformControls.enabled=!1,this.i()}},{key:"setupEventListeners",value:function(){var t=this;this.eventHandlers.transformStart=function(){t.transformState.isTransforming=!0,t.selectedObject&&(t.transformState.initialTransform={position:t.selectedObject.position.clone(),rotation:t.selectedObject.rotation.clone(),scale:t.selectedObject.scale.clone()}),t.orbitControls&&(t.orbitControls.enabled=!1),t.callbacks.onTransformStart&&t.callbacks.onTransformStart(t.selectedObject,t.currentMode)},this.eventHandlers.transformEnd=function(){if(t.transformState.isTransforming=!1,t.orbitControls&&(t.orbitControls.enabled=!0),t.selectedObject&&(t.transformState.currentTransform={position:t.selectedObject.position.clone(),rotation:t.selectedObject.rotation.clone(),scale:t.selectedObject.scale.clone()},t.boundingBoxCache.has(t.selectedObject)&&t.boundingBoxCache.delete(t.selectedObject)),t.callbacks.onTransformEnd&&t.callbacks.onTransformEnd(t.selectedObject,t.transformState.initialTransform,t.transformState.currentTransform,t.currentMode),"undefined"!=typeof window){var i,s=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),transformType:t.currentMode,objectName:(null===(i=t.selectedObject)||void 0===i?void 0:i.name)||"unknown"}});window.dispatchEvent(s)}},this.eventHandlers.transforming=function(){if(t.selectedObject&&t.boundingBoxCache.has(t.selectedObject)&&t.boundingBoxCache.delete(t.selectedObject),t.updateBoundingBox(),t.callbacks.onTransform&&t.callbacks.onTransform(t.selectedObject,t.currentMode),"undefined"!=typeof window){var i,s=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),transformType:t.currentMode,objectName:(null===(i=t.selectedObject)||void 0===i?void 0:i.name)||"unknown",isTransforming:!0}});window.dispatchEvent(s)}},this.transformControls&&(this.eventHandlers.transformStart&&this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.eventHandlers.transformEnd&&this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd),this.eventHandlers.transforming&&this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.addEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.addEventListener("mouseUp",this.eventHandlers.transformEnd),this.transformControls.addEventListener("objectChange",this.eventHandlers.transforming))}},{key:"setupKeyboardControls",value:function(){var t=this;this.eventHandlers.keydown=function(i){if(t.transformControls.enabled&&!t.transformState.isTransforming&&(!i.ctrlKey||"KeyZ"!==i.code))switch(i.code){case"KeyG":t.setMode("translate");break;case"KeyR":t.setMode("rotate");break;case"KeyS":t.setMode("scale");break;case"KeyW":t.setSpace("world");break;case"KeyL":t.setSpace("local");break;case"Escape":t.deselectObject();break;case"KeyX":t.setAxisConstraint("X");break;case"KeyY":t.setAxisConstraint("Y");break;case"KeyZ":i.ctrlKey||t.setAxisConstraint("Z");break;case"ShiftLeft":case"ShiftRight":t.clearAxisConstraint();break;case"Backspace":t.handleObjectRemoval()}},window.addEventListener("keydown",this.eventHandlers.keydown)}},{key:"setupObjectSelection",value:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=new n.Raycaster,e=new n.Vector2;this.eventHandlers.click=function(n){if(!t.transformState.isTransforming){var h=Date.now(),o=h-t.clickTiming.lastClickTime;t.h(n,e),s.setFromCamera(e,t.camera);var a=t.o(s,i),l=a===t.clickTiming.lastClickedObject,r=o<t.clickTiming.doubleClickDelay;l&&r&&null!==a?(t.selectObject(a),t.clickTiming.lastClickTime=0,t.clickTiming.lastClickedObject=null):(t.deselectObject(),a&&t.selectObjectForTransformOnly(a),t.clickTiming.lastClickTime=h,t.clickTiming.lastClickedObject=a)}},this.renderer.domElement.addEventListener("click",this.eventHandlers.click)}},{key:"_calculateMousePosition",value:function(t,i){var s=this.renderer.domElement.getBoundingClientRect();i.x=(t.clientX-s.left)/s.width*2-1,i.y=-(t.clientY-s.top)/s.height*2+1}},{key:"_findTargetObject",value:function(t,i){if(this.config.useBoundingBoxSelection){var s=this.l(t,i);if(s)return s}return this.u(t,i)}},{key:"_findTargetViaBoundingBox",value:function(t,i){var s=this.intersectObjectsBoundingBoxes(t,i);if(s.length>0){var e=s[0].object;if(this.v(e))return e}return null}},{key:"_findTargetViaMesh",value:function(t,i){var s=t.intersectObjects(this.scene.children,!0);if(s.length>0){var e=s[0].object;if(e=this.k(e),(i?i(e):this.isSelectableObject(e))&&this.v(e)){this.config.useBoundingBoxSelection;return e}}return null}},{key:"_resolveHierarchyTarget",value:function(t){var i,s,e;return this.isConnectorOrb(t)?t:null!==(i=t.parent)&&void 0!==i&&null!==(i=i.name)&&void 0!==i&&i.includes(" Component")?t.parent:null!==(s=t.parent)&&void 0!==s&&null!==(s=s.parent)&&void 0!==s&&null!==(s=s.name)&&void 0!==s&&s.includes(" Component")?t.parent.parent:(null!==(e=t.userData)&&void 0!==e&&e.isPipeSegment,t)}},{key:"_isValidSelectableObject",value:function(t){return!(!t||!t.parent)&&!!(t.position&&t.rotation&&t.scale&&t.updateMatrixWorld)}},{key:"isConnectorOrb",value:function(t){if(!t||!t.isObject3D)return!1;if(!t.isMesh||!t.geometry)return!1;var i="CONNECTOR-GEO"===t.geometry.uuid,s="SphereGeometry"===t.geometry.type&&t.geometry.parameters&&.2===t.geometry.parameters.radius,e=t.name&&t.name.toLowerCase().includes("connector");return(i||s)&&e}},{key:"isSelectableObject",value:function(t){var i,s,e,n,h,o,a,l;if(!t||!t.isObject3D)return!1;if(t.userData&&t.userData.isPipeSegment,t.isTransformControls||t.isTransformControlsPlane||t.isTransformControlsGizmo)return!1;var r=t.isHelper||(null===(i=t.userData)||void 0===i?void 0:i.isHelper)||(null===(s=t.userData)||void 0===s?void 0:s.isBoundingBox),u=null===(e=t.userData)||void 0===e?void 0:e.isBaseGround,c=null===(n=t.userData)||void 0===n?void 0:n.isBrickWall;if(r||u||c||!t.visible)return!1;if(t.name&&t.name.toLowerCase().includes("polyline")&&(null===(h=t.userData)||void 0===h||!h.isPipeSegment)&&(null===(o=t.userData)||void 0===o||!o.isPipeJunction))return!1;var v=!0===(null===(a=t.userData)||void 0===a?void 0:a.isPipeSegment),f=!0===(null===(l=t.userData)||void 0===l?void 0:l.isPipeJunction),d=t.name&&t.name.includes(" Component"),y=this.isConnectorOrb(t);return d||y||v||f}},{key:"selectObject",value:function(t){if(!t||!t.isObject3D)return!1;this.selectedObject=t,t.updateMatrixWorld(!0);var i=(new n.Box3).setFromObject(t);return this.boundingBoxCache.set(t,i),this.transformControls.attach(t),this.transformControls.updateInteractionTime&&this.transformControls.updateInteractionTime(),this.createBoundingBox(t),this.forceInvisible?(this.transformControls.enabled=!1,this.i()):(this.transformControls.enabled=this.config.enabled,this.m()),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(t),!0}},{key:"selectObjectForTransformOnly",value:function(t){if(!t||!t.isObject3D)return!1;this.selectedObject=t,t.updateMatrixWorld(!0);var i=(new n.Box3).setFromObject(t);return this.boundingBoxCache.set(t,i),this.transformControls.attach(t),this.transformControls.updateInteractionTime&&this.transformControls.updateInteractionTime(),this.createBoundingBox(t),this.forceInvisible?(this.transformControls.enabled=!1,this.i()):(this.transformControls.enabled=!0,this.m()),!0}},{key:"deselectObject",value:function(){this.selectedObject,this.removeBoundingBox(),this.selectedObject=null,this.transformControls&&(this.transformControls.detach(),this.transformControls.enabled=!1,this.i()),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(null)}},{key:"createBoundingBox",value:function(t){if(this.config.showBoundingBox&&(this.removeBoundingBox(),t))try{this.boundingBoxHelper=new n.BoxHelper(t,this.config.boundingBoxColor),this.boundingBoxHelper.isHelper=!0,this.boundingBoxHelper.userData={isBoundingBox:!0},this.scene.add(this.boundingBoxHelper)}catch(t){}}},{key:"removeBoundingBox",value:function(){if(this.boundingBoxHelper)try{this.boundingBoxHelper.parent&&this.boundingBoxHelper.parent.remove(this.boundingBoxHelper),this.boundingBoxHelper.geometry&&this.boundingBoxHelper.geometry.dispose(),this.boundingBoxHelper.material&&this.boundingBoxHelper.material.dispose()}catch(t){}finally{this.boundingBoxHelper=null}}},{key:"updateBoundingBox",value:function(){if(this.boundingBoxHelper&&this.selectedObject)try{if(this.selectedObject.updateMatrixWorld(!0),this.boundingBoxHelper.update(),this.boundingBoxCache.has(this.selectedObject)){var t=(new n.Box3).setFromObject(this.selectedObject);this.boundingBoxCache.set(this.selectedObject,t)}}catch(t){this.createBoundingBox(this.selectedObject)}}},{key:"setBoundingBoxVisibility",value:function(t){this.config.showBoundingBox=t,t&&this.selectedObject&&!this.boundingBoxHelper?this.createBoundingBox(this.selectedObject):!t&&this.boundingBoxHelper&&this.removeBoundingBox()}},{key:"setBoundingBoxColor",value:function(t){this.config.boundingBoxColor=t,this.boundingBoxHelper&&this.boundingBoxHelper.material&&this.boundingBoxHelper.material.color.setHex(t)}},{key:"setMode",value:function(t){if(["translate","rotate","scale"].includes(t)){var i=this.currentMode;this.currentMode=t,this.transformControls.setMode(t),this.callbacks.onModeChange&&this.callbacks.onModeChange(t,i)}}},{key:"setSpace",value:function(t){if(["world","local"].includes(t)){this.currentSpace;this.currentSpace=t,this.transformControls.setSpace(t)}}},{key:"setAxisConstraint",value:function(t){["X","Y","Z"].includes(t)&&(this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!1,this.transformControls["show".concat(t)]=!0)}},{key:"clearAxisConstraint",value:function(){this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ}},{key:"setSnap",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==t.translation&&(this.config.translationSnap=t.translation,this.transformControls.setTranslationSnap(t.translation)),void 0!==t.rotation&&(this.config.rotationSnap=t.rotation,this.transformControls.setRotationSnap(t.rotation)),void 0!==t.scale&&(this.config.scaleSnap=t.scale,this.transformControls.setScaleSnap(t.scale))}},{key:"snapValues",get:function(){return{translation:this.config.translationSnap||.5,rotation:this.config.rotationSnap||Math.PI/2,scale:this.config.scaleSnap||.1}}},{key:"setSize",value:function(t){this.config.size=t,this.transformControls.setSize(t)}},{key:"setEnabled",value:function(t){this.config.enabled=t,this.selectedObject&&(this.transformControls.enabled=t)}},{key:"setShowPlanes",value:function(t){return!!this.transformControls&&(this.transformControls.showXY=t,this.transformControls.showYZ=t,this.transformControls.showXZ=t,!0)}},{key:"ensureSceneAttachment",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return!this.transformControls&&this.scene&&this.camera&&this.renderer?(this.createTransformControls(),this.setupEventListeners(),t||(this.transformControls.visible=!1),!0):!(!this.transformControls||!this.scene)&&(this.scene.children.includes(this.transformControls)?!this.transformControls.visible&&t?(this.transformControls.visible=!0,!0):this.transformControls.visible&&!t?(this.transformControls.visible=!1,!0):!(!this.transformControls.parent||this.transformControls.parent===this.scene)&&(this.transformControls.parent.remove(this.transformControls),this.scene.add(this.transformControls),!0):(this.scene.add(this.transformControls),this.transformControls.enabled=!1,this.selectedObject&&(this.transformControls.attach(this.selectedObject),this.transformControls.enabled=this.config.enabled),t||(this.transformControls.visible=!1),!0))}},{key:"getTransformData",value:function(){if(!this.selectedObject)return null;var t={position:this.selectedObject.position.clone(),rotation:this.selectedObject.rotation.clone(),scale:this.selectedObject.scale.clone()},i=this.getWorldTransformData();return{object:this.selectedObject,position:t.position,rotation:t.rotation,scale:t.scale,worldPosition:i.position,worldRotation:i.rotation,worldScale:i.scale,mode:this.currentMode,space:this.currentSpace,isTransforming:this.transformState.isTransforming}}},{key:"getWorldTransformData",value:function(){if(!this.selectedObject)return null;this.selectedObject.updateMatrixWorld(!0);var t=new n.Vector3;this.selectedObject.getWorldPosition(t);var i=new n.Quaternion;this.selectedObject.getWorldQuaternion(i);var s=new n.Euler;s.setFromQuaternion(i);var e=new n.Vector3;return this.selectedObject.getWorldScale(e),{position:t,rotation:s,scale:e}}},{key:"updateObjectTransform",value:function(t,i,s){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.selectedObject){var n=this.selectedObject,h=parseFloat(s);if(!isNaN(h)){if(e)this.updateWorldTransform(n,t,i,h);else switch(t){case"position":n.position[i]=h;break;case"rotation":n.rotation[i]=h*(Math.PI/180);break;case"scale":n.scale[i]=h;break;default:return}this.transformControls&&this.transformControls.updateMatrixWorld(),this.updateBoundingBox()}}}},{key:"updateWorldTransform",value:function(t,i,s,e){switch(t.updateMatrixWorld(!0),i){case"position":this.setWorldPosition(t,s,e);break;case"rotation":this.setWorldRotation(t,s,e);break;case"scale":this.setWorldScale(t,s,e)}}},{key:"setWorldPosition",value:function(t,i,s){var e=new n.Vector3;if(t.getWorldPosition(e),e[i]=s,t.parent){var h=new n.Matrix4;h.copy(t.parent.matrixWorld).invert(),e.applyMatrix4(h)}t.position.copy(e)}},{key:"setWorldRotation",value:function(t,i,s){var e=new n.Quaternion;t.getWorldQuaternion(e);var h=new n.Euler;h.setFromQuaternion(e),h[i]=s*(Math.PI/180);var o=new n.Quaternion;if(o.setFromEuler(h),t.parent){var a=new n.Quaternion;t.parent.getWorldQuaternion(a),a.invert(),o.premultiply(a)}t.quaternion.copy(o)}},{key:"setWorldScale",value:function(t,i,s){var e=new n.Vector3;t.getWorldScale(e);var h=s/e[i];t.scale[i]*=h}},{key:"getSelectableObjectsWithBounds",value:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=[];return this.scene.traverse(function(e){var h,o;if(e&&e.isObject3D&&!(e.isTransformControls||e.isTransformControlsPlane||e.isTransformControlsGizmo||e.isHelper||null!==(h=e.userData)&&void 0!==h&&h.isHelper||null!==(o=e.userData)&&void 0!==o&&o.isBoundingBox))try{if(i?i(e):t.isSelectableObject(e)){e.updateMatrixWorld(!0);var a=t.boundingBoxCache.get(e);a&&e!==t.selectedObject||(a=(new n.Box3).setFromObject(e),t.boundingBoxCache.set(e,a)),s.push({object:e,boundingBox:a})}}catch(t){}}),s}},{key:"intersectObjectsBoundingBoxes",value:function(i){var s,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,h=this.getSelectableObjectsWithBounds(e),o=[],a=t.createForOfIteratorHelper(h);try{for(a.s();!(s=a.n()).done;){var l=s.value,r=l.object,u=l.boundingBox,c=i.ray.intersectBox(u,new n.Vector3);if(c){var v=i.ray.origin.distanceTo(c);o.push({object:r,point:c,distance:v,boundingBox:u})}}}catch(t){a.e(t)}finally{a.f()}return o.sort(function(t,i){return t.distance-i.distance}),o}},{key:"setBoundingBoxSelection",value:function(t){this.config.useBoundingBoxSelection=t}},{key:"handleObjectRemoval",value:function(){var t;this.selectedObject&&"gateway"===(null===(t=this.selectedObject.userData)||void 0===t?void 0:t.componentType)&&this.handleGatewayRemoval()}},{key:"handleGatewayRemoval",value:function(){var i,s=this.selectedObject,e={uuid:s.uuid,userData:t.objectSpread2({},s.userData),position:s.position.clone(),connections:(null===(i=s.userData)||void 0===i?void 0:i.connections)||null};s.userData.origin="computed",this.deselectObject(),this.callbacks.onObjectRemoved&&this.callbacks.onObjectRemoved(e)}},{key:"dispose",value:function(){this.eventHandlers.keydown&&window.removeEventListener("keydown",this.eventHandlers.keydown),this.eventHandlers.click&&this.renderer.domElement.removeEventListener("click",this.eventHandlers.click),this.removeBoundingBox(),this.selectedObject&&this.deselectObject(),this.transformControls&&(this.eventHandlers.transformStart&&this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.eventHandlers.transformEnd&&this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd),this.eventHandlers.transforming&&this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.detach(),this.scene&&this.transformControls.parent===this.scene&&this.scene.remove(this.transformControls),this.transformControls.dispose(),this.transformControls=null),this.selectedObject=null,this.orbitControls=null}},{key:"forceHide",value:function(){this.transformControls&&(this.i(),this.transformControls.enabled=!1)}},{key:"_hideTransformControls",value:function(){this.transformControls&&(this.transformControls.visible=!1,this.transformControls.p&&(this.transformControls.p.visible=!1),this.transformControls.j&&(this.transformControls.j.visible=!1))}},{key:"_showTransformControls",value:function(){this.transformControls&&(this.transformControls.visible=!0,this.transformControls.p&&(this.transformControls.p.visible=!0),this.transformControls.j&&(this.transformControls.j.visible=!0))}},{key:"getVisibilityState",value:function(){var t;return this.transformControls?{exists:!0,visible:this.transformControls.visible,enabled:this.transformControls.enabled,gizmoVisible:this.transformControls.p?this.transformControls.p.visible:"N/A",planeVisible:this.transformControls.j?this.transformControls.j.visible:"N/A",hasSelectedObject:!!this.selectedObject,selectedObjectName:(null===(t=this.selectedObject)||void 0===t?void 0:t.name)||"none"}:{exists:!1}}},{key:"_forceHideAllGizmoComponents",value:function(){if(this.transformControls&&this.transformControls.p){var t=this.transformControls.p;t.visible=!1,t.gizmo&&Object.keys(t.gizmo).forEach(function(i){t.gizmo[i]&&(t.gizmo[i].visible=!1)}),t.helper&&Object.keys(t.helper).forEach(function(i){t.helper[i]&&(t.helper[i].visible=!1)}),this.transformControls.j&&(this.transformControls.j.visible=!1)}}},{key:"_hidePlaneHelpers",value:function(){if(this.transformControls&&this.transformControls.p){var t=this.transformControls.p;if(t.gizmo&&t.gizmo.translate)t.gizmo.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!1)});if(t.picker&&t.picker.translate)t.picker.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!1)})}}},{key:"_showPlaneHelpers",value:function(){if(this.transformControls&&this.transformControls.p){var t=this.transformControls.p;if(t.gizmo&&t.gizmo.translate)t.gizmo.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!0)});if(t.picker&&t.picker.translate)t.picker.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!0)})}}}])}();exports.TransformControlsManager=h,exports.createTransformControls=function(t,i,s){return new h(t,i,s,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null)};
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var THREE = require('three');
7
+ var TransformControls = require('./TransformControls.js');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
28
+
29
+ var TransformControlsManager = /*#__PURE__*/function () {
30
+ function TransformControlsManager(scene, camera, renderer) {
31
+ var orbitControls = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
32
+ _rollupPluginBabelHelpers.classCallCheck(this, TransformControlsManager);
33
+ this.scene = scene;
34
+ this.camera = camera;
35
+ this.renderer = renderer;
36
+ this.orbitControls = orbitControls;
37
+ // Transform control instance
38
+ this.transformControls = null;
39
+ // Bounding box helper for visual feedback
40
+ this.boundingBoxHelper = null;
41
+
42
+ // Cache for object bounding boxes to improve performance
43
+ this.boundingBoxCache = new WeakMap();
44
+
45
+ // Currently selected object
46
+ this.selectedObject = null;
47
+
48
+ // Transform mode: 'translate', 'rotate', 'scale'
49
+ this.currentMode = 'translate';
50
+
51
+ // Transform space: 'world' or 'local'
52
+ this.currentSpace = 'world';
53
+
54
+ // Flag to force controls to stay invisible (used during scene loading)
55
+ this.forceInvisible = false;
56
+
57
+ // Event handlers storage
58
+ this.eventHandlers = {
59
+ keydown: null,
60
+ click: null,
61
+ transformStart: null,
62
+ transformEnd: null,
63
+ transforming: null
64
+ };
65
+
66
+ // Click timing for double-click detection
67
+ this.clickTiming = {
68
+ lastClickTime: 0,
69
+ lastClickedObject: null,
70
+ doubleClickDelay: 300 // milliseconds
71
+ };
72
+
73
+ // Transform state tracking
74
+ this.transformState = {
75
+ isTransforming: false,
76
+ initialTransform: null,
77
+ currentTransform: null
78
+ };
79
+
80
+ // Configuration options
81
+ this.config = {
82
+ size: 1,
83
+ enabled: true,
84
+ showX: true,
85
+ showY: true,
86
+ showZ: true,
87
+ snap: null,
88
+ // Snap value for transformations
89
+ translationSnap: null,
90
+ rotationSnap: null,
91
+ scaleSnap: null,
92
+ showBoundingBox: true,
93
+ // Show bounding box on selection
94
+ boundingBoxColor: 0x00ff00,
95
+ // Green bounding box by default
96
+ useBoundingBoxSelection: true // Use bounding box-based selection instead of mesh selection
97
+ };
98
+
99
+ // Callbacks for external event handling
100
+ this.callbacks = {
101
+ onObjectSelect: null,
102
+ onTransformStart: null,
103
+ onTransform: null,
104
+ onTransformEnd: null,
105
+ onModeChange: null,
106
+ onObjectRemoved: null
107
+ };
108
+ this.init();
109
+ }
110
+
111
+ /**
112
+ * Initialize the transform controls
113
+ */
114
+ return _rollupPluginBabelHelpers.createClass(TransformControlsManager, [{
115
+ key: "init",
116
+ value: function init() {
117
+ this.createTransformControls();
118
+ this.setupEventListeners();
119
+ this.setupKeyboardControls();
120
+ }
121
+
122
+ /**
123
+ * Register event callbacks
124
+ * @param {Object} callbacks - Object containing callback functions
125
+ * @param {Function} callbacks.onObjectSelect - Called when an object is selected/deselected
126
+ * @param {Function} callbacks.onTransformStart - Called when transform starts
127
+ * @param {Function} callbacks.onTransform - Called during transform
128
+ * @param {Function} callbacks.onTransformEnd - Called when transform ends
129
+ * @param {Function} callbacks.onModeChange - Called when transform mode changes
130
+ * @param {Function} callbacks.onObjectRemoved - Called when an object is removed
131
+ */
132
+ }, {
133
+ key: "on",
134
+ value: function on(callbacks) {
135
+ if (callbacks.onObjectSelect) {
136
+ this.callbacks.onObjectSelect = callbacks.onObjectSelect;
137
+ }
138
+ if (callbacks.onTransformStart) {
139
+ this.callbacks.onTransformStart = callbacks.onTransformStart;
140
+ }
141
+ if (callbacks.onTransform) {
142
+ this.callbacks.onTransform = callbacks.onTransform;
143
+ }
144
+ if (callbacks.onTransformEnd) {
145
+ this.callbacks.onTransformEnd = callbacks.onTransformEnd;
146
+ }
147
+ if (callbacks.onModeChange) {
148
+ this.callbacks.onModeChange = callbacks.onModeChange;
149
+ }
150
+ if (callbacks.onObjectRemoved) {
151
+ this.callbacks.onObjectRemoved = callbacks.onObjectRemoved;
152
+ }
153
+ console.log('🔗 Transform controls callbacks registered');
154
+ }
155
+ /**
156
+ * Create and configure transform controls
157
+ */
158
+ }, {
159
+ key: "createTransformControls",
160
+ value: function createTransformControls() {
161
+ this.transformControls = new TransformControls.TransformControls(this.camera, this.renderer.domElement);
162
+ this.transformControls.setMode(this.currentMode);
163
+ this.transformControls.setSpace(this.currentSpace);
164
+ this.transformControls.setSize(this.config.size);
165
+ this.transformControls.setDelay(this.clickTiming);
166
+
167
+ // Configure axes visibility
168
+ this.transformControls.showX = this.config.showX;
169
+ this.transformControls.showY = this.config.showY;
170
+ this.transformControls.showZ = this.config.showZ;
171
+
172
+ // Hide multi-axis plane helpers by default (only allow single-axis translation)
173
+ this.transformControls.showXY = false;
174
+ this.transformControls.showYZ = false;
175
+ this.transformControls.showXZ = false;
176
+
177
+ // Mark as transform controls for scene filtering
178
+ this.transformControls.isTransformControls = true;
179
+ this.transformControls.userData = {
180
+ isTransformControls: true
181
+ };
182
+ // Add to scene
183
+ this.scene.add(this.transformControls);
184
+
185
+ // Initially disabled and invisible
186
+ this.transformControls.enabled = false;
187
+ this._hideTransformControls();
188
+ }
189
+
190
+ /**
191
+ * Setup event listeners for transform controls
192
+ */
193
+ }, {
194
+ key: "setupEventListeners",
195
+ value: function setupEventListeners() {
196
+ var _this = this;
197
+ // Transform start event
198
+ this.eventHandlers.transformStart = function () {
199
+ console.log("transformControls transformStart");
200
+ _this.transformState.isTransforming = true;
201
+ if (_this.selectedObject) {
202
+ // Store initial transform state
203
+ _this.transformState.initialTransform = {
204
+ position: _this.selectedObject.position.clone(),
205
+ rotation: _this.selectedObject.rotation.clone(),
206
+ scale: _this.selectedObject.scale.clone()
207
+ };
208
+ }
209
+
210
+ // Disable orbit controls during transformation
211
+ if (_this.orbitControls) {
212
+ _this.orbitControls.enabled = false;
213
+ }
214
+
215
+ // Execute callback
216
+ if (_this.callbacks.onTransformStart) {
217
+ _this.callbacks.onTransformStart(_this.selectedObject, _this.currentMode);
218
+ }
219
+ console.log("\uD83D\uDD27 Transform started: ".concat(_this.currentMode, " mode"));
220
+ };
221
+
222
+ // Transform end event
223
+ this.eventHandlers.transformEnd = function () {
224
+ _this.transformState.isTransforming = false;
225
+
226
+ // Re-enable orbit controls
227
+ if (_this.orbitControls) {
228
+ _this.orbitControls.enabled = true;
229
+ }
230
+
231
+ // Store final transform state
232
+ if (_this.selectedObject) {
233
+ _this.transformState.currentTransform = {
234
+ position: _this.selectedObject.position.clone(),
235
+ rotation: _this.selectedObject.rotation.clone(),
236
+ scale: _this.selectedObject.scale.clone()
237
+ };
238
+
239
+ // Clear bounding box cache for the transformed object to ensure selection uses updated position
240
+ if (_this.boundingBoxCache.has(_this.selectedObject)) {
241
+ _this.boundingBoxCache.delete(_this.selectedObject);
242
+ }
243
+ }
244
+
245
+ // Execute callback
246
+ if (_this.callbacks.onTransformEnd) {
247
+ _this.callbacks.onTransformEnd(_this.selectedObject, _this.transformState.initialTransform, _this.transformState.currentTransform, _this.currentMode);
248
+ }
249
+
250
+ // Dispatch custom scene update event after transform completes
251
+ if (typeof window !== 'undefined') {
252
+ var _this$selectedObject;
253
+ console.log('📡 Dispatching sceneUpdateComplete event after transform');
254
+ var sceneCompleteEvent = new CustomEvent('sceneUpdateComplete', {
255
+ detail: {
256
+ timestamp: Date.now(),
257
+ transformType: _this.currentMode,
258
+ objectName: ((_this$selectedObject = _this.selectedObject) === null || _this$selectedObject === void 0 ? void 0 : _this$selectedObject.name) || 'unknown'
259
+ }
260
+ });
261
+ window.dispatchEvent(sceneCompleteEvent);
262
+ }
263
+ console.log("\u2705 Transform completed: ".concat(_this.currentMode, " mode"));
264
+ };
265
+ // Transform changing event
266
+ this.eventHandlers.transforming = function () {
267
+ // Clear the bounding box cache for the selected object during transformation
268
+ if (_this.selectedObject && _this.boundingBoxCache.has(_this.selectedObject)) {
269
+ _this.boundingBoxCache.delete(_this.selectedObject);
270
+ }
271
+
272
+ // Update bounding box during transformation
273
+ _this.updateBoundingBox();
274
+ if (_this.callbacks.onTransform) {
275
+ _this.callbacks.onTransform(_this.selectedObject, _this.currentMode);
276
+ }
277
+
278
+ // Dispatch custom scene update event during transform (optional - fires continuously)
279
+ if (typeof window !== 'undefined') {
280
+ var _this$selectedObject2;
281
+ var sceneCompleteEvent = new CustomEvent('sceneUpdateComplete', {
282
+ detail: {
283
+ timestamp: Date.now(),
284
+ transformType: _this.currentMode,
285
+ objectName: ((_this$selectedObject2 = _this.selectedObject) === null || _this$selectedObject2 === void 0 ? void 0 : _this$selectedObject2.name) || 'unknown',
286
+ isTransforming: true
287
+ }
288
+ });
289
+ window.dispatchEvent(sceneCompleteEvent);
290
+ }
291
+ };
292
+ // First remove any existing listeners to prevent duplicates
293
+ if (this.transformControls) {
294
+ // Remove existing listeners if they exist
295
+ if (this.eventHandlers.transformStart) {
296
+ this.transformControls.removeEventListener('mouseDown', this.eventHandlers.transformStart);
297
+ }
298
+ if (this.eventHandlers.transformEnd) {
299
+ this.transformControls.removeEventListener('mouseUp', this.eventHandlers.transformEnd);
300
+ }
301
+ if (this.eventHandlers.transforming) {
302
+ this.transformControls.removeEventListener('objectChange', this.eventHandlers.transforming);
303
+ }
304
+
305
+ // Add event listeners
306
+ this.transformControls.addEventListener('mouseDown', this.eventHandlers.transformStart);
307
+ this.transformControls.addEventListener('mouseUp', this.eventHandlers.transformEnd);
308
+ this.transformControls.addEventListener('objectChange', this.eventHandlers.transforming);
309
+ }
310
+ }
311
+ /**
312
+ * Setup keyboard controls for transform modes
313
+ */
314
+ }, {
315
+ key: "setupKeyboardControls",
316
+ value: function setupKeyboardControls() {
317
+ var _this2 = this;
318
+ this.eventHandlers.keydown = function (event) {
319
+ // Only handle keys when transform controls are active
320
+ if (!_this2.transformControls.enabled || _this2.transformState.isTransforming) {
321
+ return;
322
+ }
323
+
324
+ // Check for Ctrl+Z (undo) - don't handle it here, let it pass through
325
+ if (event.ctrlKey && event.code === 'KeyZ') {
326
+ return; // Let the KeyboardControlsManager handle Ctrl+Z
327
+ }
328
+ switch (event.code) {
329
+ case 'KeyG':
330
+ // Translate mode
331
+ _this2.setMode('translate');
332
+ break;
333
+ case 'KeyR':
334
+ // Rotate mode
335
+ _this2.setMode('rotate');
336
+ break;
337
+ case 'KeyS':
338
+ // Scale mode
339
+ _this2.setMode('scale');
340
+ break;
341
+ case 'KeyW':
342
+ // World space
343
+ _this2.setSpace('world');
344
+ break;
345
+ case 'KeyL':
346
+ // Local space
347
+ _this2.setSpace('local');
348
+ break;
349
+ case 'Escape':
350
+ // Deselect object
351
+ _this2.deselectObject();
352
+ break;
353
+ case 'KeyX':
354
+ // X-axis constraint
355
+ _this2.setAxisConstraint('X');
356
+ break;
357
+ case 'KeyY':
358
+ // Y-axis constraint
359
+ _this2.setAxisConstraint('Y');
360
+ break;
361
+ case 'KeyZ':
362
+ // Z-axis constraint (only if not Ctrl+Z)
363
+ if (!event.ctrlKey) {
364
+ _this2.setAxisConstraint('Z');
365
+ }
366
+ break;
367
+ case 'ShiftLeft':
368
+ case 'ShiftRight':
369
+ // Multi-axis constraint
370
+ _this2.clearAxisConstraint();
371
+ break;
372
+ case 'Backspace':
373
+ // Remove selected object
374
+ _this2.handleObjectRemoval();
375
+ break;
376
+ }
377
+ };
378
+ window.addEventListener('keydown', this.eventHandlers.keydown);
379
+ }
380
+ /**
381
+ * Setup mouse-based object selection
382
+ * @param {Function} objectFilter - Optional function to filter selectable objects
383
+ */
384
+ }, {
385
+ key: "setupObjectSelection",
386
+ value: function setupObjectSelection() {
387
+ var _this3 = this;
388
+ var objectFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
389
+ var raycaster = new THREE__namespace.Raycaster();
390
+ var mouse = new THREE__namespace.Vector2();
391
+
392
+ // Single click handler with double-click detection
393
+ this.eventHandlers.click = function (event) {
394
+ // Skip if currently transforming
395
+ if (_this3.transformState.isTransforming) {
396
+ return;
397
+ }
398
+ var currentTime = Date.now();
399
+ var timeSinceLastClick = currentTime - _this3.clickTiming.lastClickTime;
400
+
401
+ // Calculate mouse position and set up raycaster
402
+ _this3._calculateMousePosition(event, mouse);
403
+ raycaster.setFromCamera(mouse, _this3.camera);
404
+
405
+ // Find target object using appropriate selection method
406
+ var targetObject = _this3._findTargetObject(raycaster, objectFilter);
407
+
408
+ // Check if this is a double-click: same object clicked within delay time
409
+ var isSameObject = targetObject === _this3.clickTiming.lastClickedObject;
410
+ var isWithinDelay = timeSinceLastClick < _this3.clickTiming.doubleClickDelay;
411
+ var isDoubleClick = isSameObject && isWithinDelay && targetObject !== null;
412
+ if (isDoubleClick) {
413
+ // Double-click on same object: Full selection including tooltips
414
+ _this3.selectObject(targetObject);
415
+
416
+ // Reset click timing to prevent triple-click issues
417
+ _this3.clickTiming.lastClickTime = 0;
418
+ _this3.clickTiming.lastClickedObject = null;
419
+ } else {
420
+ // Single click: Transform controls and bounding box only
421
+ // Always deselect first (this clears tooltips via the callback)
422
+ _this3.deselectObject();
423
+
424
+ // Then select the new object if there is one (this shows transform controls and bounding box)
425
+ if (targetObject) {
426
+ _this3.selectObjectForTransformOnly(targetObject);
427
+ }
428
+
429
+ // Update click timing
430
+ _this3.clickTiming.lastClickTime = currentTime;
431
+ _this3.clickTiming.lastClickedObject = targetObject;
432
+ }
433
+ };
434
+ this.renderer.domElement.addEventListener('click', this.eventHandlers.click);
435
+ }
436
+
437
+ /**
438
+ * Calculate normalized mouse position from click event
439
+ * @param {Event} event - The click event (single or double)
440
+ * @param {THREE.Vector2} mouse - Vector2 to store mouse position
441
+ * @private
442
+ */
443
+ }, {
444
+ key: "_calculateMousePosition",
445
+ value: function _calculateMousePosition(event, mouse) {
446
+ var rect = this.renderer.domElement.getBoundingClientRect();
447
+ mouse.x = (event.clientX - rect.left) / rect.width * 2 - 1;
448
+ mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
449
+ }
450
+
451
+ /**
452
+ * Find the target object for selection using configured selection method
453
+ * @param {THREE.Raycaster} raycaster - The raycaster for intersection testing
454
+ * @param {Function} objectFilter - Optional function to filter selectable objects
455
+ * @returns {THREE.Object3D|null} The target object or null if nothing selectable
456
+ * @private
457
+ */
458
+ }, {
459
+ key: "_findTargetObject",
460
+ value: function _findTargetObject(raycaster, objectFilter) {
461
+ // Try bounding box selection first if enabled
462
+ if (this.config.useBoundingBoxSelection) {
463
+ var targetObject = this._findTargetViaBoundingBox(raycaster, objectFilter);
464
+ if (targetObject) {
465
+ return targetObject;
466
+ }
467
+ }
468
+
469
+ // Fall back to mesh-based selection
470
+ return this._findTargetViaMesh(raycaster, objectFilter);
471
+ }
472
+
473
+ /**
474
+ * Find target object using bounding box intersection
475
+ * @param {THREE.Raycaster} raycaster - The raycaster for intersection testing
476
+ * @param {Function} objectFilter - Optional function to filter selectable objects
477
+ * @returns {THREE.Object3D|null} The target object or null if nothing found
478
+ * @private
479
+ */
480
+ }, {
481
+ key: "_findTargetViaBoundingBox",
482
+ value: function _findTargetViaBoundingBox(raycaster, objectFilter) {
483
+ var intersections = this.intersectObjectsBoundingBoxes(raycaster, objectFilter);
484
+ if (intersections.length > 0) {
485
+ var targetObject = intersections[0].object;
486
+ if (this._isValidSelectableObject(targetObject)) {
487
+ console.log("\uD83D\uDCE6 Object selected via bounding box: ".concat(targetObject.name || targetObject.uuid));
488
+ return targetObject;
489
+ }
490
+ }
491
+ return null;
492
+ }
493
+
494
+ /**
495
+ * Find target object using mesh intersection
496
+ * @param {THREE.Raycaster} raycaster - The raycaster for intersection testing
497
+ * @param {Function} objectFilter - Optional function to filter selectable objects
498
+ * @returns {THREE.Object3D|null} The target object or null if nothing found
499
+ * @private
500
+ */
501
+ }, {
502
+ key: "_findTargetViaMesh",
503
+ value: function _findTargetViaMesh(raycaster, objectFilter) {
504
+ var intersections = raycaster.intersectObjects(this.scene.children, true);
505
+ if (intersections.length > 0) {
506
+ var targetObject = intersections[0].object;
507
+
508
+ // Resolve the correct object in the hierarchy
509
+ targetObject = this._resolveHierarchyTarget(targetObject);
510
+
511
+ // Check if selectable
512
+ var isSelectable = objectFilter ? objectFilter(targetObject) : this.isSelectableObject(targetObject);
513
+ if (isSelectable && this._isValidSelectableObject(targetObject)) {
514
+ var method = this.config.useBoundingBoxSelection ? ' (fallback)' : '';
515
+ console.log("\uD83C\uDFAF Object selected via mesh".concat(method, ": ").concat(targetObject.name || targetObject.uuid));
516
+ return targetObject;
517
+ }
518
+ }
519
+ return null;
520
+ }
521
+
522
+ /**
523
+ * Resolve the correct target object in the hierarchy
524
+ * @param {THREE.Object3D} object - The initially intersected object
525
+ * @returns {THREE.Object3D} The resolved target object
526
+ * @private
527
+ */
528
+ }, {
529
+ key: "_resolveHierarchyTarget",
530
+ value: function _resolveHierarchyTarget(object) {
531
+ var _object$parent, _object$parent2, _object$userData;
532
+ // Keep connector orbs as direct targets
533
+ if (this.isConnectorOrb(object)) {
534
+ console.log('🔴 Connector orb clicked directly - using connector for transform controls');
535
+ return object;
536
+ }
537
+
538
+ // Look for component parent in hierarchy
539
+ if ((_object$parent = object.parent) !== null && _object$parent !== void 0 && (_object$parent = _object$parent.name) !== null && _object$parent !== void 0 && _object$parent.includes(' Component')) {
540
+ console.log('🎯 Using parent GLB model for transform controls');
541
+ return object.parent;
542
+ }
543
+ if ((_object$parent2 = object.parent) !== null && _object$parent2 !== void 0 && (_object$parent2 = _object$parent2.parent) !== null && _object$parent2 !== void 0 && (_object$parent2 = _object$parent2.name) !== null && _object$parent2 !== void 0 && _object$parent2.includes(' Component')) {
544
+ console.log('🎯 Using grandparent GLB model for transform controls');
545
+ return object.parent.parent;
546
+ }
547
+
548
+ // Debug logging for pipe segments
549
+ if ((_object$userData = object.userData) !== null && _object$userData !== void 0 && _object$userData.isPipeSegment) {
550
+ console.log('🔍 Found pipe segment in selection:', object.name, object.userData);
551
+ }
552
+ return object;
553
+ }
554
+
555
+ /**
556
+ * Check if an object is valid for selection (has required properties and is in scene)
557
+ * @param {THREE.Object3D} object - The object to validate
558
+ * @returns {boolean} Whether the object is valid for selection
559
+ * @private
560
+ */
561
+ }, {
562
+ key: "_isValidSelectableObject",
563
+ value: function _isValidSelectableObject(object) {
564
+ // Safety check: ensure object is still valid and in the scene
565
+ if (!object || !object.parent) {
566
+ console.warn('⚠️ Selected object is no longer valid or in scene');
567
+ return false;
568
+ }
569
+
570
+ // Verify object has all required Three.js properties
571
+ if (!object.position || !object.rotation || !object.scale || !object.updateMatrixWorld) {
572
+ console.warn('❌ Object missing required Three.js properties for transform controls');
573
+ return false;
574
+ }
575
+ return true;
576
+ }
577
+
578
+ /**
579
+ * Check if an object is a connector orb
580
+ * @param {THREE.Object3D} object - The object to check
581
+ * @returns {boolean} Whether the object is a connector orb
582
+ */
583
+ }, {
584
+ key: "isConnectorOrb",
585
+ value: function isConnectorOrb(object) {
586
+ // Basic safety checks
587
+ if (!object || !object.isObject3D) {
588
+ return false;
589
+ }
590
+
591
+ // Check if it's a mesh with connector geometry
592
+ if (!object.isMesh || !object.geometry) {
593
+ return false;
594
+ }
595
+
596
+ // Check for CONNECTOR-GEO geometry uuid
597
+ var hasConnectorGeometry = object.geometry.uuid === 'CONNECTOR-GEO';
598
+
599
+ // Check for SphereGeometry with radius 0.2
600
+ var isSphereConnector = object.geometry.type === 'SphereGeometry' && object.geometry.parameters && object.geometry.parameters.radius === 0.2;
601
+
602
+ // Check if name includes connector
603
+ var hasConnectorName = object.name && object.name.toLowerCase().includes('connector');
604
+ return (hasConnectorGeometry || isSphereConnector) && hasConnectorName;
605
+ }
606
+ /**
607
+ * Default object selection filter
608
+ * @param {THREE.Object3D} object - The object to check
609
+ * @returns {boolean} Whether the object can be selected
610
+ */
611
+ }, {
612
+ key: "isSelectableObject",
613
+ value: function isSelectableObject(object) {
614
+ var _object$userData2, _object$userData3, _object$userData4, _object$userData5, _object$userData6, _object$userData7, _object$userData8, _object$userData9;
615
+ // Basic safety checks
616
+ if (!object || !object.isObject3D) {
617
+ return false;
618
+ }
619
+
620
+ // Debug logging for pipe segments
621
+ if (object.userData && object.userData.isPipeSegment) {
622
+ console.log('🔍 Found pipe segment in selection check:', object.name, object.userData);
623
+ }
624
+
625
+ // Skip transform controls and their children
626
+ if (object.isTransformControls || object.isTransformControlsPlane || object.isTransformControlsGizmo) {
627
+ return false;
628
+ }
629
+
630
+ // Skip helpers and special objects
631
+ var isHelper = object.isHelper || ((_object$userData2 = object.userData) === null || _object$userData2 === void 0 ? void 0 : _object$userData2.isHelper) || ((_object$userData3 = object.userData) === null || _object$userData3 === void 0 ? void 0 : _object$userData3.isBoundingBox);
632
+ var isBaseGround = (_object$userData4 = object.userData) === null || _object$userData4 === void 0 ? void 0 : _object$userData4.isBaseGround;
633
+ var isBrickWall = (_object$userData5 = object.userData) === null || _object$userData5 === void 0 ? void 0 : _object$userData5.isBrickWall;
634
+ if (isHelper || isBaseGround || isBrickWall || !object.visible) {
635
+ return false;
636
+ }
637
+
638
+ // Allow pipe segments and junctions to be selected, but exclude parent polyline objects
639
+ if (object.name && object.name.toLowerCase().includes('polyline') && !((_object$userData6 = object.userData) !== null && _object$userData6 !== void 0 && _object$userData6.isPipeSegment) && !((_object$userData7 = object.userData) !== null && _object$userData7 !== void 0 && _object$userData7.isPipeJunction)) {
640
+ console.log('❌ Polyline parent object excluded from selection:', object.name);
641
+ return false;
642
+ }
643
+
644
+ // Check for pipe segments and junctions
645
+ var isPipeSegment = ((_object$userData8 = object.userData) === null || _object$userData8 === void 0 ? void 0 : _object$userData8.isPipeSegment) === true;
646
+ var isPipeJunction = ((_object$userData9 = object.userData) === null || _object$userData9 === void 0 ? void 0 : _object$userData9.isPipeJunction) === true;
647
+
648
+ // Check for GLB models
649
+ var isGLBModel = object.name && object.name.includes(' Component');
650
+
651
+ // Check for connector orbs
652
+ var isConnector = this.isConnectorOrb(object);
653
+ return isGLBModel || isConnector || isPipeSegment || isPipeJunction;
654
+ }
655
+ /**
656
+ * Select an object for transformation
657
+ * @param {THREE.Object3D} object - The object to select
658
+ */
659
+ }, {
660
+ key: "selectObject",
661
+ value: function selectObject(object) {
662
+ if (!object || !object.isObject3D) {
663
+ console.warn('⚠️ Invalid object provided for selection');
664
+ return false;
665
+ }
666
+ this.selectedObject = object;
667
+
668
+ // Force object matrix update to ensure correct transforms
669
+ object.updateMatrixWorld(true);
670
+
671
+ // Refresh bounding box cache for this object
672
+ var updatedBoundingBox = new THREE__namespace.Box3().setFromObject(object);
673
+ this.boundingBoxCache.set(object, updatedBoundingBox);
674
+
675
+ // Attach transform controls
676
+ this.transformControls.attach(object);
677
+
678
+ // Update interaction time to reset delay
679
+ if (this.transformControls.updateInteractionTime) {
680
+ this.transformControls.updateInteractionTime();
681
+ }
682
+
683
+ // Create and show bounding box if enabled
684
+ this.createBoundingBox(object);
685
+
686
+ // Only enable if not forcing invisibility
687
+ if (!this.forceInvisible) {
688
+ this.transformControls.enabled = this.config.enabled;
689
+ this._showTransformControls();
690
+ } else {
691
+ console.log('🔒 Transform controls kept invisible despite object selection');
692
+ this.transformControls.enabled = false;
693
+ this._hideTransformControls();
694
+ }
695
+
696
+ // Execute callback
697
+ if (this.callbacks.onObjectSelect) {
698
+ this.callbacks.onObjectSelect(object);
699
+ }
700
+ console.log("\uD83C\uDFAF Object selected: ".concat(object.name || object.uuid));
701
+ return true;
702
+ } /**
703
+ * Select object for transform controls and bounding box only (no tooltip callback)
704
+ * @param {THREE.Object3D} object - The object to select
705
+ * @returns {boolean} True if selection successful
706
+ */
707
+ }, {
708
+ key: "selectObjectForTransformOnly",
709
+ value: function selectObjectForTransformOnly(object) {
710
+ if (!object || !object.isObject3D) {
711
+ console.warn('⚠️ Invalid object provided for selection');
712
+ return false;
713
+ }
714
+ this.selectedObject = object;
715
+
716
+ // Force object matrix update to ensure correct transforms
717
+ object.updateMatrixWorld(true);
718
+
719
+ // Refresh bounding box cache for this object
720
+ var updatedBoundingBox = new THREE__namespace.Box3().setFromObject(object);
721
+ this.boundingBoxCache.set(object, updatedBoundingBox);
722
+
723
+ // Attach transform controls
724
+ this.transformControls.attach(object);
725
+
726
+ // Update interaction time to reset delay
727
+ if (this.transformControls.updateInteractionTime) {
728
+ this.transformControls.updateInteractionTime();
729
+ }
730
+
731
+ // Create and show bounding box if enabled
732
+ this.createBoundingBox(object);
733
+
734
+ // Only enable if not forcing invisibility
735
+ if (!this.forceInvisible) {
736
+ this.transformControls.enabled = true;
737
+ this._showTransformControls();
738
+ } else {
739
+ console.log('🔒 Transform controls kept invisible despite object selection');
740
+ this.transformControls.enabled = false;
741
+ this._hideTransformControls();
742
+ }
743
+
744
+ // NOTE: We deliberately do NOT call any callback here
745
+ // This allows transform controls and bounding box to show without triggering tooltips
746
+
747
+ console.log("\uD83C\uDFAF Object selected for transform only: ".concat(object.name || object.uuid));
748
+ return true;
749
+ }
750
+
751
+ /**
752
+ * Deselect the currently selected object
753
+ */
754
+ }, {
755
+ key: "deselectObject",
756
+ value: function deselectObject() {
757
+ if (this.selectedObject) {
758
+ console.log("\uD83D\uDD04 Object deselected: ".concat(this.selectedObject.name || this.selectedObject.uuid));
759
+ }
760
+
761
+ // Remove bounding box
762
+ this.removeBoundingBox();
763
+ this.selectedObject = null;
764
+ // Detach and hide transform controls
765
+ if (this.transformControls) {
766
+ // First detach from object
767
+ this.transformControls.detach();
768
+ this.transformControls.enabled = false;
769
+
770
+ // Properly hide all transform control components
771
+ this._hideTransformControls();
772
+ console.log("\uD83D\uDD12 Transform controls hidden after deselection");
773
+ }
774
+
775
+ // Execute callback
776
+ if (this.callbacks.onObjectSelect) {
777
+ this.callbacks.onObjectSelect(null);
778
+ }
779
+ }
780
+
781
+ /**
782
+ * Create and display a bounding box for the selected object
783
+ * @param {THREE.Object3D} object - The object to create a bounding box for
784
+ */
785
+ }, {
786
+ key: "createBoundingBox",
787
+ value: function createBoundingBox(object) {
788
+ // Skip if bounding box is disabled
789
+ if (!this.config.showBoundingBox) {
790
+ return;
791
+ }
792
+
793
+ // Remove any existing bounding box first
794
+ this.removeBoundingBox();
795
+ if (!object) {
796
+ return;
797
+ }
798
+ try {
799
+ // Create a BoxHelper to show the bounding box
800
+ this.boundingBoxHelper = new THREE__namespace.BoxHelper(object, this.config.boundingBoxColor);
801
+
802
+ // Mark it as a helper to avoid selection
803
+ this.boundingBoxHelper.isHelper = true;
804
+ this.boundingBoxHelper.userData = {
805
+ isBoundingBox: true
806
+ };
807
+ console.log("this.boundingBoxHelper object:", object);
808
+
809
+ // Add to scene
810
+ this.scene.add(this.boundingBoxHelper);
811
+ console.log("\uD83D\uDCE6 Bounding box created for: ".concat(object.name || object.uuid));
812
+ } catch (error) {
813
+ console.warn('⚠️ Failed to create bounding box:', error);
814
+ }
815
+ }
816
+
817
+ /**
818
+ * Remove the current bounding box helper
819
+ */
820
+ }, {
821
+ key: "removeBoundingBox",
822
+ value: function removeBoundingBox() {
823
+ if (this.boundingBoxHelper) {
824
+ try {
825
+ // Remove from scene
826
+ if (this.boundingBoxHelper.parent) {
827
+ this.boundingBoxHelper.parent.remove(this.boundingBoxHelper);
828
+ }
829
+
830
+ // Dispose geometry and material if they exist
831
+ if (this.boundingBoxHelper.geometry) {
832
+ this.boundingBoxHelper.geometry.dispose();
833
+ }
834
+ if (this.boundingBoxHelper.material) {
835
+ this.boundingBoxHelper.material.dispose();
836
+ }
837
+ console.log('📦 Bounding box removed');
838
+ } catch (error) {
839
+ console.warn('⚠️ Error removing bounding box:', error);
840
+ } finally {
841
+ this.boundingBoxHelper = null;
842
+ }
843
+ }
844
+ }
845
+
846
+ /**
847
+ * Update the bounding box to match the current object state
848
+ * Call this after any transformation to keep the bounding box in sync
849
+ */
850
+ }, {
851
+ key: "updateBoundingBox",
852
+ value: function updateBoundingBox() {
853
+ if (this.boundingBoxHelper && this.selectedObject) {
854
+ try {
855
+ // Force object matrix update to ensure correct bounding box
856
+ this.selectedObject.updateMatrixWorld(true);
857
+
858
+ // Update bounding box
859
+ this.boundingBoxHelper.update();
860
+
861
+ // Also update the cached bounding box if it exists
862
+ if (this.boundingBoxCache.has(this.selectedObject)) {
863
+ var updatedBoundingBox = new THREE__namespace.Box3().setFromObject(this.selectedObject);
864
+ this.boundingBoxCache.set(this.selectedObject, updatedBoundingBox);
865
+ }
866
+ } catch (error) {
867
+ console.warn('⚠️ Error updating bounding box:', error);
868
+ // If update fails, recreate the bounding box
869
+ this.createBoundingBox(this.selectedObject);
870
+ }
871
+ }
872
+ }
873
+
874
+ /**
875
+ * Set bounding box visibility
876
+ * @param {boolean} show - Whether to show the bounding box
877
+ */
878
+ }, {
879
+ key: "setBoundingBoxVisibility",
880
+ value: function setBoundingBoxVisibility(show) {
881
+ this.config.showBoundingBox = show;
882
+ if (show && this.selectedObject && !this.boundingBoxHelper) {
883
+ // Create bounding box if it doesn't exist and we have a selected object
884
+ this.createBoundingBox(this.selectedObject);
885
+ } else if (!show && this.boundingBoxHelper) {
886
+ // Remove bounding box if it exists and we're hiding it
887
+ this.removeBoundingBox();
888
+ }
889
+ console.log("\uD83D\uDCE6 Bounding box visibility: ".concat(show ? 'enabled' : 'disabled'));
890
+ }
891
+
892
+ /**
893
+ * Set bounding box color
894
+ * @param {number} color - The color value (hex)
895
+ */
896
+ }, {
897
+ key: "setBoundingBoxColor",
898
+ value: function setBoundingBoxColor(color) {
899
+ this.config.boundingBoxColor = color;
900
+
901
+ // Update existing bounding box color if it exists
902
+ if (this.boundingBoxHelper && this.boundingBoxHelper.material) {
903
+ this.boundingBoxHelper.material.color.setHex(color);
904
+ }
905
+ console.log("\uD83D\uDCE6 Bounding box color set to: 0x".concat(color.toString(16).padStart(6, '0')));
906
+ }
907
+
908
+ /**
909
+ * Set the transformation mode
910
+ * @param {'translate' | 'rotate' | 'scale'} mode - The transformation mode
911
+ */
912
+ }, {
913
+ key: "setMode",
914
+ value: function setMode(mode) {
915
+ if (!['translate', 'rotate', 'scale'].includes(mode)) {
916
+ console.warn("\u26A0\uFE0F Invalid transform mode: ".concat(mode));
917
+ return;
918
+ }
919
+ var previousMode = this.currentMode;
920
+ this.currentMode = mode;
921
+ this.transformControls.setMode(mode);
922
+
923
+ // Execute callback
924
+ if (this.callbacks.onModeChange) {
925
+ this.callbacks.onModeChange(mode, previousMode);
926
+ }
927
+ console.log("\uD83D\uDD27 Transform mode changed: ".concat(previousMode, " \u2192 ").concat(mode));
928
+ }
929
+
930
+ /**
931
+ * Set the transformation space
932
+ * @param {'world' | 'local'} space - The transformation space
933
+ */
934
+ }, {
935
+ key: "setSpace",
936
+ value: function setSpace(space) {
937
+ if (!['world', 'local'].includes(space)) {
938
+ console.warn("\u26A0\uFE0F Invalid transform space: ".concat(space));
939
+ return;
940
+ }
941
+ var previousSpace = this.currentSpace;
942
+ this.currentSpace = space;
943
+ this.transformControls.setSpace(space);
944
+ console.log("\uD83C\uDF10 Transform space changed: ".concat(previousSpace, " \u2192 ").concat(space));
945
+ }
946
+
947
+ /**
948
+ * Set axis constraint for transformations
949
+ * @param {'X' | 'Y' | 'Z'} axis - The axis to constrain to
950
+ */
951
+ }, {
952
+ key: "setAxisConstraint",
953
+ value: function setAxisConstraint(axis) {
954
+ if (!['X', 'Y', 'Z'].includes(axis)) {
955
+ console.warn("\u26A0\uFE0F Invalid axis constraint: ".concat(axis));
956
+ return;
957
+ }
958
+
959
+ // Reset all axes first
960
+ this.transformControls.showX = false;
961
+ this.transformControls.showY = false;
962
+ this.transformControls.showZ = false;
963
+
964
+ // Enable only the specified axis
965
+ this.transformControls["show".concat(axis)] = true;
966
+ console.log("\uD83D\uDD12 Axis constraint set: ".concat(axis, "-axis only"));
967
+ }
968
+
969
+ /**
970
+ * Clear axis constraints (show all axes)
971
+ */
972
+ }, {
973
+ key: "clearAxisConstraint",
974
+ value: function clearAxisConstraint() {
975
+ this.transformControls.showX = this.config.showX;
976
+ this.transformControls.showY = this.config.showY;
977
+ this.transformControls.showZ = this.config.showZ;
978
+ console.log('🔓 Axis constraints cleared');
979
+ }
980
+
981
+ /**
982
+ * Set snapping values for transformations
983
+ * @param {Object} snapConfig - Snap configuration
984
+ * @param {number} snapConfig.translation - Translation snap value
985
+ * @param {number} snapConfig.rotation - Rotation snap value (in radians)
986
+ * @param {number} snapConfig.scale - Scale snap value
987
+ */
988
+ }, {
989
+ key: "setSnap",
990
+ value: function setSnap() {
991
+ var snapConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
992
+ if (snapConfig.translation !== undefined) {
993
+ this.config.translationSnap = snapConfig.translation;
994
+ this.transformControls.setTranslationSnap(snapConfig.translation);
995
+ }
996
+ if (snapConfig.rotation !== undefined) {
997
+ this.config.rotationSnap = snapConfig.rotation;
998
+ this.transformControls.setRotationSnap(snapConfig.rotation);
999
+ }
1000
+ if (snapConfig.scale !== undefined) {
1001
+ this.config.scaleSnap = snapConfig.scale;
1002
+ this.transformControls.setScaleSnap(snapConfig.scale);
1003
+ }
1004
+ console.log('📏 Snap values updated:', snapConfig);
1005
+ }
1006
+
1007
+ /**
1008
+ * Get the current snap values
1009
+ * @return {Object} The current snap values for translation, rotation, and scale
1010
+ */
1011
+ }, {
1012
+ key: "snapValues",
1013
+ get: function get() {
1014
+ return {
1015
+ translation: this.config.translationSnap || 0.5,
1016
+ // Default to 0.5 if not set
1017
+ rotation: this.config.rotationSnap || Math.PI / 2,
1018
+ // Default to 90 degrees if not set
1019
+ scale: this.config.scaleSnap || 0.1 // Default to 0.1 if not set
1020
+ };
1021
+ }
1022
+
1023
+ /**
1024
+ * Set the size of the transform controls
1025
+ * @param {number} size - The size of the transform controls
1026
+ */
1027
+ }, {
1028
+ key: "setSize",
1029
+ value: function setSize(size) {
1030
+ this.config.size = size;
1031
+ this.transformControls.setSize(size);
1032
+ console.log("\uD83D\uDCCF Transform controls size set to: ".concat(size));
1033
+ }
1034
+ /**
1035
+ * Enable or disable the transform controls
1036
+ * @param {boolean} enabled - Whether to enable the controls
1037
+ */
1038
+ }, {
1039
+ key: "setEnabled",
1040
+ value: function setEnabled(enabled) {
1041
+ this.config.enabled = enabled;
1042
+ if (this.selectedObject) {
1043
+ this.transformControls.enabled = enabled;
1044
+ }
1045
+ console.log("\uD83D\uDD04 Transform controls ".concat(enabled ? 'enabled' : 'disabled'));
1046
+ }
1047
+
1048
+ /**
1049
+ * Configure whether multi-axis plane helpers are shown
1050
+ * @param {boolean} showPlanes - Whether to show multi-axis translation planes (XY, YZ, XZ)
1051
+ */
1052
+ }, {
1053
+ key: "setShowPlanes",
1054
+ value: function setShowPlanes(showPlanes) {
1055
+ if (!this.transformControls) {
1056
+ console.warn('⚠️ Cannot configure plane helpers: transform controls not available');
1057
+ return false;
1058
+ }
1059
+
1060
+ // Set the plane visibility properties directly
1061
+ this.transformControls.showXY = showPlanes;
1062
+ this.transformControls.showYZ = showPlanes;
1063
+ this.transformControls.showXZ = showPlanes;
1064
+ console.log("\uD83D\uDD27 Multi-axis planes ".concat(showPlanes ? 'enabled' : 'disabled'));
1065
+ return true;
1066
+ }
1067
+ /**
1068
+ * Ensure transform controls are properly attached to the scene
1069
+ * This method helps recover from scene operations that might detach the controls
1070
+ */
1071
+ }, {
1072
+ key: "ensureSceneAttachment",
1073
+ value: function ensureSceneAttachment() {
1074
+ var allowVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1075
+ // If transform controls don't exist, recreate them
1076
+ if (!this.transformControls && this.scene && this.camera && this.renderer) {
1077
+ console.log('🔧 Transform controls missing, recreating...');
1078
+ this.createTransformControls();
1079
+ this.setupEventListeners();
1080
+ console.log('✅ Transform controls recreated and attached to scene');
1081
+ if (!allowVisible) {
1082
+ this.transformControls.visible = false;
1083
+ console.log('🔧 Setting newly created transform controls to invisible');
1084
+ }
1085
+ return true;
1086
+ }
1087
+ if (!this.transformControls || !this.scene) {
1088
+ console.warn('⚠️ Cannot ensure attachment: missing transform controls or scene');
1089
+ return false;
1090
+ }
1091
+
1092
+ // Check if transform controls are still in the scene
1093
+ var isAttached = this.scene.children.includes(this.transformControls);
1094
+ if (!isAttached) {
1095
+ console.log('🔧 Re-attaching transform controls to scene...');
1096
+ this.scene.add(this.transformControls);
1097
+
1098
+ // Reset state after reattachment
1099
+ this.transformControls.enabled = false;
1100
+ if (this.selectedObject) {
1101
+ // If there was a selected object, reattach it
1102
+ this.transformControls.attach(this.selectedObject);
1103
+ this.transformControls.enabled = this.config.enabled;
1104
+ }
1105
+
1106
+ // Control visibility based on allowVisible parameter
1107
+ if (!allowVisible) {
1108
+ this.transformControls.visible = false;
1109
+ console.log('🔧 Keeping reattached transform controls invisible');
1110
+ }
1111
+ console.log('✅ Transform controls reattached to scene');
1112
+ return true;
1113
+ }
1114
+ // Only make visible if allowVisible is true
1115
+ if (!this.transformControls.visible && allowVisible) {
1116
+ console.log('🔧 Transform controls were invisible, making visible');
1117
+ this.transformControls.visible = true;
1118
+ return true;
1119
+ } else if (this.transformControls.visible && !allowVisible) {
1120
+ console.log('🔧 Transform controls were visible, making invisible');
1121
+ this.transformControls.visible = false;
1122
+ return true;
1123
+ }
1124
+
1125
+ // Check if the transform controls have a parent but it's not the scene
1126
+ if (this.transformControls.parent && this.transformControls.parent !== this.scene) {
1127
+ console.log('🔧 Transform controls have wrong parent, re-attaching to scene...');
1128
+ this.transformControls.parent.remove(this.transformControls);
1129
+ this.scene.add(this.transformControls);
1130
+ return true;
1131
+ }
1132
+ return false;
1133
+ }
1134
+
1135
+ /**
1136
+ * Get the current transformation data
1137
+ * @returns {Object} Current transformation state
1138
+ */
1139
+ }, {
1140
+ key: "getTransformData",
1141
+ value: function getTransformData() {
1142
+ if (!this.selectedObject) {
1143
+ return null;
1144
+ }
1145
+
1146
+ // Get local transforms (existing)
1147
+ var localTransforms = {
1148
+ position: this.selectedObject.position.clone(),
1149
+ rotation: this.selectedObject.rotation.clone(),
1150
+ scale: this.selectedObject.scale.clone()
1151
+ };
1152
+
1153
+ // Get world transforms (new)
1154
+ var worldTransforms = this.getWorldTransformData();
1155
+ return {
1156
+ object: this.selectedObject,
1157
+ position: localTransforms.position,
1158
+ rotation: localTransforms.rotation,
1159
+ scale: localTransforms.scale,
1160
+ worldPosition: worldTransforms.position,
1161
+ worldRotation: worldTransforms.rotation,
1162
+ worldScale: worldTransforms.scale,
1163
+ mode: this.currentMode,
1164
+ space: this.currentSpace,
1165
+ isTransforming: this.transformState.isTransforming
1166
+ };
1167
+ }
1168
+
1169
+ /**
1170
+ * Get world transformation data for the selected object
1171
+ * @returns {Object} World transformation data
1172
+ */
1173
+ }, {
1174
+ key: "getWorldTransformData",
1175
+ value: function getWorldTransformData() {
1176
+ if (!this.selectedObject) {
1177
+ return null;
1178
+ }
1179
+
1180
+ // Ensure the object's world matrix is up to date
1181
+ this.selectedObject.updateMatrixWorld(true);
1182
+
1183
+ // Get world position
1184
+ var worldPosition = new THREE__namespace.Vector3();
1185
+ this.selectedObject.getWorldPosition(worldPosition);
1186
+
1187
+ // Get world quaternion
1188
+ var worldQuaternion = new THREE__namespace.Quaternion();
1189
+ this.selectedObject.getWorldQuaternion(worldQuaternion);
1190
+
1191
+ // Convert quaternion to Euler rotation
1192
+ var worldRotation = new THREE__namespace.Euler();
1193
+ worldRotation.setFromQuaternion(worldQuaternion);
1194
+
1195
+ // Get world scale
1196
+ var worldScale = new THREE__namespace.Vector3();
1197
+ this.selectedObject.getWorldScale(worldScale);
1198
+ return {
1199
+ position: worldPosition,
1200
+ rotation: worldRotation,
1201
+ scale: worldScale
1202
+ };
1203
+ }
1204
+
1205
+ /**
1206
+ * Update object transform using world coordinates
1207
+ * @param {string} type - Transform type: 'position', 'rotation', 'scale'
1208
+ * @param {string} axis - Axis: 'x', 'y', 'z'
1209
+ * @param {number|string} value - The world coordinate value to set
1210
+ * @param {boolean} useWorldCoords - Whether to interpret the value as world coordinates
1211
+ */
1212
+ }, {
1213
+ key: "updateObjectTransform",
1214
+ value: function updateObjectTransform(type, axis, value) {
1215
+ var useWorldCoords = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1216
+ if (!this.selectedObject) {
1217
+ console.warn('⚠️ No object selected for transformation');
1218
+ return;
1219
+ }
1220
+ var object = this.selectedObject;
1221
+ var numericValue = parseFloat(value);
1222
+ if (isNaN(numericValue)) {
1223
+ console.warn('⚠️ Invalid numeric value for transform:', value);
1224
+ return;
1225
+ }
1226
+ if (useWorldCoords) {
1227
+ // Update using world coordinates
1228
+ this.updateWorldTransform(object, type, axis, numericValue);
1229
+ } else {
1230
+ // Update using local coordinates (existing behavior)
1231
+ switch (type) {
1232
+ case 'position':
1233
+ object.position[axis] = numericValue;
1234
+ break;
1235
+ case 'rotation':
1236
+ // Convert from degrees to radians
1237
+ object.rotation[axis] = numericValue * (Math.PI / 180);
1238
+ break;
1239
+ case 'scale':
1240
+ object.scale[axis] = numericValue;
1241
+ break;
1242
+ default:
1243
+ console.warn("\u26A0\uFE0F Unknown transform type: ".concat(type));
1244
+ return;
1245
+ }
1246
+ } // Update transform controls to reflect the change
1247
+ if (this.transformControls) {
1248
+ this.transformControls.updateMatrixWorld();
1249
+ }
1250
+
1251
+ // Update bounding box to reflect the change
1252
+ this.updateBoundingBox();
1253
+ var coordType = useWorldCoords ? 'world' : 'local';
1254
+ console.log("\uD83D\uDD04 Updated ".concat(coordType, " ").concat(type, ".").concat(axis, " to ").concat(numericValue, " for ").concat(object.name));
1255
+ }
1256
+
1257
+ /**
1258
+ * Update object transform using world coordinates
1259
+ * @param {THREE.Object3D} object - The object to transform
1260
+ * @param {string} type - Transform type: 'position', 'rotation', 'scale'
1261
+ * @param {string} axis - Axis: 'x', 'y', 'z'
1262
+ * @param {number} worldValue - The world coordinate value
1263
+ */
1264
+ }, {
1265
+ key: "updateWorldTransform",
1266
+ value: function updateWorldTransform(object, type, axis, worldValue) {
1267
+ // Ensure matrices are up to date
1268
+ object.updateMatrixWorld(true);
1269
+ switch (type) {
1270
+ case 'position':
1271
+ this.setWorldPosition(object, axis, worldValue);
1272
+ break;
1273
+ case 'rotation':
1274
+ this.setWorldRotation(object, axis, worldValue);
1275
+ break;
1276
+ case 'scale':
1277
+ this.setWorldScale(object, axis, worldValue);
1278
+ break;
1279
+ default:
1280
+ console.warn("\u26A0\uFE0F Unknown transform type: ".concat(type));
1281
+ }
1282
+ }
1283
+
1284
+ /**
1285
+ * Set world position for a specific axis
1286
+ * @param {THREE.Object3D} object - The object
1287
+ * @param {string} axis - The axis ('x', 'y', or 'z')
1288
+ * @param {number} worldValue - The world position value
1289
+ */
1290
+ }, {
1291
+ key: "setWorldPosition",
1292
+ value: function setWorldPosition(object, axis, worldValue) {
1293
+ // Get current world position
1294
+ var currentWorldPos = new THREE__namespace.Vector3();
1295
+ object.getWorldPosition(currentWorldPos);
1296
+
1297
+ // Update the specific axis
1298
+ currentWorldPos[axis] = worldValue;
1299
+
1300
+ // Convert world position back to local position
1301
+ if (object.parent) {
1302
+ var parentMatrixInverse = new THREE__namespace.Matrix4();
1303
+ parentMatrixInverse.copy(object.parent.matrixWorld).invert();
1304
+ currentWorldPos.applyMatrix4(parentMatrixInverse);
1305
+ }
1306
+
1307
+ // Set the local position
1308
+ object.position.copy(currentWorldPos);
1309
+ }
1310
+
1311
+ /**
1312
+ * Set world rotation for a specific axis
1313
+ * @param {THREE.Object3D} object - The object
1314
+ * @param {string} axis - The axis ('x', 'y', or 'z')
1315
+ * @param {number} worldValue - The world rotation value in degrees
1316
+ */
1317
+ }, {
1318
+ key: "setWorldRotation",
1319
+ value: function setWorldRotation(object, axis, worldValue) {
1320
+ // Get current world quaternion
1321
+ var currentWorldQuat = new THREE__namespace.Quaternion();
1322
+ object.getWorldQuaternion(currentWorldQuat);
1323
+
1324
+ // Convert to Euler
1325
+ var currentWorldEuler = new THREE__namespace.Euler();
1326
+ currentWorldEuler.setFromQuaternion(currentWorldQuat);
1327
+
1328
+ // Update the specific axis (convert degrees to radians)
1329
+ currentWorldEuler[axis] = worldValue * (Math.PI / 180);
1330
+
1331
+ // Convert back to quaternion
1332
+ var newWorldQuat = new THREE__namespace.Quaternion();
1333
+ newWorldQuat.setFromEuler(currentWorldEuler);
1334
+
1335
+ // Convert world quaternion back to local rotation
1336
+ if (object.parent) {
1337
+ var parentWorldQuat = new THREE__namespace.Quaternion();
1338
+ object.parent.getWorldQuaternion(parentWorldQuat);
1339
+ parentWorldQuat.invert();
1340
+ newWorldQuat.premultiply(parentWorldQuat);
1341
+ }
1342
+
1343
+ // Set the local rotation
1344
+ object.quaternion.copy(newWorldQuat);
1345
+ }
1346
+
1347
+ /**
1348
+ * Set world scale for a specific axis
1349
+ * @param {THREE.Object3D} object - The object
1350
+ * @param {string} axis - The axis ('x', 'y', or 'z')
1351
+ * @param {number} worldValue - The world scale value
1352
+ */
1353
+ }, {
1354
+ key: "setWorldScale",
1355
+ value: function setWorldScale(object, axis, worldValue) {
1356
+ // Get current world scale
1357
+ var currentWorldScale = new THREE__namespace.Vector3();
1358
+ object.getWorldScale(currentWorldScale);
1359
+
1360
+ // Calculate the scale factor needed
1361
+ var scaleFactor = worldValue / currentWorldScale[axis];
1362
+
1363
+ // Apply to local scale
1364
+ object.scale[axis] *= scaleFactor;
1365
+ }
1366
+ /**
1367
+ * Get selectable objects with their bounding boxes for ray intersection testing
1368
+ * @param {Function} objectFilter - Optional function to filter selectable objects
1369
+ * @returns {Array} Array of objects with their bounding boxes
1370
+ */
1371
+ }, {
1372
+ key: "getSelectableObjectsWithBounds",
1373
+ value: function getSelectableObjectsWithBounds() {
1374
+ var _this4 = this;
1375
+ var objectFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1376
+ var objectsWithBounds = [];
1377
+
1378
+ // Traverse scene to find selectable objects
1379
+ this.scene.traverse(function (object) {
1380
+ var _object$userData0, _object$userData1;
1381
+ // Skip invalid objects and helpers early
1382
+ if (!object || !object.isObject3D) {
1383
+ return;
1384
+ }
1385
+
1386
+ // Skip transform controls and their children
1387
+ if (object.isTransformControls || object.isTransformControlsPlane || object.isTransformControlsGizmo) {
1388
+ return;
1389
+ }
1390
+
1391
+ // Skip other helpers and special objects
1392
+ if (object.isHelper || (_object$userData0 = object.userData) !== null && _object$userData0 !== void 0 && _object$userData0.isHelper || (_object$userData1 = object.userData) !== null && _object$userData1 !== void 0 && _object$userData1.isBoundingBox) {
1393
+ return;
1394
+ }
1395
+ try {
1396
+ // Apply filter (use provided filter or default isSelectableObject method)
1397
+ var isSelectable = objectFilter ? objectFilter(object) : _this4.isSelectableObject(object);
1398
+ if (isSelectable) {
1399
+ // Force object matrix update to ensure correct bounding box
1400
+ object.updateMatrixWorld(true);
1401
+
1402
+ // Get or compute bounding box
1403
+ var boundingBox = _this4.boundingBoxCache.get(object);
1404
+
1405
+ // Always recompute bounding box for recently transformed objects
1406
+ // or if no cached bounding box exists
1407
+ if (!boundingBox || object === _this4.selectedObject) {
1408
+ // Compute and cache bounding box
1409
+ boundingBox = new THREE__namespace.Box3().setFromObject(object);
1410
+ _this4.boundingBoxCache.set(object, boundingBox);
1411
+ }
1412
+ objectsWithBounds.push({
1413
+ object: object,
1414
+ boundingBox: boundingBox
1415
+ });
1416
+ }
1417
+ } catch (error) {
1418
+ // Silently skip objects that cause errors during filtering
1419
+ console.warn('⚠️ Skipping object due to filter error:', object.type || 'unknown', error.message);
1420
+ }
1421
+ });
1422
+ return objectsWithBounds;
1423
+ }
1424
+
1425
+ /**
1426
+ * Test ray intersection with object bounding boxes
1427
+ * @param {THREE.Raycaster} raycaster - The raycaster to test intersections with
1428
+ * @param {Function} objectFilter - Optional function to filter selectable objects
1429
+ * @returns {Array} Array of intersection results sorted by distance
1430
+ */
1431
+ }, {
1432
+ key: "intersectObjectsBoundingBoxes",
1433
+ value: function intersectObjectsBoundingBoxes(raycaster) {
1434
+ var objectFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1435
+ var objectsWithBounds = this.getSelectableObjectsWithBounds(objectFilter);
1436
+ var intersections = [];
1437
+ var _iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(objectsWithBounds),
1438
+ _step;
1439
+ try {
1440
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1441
+ var item = _step.value;
1442
+ var object = item.object,
1443
+ boundingBox = item.boundingBox;
1444
+
1445
+ // Test ray intersection with bounding box
1446
+ var intersection = raycaster.ray.intersectBox(boundingBox, new THREE__namespace.Vector3());
1447
+ if (intersection) {
1448
+ // Calculate distance from ray origin to intersection point
1449
+ var distance = raycaster.ray.origin.distanceTo(intersection);
1450
+ intersections.push({
1451
+ object: object,
1452
+ point: intersection,
1453
+ distance: distance,
1454
+ boundingBox: boundingBox
1455
+ });
1456
+ }
1457
+ }
1458
+
1459
+ // Sort by distance (closest first)
1460
+ } catch (err) {
1461
+ _iterator.e(err);
1462
+ } finally {
1463
+ _iterator.f();
1464
+ }
1465
+ intersections.sort(function (a, b) {
1466
+ return a.distance - b.distance;
1467
+ });
1468
+ return intersections;
1469
+ }
1470
+
1471
+ /**
1472
+ * Toggle between bounding box-based and mesh-based selection
1473
+ * @param {boolean} useBoundingBox - Whether to use bounding box selection
1474
+ */
1475
+ }, {
1476
+ key: "setBoundingBoxSelection",
1477
+ value: function setBoundingBoxSelection(useBoundingBox) {
1478
+ this.config.useBoundingBoxSelection = useBoundingBox;
1479
+ console.log("\uD83C\uDFAF Selection method: ".concat(useBoundingBox ? 'Bounding Box' : 'Mesh-based'));
1480
+ }
1481
+
1482
+ /**
1483
+ * Handle object removal when backspace is pressed
1484
+ */
1485
+ }, {
1486
+ key: "handleObjectRemoval",
1487
+ value: function handleObjectRemoval() {
1488
+ var _this$selectedObject$;
1489
+ if (!this.selectedObject) {
1490
+ return;
1491
+ }
1492
+
1493
+ // Check if the object is a gateway
1494
+ if (((_this$selectedObject$ = this.selectedObject.userData) === null || _this$selectedObject$ === void 0 ? void 0 : _this$selectedObject$.componentType) === 'gateway') {
1495
+ console.log('🔧 Gateway detected - converting from declared to computed');
1496
+ this.handleGatewayRemoval();
1497
+ }
1498
+ }
1499
+
1500
+ /**
1501
+ * Handle gateway removal by converting from declared to computed
1502
+ */
1503
+ }, {
1504
+ key: "handleGatewayRemoval",
1505
+ value: function handleGatewayRemoval() {
1506
+ var _gateway$userData;
1507
+ var gateway = this.selectedObject;
1508
+
1509
+ // Store gateway information before removal
1510
+ var gatewayInfo = {
1511
+ uuid: gateway.uuid,
1512
+ userData: _rollupPluginBabelHelpers.objectSpread2({}, gateway.userData),
1513
+ position: gateway.position.clone(),
1514
+ connections: ((_gateway$userData = gateway.userData) === null || _gateway$userData === void 0 ? void 0 : _gateway$userData.connections) || null
1515
+ };
1516
+ console.log('🔧 Converting gateway from declared to computed:', gatewayInfo);
1517
+
1518
+ // Change origin from 'declared' to 'computed'
1519
+ gateway.userData.origin = 'computed';
1520
+
1521
+ // Deselect the object
1522
+ this.deselectObject();
1523
+
1524
+ // Emit the object removed event
1525
+ if (this.callbacks.onObjectRemoved) {
1526
+ this.callbacks.onObjectRemoved(gatewayInfo);
1527
+ }
1528
+ }
1529
+
1530
+ /**
1531
+ * Cleanup and dispose of the transform controls
1532
+ */
1533
+ }, {
1534
+ key: "dispose",
1535
+ value: function dispose() {
1536
+ // Remove event listeners
1537
+ if (this.eventHandlers.keydown) {
1538
+ window.removeEventListener('keydown', this.eventHandlers.keydown);
1539
+ }
1540
+ if (this.eventHandlers.click) {
1541
+ this.renderer.domElement.removeEventListener('click', this.eventHandlers.click);
1542
+ }
1543
+
1544
+ // Remove bounding box helper
1545
+ this.removeBoundingBox();
1546
+
1547
+ // Deselect any object first
1548
+ if (this.selectedObject) {
1549
+ this.deselectObject();
1550
+ }
1551
+
1552
+ // Dispose transform controls
1553
+ if (this.transformControls) {
1554
+ // Remove event listeners from transform controls
1555
+ if (this.eventHandlers.transformStart) {
1556
+ this.transformControls.removeEventListener('mouseDown', this.eventHandlers.transformStart);
1557
+ }
1558
+ if (this.eventHandlers.transformEnd) {
1559
+ this.transformControls.removeEventListener('mouseUp', this.eventHandlers.transformEnd);
1560
+ }
1561
+ if (this.eventHandlers.transforming) {
1562
+ this.transformControls.removeEventListener('objectChange', this.eventHandlers.transforming);
1563
+ }
1564
+
1565
+ // Detach from any objects
1566
+ this.transformControls.detach();
1567
+
1568
+ // Remove from scene if still attached
1569
+ if (this.scene && this.transformControls.parent === this.scene) {
1570
+ this.scene.remove(this.transformControls);
1571
+ }
1572
+
1573
+ // Dispose and null the reference
1574
+ this.transformControls.dispose();
1575
+ this.transformControls = null;
1576
+ }
1577
+
1578
+ // Clear references - but keep scene, camera, and renderer references for reuse
1579
+ this.selectedObject = null;
1580
+ // Don't null these out: this.scene, this.camera, this.renderer
1581
+ this.orbitControls = null;
1582
+ console.log('🧹 Transform controls disposed');
1583
+ }
1584
+ /**
1585
+ * Force hide the transform controls (debugging method)
1586
+ */
1587
+ }, {
1588
+ key: "forceHide",
1589
+ value: function forceHide() {
1590
+ if (this.transformControls) {
1591
+ this._hideTransformControls();
1592
+ this.transformControls.enabled = false;
1593
+ console.log('🔒 Transform controls force hidden');
1594
+ }
1595
+ }
1596
+
1597
+ /**
1598
+ * Properly hide transform controls including all child components
1599
+ * @private
1600
+ */
1601
+ }, {
1602
+ key: "_hideTransformControls",
1603
+ value: function _hideTransformControls() {
1604
+ if (!this.transformControls) return;
1605
+
1606
+ // Hide main transform controls
1607
+ this.transformControls.visible = false;
1608
+
1609
+ // Also hide gizmo and plane components explicitly
1610
+ if (this.transformControls._gizmo) {
1611
+ this.transformControls._gizmo.visible = false;
1612
+ }
1613
+ if (this.transformControls._plane) {
1614
+ this.transformControls._plane.visible = false;
1615
+ }
1616
+ }
1617
+
1618
+ /**
1619
+ * Properly show transform controls including all child components
1620
+ * @private
1621
+ */
1622
+ }, {
1623
+ key: "_showTransformControls",
1624
+ value: function _showTransformControls() {
1625
+ if (!this.transformControls) return;
1626
+
1627
+ // Show main transform controls
1628
+ this.transformControls.visible = true;
1629
+
1630
+ // Also show gizmo and plane components explicitly
1631
+ if (this.transformControls._gizmo) {
1632
+ this.transformControls._gizmo.visible = true;
1633
+ }
1634
+ if (this.transformControls._plane) {
1635
+ this.transformControls._plane.visible = true;
1636
+ }
1637
+ }
1638
+
1639
+ /**
1640
+ * Check the current visibility state of transform controls (debugging method)
1641
+ */
1642
+ }, {
1643
+ key: "getVisibilityState",
1644
+ value: function getVisibilityState() {
1645
+ var _this$selectedObject3;
1646
+ if (!this.transformControls) {
1647
+ return {
1648
+ exists: false
1649
+ };
1650
+ }
1651
+ return {
1652
+ exists: true,
1653
+ visible: this.transformControls.visible,
1654
+ enabled: this.transformControls.enabled,
1655
+ gizmoVisible: this.transformControls._gizmo ? this.transformControls._gizmo.visible : 'N/A',
1656
+ planeVisible: this.transformControls._plane ? this.transformControls._plane.visible : 'N/A',
1657
+ hasSelectedObject: !!this.selectedObject,
1658
+ selectedObjectName: ((_this$selectedObject3 = this.selectedObject) === null || _this$selectedObject3 === void 0 ? void 0 : _this$selectedObject3.name) || 'none'
1659
+ };
1660
+ }
1661
+ /**
1662
+ * Force hide all gizmo components to prevent any visibility override
1663
+ * This is necessary because Three.js TransformControls has internal logic that can show gizmos
1664
+ */
1665
+ }, {
1666
+ key: "_forceHideAllGizmoComponents",
1667
+ value: function _forceHideAllGizmoComponents() {
1668
+ if (!this.transformControls || !this.transformControls._gizmo) {
1669
+ return;
1670
+ }
1671
+ var gizmo = this.transformControls._gizmo;
1672
+
1673
+ // Hide main gizmo
1674
+ gizmo.visible = false;
1675
+
1676
+ // Hide all mode-specific gizmos
1677
+ if (gizmo.gizmo) {
1678
+ Object.keys(gizmo.gizmo).forEach(function (mode) {
1679
+ if (gizmo.gizmo[mode]) {
1680
+ gizmo.gizmo[mode].visible = false;
1681
+ }
1682
+ });
1683
+ }
1684
+
1685
+ // Hide all helpers
1686
+ if (gizmo.helper) {
1687
+ Object.keys(gizmo.helper).forEach(function (mode) {
1688
+ if (gizmo.helper[mode]) {
1689
+ gizmo.helper[mode].visible = false;
1690
+ }
1691
+ });
1692
+ }
1693
+
1694
+ // Also hide the plane
1695
+ if (this.transformControls._plane) {
1696
+ this.transformControls._plane.visible = false;
1697
+ }
1698
+ console.log('🔒 All gizmo components force hidden');
1699
+ }
1700
+
1701
+ /**
1702
+ * Hide multi-axis plane helpers (XY, YZ, XZ) to only allow single-axis translation
1703
+ * @private
1704
+ */
1705
+ }, {
1706
+ key: "_hidePlaneHelpers",
1707
+ value: function _hidePlaneHelpers() {
1708
+ console.log('🔧 _hidePlaneHelpers called');
1709
+ if (!this.transformControls) {
1710
+ console.warn('⚠️ Cannot hide plane helpers: transform controls not available');
1711
+ return;
1712
+ }
1713
+ if (!this.transformControls._gizmo) {
1714
+ console.warn('⚠️ Cannot hide plane helpers: gizmo not available');
1715
+ return;
1716
+ }
1717
+ var gizmo = this.transformControls._gizmo;
1718
+ console.log('🔍 Gizmo structure:', {
1719
+ hasGizmo: !!gizmo.gizmo,
1720
+ hasTranslate: !!(gizmo.gizmo && gizmo.gizmo.translate),
1721
+ hasPicker: !!gizmo.picker,
1722
+ hasTranslatePicker: !!(gizmo.picker && gizmo.picker.translate)
1723
+ });
1724
+ var hiddenCount = 0;
1725
+
1726
+ // Hide plane helpers in translate gizmo
1727
+ if (gizmo.gizmo && gizmo.gizmo.translate) {
1728
+ var translateGizmo = gizmo.gizmo.translate;
1729
+ console.log('🔍 Translate gizmo children count:', translateGizmo.children.length);
1730
+ translateGizmo.traverse(function (child) {
1731
+ if (child.name === 'XY' || child.name === 'YZ' || child.name === 'XZ') {
1732
+ child.visible = false;
1733
+ hiddenCount++;
1734
+ console.log("\uD83D\uDD12 Hidden plane helper: ".concat(child.name));
1735
+ }
1736
+ });
1737
+ }
1738
+
1739
+ // Hide plane helpers in translate picker
1740
+ if (gizmo.picker && gizmo.picker.translate) {
1741
+ var translatePicker = gizmo.picker.translate;
1742
+ console.log('🔍 Translate picker children count:', translatePicker.children.length);
1743
+ translatePicker.traverse(function (child) {
1744
+ if (child.name === 'XY' || child.name === 'YZ' || child.name === 'XZ') {
1745
+ child.visible = false;
1746
+ hiddenCount++;
1747
+ console.log("\uD83D\uDD12 Hidden plane picker: ".concat(child.name));
1748
+ }
1749
+ });
1750
+ }
1751
+ console.log("\u2705 Multi-axis plane helpers hidden - total hidden: ".concat(hiddenCount));
1752
+ }
1753
+
1754
+ /**
1755
+ * Show multi-axis plane helpers (XY, YZ, XZ) to allow multi-axis translation
1756
+ * @private
1757
+ */
1758
+ }, {
1759
+ key: "_showPlaneHelpers",
1760
+ value: function _showPlaneHelpers() {
1761
+ if (!this.transformControls || !this.transformControls._gizmo) {
1762
+ console.warn('⚠️ Cannot show plane helpers: transform controls or gizmo not available');
1763
+ return;
1764
+ }
1765
+ var gizmo = this.transformControls._gizmo;
1766
+
1767
+ // Show plane helpers in translate gizmo
1768
+ if (gizmo.gizmo && gizmo.gizmo.translate) {
1769
+ var translateGizmo = gizmo.gizmo.translate;
1770
+ translateGizmo.traverse(function (child) {
1771
+ if (child.name === 'XY' || child.name === 'YZ' || child.name === 'XZ') {
1772
+ child.visible = true;
1773
+ console.log("\uD83D\uDC41\uFE0F Shown plane helper: ".concat(child.name));
1774
+ }
1775
+ });
1776
+ }
1777
+
1778
+ // Show plane helpers in translate picker
1779
+ if (gizmo.picker && gizmo.picker.translate) {
1780
+ var translatePicker = gizmo.picker.translate;
1781
+ translatePicker.traverse(function (child) {
1782
+ if (child.name === 'XY' || child.name === 'YZ' || child.name === 'XZ') {
1783
+ child.visible = true;
1784
+ console.log("\uD83D\uDC41\uFE0F Shown plane picker: ".concat(child.name));
1785
+ }
1786
+ });
1787
+ }
1788
+ console.log('✅ Multi-axis plane helpers shown - multi-axis translation enabled');
1789
+ }
1790
+ }]);
1791
+ }();
1792
+
1793
+ /**
1794
+ * Utility function to create a transform controls manager
1795
+ * @param {THREE.Scene} scene - The Three.js scene
1796
+ * @param {THREE.Camera} camera - The camera
1797
+ * @param {THREE.WebGLRenderer} renderer - The renderer
1798
+ * @param {OrbitControls} orbitControls - Optional orbit controls to disable during transformation
1799
+ * @returns {TransformControlsManager} Transform controls manager instance
1800
+ */
1801
+ function createTransformControls(scene, camera, renderer) {
1802
+ var orbitControls = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1803
+ return new TransformControlsManager(scene, camera, renderer, orbitControls);
1804
+ }
1805
+
1806
+ exports.TransformControlsManager = TransformControlsManager;
1807
+ exports.createTransformControls = createTransformControls;