@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,716 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
require('three');
|
|
7
|
+
var GLTFExporter = require('../../node_modules/three/examples/jsm/exporters/GLTFExporter.js');
|
|
8
|
+
var OBJExporter = require('../../node_modules/three/examples/jsm/exporters/OBJExporter.js');
|
|
9
|
+
var STLExporter = require('../../node_modules/three/examples/jsm/exporters/STLExporter.js');
|
|
10
|
+
var PLYExporter = require('../../node_modules/three/examples/jsm/exporters/PLYExporter.js');
|
|
11
|
+
var debugLogger = require('../core/debugLogger.js');
|
|
12
|
+
|
|
13
|
+
var Export = /*#__PURE__*/function () {
|
|
14
|
+
function Export() {
|
|
15
|
+
_rollupPluginBabelHelpers.classCallCheck(this, Export);
|
|
16
|
+
this.exporters = {
|
|
17
|
+
gltf: new GLTFExporter.GLTFExporter(),
|
|
18
|
+
obj: new OBJExporter.OBJExporter(),
|
|
19
|
+
stl: new STLExporter.STLExporter(),
|
|
20
|
+
ply: new PLYExporter.PLYExporter()
|
|
21
|
+
};
|
|
22
|
+
this.supportedFormats = {
|
|
23
|
+
models: ['gltf', 'glb', 'obj', 'stl', 'ply', 'dae'],
|
|
24
|
+
scenes: ['json'],
|
|
25
|
+
images: ['png', 'jpg', 'jpeg', 'webp'],
|
|
26
|
+
data: ['json', 'csv', 'xml']
|
|
27
|
+
};
|
|
28
|
+
this.exportHistory = [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Export 3D model in various formats
|
|
33
|
+
* @param {THREE.Object3D} object - Object to export
|
|
34
|
+
* @param {string} format - Export format
|
|
35
|
+
* @param {Object} options - Export options
|
|
36
|
+
* @returns {Promise<Object>} Export result
|
|
37
|
+
*/
|
|
38
|
+
return _rollupPluginBabelHelpers.createClass(Export, [{
|
|
39
|
+
key: "exportModel",
|
|
40
|
+
value: (function () {
|
|
41
|
+
var _exportModel = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee(object, format) {
|
|
42
|
+
var options,
|
|
43
|
+
startTime,
|
|
44
|
+
result,
|
|
45
|
+
exportOptions,
|
|
46
|
+
exportTime,
|
|
47
|
+
exportRecord,
|
|
48
|
+
_exportTime,
|
|
49
|
+
_exportRecord,
|
|
50
|
+
_args = arguments,
|
|
51
|
+
_t,
|
|
52
|
+
_t2;
|
|
53
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
54
|
+
while (1) switch (_context.n) {
|
|
55
|
+
case 0:
|
|
56
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
57
|
+
startTime = performance.now();
|
|
58
|
+
debugLogger.logger.info("\uD83D\uDD04 Exporting model to ".concat(format.toUpperCase(), "..."));
|
|
59
|
+
_context.p = 1;
|
|
60
|
+
exportOptions = _rollupPluginBabelHelpers.objectSpread2({
|
|
61
|
+
binary: format === 'glb',
|
|
62
|
+
embedImages: true,
|
|
63
|
+
includeCustomExtensions: false
|
|
64
|
+
}, options);
|
|
65
|
+
_t = format.toLowerCase();
|
|
66
|
+
_context.n = _t === 'gltf' ? 2 : _t === 'glb' ? 2 : _t === 'obj' ? 4 : _t === 'stl' ? 6 : 8;
|
|
67
|
+
break;
|
|
68
|
+
case 2:
|
|
69
|
+
_context.n = 3;
|
|
70
|
+
return this.exportGLTF(object, exportOptions);
|
|
71
|
+
case 3:
|
|
72
|
+
result = _context.v;
|
|
73
|
+
return _context.a(3, 9);
|
|
74
|
+
case 4:
|
|
75
|
+
_context.n = 5;
|
|
76
|
+
return this.exportOBJ(object, exportOptions);
|
|
77
|
+
case 5:
|
|
78
|
+
result = _context.v;
|
|
79
|
+
return _context.a(3, 9);
|
|
80
|
+
case 6:
|
|
81
|
+
_context.n = 7;
|
|
82
|
+
return this.exportSTL(object, exportOptions);
|
|
83
|
+
case 7:
|
|
84
|
+
result = _context.v;
|
|
85
|
+
return _context.a(3, 9);
|
|
86
|
+
case 8:
|
|
87
|
+
throw new Error("Unsupported format: ".concat(format));
|
|
88
|
+
case 9:
|
|
89
|
+
exportTime = performance.now() - startTime;
|
|
90
|
+
exportRecord = {
|
|
91
|
+
timestamp: new Date().toISOString(),
|
|
92
|
+
format: format.toLowerCase(),
|
|
93
|
+
objectName: object.name || 'Unnamed Object',
|
|
94
|
+
exportTime: exportTime,
|
|
95
|
+
options: exportOptions,
|
|
96
|
+
success: true
|
|
97
|
+
};
|
|
98
|
+
this.exportHistory.push(exportRecord);
|
|
99
|
+
debugLogger.logger.info("\u2705 Model exported successfully to ".concat(format.toUpperCase(), " in ").concat(exportTime.toFixed(2), "ms"));
|
|
100
|
+
return _context.a(2, {
|
|
101
|
+
data: result,
|
|
102
|
+
format: format,
|
|
103
|
+
exportTime: exportTime,
|
|
104
|
+
filename: this.generateFilename(object.name || 'model', format)
|
|
105
|
+
});
|
|
106
|
+
case 10:
|
|
107
|
+
_context.p = 10;
|
|
108
|
+
_t2 = _context.v;
|
|
109
|
+
_exportTime = performance.now() - startTime;
|
|
110
|
+
_exportRecord = {
|
|
111
|
+
timestamp: new Date().toISOString(),
|
|
112
|
+
format: format.toLowerCase(),
|
|
113
|
+
objectName: object.name || 'Unnamed Object',
|
|
114
|
+
exportTime: _exportTime,
|
|
115
|
+
options: options,
|
|
116
|
+
success: false,
|
|
117
|
+
error: _t2.message
|
|
118
|
+
};
|
|
119
|
+
this.exportHistory.push(_exportRecord);
|
|
120
|
+
debugLogger.logger.error("\u274C Failed to export model to ".concat(format.toUpperCase(), ":"), _t2);
|
|
121
|
+
throw _t2;
|
|
122
|
+
case 11:
|
|
123
|
+
return _context.a(2);
|
|
124
|
+
}
|
|
125
|
+
}, _callee, this, [[1, 10]]);
|
|
126
|
+
}));
|
|
127
|
+
function exportModel(_x, _x2) {
|
|
128
|
+
return _exportModel.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
return exportModel;
|
|
131
|
+
}()
|
|
132
|
+
/**
|
|
133
|
+
* Export to GLTF/GLB format
|
|
134
|
+
* @param {THREE.Object3D} object - Object to export
|
|
135
|
+
* @param {Object} options - Export options
|
|
136
|
+
* @returns {Promise<ArrayBuffer|Object>} Export result
|
|
137
|
+
*/
|
|
138
|
+
)
|
|
139
|
+
}, {
|
|
140
|
+
key: "exportGLTF",
|
|
141
|
+
value: (function () {
|
|
142
|
+
var _exportGLTF = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2(object) {
|
|
143
|
+
var _this = this;
|
|
144
|
+
var options,
|
|
145
|
+
_args2 = arguments;
|
|
146
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
|
|
147
|
+
while (1) switch (_context2.n) {
|
|
148
|
+
case 0:
|
|
149
|
+
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
150
|
+
return _context2.a(2, new Promise(function (resolve, reject) {
|
|
151
|
+
_this.exporters.gltf.parse(object, function (result) {
|
|
152
|
+
return resolve(result);
|
|
153
|
+
}, reject, options);
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
}, _callee2);
|
|
157
|
+
}));
|
|
158
|
+
function exportGLTF(_x3) {
|
|
159
|
+
return _exportGLTF.apply(this, arguments);
|
|
160
|
+
}
|
|
161
|
+
return exportGLTF;
|
|
162
|
+
}()
|
|
163
|
+
/**
|
|
164
|
+
* Export to OBJ format
|
|
165
|
+
* @param {THREE.Object3D} object - Object to export
|
|
166
|
+
* @param {Object} options - Export options
|
|
167
|
+
* @returns {Promise<string>} OBJ string
|
|
168
|
+
*/
|
|
169
|
+
)
|
|
170
|
+
}, {
|
|
171
|
+
key: "exportOBJ",
|
|
172
|
+
value: (function () {
|
|
173
|
+
var _exportOBJ = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3(object) {
|
|
174
|
+
var _this2 = this;
|
|
175
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
|
|
176
|
+
while (1) switch (_context3.n) {
|
|
177
|
+
case 0:
|
|
178
|
+
return _context3.a(2, new Promise(function (resolve) {
|
|
179
|
+
var result = _this2.exporters.obj.parse(object);
|
|
180
|
+
resolve(result);
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
}, _callee3);
|
|
184
|
+
}));
|
|
185
|
+
function exportOBJ(_x4) {
|
|
186
|
+
return _exportOBJ.apply(this, arguments);
|
|
187
|
+
}
|
|
188
|
+
return exportOBJ;
|
|
189
|
+
}()
|
|
190
|
+
/**
|
|
191
|
+
* Export to STL format
|
|
192
|
+
* @param {THREE.Object3D} object - Object to export
|
|
193
|
+
* @param {Object} options - Export options
|
|
194
|
+
* @returns {Promise<ArrayBuffer|string>} STL data
|
|
195
|
+
*/
|
|
196
|
+
)
|
|
197
|
+
}, {
|
|
198
|
+
key: "exportSTL",
|
|
199
|
+
value: (function () {
|
|
200
|
+
var _exportSTL = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee4(object) {
|
|
201
|
+
var _this3 = this;
|
|
202
|
+
var options,
|
|
203
|
+
_args4 = arguments;
|
|
204
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context4) {
|
|
205
|
+
while (1) switch (_context4.n) {
|
|
206
|
+
case 0:
|
|
207
|
+
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
208
|
+
return _context4.a(2, new Promise(function (resolve) {
|
|
209
|
+
var result = _this3.exporters.stl.parse(object, options);
|
|
210
|
+
resolve(result);
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
}, _callee4);
|
|
214
|
+
}));
|
|
215
|
+
function exportSTL(_x5) {
|
|
216
|
+
return _exportSTL.apply(this, arguments);
|
|
217
|
+
}
|
|
218
|
+
return exportSTL;
|
|
219
|
+
}()
|
|
220
|
+
/**
|
|
221
|
+
* Export to PLY format
|
|
222
|
+
* @param {THREE.Object3D} object - Object to export
|
|
223
|
+
* @param {Object} options - Export options
|
|
224
|
+
* @returns {Promise<ArrayBuffer|string>} PLY data
|
|
225
|
+
*/
|
|
226
|
+
)
|
|
227
|
+
}, {
|
|
228
|
+
key: "exportPLY",
|
|
229
|
+
value: (function () {
|
|
230
|
+
var _exportPLY = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee5(object) {
|
|
231
|
+
var _this4 = this;
|
|
232
|
+
var options,
|
|
233
|
+
_args5 = arguments;
|
|
234
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context5) {
|
|
235
|
+
while (1) switch (_context5.n) {
|
|
236
|
+
case 0:
|
|
237
|
+
options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
238
|
+
return _context5.a(2, new Promise(function (resolve) {
|
|
239
|
+
var result = _this4.exporters.ply.parse(object, options);
|
|
240
|
+
resolve(result);
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
}, _callee5);
|
|
244
|
+
}));
|
|
245
|
+
function exportPLY(_x6) {
|
|
246
|
+
return _exportPLY.apply(this, arguments);
|
|
247
|
+
}
|
|
248
|
+
return exportPLY;
|
|
249
|
+
}()
|
|
250
|
+
/**
|
|
251
|
+
* Export scene configuration to JSON
|
|
252
|
+
* @param {THREE.Scene} scene - Scene to export
|
|
253
|
+
* @param {Array} connections - Scene connections
|
|
254
|
+
* @param {Object} metadata - Additional metadata
|
|
255
|
+
* @returns {Object} Scene JSON data
|
|
256
|
+
*/
|
|
257
|
+
)
|
|
258
|
+
}, {
|
|
259
|
+
key: "exportSceneConfig",
|
|
260
|
+
value: function exportSceneConfig(scene) {
|
|
261
|
+
var connections = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
262
|
+
var metadata = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
263
|
+
debugLogger.logger.info('🔄 Exporting scene configuration...');
|
|
264
|
+
try {
|
|
265
|
+
var sceneData = {
|
|
266
|
+
metadata: _rollupPluginBabelHelpers.objectSpread2({
|
|
267
|
+
version: '1.0.0',
|
|
268
|
+
generator: 'Export',
|
|
269
|
+
timestamp: new Date().toISOString()
|
|
270
|
+
}, metadata),
|
|
271
|
+
scene: this.serializeObject(scene),
|
|
272
|
+
connections: _rollupPluginBabelHelpers.toConsumableArray(connections),
|
|
273
|
+
cameras: this.extractCameras(scene),
|
|
274
|
+
lights: this.extractLights(scene)
|
|
275
|
+
};
|
|
276
|
+
debugLogger.logger.info('✅ Scene configuration exported successfully');
|
|
277
|
+
return sceneData;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
debugLogger.logger.error('❌ Failed to export scene configuration:', error);
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Serialize Three.js object to JSON
|
|
286
|
+
* @param {THREE.Object3D} object - Object to serialize
|
|
287
|
+
* @returns {Object} Serialized object
|
|
288
|
+
*/
|
|
289
|
+
}, {
|
|
290
|
+
key: "serializeObject",
|
|
291
|
+
value: function serializeObject(object) {
|
|
292
|
+
var _this5 = this;
|
|
293
|
+
var serialized = {
|
|
294
|
+
uuid: object.uuid,
|
|
295
|
+
name: object.name,
|
|
296
|
+
type: object.type,
|
|
297
|
+
position: object.position.toArray(),
|
|
298
|
+
rotation: object.rotation.toArray(),
|
|
299
|
+
scale: object.scale.toArray(),
|
|
300
|
+
visible: object.visible,
|
|
301
|
+
castShadow: object.castShadow,
|
|
302
|
+
receiveShadow: object.receiveShadow,
|
|
303
|
+
userData: _rollupPluginBabelHelpers.objectSpread2({}, object.userData),
|
|
304
|
+
children: []
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// Serialize geometry if it exists
|
|
308
|
+
if (object.geometry) {
|
|
309
|
+
serialized.geometry = {
|
|
310
|
+
type: object.geometry.type,
|
|
311
|
+
uuid: object.geometry.uuid,
|
|
312
|
+
attributes: this.serializeGeometryAttributes(object.geometry)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Serialize material if it exists
|
|
317
|
+
if (object.material) {
|
|
318
|
+
serialized.material = this.serializeMaterial(object.material);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Recursively serialize children
|
|
322
|
+
object.children.forEach(function (child) {
|
|
323
|
+
serialized.children.push(_this5.serializeObject(child));
|
|
324
|
+
});
|
|
325
|
+
return serialized;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Serialize geometry attributes
|
|
330
|
+
* @param {THREE.BufferGeometry} geometry - Geometry to serialize
|
|
331
|
+
* @returns {Object} Serialized attributes
|
|
332
|
+
*/
|
|
333
|
+
}, {
|
|
334
|
+
key: "serializeGeometryAttributes",
|
|
335
|
+
value: function serializeGeometryAttributes(geometry) {
|
|
336
|
+
var attributes = {};
|
|
337
|
+
Object.keys(geometry.attributes).forEach(function (name) {
|
|
338
|
+
var attribute = geometry.attributes[name];
|
|
339
|
+
attributes[name] = {
|
|
340
|
+
type: attribute.constructor.name,
|
|
341
|
+
itemSize: attribute.itemSize,
|
|
342
|
+
count: attribute.count,
|
|
343
|
+
normalized: attribute.normalized
|
|
344
|
+
};
|
|
345
|
+
});
|
|
346
|
+
return attributes;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Serialize material
|
|
351
|
+
* @param {THREE.Material} material - Material to serialize
|
|
352
|
+
* @returns {Object} Serialized material
|
|
353
|
+
*/
|
|
354
|
+
}, {
|
|
355
|
+
key: "serializeMaterial",
|
|
356
|
+
value: function serializeMaterial(material) {
|
|
357
|
+
var serialized = {
|
|
358
|
+
type: material.type,
|
|
359
|
+
uuid: material.uuid,
|
|
360
|
+
name: material.name,
|
|
361
|
+
color: material.color ? material.color.getHex() : null,
|
|
362
|
+
transparent: material.transparent,
|
|
363
|
+
opacity: material.opacity,
|
|
364
|
+
side: material.side,
|
|
365
|
+
visible: material.visible
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// Add material-specific properties
|
|
369
|
+
if (material.metalness !== undefined) serialized.metalness = material.metalness;
|
|
370
|
+
if (material.roughness !== undefined) serialized.roughness = material.roughness;
|
|
371
|
+
if (material.clearcoat !== undefined) serialized.clearcoat = material.clearcoat;
|
|
372
|
+
if (material.clearcoatRoughness !== undefined) serialized.clearcoatRoughness = material.clearcoatRoughness;
|
|
373
|
+
|
|
374
|
+
// Serialize textures
|
|
375
|
+
var textureProperties = ['map', 'normalMap', 'roughnessMap', 'metalnessMap', 'aoMap', 'emissiveMap'];
|
|
376
|
+
textureProperties.forEach(function (prop) {
|
|
377
|
+
if (material[prop]) {
|
|
378
|
+
var _material$prop$image;
|
|
379
|
+
serialized[prop] = {
|
|
380
|
+
uuid: material[prop].uuid,
|
|
381
|
+
name: material[prop].name,
|
|
382
|
+
image: ((_material$prop$image = material[prop].image) === null || _material$prop$image === void 0 ? void 0 : _material$prop$image.src) || null
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return serialized;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Extract cameras from scene
|
|
391
|
+
* @param {THREE.Scene} scene - Scene to extract from
|
|
392
|
+
* @returns {Array} Camera data
|
|
393
|
+
*/
|
|
394
|
+
}, {
|
|
395
|
+
key: "extractCameras",
|
|
396
|
+
value: function extractCameras(scene) {
|
|
397
|
+
var cameras = [];
|
|
398
|
+
scene.traverse(function (object) {
|
|
399
|
+
if (object.isCamera) {
|
|
400
|
+
var cameraData = {
|
|
401
|
+
uuid: object.uuid,
|
|
402
|
+
name: object.name,
|
|
403
|
+
type: object.type,
|
|
404
|
+
position: object.position.toArray(),
|
|
405
|
+
rotation: object.rotation.toArray(),
|
|
406
|
+
fov: object.fov,
|
|
407
|
+
aspect: object.aspect,
|
|
408
|
+
near: object.near,
|
|
409
|
+
far: object.far
|
|
410
|
+
};
|
|
411
|
+
cameras.push(cameraData);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
return cameras;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Extract lights from scene
|
|
419
|
+
* @param {THREE.Scene} scene - Scene to extract from
|
|
420
|
+
* @returns {Array} Light data
|
|
421
|
+
*/
|
|
422
|
+
}, {
|
|
423
|
+
key: "extractLights",
|
|
424
|
+
value: function extractLights(scene) {
|
|
425
|
+
var lights = [];
|
|
426
|
+
scene.traverse(function (object) {
|
|
427
|
+
if (object.isLight) {
|
|
428
|
+
var lightData = {
|
|
429
|
+
uuid: object.uuid,
|
|
430
|
+
name: object.name,
|
|
431
|
+
type: object.type,
|
|
432
|
+
position: object.position.toArray(),
|
|
433
|
+
color: object.color.getHex(),
|
|
434
|
+
intensity: object.intensity
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// Add light-specific properties
|
|
438
|
+
if (object.distance !== undefined) lightData.distance = object.distance;
|
|
439
|
+
if (object.decay !== undefined) lightData.decay = object.decay;
|
|
440
|
+
if (object.angle !== undefined) lightData.angle = object.angle;
|
|
441
|
+
if (object.penumbra !== undefined) lightData.penumbra = object.penumbra;
|
|
442
|
+
if (object.castShadow !== undefined) lightData.castShadow = object.castShadow;
|
|
443
|
+
lights.push(lightData);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
return lights;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Export data to CSV format
|
|
451
|
+
* @param {Array} data - Array of objects to export
|
|
452
|
+
* @param {Array} headers - Column headers
|
|
453
|
+
* @returns {string} CSV string
|
|
454
|
+
*/
|
|
455
|
+
}, {
|
|
456
|
+
key: "exportToCSV",
|
|
457
|
+
value: function exportToCSV(data) {
|
|
458
|
+
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
459
|
+
if (!data || data.length === 0) {
|
|
460
|
+
return '';
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Auto-generate headers if not provided
|
|
464
|
+
if (!headers) {
|
|
465
|
+
headers = Object.keys(data[0]);
|
|
466
|
+
}
|
|
467
|
+
var csvRows = [];
|
|
468
|
+
|
|
469
|
+
// Add headers
|
|
470
|
+
csvRows.push(headers.join(','));
|
|
471
|
+
|
|
472
|
+
// Add data rows
|
|
473
|
+
data.forEach(function (row) {
|
|
474
|
+
var values = headers.map(function (header) {
|
|
475
|
+
var value = row[header];
|
|
476
|
+
// Escape commas and quotes
|
|
477
|
+
if (typeof value === 'string' && (value.includes(',') || value.includes('"'))) {
|
|
478
|
+
return "\"".concat(value.replace(/"/g, '""'), "\"");
|
|
479
|
+
}
|
|
480
|
+
return value;
|
|
481
|
+
});
|
|
482
|
+
csvRows.push(values.join(','));
|
|
483
|
+
});
|
|
484
|
+
return csvRows.join('\n');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Export data to XML format
|
|
489
|
+
* @param {Object} data - Data to export
|
|
490
|
+
* @param {string} rootElement - Root element name
|
|
491
|
+
* @returns {string} XML string
|
|
492
|
+
*/
|
|
493
|
+
}, {
|
|
494
|
+
key: "exportToXML",
|
|
495
|
+
value: function exportToXML(data) {
|
|
496
|
+
var _this6 = this;
|
|
497
|
+
var rootElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'root';
|
|
498
|
+
var xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
499
|
+
var _objectToXML = function objectToXML(obj) {
|
|
500
|
+
var indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
501
|
+
var spaces = ' '.repeat(indent);
|
|
502
|
+
var xml = '';
|
|
503
|
+
Object.keys(obj).forEach(function (key) {
|
|
504
|
+
var value = obj[key];
|
|
505
|
+
if (_rollupPluginBabelHelpers["typeof"](value) === 'object' && value !== null && !Array.isArray(value)) {
|
|
506
|
+
xml += "".concat(spaces, "<").concat(key, ">\n");
|
|
507
|
+
xml += _objectToXML(value, indent + 1);
|
|
508
|
+
xml += "".concat(spaces, "</").concat(key, ">\n");
|
|
509
|
+
} else if (Array.isArray(value)) {
|
|
510
|
+
value.forEach(function (item) {
|
|
511
|
+
xml += "".concat(spaces, "<").concat(key, ">");
|
|
512
|
+
if (_rollupPluginBabelHelpers["typeof"](item) === 'object') {
|
|
513
|
+
xml += '\n' + _objectToXML(item, indent + 1) + spaces;
|
|
514
|
+
} else {
|
|
515
|
+
xml += _this6.escapeXML(item);
|
|
516
|
+
}
|
|
517
|
+
xml += "</".concat(key, ">\n");
|
|
518
|
+
});
|
|
519
|
+
} else {
|
|
520
|
+
xml += "".concat(spaces, "<").concat(key, ">").concat(_this6.escapeXML(value), "</").concat(key, ">\n");
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
return xml;
|
|
524
|
+
};
|
|
525
|
+
return xmlHeader + "<".concat(rootElement, ">\n") + _objectToXML(data, 1) + "</".concat(rootElement, ">");
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Download file from data
|
|
530
|
+
* @param {*} data - Data to download
|
|
531
|
+
* @param {string} filename - Filename
|
|
532
|
+
* @param {string} mimeType - MIME type
|
|
533
|
+
*/
|
|
534
|
+
}, {
|
|
535
|
+
key: "downloadFile",
|
|
536
|
+
value: function downloadFile(data, filename) {
|
|
537
|
+
var mimeType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/octet-stream';
|
|
538
|
+
var blob;
|
|
539
|
+
if (data instanceof ArrayBuffer) {
|
|
540
|
+
blob = new Blob([data], {
|
|
541
|
+
type: mimeType
|
|
542
|
+
});
|
|
543
|
+
} else if (typeof data === 'string') {
|
|
544
|
+
blob = new Blob([data], {
|
|
545
|
+
type: mimeType
|
|
546
|
+
});
|
|
547
|
+
} else {
|
|
548
|
+
blob = new Blob([JSON.stringify(data, null, 2)], {
|
|
549
|
+
type: 'application/json'
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
var url = URL.createObjectURL(blob);
|
|
553
|
+
var link = document.createElement('a');
|
|
554
|
+
link.href = url;
|
|
555
|
+
link.download = filename;
|
|
556
|
+
link.style.display = 'none';
|
|
557
|
+
document.body.appendChild(link);
|
|
558
|
+
link.click();
|
|
559
|
+
document.body.removeChild(link);
|
|
560
|
+
URL.revokeObjectURL(url);
|
|
561
|
+
debugLogger.logger.info("\u2705 File downloaded: ".concat(filename));
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Export multiple objects in batch
|
|
566
|
+
* @param {Array} objects - Array of {object, format, options} objects
|
|
567
|
+
* @returns {Promise<Array>} Array of export results
|
|
568
|
+
*/
|
|
569
|
+
}, {
|
|
570
|
+
key: "exportBatch",
|
|
571
|
+
value: (function () {
|
|
572
|
+
var _exportBatch = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee6(objects) {
|
|
573
|
+
var results, errors, _iterator, _step, item, result, _t3, _t4;
|
|
574
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context6) {
|
|
575
|
+
while (1) switch (_context6.n) {
|
|
576
|
+
case 0:
|
|
577
|
+
debugLogger.logger.info("\uD83D\uDD04 Starting batch export of ".concat(objects.length, " objects..."));
|
|
578
|
+
results = [];
|
|
579
|
+
errors = [];
|
|
580
|
+
_iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(objects);
|
|
581
|
+
_context6.p = 1;
|
|
582
|
+
_iterator.s();
|
|
583
|
+
case 2:
|
|
584
|
+
if ((_step = _iterator.n()).done) {
|
|
585
|
+
_context6.n = 7;
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
item = _step.value;
|
|
589
|
+
_context6.p = 3;
|
|
590
|
+
_context6.n = 4;
|
|
591
|
+
return this.exportModel(item.object, item.format, item.options);
|
|
592
|
+
case 4:
|
|
593
|
+
result = _context6.v;
|
|
594
|
+
results.push(result);
|
|
595
|
+
_context6.n = 6;
|
|
596
|
+
break;
|
|
597
|
+
case 5:
|
|
598
|
+
_context6.p = 5;
|
|
599
|
+
_t3 = _context6.v;
|
|
600
|
+
errors.push({
|
|
601
|
+
object: item.object.name || 'Unnamed Object',
|
|
602
|
+
format: item.format,
|
|
603
|
+
error: _t3.message
|
|
604
|
+
});
|
|
605
|
+
case 6:
|
|
606
|
+
_context6.n = 2;
|
|
607
|
+
break;
|
|
608
|
+
case 7:
|
|
609
|
+
_context6.n = 9;
|
|
610
|
+
break;
|
|
611
|
+
case 8:
|
|
612
|
+
_context6.p = 8;
|
|
613
|
+
_t4 = _context6.v;
|
|
614
|
+
_iterator.e(_t4);
|
|
615
|
+
case 9:
|
|
616
|
+
_context6.p = 9;
|
|
617
|
+
_iterator.f();
|
|
618
|
+
return _context6.f(9);
|
|
619
|
+
case 10:
|
|
620
|
+
debugLogger.logger.info("\u2705 Batch export complete: ".concat(results.length, " successful, ").concat(errors.length, " failed"));
|
|
621
|
+
return _context6.a(2, {
|
|
622
|
+
results: results,
|
|
623
|
+
errors: errors
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}, _callee6, this, [[3, 5], [1, 8, 9, 10]]);
|
|
627
|
+
}));
|
|
628
|
+
function exportBatch(_x7) {
|
|
629
|
+
return _exportBatch.apply(this, arguments);
|
|
630
|
+
}
|
|
631
|
+
return exportBatch;
|
|
632
|
+
}()
|
|
633
|
+
/**
|
|
634
|
+
* Generate filename for export
|
|
635
|
+
* @param {string} baseName - Base name
|
|
636
|
+
* @param {string} format - File format
|
|
637
|
+
* @returns {string} Generated filename
|
|
638
|
+
*/
|
|
639
|
+
)
|
|
640
|
+
}, {
|
|
641
|
+
key: "generateFilename",
|
|
642
|
+
value: function generateFilename(baseName, format) {
|
|
643
|
+
var timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
|
|
644
|
+
var sanitizedName = baseName.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
645
|
+
return "".concat(sanitizedName, "_").concat(timestamp, ".").concat(format.toLowerCase());
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Escape XML special characters
|
|
650
|
+
* @param {*} value - Value to escape
|
|
651
|
+
* @returns {string} Escaped string
|
|
652
|
+
*/
|
|
653
|
+
}, {
|
|
654
|
+
key: "escapeXML",
|
|
655
|
+
value: function escapeXML(value) {
|
|
656
|
+
if (value === null || value === undefined) {
|
|
657
|
+
return '';
|
|
658
|
+
}
|
|
659
|
+
return String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Check if format is supported
|
|
664
|
+
* @param {string} format - Format to check
|
|
665
|
+
* @param {string} category - Category (models, scenes, images, data)
|
|
666
|
+
* @returns {boolean} Whether format is supported
|
|
667
|
+
*/
|
|
668
|
+
}, {
|
|
669
|
+
key: "isFormatSupported",
|
|
670
|
+
value: function isFormatSupported(format, category) {
|
|
671
|
+
var _this$supportedFormat;
|
|
672
|
+
return ((_this$supportedFormat = this.supportedFormats[category]) === null || _this$supportedFormat === void 0 ? void 0 : _this$supportedFormat.includes(format.toLowerCase())) || false;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Get export history
|
|
677
|
+
* @returns {Array} Export history
|
|
678
|
+
*/
|
|
679
|
+
}, {
|
|
680
|
+
key: "getExportHistory",
|
|
681
|
+
value: function getExportHistory() {
|
|
682
|
+
return this.exportHistory;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Clear export history
|
|
687
|
+
*/
|
|
688
|
+
}, {
|
|
689
|
+
key: "clearHistory",
|
|
690
|
+
value: function clearHistory() {
|
|
691
|
+
this.exportHistory = [];
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Get supported formats
|
|
696
|
+
* @returns {Object} Supported formats by category
|
|
697
|
+
*/
|
|
698
|
+
}, {
|
|
699
|
+
key: "getSupportedFormats",
|
|
700
|
+
value: function getSupportedFormats() {
|
|
701
|
+
return _rollupPluginBabelHelpers.objectSpread2({}, this.supportedFormats);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Dispose of export manager
|
|
706
|
+
*/
|
|
707
|
+
}, {
|
|
708
|
+
key: "dispose",
|
|
709
|
+
value: function dispose() {
|
|
710
|
+
this.clearHistory();
|
|
711
|
+
debugLogger.logger.info('Export disposed');
|
|
712
|
+
}
|
|
713
|
+
}]);
|
|
714
|
+
}();
|
|
715
|
+
|
|
716
|
+
exports.Export = Export;
|