@2112-lab/central-plant 0.1.1 → 0.1.3
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/bundle/index.js +1 -15140
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -353
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1292
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1543
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4374
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -465
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -117
- package/dist/cjs/src/animationManager.js +1 -121
- package/dist/cjs/src/componentManager.js +1 -151
- package/dist/cjs/src/debugLogger.js +1 -176
- package/dist/cjs/src/disposalManager.js +1 -185
- package/dist/cjs/src/environmentManager.js +1 -1308
- package/dist/cjs/src/hotReloadManager.js +1 -252
- package/dist/cjs/src/index.js +1 -128
- package/dist/cjs/src/keyboardControlsManager.js +1 -206
- package/dist/cjs/src/nameUtils.js +1 -106
- package/dist/cjs/src/pathfindingManager.js +1 -321
- package/dist/cjs/src/performanceMonitor.js +1 -718
- package/dist/cjs/src/sceneExportManager.js +1 -292
- package/dist/cjs/src/sceneInitializationManager.js +1 -540
- package/dist/cjs/src/textureConfig.js +1 -624
- package/dist/cjs/src/transformControlsManager.js +1 -851
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -328
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1287
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1537
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4370
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -461
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -113
- package/dist/esm/src/animationManager.js +1 -112
- package/dist/esm/src/componentManager.js +1 -123
- package/dist/esm/src/debugLogger.js +1 -167
- package/dist/esm/src/disposalManager.js +1 -155
- package/dist/esm/src/environmentManager.js +1 -1282
- package/dist/esm/src/hotReloadManager.js +1 -244
- package/dist/esm/src/index.js +1 -118
- package/dist/esm/src/keyboardControlsManager.js +1 -196
- package/dist/esm/src/nameUtils.js +1 -99
- package/dist/esm/src/pathfindingManager.js +1 -295
- package/dist/esm/src/performanceMonitor.js +1 -712
- package/dist/esm/src/sceneExportManager.js +1 -286
- package/dist/esm/src/sceneInitializationManager.js +1 -513
- package/dist/esm/src/textureConfig.js +1 -595
- package/dist/esm/src/transformControlsManager.js +1 -827
- package/dist/index.d.ts +0 -4
- package/package.json +1 -1
- package/dist/cjs/src/ConnectionManager.js +0 -114
- package/dist/cjs/src/Pathfinder.js +0 -88
- package/dist/cjs/src/modelPreloader.js +0 -488
- package/dist/cjs/src/sceneOperationsManager.js +0 -596
- package/dist/esm/src/ConnectionManager.js +0 -110
- package/dist/esm/src/Pathfinder.js +0 -84
- package/dist/esm/src/modelPreloader.js +0 -464
- package/dist/esm/src/sceneOperationsManager.js +0 -572
|
@@ -1,106 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Name Utilities
|
|
7
|
-
* Common helper functions for name and UUID generation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generate UUID from name using consistent transformation rules
|
|
12
|
-
* @param {string} name - The name to convert to UUID
|
|
13
|
-
* @returns {string} The generated UUID
|
|
14
|
-
*/
|
|
15
|
-
function generateUuidFromName(name) {
|
|
16
|
-
if (!name) return null;
|
|
17
|
-
|
|
18
|
-
// Convert name to uppercase and replace spaces with hyphens
|
|
19
|
-
var uuid = name.toUpperCase().replace(/\s+COMPONENT$/i, '') // Remove "Component" suffix
|
|
20
|
-
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
|
21
|
-
.replace(/[^A-Z0-9\-]/g, ''); // Remove special characters except hyphens
|
|
22
|
-
|
|
23
|
-
// Clean up any duplicate "COMPONENT" text that might have been left behind
|
|
24
|
-
uuid = uuid.replace(/-COMPONENT$/, '');
|
|
25
|
-
return uuid;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Check if two names would generate the same UUID
|
|
30
|
-
* @param {string} name1 - First name
|
|
31
|
-
* @param {string} name2 - Second name
|
|
32
|
-
* @returns {boolean} Whether the names generate the same UUID
|
|
33
|
-
*/
|
|
34
|
-
function namesGenerateSameUuid(name1, name2) {
|
|
35
|
-
var uuid1 = generateUuidFromName(name1);
|
|
36
|
-
var uuid2 = generateUuidFromName(name2);
|
|
37
|
-
return uuid1 && uuid2 && uuid1 === uuid2;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find an object in a Three.js scene by hardcoded UUID with fallback strategies
|
|
42
|
-
* @param {THREE.Scene} scene - The Three.js scene to search
|
|
43
|
-
* @param {string} targetUuid - The UUID to search for
|
|
44
|
-
* @returns {THREE.Object3D|null} The found object or null
|
|
45
|
-
*/
|
|
46
|
-
function findObjectByHardcodedUuid(scene, targetUuid) {
|
|
47
|
-
if (!scene || !targetUuid) return null;
|
|
48
|
-
var foundObject = null;
|
|
49
|
-
scene.traverse(function (child) {
|
|
50
|
-
var _child$userData;
|
|
51
|
-
if (foundObject) return; // Stop if already found
|
|
52
|
-
|
|
53
|
-
// Strategy 1: Direct UUID match (HIGHEST PRIORITY)
|
|
54
|
-
if (child.uuid === targetUuid) {
|
|
55
|
-
foundObject = child;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Strategy 2: Original hardcoded UUID match
|
|
60
|
-
if (((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.originalUuid) === targetUuid) {
|
|
61
|
-
foundObject = child;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Strategy 3: Name-based UUID match (FALLBACK)
|
|
66
|
-
if (child.name) {
|
|
67
|
-
var generatedUuid = generateUuidFromName(child.name);
|
|
68
|
-
if (generatedUuid === targetUuid) {
|
|
69
|
-
foundObject = child;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return foundObject;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get the hardcoded UUID for an object, prioritizing original over current
|
|
79
|
-
* @param {THREE.Object3D} object - The Three.js object
|
|
80
|
-
* @returns {string|null} The hardcoded UUID or null
|
|
81
|
-
*/
|
|
82
|
-
function getHardcodedUuid(object) {
|
|
83
|
-
var _object$userData;
|
|
84
|
-
if (!object) return null;
|
|
85
|
-
|
|
86
|
-
// Priority 1: Original hardcoded UUID stored in userData
|
|
87
|
-
if ((_object$userData = object.userData) !== null && _object$userData !== void 0 && _object$userData.originalUuid) {
|
|
88
|
-
return object.userData.originalUuid;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Priority 2: Current UUID (if it looks like a hardcoded one)
|
|
92
|
-
if (object.uuid && !object.uuid.includes('-') && object.uuid.length > 10) {
|
|
93
|
-
return object.uuid;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Priority 3: Generate from name if available
|
|
97
|
-
if (object.name) {
|
|
98
|
-
return generateUuidFromName(object.name);
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
exports.findObjectByHardcodedUuid = findObjectByHardcodedUuid;
|
|
104
|
-
exports.generateUuidFromName = generateUuidFromName;
|
|
105
|
-
exports.getHardcodedUuid = getHardcodedUuid;
|
|
106
|
-
exports.namesGenerateSameUuid = namesGenerateSameUuid;
|
|
1
|
+
"use strict";function r(r){if(!r)return null;var n=r.toUpperCase().replace(/\s+COMPONENT$/i,"").replace(/\s+/g,"-").replace(/[^A-Z0-9\-]/g,"");return n=n.replace(/-COMPONENT$/,"")}Object.defineProperty(exports,"u",{value:!0}),exports.findObjectByHardcodedUuid=function(n,u){if(!n||!u)return null;var e=null;return n.traverse(function(n){var t;if(!e)if(n.uuid!==u)if((null===(t=n.userData)||void 0===t?void 0:t.originalUuid)!==u){if(n.name&&r(n.name)===u)return void(e=n)}else e=n;else e=n}),e},exports.generateUuidFromName=r,exports.getHardcodedUuid=function(n){var u;return n?null!==(u=n.userData)&&void 0!==u&&u.originalUuid?n.userData.originalUuid:n.uuid&&!n.uuid.includes("-")&&n.uuid.length>10?n.uuid:n.name?r(n.name):null:null},exports.namesGenerateSameUuid=function(n,u){var e=r(n),t=r(u);return e&&t&&e===t};
|
|
@@ -1,321 +1 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),t=require("three"),n=require("../node_modules/@2112-lab/pathfinder/dist/index.esm.js"),i=require("./debugLogger.js"),r=require("./nameUtils.js");function a(e){if(e&&e.t)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var s=a(t),u=function(){return e.createClass(function t(n){e.classCallCheck(this,t),this.component=n,this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null},[{key:"getPathfinderVersionInfo",value:(c=e.asyncToGenerator(e.regenerator().m(function t(){var n;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(!this.pathfinderVersionInfo){e.n=1;break}return e.a(2,this.pathfinderVersionInfo);case 1:return n={version:"1.0.15",detectionMethod:"hardcoded-fallback",timestamp:(new Date).toISOString()},this.pathfinderVersionInfo=n,e.a(2,n)}},t,this)})),function(){return c.apply(this,arguments)})},{key:"logPathfinderVersion",value:(o=e.asyncToGenerator(e.regenerator().m(function t(){var n,r,a,s=arguments;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:return n=s.length>0&&void 0!==s[0]?s[0]:"Unknown Context",e.p=1,e.n=2,this.getPathfinderVersionInfo();case 2:r=e.v,i.pathfinderLogger.info("[".concat(n,"] Pathfinder Module Information:"),{version:r.version,detectionMethod:r.detectionMethod,context:n,timestamp:r.timestamp,pathfinderInstance:!!this.pathfinder}),e.n=4;break;case 3:e.p=3,a=e.v,i.pathfinderLogger.error("[".concat(n,"] Failed to get pathfinder version:"),a);case 4:return e.a(2)}},t,this,[[1,3]])})),function(){return o.apply(this,arguments)})},{key:"getPathColor",value:function(e){var t=["#468e49","#245e29","#2e80d2","#1d51a1"];return t[e%t.length]}},{key:"initializePathfinder",value:(u=e.asyncToGenerator(e.regenerator().m(function t(i,r){var a,s;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:return a=this.component,this.crosscubeTextureSet=r,e.n=1,this.logPathfinderVersion("Scene Loading");case 1:this.pathfinder=new n.Pathfinder(i),a.pathfinder=this.pathfinder,s=this.pathfinder.findPaths(),this.createPipePaths(s,r);case 2:return e.a(2)}},t,this)})),function(e,t){return u.apply(this,arguments)})},{key:"removeAllPaths",value:function(){var e=this.component,t=[];e.scene.traverse(function(e){e.name&&e.name.includes("Polyline")&&t.push(e)});for(var n=0,i=t;n<i.length;n++){var r=i[n];e.scene.remove(r),r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(function(e){return e.dispose()}):r.material.dispose())}}},{key:"createPipeMaterial",value:function(t,n){if(t){var i=e.objectSpread2(e.objectSpread2({},t.config.materialProps),{},{color:this.getPathColor(n),map:t.textures.diffuse,normalMap:t.textures.normal,roughnessMap:t.textures.roughness,metalness:.2,roughness:.9,clearcoat:.2,clearcoatRoughness:.2,envMapIntensity:.6,reflectivity:.4});i.normalScale&&Array.isArray(i.normalScale)&&(i.normalScale=e.construct(s.Vector2,e.toConsumableArray(i.normalScale)));var r=new s.MeshPhysicalMaterial(i);return[r.map,r.normalMap,r.roughnessMap].filter(Boolean).forEach(function(e){e.wrapS=e.wrapT=s.RepeatWrapping,e.repeat.set(2*t.config.repeat.x,2*t.config.repeat.y)}),r}return new s.MeshPhysicalMaterial({color:this.getPathColor(n),metalness:.9,roughness:.7,clearcoat:.1,clearcoatRoughness:.3,envMapIntensity:1.5,reflectivity:.3})}},{key:"createPipePaths",value:function(e,t){var n=this,i=this.component;e.forEach(function(e,r){if(e.path){var a=new s.Object3D;a.name="Polyline ".concat(e.from,"-").concat(e.to);for(var u=n.createPipeMaterial(t,r),o=0;o<e.path.length-1;o++){var c=e.path[o],h=e.path[o+1],l=(new s.Vector3).subVectors(h,c),f=l.length(),v=new s.CylinderGeometry(.1,.1,f,8,1,!1),d=new s.Mesh(v,u);d.position.copy(c).add(h).multiplyScalar(.5);var p=new s.Quaternion,w=new s.Vector3(0,1,0);if(p.setFromUnitVectors(w,l.normalize()),d.quaternion.copy(p),d.castShadow=!0,d.receiveShadow=!0,a.add(d),o<e.path.length-2){var y=e.path[o+1],g=e.path[o+2],m=l.normalize(),k=(new s.Vector3).subVectors(g,y).normalize(),P=Math.acos(m.dot(k));if(Math.abs(P-Math.PI/2)<.1){var b=new s.SphereGeometry(.1,16,16),M=new s.Mesh(b,u);M.position.copy(h),M.castShadow=!0,M.receiveShadow=!0,a.add(M)}}}a.name="Polyline",i.scene.add(a)}})}},{key:"recomputeWorldBoundingBoxes",value:function(t){this.component.scene.traverse(function(n){if(n.isMesh){var i=null,a=function(t){var i,s=e.createForOfIteratorHelper(t);try{for(s.s();!(i=s.n()).done;){var u,o,c=i.value;if(c.uuid===n.uuid||c.uuid===(null===(u=n.userData)||void 0===u?void 0:u.originalUuid)||n.uuid===(null===(o=c.userData)||void 0===o?void 0:o.originalUuid))return c;if(n.name&&c.name){var h=r.generateUuidFromName(n.name),l=r.generateUuidFromName(c.name);if(h===l||h===c.uuid||l===n.uuid)return c}if(n.name&&c.name&&n.name===c.name)return c;if(c.children){var f=a(c.children);if(f)return f}}}catch(e){s.e(e)}finally{s.f()}return null};if(i=a(t.scene.object.children)){var u=(new s.Box3).setFromObject(n);i.userData||(i.userData={}),i.userData.worldBoundingBox={min:u.min.toArray(),max:u.max.toArray()}}}})}},{key:"updatePathfindingWithConnections",value:(a=e.asyncToGenerator(e.regenerator().m(function t(i){var r,a,s;return e.regenerator().w(function(t){for(;;)switch(t.n){case 0:if((r=this.component).currentSceneData){t.n=1;break}return t.a(2,!1);case 1:return this.removeAllPaths(),(a=JSON.parse(JSON.stringify(r.currentSceneData))).connections=e.toConsumableArray(i),t.n=2,this.logPathfinderVersion("Connections Update");case 2:return this.pathfinder=new n.Pathfinder(a),r.pathfinder=this.pathfinder,s=this.pathfinder.findPaths(),this.createPipePaths(s,this.crosscubeTextureSet),r.currentSceneData=a,t.a(2,!0)}},t,this)})),function(e){return a.apply(this,arguments)})},{key:"updatePathfindingAfterTransform",value:(t=e.asyncToGenerator(e.regenerator().m(function t(i){var r;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:return this.removeAllPaths(),e.n=1,this.logPathfinderVersion("Transform Update");case 1:this.pathfinder=new n.Pathfinder(i),this.component.pathfinder=this.pathfinder,r=this.pathfinder.findPaths(),this.createPipePaths(r,this.crosscubeTextureSet);case 2:return e.a(2)}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"dispose",value:function(){this.removeAllPaths(),this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,i.logger.info("PathfindingManager disposed")}}]);var t,a,u,o,c}();exports.PathfindingManager=u;
|