@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,560 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("three"),n=require("../core/debugLogger.js");function i(e){if(e&&e.t)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var a=i(t),r=function(){return e.createClass(function t(){e.classCallCheck(this,t),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 a.Box3).setFromObject(e);return!t.isEmpty()&&t.getSize(new a.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();n.logger.info("🔍 Starting scene analysis...");var i={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)})}}}),i.performance={meshCount:a,geometryCount:r,materialCount:u.size,textureCount:c.size,vertexCount:s,triangleCount:o,memoryEstimate:this.estimateMemoryUsage(s,u.size,c.size)},i.structure=this.analyzeSceneStructure(e),i.quality=this.analyzeQuality(e),i.recommendations=this.generateRecommendations(i);var l=performance.now();return i.performance.analysisTime=l-t,n.logger.info("✅ Scene analysis complete in ".concat(i.performance.analysisTime.toFixed(2),"ms")),this.analysisHistory.push(i),i}},{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;n.logger.info("🔍 Validating scene components...");var i={passed:[],failed:[],warnings:[]};return this.validationRules.forEach(function(t,n){try{t.check(e)?i.passed.push({rule:n,target:"scene"}):i.failed.push({rule:n,target:"scene",message:t.message})}catch(e){i.warnings.push({rule:n,target:"scene",message:"Validation error: ".concat(e.message)})}}),e.traverse(function(e){e.isMesh&&t.validationRules.forEach(function(t,n){try{t.check(e)?i.passed.push({rule:n,target:e.uuid}):i.failed.push({rule:n,target:e.uuid,message:t.message,objectName:e.name||"Unnamed Object"})}catch(t){i.warnings.push({rule:n,target:e.uuid,message:"Validation error: ".concat(t.message),objectName:e.name||"Unnamed Object"})}})}),n.logger.info("✅ Validation complete: ".concat(i.passed.length," passed, ").concat(i.failed.length," failed, ").concat(i.warnings.length," warnings")),i}},{key:"applyAdjustments",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];n.logger.info("🔧 Applying scene adjustments...");var a={applied:[],failed:[],skipped:[]};return i.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"})}),n.logger.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(),n.logger.info("Analysis disposed")}}])}();exports.Analysis=r;
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;