@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,229 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var THREE = require('three');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
27
|
+
|
|
28
|
+
var TEXTURE_SETS = {
|
|
29
|
+
// Light metallic texture using the gravel_embedded_concrete with metallic properties
|
|
30
|
+
light_metal: {
|
|
31
|
+
path: '/textures/gravel_embedded_concrete_1k',
|
|
32
|
+
files: {
|
|
33
|
+
diffuse: 'diffuse.jpg',
|
|
34
|
+
normal: 'normal.jpg',
|
|
35
|
+
roughness: 'rough.jpg'
|
|
36
|
+
},
|
|
37
|
+
repeat: {
|
|
38
|
+
x: 2,
|
|
39
|
+
y: 2
|
|
40
|
+
},
|
|
41
|
+
// Moderate tiling for surface detail
|
|
42
|
+
materialProps: {
|
|
43
|
+
color: 0xb8b8b8,
|
|
44
|
+
// Light metallic base color
|
|
45
|
+
metalness: 0.3,
|
|
46
|
+
roughness: 0.3,
|
|
47
|
+
normalScale: [0.4, 0.4],
|
|
48
|
+
// Subtle surface detail
|
|
49
|
+
clearcoat: 0.3,
|
|
50
|
+
clearcoatRoughness: 0.2,
|
|
51
|
+
envMapIntensity: 1.6,
|
|
52
|
+
reflectivity: 0.5
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
brick: {
|
|
56
|
+
path: '/textures/pavement_03_1k',
|
|
57
|
+
files: {
|
|
58
|
+
diffuse: 'diffuse.jpg',
|
|
59
|
+
normal: 'normal.jpg',
|
|
60
|
+
roughness: 'rough.jpg'
|
|
61
|
+
},
|
|
62
|
+
repeat: {
|
|
63
|
+
x: 7.5,
|
|
64
|
+
y: 0.75
|
|
65
|
+
},
|
|
66
|
+
// Adjust for proper brick scale
|
|
67
|
+
materialProps: {
|
|
68
|
+
color: 0x998888,
|
|
69
|
+
roughness: 0.9,
|
|
70
|
+
metalness: 0.1,
|
|
71
|
+
normalScale: [1.5, 1.5],
|
|
72
|
+
bumpScale: 0.05,
|
|
73
|
+
clearcoat: 0.05,
|
|
74
|
+
clearcoatRoughness: 0.4
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
gravel_embedded_concrete: {
|
|
78
|
+
path: '/textures/gravel_embedded_concrete_1k',
|
|
79
|
+
files: {
|
|
80
|
+
diffuse: 'diffuse.jpg',
|
|
81
|
+
normal: 'normal.jpg',
|
|
82
|
+
roughness: 'rough.jpg'
|
|
83
|
+
},
|
|
84
|
+
repeat: {
|
|
85
|
+
x: 7,
|
|
86
|
+
y: 7
|
|
87
|
+
},
|
|
88
|
+
materialProps: {
|
|
89
|
+
color: 0x666666,
|
|
90
|
+
metalness: 0.0,
|
|
91
|
+
roughness: 1.0,
|
|
92
|
+
normalScale: [1.0, 1.0]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Helper function to load a complete texture set
|
|
99
|
+
* @param {string} setName - Name of the texture set from TEXTURE_SETS
|
|
100
|
+
* @param {THREE.TextureLoader} textureLoader - Three.js texture loader instance
|
|
101
|
+
* @returns {Promise<Object>} Promise that resolves to an object containing all loaded textures
|
|
102
|
+
*/
|
|
103
|
+
function loadTextureSet(_x, _x2) {
|
|
104
|
+
return _loadTextureSet.apply(this, arguments);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Create a Three.js material from a loaded texture set
|
|
109
|
+
* @param {Object} loadedTextureSet - Result from loadTextureSet()
|
|
110
|
+
* @param {Object} overrideProps - Optional material property overrides
|
|
111
|
+
* @returns {THREE.MeshPhysicalMaterial} Configured material
|
|
112
|
+
*/
|
|
113
|
+
function _loadTextureSet() {
|
|
114
|
+
_loadTextureSet = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2(setName, textureLoader) {
|
|
115
|
+
var textureSet, loadTexture, promises, loadedTextures, textureMap;
|
|
116
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
|
|
117
|
+
while (1) switch (_context2.n) {
|
|
118
|
+
case 0:
|
|
119
|
+
console.log("Loading texture set: ".concat(setName));
|
|
120
|
+
textureSet = TEXTURE_SETS[setName];
|
|
121
|
+
if (textureSet) {
|
|
122
|
+
_context2.n = 1;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
throw new Error("Texture set \"".concat(setName, "\" not found"));
|
|
126
|
+
case 1:
|
|
127
|
+
console.log("Texture set config:", textureSet);
|
|
128
|
+
loadTexture = function loadTexture(url) {
|
|
129
|
+
return new Promise(function (resolve, reject) {
|
|
130
|
+
console.log("Loading texture: ".concat(url));
|
|
131
|
+
textureLoader.load(url, function (texture) {
|
|
132
|
+
console.log("Successfully loaded: ".concat(url));
|
|
133
|
+
resolve(texture);
|
|
134
|
+
}, undefined, function (error) {
|
|
135
|
+
console.error("Failed to load: ".concat(url), error);
|
|
136
|
+
reject(error);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
promises = Object.entries(textureSet.files).map(/*#__PURE__*/function () {
|
|
141
|
+
var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee(_ref) {
|
|
142
|
+
var _ref3, type, filename, url, texture;
|
|
143
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
144
|
+
while (1) switch (_context.n) {
|
|
145
|
+
case 0:
|
|
146
|
+
_ref3 = _rollupPluginBabelHelpers.slicedToArray(_ref, 2), type = _ref3[0], filename = _ref3[1];
|
|
147
|
+
url = "".concat(textureSet.path, "/").concat(filename);
|
|
148
|
+
_context.n = 1;
|
|
149
|
+
return loadTexture(url);
|
|
150
|
+
case 1:
|
|
151
|
+
texture = _context.v;
|
|
152
|
+
return _context.a(2, [type, texture]);
|
|
153
|
+
}
|
|
154
|
+
}, _callee);
|
|
155
|
+
}));
|
|
156
|
+
return function (_x5) {
|
|
157
|
+
return _ref2.apply(this, arguments);
|
|
158
|
+
};
|
|
159
|
+
}());
|
|
160
|
+
_context2.n = 2;
|
|
161
|
+
return Promise.all(promises);
|
|
162
|
+
case 2:
|
|
163
|
+
loadedTextures = _context2.v;
|
|
164
|
+
textureMap = Object.fromEntries(loadedTextures); // Apply texture settings
|
|
165
|
+
Object.values(textureMap).forEach(function (texture) {
|
|
166
|
+
texture.wrapS = texture.wrapT = THREE__namespace.RepeatWrapping;
|
|
167
|
+
texture.repeat.set(textureSet.repeat.x, textureSet.repeat.y);
|
|
168
|
+
});
|
|
169
|
+
console.log("Texture set ".concat(setName, " loaded successfully"));
|
|
170
|
+
return _context2.a(2, {
|
|
171
|
+
textures: textureMap,
|
|
172
|
+
config: textureSet
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}, _callee2);
|
|
176
|
+
}));
|
|
177
|
+
return _loadTextureSet.apply(this, arguments);
|
|
178
|
+
}
|
|
179
|
+
function createMaterialFromTextureSet(loadedTextureSet) {
|
|
180
|
+
var overrideProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
181
|
+
var textures = loadedTextureSet.textures,
|
|
182
|
+
config = loadedTextureSet.config;
|
|
183
|
+
var materialProps = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({
|
|
184
|
+
map: textures.diffuse,
|
|
185
|
+
normalMap: textures.normal,
|
|
186
|
+
roughnessMap: textures.roughness
|
|
187
|
+
}, config.materialProps), overrideProps);
|
|
188
|
+
|
|
189
|
+
// Handle normalScale specially since it needs to be a Vector2
|
|
190
|
+
if (materialProps.normalScale && Array.isArray(materialProps.normalScale)) {
|
|
191
|
+
materialProps.normalScale = _rollupPluginBabelHelpers.construct(THREE__namespace.Vector2, _rollupPluginBabelHelpers.toConsumableArray(materialProps.normalScale));
|
|
192
|
+
}
|
|
193
|
+
return new THREE__namespace.MeshPhysicalMaterial(materialProps);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Convenient function to load texture set and create material in one step
|
|
198
|
+
* @param {string} setName - Name of the texture set
|
|
199
|
+
* @param {THREE.TextureLoader} textureLoader - Three.js texture loader
|
|
200
|
+
* @param {Object} materialOverrides - Optional material property overrides
|
|
201
|
+
* @returns {Promise<THREE.MeshPhysicalMaterial>} Promise that resolves to configured material
|
|
202
|
+
*/
|
|
203
|
+
function loadTextureSetAndCreateMaterial(_x3, _x4) {
|
|
204
|
+
return _loadTextureSetAndCreateMaterial.apply(this, arguments);
|
|
205
|
+
}
|
|
206
|
+
function _loadTextureSetAndCreateMaterial() {
|
|
207
|
+
_loadTextureSetAndCreateMaterial = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3(setName, textureLoader) {
|
|
208
|
+
var materialOverrides,
|
|
209
|
+
loadedTextureSet,
|
|
210
|
+
_args3 = arguments;
|
|
211
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
|
|
212
|
+
while (1) switch (_context3.n) {
|
|
213
|
+
case 0:
|
|
214
|
+
materialOverrides = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
|
|
215
|
+
_context3.n = 1;
|
|
216
|
+
return loadTextureSet(setName, textureLoader);
|
|
217
|
+
case 1:
|
|
218
|
+
loadedTextureSet = _context3.v;
|
|
219
|
+
return _context3.a(2, createMaterialFromTextureSet(loadedTextureSet, materialOverrides));
|
|
220
|
+
}
|
|
221
|
+
}, _callee3);
|
|
222
|
+
}));
|
|
223
|
+
return _loadTextureSetAndCreateMaterial.apply(this, arguments);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
exports.TEXTURE_SETS = TEXTURE_SETS;
|
|
227
|
+
exports.createMaterialFromTextureSet = createMaterialFromTextureSet;
|
|
228
|
+
exports.loadTextureSet = loadTextureSet;
|
|
229
|
+
exports.loadTextureSetAndCreateMaterial = loadTextureSetAndCreateMaterial;
|
|
@@ -1 +1,264 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var nameUtils = require('../../core/nameUtils.js');
|
|
7
|
+
|
|
8
|
+
var SceneExportManager = /*#__PURE__*/function () {
|
|
9
|
+
function SceneExportManager(sceneViewer) {
|
|
10
|
+
_rollupPluginBabelHelpers.classCallCheck(this, SceneExportManager);
|
|
11
|
+
this.sceneViewer = sceneViewer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Export function that recreates the JSON data structure from current scene objects
|
|
16
|
+
*/
|
|
17
|
+
return _rollupPluginBabelHelpers.createClass(SceneExportManager, [{
|
|
18
|
+
key: "exportSceneData",
|
|
19
|
+
value: function exportSceneData() {
|
|
20
|
+
var _this = this;
|
|
21
|
+
console.log('📤 Starting scene export...');
|
|
22
|
+
if (!this.sceneViewer.scene) {
|
|
23
|
+
console.warn('⚠️ No scene available for export');
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Helper function to extract connections from pathfinder or scene analysis
|
|
28
|
+
var extractConnections = function extractConnections() {
|
|
29
|
+
var _this$sceneViewer$cur;
|
|
30
|
+
var connections = [];
|
|
31
|
+
|
|
32
|
+
// If we have the original connections from currentSceneData, use those as base
|
|
33
|
+
if ((_this$sceneViewer$cur = _this.sceneViewer.currentSceneData) !== null && _this$sceneViewer$cur !== void 0 && _this$sceneViewer$cur.connections) {
|
|
34
|
+
connections.push.apply(connections, _rollupPluginBabelHelpers.toConsumableArray(_this.sceneViewer.currentSceneData.connections));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// If no currentSceneData, we'll return empty connections array
|
|
38
|
+
// This allows export to work even for default scenes that haven't been imported
|
|
39
|
+
return connections;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Helper function to convert Three.js object to JSON format
|
|
43
|
+
var _convertObjectToJson = function convertObjectToJson(threeObject) {
|
|
44
|
+
var _threeObject$name, _threeObject$userData, _threeObject$userData2, _threeObject$userData3, _threeObject$userData4, _threeObject$userData5, _threeObject$userData6, _threeObject$userData8;
|
|
45
|
+
var isChild = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
46
|
+
// Skip certain objects that shouldn't be exported
|
|
47
|
+
if (!threeObject || (_threeObject$name = threeObject.name) !== null && _threeObject$name !== void 0 && _threeObject$name.includes('Polyline') || // Skip pipe paths
|
|
48
|
+
(_threeObject$userData = threeObject.userData) !== null && _threeObject$userData !== void 0 && _threeObject$userData.isBrickWall || // Skip environment
|
|
49
|
+
(_threeObject$userData2 = threeObject.userData) !== null && _threeObject$userData2 !== void 0 && _threeObject$userData2.isBaseGround || // Skip environment
|
|
50
|
+
(_threeObject$userData3 = threeObject.userData) !== null && _threeObject$userData3 !== void 0 && _threeObject$userData3.isBaseGrid ||
|
|
51
|
+
// Skip environment
|
|
52
|
+
threeObject.isLight || // Skip lights
|
|
53
|
+
(_threeObject$userData4 = threeObject.userData) !== null && _threeObject$userData4 !== void 0 && _threeObject$userData4.isTransformControls ||
|
|
54
|
+
// Skip transform controls
|
|
55
|
+
threeObject.isTransformControls ||
|
|
56
|
+
// Skip transform controls
|
|
57
|
+
threeObject.type && threeObject.type.includes('TransformControls')) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// For top-level objects, require componentType, but allow children through
|
|
62
|
+
if (!isChild && !((_threeObject$userData5 = threeObject.userData) !== null && _threeObject$userData5 !== void 0 && _threeObject$userData5.componentType)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// For child objects, only include if forExport is explicitly set to true
|
|
67
|
+
if (isChild && !((_threeObject$userData6 = threeObject.userData) !== null && _threeObject$userData6 !== void 0 && _threeObject$userData6.forExport)) {
|
|
68
|
+
var _threeObject$userData7;
|
|
69
|
+
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, ")"));
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
// Log when a child is being included in export
|
|
73
|
+
if (isChild && (_threeObject$userData8 = threeObject.userData) !== null && _threeObject$userData8 !== void 0 && _threeObject$userData8.forExport) {
|
|
74
|
+
var _threeObject$userData9;
|
|
75
|
+
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, ")"));
|
|
76
|
+
} // Create base JSON object with HARDCODED UUID preservation
|
|
77
|
+
var jsonObject = {
|
|
78
|
+
uuid: nameUtils.getHardcodedUuid(threeObject),
|
|
79
|
+
// Use utility function to get hardcoded UUID
|
|
80
|
+
name: threeObject.name || 'Unnamed Object',
|
|
81
|
+
type: threeObject.type || 'Object3D'
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Add userData if it exists (preserving libraryId and other important data)
|
|
85
|
+
if (threeObject.userData && Object.keys(threeObject.userData).length > 0) {
|
|
86
|
+
jsonObject.userData = {};
|
|
87
|
+
|
|
88
|
+
// Copy important userData properties, excluding temporary/runtime data
|
|
89
|
+
Object.keys(threeObject.userData).forEach(function (key) {
|
|
90
|
+
if (key !== 'worldBoundingBox' && key !== 'isBaseGround' && key !== 'isBrickWall' && key !== 'isBaseGrid' && key !== 'isTransformControls') {
|
|
91
|
+
jsonObject.userData[key] = threeObject.userData[key];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Ensure dimensions are included if they exist
|
|
96
|
+
if (threeObject.userData.dimensions) {
|
|
97
|
+
jsonObject.userData.dimensions = threeObject.userData.dimensions;
|
|
98
|
+
console.log("\uD83D\uDCCF Exported dimensions for ".concat(threeObject.name, ":"), jsonObject.userData.dimensions);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// If no relevant userData, remove the empty object
|
|
102
|
+
if (Object.keys(jsonObject.userData).length === 0) {
|
|
103
|
+
delete jsonObject.userData;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Add transform data - convert from radians to degrees for rotation
|
|
108
|
+
jsonObject.position = {
|
|
109
|
+
x: parseFloat(threeObject.position.x.toFixed(6)),
|
|
110
|
+
y: parseFloat(threeObject.position.y.toFixed(6)),
|
|
111
|
+
z: parseFloat(threeObject.position.z.toFixed(6))
|
|
112
|
+
};
|
|
113
|
+
jsonObject.rotation = {
|
|
114
|
+
x: parseFloat((threeObject.rotation.x * (180 / Math.PI)).toFixed(6)),
|
|
115
|
+
y: parseFloat((threeObject.rotation.y * (180 / Math.PI)).toFixed(6)),
|
|
116
|
+
z: parseFloat((threeObject.rotation.z * (180 / Math.PI)).toFixed(6))
|
|
117
|
+
};
|
|
118
|
+
jsonObject.scale = {
|
|
119
|
+
x: parseFloat(threeObject.scale.x.toFixed(6)),
|
|
120
|
+
y: parseFloat(threeObject.scale.y.toFixed(6)),
|
|
121
|
+
z: parseFloat(threeObject.scale.z.toFixed(6))
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Add geometry reference for connectors and other special objects
|
|
125
|
+
if (threeObject.geometry) {
|
|
126
|
+
var _threeObject$name2, _threeObject$name3, _threeObject$userData0;
|
|
127
|
+
if ((_threeObject$name2 = threeObject.name) !== null && _threeObject$name2 !== void 0 && _threeObject$name2.toLowerCase().includes('connector')) {
|
|
128
|
+
jsonObject.geometry = 'CONNECTOR-GEO';
|
|
129
|
+
} else if ((_threeObject$name3 = threeObject.name) !== null && _threeObject$name3 !== void 0 && _threeObject$name3.toLowerCase().includes('gateway')) {
|
|
130
|
+
jsonObject.geometry = 'GATEWAY-GEO';
|
|
131
|
+
} else if ((_threeObject$userData0 = threeObject.userData) !== null && _threeObject$userData0 !== void 0 && _threeObject$userData0.libraryId) {
|
|
132
|
+
// For library objects, use a standard geometry reference
|
|
133
|
+
jsonObject.geometry = "".concat(threeObject.userData.libraryId, "-GEO");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Process children recursively
|
|
138
|
+
if (threeObject.children && threeObject.children.length > 0) {
|
|
139
|
+
var validChildren = [];
|
|
140
|
+
threeObject.children.forEach(function (child) {
|
|
141
|
+
var childJson = _convertObjectToJson(child, true);
|
|
142
|
+
if (childJson) {
|
|
143
|
+
validChildren.push(childJson);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
if (validChildren.length > 0) {
|
|
147
|
+
jsonObject.children = validChildren;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return jsonObject;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Extract main scene objects (excluding environment and utility objects)
|
|
154
|
+
var sceneChildren = [];
|
|
155
|
+
this.sceneViewer.scene.children.forEach(function (child) {
|
|
156
|
+
var jsonChild = _convertObjectToJson(child);
|
|
157
|
+
if (jsonChild) {
|
|
158
|
+
sceneChildren.push(jsonChild);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Build the complete export data structure
|
|
163
|
+
var exportData = {
|
|
164
|
+
connections: extractConnections(),
|
|
165
|
+
scene: {
|
|
166
|
+
object: {
|
|
167
|
+
uuid: 'PLANT-SCENE',
|
|
168
|
+
name: 'Scene',
|
|
169
|
+
type: 'Scene',
|
|
170
|
+
children: sceneChildren
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Add metadata for tracking
|
|
176
|
+
exportData._metadata = {
|
|
177
|
+
exportedAt: new Date().toISOString(),
|
|
178
|
+
exportedFrom: 'SceneViewerEnhanced',
|
|
179
|
+
version: '1.0.0',
|
|
180
|
+
objectCount: sceneChildren.length
|
|
181
|
+
};
|
|
182
|
+
console.log('✅ Scene export completed:', exportData);
|
|
183
|
+
return exportData;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Helper function to download the exported scene data as JSON file
|
|
188
|
+
*/
|
|
189
|
+
}, {
|
|
190
|
+
key: "downloadSceneExport",
|
|
191
|
+
value: function downloadSceneExport() {
|
|
192
|
+
var filename = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
193
|
+
var exportData = this.exportSceneData();
|
|
194
|
+
if (!exportData) {
|
|
195
|
+
console.error('❌ Failed to export scene data');
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Generate filename if not provided
|
|
200
|
+
if (!filename) {
|
|
201
|
+
filename = "cp-export.json";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Create and download the file
|
|
205
|
+
try {
|
|
206
|
+
var jsonString = JSON.stringify(exportData, null, 2);
|
|
207
|
+
var blob = new Blob([jsonString], {
|
|
208
|
+
type: 'application/json'
|
|
209
|
+
});
|
|
210
|
+
var url = URL.createObjectURL(blob);
|
|
211
|
+
var link = document.createElement('a');
|
|
212
|
+
link.href = url;
|
|
213
|
+
link.download = filename;
|
|
214
|
+
document.body.appendChild(link);
|
|
215
|
+
link.click();
|
|
216
|
+
document.body.removeChild(link);
|
|
217
|
+
URL.revokeObjectURL(url);
|
|
218
|
+
console.log("\uD83D\uDCC1 Scene exported successfully as: ".concat(filename));
|
|
219
|
+
return true;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.error('❌ Error downloading scene export:', error);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Export scene data as JSON string
|
|
228
|
+
*/
|
|
229
|
+
}, {
|
|
230
|
+
key: "exportSceneDataAsString",
|
|
231
|
+
value: function exportSceneDataAsString() {
|
|
232
|
+
var pretty = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
233
|
+
var exportData = this.exportSceneData();
|
|
234
|
+
if (!exportData) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return pretty ? JSON.stringify(exportData, null, 2) : JSON.stringify(exportData);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get export metadata
|
|
242
|
+
*/
|
|
243
|
+
}, {
|
|
244
|
+
key: "getExportMetadata",
|
|
245
|
+
value: function getExportMetadata() {
|
|
246
|
+
var _this$sceneViewer$cur2;
|
|
247
|
+
if (!this.sceneViewer.scene) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
var objectCount = 0;
|
|
251
|
+
this.sceneViewer.scene.traverse(function () {
|
|
252
|
+
return objectCount++;
|
|
253
|
+
});
|
|
254
|
+
return {
|
|
255
|
+
totalObjects: objectCount,
|
|
256
|
+
hasCurrentSceneData: !!this.sceneViewer.currentSceneData,
|
|
257
|
+
connectionsCount: ((_this$sceneViewer$cur2 = this.sceneViewer.currentSceneData) === null || _this$sceneViewer$cur2 === void 0 || (_this$sceneViewer$cur2 = _this$sceneViewer$cur2.connections) === null || _this$sceneViewer$cur2 === void 0 ? void 0 : _this$sceneViewer$cur2.length) || 0,
|
|
258
|
+
exportTimestamp: new Date().toISOString()
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}]);
|
|
262
|
+
}();
|
|
263
|
+
|
|
264
|
+
exports.SceneExportManager = SceneExportManager;
|