@2112-lab/central-plant 0.1.4 → 0.1.6
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 +33146 -1
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
- package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
- package/dist/cjs/src/analysis/analysis.js +560 -1
- package/dist/cjs/src/analysis/testing.js +958 -1
- package/dist/cjs/src/core/centralPlant.js +1149 -1
- package/dist/cjs/src/core/debugLogger.js +175 -1
- package/dist/cjs/src/core/mathUtils.js +574 -1
- package/dist/cjs/src/core/nameUtils.js +93 -1
- package/dist/cjs/src/data/export.js +716 -1
- package/dist/cjs/src/data/import.js +380 -1
- package/dist/cjs/src/data/numerics.js +522 -1
- package/dist/cjs/src/helpers/sceneHelper.js +572 -1
- package/dist/cjs/src/index.js +69 -1
- package/dist/cjs/src/managers/components/animationManager.js +123 -1
- package/dist/cjs/src/managers/components/componentManager.js +332 -1
- package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
- package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
- package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
- package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
- package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
- package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
- package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
- package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
- package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
- package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
- package/dist/cjs/src/managers/system/disposalManager.js +444 -1
- package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
- package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
- package/dist/cjs/src/rendering/modelPreloader.js +369 -1
- package/dist/cjs/src/rendering/rendering2D.js +631 -1
- package/dist/cjs/src/rendering/rendering3D.js +685 -1
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
- package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
- package/dist/esm/src/analysis/analysis.js +536 -1
- package/dist/esm/src/analysis/testing.js +954 -1
- package/dist/esm/src/core/centralPlant.js +1144 -1
- package/dist/esm/src/core/debugLogger.js +167 -1
- package/dist/esm/src/core/mathUtils.js +570 -1
- package/dist/esm/src/core/nameUtils.js +87 -1
- package/dist/esm/src/data/export.js +712 -1
- package/dist/esm/src/data/import.js +356 -1
- package/dist/esm/src/data/numerics.js +518 -1
- package/dist/esm/src/helpers/sceneHelper.js +547 -1
- package/dist/esm/src/index.js +35 -1
- package/dist/esm/src/managers/components/animationManager.js +119 -1
- package/dist/esm/src/managers/components/componentManager.js +328 -1
- package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
- package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
- package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
- package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
- package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
- package/dist/esm/src/managers/environment/environmentManager.js +690 -1
- package/dist/esm/src/managers/environment/textureConfig.js +202 -1
- package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
- package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
- package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
- package/dist/esm/src/managers/system/disposalManager.js +440 -1
- package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
- package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
- package/dist/esm/src/rendering/modelPreloader.js +364 -1
- package/dist/esm/src/rendering/rendering2D.js +627 -1
- package/dist/esm/src/rendering/rendering3D.js +661 -1
- package/package.json +1 -1
|
@@ -1 +1,560 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var THREE = require('three');
|
|
7
|
+
var debugLogger = require('../core/debugLogger.js');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n["default"] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
28
|
+
|
|
29
|
+
var Analysis = /*#__PURE__*/function () {
|
|
30
|
+
function Analysis() {
|
|
31
|
+
_rollupPluginBabelHelpers.classCallCheck(this, Analysis);
|
|
32
|
+
this.analysisHistory = [];
|
|
33
|
+
this.validationRules = new Map();
|
|
34
|
+
this.adjustmentStrategies = new Map();
|
|
35
|
+
this.initializeDefaultRules();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Initialize default validation rules
|
|
40
|
+
*/
|
|
41
|
+
return _rollupPluginBabelHelpers.createClass(Analysis, [{
|
|
42
|
+
key: "initializeDefaultRules",
|
|
43
|
+
value: function initializeDefaultRules() {
|
|
44
|
+
// Component validation rules
|
|
45
|
+
this.addValidationRule('component_bounds', {
|
|
46
|
+
check: function check(component) {
|
|
47
|
+
var bbox = new THREE__namespace.Box3().setFromObject(component);
|
|
48
|
+
return !bbox.isEmpty() && bbox.getSize(new THREE__namespace.Vector3()).length() > 0;
|
|
49
|
+
},
|
|
50
|
+
message: 'Component has invalid bounding box'
|
|
51
|
+
});
|
|
52
|
+
this.addValidationRule('component_position', {
|
|
53
|
+
check: function check(component) {
|
|
54
|
+
var pos = component.position;
|
|
55
|
+
return !isNaN(pos.x) && !isNaN(pos.y) && !isNaN(pos.z) && isFinite(pos.x) && isFinite(pos.y) && isFinite(pos.z);
|
|
56
|
+
},
|
|
57
|
+
message: 'Component has invalid position values'
|
|
58
|
+
});
|
|
59
|
+
this.addValidationRule('component_scale', {
|
|
60
|
+
check: function check(component) {
|
|
61
|
+
var scale = component.scale;
|
|
62
|
+
return scale.x > 0 && scale.y > 0 && scale.z > 0 && scale.x < 1000 && scale.y < 1000 && scale.z < 1000;
|
|
63
|
+
},
|
|
64
|
+
message: 'Component has invalid scale values'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Scene validation rules
|
|
68
|
+
this.addValidationRule('scene_complexity', {
|
|
69
|
+
check: function check(scene) {
|
|
70
|
+
var meshCount = 0;
|
|
71
|
+
scene.traverse(function (obj) {
|
|
72
|
+
if (obj.isMesh) meshCount++;
|
|
73
|
+
});
|
|
74
|
+
return meshCount < 10000; // Arbitrary limit
|
|
75
|
+
},
|
|
76
|
+
message: 'Scene complexity too high (too many meshes)'
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Add a validation rule
|
|
82
|
+
* @param {string} name - Rule name
|
|
83
|
+
* @param {Object} rule - Rule object with check function and message
|
|
84
|
+
*/
|
|
85
|
+
}, {
|
|
86
|
+
key: "addValidationRule",
|
|
87
|
+
value: function addValidationRule(name, rule) {
|
|
88
|
+
this.validationRules.set(name, rule);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Add an adjustment strategy
|
|
93
|
+
* @param {string} name - Strategy name
|
|
94
|
+
* @param {Function} strategy - Adjustment function
|
|
95
|
+
*/
|
|
96
|
+
}, {
|
|
97
|
+
key: "addAdjustmentStrategy",
|
|
98
|
+
value: function addAdjustmentStrategy(name, strategy) {
|
|
99
|
+
this.adjustmentStrategies.set(name, strategy);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Analyze scene composition and structure
|
|
104
|
+
* @param {THREE.Scene} scene - Scene to analyze
|
|
105
|
+
* @returns {Object} Analysis results
|
|
106
|
+
*/
|
|
107
|
+
}, {
|
|
108
|
+
key: "analyzeScene",
|
|
109
|
+
value: function analyzeScene(scene) {
|
|
110
|
+
var startTime = performance.now();
|
|
111
|
+
debugLogger.logger.info('🔍 Starting scene analysis...');
|
|
112
|
+
var analysis = {
|
|
113
|
+
timestamp: new Date().toISOString(),
|
|
114
|
+
performance: {},
|
|
115
|
+
structure: {},
|
|
116
|
+
quality: {},
|
|
117
|
+
recommendations: []
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Performance analysis
|
|
121
|
+
var meshCount = 0;
|
|
122
|
+
var geometryCount = 0;
|
|
123
|
+
var vertexCount = 0;
|
|
124
|
+
var triangleCount = 0;
|
|
125
|
+
var materials = new Set();
|
|
126
|
+
var textures = new Set();
|
|
127
|
+
scene.traverse(function (object) {
|
|
128
|
+
if (object.isMesh) {
|
|
129
|
+
meshCount++;
|
|
130
|
+
if (object.geometry) {
|
|
131
|
+
geometryCount++;
|
|
132
|
+
|
|
133
|
+
// Count vertices and triangles
|
|
134
|
+
var positionAttribute = object.geometry.getAttribute('position');
|
|
135
|
+
if (positionAttribute) {
|
|
136
|
+
vertexCount += positionAttribute.count;
|
|
137
|
+
if (object.geometry.index) {
|
|
138
|
+
triangleCount += object.geometry.index.count / 3;
|
|
139
|
+
} else {
|
|
140
|
+
triangleCount += positionAttribute.count / 3;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (object.material) {
|
|
145
|
+
if (Array.isArray(object.material)) {
|
|
146
|
+
object.material.forEach(function (mat) {
|
|
147
|
+
return materials.add(mat.uuid);
|
|
148
|
+
});
|
|
149
|
+
} else {
|
|
150
|
+
materials.add(object.material.uuid);
|
|
151
|
+
|
|
152
|
+
// Count textures
|
|
153
|
+
var material = object.material;
|
|
154
|
+
Object.keys(material).forEach(function (key) {
|
|
155
|
+
if (material[key] && material[key].isTexture) {
|
|
156
|
+
textures.add(material[key].uuid);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
analysis.performance = {
|
|
164
|
+
meshCount: meshCount,
|
|
165
|
+
geometryCount: geometryCount,
|
|
166
|
+
materialCount: materials.size,
|
|
167
|
+
textureCount: textures.size,
|
|
168
|
+
vertexCount: vertexCount,
|
|
169
|
+
triangleCount: triangleCount,
|
|
170
|
+
memoryEstimate: this.estimateMemoryUsage(vertexCount, materials.size, textures.size)
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// Structure analysis
|
|
174
|
+
analysis.structure = this.analyzeSceneStructure(scene);
|
|
175
|
+
|
|
176
|
+
// Quality analysis
|
|
177
|
+
analysis.quality = this.analyzeQuality(scene);
|
|
178
|
+
|
|
179
|
+
// Generate recommendations
|
|
180
|
+
analysis.recommendations = this.generateRecommendations(analysis);
|
|
181
|
+
var endTime = performance.now();
|
|
182
|
+
analysis.performance.analysisTime = endTime - startTime;
|
|
183
|
+
debugLogger.logger.info("\u2705 Scene analysis complete in ".concat(analysis.performance.analysisTime.toFixed(2), "ms"));
|
|
184
|
+
this.analysisHistory.push(analysis);
|
|
185
|
+
return analysis;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Analyze scene structure and hierarchy
|
|
190
|
+
* @param {THREE.Scene} scene - Scene to analyze
|
|
191
|
+
* @returns {Object} Structure analysis
|
|
192
|
+
*/
|
|
193
|
+
}, {
|
|
194
|
+
key: "analyzeSceneStructure",
|
|
195
|
+
value: function analyzeSceneStructure(scene) {
|
|
196
|
+
var structure = {
|
|
197
|
+
depth: 0,
|
|
198
|
+
branches: 0,
|
|
199
|
+
emptyNodes: 0,
|
|
200
|
+
namedObjects: 0,
|
|
201
|
+
groups: 0
|
|
202
|
+
};
|
|
203
|
+
var _analyzeNode = function analyzeNode(node) {
|
|
204
|
+
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
205
|
+
structure.depth = Math.max(structure.depth, depth);
|
|
206
|
+
if (node.children.length > 0) {
|
|
207
|
+
structure.branches++;
|
|
208
|
+
}
|
|
209
|
+
if (node.children.length === 0 && !node.isMesh && !node.isLight && !node.isCamera) {
|
|
210
|
+
structure.emptyNodes++;
|
|
211
|
+
}
|
|
212
|
+
if (node.name && node.name.trim() !== '') {
|
|
213
|
+
structure.namedObjects++;
|
|
214
|
+
}
|
|
215
|
+
if (node.isGroup) {
|
|
216
|
+
structure.groups++;
|
|
217
|
+
}
|
|
218
|
+
node.children.forEach(function (child) {
|
|
219
|
+
return _analyzeNode(child, depth + 1);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
_analyzeNode(scene);
|
|
223
|
+
return structure;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Analyze scene quality metrics
|
|
228
|
+
* @param {THREE.Scene} scene - Scene to analyze
|
|
229
|
+
* @returns {Object} Quality analysis
|
|
230
|
+
*/
|
|
231
|
+
}, {
|
|
232
|
+
key: "analyzeQuality",
|
|
233
|
+
value: function analyzeQuality(scene) {
|
|
234
|
+
var _this = this;
|
|
235
|
+
var quality = {
|
|
236
|
+
duplicateMaterials: 0,
|
|
237
|
+
unusedMaterials: 0,
|
|
238
|
+
missingTextures: 0,
|
|
239
|
+
invalidTransforms: 0,
|
|
240
|
+
memoryLeaks: [],
|
|
241
|
+
optimization: {
|
|
242
|
+
mergeable: [],
|
|
243
|
+
instancingCandidates: []
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var materials = new Map();
|
|
247
|
+
var geometries = new Map();
|
|
248
|
+
scene.traverse(function (object) {
|
|
249
|
+
// Check for duplicate materials
|
|
250
|
+
if (object.material) {
|
|
251
|
+
var matKey = _this.getMaterialSignature(object.material);
|
|
252
|
+
if (materials.has(matKey)) {
|
|
253
|
+
quality.duplicateMaterials++;
|
|
254
|
+
} else {
|
|
255
|
+
materials.set(matKey, object.material);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Check for duplicate geometries (instancing candidates)
|
|
260
|
+
if (object.geometry) {
|
|
261
|
+
var geoKey = _this.getGeometrySignature(object.geometry);
|
|
262
|
+
if (!geometries.has(geoKey)) {
|
|
263
|
+
geometries.set(geoKey, []);
|
|
264
|
+
}
|
|
265
|
+
geometries.get(geoKey).push(object);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Check for invalid transforms
|
|
269
|
+
if (object.position && (!isFinite(object.position.x) || !isFinite(object.position.y) || !isFinite(object.position.z))) {
|
|
270
|
+
quality.invalidTransforms++;
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Find instancing candidates
|
|
275
|
+
geometries.forEach(function (objects, geoKey) {
|
|
276
|
+
if (objects.length > 1) {
|
|
277
|
+
quality.optimization.instancingCandidates.push({
|
|
278
|
+
geometry: geoKey,
|
|
279
|
+
count: objects.length,
|
|
280
|
+
objects: objects.map(function (obj) {
|
|
281
|
+
return obj.uuid;
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
return quality;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Generate optimization recommendations
|
|
291
|
+
* @param {Object} analysis - Analysis results
|
|
292
|
+
* @returns {Array} Recommendations
|
|
293
|
+
*/
|
|
294
|
+
}, {
|
|
295
|
+
key: "generateRecommendations",
|
|
296
|
+
value: function generateRecommendations(analysis) {
|
|
297
|
+
var recommendations = [];
|
|
298
|
+
|
|
299
|
+
// Performance recommendations
|
|
300
|
+
if (analysis.performance.triangleCount > 500000) {
|
|
301
|
+
recommendations.push({
|
|
302
|
+
type: 'performance',
|
|
303
|
+
priority: 'high',
|
|
304
|
+
message: 'Consider using Level of Detail (LOD) for high polygon models',
|
|
305
|
+
action: 'implement_lod'
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (analysis.performance.materialCount > 50) {
|
|
309
|
+
recommendations.push({
|
|
310
|
+
type: 'performance',
|
|
311
|
+
priority: 'medium',
|
|
312
|
+
message: 'High material count detected. Consider material atlasing',
|
|
313
|
+
action: 'optimize_materials'
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (analysis.quality.duplicateMaterials > 10) {
|
|
317
|
+
recommendations.push({
|
|
318
|
+
type: 'optimization',
|
|
319
|
+
priority: 'medium',
|
|
320
|
+
message: 'Duplicate materials found. Consider material sharing',
|
|
321
|
+
action: 'merge_materials'
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (analysis.quality.optimization.instancingCandidates.length > 0) {
|
|
325
|
+
recommendations.push({
|
|
326
|
+
type: 'optimization',
|
|
327
|
+
priority: 'high',
|
|
328
|
+
message: 'Instancing opportunities detected for repeated geometries',
|
|
329
|
+
action: 'implement_instancing'
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return recommendations;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Validate scene components
|
|
337
|
+
* @param {THREE.Scene} scene - Scene to validate
|
|
338
|
+
* @returns {Object} Validation results
|
|
339
|
+
*/
|
|
340
|
+
}, {
|
|
341
|
+
key: "validateScene",
|
|
342
|
+
value: function validateScene(scene) {
|
|
343
|
+
var _this2 = this;
|
|
344
|
+
debugLogger.logger.info('🔍 Validating scene components...');
|
|
345
|
+
var validation = {
|
|
346
|
+
passed: [],
|
|
347
|
+
failed: [],
|
|
348
|
+
warnings: []
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// Validate scene itself
|
|
352
|
+
this.validationRules.forEach(function (rule, name) {
|
|
353
|
+
try {
|
|
354
|
+
if (rule.check(scene)) {
|
|
355
|
+
validation.passed.push({
|
|
356
|
+
rule: name,
|
|
357
|
+
target: 'scene'
|
|
358
|
+
});
|
|
359
|
+
} else {
|
|
360
|
+
validation.failed.push({
|
|
361
|
+
rule: name,
|
|
362
|
+
target: 'scene',
|
|
363
|
+
message: rule.message
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
} catch (error) {
|
|
367
|
+
validation.warnings.push({
|
|
368
|
+
rule: name,
|
|
369
|
+
target: 'scene',
|
|
370
|
+
message: "Validation error: ".concat(error.message)
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// Validate individual components
|
|
376
|
+
scene.traverse(function (object) {
|
|
377
|
+
if (object.isMesh) {
|
|
378
|
+
_this2.validationRules.forEach(function (rule, name) {
|
|
379
|
+
try {
|
|
380
|
+
if (rule.check(object)) {
|
|
381
|
+
validation.passed.push({
|
|
382
|
+
rule: name,
|
|
383
|
+
target: object.uuid
|
|
384
|
+
});
|
|
385
|
+
} else {
|
|
386
|
+
validation.failed.push({
|
|
387
|
+
rule: name,
|
|
388
|
+
target: object.uuid,
|
|
389
|
+
message: rule.message,
|
|
390
|
+
objectName: object.name || 'Unnamed Object'
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
} catch (error) {
|
|
394
|
+
validation.warnings.push({
|
|
395
|
+
rule: name,
|
|
396
|
+
target: object.uuid,
|
|
397
|
+
message: "Validation error: ".concat(error.message),
|
|
398
|
+
objectName: object.name || 'Unnamed Object'
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
debugLogger.logger.info("\u2705 Validation complete: ".concat(validation.passed.length, " passed, ").concat(validation.failed.length, " failed, ").concat(validation.warnings.length, " warnings"));
|
|
405
|
+
return validation;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Apply automatic adjustments to scene
|
|
410
|
+
* @param {THREE.Scene} scene - Scene to adjust
|
|
411
|
+
* @param {Array} adjustments - List of adjustments to apply
|
|
412
|
+
* @returns {Object} Adjustment results
|
|
413
|
+
*/
|
|
414
|
+
}, {
|
|
415
|
+
key: "applyAdjustments",
|
|
416
|
+
value: function applyAdjustments(scene) {
|
|
417
|
+
var _this3 = this;
|
|
418
|
+
var adjustments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
419
|
+
debugLogger.logger.info('🔧 Applying scene adjustments...');
|
|
420
|
+
var results = {
|
|
421
|
+
applied: [],
|
|
422
|
+
failed: [],
|
|
423
|
+
skipped: []
|
|
424
|
+
};
|
|
425
|
+
adjustments.forEach(function (adjustment) {
|
|
426
|
+
var strategy = _this3.adjustmentStrategies.get(adjustment.type);
|
|
427
|
+
if (!strategy) {
|
|
428
|
+
results.skipped.push({
|
|
429
|
+
adjustment: adjustment.type,
|
|
430
|
+
reason: 'No strategy found'
|
|
431
|
+
});
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
try {
|
|
435
|
+
var result = strategy(scene, adjustment.options || {});
|
|
436
|
+
results.applied.push({
|
|
437
|
+
adjustment: adjustment.type,
|
|
438
|
+
result: result
|
|
439
|
+
});
|
|
440
|
+
} catch (error) {
|
|
441
|
+
results.failed.push({
|
|
442
|
+
adjustment: adjustment.type,
|
|
443
|
+
error: error.message
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
debugLogger.logger.info("\u2705 Adjustments complete: ".concat(results.applied.length, " applied, ").concat(results.failed.length, " failed, ").concat(results.skipped.length, " skipped"));
|
|
448
|
+
return results;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Get material signature for comparison
|
|
453
|
+
* @param {THREE.Material} material - Material to analyze
|
|
454
|
+
* @returns {string} Material signature
|
|
455
|
+
*/
|
|
456
|
+
}, {
|
|
457
|
+
key: "getMaterialSignature",
|
|
458
|
+
value: function getMaterialSignature(material) {
|
|
459
|
+
var props = {
|
|
460
|
+
type: material.type,
|
|
461
|
+
color: material.color ? material.color.getHex() : null,
|
|
462
|
+
metalness: material.metalness,
|
|
463
|
+
roughness: material.roughness,
|
|
464
|
+
transparent: material.transparent,
|
|
465
|
+
opacity: material.opacity
|
|
466
|
+
};
|
|
467
|
+
return JSON.stringify(props);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Get geometry signature for comparison
|
|
472
|
+
* @param {THREE.BufferGeometry} geometry - Geometry to analyze
|
|
473
|
+
* @returns {string} Geometry signature
|
|
474
|
+
*/
|
|
475
|
+
}, {
|
|
476
|
+
key: "getGeometrySignature",
|
|
477
|
+
value: function getGeometrySignature(geometry) {
|
|
478
|
+
var _geometry$getAttribut;
|
|
479
|
+
var attributes = Object.keys(geometry.attributes);
|
|
480
|
+
var vertexCount = ((_geometry$getAttribut = geometry.getAttribute('position')) === null || _geometry$getAttribut === void 0 ? void 0 : _geometry$getAttribut.count) || 0;
|
|
481
|
+
var hasIndex = !!geometry.index;
|
|
482
|
+
return "".concat(geometry.type, "_").concat(vertexCount, "_").concat(hasIndex, "_").concat(attributes.join(','));
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Estimate memory usage
|
|
487
|
+
* @param {number} vertices - Vertex count
|
|
488
|
+
* @param {number} materials - Material count
|
|
489
|
+
* @param {number} textures - Texture count
|
|
490
|
+
* @returns {Object} Memory estimates
|
|
491
|
+
*/
|
|
492
|
+
}, {
|
|
493
|
+
key: "estimateMemoryUsage",
|
|
494
|
+
value: function estimateMemoryUsage(vertices, materials, textures) {
|
|
495
|
+
var bytesPerVertex = 32; // Rough estimate for position + normal + uv
|
|
496
|
+
var bytesPerMaterial = 1024; // Rough estimate
|
|
497
|
+
var bytesPerTexture = 1024 * 1024; // Assume 1MB average per texture
|
|
498
|
+
|
|
499
|
+
var geometryMemory = vertices * bytesPerVertex;
|
|
500
|
+
var materialMemory = materials * bytesPerMaterial;
|
|
501
|
+
var textureMemory = textures * bytesPerTexture;
|
|
502
|
+
var total = geometryMemory + materialMemory + textureMemory;
|
|
503
|
+
return {
|
|
504
|
+
geometry: this.formatBytes(geometryMemory),
|
|
505
|
+
materials: this.formatBytes(materialMemory),
|
|
506
|
+
textures: this.formatBytes(textureMemory),
|
|
507
|
+
total: this.formatBytes(total),
|
|
508
|
+
totalBytes: total
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Format bytes to human readable format
|
|
514
|
+
* @param {number} bytes - Bytes to format
|
|
515
|
+
* @returns {string} Formatted string
|
|
516
|
+
*/
|
|
517
|
+
}, {
|
|
518
|
+
key: "formatBytes",
|
|
519
|
+
value: function formatBytes(bytes) {
|
|
520
|
+
if (bytes === 0) return '0 Bytes';
|
|
521
|
+
var k = 1024;
|
|
522
|
+
var sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
523
|
+
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
524
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Get analysis history
|
|
529
|
+
* @returns {Array} Analysis history
|
|
530
|
+
*/
|
|
531
|
+
}, {
|
|
532
|
+
key: "getAnalysisHistory",
|
|
533
|
+
value: function getAnalysisHistory() {
|
|
534
|
+
return this.analysisHistory;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Clear analysis history
|
|
539
|
+
*/
|
|
540
|
+
}, {
|
|
541
|
+
key: "clearHistory",
|
|
542
|
+
value: function clearHistory() {
|
|
543
|
+
this.analysisHistory = [];
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Dispose of analysis manager
|
|
548
|
+
*/
|
|
549
|
+
}, {
|
|
550
|
+
key: "dispose",
|
|
551
|
+
value: function dispose() {
|
|
552
|
+
this.clearHistory();
|
|
553
|
+
this.validationRules.clear();
|
|
554
|
+
this.adjustmentStrategies.clear();
|
|
555
|
+
debugLogger.logger.info('Analysis disposed');
|
|
556
|
+
}
|
|
557
|
+
}]);
|
|
558
|
+
}();
|
|
559
|
+
|
|
560
|
+
exports.Analysis = Analysis;
|