@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.
Files changed (54) hide show
  1. package/README.md +0 -0
  2. package/dist/bundle/index.js +14259 -0
  3. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +353 -0
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1292 -0
  5. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1543 -0
  6. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4374 -0
  7. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +465 -0
  8. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +117 -0
  9. package/dist/cjs/src/ConnectionManager.js +114 -0
  10. package/dist/cjs/src/Pathfinder.js +88 -0
  11. package/dist/cjs/src/animationManager.js +121 -0
  12. package/dist/cjs/src/componentManager.js +151 -0
  13. package/dist/cjs/src/debugLogger.js +176 -0
  14. package/dist/cjs/src/disposalManager.js +185 -0
  15. package/dist/cjs/src/environmentManager.js +1015 -0
  16. package/dist/cjs/src/hotReloadManager.js +252 -0
  17. package/dist/cjs/src/index.js +126 -0
  18. package/dist/cjs/src/keyboardControlsManager.js +206 -0
  19. package/dist/cjs/src/modelPreloader.js +360 -0
  20. package/dist/cjs/src/nameUtils.js +106 -0
  21. package/dist/cjs/src/pathfindingManager.js +321 -0
  22. package/dist/cjs/src/performanceMonitor.js +718 -0
  23. package/dist/cjs/src/sceneExportManager.js +292 -0
  24. package/dist/cjs/src/sceneInitializationManager.js +540 -0
  25. package/dist/cjs/src/sceneOperationsManager.js +560 -0
  26. package/dist/cjs/src/textureConfig.js +195 -0
  27. package/dist/cjs/src/transformControlsManager.js +851 -0
  28. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +328 -0
  29. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1287 -0
  30. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1537 -0
  31. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4370 -0
  32. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +461 -0
  33. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +113 -0
  34. package/dist/esm/src/ConnectionManager.js +110 -0
  35. package/dist/esm/src/Pathfinder.js +84 -0
  36. package/dist/esm/src/animationManager.js +112 -0
  37. package/dist/esm/src/componentManager.js +123 -0
  38. package/dist/esm/src/debugLogger.js +167 -0
  39. package/dist/esm/src/disposalManager.js +155 -0
  40. package/dist/esm/src/environmentManager.js +989 -0
  41. package/dist/esm/src/hotReloadManager.js +244 -0
  42. package/dist/esm/src/index.js +117 -0
  43. package/dist/esm/src/keyboardControlsManager.js +196 -0
  44. package/dist/esm/src/modelPreloader.js +337 -0
  45. package/dist/esm/src/nameUtils.js +99 -0
  46. package/dist/esm/src/pathfindingManager.js +295 -0
  47. package/dist/esm/src/performanceMonitor.js +712 -0
  48. package/dist/esm/src/sceneExportManager.js +286 -0
  49. package/dist/esm/src/sceneInitializationManager.js +513 -0
  50. package/dist/esm/src/sceneOperationsManager.js +536 -0
  51. package/dist/esm/src/textureConfig.js +168 -0
  52. package/dist/esm/src/transformControlsManager.js +827 -0
  53. package/dist/index.d.ts +259 -0
  54. package/package.json +53 -0
@@ -0,0 +1,321 @@
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
+ var Pathfinder = require('./Pathfinder.js');
8
+ var debugLogger = require('./debugLogger.js');
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n["default"] = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
29
+
30
+ var PathfindingManager = /*#__PURE__*/function () {
31
+ function PathfindingManager(component) {
32
+ _rollupPluginBabelHelpers.classCallCheck(this, PathfindingManager);
33
+ this.component = component;
34
+ this.crosscubeTextureSet = null;
35
+ this.pathfinderVersionInfo = null;
36
+
37
+ // Initialize pathfinder
38
+ this.pathfinder = new Pathfinder["default"](component === null || component === void 0 ? void 0 : component.sceneData);
39
+ }
40
+
41
+ /**
42
+ * Get pathfinder version information
43
+ */
44
+ return _rollupPluginBabelHelpers.createClass(PathfindingManager, [{
45
+ key: "getPathfinderVersionInfo",
46
+ value: (function () {
47
+ var _getPathfinderVersionInfo = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
48
+ var versionInfo;
49
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
50
+ while (1) switch (_context.n) {
51
+ case 0:
52
+ if (!this.pathfinderVersionInfo) {
53
+ _context.n = 1;
54
+ break;
55
+ }
56
+ return _context.a(2, this.pathfinderVersionInfo);
57
+ case 1:
58
+ versionInfo = {
59
+ version: '1.0.15',
60
+ detectionMethod: 'hardcoded-fallback',
61
+ timestamp: new Date().toISOString()
62
+ };
63
+ this.pathfinderVersionInfo = versionInfo;
64
+ return _context.a(2, versionInfo);
65
+ }
66
+ }, _callee, this);
67
+ }));
68
+ function getPathfinderVersionInfo() {
69
+ return _getPathfinderVersionInfo.apply(this, arguments);
70
+ }
71
+ return getPathfinderVersionInfo;
72
+ }()
73
+ /**
74
+ * Log pathfinder version information
75
+ */
76
+ )
77
+ }, {
78
+ key: "logPathfinderVersion",
79
+ value: (function () {
80
+ var _logPathfinderVersion = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2() {
81
+ var context,
82
+ versionInfo,
83
+ _args2 = arguments,
84
+ _t;
85
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
86
+ while (1) switch (_context2.n) {
87
+ case 0:
88
+ context = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 'Unknown Context';
89
+ _context2.p = 1;
90
+ _context2.n = 2;
91
+ return this.getPathfinderVersionInfo();
92
+ case 2:
93
+ versionInfo = _context2.v;
94
+ debugLogger.pathfinderLogger.info("[".concat(context, "] Pathfinder Module Information:"), {
95
+ version: versionInfo.version,
96
+ detectionMethod: versionInfo.detectionMethod,
97
+ context: context,
98
+ timestamp: versionInfo.timestamp,
99
+ pathfinderInstance: !!this.pathfinder
100
+ });
101
+ _context2.n = 4;
102
+ break;
103
+ case 3:
104
+ _context2.p = 3;
105
+ _t = _context2.v;
106
+ debugLogger.pathfinderLogger.error("[".concat(context, "] Failed to get pathfinder version:"), _t);
107
+ case 4:
108
+ return _context2.a(2);
109
+ }
110
+ }, _callee2, this, [[1, 3]]);
111
+ }));
112
+ function logPathfinderVersion() {
113
+ return _logPathfinderVersion.apply(this, arguments);
114
+ }
115
+ return logPathfinderVersion;
116
+ }()
117
+ /**
118
+ * Get path colors for visual distinction
119
+ */
120
+ )
121
+ }, {
122
+ key: "getPathColor",
123
+ value: function getPathColor(index) {
124
+ var colors = ['#468e49', '#245e29', '#2e80d2', '#1d51a1'];
125
+ return colors[index % colors.length];
126
+ }
127
+
128
+ /**
129
+ * Initialize pathfinder and create paths
130
+ */
131
+ }, {
132
+ key: "initializePathfinder",
133
+ value: (function () {
134
+ var _initializePathfinder = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3(data, crosscubeTextureSet) {
135
+ var _data$scene;
136
+ var component, paths;
137
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
138
+ while (1) switch (_context3.n) {
139
+ case 0:
140
+ if (Pathfinder["default"]) {
141
+ _context3.n = 1;
142
+ break;
143
+ }
144
+ _context3.n = 1;
145
+ return importPathfinder();
146
+ case 1:
147
+ component = this.component;
148
+ this.crosscubeTextureSet = crosscubeTextureSet;
149
+
150
+ // Log pathfinder version information
151
+ _context3.n = 2;
152
+ return this.logPathfinderVersion('Scene Loading');
153
+ case 2:
154
+ this.pathfinder = new Pathfinder["default"](data);
155
+ if (component) component.pathfinder = this.pathfinder;
156
+
157
+ // Add debugging for pathfinder input
158
+ console.log('🔍 PATHFINDER DEBUGGING:');
159
+ console.log('🔗 Connections:', data.connections);
160
+ console.log('🏗️ Scene structure:', JSON.parse(JSON.stringify((_data$scene = data.scene) === null || _data$scene === void 0 ? void 0 : _data$scene.object)));
161
+
162
+ // Ensure connections exist before finding paths
163
+ if (!(!data.connections || !Array.isArray(data.connections))) {
164
+ _context3.n = 3;
165
+ break;
166
+ }
167
+ console.warn('⚠️ No connections found in scene data, skipping path finding');
168
+ return _context3.a(2, []);
169
+ case 3:
170
+ paths = this.pathfinder.findPaths();
171
+ console.log('Found paths:', paths);
172
+
173
+ // Create pipe paths with materials
174
+ return _context3.a(2, this.createPipePaths(paths, crosscubeTextureSet));
175
+ }
176
+ }, _callee3, this);
177
+ }));
178
+ function initializePathfinder(_x, _x2) {
179
+ return _initializePathfinder.apply(this, arguments);
180
+ }
181
+ return initializePathfinder;
182
+ }()
183
+ /**
184
+ * Remove all existing paths from the scene
185
+ */
186
+ )
187
+ }, {
188
+ key: "removeAllPaths",
189
+ value: function removeAllPaths() {
190
+ var component = this.component;
191
+ if (!component || !component.scene) {
192
+ return;
193
+ }
194
+ console.log("removeAllPaths started");
195
+ var objectsToRemove = [];
196
+
197
+ // Find all path objects in the scene
198
+ component.scene.traverse(function (child) {
199
+ if (child.userData && child.userData.isPathObject) {
200
+ objectsToRemove.push(child);
201
+ }
202
+ });
203
+
204
+ // Remove all found path objects
205
+ objectsToRemove.forEach(function (object) {
206
+ object.parent.remove(object);
207
+
208
+ // Dispose of geometries and materials
209
+ if (object.geometry) {
210
+ object.geometry.dispose();
211
+ }
212
+ if (object.material) {
213
+ if (Array.isArray(object.material)) {
214
+ object.material.forEach(function (material) {
215
+ return material.dispose();
216
+ });
217
+ } else {
218
+ object.material.dispose();
219
+ }
220
+ }
221
+ });
222
+ console.log("Removed ".concat(objectsToRemove.length, " path objects"));
223
+ }
224
+
225
+ /**
226
+ * Material factory function to reduce duplication
227
+ */
228
+ }, {
229
+ key: "createPipeMaterial",
230
+ value: function createPipeMaterial(crosscubeTextureSet, pathIndex) {
231
+ var color = this.getPathColor(pathIndex);
232
+ var material = new THREE__namespace.MeshStandardMaterial({
233
+ color: new THREE__namespace.Color(color),
234
+ roughness: 0.3,
235
+ metalness: 0.8,
236
+ envMap: crosscubeTextureSet ? crosscubeTextureSet.envMap : null
237
+ });
238
+ return material;
239
+ }
240
+
241
+ /**
242
+ * Helper function to create pipe paths
243
+ */
244
+ }, {
245
+ key: "createPipePaths",
246
+ value: function createPipePaths(paths, crosscubeTextureSet) {
247
+ var _this = this;
248
+ var component = this.component;
249
+ if (!component || !component.scene) {
250
+ console.warn('Cannot create pipe paths: component or scene not available');
251
+ return [];
252
+ }
253
+
254
+ // Remove existing paths before creating new ones
255
+ this.removeAllPaths();
256
+ var pipeObjects = [];
257
+ paths.forEach(function (path, pathIndex) {
258
+ if (!path || !path.points || path.points.length < 2) {
259
+ console.warn('Invalid path data, skipping:', path);
260
+ return;
261
+ }
262
+ try {
263
+ var material = _this.createPipeMaterial(crosscubeTextureSet, pathIndex);
264
+
265
+ // Create a path from the points
266
+ var points = path.points.map(function (point) {
267
+ return new THREE__namespace.Vector3(point.x, point.y, point.z);
268
+ });
269
+ var curve = new THREE__namespace.CatmullRomCurve3(points);
270
+
271
+ // Create the pipe geometry
272
+ var pipeRadius = 0.15;
273
+ var radialSegments = 8;
274
+ var tubularSegments = points.length * 3;
275
+ var geometry = new THREE__namespace.TubeGeometry(curve, tubularSegments, pipeRadius, radialSegments, false);
276
+
277
+ // Create the mesh
278
+ var pipe = new THREE__namespace.Mesh(geometry, material);
279
+
280
+ // Add metadata
281
+ pipe.userData = {
282
+ isPathObject: true,
283
+ pathIndex: pathIndex,
284
+ connectionId: path.connectionId,
285
+ startComponentId: path.startComponentId,
286
+ endComponentId: path.endComponentId
287
+ };
288
+
289
+ // Add to scene
290
+ component.scene.add(pipe);
291
+ pipeObjects.push(pipe);
292
+ } catch (error) {
293
+ console.error('Error creating pipe for path:', path, error);
294
+ }
295
+ });
296
+ return pipeObjects;
297
+ }
298
+ }]);
299
+ }();
300
+
301
+ // Create a singleton instance
302
+ var pathfindingManager = null;
303
+
304
+ /**
305
+ * Get the global pathfinding manager instance
306
+ */
307
+ function getPathfindingManager() {
308
+ var component = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
309
+ if (!pathfindingManager || component && pathfindingManager.component !== component) {
310
+ pathfindingManager = new PathfindingManager(component);
311
+ }
312
+ return pathfindingManager;
313
+ }
314
+ var pathfindingManager$1 = {
315
+ PathfindingManager: PathfindingManager,
316
+ getPathfindingManager: getPathfindingManager
317
+ };
318
+
319
+ exports.PathfindingManager = PathfindingManager;
320
+ exports["default"] = pathfindingManager$1;
321
+ exports.getPathfindingManager = getPathfindingManager;