@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,84 @@
|
|
|
1
|
+
import { createClass as _createClass, toConsumableArray as _toConsumableArray, classCallCheck as _classCallCheck } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import ConnectionManager from './ConnectionManager.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pathfinder class
|
|
6
|
+
* Enhanced version with better error handling for missing data
|
|
7
|
+
*/
|
|
8
|
+
var Pathfinder = /*#__PURE__*/function () {
|
|
9
|
+
function Pathfinder(sceneData) {
|
|
10
|
+
_classCallCheck(this, Pathfinder);
|
|
11
|
+
this.sceneData = sceneData || {};
|
|
12
|
+
this.connectionManager = new ConnectionManager();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Find paths in the scene
|
|
17
|
+
* @returns {Array} Array of paths
|
|
18
|
+
*/
|
|
19
|
+
return _createClass(Pathfinder, [{
|
|
20
|
+
key: "findPaths",
|
|
21
|
+
value: function findPaths() {
|
|
22
|
+
var _this = this;
|
|
23
|
+
console.log('[DEBUG] Starting findPaths()');
|
|
24
|
+
try {
|
|
25
|
+
var connections = this.sceneData.connections;
|
|
26
|
+
|
|
27
|
+
// Safety check for connections
|
|
28
|
+
if (!connections || !Array.isArray(connections)) {
|
|
29
|
+
console.warn('Pathfinder: No valid connections provided in scene data');
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Create clusters from connections
|
|
34
|
+
var clusters = this.connectionManager.clusterConnections(connections);
|
|
35
|
+
|
|
36
|
+
// Return empty array if there are no valid clusters
|
|
37
|
+
if (!clusters || !clusters.length) {
|
|
38
|
+
console.log('Pathfinder: No valid connection clusters generated');
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Process the clusters and generate paths
|
|
43
|
+
// (Simplified implementation, the actual process would be more complex)
|
|
44
|
+
var paths = [];
|
|
45
|
+
clusters.forEach(function (cluster) {
|
|
46
|
+
if (cluster && cluster.objects && Array.isArray(cluster.objects)) {
|
|
47
|
+
// Generate path for this cluster
|
|
48
|
+
var clusterPaths = _this._generatePathsForCluster(cluster);
|
|
49
|
+
paths.push.apply(paths, _toConsumableArray(clusterPaths));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return paths;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Pathfinder: Error finding paths:', error);
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generate paths for a single cluster
|
|
61
|
+
* @param {Object} cluster - The cluster to generate paths for
|
|
62
|
+
* @returns {Array} Array of paths for this cluster
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
}, {
|
|
66
|
+
key: "_generatePathsForCluster",
|
|
67
|
+
value: function _generatePathsForCluster(cluster) {
|
|
68
|
+
// This is a placeholder implementation
|
|
69
|
+
// In your actual system, this would use your existing pathfinding logic
|
|
70
|
+
return cluster.objects.map(function (obj, index, arr) {
|
|
71
|
+
if (index < arr.length - 1) {
|
|
72
|
+
return {
|
|
73
|
+
from: obj,
|
|
74
|
+
to: arr[index + 1],
|
|
75
|
+
path: [] // This would normally contain 3D points for the path
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}).filter(Boolean);
|
|
80
|
+
}
|
|
81
|
+
}]);
|
|
82
|
+
}();
|
|
83
|
+
|
|
84
|
+
export { Pathfinder as default };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { logger } from './debugLogger.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Animation Manager
|
|
5
|
+
* Handles animation loops and timing
|
|
6
|
+
*/
|
|
7
|
+
var animationFrameId = null;
|
|
8
|
+
var isAnimating = false;
|
|
9
|
+
var lastTime = 0;
|
|
10
|
+
var callbacks = [];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Start the animation loop
|
|
14
|
+
*/
|
|
15
|
+
function startAnimation(component) {
|
|
16
|
+
if (isAnimating) return;
|
|
17
|
+
isAnimating = true;
|
|
18
|
+
lastTime = performance.now();
|
|
19
|
+
var _animate = function animate(time) {
|
|
20
|
+
if (!isAnimating) return;
|
|
21
|
+
|
|
22
|
+
// Calculate delta time
|
|
23
|
+
var deltaTime = (time - lastTime) / 1000; // in seconds
|
|
24
|
+
lastTime = time;
|
|
25
|
+
|
|
26
|
+
// Execute animation callbacks
|
|
27
|
+
executeCallbacks(time, deltaTime);
|
|
28
|
+
|
|
29
|
+
// Render if component exists
|
|
30
|
+
if (component && component.renderer && component.scene && component.camera) {
|
|
31
|
+
component.renderer.render(component.scene, component.camera);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Update orbit controls if they exist
|
|
35
|
+
if (component && component.controls && component.controls.update) {
|
|
36
|
+
component.controls.update();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Continue animation loop
|
|
40
|
+
animationFrameId = requestAnimationFrame(_animate);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Start animation loop
|
|
44
|
+
animationFrameId = requestAnimationFrame(_animate);
|
|
45
|
+
logger.info('Animation loop started');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Stop the animation loop
|
|
50
|
+
*/
|
|
51
|
+
function stopAnimation() {
|
|
52
|
+
if (!isAnimating) return;
|
|
53
|
+
if (animationFrameId !== null) {
|
|
54
|
+
cancelAnimationFrame(animationFrameId);
|
|
55
|
+
animationFrameId = null;
|
|
56
|
+
}
|
|
57
|
+
isAnimating = false;
|
|
58
|
+
logger.info('Animation loop stopped');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Register an animation callback
|
|
63
|
+
*/
|
|
64
|
+
function addAnimationCallback(callback) {
|
|
65
|
+
if (typeof callback !== 'function') {
|
|
66
|
+
logger.warn('Invalid animation callback');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
callbacks.push(callback);
|
|
70
|
+
return callback;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Remove an animation callback
|
|
75
|
+
*/
|
|
76
|
+
function removeAnimationCallback(callback) {
|
|
77
|
+
var index = callbacks.indexOf(callback);
|
|
78
|
+
if (index !== -1) {
|
|
79
|
+
callbacks.splice(index, 1);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Execute all registered animation callbacks
|
|
87
|
+
*/
|
|
88
|
+
function executeCallbacks(time, deltaTime) {
|
|
89
|
+
callbacks.forEach(function (callback) {
|
|
90
|
+
try {
|
|
91
|
+
callback(time, deltaTime);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
logger.error('Error in animation callback:', error);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Check if animation is running
|
|
100
|
+
*/
|
|
101
|
+
function isAnimationRunning() {
|
|
102
|
+
return isAnimating;
|
|
103
|
+
}
|
|
104
|
+
var animationManager = {
|
|
105
|
+
startAnimation: startAnimation,
|
|
106
|
+
stopAnimation: stopAnimation,
|
|
107
|
+
addAnimationCallback: addAnimationCallback,
|
|
108
|
+
removeAnimationCallback: removeAnimationCallback,
|
|
109
|
+
isAnimationRunning: isAnimationRunning
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export { addAnimationCallback, animationManager as default, isAnimationRunning, removeAnimationCallback, startAnimation, stopAnimation };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { logger } from './debugLogger.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Load a component from data
|
|
7
|
+
*/
|
|
8
|
+
function loadComponent(_x) {
|
|
9
|
+
return _loadComponent.apply(this, arguments);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Place a component in the scene
|
|
14
|
+
*/
|
|
15
|
+
function _loadComponent() {
|
|
16
|
+
_loadComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(componentData) {
|
|
17
|
+
var component;
|
|
18
|
+
return _regenerator().w(function (_context) {
|
|
19
|
+
while (1) switch (_context.n) {
|
|
20
|
+
case 0:
|
|
21
|
+
logger.info("Loading component: ".concat(componentData.id || 'Unknown'));
|
|
22
|
+
|
|
23
|
+
// This is a stub implementation that will need to be expanded
|
|
24
|
+
component = {
|
|
25
|
+
id: componentData.id || 'unknown-component',
|
|
26
|
+
type: componentData.type || 'generic',
|
|
27
|
+
data: componentData,
|
|
28
|
+
object: new THREE.Group(),
|
|
29
|
+
position: componentData.position || {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
z: 0
|
|
33
|
+
},
|
|
34
|
+
rotation: componentData.rotation || {
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
z: 0
|
|
38
|
+
},
|
|
39
|
+
scale: componentData.scale || {
|
|
40
|
+
x: 1,
|
|
41
|
+
y: 1,
|
|
42
|
+
z: 1
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return _context.a(2, component);
|
|
46
|
+
}
|
|
47
|
+
}, _callee);
|
|
48
|
+
}));
|
|
49
|
+
return _loadComponent.apply(this, arguments);
|
|
50
|
+
}
|
|
51
|
+
function placeComponent(component, position, rotation, scene) {
|
|
52
|
+
if (!component || !component.object) {
|
|
53
|
+
logger.error('Cannot place component: invalid component object');
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Set position
|
|
58
|
+
if (position) {
|
|
59
|
+
component.object.position.set(position.x || 0, position.y || 0, position.z || 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Set rotation
|
|
63
|
+
if (rotation) {
|
|
64
|
+
component.object.rotation.set(rotation.x || 0, rotation.y || 0, rotation.z || 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Add to scene if provided
|
|
68
|
+
if (scene && scene.add) {
|
|
69
|
+
scene.add(component.object);
|
|
70
|
+
}
|
|
71
|
+
return component;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Remove a component from the scene
|
|
76
|
+
*/
|
|
77
|
+
function removeComponent(componentId, scene) {
|
|
78
|
+
if (!scene) {
|
|
79
|
+
logger.error('Cannot remove component: scene not provided');
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Find the component by ID
|
|
84
|
+
var componentObject = null;
|
|
85
|
+
scene.traverse(function (object) {
|
|
86
|
+
if (object.userData && object.userData.id === componentId) {
|
|
87
|
+
componentObject = object;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (componentObject && componentObject.parent) {
|
|
91
|
+
componentObject.parent.remove(componentObject);
|
|
92
|
+
logger.info("Component removed: ".concat(componentId));
|
|
93
|
+
return true;
|
|
94
|
+
} else {
|
|
95
|
+
logger.warn("Component not found: ".concat(componentId));
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get a component by ID
|
|
102
|
+
*/
|
|
103
|
+
function getComponentById(id, scene) {
|
|
104
|
+
if (!scene) {
|
|
105
|
+
logger.error('Cannot get component: scene not provided');
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
var component = null;
|
|
109
|
+
scene.traverse(function (object) {
|
|
110
|
+
if (object.userData && object.userData.id === id) {
|
|
111
|
+
component = object;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return component;
|
|
115
|
+
}
|
|
116
|
+
var componentManager = {
|
|
117
|
+
loadComponent: loadComponent,
|
|
118
|
+
placeComponent: placeComponent,
|
|
119
|
+
removeComponent: removeComponent,
|
|
120
|
+
getComponentById: getComponentById
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { componentManager as default, getComponentById, loadComponent, placeComponent, removeComponent };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createClass as _createClass, toConsumableArray as _toConsumableArray, classCallCheck as _classCallCheck } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
|
|
3
|
+
// Debug logging utility to reduce excessive console statements
|
|
4
|
+
// Provides conditional logging based on environment and debug levels
|
|
5
|
+
|
|
6
|
+
var DebugLogger = /*#__PURE__*/function () {
|
|
7
|
+
function DebugLogger() {
|
|
8
|
+
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'SceneViewer';
|
|
9
|
+
var debugLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'info';
|
|
10
|
+
_classCallCheck(this, DebugLogger);
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.debugLevel = debugLevel;
|
|
13
|
+
this.isProduction = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
|
|
14
|
+
this.enabled = !this.isProduction;
|
|
15
|
+
|
|
16
|
+
// Debug levels: 'error', 'warn', 'info', 'debug', 'verbose'
|
|
17
|
+
this.levels = {
|
|
18
|
+
error: 0,
|
|
19
|
+
warn: 1,
|
|
20
|
+
info: 2,
|
|
21
|
+
debug: 3,
|
|
22
|
+
verbose: 4
|
|
23
|
+
};
|
|
24
|
+
this.currentLevel = this.levels[debugLevel] || this.levels.info;
|
|
25
|
+
}
|
|
26
|
+
return _createClass(DebugLogger, [{
|
|
27
|
+
key: "setLevel",
|
|
28
|
+
value: function setLevel(level) {
|
|
29
|
+
this.currentLevel = this.levels[level] || this.levels.info;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "enable",
|
|
34
|
+
value: function enable() {
|
|
35
|
+
this.enabled = true;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "disable",
|
|
40
|
+
value: function disable() {
|
|
41
|
+
this.enabled = false;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "_shouldLog",
|
|
46
|
+
value: function _shouldLog(level) {
|
|
47
|
+
return this.enabled && this.levels[level] <= this.currentLevel;
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "_formatMessage",
|
|
51
|
+
value: function _formatMessage(level, message) {
|
|
52
|
+
var prefix = "[".concat(this.namespace, ":").concat(level.toUpperCase(), "]");
|
|
53
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
54
|
+
args[_key - 2] = arguments[_key];
|
|
55
|
+
}
|
|
56
|
+
return [prefix, message].concat(args);
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "error",
|
|
60
|
+
value: function error(message) {
|
|
61
|
+
if (this._shouldLog('error')) {
|
|
62
|
+
var _console;
|
|
63
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
64
|
+
args[_key2 - 1] = arguments[_key2];
|
|
65
|
+
}
|
|
66
|
+
(_console = console).error.apply(_console, _toConsumableArray(this._formatMessage.apply(this, ['error', message].concat(args))));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "warn",
|
|
71
|
+
value: function warn(message) {
|
|
72
|
+
if (this._shouldLog('warn')) {
|
|
73
|
+
var _console2;
|
|
74
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
75
|
+
args[_key3 - 1] = arguments[_key3];
|
|
76
|
+
}
|
|
77
|
+
(_console2 = console).warn.apply(_console2, _toConsumableArray(this._formatMessage.apply(this, ['warn', message].concat(args))));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "info",
|
|
82
|
+
value: function info(message) {
|
|
83
|
+
if (this._shouldLog('info')) {
|
|
84
|
+
var _console3;
|
|
85
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
86
|
+
args[_key4 - 1] = arguments[_key4];
|
|
87
|
+
}
|
|
88
|
+
(_console3 = console).log.apply(_console3, _toConsumableArray(this._formatMessage.apply(this, ['info', message].concat(args))));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "debug",
|
|
93
|
+
value: function debug(message) {
|
|
94
|
+
if (this._shouldLog('debug')) {
|
|
95
|
+
var _console4;
|
|
96
|
+
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
97
|
+
args[_key5 - 1] = arguments[_key5];
|
|
98
|
+
}
|
|
99
|
+
(_console4 = console).debug.apply(_console4, _toConsumableArray(this._formatMessage.apply(this, ['debug', message].concat(args))));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "verbose",
|
|
104
|
+
value: function verbose(message) {
|
|
105
|
+
if (this._shouldLog('verbose')) {
|
|
106
|
+
var _console5;
|
|
107
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
108
|
+
args[_key6 - 1] = arguments[_key6];
|
|
109
|
+
}
|
|
110
|
+
(_console5 = console).debug.apply(_console5, _toConsumableArray(this._formatMessage.apply(this, ['verbose', message].concat(args))));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Special methods for common patterns
|
|
115
|
+
}, {
|
|
116
|
+
key: "phase",
|
|
117
|
+
value: function phase(phaseNumber, message) {
|
|
118
|
+
for (var _len7 = arguments.length, args = new Array(_len7 > 2 ? _len7 - 2 : 0), _key7 = 2; _key7 < _len7; _key7++) {
|
|
119
|
+
args[_key7 - 2] = arguments[_key7];
|
|
120
|
+
}
|
|
121
|
+
this.info.apply(this, ["\uD83D\uDD0D PHASE ".concat(phaseNumber, ": ").concat(message)].concat(args));
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "success",
|
|
125
|
+
value: function success(message) {
|
|
126
|
+
for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
|
|
127
|
+
args[_key8 - 1] = arguments[_key8];
|
|
128
|
+
}
|
|
129
|
+
this.info.apply(this, ["\u2705 ".concat(message)].concat(args));
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "failure",
|
|
133
|
+
value: function failure(message) {
|
|
134
|
+
for (var _len9 = arguments.length, args = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
|
|
135
|
+
args[_key9 - 1] = arguments[_key9];
|
|
136
|
+
}
|
|
137
|
+
this.error.apply(this, ["\u274C ".concat(message)].concat(args));
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "loading",
|
|
141
|
+
value: function loading(message) {
|
|
142
|
+
for (var _len0 = arguments.length, args = new Array(_len0 > 1 ? _len0 - 1 : 0), _key0 = 1; _key0 < _len0; _key0++) {
|
|
143
|
+
args[_key0 - 1] = arguments[_key0];
|
|
144
|
+
}
|
|
145
|
+
this.debug.apply(this, ["\uD83D\uDD04 ".concat(message)].concat(args));
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "timing",
|
|
149
|
+
value: function timing(message) {
|
|
150
|
+
for (var _len1 = arguments.length, args = new Array(_len1 > 1 ? _len1 - 1 : 0), _key1 = 1; _key1 < _len1; _key1++) {
|
|
151
|
+
args[_key1 - 1] = arguments[_key1];
|
|
152
|
+
}
|
|
153
|
+
this.debug.apply(this, ["\u23F1\uFE0F ".concat(message)].concat(args));
|
|
154
|
+
}
|
|
155
|
+
}]);
|
|
156
|
+
}();
|
|
157
|
+
|
|
158
|
+
// Create default logger instance
|
|
159
|
+
var logger = new DebugLogger('SceneViewer', 'info');
|
|
160
|
+
|
|
161
|
+
// Create specialized loggers for different subsystems
|
|
162
|
+
var transformLogger = new DebugLogger('Transform', 'warn');
|
|
163
|
+
var pathfinderLogger = new DebugLogger('Pathfinder', 'info');
|
|
164
|
+
var modelLogger = new DebugLogger('Models', 'info');
|
|
165
|
+
var materialLogger = new DebugLogger('Materials', 'warn');
|
|
166
|
+
|
|
167
|
+
export { DebugLogger, logger, materialLogger, modelLogger, pathfinderLogger, transformLogger };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { logger } from './debugLogger.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dispose a Three.js object including geometry, material, and textures
|
|
7
|
+
*/
|
|
8
|
+
function disposeObject(object) {
|
|
9
|
+
if (!object) return;
|
|
10
|
+
|
|
11
|
+
// Dispose geometry
|
|
12
|
+
if (object.geometry) {
|
|
13
|
+
object.geometry.dispose();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Dispose material(s)
|
|
17
|
+
if (object.material) {
|
|
18
|
+
if (Array.isArray(object.material)) {
|
|
19
|
+
object.material.forEach(function (material) {
|
|
20
|
+
return disposeMaterial(material);
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
disposeMaterial(object.material);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Dispose any children
|
|
28
|
+
if (object.children && object.children.length > 0) {
|
|
29
|
+
// Work with a copy of the children array to avoid issues during iteration
|
|
30
|
+
var children = _toConsumableArray(object.children);
|
|
31
|
+
children.forEach(function (child) {
|
|
32
|
+
return disposeObject(child);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Dispose a Three.js material and its textures
|
|
39
|
+
*/
|
|
40
|
+
function disposeMaterial(material) {
|
|
41
|
+
if (!material) return;
|
|
42
|
+
|
|
43
|
+
// Dispose textures
|
|
44
|
+
Object.keys(material).forEach(function (key) {
|
|
45
|
+
var value = material[key];
|
|
46
|
+
if (value && value instanceof THREE.Texture) {
|
|
47
|
+
value.dispose();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Dispose the material itself
|
|
52
|
+
material.dispose();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Clean up a Three.js scene
|
|
57
|
+
*/
|
|
58
|
+
function cleanupScene(scene) {
|
|
59
|
+
if (!scene) {
|
|
60
|
+
logger.warn('Cannot cleanup: scene not provided');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Dispose all objects in the scene
|
|
65
|
+
while (scene.children.length > 0) {
|
|
66
|
+
var object = scene.children[0];
|
|
67
|
+
scene.remove(object);
|
|
68
|
+
disposeObject(object);
|
|
69
|
+
}
|
|
70
|
+
logger.info('Scene cleared and disposed');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Clean up a Three.js renderer
|
|
75
|
+
*/
|
|
76
|
+
function cleanupRenderer(renderer) {
|
|
77
|
+
if (!renderer) {
|
|
78
|
+
logger.warn('Cannot cleanup: renderer not provided');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
renderer.dispose();
|
|
82
|
+
|
|
83
|
+
// Remove from DOM if possible
|
|
84
|
+
var canvas = renderer.domElement;
|
|
85
|
+
if (canvas && canvas.parentNode) {
|
|
86
|
+
canvas.parentNode.removeChild(canvas);
|
|
87
|
+
}
|
|
88
|
+
logger.info('Renderer disposed');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Clean up Nuxt-specific event listeners
|
|
93
|
+
*/
|
|
94
|
+
function cleanupNuxtEventListeners() {
|
|
95
|
+
if (typeof window === 'undefined' || !window.$nuxt) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Clean up any registered event listeners
|
|
100
|
+
if (window.$nuxt.$off) {
|
|
101
|
+
// This is a simple placeholder - actual implementation would need to track
|
|
102
|
+
// specific listeners that were registered
|
|
103
|
+
logger.info('Nuxt event listeners cleaned up');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Comprehensive cleanup of Three.js resources
|
|
109
|
+
*/
|
|
110
|
+
function cleanupThreeJsResources(component) {
|
|
111
|
+
if (!component) return;
|
|
112
|
+
|
|
113
|
+
// Stop animation if it's running
|
|
114
|
+
if (component.stopAnimation) {
|
|
115
|
+
component.stopAnimation();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Clean up controls
|
|
119
|
+
if (component.controls) {
|
|
120
|
+
if (component.controls.dispose) {
|
|
121
|
+
component.controls.dispose();
|
|
122
|
+
}
|
|
123
|
+
component.controls = null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Clean up scene
|
|
127
|
+
if (component.scene) {
|
|
128
|
+
cleanupScene(component.scene);
|
|
129
|
+
component.scene = null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Clean up renderer
|
|
133
|
+
if (component.renderer) {
|
|
134
|
+
cleanupRenderer(component.renderer);
|
|
135
|
+
component.renderer = null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Clean up camera
|
|
139
|
+
component.camera = null;
|
|
140
|
+
|
|
141
|
+
// Cleanup other resources
|
|
142
|
+
component.textureLoader = null;
|
|
143
|
+
component.gltfLoader = null;
|
|
144
|
+
logger.info('All Three.js resources cleaned up');
|
|
145
|
+
}
|
|
146
|
+
var disposalManager = {
|
|
147
|
+
disposeObject: disposeObject,
|
|
148
|
+
disposeMaterial: disposeMaterial,
|
|
149
|
+
cleanupScene: cleanupScene,
|
|
150
|
+
cleanupRenderer: cleanupRenderer,
|
|
151
|
+
cleanupNuxtEventListeners: cleanupNuxtEventListeners,
|
|
152
|
+
cleanupThreeJsResources: cleanupThreeJsResources
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { cleanupNuxtEventListeners, cleanupRenderer, cleanupScene, cleanupThreeJsResources, disposalManager as default, disposeMaterial, disposeObject };
|