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