@2112-lab/central-plant 0.1.0
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/README.md +0 -0
- package/dist/bundle/index.js +14259 -0
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +353 -0
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1292 -0
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1543 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4374 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +465 -0
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +117 -0
- package/dist/cjs/src/ConnectionManager.js +114 -0
- package/dist/cjs/src/Pathfinder.js +88 -0
- package/dist/cjs/src/animationManager.js +121 -0
- package/dist/cjs/src/componentManager.js +151 -0
- package/dist/cjs/src/debugLogger.js +176 -0
- package/dist/cjs/src/disposalManager.js +185 -0
- package/dist/cjs/src/environmentManager.js +1015 -0
- package/dist/cjs/src/hotReloadManager.js +252 -0
- package/dist/cjs/src/index.js +126 -0
- package/dist/cjs/src/keyboardControlsManager.js +206 -0
- package/dist/cjs/src/modelPreloader.js +360 -0
- package/dist/cjs/src/nameUtils.js +106 -0
- package/dist/cjs/src/pathfindingManager.js +321 -0
- package/dist/cjs/src/performanceMonitor.js +718 -0
- package/dist/cjs/src/sceneExportManager.js +292 -0
- package/dist/cjs/src/sceneInitializationManager.js +540 -0
- package/dist/cjs/src/sceneOperationsManager.js +560 -0
- package/dist/cjs/src/textureConfig.js +195 -0
- package/dist/cjs/src/transformControlsManager.js +851 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +328 -0
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1287 -0
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1537 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4370 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +461 -0
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +113 -0
- package/dist/esm/src/ConnectionManager.js +110 -0
- package/dist/esm/src/Pathfinder.js +84 -0
- package/dist/esm/src/animationManager.js +112 -0
- package/dist/esm/src/componentManager.js +123 -0
- package/dist/esm/src/debugLogger.js +167 -0
- package/dist/esm/src/disposalManager.js +155 -0
- package/dist/esm/src/environmentManager.js +989 -0
- package/dist/esm/src/hotReloadManager.js +244 -0
- package/dist/esm/src/index.js +117 -0
- package/dist/esm/src/keyboardControlsManager.js +196 -0
- package/dist/esm/src/modelPreloader.js +337 -0
- package/dist/esm/src/nameUtils.js +99 -0
- package/dist/esm/src/pathfindingManager.js +295 -0
- package/dist/esm/src/performanceMonitor.js +712 -0
- package/dist/esm/src/sceneExportManager.js +286 -0
- package/dist/esm/src/sceneInitializationManager.js +513 -0
- package/dist/esm/src/sceneOperationsManager.js +536 -0
- package/dist/esm/src/textureConfig.js +168 -0
- package/dist/esm/src/transformControlsManager.js +827 -0
- package/dist/index.d.ts +259 -0
- package/package.json +53 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { createClass as _createClass, classCallCheck as _classCallCheck, toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { getHardcodedUuid } from './nameUtils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Class for managing scene export operations
|
|
6
|
+
*/
|
|
7
|
+
var SceneExportManager = /*#__PURE__*/function () {
|
|
8
|
+
/**
|
|
9
|
+
* Create a SceneExportManager
|
|
10
|
+
* @param {Object} componentInstance - The component instance containing scene data
|
|
11
|
+
*/
|
|
12
|
+
function SceneExportManager(componentInstance) {
|
|
13
|
+
_classCallCheck(this, SceneExportManager);
|
|
14
|
+
this.component = componentInstance;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Export function that recreates the JSON data structure from current scene objects
|
|
19
|
+
* @returns {Object|null} The exported scene data as JSON object or null if export failed
|
|
20
|
+
*/
|
|
21
|
+
return _createClass(SceneExportManager, [{
|
|
22
|
+
key: "exportSceneData",
|
|
23
|
+
value: function exportSceneData() {
|
|
24
|
+
var _this = this;
|
|
25
|
+
console.log('📤 Starting scene export...');
|
|
26
|
+
if (!this.component.scene) {
|
|
27
|
+
console.warn('⚠️ No scene available for export');
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Helper function to extract connections from pathfinder or scene analysis
|
|
32
|
+
var extractConnections = function extractConnections() {
|
|
33
|
+
var _this$component$curre;
|
|
34
|
+
var connections = [];
|
|
35
|
+
|
|
36
|
+
// If we have the original connections from currentSceneData, use those as base
|
|
37
|
+
if ((_this$component$curre = _this.component.currentSceneData) !== null && _this$component$curre !== void 0 && _this$component$curre.connections) {
|
|
38
|
+
connections.push.apply(connections, _toConsumableArray(_this.component.currentSceneData.connections));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// If no currentSceneData, we'll return empty connections array
|
|
42
|
+
// This allows export to work even for default scenes that haven't been imported
|
|
43
|
+
return connections;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Helper function to convert Three.js object to JSON format
|
|
47
|
+
var _convertObjectToJson = function convertObjectToJson(threeObject) {
|
|
48
|
+
var _threeObject$name, _threeObject$userData, _threeObject$userData2, _threeObject$userData3, _threeObject$userData4, _threeObject$userData5, _threeObject$userData6, _threeObject$userData8;
|
|
49
|
+
var isChild = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
50
|
+
// Skip certain objects that shouldn't be exported
|
|
51
|
+
if (!threeObject || (_threeObject$name = threeObject.name) !== null && _threeObject$name !== void 0 && _threeObject$name.includes('Polyline') || // Skip pipe paths
|
|
52
|
+
(_threeObject$userData = threeObject.userData) !== null && _threeObject$userData !== void 0 && _threeObject$userData.isBrickWall || // Skip environment
|
|
53
|
+
(_threeObject$userData2 = threeObject.userData) !== null && _threeObject$userData2 !== void 0 && _threeObject$userData2.isBaseGround || // Skip environment
|
|
54
|
+
(_threeObject$userData3 = threeObject.userData) !== null && _threeObject$userData3 !== void 0 && _threeObject$userData3.isBaseGrid ||
|
|
55
|
+
// Skip environment
|
|
56
|
+
threeObject.isLight || // Skip lights
|
|
57
|
+
(_threeObject$userData4 = threeObject.userData) !== null && _threeObject$userData4 !== void 0 && _threeObject$userData4.isTransformControls ||
|
|
58
|
+
// Skip transform controls
|
|
59
|
+
threeObject.isTransformControls ||
|
|
60
|
+
// Skip transform controls
|
|
61
|
+
threeObject.type && threeObject.type.includes('TransformControls')) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// For top-level objects, require componentType, but allow children through
|
|
66
|
+
if (!isChild && !((_threeObject$userData5 = threeObject.userData) !== null && _threeObject$userData5 !== void 0 && _threeObject$userData5.componentType)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// For child objects, only include if forExport is explicitly set to true
|
|
71
|
+
if (isChild && !((_threeObject$userData6 = threeObject.userData) !== null && _threeObject$userData6 !== void 0 && _threeObject$userData6.forExport)) {
|
|
72
|
+
var _threeObject$userData7;
|
|
73
|
+
console.log("\uD83D\uDD3D Excluding child '".concat(threeObject.name, "' from export (forExport: ").concat((_threeObject$userData7 = threeObject.userData) === null || _threeObject$userData7 === void 0 ? void 0 : _threeObject$userData7.forExport, ")"));
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Log when a child is being included in export
|
|
78
|
+
if (isChild && (_threeObject$userData8 = threeObject.userData) !== null && _threeObject$userData8 !== void 0 && _threeObject$userData8.forExport) {
|
|
79
|
+
var _threeObject$userData9;
|
|
80
|
+
console.log("\u2705 Including child '".concat(threeObject.name, "' in export (forExport: ").concat((_threeObject$userData9 = threeObject.userData) === null || _threeObject$userData9 === void 0 ? void 0 : _threeObject$userData9.forExport, ")"));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Create base JSON object with HARDCODED UUID preservation
|
|
84
|
+
var jsonObject = {
|
|
85
|
+
uuid: getHardcodedUuid(threeObject),
|
|
86
|
+
// Use utility function to get hardcoded UUID
|
|
87
|
+
name: threeObject.name || 'Unnamed Object',
|
|
88
|
+
type: threeObject.type || 'Object3D'
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Add userData if it exists (preserving libraryId and other important data)
|
|
92
|
+
if (threeObject.userData && Object.keys(threeObject.userData).length > 0) {
|
|
93
|
+
jsonObject.userData = {};
|
|
94
|
+
|
|
95
|
+
// Copy important userData properties, excluding temporary/runtime data
|
|
96
|
+
Object.keys(threeObject.userData).forEach(function (key) {
|
|
97
|
+
if (key !== 'worldBoundingBox' && key !== 'isBaseGround' && key !== 'isBrickWall' && key !== 'isBaseGrid' && key !== 'isTransformControls') {
|
|
98
|
+
jsonObject.userData[key] = threeObject.userData[key];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// If no relevant userData, remove the empty object
|
|
103
|
+
if (Object.keys(jsonObject.userData).length === 0) {
|
|
104
|
+
delete jsonObject.userData;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Add transform data - convert from radians to degrees for rotation
|
|
109
|
+
jsonObject.position = {
|
|
110
|
+
x: parseFloat(threeObject.position.x.toFixed(6)),
|
|
111
|
+
y: parseFloat(threeObject.position.y.toFixed(6)),
|
|
112
|
+
z: parseFloat(threeObject.position.z.toFixed(6))
|
|
113
|
+
};
|
|
114
|
+
jsonObject.rotation = {
|
|
115
|
+
x: parseFloat((threeObject.rotation.x * (180 / Math.PI)).toFixed(6)),
|
|
116
|
+
y: parseFloat((threeObject.rotation.y * (180 / Math.PI)).toFixed(6)),
|
|
117
|
+
z: parseFloat((threeObject.rotation.z * (180 / Math.PI)).toFixed(6))
|
|
118
|
+
};
|
|
119
|
+
jsonObject.scale = {
|
|
120
|
+
x: parseFloat(threeObject.scale.x.toFixed(6)),
|
|
121
|
+
y: parseFloat(threeObject.scale.y.toFixed(6)),
|
|
122
|
+
z: parseFloat(threeObject.scale.z.toFixed(6))
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Add geometry reference for connectors and other special objects
|
|
126
|
+
if (threeObject.geometry) {
|
|
127
|
+
var _threeObject$name2, _threeObject$name3, _threeObject$userData0;
|
|
128
|
+
if ((_threeObject$name2 = threeObject.name) !== null && _threeObject$name2 !== void 0 && _threeObject$name2.toLowerCase().includes('connector')) {
|
|
129
|
+
jsonObject.geometry = 'CONNECTOR-GEO';
|
|
130
|
+
} else if ((_threeObject$name3 = threeObject.name) !== null && _threeObject$name3 !== void 0 && _threeObject$name3.toLowerCase().includes('gateway')) {
|
|
131
|
+
jsonObject.geometry = 'GATEWAY-GEO';
|
|
132
|
+
} else if ((_threeObject$userData0 = threeObject.userData) !== null && _threeObject$userData0 !== void 0 && _threeObject$userData0.libraryId) {
|
|
133
|
+
// For library objects, use a standard geometry reference
|
|
134
|
+
jsonObject.geometry = "".concat(threeObject.userData.libraryId, "-GEO");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Process children recursively
|
|
139
|
+
if (threeObject.children && threeObject.children.length > 0) {
|
|
140
|
+
var validChildren = [];
|
|
141
|
+
threeObject.children.forEach(function (child) {
|
|
142
|
+
var childJson = _convertObjectToJson(child, true);
|
|
143
|
+
if (childJson) {
|
|
144
|
+
validChildren.push(childJson);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (validChildren.length > 0) {
|
|
148
|
+
jsonObject.children = validChildren;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return jsonObject;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Extract main scene objects (excluding environment and utility objects)
|
|
155
|
+
var sceneChildren = [];
|
|
156
|
+
this.component.scene.children.forEach(function (child) {
|
|
157
|
+
var jsonChild = _convertObjectToJson(child);
|
|
158
|
+
if (jsonChild) {
|
|
159
|
+
sceneChildren.push(jsonChild);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Build the complete export data structure
|
|
164
|
+
var exportData = {
|
|
165
|
+
connections: extractConnections(),
|
|
166
|
+
scene: {
|
|
167
|
+
object: {
|
|
168
|
+
uuid: 'PLANT-SCENE',
|
|
169
|
+
name: 'Scene',
|
|
170
|
+
type: 'Scene',
|
|
171
|
+
children: sceneChildren
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Add metadata for tracking
|
|
177
|
+
exportData._metadata = {
|
|
178
|
+
exportedAt: new Date().toISOString(),
|
|
179
|
+
exportedFrom: 'SceneViewerEnhanced',
|
|
180
|
+
version: '1.0.0',
|
|
181
|
+
objectCount: sceneChildren.length
|
|
182
|
+
};
|
|
183
|
+
console.log('✅ Scene export completed:', exportData);
|
|
184
|
+
return exportData;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Helper function to download the exported scene data as JSON file
|
|
189
|
+
* @param {string} filename - Optional filename for the export
|
|
190
|
+
* @returns {boolean} Success status of the download operation
|
|
191
|
+
*/
|
|
192
|
+
}, {
|
|
193
|
+
key: "downloadSceneExport",
|
|
194
|
+
value: function downloadSceneExport() {
|
|
195
|
+
var filename = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
196
|
+
var exportData = this.exportSceneData();
|
|
197
|
+
if (!exportData) {
|
|
198
|
+
console.error('❌ Failed to export scene data');
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Generate filename if not provided
|
|
203
|
+
if (!filename) {
|
|
204
|
+
filename = "cp-export.json";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Create and download the file
|
|
208
|
+
try {
|
|
209
|
+
var jsonString = JSON.stringify(exportData, null, 2);
|
|
210
|
+
|
|
211
|
+
// Check if we're in a browser environment
|
|
212
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
213
|
+
var blob = new Blob([jsonString], {
|
|
214
|
+
type: 'application/json'
|
|
215
|
+
});
|
|
216
|
+
var url = URL.createObjectURL(blob);
|
|
217
|
+
var link = document.createElement('a');
|
|
218
|
+
link.href = url;
|
|
219
|
+
link.download = filename;
|
|
220
|
+
document.body.appendChild(link);
|
|
221
|
+
link.click();
|
|
222
|
+
document.body.removeChild(link);
|
|
223
|
+
URL.revokeObjectURL(url);
|
|
224
|
+
console.log("\uD83D\uDCC1 Scene exported successfully as: ".concat(filename));
|
|
225
|
+
return true;
|
|
226
|
+
} else {
|
|
227
|
+
console.warn('⚠️ Download functionality requires browser environment');
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.error('❌ Error downloading scene export:', error);
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Export scene data as JSON string
|
|
238
|
+
* @param {boolean} pretty - Whether to format the JSON with indentation
|
|
239
|
+
* @returns {string|null} JSON string or null if export failed
|
|
240
|
+
*/
|
|
241
|
+
}, {
|
|
242
|
+
key: "exportSceneDataAsString",
|
|
243
|
+
value: function exportSceneDataAsString() {
|
|
244
|
+
var pretty = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
245
|
+
var exportData = this.exportSceneData();
|
|
246
|
+
if (!exportData) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
return pretty ? JSON.stringify(exportData, null, 2) : JSON.stringify(exportData);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get export metadata
|
|
254
|
+
* @returns {Object|null} Export metadata or null if scene is not available
|
|
255
|
+
*/
|
|
256
|
+
}, {
|
|
257
|
+
key: "getExportMetadata",
|
|
258
|
+
value: function getExportMetadata() {
|
|
259
|
+
var _this$component$curre2;
|
|
260
|
+
if (!this.component.scene) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
var objectCount = 0;
|
|
264
|
+
this.component.scene.traverse(function () {
|
|
265
|
+
return objectCount++;
|
|
266
|
+
});
|
|
267
|
+
return {
|
|
268
|
+
totalObjects: objectCount,
|
|
269
|
+
hasCurrentSceneData: !!this.component.currentSceneData,
|
|
270
|
+
connectionsCount: ((_this$component$curre2 = this.component.currentSceneData) === null || _this$component$curre2 === void 0 || (_this$component$curre2 = _this$component$curre2.connections) === null || _this$component$curre2 === void 0 ? void 0 : _this$component$curre2.length) || 0,
|
|
271
|
+
exportTimestamp: new Date().toISOString()
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}]);
|
|
275
|
+
}();
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Factory function to get SceneExportManager instance
|
|
279
|
+
* @param {CentralPlantComponent} component - The component instance
|
|
280
|
+
* @returns {SceneExportManager} SceneExportManager instance
|
|
281
|
+
*/
|
|
282
|
+
function getSceneExportManager(component) {
|
|
283
|
+
return new SceneExportManager(component);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export { SceneExportManager, SceneExportManager as default, getSceneExportManager };
|