@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.
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
- package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
- package/dist/cjs/src/analysis/analysis.js +560 -1
- package/dist/cjs/src/analysis/testing.js +958 -1
- package/dist/cjs/src/core/centralPlant.js +1149 -1
- package/dist/cjs/src/core/debugLogger.js +175 -1
- package/dist/cjs/src/core/mathUtils.js +574 -1
- package/dist/cjs/src/core/nameUtils.js +93 -1
- package/dist/cjs/src/data/export.js +716 -1
- package/dist/cjs/src/data/import.js +380 -1
- package/dist/cjs/src/data/numerics.js +522 -1
- package/dist/cjs/src/helpers/sceneHelper.js +572 -1
- package/dist/cjs/src/index.js +69 -1
- package/dist/cjs/src/managers/components/animationManager.js +123 -1
- package/dist/cjs/src/managers/components/componentManager.js +332 -1
- package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
- package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
- package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
- package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
- package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
- package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
- package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
- package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
- package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
- package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
- package/dist/cjs/src/managers/system/disposalManager.js +444 -1
- package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
- package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
- package/dist/cjs/src/rendering/modelPreloader.js +369 -1
- package/dist/cjs/src/rendering/rendering2D.js +631 -1
- package/dist/cjs/src/rendering/rendering3D.js +685 -1
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
- package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
- package/dist/esm/src/analysis/analysis.js +536 -1
- package/dist/esm/src/analysis/testing.js +954 -1
- package/dist/esm/src/core/centralPlant.js +1144 -1
- package/dist/esm/src/core/debugLogger.js +167 -1
- package/dist/esm/src/core/mathUtils.js +570 -1
- package/dist/esm/src/core/nameUtils.js +87 -1
- package/dist/esm/src/data/export.js +712 -1
- package/dist/esm/src/data/import.js +356 -1
- package/dist/esm/src/data/numerics.js +518 -1
- package/dist/esm/src/helpers/sceneHelper.js +547 -1
- package/dist/esm/src/index.js +35 -1
- package/dist/esm/src/managers/components/animationManager.js +119 -1
- package/dist/esm/src/managers/components/componentManager.js +328 -1
- package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
- package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
- package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
- package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
- package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
- package/dist/esm/src/managers/environment/environmentManager.js +690 -1
- package/dist/esm/src/managers/environment/textureConfig.js +202 -1
- package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
- package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
- package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
- package/dist/esm/src/managers/system/disposalManager.js +440 -1
- package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
- package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
- package/dist/esm/src/rendering/modelPreloader.js +364 -1
- package/dist/esm/src/rendering/rendering2D.js +627 -1
- package/dist/esm/src/rendering/rendering3D.js +661 -1
- package/package.json +1 -1
|
@@ -1 +1,1002 @@
|
|
|
1
|
-
import{createClass as t,classCallCheck as e,asyncToGenerator as i,regenerator as r}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as n from"three";var s=function(){return t(function t(i){e(this,t),this.scene=i.scene,this.camera=i.camera,this.transformManager=i.transformManager,this.modelPreloader=i.modelPreloader,this.componentManager=i.componentManager,this.currentDragComponentData=null,this.dragPreviewSize=null,this.isCreatingDragPreview=!1,this.dragPreviewMesh=null,this.dragPreviewBoundingBox=null,this.dragTargetPosition=null,this.isDragOverScene=!1,this.onComponentDragStart=this.onComponentDragStart.bind(this),this.onComponentDragEnd=this.onComponentDragEnd.bind(this),this.onDragEnter=this.onDragEnter.bind(this),this.onDragLeave=this.onDragLeave.bind(this),this.onDragOver=this.onDragOver.bind(this),this.onDrop=this.onDrop.bind(this)},[{key:"onComponentDragStart",value:(f=i(r().m(function t(e,i){return r().w(function(t){for(;;)switch(t.n){case 0:return this.currentDragComponentData=e,t.n=1,this.calculateDragPreviewSize(e);case 1:return t.a(2,!0)}},t,this)})),function(t,e){return f.apply(this,arguments)})},{key:"onComponentDragEnd",value:function(){return this.currentDragComponentData=null,this.dragPreviewSize=null,this.isCreatingDragPreview=!1,this.clearDragPreview(),this.cleanupDragPreview(),this.dragTargetPosition=null,this.isDragOverScene=!1,!0}},{key:"onDragEnter",value:(l=i(r().m(function t(e,i){var n;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.preventDefault(),this.isDragOverScene=!0,!this.currentDragComponentData)try{(n=e.dataTransfer.getData("application/json"))&&(this.currentDragComponentData=JSON.parse(n))}catch(t){}if(this.dragPreviewSize||!this.currentDragComponentData){t.n=1;break}return t.n=1,this.calculateDragPreviewSize(this.currentDragComponentData);case 1:if(this.dragPreviewMesh||!this.currentDragComponentData||this.isCreatingDragPreview){t.n=4;break}return this.isCreatingDragPreview=!0,t.p=2,t.n=3,this.createDragPreview();case 3:return t.p=3,this.isCreatingDragPreview=!1,t.f(3);case 4:case 5:return t.a(2)}},t,this,[[2,,3,4]])})),function(t,e){return l.apply(this,arguments)})},{key:"onDragLeave",value:function(t,e){e.contains(t.relatedTarget)||(this.isDragOverScene=!1,this.clearDragPreview())}},{key:"onDragOver",value:(c=i(r().m(function t(e,i){var n,s,a,h;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.preventDefault(),e.dataTransfer.dropEffect="copy",this.currentDragComponentData){t.n=4;break}if(t.p=1,!(n=e.dataTransfer.getData("application/json"))){t.n=2;break}if(this.currentDragComponentData=JSON.parse(n),this.dragPreviewSize){t.n=2;break}return t.n=2,this.calculateDragPreviewSize(this.currentDragComponentData);case 2:t.n=4;break;case 3:t.p=3,t.v;case 4:if(!(s=this.calculateDropPosition(e,i))){t.n=6;break}return this.dragTargetPosition=s,t.n=5,this.updateDragPreview(s);case 5:this.dragPreviewMesh&&this.dragPreviewMesh.userData.isFallback&&(a=this.checkBoundingBoxOverlap(),h=a?16711680:65280,this.dragPreviewMesh.material.color.set(h));case 6:return t.a(2)}},t,this,[[1,3]])})),function(t,e){return c.apply(this,arguments)})},{key:"onDrop",value:(o=i(r().m(function t(e,i){var n,s,a,h,u,o,c=arguments;return r().w(function(t){for(;;)switch(t.n){case 0:if(n=c.length>2&&void 0!==c[2]?c[2]:{},e.preventDefault(),this.isDragOverScene=!1,t.p=1,s=e.dataTransfer.getData("application/json")){t.n=2;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"invalid-data",message:"No component data found in drop event"}),t.a(2,!1);case 2:t.p=2,a=JSON.parse(s),t.n=4;break;case 3:return t.p=3,t.v,n.onPlacementCanceled&&n.onPlacementCanceled({reason:"parse-error",message:"Could not parse component data"}),t.a(2,!1);case 4:if(a&&a.libraryId&&a.modelKey){t.n=5;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"invalid-data",message:"Component data missing required fields"}),t.a(2,!1);case 5:if(h=this.calculateDropPosition(e,i)){t.n=6;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"position-error",message:"Could not calculate drop position",componentData:a}),t.a(2,!1);case 6:if(a.position={x:h.x,y:h.y,z:h.z},u=this.checkBoundingBoxOverlap(),o=!1,!u){t.n=7;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"overlap",componentData:a}),t.a(2,!1);case 7:if(!n.onAddComponent){t.n=9;break}return t.n=8,n.onAddComponent(a);case 8:o=t.v,t.n=11;break;case 9:if(!this.componentManager){t.n=11;break}return t.n=10,this.componentManager.addComponentToScene(a);case 10:o=t.v;case 11:return o&&n.onComponentAdded&&n.onComponentAdded({componentData:a,position:h}),t.a(2,o);case 12:return t.p=12,t.v,t.a(2,!1);case 13:return t.p=13,this.clearDragPreview(),this.cleanupDragPreview(),this.currentDragComponentData=null,this.dragPreviewSize=null,this.dragTargetPosition=null,this.isDragOverScene=!1,t.f(13);case 14:return t.a(2)}},t,this,[[2,3],[1,12,13,14]])})),function(t,e){return o.apply(this,arguments)})},{key:"calculateDropPosition",value:function(t,e){if(!this.camera||!e)return null;try{var i,r=e.getBoundingClientRect(),s=(t.clientX-r.left)/r.width*2-1,a=-(t.clientY-r.top)/r.height*2+1,h=new n.Raycaster;h.setFromCamera({x:s,y:a},this.camera);var u=1/((null===(i=this.transformManager)||void 0===i||null===(i=i.snapValues)||void 0===i?void 0:i.translation)||.5),o=null;if(this.scene.traverse(function(t){var e;t.isMesh&&null!==(e=t.userData)&&void 0!==e&&e.isBaseGround&&(o=t)}),o){var c=h.intersectObject(o,!1);if(c.length>0){var l=c[0];return{x:Math.round(l.point.x*u)/u,y:Math.max(0,l.point.y),z:Math.round(l.point.z*u)/u}}}var f=new n.Plane(new n.Vector3(0,1,0),0),v=new n.Vector3;return h.ray.intersectPlane(f,v)&&v?{x:Math.round(v.x*u)/u,y:0,z:Math.round(v.z*u)/u}:{x:0,y:0,z:0}}catch(t){}return null}},{key:"calculateDragPreviewSize",value:(u=i(r().m(function t(e){var i,n,s,a,h,u;return r().w(function(t){for(;;)switch(t.n){case 0:return i=1,n=1,s=1,t.p=1,t.p=2,t.n=3,this.getModelBoundingBox(e);case 3:if(!(a=t.v)){t.n=4;break}i=a.width,n=a.height,s=a.depth,t.n=5;break;case 4:throw new Error("Could not get model bounding box");case 5:t.n=7;break;case 6:t.p=6,t.v,e.dimensions?(i=e.dimensions.width||e.dimensions.x||1,n=e.dimensions.height||e.dimensions.y||1,s=e.dimensions.depth||e.dimensions.z||1):e.boundingBox?(h=e.boundingBox).max&&h.min?(i=Math.abs(h.max.x-h.min.x)||1,n=Math.abs(h.max.y-h.min.y)||1,s=Math.abs(h.max.z-h.min.z)||1):void 0!==h.width&&void 0!==h.height&&void 0!==h.depth?(i=h.width||1,n=h.height||1,s=h.depth||1):"number"==typeof h.x&&"number"==typeof h.y&&"number"==typeof h.z&&(i=h.x||1,n=h.y||1,s=h.z||1):(u=e.type||"").toLowerCase().includes("chiller")?(i=2,n=2,s=2):u.toLowerCase().includes("pump")?(i=1,n=1,s=1):u.toLowerCase().includes("tower")?(i=3,n=4,s=3):(i=1,n=1,s=1);case 7:i=Math.max(i,.5),n=Math.max(n,.5),s=Math.max(s,.5),this.dragPreviewSize={width:i,height:n,depth:s},t.n=9;break;case 8:t.p=8,t.v,this.dragPreviewSize={width:1,height:1,depth:1};case 9:return t.a(2)}},t,this,[[2,6],[1,8]])})),function(t){return u.apply(this,arguments)})},{key:"getModelBoundingBox",value:(h=i(r().m(function t(e){var i,s,a,h,u,o,c;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.libraryId){t.n=1;break}return t.a(2,null);case 1:return t.p=1,s={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return a=t.v,t.n=4,a.json();case 4:s=t.v,t.n=6;break;case 5:return t.p=5,t.v,t.a(2,null);case 6:if((h=s[e.libraryId])&&h.modelKey){t.n=7;break}return t.a(2,null);case 7:if(u=null===(i=this.modelPreloader)||void 0===i?void 0:i.getCachedModel(h.modelKey)){t.n=8;break}return t.a(2,null);case 8:return o=(new n.Box3).setFromObject(u),c=o.getSize(new n.Vector3),t.a(2,{width:c.x,height:c.y,depth:c.z});case 9:return t.p=9,t.v,t.a(2,null)}},t,this,[[2,5],[1,9]])})),function(t){return h.apply(this,arguments)})},{key:"updateDragPreview",value:(a=i(r().m(function t(e){return r().w(function(t){for(;;)switch(t.n){case 0:if(this.dragPreviewMesh||this.isCreatingDragPreview){t.n=3;break}return this.isCreatingDragPreview=!0,t.p=1,t.n=2,this.createDragPreview();case 2:return t.p=2,this.isCreatingDragPreview=!1,t.f(2);case 3:this.dragPreviewMesh&&e&&(this.dragPreviewMesh.position.set(e.x,e.y,e.z),this.dragPreviewMesh.visible=!0,this.dragPreviewBoundingBox&&(this.dragPreviewBoundingBox.position.set(e.x,e.y,e.z),this.dragPreviewBoundingBox.visible=!0));case 4:return t.a(2)}},t,this,[[1,,2,3]])})),function(t){return a.apply(this,arguments)})},{key:"createDragPreview",value:(s=i(r().m(function t(){var e,i,s,a,h,u,o,c,l;return r().w(function(t){for(;;)switch(t.n){case 0:if(this.clearDragPreview(),this.scene&&this.currentDragComponentData){t.n=1;break}return t.a(2);case 1:return t.p=1,e={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return i=t.v,t.n=4,i.json();case 4:e=t.v,t.n=6;break;case 5:t.p=5,t.v;case 6:if(s=this.currentDragComponentData.libraryId,a=e[s],h=null,a&&a.modelKey&&this.modelPreloader)try{(u=this.modelPreloader.getCachedModel(a.modelKey))&&((h=u.clone()).traverse(function(t){t.isMesh&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.opacity=.4,t.material.depthTest=!0,t.material.depthWrite=!0,t.material.needsUpdate=!0)}),h.userData.isPreview=!0)}catch(t){h=null}return h||(o=this.dragPreviewSize||{width:1,height:1,depth:1},c=new n.BoxGeometry(o.width,o.height,o.depth),l=new n.MeshBasicMaterial({color:65280,wireframe:!0,transparent:!0,opacity:.6}),(h=new n.Mesh(c,l)).userData.isFallback=!0,h.userData.isPreview=!0),this.scene.add(h),this.dragPreviewMesh=h,this.dragPreviewMesh.visible=!1,this.createBoundingBoxHelper(),t.a(2,!0);case 7:return t.p=7,t.v,t.a(2,!1)}},t,this,[[2,5],[1,7]])})),function(){return s.apply(this,arguments)})},{key:"createBoundingBoxHelper",value:function(){if(this.dragPreviewMesh){var t=(new n.Box3).setFromObject(this.dragPreviewMesh),e=t.getSize(new n.Vector3);t.getCenter(new n.Vector3);var i=new n.BoxGeometry(e.x,e.y,e.z),r=new n.LineBasicMaterial({color:16776960,transparent:!0,opacity:.3}),s=new n.EdgesGeometry(i),a=new n.LineSegments(s,r);a.position.copy(this.dragPreviewMesh.position),this.scene.add(a),this.dragPreviewBoundingBox=a,this.dragPreviewBoundingBox.visible=!1}}},{key:"checkBoundingBoxOverlap",value:function(){var t=this;if(!this.dragPreviewMesh||!this.scene)return!1;var e=(new n.Box3).setFromObject(this.dragPreviewMesh),i=[];this.scene.traverse(function(e){!e.isMesh||e===t.dragPreviewMesh||e===t.dragPreviewBoundingBox||e.userData.isBaseGround||e.userData.isBrickWall||e.userData.isBaseGrid||e.userData&&("component"===e.userData.componentType||"connector"===e.userData.componentType||"gateway"===e.userData.componentType)&&i.push(e)});for(var r=0,s=i;r<s.length;r++){var a=s[r],h=(new n.Box3).setFromObject(a);if(e.intersectsBox(h))return!0}return!1}},{key:"clearDragPreview",value:function(){this.dragPreviewMesh&&(this.dragPreviewMesh.visible=!1),this.dragPreviewBoundingBox&&(this.dragPreviewBoundingBox.visible=!1)}},{key:"cleanupDragPreview",value:function(){this.dragPreviewMesh&&(this.scene.remove(this.dragPreviewMesh),this.dragPreviewMesh.geometry&&this.dragPreviewMesh.geometry.dispose(),this.dragPreviewMesh.material&&(Array.isArray(this.dragPreviewMesh.material)?this.dragPreviewMesh.material.forEach(function(t){return t.dispose()}):this.dragPreviewMesh.material.dispose()),this.dragPreviewMesh=null),this.dragPreviewBoundingBox&&(this.scene.remove(this.dragPreviewBoundingBox),this.dragPreviewBoundingBox.geometry&&this.dragPreviewBoundingBox.geometry.dispose(),this.dragPreviewBoundingBox.material&&this.dragPreviewBoundingBox.material.dispose(),this.dragPreviewBoundingBox=null)}},{key:"dispose",value:function(){this.cleanupDragPreview(),this.currentDragComponentData=null,this.dragPreviewSize=null,this.isDragOverScene=!1,this.dragTargetPosition=null}},{key:"getDragState",value:function(){return{isDragging:!!this.currentDragComponentData,isDragOverScene:this.isDragOverScene,dragComponentData:this.currentDragComponentData,dragTargetPosition:this.dragTargetPosition}}}]);var s,a,h,u,o,c,l,f}();export{s as default};
|
|
1
|
+
import { createClass as _createClass, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DragDropManager - Manages 3D drag and drop operations for scene components
|
|
6
|
+
*/
|
|
7
|
+
var DragDropManager = /*#__PURE__*/function () {
|
|
8
|
+
function DragDropManager(params) {
|
|
9
|
+
_classCallCheck(this, DragDropManager);
|
|
10
|
+
// Store references to essential scene components
|
|
11
|
+
this.scene = params.scene;
|
|
12
|
+
this.camera = params.camera;
|
|
13
|
+
this.transformManager = params.transformManager;
|
|
14
|
+
this.modelPreloader = params.modelPreloader;
|
|
15
|
+
this.componentManager = params.componentManager;
|
|
16
|
+
|
|
17
|
+
// Internal state
|
|
18
|
+
this.currentDragComponentData = null;
|
|
19
|
+
this.dragPreviewSize = null;
|
|
20
|
+
this.isCreatingDragPreview = false;
|
|
21
|
+
this.dragPreviewMesh = null;
|
|
22
|
+
this.dragPreviewBoundingBox = null;
|
|
23
|
+
this.dragTargetPosition = null;
|
|
24
|
+
this.isDragOverScene = false;
|
|
25
|
+
|
|
26
|
+
// Bind methods to preserve context
|
|
27
|
+
this.onComponentDragStart = this.onComponentDragStart.bind(this);
|
|
28
|
+
this.onComponentDragEnd = this.onComponentDragEnd.bind(this);
|
|
29
|
+
this.onDragEnter = this.onDragEnter.bind(this);
|
|
30
|
+
this.onDragLeave = this.onDragLeave.bind(this);
|
|
31
|
+
this.onDragOver = this.onDragOver.bind(this);
|
|
32
|
+
this.onDrop = this.onDrop.bind(this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Handle component drag start with component data
|
|
37
|
+
*/
|
|
38
|
+
return _createClass(DragDropManager, [{
|
|
39
|
+
key: "onComponentDragStart",
|
|
40
|
+
value: (function () {
|
|
41
|
+
var _onComponentDragStart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(componentData, containerRef) {
|
|
42
|
+
return _regenerator().w(function (_context) {
|
|
43
|
+
while (1) switch (_context.n) {
|
|
44
|
+
case 0:
|
|
45
|
+
console.log('🎯 Component drag started with data:', componentData);
|
|
46
|
+
this.currentDragComponentData = componentData;
|
|
47
|
+
|
|
48
|
+
// Calculate size immediately since we have the data
|
|
49
|
+
_context.n = 1;
|
|
50
|
+
return this.calculateDragPreviewSize(componentData);
|
|
51
|
+
case 1:
|
|
52
|
+
return _context.a(2, true);
|
|
53
|
+
}
|
|
54
|
+
}, _callee, this);
|
|
55
|
+
}));
|
|
56
|
+
function onComponentDragStart(_x, _x2) {
|
|
57
|
+
return _onComponentDragStart.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
return onComponentDragStart;
|
|
60
|
+
}()
|
|
61
|
+
/**
|
|
62
|
+
* Handle component drag end
|
|
63
|
+
*/
|
|
64
|
+
)
|
|
65
|
+
}, {
|
|
66
|
+
key: "onComponentDragEnd",
|
|
67
|
+
value: function onComponentDragEnd() {
|
|
68
|
+
console.log('🎯 Component drag ended');
|
|
69
|
+
// IMPORTANT: Full cleanup of all drag-related state
|
|
70
|
+
this.currentDragComponentData = null;
|
|
71
|
+
this.dragPreviewSize = null;
|
|
72
|
+
this.isCreatingDragPreview = false;
|
|
73
|
+
this.clearDragPreview();
|
|
74
|
+
this.cleanupDragPreview();
|
|
75
|
+
this.dragTargetPosition = null;
|
|
76
|
+
this.isDragOverScene = false;
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Handle drag enter event
|
|
82
|
+
*/
|
|
83
|
+
}, {
|
|
84
|
+
key: "onDragEnter",
|
|
85
|
+
value: (function () {
|
|
86
|
+
var _onDragEnter = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event, containerRef) {
|
|
87
|
+
var componentDataStr;
|
|
88
|
+
return _regenerator().w(function (_context2) {
|
|
89
|
+
while (1) switch (_context2.n) {
|
|
90
|
+
case 0:
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
this.isDragOverScene = true;
|
|
93
|
+
|
|
94
|
+
// Try to get component data from the drag event first if we don't have it
|
|
95
|
+
if (!this.currentDragComponentData) {
|
|
96
|
+
try {
|
|
97
|
+
componentDataStr = event.dataTransfer.getData('application/json');
|
|
98
|
+
if (componentDataStr) {
|
|
99
|
+
this.currentDragComponentData = JSON.parse(componentDataStr);
|
|
100
|
+
console.log('🎯 Retrieved component data from drag event:', this.currentDragComponentData);
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.warn('⚠️ Could not parse component data from drag event:', error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// If we don't have size calculated yet and we have component data, calculate it now
|
|
108
|
+
if (!(!this.dragPreviewSize && this.currentDragComponentData)) {
|
|
109
|
+
_context2.n = 1;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
_context2.n = 1;
|
|
113
|
+
return this.calculateDragPreviewSize(this.currentDragComponentData);
|
|
114
|
+
case 1:
|
|
115
|
+
if (!(!this.dragPreviewMesh && this.currentDragComponentData && !this.isCreatingDragPreview)) {
|
|
116
|
+
_context2.n = 4;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
this.isCreatingDragPreview = true;
|
|
120
|
+
_context2.p = 2;
|
|
121
|
+
_context2.n = 3;
|
|
122
|
+
return this.createDragPreview();
|
|
123
|
+
case 3:
|
|
124
|
+
_context2.p = 3;
|
|
125
|
+
this.isCreatingDragPreview = false;
|
|
126
|
+
return _context2.f(3);
|
|
127
|
+
case 4:
|
|
128
|
+
console.log('🎯 Component drag entered scene area');
|
|
129
|
+
case 5:
|
|
130
|
+
return _context2.a(2);
|
|
131
|
+
}
|
|
132
|
+
}, _callee2, this, [[2,, 3, 4]]);
|
|
133
|
+
}));
|
|
134
|
+
function onDragEnter(_x3, _x4) {
|
|
135
|
+
return _onDragEnter.apply(this, arguments);
|
|
136
|
+
}
|
|
137
|
+
return onDragEnter;
|
|
138
|
+
}()
|
|
139
|
+
/**
|
|
140
|
+
* Handle drag leave event
|
|
141
|
+
*/
|
|
142
|
+
)
|
|
143
|
+
}, {
|
|
144
|
+
key: "onDragLeave",
|
|
145
|
+
value: function onDragLeave(event, containerRef) {
|
|
146
|
+
// Only set to false if we're actually leaving the scene container
|
|
147
|
+
if (!containerRef.contains(event.relatedTarget)) {
|
|
148
|
+
this.isDragOverScene = false;
|
|
149
|
+
this.clearDragPreview();
|
|
150
|
+
console.log('🎯 Component drag left scene area');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Handle drag over event to calculate 3D position
|
|
156
|
+
*/
|
|
157
|
+
}, {
|
|
158
|
+
key: "onDragOver",
|
|
159
|
+
value: (function () {
|
|
160
|
+
var _onDragOver = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(event, containerRef) {
|
|
161
|
+
var componentDataStr, targetPosition, isOverlapping, meshColor, _t;
|
|
162
|
+
return _regenerator().w(function (_context3) {
|
|
163
|
+
while (1) switch (_context3.n) {
|
|
164
|
+
case 0:
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
167
|
+
|
|
168
|
+
// Try to get component data from the drag event if we don't have it
|
|
169
|
+
if (this.currentDragComponentData) {
|
|
170
|
+
_context3.n = 4;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
_context3.p = 1;
|
|
174
|
+
componentDataStr = event.dataTransfer.getData('application/json');
|
|
175
|
+
if (!componentDataStr) {
|
|
176
|
+
_context3.n = 2;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
this.currentDragComponentData = JSON.parse(componentDataStr);
|
|
180
|
+
console.log('🎯 Retrieved component data from drag over event:', this.currentDragComponentData);
|
|
181
|
+
|
|
182
|
+
// Calculate size now that we have the data
|
|
183
|
+
if (this.dragPreviewSize) {
|
|
184
|
+
_context3.n = 2;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
_context3.n = 2;
|
|
188
|
+
return this.calculateDragPreviewSize(this.currentDragComponentData);
|
|
189
|
+
case 2:
|
|
190
|
+
_context3.n = 4;
|
|
191
|
+
break;
|
|
192
|
+
case 3:
|
|
193
|
+
_context3.p = 3;
|
|
194
|
+
_t = _context3.v;
|
|
195
|
+
console.warn('⚠️ Could not parse component data from drag over event:', _t);
|
|
196
|
+
case 4:
|
|
197
|
+
// Calculate 3D world position from mouse coordinates
|
|
198
|
+
targetPosition = this.calculateDropPosition(event, containerRef);
|
|
199
|
+
if (!targetPosition) {
|
|
200
|
+
_context3.n = 6;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
this.dragTargetPosition = targetPosition;
|
|
204
|
+
_context3.n = 5;
|
|
205
|
+
return this.updateDragPreview(targetPosition);
|
|
206
|
+
case 5:
|
|
207
|
+
// Update fallback mesh color if using wireframe preview
|
|
208
|
+
if (this.dragPreviewMesh && this.dragPreviewMesh.userData.isFallback) {
|
|
209
|
+
isOverlapping = this.checkBoundingBoxOverlap();
|
|
210
|
+
meshColor = isOverlapping ? 0xff0000 : 0x00ff00; // Red if overlapping, green otherwise
|
|
211
|
+
this.dragPreviewMesh.material.color.set(meshColor);
|
|
212
|
+
}
|
|
213
|
+
case 6:
|
|
214
|
+
return _context3.a(2);
|
|
215
|
+
}
|
|
216
|
+
}, _callee3, this, [[1, 3]]);
|
|
217
|
+
}));
|
|
218
|
+
function onDragOver(_x5, _x6) {
|
|
219
|
+
return _onDragOver.apply(this, arguments);
|
|
220
|
+
}
|
|
221
|
+
return onDragOver;
|
|
222
|
+
}()
|
|
223
|
+
/**
|
|
224
|
+
* Handle drop event to add component to scene
|
|
225
|
+
*/
|
|
226
|
+
)
|
|
227
|
+
}, {
|
|
228
|
+
key: "onDrop",
|
|
229
|
+
value: (function () {
|
|
230
|
+
var _onDrop = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(event, containerRef) {
|
|
231
|
+
var callbacks,
|
|
232
|
+
componentDataStr,
|
|
233
|
+
componentData,
|
|
234
|
+
dropPosition,
|
|
235
|
+
isOverlapping,
|
|
236
|
+
success,
|
|
237
|
+
_args4 = arguments,
|
|
238
|
+
_t2,
|
|
239
|
+
_t3;
|
|
240
|
+
return _regenerator().w(function (_context4) {
|
|
241
|
+
while (1) switch (_context4.n) {
|
|
242
|
+
case 0:
|
|
243
|
+
callbacks = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
this.isDragOverScene = false;
|
|
246
|
+
_context4.p = 1;
|
|
247
|
+
// IMPORTANT: Always get fresh component data from the event
|
|
248
|
+
// Don't rely on this.currentDragComponentData which might be stale
|
|
249
|
+
componentDataStr = event.dataTransfer.getData('application/json');
|
|
250
|
+
if (componentDataStr) {
|
|
251
|
+
_context4.n = 2;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
console.warn('⚠️ No component data found in drop event');
|
|
255
|
+
// Notify parent about the error
|
|
256
|
+
if (callbacks.onPlacementCanceled) {
|
|
257
|
+
callbacks.onPlacementCanceled({
|
|
258
|
+
reason: 'invalid-data',
|
|
259
|
+
message: 'No component data found in drop event'
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return _context4.a(2, false);
|
|
263
|
+
case 2:
|
|
264
|
+
_context4.p = 2;
|
|
265
|
+
componentData = JSON.parse(componentDataStr);
|
|
266
|
+
console.log('🎯 Component dropped:', componentData);
|
|
267
|
+
_context4.n = 4;
|
|
268
|
+
break;
|
|
269
|
+
case 3:
|
|
270
|
+
_context4.p = 3;
|
|
271
|
+
_t2 = _context4.v;
|
|
272
|
+
console.error('❌ Error parsing component data:', _t2);
|
|
273
|
+
// Notify parent about the error
|
|
274
|
+
if (callbacks.onPlacementCanceled) {
|
|
275
|
+
callbacks.onPlacementCanceled({
|
|
276
|
+
reason: 'parse-error',
|
|
277
|
+
message: 'Could not parse component data'
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return _context4.a(2, false);
|
|
281
|
+
case 4:
|
|
282
|
+
if (!(!componentData || !componentData.libraryId || !componentData.modelKey)) {
|
|
283
|
+
_context4.n = 5;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
console.error('❌ Invalid component data, missing required fields');
|
|
287
|
+
// Notify parent about the error
|
|
288
|
+
if (callbacks.onPlacementCanceled) {
|
|
289
|
+
callbacks.onPlacementCanceled({
|
|
290
|
+
reason: 'invalid-data',
|
|
291
|
+
message: 'Component data missing required fields'
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return _context4.a(2, false);
|
|
295
|
+
case 5:
|
|
296
|
+
// Calculate 3D world position
|
|
297
|
+
dropPosition = this.calculateDropPosition(event, containerRef); // We always get a valid position now due to the improved calculateDropPosition method,
|
|
298
|
+
// but let's still check for safety
|
|
299
|
+
if (dropPosition) {
|
|
300
|
+
_context4.n = 6;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
console.warn('⚠️ Could not calculate drop position');
|
|
304
|
+
if (callbacks.onPlacementCanceled) {
|
|
305
|
+
callbacks.onPlacementCanceled({
|
|
306
|
+
reason: 'position-error',
|
|
307
|
+
message: 'Could not calculate drop position',
|
|
308
|
+
componentData: componentData
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return _context4.a(2, false);
|
|
312
|
+
case 6:
|
|
313
|
+
// Update component position
|
|
314
|
+
componentData.position = {
|
|
315
|
+
x: dropPosition.x,
|
|
316
|
+
y: dropPosition.y,
|
|
317
|
+
z: dropPosition.z
|
|
318
|
+
};
|
|
319
|
+
console.log('🎯 Dropping component at position:', dropPosition);
|
|
320
|
+
|
|
321
|
+
// Check for component overlap before adding
|
|
322
|
+
isOverlapping = this.checkBoundingBoxOverlap(); // Only add component to scene if not overlapping
|
|
323
|
+
success = false;
|
|
324
|
+
if (!isOverlapping) {
|
|
325
|
+
_context4.n = 7;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
console.warn('⚠️ Canceling component placement due to overlap');
|
|
329
|
+
// Emit an event to inform the user
|
|
330
|
+
if (callbacks.onPlacementCanceled) {
|
|
331
|
+
callbacks.onPlacementCanceled({
|
|
332
|
+
reason: 'overlap',
|
|
333
|
+
componentData: componentData
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
return _context4.a(2, false);
|
|
337
|
+
case 7:
|
|
338
|
+
if (!callbacks.onAddComponent) {
|
|
339
|
+
_context4.n = 9;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
_context4.n = 8;
|
|
343
|
+
return callbacks.onAddComponent(componentData);
|
|
344
|
+
case 8:
|
|
345
|
+
success = _context4.v;
|
|
346
|
+
_context4.n = 11;
|
|
347
|
+
break;
|
|
348
|
+
case 9:
|
|
349
|
+
if (!this.componentManager) {
|
|
350
|
+
_context4.n = 11;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
_context4.n = 10;
|
|
354
|
+
return this.componentManager.addComponentToScene(componentData);
|
|
355
|
+
case 10:
|
|
356
|
+
success = _context4.v;
|
|
357
|
+
case 11:
|
|
358
|
+
if (success) {
|
|
359
|
+
console.log('✅ Component successfully added to scene via drag & drop');
|
|
360
|
+
// Pass properly structured data with position and componentData properties
|
|
361
|
+
if (callbacks.onComponentAdded) {
|
|
362
|
+
callbacks.onComponentAdded({
|
|
363
|
+
componentData: componentData,
|
|
364
|
+
position: dropPosition
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
console.error('❌ Failed to add component to scene via drag & drop');
|
|
369
|
+
}
|
|
370
|
+
return _context4.a(2, success);
|
|
371
|
+
case 12:
|
|
372
|
+
_context4.p = 12;
|
|
373
|
+
_t3 = _context4.v;
|
|
374
|
+
console.error('❌ Error handling component drop:', _t3);
|
|
375
|
+
return _context4.a(2, false);
|
|
376
|
+
case 13:
|
|
377
|
+
_context4.p = 13;
|
|
378
|
+
// IMPORTANT: Explicitly reset all drag-related state to prevent reuse
|
|
379
|
+
this.clearDragPreview();
|
|
380
|
+
this.cleanupDragPreview();
|
|
381
|
+
this.currentDragComponentData = null;
|
|
382
|
+
this.dragPreviewSize = null;
|
|
383
|
+
this.dragTargetPosition = null;
|
|
384
|
+
this.isDragOverScene = false;
|
|
385
|
+
return _context4.f(13);
|
|
386
|
+
case 14:
|
|
387
|
+
return _context4.a(2);
|
|
388
|
+
}
|
|
389
|
+
}, _callee4, this, [[2, 3], [1, 12, 13, 14]]);
|
|
390
|
+
}));
|
|
391
|
+
function onDrop(_x7, _x8) {
|
|
392
|
+
return _onDrop.apply(this, arguments);
|
|
393
|
+
}
|
|
394
|
+
return onDrop;
|
|
395
|
+
}()
|
|
396
|
+
/**
|
|
397
|
+
* Calculate 3D world position from mouse coordinates
|
|
398
|
+
*/
|
|
399
|
+
)
|
|
400
|
+
}, {
|
|
401
|
+
key: "calculateDropPosition",
|
|
402
|
+
value: function calculateDropPosition(event, containerRef) {
|
|
403
|
+
console.log("calculateDropPosition started");
|
|
404
|
+
if (!this.camera || !containerRef) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
var _this$transformManage;
|
|
409
|
+
// Get mouse position relative to the scene container
|
|
410
|
+
var rect = containerRef.getBoundingClientRect();
|
|
411
|
+
var mouseX = (event.clientX - rect.left) / rect.width * 2 - 1;
|
|
412
|
+
var mouseY = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
413
|
+
|
|
414
|
+
// Create raycaster
|
|
415
|
+
var raycaster = new THREE.Raycaster();
|
|
416
|
+
raycaster.setFromCamera({
|
|
417
|
+
x: mouseX,
|
|
418
|
+
y: mouseY
|
|
419
|
+
}, this.camera);
|
|
420
|
+
|
|
421
|
+
// Get the translation snap value from transform manager, default to 0.5 if not available
|
|
422
|
+
var snapGrid = ((_this$transformManage = this.transformManager) === null || _this$transformManage === void 0 || (_this$transformManage = _this$transformManage.snapValues) === null || _this$transformManage === void 0 ? void 0 : _this$transformManage.translation) || 0.5;
|
|
423
|
+
var snapFactor = 1 / snapGrid;
|
|
424
|
+
|
|
425
|
+
// Find only the ground mesh for intersection
|
|
426
|
+
var groundMesh = null;
|
|
427
|
+
this.scene.traverse(function (child) {
|
|
428
|
+
var _child$userData;
|
|
429
|
+
if (child.isMesh && (_child$userData = child.userData) !== null && _child$userData !== void 0 && _child$userData.isBaseGround) {
|
|
430
|
+
groundMesh = child;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
if (groundMesh) {
|
|
434
|
+
// Intersect only with the ground mesh
|
|
435
|
+
var intersections = raycaster.intersectObject(groundMesh, false);
|
|
436
|
+
if (intersections.length > 0) {
|
|
437
|
+
var intersection = intersections[0];
|
|
438
|
+
return {
|
|
439
|
+
x: Math.round(intersection.point.x * snapFactor) / snapFactor,
|
|
440
|
+
// Snap to grid
|
|
441
|
+
y: Math.max(0, intersection.point.y),
|
|
442
|
+
// Ensure above ground
|
|
443
|
+
z: Math.round(intersection.point.z * snapFactor) / snapFactor // Snap to grid
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// If no ground mesh found or no intersection, project onto a plane at Y=0 (ground level) as fallback
|
|
449
|
+
var groundPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
|
|
450
|
+
var intersectionPoint = new THREE.Vector3();
|
|
451
|
+
var didIntersect = raycaster.ray.intersectPlane(groundPlane, intersectionPoint);
|
|
452
|
+
if (didIntersect && intersectionPoint) {
|
|
453
|
+
return {
|
|
454
|
+
x: Math.round(intersectionPoint.x * snapFactor) / snapFactor,
|
|
455
|
+
// Snap to grid
|
|
456
|
+
y: 0,
|
|
457
|
+
// Ground level
|
|
458
|
+
z: Math.round(intersectionPoint.z * snapFactor) / snapFactor // Snap to grid
|
|
459
|
+
};
|
|
460
|
+
} else {
|
|
461
|
+
// Provide a reasonable default position if we can't determine one
|
|
462
|
+
console.log('⚠️ Could not determine intersection, using default position');
|
|
463
|
+
return {
|
|
464
|
+
x: 0,
|
|
465
|
+
y: 0,
|
|
466
|
+
z: 0
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
} catch (error) {
|
|
470
|
+
console.error('❌ Error calculating drop position:', error);
|
|
471
|
+
}
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Calculate drag preview size once based on component data
|
|
477
|
+
*/
|
|
478
|
+
}, {
|
|
479
|
+
key: "calculateDragPreviewSize",
|
|
480
|
+
value: (function () {
|
|
481
|
+
var _calculateDragPreviewSize = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(componentData) {
|
|
482
|
+
var width, height, depth, actualSize, bbox, type, _t5;
|
|
483
|
+
return _regenerator().w(function (_context5) {
|
|
484
|
+
while (1) switch (_context5.n) {
|
|
485
|
+
case 0:
|
|
486
|
+
// Use component dimensions if available, otherwise use defaults
|
|
487
|
+
width = 1, height = 1, depth = 1;
|
|
488
|
+
_context5.p = 1;
|
|
489
|
+
console.log('🎯 Calculating preview size for:', componentData);
|
|
490
|
+
|
|
491
|
+
// First try to get accurate size from the actual model
|
|
492
|
+
_context5.p = 2;
|
|
493
|
+
_context5.n = 3;
|
|
494
|
+
return this.getModelBoundingBox(componentData);
|
|
495
|
+
case 3:
|
|
496
|
+
actualSize = _context5.v;
|
|
497
|
+
if (!actualSize) {
|
|
498
|
+
_context5.n = 4;
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
width = actualSize.width;
|
|
502
|
+
height = actualSize.height;
|
|
503
|
+
depth = actualSize.depth;
|
|
504
|
+
console.log('📐 Using actual model dimensions:', {
|
|
505
|
+
width: width,
|
|
506
|
+
height: height,
|
|
507
|
+
depth: depth
|
|
508
|
+
});
|
|
509
|
+
_context5.n = 5;
|
|
510
|
+
break;
|
|
511
|
+
case 4:
|
|
512
|
+
throw new Error('Could not get model bounding box');
|
|
513
|
+
case 5:
|
|
514
|
+
_context5.n = 7;
|
|
515
|
+
break;
|
|
516
|
+
case 6:
|
|
517
|
+
_context5.p = 6;
|
|
518
|
+
_context5.v;
|
|
519
|
+
console.log('📐 Falling back to metadata-based sizing');
|
|
520
|
+
|
|
521
|
+
// Check if component has explicit dimensions
|
|
522
|
+
if (componentData.dimensions) {
|
|
523
|
+
width = componentData.dimensions.width || componentData.dimensions.x || 1;
|
|
524
|
+
height = componentData.dimensions.height || componentData.dimensions.y || 1;
|
|
525
|
+
depth = componentData.dimensions.depth || componentData.dimensions.z || 1;
|
|
526
|
+
console.log('📐 Using explicit dimensions:', {
|
|
527
|
+
width: width,
|
|
528
|
+
height: height,
|
|
529
|
+
depth: depth
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
// Check if component has boundingBox data
|
|
533
|
+
else if (componentData.boundingBox) {
|
|
534
|
+
bbox = componentData.boundingBox;
|
|
535
|
+
console.log('📐 Using boundingBox data:', bbox);
|
|
536
|
+
if (bbox.max && bbox.min) {
|
|
537
|
+
width = Math.abs(bbox.max.x - bbox.min.x) || 1;
|
|
538
|
+
height = Math.abs(bbox.max.y - bbox.min.y) || 1;
|
|
539
|
+
depth = Math.abs(bbox.max.z - bbox.min.z) || 1;
|
|
540
|
+
} else if (bbox.width !== undefined && bbox.height !== undefined && bbox.depth !== undefined) {
|
|
541
|
+
width = bbox.width || 1;
|
|
542
|
+
height = bbox.height || 1;
|
|
543
|
+
depth = bbox.depth || 1;
|
|
544
|
+
} else if (typeof bbox.x === 'number' && typeof bbox.y === 'number' && typeof bbox.z === 'number') {
|
|
545
|
+
width = bbox.x || 1;
|
|
546
|
+
height = bbox.y || 1;
|
|
547
|
+
depth = bbox.z || 1;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
// Use default size based on component type
|
|
551
|
+
else {
|
|
552
|
+
// Default sizes based on component type
|
|
553
|
+
type = componentData.type || '';
|
|
554
|
+
if (type.toLowerCase().includes('chiller')) {
|
|
555
|
+
width = 2;
|
|
556
|
+
height = 2;
|
|
557
|
+
depth = 2;
|
|
558
|
+
} else if (type.toLowerCase().includes('pump')) {
|
|
559
|
+
width = 1;
|
|
560
|
+
height = 1;
|
|
561
|
+
depth = 1;
|
|
562
|
+
} else if (type.toLowerCase().includes('tower')) {
|
|
563
|
+
width = 3;
|
|
564
|
+
height = 4;
|
|
565
|
+
depth = 3;
|
|
566
|
+
} else {
|
|
567
|
+
width = 1;
|
|
568
|
+
height = 1;
|
|
569
|
+
depth = 1;
|
|
570
|
+
}
|
|
571
|
+
console.log('📐 Using type-based default dimensions:', {
|
|
572
|
+
width: width,
|
|
573
|
+
height: height,
|
|
574
|
+
depth: depth
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
case 7:
|
|
578
|
+
// Ensure minimum size
|
|
579
|
+
width = Math.max(width, 0.5);
|
|
580
|
+
height = Math.max(height, 0.5);
|
|
581
|
+
depth = Math.max(depth, 0.5);
|
|
582
|
+
this.dragPreviewSize = {
|
|
583
|
+
width: width,
|
|
584
|
+
height: height,
|
|
585
|
+
depth: depth
|
|
586
|
+
};
|
|
587
|
+
console.log('🎯 Final calculated drag preview size:', this.dragPreviewSize);
|
|
588
|
+
_context5.n = 9;
|
|
589
|
+
break;
|
|
590
|
+
case 8:
|
|
591
|
+
_context5.p = 8;
|
|
592
|
+
_t5 = _context5.v;
|
|
593
|
+
console.warn('⚠️ Error calculating preview size, using defaults:', _t5);
|
|
594
|
+
this.dragPreviewSize = {
|
|
595
|
+
width: 1,
|
|
596
|
+
height: 1,
|
|
597
|
+
depth: 1
|
|
598
|
+
};
|
|
599
|
+
case 9:
|
|
600
|
+
return _context5.a(2);
|
|
601
|
+
}
|
|
602
|
+
}, _callee5, this, [[2, 6], [1, 8]]);
|
|
603
|
+
}));
|
|
604
|
+
function calculateDragPreviewSize(_x9) {
|
|
605
|
+
return _calculateDragPreviewSize.apply(this, arguments);
|
|
606
|
+
}
|
|
607
|
+
return calculateDragPreviewSize;
|
|
608
|
+
}()
|
|
609
|
+
/**
|
|
610
|
+
* Get the actual bounding box of a model
|
|
611
|
+
*/
|
|
612
|
+
)
|
|
613
|
+
}, {
|
|
614
|
+
key: "getModelBoundingBox",
|
|
615
|
+
value: (function () {
|
|
616
|
+
var _getModelBoundingBox = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(componentData) {
|
|
617
|
+
var _this$modelPreloader, componentDictionary, dictResponse, libraryComponent, gltfScene, boundingBox, size, _t7;
|
|
618
|
+
return _regenerator().w(function (_context6) {
|
|
619
|
+
while (1) switch (_context6.n) {
|
|
620
|
+
case 0:
|
|
621
|
+
if (componentData.libraryId) {
|
|
622
|
+
_context6.n = 1;
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
return _context6.a(2, null);
|
|
626
|
+
case 1:
|
|
627
|
+
_context6.p = 1;
|
|
628
|
+
// Get the component dictionary for model information
|
|
629
|
+
componentDictionary = {};
|
|
630
|
+
_context6.p = 2;
|
|
631
|
+
_context6.n = 3;
|
|
632
|
+
return fetch('./library/component-dictionary.json');
|
|
633
|
+
case 3:
|
|
634
|
+
dictResponse = _context6.v;
|
|
635
|
+
_context6.n = 4;
|
|
636
|
+
return dictResponse.json();
|
|
637
|
+
case 4:
|
|
638
|
+
componentDictionary = _context6.v;
|
|
639
|
+
_context6.n = 6;
|
|
640
|
+
break;
|
|
641
|
+
case 5:
|
|
642
|
+
_context6.p = 5;
|
|
643
|
+
_context6.v;
|
|
644
|
+
console.warn('⚠️ Could not load component dictionary for size calculation');
|
|
645
|
+
return _context6.a(2, null);
|
|
646
|
+
case 6:
|
|
647
|
+
libraryComponent = componentDictionary[componentData.libraryId];
|
|
648
|
+
if (!(!libraryComponent || !libraryComponent.modelKey)) {
|
|
649
|
+
_context6.n = 7;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
return _context6.a(2, null);
|
|
653
|
+
case 7:
|
|
654
|
+
// Try to get the model from the preloader cache first
|
|
655
|
+
gltfScene = (_this$modelPreloader = this.modelPreloader) === null || _this$modelPreloader === void 0 ? void 0 : _this$modelPreloader.getCachedModel(libraryComponent.modelKey);
|
|
656
|
+
if (gltfScene) {
|
|
657
|
+
_context6.n = 8;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
console.log('📐 Model not in cache, cannot get accurate size');
|
|
661
|
+
return _context6.a(2, null);
|
|
662
|
+
case 8:
|
|
663
|
+
// Calculate the bounding box
|
|
664
|
+
boundingBox = new THREE.Box3().setFromObject(gltfScene);
|
|
665
|
+
size = boundingBox.getSize(new THREE.Vector3());
|
|
666
|
+
return _context6.a(2, {
|
|
667
|
+
width: size.x,
|
|
668
|
+
height: size.y,
|
|
669
|
+
depth: size.z
|
|
670
|
+
});
|
|
671
|
+
case 9:
|
|
672
|
+
_context6.p = 9;
|
|
673
|
+
_t7 = _context6.v;
|
|
674
|
+
console.warn('⚠️ Error getting model bounding box:', _t7);
|
|
675
|
+
return _context6.a(2, null);
|
|
676
|
+
}
|
|
677
|
+
}, _callee6, this, [[2, 5], [1, 9]]);
|
|
678
|
+
}));
|
|
679
|
+
function getModelBoundingBox(_x0) {
|
|
680
|
+
return _getModelBoundingBox.apply(this, arguments);
|
|
681
|
+
}
|
|
682
|
+
return getModelBoundingBox;
|
|
683
|
+
}()
|
|
684
|
+
/**
|
|
685
|
+
* Update drag preview visualization
|
|
686
|
+
*/
|
|
687
|
+
)
|
|
688
|
+
}, {
|
|
689
|
+
key: "updateDragPreview",
|
|
690
|
+
value: (function () {
|
|
691
|
+
var _updateDragPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(position) {
|
|
692
|
+
return _regenerator().w(function (_context7) {
|
|
693
|
+
while (1) switch (_context7.n) {
|
|
694
|
+
case 0:
|
|
695
|
+
if (!(!this.dragPreviewMesh && !this.isCreatingDragPreview)) {
|
|
696
|
+
_context7.n = 3;
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
699
|
+
this.isCreatingDragPreview = true;
|
|
700
|
+
_context7.p = 1;
|
|
701
|
+
_context7.n = 2;
|
|
702
|
+
return this.createDragPreview();
|
|
703
|
+
case 2:
|
|
704
|
+
_context7.p = 2;
|
|
705
|
+
this.isCreatingDragPreview = false;
|
|
706
|
+
return _context7.f(2);
|
|
707
|
+
case 3:
|
|
708
|
+
if (this.dragPreviewMesh && position) {
|
|
709
|
+
// Update mesh position
|
|
710
|
+
this.dragPreviewMesh.position.set(position.x, position.y, position.z);
|
|
711
|
+
this.dragPreviewMesh.visible = true;
|
|
712
|
+
|
|
713
|
+
// Update bounding box position if it exists
|
|
714
|
+
if (this.dragPreviewBoundingBox) {
|
|
715
|
+
this.dragPreviewBoundingBox.position.set(position.x, position.y, position.z);
|
|
716
|
+
this.dragPreviewBoundingBox.visible = true;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
case 4:
|
|
720
|
+
return _context7.a(2);
|
|
721
|
+
}
|
|
722
|
+
}, _callee7, this, [[1,, 2, 3]]);
|
|
723
|
+
}));
|
|
724
|
+
function updateDragPreview(_x1) {
|
|
725
|
+
return _updateDragPreview.apply(this, arguments);
|
|
726
|
+
}
|
|
727
|
+
return updateDragPreview;
|
|
728
|
+
}()
|
|
729
|
+
/**
|
|
730
|
+
* Create drag preview mesh with actual model or fallback box
|
|
731
|
+
*/
|
|
732
|
+
)
|
|
733
|
+
}, {
|
|
734
|
+
key: "createDragPreview",
|
|
735
|
+
value: (function () {
|
|
736
|
+
var _createDragPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
737
|
+
var componentDictionary, dictResponse, libraryId, libraryComponent, previewMesh, cachedModel, size, geometry, material, _t9;
|
|
738
|
+
return _regenerator().w(function (_context8) {
|
|
739
|
+
while (1) switch (_context8.n) {
|
|
740
|
+
case 0:
|
|
741
|
+
// Clean up any existing preview
|
|
742
|
+
this.clearDragPreview();
|
|
743
|
+
if (!(!this.scene || !this.currentDragComponentData)) {
|
|
744
|
+
_context8.n = 1;
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
return _context8.a(2);
|
|
748
|
+
case 1:
|
|
749
|
+
_context8.p = 1;
|
|
750
|
+
console.log('🎯 Creating drag preview for:', this.currentDragComponentData);
|
|
751
|
+
|
|
752
|
+
// Get the component dictionary for model information
|
|
753
|
+
componentDictionary = {};
|
|
754
|
+
_context8.p = 2;
|
|
755
|
+
_context8.n = 3;
|
|
756
|
+
return fetch('./library/component-dictionary.json');
|
|
757
|
+
case 3:
|
|
758
|
+
dictResponse = _context8.v;
|
|
759
|
+
_context8.n = 4;
|
|
760
|
+
return dictResponse.json();
|
|
761
|
+
case 4:
|
|
762
|
+
componentDictionary = _context8.v;
|
|
763
|
+
_context8.n = 6;
|
|
764
|
+
break;
|
|
765
|
+
case 5:
|
|
766
|
+
_context8.p = 5;
|
|
767
|
+
_context8.v;
|
|
768
|
+
console.warn('⚠️ Could not load component dictionary for preview');
|
|
769
|
+
case 6:
|
|
770
|
+
libraryId = this.currentDragComponentData.libraryId;
|
|
771
|
+
libraryComponent = componentDictionary[libraryId];
|
|
772
|
+
previewMesh = null; // Try to create a preview from the actual model if available
|
|
773
|
+
if (libraryComponent && libraryComponent.modelKey && this.modelPreloader) {
|
|
774
|
+
try {
|
|
775
|
+
// Get the cached model if available
|
|
776
|
+
cachedModel = this.modelPreloader.getCachedModel(libraryComponent.modelKey);
|
|
777
|
+
if (cachedModel) {
|
|
778
|
+
// Clone the model for preview
|
|
779
|
+
previewMesh = cachedModel.clone();
|
|
780
|
+
|
|
781
|
+
// Make it semi-transparent
|
|
782
|
+
previewMesh.traverse(function (child) {
|
|
783
|
+
if (child.isMesh) {
|
|
784
|
+
// Create a clone of the material to avoid affecting the original
|
|
785
|
+
child.material = child.material.clone();
|
|
786
|
+
child.material.transparent = true;
|
|
787
|
+
child.material.opacity = 0.4;
|
|
788
|
+
child.material.depthTest = true;
|
|
789
|
+
child.material.depthWrite = true;
|
|
790
|
+
child.material.needsUpdate = true;
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
previewMesh.userData.isPreview = true;
|
|
794
|
+
console.log('🎯 Created model-based preview');
|
|
795
|
+
}
|
|
796
|
+
} catch (modelError) {
|
|
797
|
+
console.warn('⚠️ Could not create model-based preview:', modelError);
|
|
798
|
+
previewMesh = null;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// If we couldn't create a preview from the model, use a fallback box
|
|
803
|
+
if (!previewMesh) {
|
|
804
|
+
console.log('🎯 Creating fallback box preview');
|
|
805
|
+
|
|
806
|
+
// Use the calculated size or defaults
|
|
807
|
+
size = this.dragPreviewSize || {
|
|
808
|
+
width: 1,
|
|
809
|
+
height: 1,
|
|
810
|
+
depth: 1
|
|
811
|
+
}; // Create a box with wireframe material
|
|
812
|
+
geometry = new THREE.BoxGeometry(size.width, size.height, size.depth);
|
|
813
|
+
material = new THREE.MeshBasicMaterial({
|
|
814
|
+
color: 0x00ff00,
|
|
815
|
+
// Green by default
|
|
816
|
+
wireframe: true,
|
|
817
|
+
transparent: true,
|
|
818
|
+
opacity: 0.6
|
|
819
|
+
});
|
|
820
|
+
previewMesh = new THREE.Mesh(geometry, material);
|
|
821
|
+
previewMesh.userData.isFallback = true;
|
|
822
|
+
previewMesh.userData.isPreview = true;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// Add to scene
|
|
826
|
+
this.scene.add(previewMesh);
|
|
827
|
+
this.dragPreviewMesh = previewMesh;
|
|
828
|
+
|
|
829
|
+
// Initially hide the preview
|
|
830
|
+
this.dragPreviewMesh.visible = false;
|
|
831
|
+
|
|
832
|
+
// Also create a bounding box for overlap detection
|
|
833
|
+
this.createBoundingBoxHelper();
|
|
834
|
+
return _context8.a(2, true);
|
|
835
|
+
case 7:
|
|
836
|
+
_context8.p = 7;
|
|
837
|
+
_t9 = _context8.v;
|
|
838
|
+
console.error('❌ Error creating drag preview:', _t9);
|
|
839
|
+
return _context8.a(2, false);
|
|
840
|
+
}
|
|
841
|
+
}, _callee8, this, [[2, 5], [1, 7]]);
|
|
842
|
+
}));
|
|
843
|
+
function createDragPreview() {
|
|
844
|
+
return _createDragPreview.apply(this, arguments);
|
|
845
|
+
}
|
|
846
|
+
return createDragPreview;
|
|
847
|
+
}()
|
|
848
|
+
/**
|
|
849
|
+
* Create a bounding box helper for the preview mesh
|
|
850
|
+
*/
|
|
851
|
+
)
|
|
852
|
+
}, {
|
|
853
|
+
key: "createBoundingBoxHelper",
|
|
854
|
+
value: function createBoundingBoxHelper() {
|
|
855
|
+
if (!this.dragPreviewMesh) return;
|
|
856
|
+
|
|
857
|
+
// Create a bounding box for overlap detection
|
|
858
|
+
var bbox = new THREE.Box3().setFromObject(this.dragPreviewMesh);
|
|
859
|
+
var size = bbox.getSize(new THREE.Vector3());
|
|
860
|
+
bbox.getCenter(new THREE.Vector3());
|
|
861
|
+
|
|
862
|
+
// Create a wireframe box to represent the bounding box
|
|
863
|
+
var geometry = new THREE.BoxGeometry(size.x, size.y, size.z);
|
|
864
|
+
var material = new THREE.LineBasicMaterial({
|
|
865
|
+
color: 0xffff00,
|
|
866
|
+
transparent: true,
|
|
867
|
+
opacity: 0.3
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// Use edges to create a wireframe
|
|
871
|
+
var edges = new THREE.EdgesGeometry(geometry);
|
|
872
|
+
var bboxMesh = new THREE.LineSegments(edges, material);
|
|
873
|
+
|
|
874
|
+
// Position relative to the preview mesh
|
|
875
|
+
bboxMesh.position.copy(this.dragPreviewMesh.position);
|
|
876
|
+
|
|
877
|
+
// Add to scene
|
|
878
|
+
this.scene.add(bboxMesh);
|
|
879
|
+
this.dragPreviewBoundingBox = bboxMesh;
|
|
880
|
+
this.dragPreviewBoundingBox.visible = false;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Check if the preview mesh overlaps with any existing scene objects
|
|
885
|
+
*/
|
|
886
|
+
}, {
|
|
887
|
+
key: "checkBoundingBoxOverlap",
|
|
888
|
+
value: function checkBoundingBoxOverlap() {
|
|
889
|
+
var _this = this;
|
|
890
|
+
if (!this.dragPreviewMesh || !this.scene) return false;
|
|
891
|
+
|
|
892
|
+
// Create a bounding box for the preview mesh
|
|
893
|
+
var previewBBox = new THREE.Box3().setFromObject(this.dragPreviewMesh);
|
|
894
|
+
|
|
895
|
+
// Get all meshes in the scene
|
|
896
|
+
var sceneMeshes = [];
|
|
897
|
+
this.scene.traverse(function (object) {
|
|
898
|
+
// Only check meshes that:
|
|
899
|
+
// 1. Are not the preview mesh itself
|
|
900
|
+
// 2. Are not marked as ground, grid, or wall
|
|
901
|
+
// 3. Have component or connector type
|
|
902
|
+
if (object.isMesh && object !== _this.dragPreviewMesh && object !== _this.dragPreviewBoundingBox && !object.userData.isBaseGround && !object.userData.isBrickWall && !object.userData.isBaseGrid) {
|
|
903
|
+
// Check for component objects by userData
|
|
904
|
+
var isComponent = object.userData && (object.userData.componentType === 'component' || object.userData.componentType === 'connector' || object.userData.componentType === 'gateway');
|
|
905
|
+
if (isComponent) {
|
|
906
|
+
sceneMeshes.push(object);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
// Check for overlaps
|
|
912
|
+
for (var _i = 0, _sceneMeshes = sceneMeshes; _i < _sceneMeshes.length; _i++) {
|
|
913
|
+
var mesh = _sceneMeshes[_i];
|
|
914
|
+
var meshBBox = new THREE.Box3().setFromObject(mesh);
|
|
915
|
+
if (previewBBox.intersectsBox(meshBBox)) {
|
|
916
|
+
console.log('⚠️ Overlap detected with:', mesh.uuid);
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Clear the drag preview
|
|
925
|
+
*/
|
|
926
|
+
}, {
|
|
927
|
+
key: "clearDragPreview",
|
|
928
|
+
value: function clearDragPreview() {
|
|
929
|
+
if (this.dragPreviewMesh) {
|
|
930
|
+
this.dragPreviewMesh.visible = false;
|
|
931
|
+
}
|
|
932
|
+
if (this.dragPreviewBoundingBox) {
|
|
933
|
+
this.dragPreviewBoundingBox.visible = false;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Cleanup and remove the drag preview meshes
|
|
939
|
+
*/
|
|
940
|
+
}, {
|
|
941
|
+
key: "cleanupDragPreview",
|
|
942
|
+
value: function cleanupDragPreview() {
|
|
943
|
+
if (this.dragPreviewMesh) {
|
|
944
|
+
this.scene.remove(this.dragPreviewMesh);
|
|
945
|
+
|
|
946
|
+
// Dispose of geometries and materials
|
|
947
|
+
if (this.dragPreviewMesh.geometry) {
|
|
948
|
+
this.dragPreviewMesh.geometry.dispose();
|
|
949
|
+
}
|
|
950
|
+
if (this.dragPreviewMesh.material) {
|
|
951
|
+
if (Array.isArray(this.dragPreviewMesh.material)) {
|
|
952
|
+
this.dragPreviewMesh.material.forEach(function (material) {
|
|
953
|
+
return material.dispose();
|
|
954
|
+
});
|
|
955
|
+
} else {
|
|
956
|
+
this.dragPreviewMesh.material.dispose();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
this.dragPreviewMesh = null;
|
|
960
|
+
}
|
|
961
|
+
if (this.dragPreviewBoundingBox) {
|
|
962
|
+
this.scene.remove(this.dragPreviewBoundingBox);
|
|
963
|
+
if (this.dragPreviewBoundingBox.geometry) {
|
|
964
|
+
this.dragPreviewBoundingBox.geometry.dispose();
|
|
965
|
+
}
|
|
966
|
+
if (this.dragPreviewBoundingBox.material) {
|
|
967
|
+
this.dragPreviewBoundingBox.material.dispose();
|
|
968
|
+
}
|
|
969
|
+
this.dragPreviewBoundingBox = null;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Clean up all resources
|
|
975
|
+
*/
|
|
976
|
+
}, {
|
|
977
|
+
key: "dispose",
|
|
978
|
+
value: function dispose() {
|
|
979
|
+
this.cleanupDragPreview();
|
|
980
|
+
this.currentDragComponentData = null;
|
|
981
|
+
this.dragPreviewSize = null;
|
|
982
|
+
this.isDragOverScene = false;
|
|
983
|
+
this.dragTargetPosition = null;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Get current drag state
|
|
988
|
+
*/
|
|
989
|
+
}, {
|
|
990
|
+
key: "getDragState",
|
|
991
|
+
value: function getDragState() {
|
|
992
|
+
return {
|
|
993
|
+
isDragging: !!this.currentDragComponentData,
|
|
994
|
+
isDragOverScene: this.isDragOverScene,
|
|
995
|
+
dragComponentData: this.currentDragComponentData,
|
|
996
|
+
dragTargetPosition: this.dragTargetPosition
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
}]);
|
|
1000
|
+
}();
|
|
1001
|
+
|
|
1002
|
+
export { DragDropManager as default };
|