@2112-lab/central-plant 0.1.0 → 0.1.2
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 +7782 -6543
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +23 -10
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -0
- package/dist/cjs/src/animationManager.js +15 -15
- package/dist/cjs/src/componentManager.js +8 -8
- package/dist/cjs/src/disposalManager.js +12 -12
- package/dist/cjs/src/environmentManager.js +392 -99
- package/dist/cjs/src/hotReloadManager.js +26 -26
- package/dist/cjs/src/index.js +19 -66
- package/dist/cjs/src/keyboardControlsManager.js +23 -23
- package/dist/cjs/src/nameUtils.js +21 -21
- package/dist/cjs/src/pathfindingManager.js +311 -129
- package/dist/cjs/src/performanceMonitor.js +52 -52
- package/dist/cjs/src/sceneExportManager.js +23 -23
- package/dist/cjs/src/sceneInitializationManager.js +18 -18
- package/dist/cjs/src/textureConfig.js +469 -40
- package/dist/cjs/src/transformControlsManager.js +79 -79
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +21 -10
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -0
- package/dist/esm/src/animationManager.js +15 -15
- package/dist/esm/src/componentManager.js +8 -8
- package/dist/esm/src/disposalManager.js +12 -12
- package/dist/esm/src/environmentManager.js +393 -100
- package/dist/esm/src/hotReloadManager.js +26 -26
- package/dist/esm/src/index.js +19 -66
- package/dist/esm/src/keyboardControlsManager.js +23 -23
- package/dist/esm/src/nameUtils.js +21 -21
- package/dist/esm/src/pathfindingManager.js +313 -129
- package/dist/esm/src/performanceMonitor.js +52 -52
- package/dist/esm/src/sceneExportManager.js +23 -23
- package/dist/esm/src/sceneInitializationManager.js +18 -18
- package/dist/esm/src/textureConfig.js +469 -42
- package/dist/esm/src/transformControlsManager.js +79 -79
- package/dist/index.d.ts +255 -259
- package/package.json +52 -53
- package/dist/cjs/src/ConnectionManager.js +0 -114
- package/dist/cjs/src/Pathfinder.js +0 -88
- package/dist/cjs/src/modelPreloader.js +0 -360
- package/dist/cjs/src/sceneOperationsManager.js +0 -560
- package/dist/esm/src/ConnectionManager.js +0 -110
- package/dist/esm/src/Pathfinder.js +0 -84
- package/dist/esm/src/modelPreloader.js +0 -337
- package/dist/esm/src/sceneOperationsManager.js +0 -536
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* ConnectionManager class
|
|
9
|
-
* Handles object connections in the pathfinding system with improved safety for missing data
|
|
10
|
-
*/
|
|
11
|
-
var ConnectionManager = /*#__PURE__*/function () {
|
|
12
|
-
function ConnectionManager(sceneManager) {
|
|
13
|
-
_rollupPluginBabelHelpers.classCallCheck(this, ConnectionManager);
|
|
14
|
-
this.sceneManager = sceneManager;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Safely cluster connections by shared objects
|
|
19
|
-
* @param {Array<Object>} connections - Array of connections between objects (or null/undefined)
|
|
20
|
-
* @returns {Array<Object>} Array of clusters
|
|
21
|
-
*/
|
|
22
|
-
return _rollupPluginBabelHelpers.createClass(ConnectionManager, [{
|
|
23
|
-
key: "clusterConnections",
|
|
24
|
-
value: function clusterConnections(connections) {
|
|
25
|
-
// Safety check for undefined or non-array connections
|
|
26
|
-
if (!connections || !Array.isArray(connections)) {
|
|
27
|
-
console.warn('ConnectionManager: No valid connections provided');
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
var clusters = new Map(); // Map of object UUID to its cluster
|
|
31
|
-
var clusterMap = new Map(); // Map of cluster ID to set of object UUIDs
|
|
32
|
-
var nextClusterId = 0;
|
|
33
|
-
|
|
34
|
-
// Process each connection
|
|
35
|
-
connections.forEach(function (conn) {
|
|
36
|
-
// Safety check for invalid connection format
|
|
37
|
-
if (!conn || _rollupPluginBabelHelpers["typeof"](conn) !== 'object' || !conn.from || !conn.to) {
|
|
38
|
-
console.warn('ConnectionManager: Invalid connection format', conn);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
var from = conn.from,
|
|
42
|
-
to = conn.to;
|
|
43
|
-
|
|
44
|
-
// If neither object is in a cluster, create new cluster
|
|
45
|
-
if (!clusters.has(from) && !clusters.has(to)) {
|
|
46
|
-
var clusterId = nextClusterId++;
|
|
47
|
-
clusters.set(from, clusterId);
|
|
48
|
-
clusters.set(to, clusterId);
|
|
49
|
-
clusterMap.set(clusterId, new Set([from, to]));
|
|
50
|
-
}
|
|
51
|
-
// If only 'from' is in a cluster, add 'to' to that cluster
|
|
52
|
-
else if (clusters.has(from) && !clusters.has(to)) {
|
|
53
|
-
var _clusterId = clusters.get(from);
|
|
54
|
-
clusters.set(to, _clusterId);
|
|
55
|
-
clusterMap.get(_clusterId).add(to);
|
|
56
|
-
}
|
|
57
|
-
// If only 'to' is in a cluster, add 'from' to that cluster
|
|
58
|
-
else if (!clusters.has(from) && clusters.has(to)) {
|
|
59
|
-
var _clusterId2 = clusters.get(to);
|
|
60
|
-
clusters.set(from, _clusterId2);
|
|
61
|
-
clusterMap.get(_clusterId2).add(from);
|
|
62
|
-
}
|
|
63
|
-
// If both are in different clusters, merge the clusters
|
|
64
|
-
else if (clusters.has(from) && clusters.has(to) && clusters.get(from) !== clusters.get(to)) {
|
|
65
|
-
var fromCluster = clusters.get(from);
|
|
66
|
-
var toCluster = clusters.get(to);
|
|
67
|
-
var fromObjects = clusterMap.get(fromCluster);
|
|
68
|
-
var toObjects = clusterMap.get(toCluster);
|
|
69
|
-
|
|
70
|
-
// Merge all objects from 'to' cluster into 'from' cluster
|
|
71
|
-
var _iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(toObjects),
|
|
72
|
-
_step;
|
|
73
|
-
try {
|
|
74
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
75
|
-
var obj = _step.value;
|
|
76
|
-
clusters.set(obj, fromCluster);
|
|
77
|
-
fromObjects.add(obj);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Delete the now-empty 'to' cluster
|
|
81
|
-
} catch (err) {
|
|
82
|
-
_iterator.e(err);
|
|
83
|
-
} finally {
|
|
84
|
-
_iterator.f();
|
|
85
|
-
}
|
|
86
|
-
clusterMap.delete(toCluster);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// Convert clusters to array format
|
|
91
|
-
var result = [];
|
|
92
|
-
var _iterator2 = _rollupPluginBabelHelpers.createForOfIteratorHelper(clusterMap.entries()),
|
|
93
|
-
_step2;
|
|
94
|
-
try {
|
|
95
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
96
|
-
var _step2$value = _rollupPluginBabelHelpers.slicedToArray(_step2.value, 2),
|
|
97
|
-
clusterId = _step2$value[0],
|
|
98
|
-
objectSet = _step2$value[1];
|
|
99
|
-
result.push({
|
|
100
|
-
id: clusterId,
|
|
101
|
-
objects: Array.from(objectSet)
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
} catch (err) {
|
|
105
|
-
_iterator2.e(err);
|
|
106
|
-
} finally {
|
|
107
|
-
_iterator2.f();
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
}]);
|
|
112
|
-
}();
|
|
113
|
-
|
|
114
|
-
exports["default"] = ConnectionManager;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
var ConnectionManager = require('./ConnectionManager.js');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Pathfinder class
|
|
10
|
-
* Enhanced version with better error handling for missing data
|
|
11
|
-
*/
|
|
12
|
-
var Pathfinder = /*#__PURE__*/function () {
|
|
13
|
-
function Pathfinder(sceneData) {
|
|
14
|
-
_rollupPluginBabelHelpers.classCallCheck(this, Pathfinder);
|
|
15
|
-
this.sceneData = sceneData || {};
|
|
16
|
-
this.connectionManager = new ConnectionManager["default"]();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Find paths in the scene
|
|
21
|
-
* @returns {Array} Array of paths
|
|
22
|
-
*/
|
|
23
|
-
return _rollupPluginBabelHelpers.createClass(Pathfinder, [{
|
|
24
|
-
key: "findPaths",
|
|
25
|
-
value: function findPaths() {
|
|
26
|
-
var _this = this;
|
|
27
|
-
console.log('[DEBUG] Starting findPaths()');
|
|
28
|
-
try {
|
|
29
|
-
var connections = this.sceneData.connections;
|
|
30
|
-
|
|
31
|
-
// Safety check for connections
|
|
32
|
-
if (!connections || !Array.isArray(connections)) {
|
|
33
|
-
console.warn('Pathfinder: No valid connections provided in scene data');
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Create clusters from connections
|
|
38
|
-
var clusters = this.connectionManager.clusterConnections(connections);
|
|
39
|
-
|
|
40
|
-
// Return empty array if there are no valid clusters
|
|
41
|
-
if (!clusters || !clusters.length) {
|
|
42
|
-
console.log('Pathfinder: No valid connection clusters generated');
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Process the clusters and generate paths
|
|
47
|
-
// (Simplified implementation, the actual process would be more complex)
|
|
48
|
-
var paths = [];
|
|
49
|
-
clusters.forEach(function (cluster) {
|
|
50
|
-
if (cluster && cluster.objects && Array.isArray(cluster.objects)) {
|
|
51
|
-
// Generate path for this cluster
|
|
52
|
-
var clusterPaths = _this._generatePathsForCluster(cluster);
|
|
53
|
-
paths.push.apply(paths, _rollupPluginBabelHelpers.toConsumableArray(clusterPaths));
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return paths;
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error('Pathfinder: Error finding paths:', error);
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Generate paths for a single cluster
|
|
65
|
-
* @param {Object} cluster - The cluster to generate paths for
|
|
66
|
-
* @returns {Array} Array of paths for this cluster
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
69
|
-
}, {
|
|
70
|
-
key: "_generatePathsForCluster",
|
|
71
|
-
value: function _generatePathsForCluster(cluster) {
|
|
72
|
-
// This is a placeholder implementation
|
|
73
|
-
// In your actual system, this would use your existing pathfinding logic
|
|
74
|
-
return cluster.objects.map(function (obj, index, arr) {
|
|
75
|
-
if (index < arr.length - 1) {
|
|
76
|
-
return {
|
|
77
|
-
from: obj,
|
|
78
|
-
to: arr[index + 1],
|
|
79
|
-
path: [] // This would normally contain 3D points for the path
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}).filter(Boolean);
|
|
84
|
-
}
|
|
85
|
-
}]);
|
|
86
|
-
}();
|
|
87
|
-
|
|
88
|
-
exports["default"] = Pathfinder;
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
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 ModelPreloader = /*#__PURE__*/function () {
|
|
27
|
-
function ModelPreloader() {
|
|
28
|
-
_rollupPluginBabelHelpers.classCallCheck(this, ModelPreloader);
|
|
29
|
-
this.modelCache = new Map(); // Cache for loaded GLB models
|
|
30
|
-
this.loadingPromises = new Map(); // Track ongoing loads to prevent duplicates
|
|
31
|
-
this.isPreloading = false;
|
|
32
|
-
this.preloadingPromise = null;
|
|
33
|
-
this.componentDictionary = null;
|
|
34
|
-
|
|
35
|
-
// Load GLTFLoader dynamically if available
|
|
36
|
-
this.gltfLoader = null;
|
|
37
|
-
this.initLoader();
|
|
38
|
-
}
|
|
39
|
-
return _rollupPluginBabelHelpers.createClass(ModelPreloader, [{
|
|
40
|
-
key: "initLoader",
|
|
41
|
-
value: function () {
|
|
42
|
-
var _initLoader = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
|
|
43
|
-
var GLTFLoaderModule, _t;
|
|
44
|
-
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
45
|
-
while (1) switch (_context.n) {
|
|
46
|
-
case 0:
|
|
47
|
-
_context.p = 0;
|
|
48
|
-
if (!(typeof window !== 'undefined')) {
|
|
49
|
-
_context.n = 3;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
_context.n = 1;
|
|
53
|
-
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('three')); });
|
|
54
|
-
case 1:
|
|
55
|
-
_context.v;
|
|
56
|
-
_context.n = 2;
|
|
57
|
-
return Promise.resolve().then(function () { return require('../node_modules/three/examples/jsm/loaders/GLTFLoader.js'); });
|
|
58
|
-
case 2:
|
|
59
|
-
GLTFLoaderModule = _context.v;
|
|
60
|
-
this.gltfLoader = new GLTFLoaderModule.GLTFLoader();
|
|
61
|
-
case 3:
|
|
62
|
-
_context.n = 5;
|
|
63
|
-
break;
|
|
64
|
-
case 4:
|
|
65
|
-
_context.p = 4;
|
|
66
|
-
_t = _context.v;
|
|
67
|
-
console.warn('Failed to initialize GLTFLoader:', _t);
|
|
68
|
-
case 5:
|
|
69
|
-
return _context.a(2);
|
|
70
|
-
}
|
|
71
|
-
}, _callee, this, [[0, 4]]);
|
|
72
|
-
}));
|
|
73
|
-
function initLoader() {
|
|
74
|
-
return _initLoader.apply(this, arguments);
|
|
75
|
-
}
|
|
76
|
-
return initLoader;
|
|
77
|
-
}()
|
|
78
|
-
/**
|
|
79
|
-
* Preload all models from the component dictionary
|
|
80
|
-
* @param {Object} componentDictionary - The component dictionary object
|
|
81
|
-
* @returns {Promise} Promise that resolves when all models are loaded
|
|
82
|
-
*/
|
|
83
|
-
}, {
|
|
84
|
-
key: "preloadAllModels",
|
|
85
|
-
value: (function () {
|
|
86
|
-
var _preloadAllModels = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3(componentDictionary) {
|
|
87
|
-
var _this = this;
|
|
88
|
-
return _rollupPluginBabelHelpers.regenerator().w(function (_context4) {
|
|
89
|
-
while (1) switch (_context4.n) {
|
|
90
|
-
case 0:
|
|
91
|
-
if (!this.isPreloading) {
|
|
92
|
-
_context4.n = 1;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
console.log('⏳ Preloading already in progress, returning existing promise');
|
|
96
|
-
return _context4.a(2, this.preloadingPromise);
|
|
97
|
-
case 1:
|
|
98
|
-
if (componentDictionary) {
|
|
99
|
-
_context4.n = 2;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
throw new Error('Component dictionary is required to preload models');
|
|
103
|
-
case 2:
|
|
104
|
-
this.isPreloading = true;
|
|
105
|
-
this.componentDictionary = componentDictionary;
|
|
106
|
-
|
|
107
|
-
// Create a promise to track overall preloading
|
|
108
|
-
this.preloadingPromise = new Promise(/*#__PURE__*/function () {
|
|
109
|
-
var _ref = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2(resolve) {
|
|
110
|
-
var results, modelKeysSet, loadPromises, _iterator, _step, _loop, _t2, _t3;
|
|
111
|
-
return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
|
|
112
|
-
while (1) switch (_context3.n) {
|
|
113
|
-
case 0:
|
|
114
|
-
_context3.p = 0;
|
|
115
|
-
console.log("\uD83D\uDE80 Starting preload of models from dictionary with ".concat(Object.keys(componentDictionary).length, " components"));
|
|
116
|
-
results = {
|
|
117
|
-
total: 0,
|
|
118
|
-
success: 0,
|
|
119
|
-
failed: 0,
|
|
120
|
-
skipped: 0,
|
|
121
|
-
modelKeys: []
|
|
122
|
-
}; // Extract all unique model keys from the dictionary
|
|
123
|
-
modelKeysSet = new Set();
|
|
124
|
-
Object.values(componentDictionary).forEach(function (component) {
|
|
125
|
-
if (component.modelKey) {
|
|
126
|
-
modelKeysSet.add(component.modelKey);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
results.total = modelKeysSet.size;
|
|
130
|
-
results.modelKeys = Array.from(modelKeysSet);
|
|
131
|
-
|
|
132
|
-
// Load basic models first
|
|
133
|
-
console.log("\uD83D\uDCE6 Found ".concat(results.total, " unique model keys to preload"));
|
|
134
|
-
|
|
135
|
-
// Return early if no models to load
|
|
136
|
-
if (!(results.total === 0)) {
|
|
137
|
-
_context3.n = 1;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
_this.isPreloading = false;
|
|
141
|
-
resolve(results);
|
|
142
|
-
return _context3.a(2);
|
|
143
|
-
case 1:
|
|
144
|
-
// Process each model key
|
|
145
|
-
loadPromises = [];
|
|
146
|
-
_iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(results.modelKeys);
|
|
147
|
-
_context3.p = 2;
|
|
148
|
-
_loop = /*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _loop() {
|
|
149
|
-
var modelKey, modelUrl;
|
|
150
|
-
return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
|
|
151
|
-
while (1) switch (_context2.n) {
|
|
152
|
-
case 0:
|
|
153
|
-
modelKey = _step.value;
|
|
154
|
-
modelUrl = _this.getModelUrlFromKey(modelKey);
|
|
155
|
-
if (modelUrl) {
|
|
156
|
-
loadPromises.push(_this.preloadModel(modelKey, modelUrl).then(function () {
|
|
157
|
-
results.success++;
|
|
158
|
-
}).catch(function (error) {
|
|
159
|
-
console.error("\u274C Failed to preload model ".concat(modelKey, ":"), error);
|
|
160
|
-
results.failed++;
|
|
161
|
-
}));
|
|
162
|
-
} else {
|
|
163
|
-
console.warn("\u26A0\uFE0F No URL found for model key: ".concat(modelKey));
|
|
164
|
-
results.skipped++;
|
|
165
|
-
}
|
|
166
|
-
case 1:
|
|
167
|
-
return _context2.a(2);
|
|
168
|
-
}
|
|
169
|
-
}, _loop);
|
|
170
|
-
});
|
|
171
|
-
_iterator.s();
|
|
172
|
-
case 3:
|
|
173
|
-
if ((_step = _iterator.n()).done) {
|
|
174
|
-
_context3.n = 5;
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
return _context3.d(_rollupPluginBabelHelpers.regeneratorValues(_loop()), 4);
|
|
178
|
-
case 4:
|
|
179
|
-
_context3.n = 3;
|
|
180
|
-
break;
|
|
181
|
-
case 5:
|
|
182
|
-
_context3.n = 7;
|
|
183
|
-
break;
|
|
184
|
-
case 6:
|
|
185
|
-
_context3.p = 6;
|
|
186
|
-
_t2 = _context3.v;
|
|
187
|
-
_iterator.e(_t2);
|
|
188
|
-
case 7:
|
|
189
|
-
_context3.p = 7;
|
|
190
|
-
_iterator.f();
|
|
191
|
-
return _context3.f(7);
|
|
192
|
-
case 8:
|
|
193
|
-
_context3.n = 9;
|
|
194
|
-
return Promise.allSettled(loadPromises);
|
|
195
|
-
case 9:
|
|
196
|
-
console.log('✅ Model preloading completed with results:', results);
|
|
197
|
-
_this.isPreloading = false;
|
|
198
|
-
resolve(results);
|
|
199
|
-
_context3.n = 11;
|
|
200
|
-
break;
|
|
201
|
-
case 10:
|
|
202
|
-
_context3.p = 10;
|
|
203
|
-
_t3 = _context3.v;
|
|
204
|
-
console.error('❌ Error during model preloading:', _t3);
|
|
205
|
-
_this.isPreloading = false;
|
|
206
|
-
resolve({
|
|
207
|
-
total: 0,
|
|
208
|
-
success: 0,
|
|
209
|
-
failed: 1,
|
|
210
|
-
skipped: 0,
|
|
211
|
-
error: _t3.message
|
|
212
|
-
});
|
|
213
|
-
case 11:
|
|
214
|
-
return _context3.a(2);
|
|
215
|
-
}
|
|
216
|
-
}, _callee2, null, [[2, 6, 7, 8], [0, 10]]);
|
|
217
|
-
}));
|
|
218
|
-
return function (_x2) {
|
|
219
|
-
return _ref.apply(this, arguments);
|
|
220
|
-
};
|
|
221
|
-
}());
|
|
222
|
-
return _context4.a(2, this.preloadingPromise);
|
|
223
|
-
}
|
|
224
|
-
}, _callee3, this);
|
|
225
|
-
}));
|
|
226
|
-
function preloadAllModels(_x) {
|
|
227
|
-
return _preloadAllModels.apply(this, arguments);
|
|
228
|
-
}
|
|
229
|
-
return preloadAllModels;
|
|
230
|
-
}()
|
|
231
|
-
/**
|
|
232
|
-
* Convert a model key to a URL
|
|
233
|
-
* @param {string} modelKey - The model key from the dictionary
|
|
234
|
-
* @returns {string} The URL for the model
|
|
235
|
-
*/
|
|
236
|
-
)
|
|
237
|
-
}, {
|
|
238
|
-
key: "getModelUrlFromKey",
|
|
239
|
-
value: function getModelUrlFromKey(modelKey) {
|
|
240
|
-
// The modelKey already includes the .glb extension from the component dictionary
|
|
241
|
-
return modelKey;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Preload a specific model
|
|
246
|
-
* @param {string} modelKey - The model key
|
|
247
|
-
* @param {string} modelUrl - The URL to the model
|
|
248
|
-
* @returns {Promise} Promise that resolves with the loaded model
|
|
249
|
-
*/
|
|
250
|
-
}, {
|
|
251
|
-
key: "preloadModel",
|
|
252
|
-
value: (function () {
|
|
253
|
-
var _preloadModel = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee4(modelKey, modelUrl) {
|
|
254
|
-
var _this2 = this;
|
|
255
|
-
var loadPromise;
|
|
256
|
-
return _rollupPluginBabelHelpers.regenerator().w(function (_context5) {
|
|
257
|
-
while (1) switch (_context5.n) {
|
|
258
|
-
case 0:
|
|
259
|
-
if (this.gltfLoader) {
|
|
260
|
-
_context5.n = 2;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
_context5.n = 1;
|
|
264
|
-
return this.initLoader();
|
|
265
|
-
case 1:
|
|
266
|
-
if (this.gltfLoader) {
|
|
267
|
-
_context5.n = 2;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
throw new Error('GLTFLoader is not available');
|
|
271
|
-
case 2:
|
|
272
|
-
if (!this.modelCache.has(modelKey)) {
|
|
273
|
-
_context5.n = 3;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
return _context5.a(2, this.modelCache.get(modelKey));
|
|
277
|
-
case 3:
|
|
278
|
-
if (!this.loadingPromises.has(modelKey)) {
|
|
279
|
-
_context5.n = 4;
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
return _context5.a(2, this.loadingPromises.get(modelKey));
|
|
283
|
-
case 4:
|
|
284
|
-
// Start loading the model
|
|
285
|
-
loadPromise = new Promise(function (resolve, reject) {
|
|
286
|
-
_this2.gltfLoader.load(modelUrl, function (gltf) {
|
|
287
|
-
console.log("\u2705 Successfully loaded model: ".concat(modelKey, " from ").concat(modelUrl));
|
|
288
|
-
_this2.modelCache.set(modelKey, gltf);
|
|
289
|
-
_this2.loadingPromises.delete(modelKey);
|
|
290
|
-
resolve(gltf);
|
|
291
|
-
}, function (progress) {
|
|
292
|
-
// Optional progress callback
|
|
293
|
-
if (progress.lengthComputable) {
|
|
294
|
-
progress.loaded / progress.total * 100;
|
|
295
|
-
// console.log(`📥 Loading ${modelKey}: ${percentComplete.toFixed(1)}%`);
|
|
296
|
-
}
|
|
297
|
-
}, function (error) {
|
|
298
|
-
console.error("\u274C Failed to load model ".concat(modelKey, " from ").concat(modelUrl, ":"), error);
|
|
299
|
-
|
|
300
|
-
// Add more detailed error information
|
|
301
|
-
if (error.message && error.message.includes('404')) {
|
|
302
|
-
console.error(" File not found. Check if the model exists at: ".concat(modelUrl));
|
|
303
|
-
} else if (error.message && error.message.includes('JSON')) {
|
|
304
|
-
console.error(" Invalid GLB file format. The file may be corrupted or is not a valid GLB/GLTF file.");
|
|
305
|
-
}
|
|
306
|
-
_this2.loadingPromises.delete(modelKey);
|
|
307
|
-
reject(error);
|
|
308
|
-
});
|
|
309
|
-
}); // Store the loading promise
|
|
310
|
-
this.loadingPromises.set(modelKey, loadPromise);
|
|
311
|
-
return _context5.a(2, loadPromise);
|
|
312
|
-
}
|
|
313
|
-
}, _callee4, this);
|
|
314
|
-
}));
|
|
315
|
-
function preloadModel(_x3, _x4) {
|
|
316
|
-
return _preloadModel.apply(this, arguments);
|
|
317
|
-
}
|
|
318
|
-
return preloadModel;
|
|
319
|
-
}()
|
|
320
|
-
/**
|
|
321
|
-
* Get a model from the cache
|
|
322
|
-
* @param {string} modelKey - The model key
|
|
323
|
-
* @returns {Object|null} The loaded model or null if not found
|
|
324
|
-
*/
|
|
325
|
-
)
|
|
326
|
-
}, {
|
|
327
|
-
key: "getModel",
|
|
328
|
-
value: function getModel(modelKey) {
|
|
329
|
-
return this.modelCache.get(modelKey) || null;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Clear the model cache
|
|
334
|
-
*/
|
|
335
|
-
}, {
|
|
336
|
-
key: "clearCache",
|
|
337
|
-
value: function clearCache() {
|
|
338
|
-
this.modelCache.clear();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Get statistics about the model cache
|
|
343
|
-
* @returns {Object} Cache statistics
|
|
344
|
-
*/
|
|
345
|
-
}, {
|
|
346
|
-
key: "getCacheStats",
|
|
347
|
-
value: function getCacheStats() {
|
|
348
|
-
return {
|
|
349
|
-
cacheSize: this.modelCache.size,
|
|
350
|
-
cachedModels: Array.from(this.modelCache.keys()),
|
|
351
|
-
loading: Array.from(this.loadingPromises.keys()),
|
|
352
|
-
isPreloading: this.isPreloading
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
}]);
|
|
356
|
-
}(); // Create singleton instance
|
|
357
|
-
var modelPreloader = new ModelPreloader();
|
|
358
|
-
|
|
359
|
-
exports.ModelPreloader = ModelPreloader;
|
|
360
|
-
exports["default"] = modelPreloader;
|