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