@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,1149 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"t",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("../managers/controls/transformControlsManager.js"),n=require("../managers/system/hotReloadManager.js"),i=require("../managers/system/disposalManager.js"),a=require("../managers/scene/sceneExportManager.js"),s=require("../managers/components/componentManager.js"),r=require("../managers/scene/sceneInitializationManager.js"),o=require("../managers/environment/environmentManager.js"),u=require("../managers/controls/keyboardControlsManager.js"),l=require("../managers/components/pathfindingManager.js"),c=require("../managers/scene/sceneOperationsManager.js"),h=require("../managers/components/animationManager.js"),d=require("../managers/controls/cameraControlsManager.js"),v=require("../managers/scene/sceneTooltipsManager.js"),f=require("./nameUtils.js"),m=require("./debugLogger.js"),p=require("../rendering/modelPreloader.js"),g=require("../managers/controls/dragDropManager.js"),y=require("../helpers/sceneHelper.js"),w=function(){return e.createClass(function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e.classCallCheck(this,t),this.sceneViewer=n,this.managers={},this.utilities={},this.isInitialized=!1,this.importedSceneData=null,this.metadata={},this.transformHistory={lastTransform:null},this.setDefaultSceneMetadata(),this.initializeUtilities(),n&&(this.initializeManagers(),this.isInitialized=!0)},[{key:"setSceneViewer",value:function(e){this.sceneViewer=e,!this.isInitialized&&e&&(this.initializeManagers(),this.isInitialized=!0)}},{key:"initializeManagers",value:function(){this.sceneViewer&&(this.managers.hotReloadManager=new n.HotReloadManager(this.sceneViewer),this.managers.disposalManager=new i.DisposalManager(this.sceneViewer),this.managers.sceneExportManager=new a.SceneExportManager(this.sceneViewer),this.managers.componentManager=new s.ComponentManager(this.sceneViewer),this.managers.sceneInitializationManager=new r.SceneInitializationManager(this.sceneViewer),this.managers.environmentManager=new o.EnvironmentManager(this.sceneViewer),this.managers.keyboardControlsManager=new u.KeyboardControlsManager(this.sceneViewer),this.managers.pathfindingManager=new l.PathfindingManager(this.sceneViewer),this.managers.sceneOperationsManager=new c.SceneOperationsManager(this.sceneViewer),this.managers.animationManager=new h.AnimationManager(this.sceneViewer),this.managers.cameraControlsManager=new d.CameraControlsManager(this.sceneViewer))}},{key:"initializeUtilities",value:function(){this.utilities.createTransformControls=t.createTransformControls,this.utilities.generateUuidFromName=f.generateUuidFromName,this.utilities.getHardcodedUuid=f.getHardcodedUuid,this.utilities.logger=m.logger,this.utilities.transformLogger=m.transformLogger,this.utilities.pathfinderLogger=m.pathfinderLogger,this.utilities.modelLogger=m.modelLogger,this.utilities.modelPreloader=p.default,this.utilities.SceneHelper=y.SceneHelper,this.utilities.DragDropManager=g.default}},{key:"attachToComponent",value:function(){var e=this;this.sceneViewer&&(this.isInitialized||this.initializeManagers(),Object.keys(this.managers).forEach(function(t){e.sceneViewer[t]=e.managers[t]}),Object.keys(this.utilities).forEach(function(t){e.sceneViewer[t]=e.utilities[t]}))}},{key:"initializePostSceneManagers",value:function(){this.sceneViewer.$refs.container&&this.sceneViewer.camera&&this.sceneViewer.scene&&(this.managers.tooltipsManager=new v.SceneTooltipsManager(this.sceneViewer.$refs.container,this.sceneViewer.camera,this.sceneViewer.scene),this.sceneViewer.tooltipsManager=this.managers.tooltipsManager),this.sceneViewer.scene&&this.sceneViewer.camera&&(this.managers.dragDropManager=new g.default({scene:this.sceneViewer.scene,camera:this.sceneViewer.camera,transformManager:this.sceneViewer.transformManager,modelPreloader:this.utilities.modelPreloader,componentManager:this.sceneViewer.componentManager}),this.sceneViewer.dragDropManager=this.managers.dragDropManager),this.sceneViewer.scene&&this.sceneViewer.camera&&this.sceneViewer.renderer&&(this.utilities.sceneHelper=new y.SceneHelper({scene:this.sceneViewer.scene,camera:this.sceneViewer.camera,renderer:this.sceneViewer.renderer,controls:this.sceneViewer.controls,transformManager:this.sceneViewer.transformManager,componentManager:this.sceneViewer.componentManager,pathfindingManager:this.sceneViewer.pathfindingManager,currentSceneData:this.sceneViewer.currentSceneData,logger:this.utilities.logger}),this.sceneViewer.sceneHelper=this.utilities.sceneHelper)}},{key:"updateSceneHelperData",value:function(e){this.utilities.sceneHelper&&"function"==typeof this.utilities.sceneHelper.updateSceneData&&this.utilities.sceneHelper.updateSceneData(e)}},{key:"setImportedSceneData",value:function(t){this.importedSceneData=e.objectSpread2({},t),this.setDefaultImportedSceneMetadata(t),this.utilities.sceneHelper&&"function"==typeof this.utilities.sceneHelper.updateSceneData&&this.utilities.sceneHelper.updateSceneData(t)}},{key:"getImportedSceneData",value:function(){return this.importedSceneData}},{key:"getImportedConnections",value:function(){var e;return(null===(e=this.importedSceneData)||void 0===e?void 0:e.connections)||[]}},{key:"getImportedSceneObjects",value:function(){var e;return(null===(e=this.importedSceneData)||void 0===e||null===(e=e.scene)||void 0===e?void 0:e.object)||null}},{key:"clearImportedSceneData",value:function(){this.importedSceneData=null}},{key:"setMetadata",value:function(e,t){this.metadata[e]=t}},{key:"getMetadata",value:function(e){return this.metadata[e]}},{key:"getAllMetadata",value:function(){return e.objectSpread2({},this.metadata)}},{key:"removeMetadata",value:function(e){delete this.metadata[e]}},{key:"clearAllMetadata",value:function(){this.metadata={}}},{key:"clearAllData",value:function(){this.metadata={},this.transformHistory.lastTransform=null}},{key:"recordTransform",value:function(e){var t,n;if(e&&e.object){e.previousValues;var i={type:e.type,object:e.object,values:e.values,previousValues:e.previousValues,timestamp:(new Date).toISOString(),objectId:(null===(t=e.object)||void 0===t?void 0:t.uuid)||(null===(n=e.object)||void 0===n?void 0:n.id)||"unknown"};this.transformHistory.lastTransform=i}}},{key:"getLastTransform",value:function(){return this.transformHistory.lastTransform}},{key:"getTransformHistory",value:function(){return e.objectSpread2({},this.transformHistory)}},{key:"clearTransformHistory",value:function(){this.transformHistory.lastTransform=null}},{key:"hasMetadata",value:function(e){return e in this.metadata}},{key:"setDefaultSceneMetadata",value:function(){var e=this,t={sceneInfo:{name:"Untitled Central Plant Scene",description:"A central plant facility scene",version:"1.0.0",created:(new Date).toISOString(),lastModified:(new Date).toISOString(),author:"Engineering Team"},projectSettings:{units:"metric",scale:1,gridSize:1,snapToGrid:!0,showGrid:!0,showAxes:!0},viewportSettings:{defaultViewMode:"perspective",backgroundType:"skybox",showEnvironment:!0,autoRotate:!1,cameraPosition:{x:10,y:10,z:10},cameraTarget:{x:0,y:0,z:0}},componentSettings:{defaultComponentScale:1,showBoundingBoxes:!1,showConnectionPaths:!0,highlightOnHover:!0,selectionOutlineColor:"#00ff00"},spatialBoundaries:{min:{x:-60,y:-16,z:-60},max:{x:60,y:16,z:60},center:{x:0,y:4,z:0}},systemInfo:{centralPlantVersion:"2.0.0",buildDate:(new Date).toISOString(),platform:"undefined"!=typeof window?window.navigator.platform:"Unknown",userAgent:"undefined"!=typeof window?window.navigator.userAgent:"Unknown"}};Object.keys(t).forEach(function(n){e.hasMetadata(n)||e.setMetadata(n,t[n])})}},{key:"setDefaultImportedSceneMetadata",value:function(t){var n,i,a,s=(new Date).toISOString(),r=(null===(n=t.connections)||void 0===n?void 0:n.length)||0,o=(null===(i=t.scene)||void 0===i||null===(i=i.object)||void 0===i||null===(i=i.children)||void 0===i?void 0:i.length)||0,u={};null!==(a=t.scene)&&void 0!==a&&null!==(a=a.object)&&void 0!==a&&a.children&&t.scene.object.children.forEach(function(e){var t,n=(null===(t=e.userData)||void 0===t?void 0:t.componentType)||"unknown";u[n]=(u[n]||0)+1});var l={importInfo:{importTimestamp:s,originalFileName:null,fileSize:null,importMethod:"file-upload",importVersion:"1.0.0"},sceneAnalysis:{totalComponents:o,totalConnections:r,componentTypes:u,sceneComplexity:this.calculateSceneComplexity(r,o),hasValidStructure:this.validateImportedSceneStructure(t)},dataQuality:{hasConnections:r>0,hasComponents:o>0,hasValidScene:!!t.scene,missingData:this.identifyMissingData(t),warnings:this.generateImportWarnings(t)},processingStats:{processedAt:s,processingDuration:null,memoryUsage:this.estimateMemoryUsage(t),cacheStatus:"pending"}};if(this.setMetadata("lastImport",l),this.hasMetadata("sceneInfo")){var c=this.getMetadata("sceneInfo");this.setMetadata("sceneInfo",e.objectSpread2(e.objectSpread2({},c),{},{lastModified:s,importSource:"file-import",dataSourceType:"json"}))}}},{key:"calculateSceneComplexity",value:function(e,t){var n=e+t;return n<=10?"simple":n<=50?"moderate":n<=200?"complex":"very-complex"}},{key:"validateImportedSceneStructure",value:function(e){return!!(e&&e.scene&&e.scene.object&&Array.isArray(e.connections))}},{key:"identifyMissingData",value:function(e){var t,n=[];return e.connections&&0!==e.connections.length||n.push("No connection data found"),null!==(t=e.scene)&&void 0!==t&&null!==(t=t.object)&&void 0!==t&&t.children&&0!==e.scene.object.children.length||n.push("No component data found"),e.metadata||n.push("No metadata found"),e.version||n.push("No version information"),n}},{key:"generateImportWarnings",value:function(e){var t,n,i=[],a=(null===(t=e.scene)||void 0===t||null===(t=t.object)||void 0===t||null===(t=t.children)||void 0===t?void 0:t.length)||0;a>100&&i.push("Large scene detected (".concat(a," components) - may impact performance"));var s=(null===(n=e.connections)||void 0===n?void 0:n.length)||0;return a>0&&0===s&&i.push("Components found but no connections - scene may be incomplete"),e.version&&parseFloat(e.version)<1&&i.push("Scene data version is older than current - some features may not work correctly"),i}},{key:"estimateMemoryUsage",value:function(e){var t=JSON.stringify(e).length,n=(t/1024/1024).toFixed(2);return{jsonSizeBytes:t,estimatedMB:parseFloat(n),category:n<1?"small":n<10?"medium":"large"}}},{key:"updateMetadataCategory",value:function(t,n){if(this.hasMetadata(t)){var i=this.getMetadata(t);this.setMetadata(t,e.objectSpread2(e.objectSpread2({},i),n))}else this.setMetadata(t,n)}},{key:"undoTransform",value:function(){var e=this.getLastTransform();if(!e)return!1;try{var t,n=e.object,i=e.type,a=e.previousValues;if(!n||!a)return!1;if(this.debugTransformState(n,"Before Undo"),this.sceneViewer&&this.sceneViewer.scene){var s=!1;if(this.sceneViewer.scene.traverse(function(e){e===n&&(s=!0)}),!s)return!1}switch(i){case"translate":case"position":a.position?(void 0!==a.position.x&&(n.position.x=a.position.x),void 0!==a.position.y&&(n.position.y=a.position.y),void 0!==a.position.z&&(n.position.z=a.position.z)):(void 0!==a.x&&(n.position.x=a.x),void 0!==a.y&&(n.position.y=a.y),void 0!==a.z&&(n.position.z=a.z));break;case"rotate":case"rotation":a.rotation?(void 0!==a.rotation.x&&(n.rotation.x=a.rotation.x),void 0!==a.rotation.y&&(n.rotation.y=a.rotation.y),void 0!==a.rotation.z&&(n.rotation.z=a.rotation.z)):(void 0!==a.x&&(n.rotation.x=a.x),void 0!==a.y&&(n.rotation.y=a.y),void 0!==a.z&&(n.rotation.z=a.z));break;case"scale":a.scale?(void 0!==a.scale.x&&(n.scale.x=a.scale.x),void 0!==a.scale.y&&(n.scale.y=a.scale.y),void 0!==a.scale.z&&(n.scale.z=a.scale.z)):(void 0!==a.x&&(n.scale.x=a.x),void 0!==a.y&&(n.scale.y=a.y),void 0!==a.z&&(n.scale.z=a.z));break;default:return!1}n.updateMatrix(),n.updateMatrixWorld(!0);var r=null===(t=this.sceneViewer)||void 0===t?void 0:t.transformManager;if(r&&r.transformControls){var o=r.transformControls;o.object===n&&(o.detach(),r.ensureSceneAttachment&&r.ensureSceneAttachment(!0),o.attach(n),r.selectedObject=n,r.updateBoundingBox&&r.updateBoundingBox(),r.boundingBoxCache&&r.boundingBoxCache.has(n)&&r.boundingBoxCache.delete(n))}if(this.sceneViewer&&this.sceneViewer.sceneOperationsManager&&this.sceneViewer.currentSceneData)try{this.sceneViewer.onTransformEnd(n)}catch(e){}if("undefined"!=typeof window){var u=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),action:"undo-transform",objectId:n.uuid||n.id||"unknown"}});window.dispatchEvent(u)}return this.clearTransformHistory(),this.ensureObjectSelectable(n),this.debugTransformState(n,"After Undo"),!0}catch(e){return!1}}},{key:"ensureObjectSelectable",value:function(e){if(!e||!this.sceneViewer)return!1;try{var t=this.sceneViewer.transformManager;return!!t&&(t.recoverTransformControls?t.recoverTransformControls(e):(e.updateMatrixWorld(!0),t.boundingBoxCache&&t.boundingBoxCache.has(e)&&t.boundingBoxCache.delete(e),t.ensureSceneAttachment&&t.ensureSceneAttachment(!0),t.selectedObject===e&&(t.deselectObject(),requestAnimationFrame(function(){t.selectObjectForTransformOnly(e)})),!0))}catch(e){return!1}}},{key:"debugTransformState",value:function(e){}},{key:"fixTransformControlsSelection",value:function(){if(!this.sceneViewer||!this.sceneViewer.transformManager)return!1;var e=this.sceneViewer.transformManager;if(e.recoverTransformControls&&e.recoverTransformControls())return!0;try{var t=e.currentMode,n=e.currentSpace;return e.transformControls&&(e.transformControls.detach(),e.scene.remove(e.transformControls),e.transformControls.dispose(),e.transformControls=null),e.createTransformControls(),e.setupEventListeners(),e.setMode(t),e.setSpace(n),!0}catch(e){return!1}}},{key:"isObjectInScene",value:function(e){if(!this.sceneViewer||!this.sceneViewer.scene)return!1;var t=!1;return this.sceneViewer.scene.traverse(function(n){n===e&&(t=!0)}),t}}])}();exports.CentralPlant=w,exports.default=w;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var transformControlsManager = require('../managers/controls/transformControlsManager.js');
|
|
7
|
+
var hotReloadManager = require('../managers/system/hotReloadManager.js');
|
|
8
|
+
var disposalManager = require('../managers/system/disposalManager.js');
|
|
9
|
+
var sceneExportManager = require('../managers/scene/sceneExportManager.js');
|
|
10
|
+
var componentManager = require('../managers/components/componentManager.js');
|
|
11
|
+
var sceneInitializationManager = require('../managers/scene/sceneInitializationManager.js');
|
|
12
|
+
var environmentManager = require('../managers/environment/environmentManager.js');
|
|
13
|
+
var keyboardControlsManager = require('../managers/controls/keyboardControlsManager.js');
|
|
14
|
+
var pathfindingManager = require('../managers/components/pathfindingManager.js');
|
|
15
|
+
var sceneOperationsManager = require('../managers/scene/sceneOperationsManager.js');
|
|
16
|
+
var animationManager = require('../managers/components/animationManager.js');
|
|
17
|
+
var cameraControlsManager = require('../managers/controls/cameraControlsManager.js');
|
|
18
|
+
var sceneTooltipsManager = require('../managers/scene/sceneTooltipsManager.js');
|
|
19
|
+
var nameUtils = require('./nameUtils.js');
|
|
20
|
+
var debugLogger = require('./debugLogger.js');
|
|
21
|
+
var modelPreloader = require('../rendering/modelPreloader.js');
|
|
22
|
+
var dragDropManager = require('../managers/controls/dragDropManager.js');
|
|
23
|
+
var sceneHelper = require('../helpers/sceneHelper.js');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* CentralPlant class that manages all scene utility instances
|
|
27
|
+
*/
|
|
28
|
+
var CentralPlant = /*#__PURE__*/function () {
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the CentralPlant manager
|
|
31
|
+
* @param {Object} sceneViewer - The SceneViewerEnhanced component instance
|
|
32
|
+
*/
|
|
33
|
+
function CentralPlant() {
|
|
34
|
+
var sceneViewer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
35
|
+
_rollupPluginBabelHelpers.classCallCheck(this, CentralPlant);
|
|
36
|
+
this.sceneViewer = sceneViewer;
|
|
37
|
+
this.managers = {};
|
|
38
|
+
this.utilities = {};
|
|
39
|
+
this.isInitialized = false;
|
|
40
|
+
|
|
41
|
+
// Store imported scene data directly
|
|
42
|
+
this.importedSceneData = null;
|
|
43
|
+
|
|
44
|
+
// Add metadata storage
|
|
45
|
+
this.metadata = {};
|
|
46
|
+
|
|
47
|
+
// Add transform history tracking
|
|
48
|
+
this.transformHistory = {
|
|
49
|
+
lastTransform: null
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Set default scene metadata
|
|
53
|
+
this.setDefaultSceneMetadata();
|
|
54
|
+
|
|
55
|
+
// Initialize utilities immediately (they don't need scene viewer)
|
|
56
|
+
this.initializeUtilities();
|
|
57
|
+
|
|
58
|
+
// Initialize managers only if sceneViewer is provided
|
|
59
|
+
if (sceneViewer) {
|
|
60
|
+
this.initializeManagers();
|
|
61
|
+
this.isInitialized = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Set the scene viewer instance and initialize managers if not already done
|
|
67
|
+
* @param {Object} sceneViewer - The SceneViewerEnhanced component instance
|
|
68
|
+
*/
|
|
69
|
+
return _rollupPluginBabelHelpers.createClass(CentralPlant, [{
|
|
70
|
+
key: "setSceneViewer",
|
|
71
|
+
value: function setSceneViewer(sceneViewer) {
|
|
72
|
+
this.sceneViewer = sceneViewer;
|
|
73
|
+
if (!this.isInitialized && sceneViewer) {
|
|
74
|
+
this.initializeManagers();
|
|
75
|
+
this.isInitialized = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Initialize all manager instances
|
|
81
|
+
*/
|
|
82
|
+
}, {
|
|
83
|
+
key: "initializeManagers",
|
|
84
|
+
value: function initializeManagers() {
|
|
85
|
+
if (!this.sceneViewer) {
|
|
86
|
+
console.warn('โ ๏ธ Cannot initialize managers without scene viewer');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Initialize all managers consistently
|
|
91
|
+
this.managers.hotReloadManager = new hotReloadManager.HotReloadManager(this.sceneViewer);
|
|
92
|
+
this.managers.disposalManager = new disposalManager.DisposalManager(this.sceneViewer);
|
|
93
|
+
this.managers.sceneExportManager = new sceneExportManager.SceneExportManager(this.sceneViewer);
|
|
94
|
+
this.managers.componentManager = new componentManager.ComponentManager(this.sceneViewer);
|
|
95
|
+
this.managers.sceneInitializationManager = new sceneInitializationManager.SceneInitializationManager(this.sceneViewer);
|
|
96
|
+
this.managers.environmentManager = new environmentManager.EnvironmentManager(this.sceneViewer);
|
|
97
|
+
this.managers.keyboardControlsManager = new keyboardControlsManager.KeyboardControlsManager(this.sceneViewer);
|
|
98
|
+
this.managers.pathfindingManager = new pathfindingManager.PathfindingManager(this.sceneViewer);
|
|
99
|
+
this.managers.sceneOperationsManager = new sceneOperationsManager.SceneOperationsManager(this.sceneViewer);
|
|
100
|
+
this.managers.animationManager = new animationManager.AnimationManager(this.sceneViewer);
|
|
101
|
+
this.managers.cameraControlsManager = new cameraControlsManager.CameraControlsManager(this.sceneViewer);
|
|
102
|
+
|
|
103
|
+
// All managers are now stored in the managers collection and will be attached via attachToComponent()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Initialize utility functions and objects
|
|
108
|
+
*/
|
|
109
|
+
}, {
|
|
110
|
+
key: "initializeUtilities",
|
|
111
|
+
value: function initializeUtilities() {
|
|
112
|
+
// Transform controls factory function
|
|
113
|
+
this.utilities.createTransformControls = transformControlsManager.createTransformControls;
|
|
114
|
+
|
|
115
|
+
// Name utilities
|
|
116
|
+
this.utilities.generateUuidFromName = nameUtils.generateUuidFromName;
|
|
117
|
+
this.utilities.getHardcodedUuid = nameUtils.getHardcodedUuid;
|
|
118
|
+
|
|
119
|
+
// Loggers
|
|
120
|
+
this.utilities.logger = debugLogger.logger;
|
|
121
|
+
this.utilities.transformLogger = debugLogger.transformLogger;
|
|
122
|
+
this.utilities.pathfinderLogger = debugLogger.pathfinderLogger;
|
|
123
|
+
this.utilities.modelLogger = debugLogger.modelLogger;
|
|
124
|
+
|
|
125
|
+
// Model preloader
|
|
126
|
+
this.utilities.modelPreloader = modelPreloader["default"];
|
|
127
|
+
|
|
128
|
+
// Scene helper utility
|
|
129
|
+
this.utilities.SceneHelper = sceneHelper.SceneHelper;
|
|
130
|
+
|
|
131
|
+
// Drag drop manager factory (will be initialized after scene is ready)
|
|
132
|
+
this.utilities.DragDropManager = dragDropManager["default"];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Set all managers and utilities on the scene viewer instance
|
|
137
|
+
*/
|
|
138
|
+
}, {
|
|
139
|
+
key: "attachToComponent",
|
|
140
|
+
value: function attachToComponent() {
|
|
141
|
+
var _this = this;
|
|
142
|
+
if (!this.sceneViewer) {
|
|
143
|
+
console.warn('โ ๏ธ Cannot attach to component: no scene viewer set');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Initialize managers if not already done
|
|
148
|
+
if (!this.isInitialized) {
|
|
149
|
+
this.initializeManagers();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Attach all managers to the scene viewer instance
|
|
153
|
+
Object.keys(this.managers).forEach(function (key) {
|
|
154
|
+
_this.sceneViewer[key] = _this.managers[key];
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Attach utilities to the scene viewer instance
|
|
158
|
+
Object.keys(this.utilities).forEach(function (key) {
|
|
159
|
+
_this.sceneViewer[key] = _this.utilities[key];
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Initialize specific managers that need to be created after scene setup
|
|
165
|
+
*/
|
|
166
|
+
}, {
|
|
167
|
+
key: "initializePostSceneManagers",
|
|
168
|
+
value: function initializePostSceneManagers() {
|
|
169
|
+
// Initialize the tooltip manager (needs container, camera, scene)
|
|
170
|
+
if (this.sceneViewer.$refs.container && this.sceneViewer.camera && this.sceneViewer.scene) {
|
|
171
|
+
this.managers.tooltipsManager = new sceneTooltipsManager.SceneTooltipsManager(this.sceneViewer.$refs.container, this.sceneViewer.camera, this.sceneViewer.scene);
|
|
172
|
+
this.sceneViewer.tooltipsManager = this.managers.tooltipsManager;
|
|
173
|
+
console.log('๐ Tooltip manager initialized:', this.managers.tooltipsManager);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Initialize the drag and drop manager (needs scene, camera, etc.)
|
|
177
|
+
if (this.sceneViewer.scene && this.sceneViewer.camera) {
|
|
178
|
+
this.managers.dragDropManager = new dragDropManager["default"]({
|
|
179
|
+
scene: this.sceneViewer.scene,
|
|
180
|
+
camera: this.sceneViewer.camera,
|
|
181
|
+
transformManager: this.sceneViewer.transformManager,
|
|
182
|
+
modelPreloader: this.utilities.modelPreloader,
|
|
183
|
+
componentManager: this.sceneViewer.componentManager
|
|
184
|
+
});
|
|
185
|
+
this.sceneViewer.dragDropManager = this.managers.dragDropManager;
|
|
186
|
+
console.log('๐ฏ Drag and drop manager initialized');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Initialize the scene helper utility (needs scene, camera, renderer, etc.)
|
|
190
|
+
if (this.sceneViewer.scene && this.sceneViewer.camera && this.sceneViewer.renderer) {
|
|
191
|
+
this.utilities.sceneHelper = new sceneHelper.SceneHelper({
|
|
192
|
+
scene: this.sceneViewer.scene,
|
|
193
|
+
camera: this.sceneViewer.camera,
|
|
194
|
+
renderer: this.sceneViewer.renderer,
|
|
195
|
+
controls: this.sceneViewer.controls,
|
|
196
|
+
transformManager: this.sceneViewer.transformManager,
|
|
197
|
+
componentManager: this.sceneViewer.componentManager,
|
|
198
|
+
pathfindingManager: this.sceneViewer.pathfindingManager,
|
|
199
|
+
currentSceneData: this.sceneViewer.currentSceneData,
|
|
200
|
+
logger: this.utilities.logger
|
|
201
|
+
});
|
|
202
|
+
this.sceneViewer.sceneHelper = this.utilities.sceneHelper;
|
|
203
|
+
console.log('๐ง Scene helper utility initialized:', this.utilities.sceneHelper);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Update scene helper with new scene data
|
|
209
|
+
* @param {Object} sceneData - Updated scene data
|
|
210
|
+
*/
|
|
211
|
+
}, {
|
|
212
|
+
key: "updateSceneHelperData",
|
|
213
|
+
value: function updateSceneHelperData(sceneData) {
|
|
214
|
+
if (this.utilities.sceneHelper && typeof this.utilities.sceneHelper.updateSceneData === 'function') {
|
|
215
|
+
this.utilities.sceneHelper.updateSceneData(sceneData);
|
|
216
|
+
console.log('๐ Scene helper data updated');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Set imported scene data directly in CentralPlant
|
|
222
|
+
* @param {Object} sceneData - The imported scene data (from cp-01-01.json or other scene files)
|
|
223
|
+
*/
|
|
224
|
+
}, {
|
|
225
|
+
key: "setImportedSceneData",
|
|
226
|
+
value: function setImportedSceneData(sceneData) {
|
|
227
|
+
var _this$importedSceneDa, _this$importedSceneDa2;
|
|
228
|
+
this.importedSceneData = _rollupPluginBabelHelpers.objectSpread2({}, sceneData);
|
|
229
|
+
console.log('๐ฅ Imported scene data stored in CentralPlant:', {
|
|
230
|
+
connections: ((_this$importedSceneDa = this.importedSceneData.connections) === null || _this$importedSceneDa === void 0 ? void 0 : _this$importedSceneDa.length) || 0,
|
|
231
|
+
sceneObjects: ((_this$importedSceneDa2 = this.importedSceneData.scene) === null || _this$importedSceneDa2 === void 0 || (_this$importedSceneDa2 = _this$importedSceneDa2.object) === null || _this$importedSceneDa2 === void 0 || (_this$importedSceneDa2 = _this$importedSceneDa2.children) === null || _this$importedSceneDa2 === void 0 ? void 0 : _this$importedSceneDa2.length) || 0,
|
|
232
|
+
timestamp: new Date().toISOString()
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Set default metadata for imported scene data
|
|
236
|
+
this.setDefaultImportedSceneMetadata(sceneData);
|
|
237
|
+
|
|
238
|
+
// Also update the scene helper if available
|
|
239
|
+
if (this.utilities.sceneHelper && typeof this.utilities.sceneHelper.updateSceneData === 'function') {
|
|
240
|
+
this.utilities.sceneHelper.updateSceneData(sceneData);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Get the stored imported scene data
|
|
246
|
+
* @returns {Object|null} The imported scene data or null if none is stored
|
|
247
|
+
*/
|
|
248
|
+
}, {
|
|
249
|
+
key: "getImportedSceneData",
|
|
250
|
+
value: function getImportedSceneData() {
|
|
251
|
+
return this.importedSceneData;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get connections from the imported scene data
|
|
256
|
+
* @returns {Array} The connections array or empty array if none
|
|
257
|
+
*/
|
|
258
|
+
}, {
|
|
259
|
+
key: "getImportedConnections",
|
|
260
|
+
value: function getImportedConnections() {
|
|
261
|
+
var _this$importedSceneDa3;
|
|
262
|
+
return ((_this$importedSceneDa3 = this.importedSceneData) === null || _this$importedSceneDa3 === void 0 ? void 0 : _this$importedSceneDa3.connections) || [];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Get scene objects from the imported scene data
|
|
267
|
+
* @returns {Object|null} The scene object structure or null if none
|
|
268
|
+
*/
|
|
269
|
+
}, {
|
|
270
|
+
key: "getImportedSceneObjects",
|
|
271
|
+
value: function getImportedSceneObjects() {
|
|
272
|
+
var _this$importedSceneDa4;
|
|
273
|
+
return ((_this$importedSceneDa4 = this.importedSceneData) === null || _this$importedSceneDa4 === void 0 || (_this$importedSceneDa4 = _this$importedSceneDa4.scene) === null || _this$importedSceneDa4 === void 0 ? void 0 : _this$importedSceneDa4.object) || null;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Clear the stored imported scene data
|
|
278
|
+
*/
|
|
279
|
+
}, {
|
|
280
|
+
key: "clearImportedSceneData",
|
|
281
|
+
value: function clearImportedSceneData() {
|
|
282
|
+
this.importedSceneData = null;
|
|
283
|
+
console.log('๐๏ธ Imported scene data cleared from CentralPlant');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Set a metadata attribute
|
|
288
|
+
* @param {string} key - The metadata key
|
|
289
|
+
* @param {any} value - The metadata value
|
|
290
|
+
*/
|
|
291
|
+
}, {
|
|
292
|
+
key: "setMetadata",
|
|
293
|
+
value: function setMetadata(key, value) {
|
|
294
|
+
this.metadata[key] = value;
|
|
295
|
+
console.log("\uD83D\uDCDD Metadata set: ".concat(key, " ="), value);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Get a metadata attribute
|
|
300
|
+
* @param {string} key - The metadata key
|
|
301
|
+
* @returns {any} The metadata value or undefined if not found
|
|
302
|
+
*/
|
|
303
|
+
}, {
|
|
304
|
+
key: "getMetadata",
|
|
305
|
+
value: function getMetadata(key) {
|
|
306
|
+
return this.metadata[key];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Get all metadata
|
|
311
|
+
* @returns {Object} All metadata attributes
|
|
312
|
+
*/
|
|
313
|
+
}, {
|
|
314
|
+
key: "getAllMetadata",
|
|
315
|
+
value: function getAllMetadata() {
|
|
316
|
+
return _rollupPluginBabelHelpers.objectSpread2({}, this.metadata);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Remove a metadata attribute
|
|
321
|
+
* @param {string} key - The metadata key to remove
|
|
322
|
+
*/
|
|
323
|
+
}, {
|
|
324
|
+
key: "removeMetadata",
|
|
325
|
+
value: function removeMetadata(key) {
|
|
326
|
+
delete this.metadata[key];
|
|
327
|
+
console.log("\uD83D\uDDD1\uFE0F Metadata removed: ".concat(key));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Clear all metadata
|
|
332
|
+
*/
|
|
333
|
+
}, {
|
|
334
|
+
key: "clearAllMetadata",
|
|
335
|
+
value: function clearAllMetadata() {
|
|
336
|
+
this.metadata = {};
|
|
337
|
+
console.log('๐๏ธ All metadata cleared from CentralPlant');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Clear all data including metadata and transform history
|
|
342
|
+
*/
|
|
343
|
+
}, {
|
|
344
|
+
key: "clearAllData",
|
|
345
|
+
value: function clearAllData() {
|
|
346
|
+
this.metadata = {};
|
|
347
|
+
this.transformHistory.lastTransform = null;
|
|
348
|
+
console.log('๐๏ธ All data cleared from CentralPlant (metadata + transform history)');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Record a transform operation in the history
|
|
353
|
+
* @param {Object} transformData - The transform data to record
|
|
354
|
+
* @param {string} transformData.type - The type of transform (e.g., 'translate', 'rotate', 'scale')
|
|
355
|
+
* @param {Object} transformData.object - The object that was transformed
|
|
356
|
+
* @param {Object} transformData.values - The transform values applied
|
|
357
|
+
* @param {Object} transformData.previousValues - The previous transform values (for undo)
|
|
358
|
+
*/
|
|
359
|
+
}, {
|
|
360
|
+
key: "recordTransform",
|
|
361
|
+
value: function recordTransform(transformData) {
|
|
362
|
+
var _transformData$object, _transformData$object2, _transformRecord$prev;
|
|
363
|
+
console.log("recordTransform started");
|
|
364
|
+
|
|
365
|
+
// Validate the transform data
|
|
366
|
+
if (!transformData || !transformData.object) {
|
|
367
|
+
console.error('โ Invalid transform data provided to recordTransform:', transformData);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (!transformData.previousValues) {
|
|
371
|
+
console.warn('โ ๏ธ No previous values provided for transform recording - undo may not work properly');
|
|
372
|
+
}
|
|
373
|
+
var transformRecord = {
|
|
374
|
+
type: transformData.type,
|
|
375
|
+
object: transformData.object,
|
|
376
|
+
values: transformData.values,
|
|
377
|
+
previousValues: transformData.previousValues,
|
|
378
|
+
timestamp: new Date().toISOString(),
|
|
379
|
+
objectId: ((_transformData$object = transformData.object) === null || _transformData$object === void 0 ? void 0 : _transformData$object.uuid) || ((_transformData$object2 = transformData.object) === null || _transformData$object2 === void 0 ? void 0 : _transformData$object2.id) || 'unknown'
|
|
380
|
+
};
|
|
381
|
+
this.transformHistory.lastTransform = transformRecord;
|
|
382
|
+
console.log('๐ Transform recorded:', {
|
|
383
|
+
type: transformRecord.type,
|
|
384
|
+
objectId: transformRecord.objectId,
|
|
385
|
+
currentValues: transformRecord.values,
|
|
386
|
+
previousValues: transformRecord.previousValues,
|
|
387
|
+
previousValuesStructure: {
|
|
388
|
+
type: _rollupPluginBabelHelpers["typeof"](transformRecord.previousValues),
|
|
389
|
+
keys: Object.keys(transformRecord.previousValues || {}),
|
|
390
|
+
hasPosition: !!(transformRecord.previousValues && transformRecord.previousValues.position),
|
|
391
|
+
hasRotation: !!(transformRecord.previousValues && transformRecord.previousValues.rotation),
|
|
392
|
+
hasScale: !!(transformRecord.previousValues && transformRecord.previousValues.scale),
|
|
393
|
+
positionValues: (_transformRecord$prev = transformRecord.previousValues) !== null && _transformRecord$prev !== void 0 && _transformRecord$prev.position ? {
|
|
394
|
+
x: transformRecord.previousValues.position.x,
|
|
395
|
+
y: transformRecord.previousValues.position.y,
|
|
396
|
+
z: transformRecord.previousValues.position.z
|
|
397
|
+
} : null
|
|
398
|
+
},
|
|
399
|
+
timestamp: transformRecord.timestamp
|
|
400
|
+
});
|
|
401
|
+
console.log("recordTransform this.transformHistory:", this.transformHistory);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Get the last transform operation
|
|
406
|
+
* @returns {Object|null} The last transform record or null if none exists
|
|
407
|
+
*/
|
|
408
|
+
}, {
|
|
409
|
+
key: "getLastTransform",
|
|
410
|
+
value: function getLastTransform() {
|
|
411
|
+
return this.transformHistory.lastTransform;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Get the complete transform history
|
|
416
|
+
* @returns {Object} The transform history object
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "getTransformHistory",
|
|
420
|
+
value: function getTransformHistory() {
|
|
421
|
+
return _rollupPluginBabelHelpers.objectSpread2({}, this.transformHistory);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Clear the transform history
|
|
426
|
+
*/
|
|
427
|
+
}, {
|
|
428
|
+
key: "clearTransformHistory",
|
|
429
|
+
value: function clearTransformHistory() {
|
|
430
|
+
this.transformHistory.lastTransform = null;
|
|
431
|
+
console.log('๐๏ธ Transform history cleared');
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Check if a metadata key exists
|
|
436
|
+
* @param {string} key - The metadata key to check
|
|
437
|
+
* @returns {boolean} True if the key exists
|
|
438
|
+
*/
|
|
439
|
+
}, {
|
|
440
|
+
key: "hasMetadata",
|
|
441
|
+
value: function hasMetadata(key) {
|
|
442
|
+
return key in this.metadata;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Set default metadata for the CentralPlant scene
|
|
447
|
+
*/
|
|
448
|
+
}, {
|
|
449
|
+
key: "setDefaultSceneMetadata",
|
|
450
|
+
value: function setDefaultSceneMetadata() {
|
|
451
|
+
var _this2 = this;
|
|
452
|
+
var defaultMetadata = {
|
|
453
|
+
// Scene Information
|
|
454
|
+
sceneInfo: {
|
|
455
|
+
name: 'Untitled Central Plant Scene',
|
|
456
|
+
description: 'A central plant facility scene',
|
|
457
|
+
version: '1.0.0',
|
|
458
|
+
created: new Date().toISOString(),
|
|
459
|
+
lastModified: new Date().toISOString(),
|
|
460
|
+
author: 'Engineering Team'
|
|
461
|
+
},
|
|
462
|
+
// Project Settings
|
|
463
|
+
projectSettings: {
|
|
464
|
+
units: 'metric',
|
|
465
|
+
// or 'imperial'
|
|
466
|
+
scale: 1.0,
|
|
467
|
+
gridSize: 1.0,
|
|
468
|
+
snapToGrid: true,
|
|
469
|
+
showGrid: true,
|
|
470
|
+
showAxes: true
|
|
471
|
+
},
|
|
472
|
+
// Viewport Settings
|
|
473
|
+
viewportSettings: {
|
|
474
|
+
defaultViewMode: 'perspective',
|
|
475
|
+
backgroundType: 'skybox',
|
|
476
|
+
showEnvironment: true,
|
|
477
|
+
autoRotate: false,
|
|
478
|
+
cameraPosition: {
|
|
479
|
+
x: 10,
|
|
480
|
+
y: 10,
|
|
481
|
+
z: 10
|
|
482
|
+
},
|
|
483
|
+
cameraTarget: {
|
|
484
|
+
x: 0,
|
|
485
|
+
y: 0,
|
|
486
|
+
z: 0
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
// Component Settings
|
|
490
|
+
componentSettings: {
|
|
491
|
+
defaultComponentScale: 1.0,
|
|
492
|
+
showBoundingBoxes: false,
|
|
493
|
+
showConnectionPaths: true,
|
|
494
|
+
highlightOnHover: true,
|
|
495
|
+
selectionOutlineColor: '#00ff00'
|
|
496
|
+
},
|
|
497
|
+
// Spatial Boundaries
|
|
498
|
+
spatialBoundaries: {
|
|
499
|
+
min: {
|
|
500
|
+
x: -60,
|
|
501
|
+
y: -16,
|
|
502
|
+
z: -60
|
|
503
|
+
},
|
|
504
|
+
max: {
|
|
505
|
+
x: 60,
|
|
506
|
+
y: 16,
|
|
507
|
+
z: 60
|
|
508
|
+
},
|
|
509
|
+
center: {
|
|
510
|
+
x: 0,
|
|
511
|
+
y: 4,
|
|
512
|
+
z: 0
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
// System Information
|
|
516
|
+
systemInfo: {
|
|
517
|
+
centralPlantVersion: '2.0.0',
|
|
518
|
+
buildDate: new Date().toISOString(),
|
|
519
|
+
platform: typeof window !== 'undefined' ? window.navigator.platform : 'Unknown',
|
|
520
|
+
userAgent: typeof window !== 'undefined' ? window.navigator.userAgent : 'Unknown'
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
// Set each default metadata category
|
|
525
|
+
Object.keys(defaultMetadata).forEach(function (category) {
|
|
526
|
+
if (!_this2.hasMetadata(category)) {
|
|
527
|
+
_this2.setMetadata(category, defaultMetadata[category]);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
console.log('๐ฏ Default scene metadata initialized:', Object.keys(defaultMetadata));
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Set default metadata for imported scene data
|
|
535
|
+
* @param {Object} sceneData - The imported scene data
|
|
536
|
+
*/
|
|
537
|
+
}, {
|
|
538
|
+
key: "setDefaultImportedSceneMetadata",
|
|
539
|
+
value: function setDefaultImportedSceneMetadata(sceneData) {
|
|
540
|
+
var _sceneData$connection, _sceneData$scene, _sceneData$scene2;
|
|
541
|
+
var importTimestamp = new Date().toISOString();
|
|
542
|
+
|
|
543
|
+
// Extract information from the imported scene data
|
|
544
|
+
var connectionsCount = ((_sceneData$connection = sceneData.connections) === null || _sceneData$connection === void 0 ? void 0 : _sceneData$connection.length) || 0;
|
|
545
|
+
var componentsCount = ((_sceneData$scene = sceneData.scene) === null || _sceneData$scene === void 0 || (_sceneData$scene = _sceneData$scene.object) === null || _sceneData$scene === void 0 || (_sceneData$scene = _sceneData$scene.children) === null || _sceneData$scene === void 0 ? void 0 : _sceneData$scene.length) || 0;
|
|
546
|
+
|
|
547
|
+
// Count different types of components
|
|
548
|
+
var componentTypes = {};
|
|
549
|
+
if ((_sceneData$scene2 = sceneData.scene) !== null && _sceneData$scene2 !== void 0 && (_sceneData$scene2 = _sceneData$scene2.object) !== null && _sceneData$scene2 !== void 0 && _sceneData$scene2.children) {
|
|
550
|
+
sceneData.scene.object.children.forEach(function (child) {
|
|
551
|
+
var _child$userData;
|
|
552
|
+
var componentType = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.componentType) || 'unknown';
|
|
553
|
+
componentTypes[componentType] = (componentTypes[componentType] || 0) + 1;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
var importMetadata = {
|
|
557
|
+
// Import Information
|
|
558
|
+
importInfo: {
|
|
559
|
+
importTimestamp: importTimestamp,
|
|
560
|
+
originalFileName: null,
|
|
561
|
+
// Will be set from the calling context
|
|
562
|
+
fileSize: null,
|
|
563
|
+
// Will be set from the calling context
|
|
564
|
+
importMethod: 'file-upload',
|
|
565
|
+
importVersion: '1.0.0'
|
|
566
|
+
},
|
|
567
|
+
// Scene Analysis
|
|
568
|
+
sceneAnalysis: {
|
|
569
|
+
totalComponents: componentsCount,
|
|
570
|
+
totalConnections: connectionsCount,
|
|
571
|
+
componentTypes: componentTypes,
|
|
572
|
+
sceneComplexity: this.calculateSceneComplexity(connectionsCount, componentsCount),
|
|
573
|
+
hasValidStructure: this.validateImportedSceneStructure(sceneData)
|
|
574
|
+
},
|
|
575
|
+
// Data Quality
|
|
576
|
+
dataQuality: {
|
|
577
|
+
hasConnections: connectionsCount > 0,
|
|
578
|
+
hasComponents: componentsCount > 0,
|
|
579
|
+
hasValidScene: !!sceneData.scene,
|
|
580
|
+
missingData: this.identifyMissingData(sceneData),
|
|
581
|
+
warnings: this.generateImportWarnings(sceneData)
|
|
582
|
+
},
|
|
583
|
+
// Processing Stats
|
|
584
|
+
processingStats: {
|
|
585
|
+
processedAt: importTimestamp,
|
|
586
|
+
processingDuration: null,
|
|
587
|
+
// Can be updated after processing
|
|
588
|
+
memoryUsage: this.estimateMemoryUsage(sceneData),
|
|
589
|
+
cacheStatus: 'pending'
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// Store import-specific metadata
|
|
594
|
+
this.setMetadata('lastImport', importMetadata);
|
|
595
|
+
|
|
596
|
+
// Update scene info if it exists
|
|
597
|
+
if (this.hasMetadata('sceneInfo')) {
|
|
598
|
+
var existingSceneInfo = this.getMetadata('sceneInfo');
|
|
599
|
+
this.setMetadata('sceneInfo', _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, existingSceneInfo), {}, {
|
|
600
|
+
lastModified: importTimestamp,
|
|
601
|
+
importSource: 'file-import',
|
|
602
|
+
dataSourceType: 'json'
|
|
603
|
+
}));
|
|
604
|
+
}
|
|
605
|
+
console.log('๐ฅ Default imported scene metadata set:', {
|
|
606
|
+
components: componentsCount,
|
|
607
|
+
connections: connectionsCount,
|
|
608
|
+
complexity: importMetadata.sceneAnalysis.sceneComplexity,
|
|
609
|
+
types: componentTypes
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Calculate scene complexity based on components and connections
|
|
615
|
+
* @param {number} connectionsCount - Number of connections
|
|
616
|
+
* @param {number} componentsCount - Number of components
|
|
617
|
+
* @returns {string} Complexity level (simple, moderate, complex, very-complex)
|
|
618
|
+
*/
|
|
619
|
+
}, {
|
|
620
|
+
key: "calculateSceneComplexity",
|
|
621
|
+
value: function calculateSceneComplexity(connectionsCount, componentsCount) {
|
|
622
|
+
var totalElements = connectionsCount + componentsCount;
|
|
623
|
+
if (totalElements <= 10) return 'simple';
|
|
624
|
+
if (totalElements <= 50) return 'moderate';
|
|
625
|
+
if (totalElements <= 200) return 'complex';
|
|
626
|
+
return 'very-complex';
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Validate the structure of imported scene data
|
|
631
|
+
* @param {Object} sceneData - The imported scene data
|
|
632
|
+
* @returns {boolean} True if structure is valid
|
|
633
|
+
*/
|
|
634
|
+
}, {
|
|
635
|
+
key: "validateImportedSceneStructure",
|
|
636
|
+
value: function validateImportedSceneStructure(sceneData) {
|
|
637
|
+
return !!(sceneData && sceneData.scene && sceneData.scene.object && Array.isArray(sceneData.connections));
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Identify missing or incomplete data in imported scene
|
|
642
|
+
* @param {Object} sceneData - The imported scene data
|
|
643
|
+
* @returns {Array} Array of missing data warnings
|
|
644
|
+
*/
|
|
645
|
+
}, {
|
|
646
|
+
key: "identifyMissingData",
|
|
647
|
+
value: function identifyMissingData(sceneData) {
|
|
648
|
+
var _sceneData$scene3;
|
|
649
|
+
var missing = [];
|
|
650
|
+
if (!sceneData.connections || sceneData.connections.length === 0) {
|
|
651
|
+
missing.push('No connection data found');
|
|
652
|
+
}
|
|
653
|
+
if (!((_sceneData$scene3 = sceneData.scene) !== null && _sceneData$scene3 !== void 0 && (_sceneData$scene3 = _sceneData$scene3.object) !== null && _sceneData$scene3 !== void 0 && _sceneData$scene3.children) || sceneData.scene.object.children.length === 0) {
|
|
654
|
+
missing.push('No component data found');
|
|
655
|
+
}
|
|
656
|
+
if (!sceneData.metadata) {
|
|
657
|
+
missing.push('No metadata found');
|
|
658
|
+
}
|
|
659
|
+
if (!sceneData.version) {
|
|
660
|
+
missing.push('No version information');
|
|
661
|
+
}
|
|
662
|
+
return missing;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Generate import warnings for potential issues
|
|
667
|
+
* @param {Object} sceneData - The imported scene data
|
|
668
|
+
* @returns {Array} Array of warning messages
|
|
669
|
+
*/
|
|
670
|
+
}, {
|
|
671
|
+
key: "generateImportWarnings",
|
|
672
|
+
value: function generateImportWarnings(sceneData) {
|
|
673
|
+
var _sceneData$scene4, _sceneData$connection2;
|
|
674
|
+
var warnings = [];
|
|
675
|
+
|
|
676
|
+
// Check for large scene data
|
|
677
|
+
var componentsCount = ((_sceneData$scene4 = sceneData.scene) === null || _sceneData$scene4 === void 0 || (_sceneData$scene4 = _sceneData$scene4.object) === null || _sceneData$scene4 === void 0 || (_sceneData$scene4 = _sceneData$scene4.children) === null || _sceneData$scene4 === void 0 ? void 0 : _sceneData$scene4.length) || 0;
|
|
678
|
+
if (componentsCount > 100) {
|
|
679
|
+
warnings.push("Large scene detected (".concat(componentsCount, " components) - may impact performance"));
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// Check for orphaned components (components without connections)
|
|
683
|
+
var connectionsCount = ((_sceneData$connection2 = sceneData.connections) === null || _sceneData$connection2 === void 0 ? void 0 : _sceneData$connection2.length) || 0;
|
|
684
|
+
if (componentsCount > 0 && connectionsCount === 0) {
|
|
685
|
+
warnings.push('Components found but no connections - scene may be incomplete');
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// Check for version compatibility
|
|
689
|
+
if (sceneData.version && parseFloat(sceneData.version) < 1.0) {
|
|
690
|
+
warnings.push('Scene data version is older than current - some features may not work correctly');
|
|
691
|
+
}
|
|
692
|
+
return warnings;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Estimate memory usage of imported scene data
|
|
697
|
+
* @param {Object} sceneData - The imported scene data
|
|
698
|
+
* @returns {Object} Memory usage estimate
|
|
699
|
+
*/
|
|
700
|
+
}, {
|
|
701
|
+
key: "estimateMemoryUsage",
|
|
702
|
+
value: function estimateMemoryUsage(sceneData) {
|
|
703
|
+
var jsonSize = JSON.stringify(sceneData).length;
|
|
704
|
+
var estimatedMB = (jsonSize / 1024 / 1024).toFixed(2);
|
|
705
|
+
return {
|
|
706
|
+
jsonSizeBytes: jsonSize,
|
|
707
|
+
estimatedMB: parseFloat(estimatedMB),
|
|
708
|
+
category: estimatedMB < 1 ? 'small' : estimatedMB < 10 ? 'medium' : 'large'
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Update specific metadata category
|
|
714
|
+
* @param {string} category - The metadata category (e.g., 'sceneInfo', 'projectSettings')
|
|
715
|
+
* @param {Object} updates - The updates to apply to the category
|
|
716
|
+
*/
|
|
717
|
+
}, {
|
|
718
|
+
key: "updateMetadataCategory",
|
|
719
|
+
value: function updateMetadataCategory(category, updates) {
|
|
720
|
+
if (this.hasMetadata(category)) {
|
|
721
|
+
var existing = this.getMetadata(category);
|
|
722
|
+
this.setMetadata(category, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, existing), updates));
|
|
723
|
+
} else {
|
|
724
|
+
this.setMetadata(category, updates);
|
|
725
|
+
}
|
|
726
|
+
console.log("\uD83D\uDCDD Metadata category '".concat(category, "' updated:"), updates);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Undo the last transform operation
|
|
731
|
+
* @returns {boolean} True if undo was successful, false otherwise
|
|
732
|
+
*/
|
|
733
|
+
}, {
|
|
734
|
+
key: "undoTransform",
|
|
735
|
+
value: function undoTransform() {
|
|
736
|
+
var lastTransform = this.getLastTransform();
|
|
737
|
+
if (!lastTransform) {
|
|
738
|
+
console.warn('โ ๏ธ No transform to undo');
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
console.log('๐ Undoing transform:', lastTransform);
|
|
742
|
+
try {
|
|
743
|
+
var _this$sceneViewer;
|
|
744
|
+
var object = lastTransform.object,
|
|
745
|
+
type = lastTransform.type,
|
|
746
|
+
previousValues = lastTransform.previousValues;
|
|
747
|
+
if (!object || !previousValues) {
|
|
748
|
+
console.error('โ Invalid transform data for undo');
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// Debug current state before undo
|
|
753
|
+
this.debugTransformState(object, 'Before Undo');
|
|
754
|
+
|
|
755
|
+
// Debug the structure of previousValues
|
|
756
|
+
console.log('๐ previousValues structure:', {
|
|
757
|
+
type: _rollupPluginBabelHelpers["typeof"](previousValues),
|
|
758
|
+
keys: Object.keys(previousValues || {}),
|
|
759
|
+
values: previousValues,
|
|
760
|
+
hasPosition: !!(previousValues && previousValues.position),
|
|
761
|
+
hasRotation: !!(previousValues && previousValues.rotation),
|
|
762
|
+
hasScale: !!(previousValues && previousValues.scale),
|
|
763
|
+
hasDirectXYZ: !!(previousValues && (previousValues.x !== undefined || previousValues.y !== undefined || previousValues.z !== undefined))
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// Verify the object still exists in the scene
|
|
767
|
+
if (this.sceneViewer && this.sceneViewer.scene) {
|
|
768
|
+
var objectFound = false;
|
|
769
|
+
this.sceneViewer.scene.traverse(function (child) {
|
|
770
|
+
if (child === object) {
|
|
771
|
+
objectFound = true;
|
|
772
|
+
console.log("undoTransform object:", object);
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
if (!objectFound) {
|
|
776
|
+
console.error('โ Object no longer exists in scene, cannot undo');
|
|
777
|
+
return false;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// Apply the previous values based on transform type
|
|
782
|
+
switch (type) {
|
|
783
|
+
case 'translate':
|
|
784
|
+
case 'position':
|
|
785
|
+
console.log('๐ undoTransform - Undoing position transform:', {
|
|
786
|
+
current: {
|
|
787
|
+
x: object.position.x,
|
|
788
|
+
y: object.position.y,
|
|
789
|
+
z: object.position.z
|
|
790
|
+
},
|
|
791
|
+
restoring: previousValues,
|
|
792
|
+
restoringPosition: previousValues.position
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
// Check if previousValues has position property (Vector3) or direct x,y,z properties
|
|
796
|
+
if (previousValues.position) {
|
|
797
|
+
// Handle Vector3 object
|
|
798
|
+
if (previousValues.position.x !== undefined) object.position.x = previousValues.position.x;
|
|
799
|
+
if (previousValues.position.y !== undefined) object.position.y = previousValues.position.y;
|
|
800
|
+
if (previousValues.position.z !== undefined) object.position.z = previousValues.position.z;
|
|
801
|
+
} else {
|
|
802
|
+
// Handle direct x,y,z properties
|
|
803
|
+
if (previousValues.x !== undefined) object.position.x = previousValues.x;
|
|
804
|
+
if (previousValues.y !== undefined) object.position.y = previousValues.y;
|
|
805
|
+
if (previousValues.z !== undefined) object.position.z = previousValues.z;
|
|
806
|
+
}
|
|
807
|
+
console.log('โ
undoTransform - Position restored to:', {
|
|
808
|
+
x: object.position.x,
|
|
809
|
+
y: object.position.y,
|
|
810
|
+
z: object.position.z
|
|
811
|
+
});
|
|
812
|
+
break;
|
|
813
|
+
case 'rotate':
|
|
814
|
+
case 'rotation':
|
|
815
|
+
console.log('๐ Undoing rotation transform:', {
|
|
816
|
+
current: {
|
|
817
|
+
x: object.rotation.x,
|
|
818
|
+
y: object.rotation.y,
|
|
819
|
+
z: object.rotation.z
|
|
820
|
+
},
|
|
821
|
+
restoring: previousValues,
|
|
822
|
+
restoringRotation: previousValues.rotation
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
// Check if previousValues has rotation property (Euler) or direct x,y,z properties
|
|
826
|
+
if (previousValues.rotation) {
|
|
827
|
+
// Handle Euler object
|
|
828
|
+
if (previousValues.rotation.x !== undefined) object.rotation.x = previousValues.rotation.x;
|
|
829
|
+
if (previousValues.rotation.y !== undefined) object.rotation.y = previousValues.rotation.y;
|
|
830
|
+
if (previousValues.rotation.z !== undefined) object.rotation.z = previousValues.rotation.z;
|
|
831
|
+
} else {
|
|
832
|
+
// Handle direct x,y,z properties
|
|
833
|
+
if (previousValues.x !== undefined) object.rotation.x = previousValues.x;
|
|
834
|
+
if (previousValues.y !== undefined) object.rotation.y = previousValues.y;
|
|
835
|
+
if (previousValues.z !== undefined) object.rotation.z = previousValues.z;
|
|
836
|
+
}
|
|
837
|
+
console.log('โ
Rotation restored to:', {
|
|
838
|
+
x: object.rotation.x,
|
|
839
|
+
y: object.rotation.y,
|
|
840
|
+
z: object.rotation.z
|
|
841
|
+
});
|
|
842
|
+
break;
|
|
843
|
+
case 'scale':
|
|
844
|
+
console.log('๐ Undoing scale transform:', {
|
|
845
|
+
current: {
|
|
846
|
+
x: object.scale.x,
|
|
847
|
+
y: object.scale.y,
|
|
848
|
+
z: object.scale.z
|
|
849
|
+
},
|
|
850
|
+
restoring: previousValues,
|
|
851
|
+
restoringScale: previousValues.scale
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// Check if previousValues has scale property (Vector3) or direct x,y,z properties
|
|
855
|
+
if (previousValues.scale) {
|
|
856
|
+
// Handle Vector3 object
|
|
857
|
+
if (previousValues.scale.x !== undefined) object.scale.x = previousValues.scale.x;
|
|
858
|
+
if (previousValues.scale.y !== undefined) object.scale.y = previousValues.scale.y;
|
|
859
|
+
if (previousValues.scale.z !== undefined) object.scale.z = previousValues.scale.z;
|
|
860
|
+
} else {
|
|
861
|
+
// Handle direct x,y,z properties
|
|
862
|
+
if (previousValues.x !== undefined) object.scale.x = previousValues.x;
|
|
863
|
+
if (previousValues.y !== undefined) object.scale.y = previousValues.y;
|
|
864
|
+
if (previousValues.z !== undefined) object.scale.z = previousValues.z;
|
|
865
|
+
}
|
|
866
|
+
console.log('โ
Scale restored to:', {
|
|
867
|
+
x: object.scale.x,
|
|
868
|
+
y: object.scale.y,
|
|
869
|
+
z: object.scale.z
|
|
870
|
+
});
|
|
871
|
+
break;
|
|
872
|
+
default:
|
|
873
|
+
console.warn("\u26A0\uFE0F Unknown transform type for undo: ".concat(type));
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// Force update the object's matrix to ensure transforms are properly applied
|
|
878
|
+
object.updateMatrix();
|
|
879
|
+
object.updateMatrixWorld(true);
|
|
880
|
+
|
|
881
|
+
// Get the transform controls manager reference
|
|
882
|
+
var transformManager = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.transformManager;
|
|
883
|
+
|
|
884
|
+
// Update transform controls if they exist and are attached to this object
|
|
885
|
+
if (transformManager && transformManager.transformControls) {
|
|
886
|
+
var transformControls = transformManager.transformControls;
|
|
887
|
+
|
|
888
|
+
// Check if the object is currently selected
|
|
889
|
+
var isCurrentlySelected = transformControls.object === object;
|
|
890
|
+
if (isCurrentlySelected) {
|
|
891
|
+
console.log('๐ง Updating transform controls after undo');
|
|
892
|
+
|
|
893
|
+
// Temporarily detach to force a clean reattachment
|
|
894
|
+
transformControls.detach();
|
|
895
|
+
|
|
896
|
+
// Ensure the transform controls are properly attached to the scene
|
|
897
|
+
if (transformManager.ensureSceneAttachment) {
|
|
898
|
+
transformManager.ensureSceneAttachment(true);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// Reattach to the object
|
|
902
|
+
transformControls.attach(object);
|
|
903
|
+
|
|
904
|
+
// Update the transform manager's selected object state
|
|
905
|
+
transformManager.selectedObject = object;
|
|
906
|
+
|
|
907
|
+
// Refresh the bounding box if it exists
|
|
908
|
+
if (transformManager.updateBoundingBox) {
|
|
909
|
+
transformManager.updateBoundingBox();
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// Clear any cached bounding box data for this object
|
|
913
|
+
if (transformManager.boundingBoxCache && transformManager.boundingBoxCache.has(object)) {
|
|
914
|
+
transformManager.boundingBoxCache.delete(object);
|
|
915
|
+
}
|
|
916
|
+
console.log('โ
Transform controls successfully updated after undo');
|
|
917
|
+
} else {
|
|
918
|
+
console.log('๐ Object not currently selected by transform controls');
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// Notify SceneOperationsManager about the transform change
|
|
923
|
+
if (this.sceneViewer && this.sceneViewer.sceneOperationsManager && this.sceneViewer.currentSceneData) {
|
|
924
|
+
try {
|
|
925
|
+
console.log('๐ Updating scene data after undo');
|
|
926
|
+
this.sceneViewer.onTransformEnd(object);
|
|
927
|
+
// this.sceneViewer.sceneOperationsManager.updateSceneDataAfterTransform(object, this.sceneViewer.currentSceneData)
|
|
928
|
+
} catch (sceneOpsError) {
|
|
929
|
+
console.warn('โ ๏ธ Error updating scene operations after undo:', sceneOpsError);
|
|
930
|
+
// Continue with undo operation even if scene operations update fails
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// Dispatch scene update events if available
|
|
935
|
+
if (typeof window !== 'undefined') {
|
|
936
|
+
var sceneUpdateEvent = new CustomEvent('sceneUpdateComplete', {
|
|
937
|
+
detail: {
|
|
938
|
+
timestamp: Date.now(),
|
|
939
|
+
action: 'undo-transform',
|
|
940
|
+
objectId: object.uuid || object.id || 'unknown'
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
window.dispatchEvent(sceneUpdateEvent);
|
|
944
|
+
console.log('๐ก Scene update event dispatched after undo');
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// Clear the transform history since we've undone it
|
|
948
|
+
this.clearTransformHistory();
|
|
949
|
+
|
|
950
|
+
// Ensure object is selectable after undo
|
|
951
|
+
this.ensureObjectSelectable(object);
|
|
952
|
+
|
|
953
|
+
// Debug final state after undo
|
|
954
|
+
this.debugTransformState(object, 'After Undo');
|
|
955
|
+
|
|
956
|
+
// Log success
|
|
957
|
+
console.log('โ
Transform undone successfully', {
|
|
958
|
+
type: type,
|
|
959
|
+
objectId: object.uuid || object.id || 'unknown',
|
|
960
|
+
restoredValues: previousValues,
|
|
961
|
+
matrixUpdated: true,
|
|
962
|
+
transformControlsUpdated: !!(this.sceneViewer && this.sceneViewer.transformManager),
|
|
963
|
+
sceneRerendered: !!(this.sceneViewer && this.sceneViewer.renderer)
|
|
964
|
+
});
|
|
965
|
+
return true;
|
|
966
|
+
} catch (error) {
|
|
967
|
+
console.error('โ Error undoing transform:', error);
|
|
968
|
+
return false;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Ensure object is properly selectable after undo operation
|
|
974
|
+
* This method addresses issues where transform controls become unresponsive
|
|
975
|
+
* @param {Object} object - The Three.js object to ensure is selectable
|
|
976
|
+
* @returns {boolean} True if object selection was refreshed successfully
|
|
977
|
+
*/
|
|
978
|
+
}, {
|
|
979
|
+
key: "ensureObjectSelectable",
|
|
980
|
+
value: function ensureObjectSelectable(object) {
|
|
981
|
+
if (!object || !this.sceneViewer) {
|
|
982
|
+
console.warn('โ ๏ธ Cannot ensure object selectable: missing object or scene viewer');
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
try {
|
|
986
|
+
var transformManager = this.sceneViewer.transformManager;
|
|
987
|
+
if (!transformManager) {
|
|
988
|
+
console.warn('โ ๏ธ Transform manager not available');
|
|
989
|
+
return false;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// Use the recovery method in transform controls manager
|
|
993
|
+
if (transformManager.recoverTransformControls) {
|
|
994
|
+
console.log('๐ Using transform controls recovery method');
|
|
995
|
+
return transformManager.recoverTransformControls(object);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// Fallback to original method if recovery method not available
|
|
999
|
+
console.log('โ ๏ธ Recovery method not available, using fallback');
|
|
1000
|
+
|
|
1001
|
+
// Force update the object's world matrix
|
|
1002
|
+
object.updateMatrixWorld(true);
|
|
1003
|
+
|
|
1004
|
+
// Clear any cached bounding box data for this object
|
|
1005
|
+
if (transformManager.boundingBoxCache && transformManager.boundingBoxCache.has(object)) {
|
|
1006
|
+
transformManager.boundingBoxCache.delete(object);
|
|
1007
|
+
console.log('๐งน Cleared bounding box cache for object');
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// Ensure transform controls are properly attached to the scene
|
|
1011
|
+
if (transformManager.ensureSceneAttachment) {
|
|
1012
|
+
transformManager.ensureSceneAttachment(true);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// If this object is currently selected, refresh the selection
|
|
1016
|
+
if (transformManager.selectedObject === object) {
|
|
1017
|
+
console.log('๐ Refreshing object selection after undo');
|
|
1018
|
+
|
|
1019
|
+
// Temporarily deselect
|
|
1020
|
+
transformManager.deselectObject();
|
|
1021
|
+
|
|
1022
|
+
// Wait a frame to ensure state is clean
|
|
1023
|
+
requestAnimationFrame(function () {
|
|
1024
|
+
// Reselect the object
|
|
1025
|
+
transformManager.selectObjectForTransformOnly(object);
|
|
1026
|
+
console.log('โ
Object selection refreshed successfully');
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
return true;
|
|
1030
|
+
} catch (error) {
|
|
1031
|
+
console.error('โ Error ensuring object selectable:', error);
|
|
1032
|
+
return false;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Debug method to log current transform state of an object
|
|
1038
|
+
* @param {Object} object - The Three.js object to debug
|
|
1039
|
+
* @param {string} context - Context string for logging
|
|
1040
|
+
*/
|
|
1041
|
+
}, {
|
|
1042
|
+
key: "debugTransformState",
|
|
1043
|
+
value: function debugTransformState(object) {
|
|
1044
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Debug';
|
|
1045
|
+
if (!object) {
|
|
1046
|
+
console.log("\uD83D\uDD0D ".concat(context, ": No object provided"));
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
console.log("\uD83D\uDD0D ".concat(context, " - Object Transform State:"), {
|
|
1050
|
+
objectId: object.uuid || object.id || 'unknown',
|
|
1051
|
+
position: {
|
|
1052
|
+
x: object.position.x,
|
|
1053
|
+
y: object.position.y,
|
|
1054
|
+
z: object.position.z
|
|
1055
|
+
},
|
|
1056
|
+
rotation: {
|
|
1057
|
+
x: object.rotation.x,
|
|
1058
|
+
y: object.rotation.y,
|
|
1059
|
+
z: object.rotation.z
|
|
1060
|
+
},
|
|
1061
|
+
scale: {
|
|
1062
|
+
x: object.scale.x,
|
|
1063
|
+
y: object.scale.y,
|
|
1064
|
+
z: object.scale.z
|
|
1065
|
+
},
|
|
1066
|
+
matrixWorldNeedsUpdate: object.matrixWorldNeedsUpdate,
|
|
1067
|
+
visible: object.visible,
|
|
1068
|
+
parent: object.parent ? object.parent.uuid || object.parent.id || 'unknown' : 'none',
|
|
1069
|
+
inScene: this.sceneViewer && this.sceneViewer.scene ? this.isObjectInScene(object) : 'unknown'
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* Manual fix for when transform controls become unresponsive
|
|
1075
|
+
* Call this method if you can't select objects after undo
|
|
1076
|
+
* @returns {boolean} True if fix was attempted
|
|
1077
|
+
*/
|
|
1078
|
+
}, {
|
|
1079
|
+
key: "fixTransformControlsSelection",
|
|
1080
|
+
value: function fixTransformControlsSelection() {
|
|
1081
|
+
if (!this.sceneViewer || !this.sceneViewer.transformManager) {
|
|
1082
|
+
console.warn('โ ๏ธ Cannot fix transform controls: missing scene viewer or transform manager');
|
|
1083
|
+
return false;
|
|
1084
|
+
}
|
|
1085
|
+
var transformManager = this.sceneViewer.transformManager;
|
|
1086
|
+
console.log('๐ง Manually fixing transform controls selection...');
|
|
1087
|
+
|
|
1088
|
+
// Try to recover the transform controls
|
|
1089
|
+
if (transformManager.recoverTransformControls) {
|
|
1090
|
+
var result = transformManager.recoverTransformControls();
|
|
1091
|
+
if (result) {
|
|
1092
|
+
console.log('โ
Transform controls manually fixed');
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// Fallback: Force recreate the entire transform controls system
|
|
1098
|
+
try {
|
|
1099
|
+
console.log('๐ Attempting to recreate transform controls system...');
|
|
1100
|
+
|
|
1101
|
+
// Store current settings
|
|
1102
|
+
var currentMode = transformManager.currentMode;
|
|
1103
|
+
var currentSpace = transformManager.currentSpace;
|
|
1104
|
+
|
|
1105
|
+
// Dispose existing controls
|
|
1106
|
+
if (transformManager.transformControls) {
|
|
1107
|
+
transformManager.transformControls.detach();
|
|
1108
|
+
transformManager.scene.remove(transformManager.transformControls);
|
|
1109
|
+
transformManager.transformControls.dispose();
|
|
1110
|
+
transformManager.transformControls = null;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// Recreate controls
|
|
1114
|
+
transformManager.createTransformControls();
|
|
1115
|
+
transformManager.setupEventListeners();
|
|
1116
|
+
|
|
1117
|
+
// Restore settings
|
|
1118
|
+
transformManager.setMode(currentMode);
|
|
1119
|
+
transformManager.setSpace(currentSpace);
|
|
1120
|
+
console.log('โ
Transform controls system recreated successfully');
|
|
1121
|
+
return true;
|
|
1122
|
+
} catch (error) {
|
|
1123
|
+
console.error('โ Error recreating transform controls:', error);
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Check if an object is in the scene
|
|
1130
|
+
* @param {Object} object - The Three.js object to check
|
|
1131
|
+
* @returns {boolean} True if object is in scene
|
|
1132
|
+
*/
|
|
1133
|
+
}, {
|
|
1134
|
+
key: "isObjectInScene",
|
|
1135
|
+
value: function isObjectInScene(object) {
|
|
1136
|
+
if (!this.sceneViewer || !this.sceneViewer.scene) return false;
|
|
1137
|
+
var found = false;
|
|
1138
|
+
this.sceneViewer.scene.traverse(function (child) {
|
|
1139
|
+
if (child === object) {
|
|
1140
|
+
found = true;
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
return found;
|
|
1144
|
+
}
|
|
1145
|
+
}]);
|
|
1146
|
+
}();
|
|
1147
|
+
|
|
1148
|
+
exports.CentralPlant = CentralPlant;
|
|
1149
|
+
exports["default"] = CentralPlant;
|