@esengine/ecs-framework 2.1.30 → 2.1.31

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 (286) hide show
  1. package/index.cjs +2 -0
  2. package/index.cjs.map +1 -0
  3. package/index.d.ts +6357 -0
  4. package/index.mjs +2 -0
  5. package/index.mjs.map +1 -0
  6. package/package.json +24 -50
  7. package/bin/Core.d.ts +0 -279
  8. package/bin/Core.d.ts.map +0 -1
  9. package/bin/Core.js +0 -400
  10. package/bin/Core.js.map +0 -1
  11. package/bin/ECS/Component.d.ts +0 -120
  12. package/bin/ECS/Component.d.ts.map +0 -1
  13. package/bin/ECS/Component.js +0 -129
  14. package/bin/ECS/Component.js.map +0 -1
  15. package/bin/ECS/Components/IUpdatable.d.ts +0 -22
  16. package/bin/ECS/Components/IUpdatable.d.ts.map +0 -1
  17. package/bin/ECS/Components/IUpdatable.js +0 -17
  18. package/bin/ECS/Components/IUpdatable.js.map +0 -1
  19. package/bin/ECS/Components/SceneComponent.d.ts +0 -40
  20. package/bin/ECS/Components/SceneComponent.d.ts.map +0 -1
  21. package/bin/ECS/Components/SceneComponent.js +0 -57
  22. package/bin/ECS/Components/SceneComponent.js.map +0 -1
  23. package/bin/ECS/Core/ArchetypeSystem.d.ts +0 -100
  24. package/bin/ECS/Core/ArchetypeSystem.d.ts.map +0 -1
  25. package/bin/ECS/Core/ArchetypeSystem.js +0 -193
  26. package/bin/ECS/Core/ArchetypeSystem.js.map +0 -1
  27. package/bin/ECS/Core/ComponentIndex.d.ts +0 -151
  28. package/bin/ECS/Core/ComponentIndex.d.ts.map +0 -1
  29. package/bin/ECS/Core/ComponentIndex.js +0 -405
  30. package/bin/ECS/Core/ComponentIndex.js.map +0 -1
  31. package/bin/ECS/Core/ComponentPool.d.ts +0 -88
  32. package/bin/ECS/Core/ComponentPool.d.ts.map +0 -1
  33. package/bin/ECS/Core/ComponentPool.js +0 -159
  34. package/bin/ECS/Core/ComponentPool.js.map +0 -1
  35. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts +0 -92
  36. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts.map +0 -1
  37. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js +0 -167
  38. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js.map +0 -1
  39. package/bin/ECS/Core/ComponentStorage.d.ts +0 -233
  40. package/bin/ECS/Core/ComponentStorage.d.ts.map +0 -1
  41. package/bin/ECS/Core/ComponentStorage.js +0 -463
  42. package/bin/ECS/Core/ComponentStorage.js.map +0 -1
  43. package/bin/ECS/Core/DirtyTrackingSystem.d.ts +0 -197
  44. package/bin/ECS/Core/DirtyTrackingSystem.d.ts.map +0 -1
  45. package/bin/ECS/Core/DirtyTrackingSystem.js +0 -297
  46. package/bin/ECS/Core/DirtyTrackingSystem.js.map +0 -1
  47. package/bin/ECS/Core/EntityManager.d.ts +0 -379
  48. package/bin/ECS/Core/EntityManager.d.ts.map +0 -1
  49. package/bin/ECS/Core/EntityManager.js +0 -686
  50. package/bin/ECS/Core/EntityManager.js.map +0 -1
  51. package/bin/ECS/Core/EventBus.d.ts +0 -218
  52. package/bin/ECS/Core/EventBus.d.ts.map +0 -1
  53. package/bin/ECS/Core/EventBus.js +0 -402
  54. package/bin/ECS/Core/EventBus.js.map +0 -1
  55. package/bin/ECS/Core/EventSystem.d.ts +0 -237
  56. package/bin/ECS/Core/EventSystem.d.ts.map +0 -1
  57. package/bin/ECS/Core/EventSystem.js +0 -478
  58. package/bin/ECS/Core/EventSystem.js.map +0 -1
  59. package/bin/ECS/Core/Events/index.d.ts +0 -3
  60. package/bin/ECS/Core/Events/index.d.ts.map +0 -1
  61. package/bin/ECS/Core/Events/index.js +0 -3
  62. package/bin/ECS/Core/Events/index.js.map +0 -1
  63. package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts +0 -35
  64. package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts.map +0 -1
  65. package/bin/ECS/Core/FluentAPI/ComponentBuilder.js +0 -48
  66. package/bin/ECS/Core/FluentAPI/ComponentBuilder.js.map +0 -1
  67. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts +0 -135
  68. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts.map +0 -1
  69. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js +0 -166
  70. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js.map +0 -1
  71. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts +0 -58
  72. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts.map +0 -1
  73. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js +0 -85
  74. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js.map +0 -1
  75. package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts +0 -110
  76. package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts.map +0 -1
  77. package/bin/ECS/Core/FluentAPI/EntityBuilder.js +0 -174
  78. package/bin/ECS/Core/FluentAPI/EntityBuilder.js.map +0 -1
  79. package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts +0 -53
  80. package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts.map +0 -1
  81. package/bin/ECS/Core/FluentAPI/SceneBuilder.js +0 -79
  82. package/bin/ECS/Core/FluentAPI/SceneBuilder.js.map +0 -1
  83. package/bin/ECS/Core/FluentAPI/index.d.ts +0 -6
  84. package/bin/ECS/Core/FluentAPI/index.d.ts.map +0 -1
  85. package/bin/ECS/Core/FluentAPI/index.js +0 -6
  86. package/bin/ECS/Core/FluentAPI/index.js.map +0 -1
  87. package/bin/ECS/Core/FluentAPI.d.ts +0 -2
  88. package/bin/ECS/Core/FluentAPI.d.ts.map +0 -1
  89. package/bin/ECS/Core/FluentAPI.js +0 -3
  90. package/bin/ECS/Core/FluentAPI.js.map +0 -1
  91. package/bin/ECS/Core/Performance/index.d.ts +0 -4
  92. package/bin/ECS/Core/Performance/index.d.ts.map +0 -1
  93. package/bin/ECS/Core/Performance/index.js +0 -4
  94. package/bin/ECS/Core/Performance/index.js.map +0 -1
  95. package/bin/ECS/Core/Query/index.d.ts +0 -4
  96. package/bin/ECS/Core/Query/index.d.ts.map +0 -1
  97. package/bin/ECS/Core/Query/index.js +0 -4
  98. package/bin/ECS/Core/Query/index.js.map +0 -1
  99. package/bin/ECS/Core/QuerySystem.d.ts +0 -438
  100. package/bin/ECS/Core/QuerySystem.d.ts.map +0 -1
  101. package/bin/ECS/Core/QuerySystem.js +0 -974
  102. package/bin/ECS/Core/QuerySystem.js.map +0 -1
  103. package/bin/ECS/Core/SoAStorage.d.ts +0 -97
  104. package/bin/ECS/Core/SoAStorage.d.ts.map +0 -1
  105. package/bin/ECS/Core/SoAStorage.js +0 -548
  106. package/bin/ECS/Core/SoAStorage.js.map +0 -1
  107. package/bin/ECS/Core/Storage/index.d.ts +0 -4
  108. package/bin/ECS/Core/Storage/index.d.ts.map +0 -1
  109. package/bin/ECS/Core/Storage/index.js +0 -4
  110. package/bin/ECS/Core/Storage/index.js.map +0 -1
  111. package/bin/ECS/CoreEvents.d.ts +0 -131
  112. package/bin/ECS/CoreEvents.d.ts.map +0 -1
  113. package/bin/ECS/CoreEvents.js +0 -163
  114. package/bin/ECS/CoreEvents.js.map +0 -1
  115. package/bin/ECS/Entity.d.ts +0 -455
  116. package/bin/ECS/Entity.d.ts.map +0 -1
  117. package/bin/ECS/Entity.js +0 -837
  118. package/bin/ECS/Entity.js.map +0 -1
  119. package/bin/ECS/Scene.d.ts +0 -225
  120. package/bin/ECS/Scene.d.ts.map +0 -1
  121. package/bin/ECS/Scene.js +0 -325
  122. package/bin/ECS/Scene.js.map +0 -1
  123. package/bin/ECS/Systems/EntitySystem.d.ts +0 -200
  124. package/bin/ECS/Systems/EntitySystem.d.ts.map +0 -1
  125. package/bin/ECS/Systems/EntitySystem.js +0 -431
  126. package/bin/ECS/Systems/EntitySystem.js.map +0 -1
  127. package/bin/ECS/Systems/IntervalSystem.d.ts +0 -33
  128. package/bin/ECS/Systems/IntervalSystem.d.ts.map +0 -1
  129. package/bin/ECS/Systems/IntervalSystem.js +0 -50
  130. package/bin/ECS/Systems/IntervalSystem.js.map +0 -1
  131. package/bin/ECS/Systems/PassiveSystem.d.ts +0 -17
  132. package/bin/ECS/Systems/PassiveSystem.d.ts.map +0 -1
  133. package/bin/ECS/Systems/PassiveSystem.js +0 -19
  134. package/bin/ECS/Systems/PassiveSystem.js.map +0 -1
  135. package/bin/ECS/Systems/ProcessingSystem.d.ts +0 -21
  136. package/bin/ECS/Systems/ProcessingSystem.d.ts.map +0 -1
  137. package/bin/ECS/Systems/ProcessingSystem.js +0 -20
  138. package/bin/ECS/Systems/ProcessingSystem.js.map +0 -1
  139. package/bin/ECS/Systems/index.d.ts +0 -5
  140. package/bin/ECS/Systems/index.d.ts.map +0 -1
  141. package/bin/ECS/Systems/index.js +0 -6
  142. package/bin/ECS/Systems/index.js.map +0 -1
  143. package/bin/ECS/Utils/BigIntCompatibility.d.ts +0 -164
  144. package/bin/ECS/Utils/BigIntCompatibility.d.ts.map +0 -1
  145. package/bin/ECS/Utils/BigIntCompatibility.js +0 -578
  146. package/bin/ECS/Utils/BigIntCompatibility.js.map +0 -1
  147. package/bin/ECS/Utils/Bits.d.ts +0 -163
  148. package/bin/ECS/Utils/Bits.d.ts.map +0 -1
  149. package/bin/ECS/Utils/Bits.js +0 -286
  150. package/bin/ECS/Utils/Bits.js.map +0 -1
  151. package/bin/ECS/Utils/ComponentTypeManager.d.ts +0 -50
  152. package/bin/ECS/Utils/ComponentTypeManager.d.ts.map +0 -1
  153. package/bin/ECS/Utils/ComponentTypeManager.js +0 -84
  154. package/bin/ECS/Utils/ComponentTypeManager.js.map +0 -1
  155. package/bin/ECS/Utils/EntityList.d.ts +0 -108
  156. package/bin/ECS/Utils/EntityList.d.ts.map +0 -1
  157. package/bin/ECS/Utils/EntityList.js +0 -262
  158. package/bin/ECS/Utils/EntityList.js.map +0 -1
  159. package/bin/ECS/Utils/EntityProcessorList.d.ts +0 -56
  160. package/bin/ECS/Utils/EntityProcessorList.d.ts.map +0 -1
  161. package/bin/ECS/Utils/EntityProcessorList.js +0 -102
  162. package/bin/ECS/Utils/EntityProcessorList.js.map +0 -1
  163. package/bin/ECS/Utils/IdentifierPool.d.ts +0 -203
  164. package/bin/ECS/Utils/IdentifierPool.d.ts.map +0 -1
  165. package/bin/ECS/Utils/IdentifierPool.js +0 -325
  166. package/bin/ECS/Utils/IdentifierPool.js.map +0 -1
  167. package/bin/ECS/Utils/Matcher.d.ts +0 -143
  168. package/bin/ECS/Utils/Matcher.d.ts.map +0 -1
  169. package/bin/ECS/Utils/Matcher.js +0 -249
  170. package/bin/ECS/Utils/Matcher.js.map +0 -1
  171. package/bin/ECS/Utils/index.d.ts +0 -8
  172. package/bin/ECS/Utils/index.d.ts.map +0 -1
  173. package/bin/ECS/Utils/index.js +0 -9
  174. package/bin/ECS/Utils/index.js.map +0 -1
  175. package/bin/ECS/index.d.ts +0 -12
  176. package/bin/ECS/index.d.ts.map +0 -1
  177. package/bin/ECS/index.js +0 -12
  178. package/bin/ECS/index.js.map +0 -1
  179. package/bin/Types/index.d.ts +0 -471
  180. package/bin/Types/index.d.ts.map +0 -1
  181. package/bin/Types/index.js +0 -5
  182. package/bin/Types/index.js.map +0 -1
  183. package/bin/Utils/Debug/ComponentDataCollector.d.ts +0 -28
  184. package/bin/Utils/Debug/ComponentDataCollector.d.ts.map +0 -1
  185. package/bin/Utils/Debug/ComponentDataCollector.js +0 -248
  186. package/bin/Utils/Debug/ComponentDataCollector.js.map +0 -1
  187. package/bin/Utils/Debug/DebugDataFormatter.d.ts +0 -22
  188. package/bin/Utils/Debug/DebugDataFormatter.d.ts.map +0 -1
  189. package/bin/Utils/Debug/DebugDataFormatter.js +0 -117
  190. package/bin/Utils/Debug/DebugDataFormatter.js.map +0 -1
  191. package/bin/Utils/Debug/DebugManager.d.ts +0 -104
  192. package/bin/Utils/Debug/DebugManager.d.ts.map +0 -1
  193. package/bin/Utils/Debug/DebugManager.js +0 -647
  194. package/bin/Utils/Debug/DebugManager.js.map +0 -1
  195. package/bin/Utils/Debug/EntityDataCollector.d.ts +0 -92
  196. package/bin/Utils/Debug/EntityDataCollector.d.ts.map +0 -1
  197. package/bin/Utils/Debug/EntityDataCollector.js +0 -864
  198. package/bin/Utils/Debug/EntityDataCollector.js.map +0 -1
  199. package/bin/Utils/Debug/PerformanceDataCollector.d.ts +0 -32
  200. package/bin/Utils/Debug/PerformanceDataCollector.d.ts.map +0 -1
  201. package/bin/Utils/Debug/PerformanceDataCollector.js +0 -217
  202. package/bin/Utils/Debug/PerformanceDataCollector.js.map +0 -1
  203. package/bin/Utils/Debug/SceneDataCollector.d.ts +0 -16
  204. package/bin/Utils/Debug/SceneDataCollector.d.ts.map +0 -1
  205. package/bin/Utils/Debug/SceneDataCollector.js +0 -46
  206. package/bin/Utils/Debug/SceneDataCollector.js.map +0 -1
  207. package/bin/Utils/Debug/SystemDataCollector.d.ts +0 -11
  208. package/bin/Utils/Debug/SystemDataCollector.d.ts.map +0 -1
  209. package/bin/Utils/Debug/SystemDataCollector.js +0 -59
  210. package/bin/Utils/Debug/SystemDataCollector.js.map +0 -1
  211. package/bin/Utils/Debug/WebSocketManager.d.ts +0 -59
  212. package/bin/Utils/Debug/WebSocketManager.d.ts.map +0 -1
  213. package/bin/Utils/Debug/WebSocketManager.js +0 -148
  214. package/bin/Utils/Debug/WebSocketManager.js.map +0 -1
  215. package/bin/Utils/Debug/index.d.ts +0 -8
  216. package/bin/Utils/Debug/index.d.ts.map +0 -1
  217. package/bin/Utils/Debug/index.js +0 -8
  218. package/bin/Utils/Debug/index.js.map +0 -1
  219. package/bin/Utils/Emitter.d.ts +0 -43
  220. package/bin/Utils/Emitter.d.ts.map +0 -1
  221. package/bin/Utils/Emitter.js +0 -69
  222. package/bin/Utils/Emitter.js.map +0 -1
  223. package/bin/Utils/Extensions/NumberExtension.d.ts +0 -13
  224. package/bin/Utils/Extensions/NumberExtension.d.ts.map +0 -1
  225. package/bin/Utils/Extensions/NumberExtension.js +0 -17
  226. package/bin/Utils/Extensions/NumberExtension.js.map +0 -1
  227. package/bin/Utils/Extensions/TypeUtils.d.ts +0 -13
  228. package/bin/Utils/Extensions/TypeUtils.d.ts.map +0 -1
  229. package/bin/Utils/Extensions/TypeUtils.js +0 -15
  230. package/bin/Utils/Extensions/TypeUtils.js.map +0 -1
  231. package/bin/Utils/Extensions/index.d.ts +0 -3
  232. package/bin/Utils/Extensions/index.d.ts.map +0 -1
  233. package/bin/Utils/Extensions/index.js +0 -4
  234. package/bin/Utils/Extensions/index.js.map +0 -1
  235. package/bin/Utils/GlobalManager.d.ts +0 -32
  236. package/bin/Utils/GlobalManager.d.ts.map +0 -1
  237. package/bin/Utils/GlobalManager.js +0 -53
  238. package/bin/Utils/GlobalManager.js.map +0 -1
  239. package/bin/Utils/Logger.d.ts +0 -156
  240. package/bin/Utils/Logger.d.ts.map +0 -1
  241. package/bin/Utils/Logger.js +0 -256
  242. package/bin/Utils/Logger.js.map +0 -1
  243. package/bin/Utils/PerformanceMonitor.d.ts +0 -211
  244. package/bin/Utils/PerformanceMonitor.d.ts.map +0 -1
  245. package/bin/Utils/PerformanceMonitor.js +0 -270
  246. package/bin/Utils/PerformanceMonitor.js.map +0 -1
  247. package/bin/Utils/Pool/IPoolable.d.ts +0 -29
  248. package/bin/Utils/Pool/IPoolable.d.ts.map +0 -1
  249. package/bin/Utils/Pool/IPoolable.js +0 -2
  250. package/bin/Utils/Pool/IPoolable.js.map +0 -1
  251. package/bin/Utils/Pool/Pool.d.ts +0 -109
  252. package/bin/Utils/Pool/Pool.d.ts.map +0 -1
  253. package/bin/Utils/Pool/Pool.js +0 -238
  254. package/bin/Utils/Pool/Pool.js.map +0 -1
  255. package/bin/Utils/Pool/PoolManager.d.ts +0 -91
  256. package/bin/Utils/Pool/PoolManager.d.ts.map +0 -1
  257. package/bin/Utils/Pool/PoolManager.js +0 -197
  258. package/bin/Utils/Pool/PoolManager.js.map +0 -1
  259. package/bin/Utils/Pool/index.d.ts +0 -4
  260. package/bin/Utils/Pool/index.d.ts.map +0 -1
  261. package/bin/Utils/Pool/index.js +0 -4
  262. package/bin/Utils/Pool/index.js.map +0 -1
  263. package/bin/Utils/Time.d.ts +0 -47
  264. package/bin/Utils/Time.d.ts.map +0 -1
  265. package/bin/Utils/Time.js +0 -64
  266. package/bin/Utils/Time.js.map +0 -1
  267. package/bin/Utils/Timers/ITimer.d.ts +0 -16
  268. package/bin/Utils/Timers/ITimer.d.ts.map +0 -1
  269. package/bin/Utils/Timers/ITimer.js +0 -2
  270. package/bin/Utils/Timers/ITimer.js.map +0 -1
  271. package/bin/Utils/Timers/Timer.d.ts +0 -30
  272. package/bin/Utils/Timers/Timer.d.ts.map +0 -1
  273. package/bin/Utils/Timers/Timer.js +0 -58
  274. package/bin/Utils/Timers/Timer.js.map +0 -1
  275. package/bin/Utils/Timers/TimerManager.d.ts +0 -19
  276. package/bin/Utils/Timers/TimerManager.d.ts.map +0 -1
  277. package/bin/Utils/Timers/TimerManager.js +0 -33
  278. package/bin/Utils/Timers/TimerManager.js.map +0 -1
  279. package/bin/Utils/index.d.ts +0 -9
  280. package/bin/Utils/index.d.ts.map +0 -1
  281. package/bin/Utils/index.js +0 -9
  282. package/bin/Utils/index.js.map +0 -1
  283. package/bin/index.d.ts +0 -16
  284. package/bin/index.d.ts.map +0 -1
  285. package/bin/index.js +0 -19
  286. package/bin/index.js.map +0 -1
@@ -1,864 +0,0 @@
1
- import { Core } from '../../Core';
2
- /**
3
- * 实体数据收集器
4
- */
5
- export class EntityDataCollector {
6
- collectEntityData() {
7
- const scene = Core.scene;
8
- if (!scene) {
9
- return this.getEmptyEntityDebugData();
10
- }
11
- const entityList = scene.entities;
12
- if (!entityList) {
13
- return this.getEmptyEntityDebugData();
14
- }
15
- let stats;
16
- try {
17
- stats = entityList.getStats ? entityList.getStats() : this.calculateFallbackEntityStats(entityList);
18
- }
19
- catch (error) {
20
- return {
21
- totalEntities: 0,
22
- activeEntities: 0,
23
- pendingAdd: 0,
24
- pendingRemove: 0,
25
- entitiesPerArchetype: [],
26
- topEntitiesByComponents: [],
27
- entityHierarchy: [],
28
- entityDetailsMap: {}
29
- };
30
- }
31
- const archetypeData = this.collectArchetypeData(scene);
32
- return {
33
- totalEntities: stats.totalEntities,
34
- activeEntities: stats.activeEntities,
35
- pendingAdd: stats.pendingAdd || 0,
36
- pendingRemove: stats.pendingRemove || 0,
37
- entitiesPerArchetype: archetypeData.distribution,
38
- topEntitiesByComponents: archetypeData.topEntities,
39
- entityHierarchy: [],
40
- entityDetailsMap: {}
41
- };
42
- }
43
- getRawEntityList() {
44
- const scene = Core.scene;
45
- if (!scene)
46
- return [];
47
- const entityList = scene.entities;
48
- if (!entityList?.buffer)
49
- return [];
50
- return entityList.buffer.map((entity) => ({
51
- id: entity.id,
52
- name: entity.name || `Entity_${entity.id}`,
53
- active: entity.active !== false,
54
- enabled: entity.enabled !== false,
55
- activeInHierarchy: entity.activeInHierarchy !== false,
56
- componentCount: entity.components.length,
57
- componentTypes: entity.components.map((component) => component.constructor.name),
58
- parentId: entity.parent?.id || null,
59
- childIds: entity.children?.map((child) => child.id) || [],
60
- depth: entity.getDepth ? entity.getDepth() : 0,
61
- tag: entity.tag || 0,
62
- updateOrder: entity.updateOrder || 0
63
- }));
64
- }
65
- getEntityDetails(entityId) {
66
- try {
67
- const scene = Core.scene;
68
- if (!scene)
69
- return null;
70
- const entityList = scene.entities;
71
- if (!entityList?.buffer)
72
- return null;
73
- const entity = entityList.buffer.find((e) => e.id === entityId);
74
- if (!entity)
75
- return null;
76
- const baseDebugInfo = entity.getDebugInfo ?
77
- entity.getDebugInfo() :
78
- this.buildFallbackEntityInfo(entity);
79
- const componentDetails = this.extractComponentDetails(entity.components);
80
- const sceneInfo = this.getSceneInfo(scene);
81
- return {
82
- ...baseDebugInfo,
83
- scene: sceneInfo.name,
84
- sceneName: sceneInfo.name,
85
- sceneType: sceneInfo.type,
86
- parentName: entity.parent?.name || null,
87
- components: componentDetails || [],
88
- componentCount: entity.components?.length || 0,
89
- componentTypes: entity.components?.map((comp) => comp.constructor.name) || []
90
- };
91
- }
92
- catch (error) {
93
- return {
94
- error: `获取实体详情失败: ${error instanceof Error ? error.message : String(error)}`,
95
- scene: '获取失败',
96
- components: [],
97
- componentCount: 0,
98
- componentTypes: []
99
- };
100
- }
101
- }
102
- getSceneInfo(scene) {
103
- let sceneName = '当前场景';
104
- let sceneType = 'Scene';
105
- try {
106
- if (scene.name && typeof scene.name === 'string' && scene.name.trim()) {
107
- sceneName = scene.name.trim();
108
- }
109
- else if (scene.constructor && scene.constructor.name) {
110
- sceneName = scene.constructor.name;
111
- sceneType = scene.constructor.name;
112
- }
113
- else if (scene._name && typeof scene._name === 'string' && scene._name.trim()) {
114
- sceneName = scene._name.trim();
115
- }
116
- else {
117
- const sceneClassName = Object.getPrototypeOf(scene)?.constructor?.name;
118
- if (sceneClassName && sceneClassName !== 'Object') {
119
- sceneName = sceneClassName;
120
- sceneType = sceneClassName;
121
- }
122
- }
123
- }
124
- catch (error) {
125
- sceneName = '场景名获取失败';
126
- }
127
- return { name: sceneName, type: sceneType };
128
- }
129
- collectEntityDataWithMemory() {
130
- const scene = Core.scene;
131
- if (!scene) {
132
- return this.getEmptyEntityDebugData();
133
- }
134
- const entityList = scene.entities;
135
- if (!entityList) {
136
- return this.getEmptyEntityDebugData();
137
- }
138
- let stats;
139
- try {
140
- stats = entityList.getStats ? entityList.getStats() : this.calculateFallbackEntityStats(entityList);
141
- }
142
- catch (error) {
143
- return {
144
- totalEntities: 0,
145
- activeEntities: 0,
146
- pendingAdd: 0,
147
- pendingRemove: 0,
148
- entitiesPerArchetype: [],
149
- topEntitiesByComponents: [],
150
- entityHierarchy: [],
151
- entityDetailsMap: {}
152
- };
153
- }
154
- const archetypeData = this.collectArchetypeDataWithMemory(scene);
155
- return {
156
- totalEntities: stats.totalEntities,
157
- activeEntities: stats.activeEntities,
158
- pendingAdd: stats.pendingAdd || 0,
159
- pendingRemove: stats.pendingRemove || 0,
160
- entitiesPerArchetype: archetypeData.distribution,
161
- topEntitiesByComponents: archetypeData.topEntities,
162
- entityHierarchy: this.buildEntityHierarchyTree(entityList),
163
- entityDetailsMap: this.buildEntityDetailsMap(entityList)
164
- };
165
- }
166
- collectArchetypeData(scene) {
167
- if (scene && scene.archetypeSystem && typeof scene.archetypeSystem.getAllArchetypes === 'function') {
168
- return this.extractArchetypeStatistics(scene.archetypeSystem);
169
- }
170
- const entityContainer = { entities: scene.entities?.buffer || [] };
171
- return {
172
- distribution: this.getArchetypeDistributionFast(entityContainer),
173
- topEntities: this.getTopEntitiesByComponentsFast(entityContainer)
174
- };
175
- }
176
- getArchetypeDistributionFast(entityContainer) {
177
- const distribution = new Map();
178
- if (entityContainer && entityContainer.entities) {
179
- entityContainer.entities.forEach((entity) => {
180
- const componentTypes = entity.components?.map((comp) => comp.constructor.name) || [];
181
- const signature = componentTypes.length > 0 ? componentTypes.sort().join(', ') : '无组件';
182
- const existing = distribution.get(signature);
183
- if (existing) {
184
- existing.count++;
185
- }
186
- else {
187
- distribution.set(signature, { count: 1, componentTypes });
188
- }
189
- });
190
- }
191
- return Array.from(distribution.entries())
192
- .map(([signature, data]) => ({
193
- signature,
194
- count: data.count,
195
- memory: 0
196
- }))
197
- .sort((a, b) => b.count - a.count)
198
- .slice(0, 20);
199
- }
200
- getTopEntitiesByComponentsFast(entityContainer) {
201
- if (!entityContainer || !entityContainer.entities) {
202
- return [];
203
- }
204
- return entityContainer.entities
205
- .map((entity) => ({
206
- id: entity.id.toString(),
207
- name: entity.name || `Entity_${entity.id}`,
208
- componentCount: entity.components?.length || 0,
209
- memory: 0
210
- }))
211
- .sort((a, b) => b.componentCount - a.componentCount)
212
- .slice(0, 10);
213
- }
214
- collectArchetypeDataWithMemory(scene) {
215
- if (scene && scene.archetypeSystem && typeof scene.archetypeSystem.getAllArchetypes === 'function') {
216
- return this.extractArchetypeStatisticsWithMemory(scene.archetypeSystem);
217
- }
218
- const entityContainer = { entities: scene.entities?.buffer || [] };
219
- return {
220
- distribution: this.getArchetypeDistributionWithMemory(entityContainer),
221
- topEntities: this.getTopEntitiesByComponentsWithMemory(entityContainer)
222
- };
223
- }
224
- extractArchetypeStatistics(archetypeSystem) {
225
- const archetypes = archetypeSystem.getAllArchetypes();
226
- const distribution = [];
227
- const topEntities = [];
228
- archetypes.forEach((archetype) => {
229
- const signature = archetype.componentTypes?.map((type) => type.name).join(',') || 'Unknown';
230
- const entityCount = archetype.entities?.length || 0;
231
- distribution.push({
232
- signature,
233
- count: entityCount,
234
- memory: 0
235
- });
236
- if (archetype.entities) {
237
- archetype.entities.slice(0, 5).forEach((entity) => {
238
- topEntities.push({
239
- id: entity.id.toString(),
240
- name: entity.name || `Entity_${entity.id}`,
241
- componentCount: entity.components?.length || 0,
242
- memory: 0
243
- });
244
- });
245
- }
246
- });
247
- distribution.sort((a, b) => b.count - a.count);
248
- topEntities.sort((a, b) => b.componentCount - a.componentCount);
249
- return { distribution, topEntities };
250
- }
251
- extractArchetypeStatisticsWithMemory(archetypeSystem) {
252
- const archetypes = archetypeSystem.getAllArchetypes();
253
- const distribution = [];
254
- const topEntities = [];
255
- archetypes.forEach((archetype) => {
256
- const signature = archetype.componentTypes?.map((type) => type.name).join(',') || 'Unknown';
257
- const entityCount = archetype.entities?.length || 0;
258
- let actualMemory = 0;
259
- if (archetype.entities && archetype.entities.length > 0) {
260
- const sampleSize = Math.min(5, archetype.entities.length);
261
- let sampleMemory = 0;
262
- for (let i = 0; i < sampleSize; i++) {
263
- sampleMemory += this.estimateEntityMemoryUsage(archetype.entities[i]);
264
- }
265
- actualMemory = (sampleMemory / sampleSize) * entityCount;
266
- }
267
- distribution.push({
268
- signature,
269
- count: entityCount,
270
- memory: actualMemory
271
- });
272
- if (archetype.entities) {
273
- archetype.entities.slice(0, 5).forEach((entity) => {
274
- topEntities.push({
275
- id: entity.id.toString(),
276
- name: entity.name || `Entity_${entity.id}`,
277
- componentCount: entity.components?.length || 0,
278
- memory: this.estimateEntityMemoryUsage(entity)
279
- });
280
- });
281
- }
282
- });
283
- distribution.sort((a, b) => b.count - a.count);
284
- topEntities.sort((a, b) => b.componentCount - a.componentCount);
285
- return { distribution, topEntities };
286
- }
287
- getArchetypeDistribution(entityContainer) {
288
- const distribution = new Map();
289
- if (entityContainer && entityContainer.entities) {
290
- entityContainer.entities.forEach((entity) => {
291
- const signature = entity.componentMask?.toString() || '0';
292
- const existing = distribution.get(signature);
293
- distribution.set(signature, (existing || 0) + 1);
294
- });
295
- }
296
- return Array.from(distribution.entries())
297
- .map(([signature, count]) => ({ signature, count, memory: 0 }))
298
- .sort((a, b) => b.count - a.count);
299
- }
300
- getArchetypeDistributionWithMemory(entityContainer) {
301
- const distribution = new Map();
302
- if (entityContainer && entityContainer.entities) {
303
- entityContainer.entities.forEach((entity) => {
304
- const componentTypes = entity.components?.map((comp) => comp.constructor.name) || [];
305
- const signature = componentTypes.length > 0 ? componentTypes.sort().join(', ') : '无组件';
306
- const existing = distribution.get(signature);
307
- let memory = this.estimateEntityMemoryUsage(entity);
308
- if (isNaN(memory) || memory < 0) {
309
- memory = 0;
310
- }
311
- if (existing) {
312
- existing.count++;
313
- existing.memory += memory;
314
- }
315
- else {
316
- distribution.set(signature, { count: 1, memory, componentTypes });
317
- }
318
- });
319
- }
320
- return Array.from(distribution.entries())
321
- .map(([signature, data]) => ({
322
- signature,
323
- count: data.count,
324
- memory: isNaN(data.memory) ? 0 : data.memory
325
- }))
326
- .sort((a, b) => b.count - a.count);
327
- }
328
- getTopEntitiesByComponents(entityContainer) {
329
- if (!entityContainer || !entityContainer.entities) {
330
- return [];
331
- }
332
- return entityContainer.entities
333
- .map((entity) => ({
334
- id: entity.id.toString(),
335
- name: entity.name || `Entity_${entity.id}`,
336
- componentCount: entity.components?.length || 0,
337
- memory: 0
338
- }))
339
- .sort((a, b) => b.componentCount - a.componentCount);
340
- }
341
- getTopEntitiesByComponentsWithMemory(entityContainer) {
342
- if (!entityContainer || !entityContainer.entities) {
343
- return [];
344
- }
345
- return entityContainer.entities
346
- .map((entity) => ({
347
- id: entity.id.toString(),
348
- name: entity.name || `Entity_${entity.id}`,
349
- componentCount: entity.components?.length || 0,
350
- memory: this.estimateEntityMemoryUsage(entity)
351
- }))
352
- .sort((a, b) => b.componentCount - a.componentCount);
353
- }
354
- getEmptyEntityDebugData() {
355
- return {
356
- totalEntities: 0,
357
- activeEntities: 0,
358
- pendingAdd: 0,
359
- pendingRemove: 0,
360
- entitiesPerArchetype: [],
361
- topEntitiesByComponents: [],
362
- entityHierarchy: [],
363
- entityDetailsMap: {}
364
- };
365
- }
366
- calculateFallbackEntityStats(entityList) {
367
- const allEntities = entityList.buffer || [];
368
- const activeEntities = allEntities.filter((entity) => entity.enabled && !entity._isDestroyed);
369
- return {
370
- totalEntities: allEntities.length,
371
- activeEntities: activeEntities.length,
372
- pendingAdd: 0,
373
- pendingRemove: 0,
374
- averageComponentsPerEntity: activeEntities.length > 0 ?
375
- allEntities.reduce((sum, e) => sum + (e.components?.length || 0), 0) / activeEntities.length : 0
376
- };
377
- }
378
- estimateEntityMemoryUsage(entity) {
379
- try {
380
- let totalSize = 0;
381
- const entitySize = this.calculateObjectSize(entity, ['components', 'children', 'parent']);
382
- if (!isNaN(entitySize) && entitySize > 0) {
383
- totalSize += entitySize;
384
- }
385
- if (entity.components && Array.isArray(entity.components)) {
386
- entity.components.forEach((component) => {
387
- const componentSize = this.calculateObjectSize(component, ['entity']);
388
- if (!isNaN(componentSize) && componentSize > 0) {
389
- totalSize += componentSize;
390
- }
391
- });
392
- }
393
- return isNaN(totalSize) || totalSize < 0 ? 0 : totalSize;
394
- }
395
- catch (error) {
396
- return 0;
397
- }
398
- }
399
- calculateObjectSize(obj, excludeKeys = []) {
400
- if (!obj || typeof obj !== 'object')
401
- return 0;
402
- const visited = new WeakSet();
403
- const maxDepth = 2;
404
- const calculate = (item, depth = 0) => {
405
- if (!item || typeof item !== 'object' || depth >= maxDepth) {
406
- return 0;
407
- }
408
- if (visited.has(item))
409
- return 0;
410
- visited.add(item);
411
- let itemSize = 32;
412
- try {
413
- const keys = Object.keys(item);
414
- const maxKeys = Math.min(keys.length, 20);
415
- for (let i = 0; i < maxKeys; i++) {
416
- const key = keys[i];
417
- if (excludeKeys.includes(key) ||
418
- key === 'constructor' ||
419
- key === '__proto__' ||
420
- key.startsWith('_cc_') ||
421
- key.startsWith('__')) {
422
- continue;
423
- }
424
- const value = item[key];
425
- itemSize += key.length * 2;
426
- if (typeof value === 'string') {
427
- itemSize += Math.min(value.length * 2, 200);
428
- }
429
- else if (typeof value === 'number') {
430
- itemSize += 8;
431
- }
432
- else if (typeof value === 'boolean') {
433
- itemSize += 4;
434
- }
435
- else if (Array.isArray(value)) {
436
- itemSize += 40 + Math.min(value.length * 8, 160);
437
- }
438
- else if (typeof value === 'object' && value !== null) {
439
- itemSize += calculate(value, depth + 1);
440
- }
441
- }
442
- }
443
- catch (error) {
444
- return 64;
445
- }
446
- return itemSize;
447
- };
448
- try {
449
- const size = calculate(obj);
450
- return Math.max(size, 32);
451
- }
452
- catch (error) {
453
- return 64;
454
- }
455
- }
456
- buildEntityHierarchyTree(entityList) {
457
- if (!entityList?.buffer)
458
- return [];
459
- const rootEntities = [];
460
- entityList.buffer.forEach((entity) => {
461
- if (!entity.parent) {
462
- const hierarchyNode = this.buildEntityHierarchyNode(entity);
463
- rootEntities.push(hierarchyNode);
464
- }
465
- });
466
- // 按实体名称排序,提供一致的显示顺序
467
- rootEntities.sort((nodeA, nodeB) => {
468
- if (nodeA.name < nodeB.name)
469
- return -1;
470
- if (nodeA.name > nodeB.name)
471
- return 1;
472
- return nodeA.id - nodeB.id;
473
- });
474
- return rootEntities;
475
- }
476
- /**
477
- * 构建实体层次结构节点
478
- */
479
- buildEntityHierarchyNode(entity) {
480
- let node = {
481
- id: entity.id,
482
- name: entity.name || `Entity_${entity.id}`,
483
- active: entity.active !== false,
484
- enabled: entity.enabled !== false,
485
- activeInHierarchy: entity.activeInHierarchy !== false,
486
- componentCount: entity.components.length,
487
- componentTypes: entity.components.map((component) => component.constructor.name),
488
- parentId: entity.parent?.id || null,
489
- children: [],
490
- depth: entity.getDepth ? entity.getDepth() : 0,
491
- tag: entity.tag || 0,
492
- updateOrder: entity.updateOrder || 0
493
- };
494
- // 递归构建子实体节点
495
- if (entity.children && entity.children.length > 0) {
496
- node.children = entity.children.map((child) => this.buildEntityHierarchyNode(child));
497
- }
498
- // 优先使用Entity的getDebugInfo方法
499
- if (typeof entity.getDebugInfo === 'function') {
500
- const debugInfo = entity.getDebugInfo();
501
- node = {
502
- ...node,
503
- ...debugInfo
504
- };
505
- }
506
- // 收集所有组件详细属性信息
507
- if (entity.components && entity.components.length > 0) {
508
- node.componentDetails = this.extractComponentDetails(entity.components);
509
- }
510
- return node;
511
- }
512
- /**
513
- * 构建实体详情映射
514
- */
515
- buildEntityDetailsMap(entityList) {
516
- if (!entityList?.buffer)
517
- return {};
518
- const entityDetailsMap = {};
519
- const entities = entityList.buffer;
520
- const batchSize = 100;
521
- for (let i = 0; i < entities.length; i += batchSize) {
522
- const batch = entities.slice(i, i + batchSize);
523
- batch.forEach((entity) => {
524
- const baseDebugInfo = entity.getDebugInfo ?
525
- entity.getDebugInfo() :
526
- this.buildFallbackEntityInfo(entity);
527
- const componentCacheStats = entity.getComponentCacheStats ?
528
- entity.getComponentCacheStats() : null;
529
- const componentDetails = this.extractComponentDetails(entity.components);
530
- entityDetailsMap[entity.id] = {
531
- ...baseDebugInfo,
532
- parentName: entity.parent?.name || null,
533
- components: componentDetails,
534
- componentTypes: baseDebugInfo.componentTypes ||
535
- componentDetails.map((comp) => comp.typeName),
536
- cachePerformance: componentCacheStats ? {
537
- hitRate: componentCacheStats.cacheStats.hitRate,
538
- size: componentCacheStats.cacheStats.size,
539
- maxSize: componentCacheStats.cacheStats.maxSize
540
- } : null
541
- };
542
- });
543
- }
544
- return entityDetailsMap;
545
- }
546
- /**
547
- * 构建实体基础信息
548
- */
549
- buildFallbackEntityInfo(entity) {
550
- const scene = Core.scene;
551
- const sceneInfo = this.getSceneInfo(scene);
552
- return {
553
- name: entity.name || `Entity_${entity.id}`,
554
- id: entity.id,
555
- enabled: entity.enabled !== false,
556
- active: entity.active !== false,
557
- activeInHierarchy: entity.activeInHierarchy !== false,
558
- destroyed: entity.isDestroyed || false,
559
- scene: sceneInfo.name,
560
- sceneName: sceneInfo.name,
561
- sceneType: sceneInfo.type,
562
- componentCount: entity.components.length,
563
- componentTypes: entity.components.map((component) => component.constructor.name),
564
- componentMask: entity.componentMask?.toString() || '0',
565
- parentId: entity.parent?.id || null,
566
- childCount: entity.children?.length || 0,
567
- childIds: entity.children.map((child) => child.id) || [],
568
- depth: entity.getDepth ? entity.getDepth() : 0,
569
- tag: entity.tag || 0,
570
- updateOrder: entity.updateOrder || 0
571
- };
572
- }
573
- /**
574
- * 提取组件详细信息
575
- */
576
- extractComponentDetails(components) {
577
- return components.map((component) => {
578
- let typeName = component.constructor.name;
579
- if (!typeName || typeName === 'Object' || typeName === 'Function') {
580
- try {
581
- const { ComponentTypeManager } = require('../../ECS/Utils/ComponentTypeManager');
582
- const typeManager = ComponentTypeManager.instance;
583
- const componentType = component.constructor;
584
- const typeId = typeManager.getTypeId(componentType);
585
- typeName = typeManager.getTypeName(typeId);
586
- }
587
- catch (error) {
588
- typeName = 'UnknownComponent';
589
- }
590
- }
591
- // 提取实际的组件属性
592
- const properties = {};
593
- try {
594
- const propertyKeys = Object.keys(component);
595
- propertyKeys.forEach(propertyKey => {
596
- if (!propertyKey.startsWith('_') && propertyKey !== 'entity' && propertyKey !== 'constructor') {
597
- const propertyValue = component[propertyKey];
598
- if (propertyValue !== undefined && propertyValue !== null) {
599
- properties[propertyKey] = this.formatPropertyValue(propertyValue);
600
- }
601
- }
602
- });
603
- // 如果没有找到任何属性,添加一些调试信息
604
- if (Object.keys(properties).length === 0) {
605
- properties._info = '该组件没有公开属性';
606
- properties._componentId = component.constructor.name;
607
- }
608
- }
609
- catch (error) {
610
- properties._error = '属性提取失败';
611
- properties._componentId = component.constructor.name;
612
- }
613
- return {
614
- typeName: typeName,
615
- properties: properties
616
- };
617
- });
618
- }
619
- /**
620
- * 获取组件的完整属性信息(仅在需要时调用)
621
- */
622
- getComponentProperties(entityId, componentIndex) {
623
- try {
624
- const scene = Core.scene;
625
- if (!scene)
626
- return {};
627
- const entityList = scene.entities;
628
- if (!entityList?.buffer)
629
- return {};
630
- const entity = entityList.buffer.find((e) => e.id === entityId);
631
- if (!entity || componentIndex >= entity.components.length)
632
- return {};
633
- const component = entity.components[componentIndex];
634
- const properties = {};
635
- const propertyKeys = Object.keys(component);
636
- propertyKeys.forEach(propertyKey => {
637
- if (!propertyKey.startsWith('_') && propertyKey !== 'entity') {
638
- const propertyValue = component[propertyKey];
639
- if (propertyValue !== undefined && propertyValue !== null) {
640
- properties[propertyKey] = this.formatPropertyValue(propertyValue);
641
- }
642
- }
643
- });
644
- return properties;
645
- }
646
- catch (error) {
647
- return { _error: '属性提取失败' };
648
- }
649
- }
650
- /**
651
- * 格式化属性值
652
- */
653
- formatPropertyValue(value, depth = 0) {
654
- if (value === null || value === undefined) {
655
- return value;
656
- }
657
- if (typeof value !== 'object') {
658
- if (typeof value === 'string' && value.length > 200) {
659
- return `[长字符串: ${value.length}字符] ${value.substring(0, 100)}...`;
660
- }
661
- return value;
662
- }
663
- if (depth === 0) {
664
- return this.formatObjectFirstLevel(value);
665
- }
666
- else {
667
- return this.createLazyLoadPlaceholder(value);
668
- }
669
- }
670
- /**
671
- * 格式化对象第一层
672
- */
673
- formatObjectFirstLevel(obj) {
674
- try {
675
- if (Array.isArray(obj)) {
676
- if (obj.length === 0)
677
- return [];
678
- if (obj.length > 10) {
679
- const sample = obj.slice(0, 3).map(item => this.formatPropertyValue(item, 1));
680
- return {
681
- _isLazyArray: true,
682
- _arrayLength: obj.length,
683
- _sample: sample,
684
- _summary: `数组[${obj.length}个元素]`
685
- };
686
- }
687
- return obj.map(item => this.formatPropertyValue(item, 1));
688
- }
689
- const keys = Object.keys(obj);
690
- if (keys.length === 0)
691
- return {};
692
- const result = {};
693
- let processedCount = 0;
694
- const maxProperties = 15;
695
- for (const key of keys) {
696
- if (processedCount >= maxProperties) {
697
- result._hasMoreProperties = true;
698
- result._totalProperties = keys.length;
699
- result._hiddenCount = keys.length - processedCount;
700
- break;
701
- }
702
- if (key.startsWith('_') || key.startsWith('$') || typeof obj[key] === 'function') {
703
- continue;
704
- }
705
- try {
706
- const value = obj[key];
707
- if (value !== null && value !== undefined) {
708
- result[key] = this.formatPropertyValue(value, 1);
709
- processedCount++;
710
- }
711
- }
712
- catch (error) {
713
- result[key] = `[访问失败: ${error instanceof Error ? error.message : String(error)}]`;
714
- processedCount++;
715
- }
716
- }
717
- return result;
718
- }
719
- catch (error) {
720
- return `[对象解析失败: ${error instanceof Error ? error.message : String(error)}]`;
721
- }
722
- }
723
- /**
724
- * 创建懒加载占位符
725
- */
726
- createLazyLoadPlaceholder(obj) {
727
- try {
728
- const typeName = obj.constructor?.name || 'Object';
729
- const summary = this.getObjectSummary(obj, typeName);
730
- return {
731
- _isLazyObject: true,
732
- _typeName: typeName,
733
- _summary: summary,
734
- _objectId: this.generateObjectId(obj)
735
- };
736
- }
737
- catch (error) {
738
- return {
739
- _isLazyObject: true,
740
- _typeName: 'Unknown',
741
- _summary: `无法分析的对象: ${error instanceof Error ? error.message : String(error)}`,
742
- _objectId: Math.random().toString(36).substr(2, 9)
743
- };
744
- }
745
- }
746
- /**
747
- * 获取对象摘要信息
748
- */
749
- getObjectSummary(obj, typeName) {
750
- try {
751
- if (typeName.toLowerCase().includes('vec') || typeName.toLowerCase().includes('vector')) {
752
- if (obj.x !== undefined && obj.y !== undefined) {
753
- const z = obj.z !== undefined ? obj.z : '';
754
- return `${typeName}(${obj.x}, ${obj.y}${z ? ', ' + z : ''})`;
755
- }
756
- }
757
- if (typeName.toLowerCase().includes('color')) {
758
- if (obj.r !== undefined && obj.g !== undefined && obj.b !== undefined) {
759
- const a = obj.a !== undefined ? obj.a : 1;
760
- return `${typeName}(${obj.r}, ${obj.g}, ${obj.b}, ${a})`;
761
- }
762
- }
763
- if (typeName.toLowerCase().includes('node')) {
764
- const name = obj.name || obj._name || '未命名';
765
- return `${typeName}: ${name}`;
766
- }
767
- if (typeName.toLowerCase().includes('component')) {
768
- const nodeName = obj.node?.name || obj.node?._name || '';
769
- return `${typeName}${nodeName ? ` on ${nodeName}` : ''}`;
770
- }
771
- const keys = Object.keys(obj);
772
- if (keys.length === 0) {
773
- return `${typeName} (空对象)`;
774
- }
775
- return `${typeName} (${keys.length}个属性)`;
776
- }
777
- catch (error) {
778
- return `${typeName} (无法分析)`;
779
- }
780
- }
781
- /**
782
- * 生成对象ID
783
- */
784
- generateObjectId(obj) {
785
- try {
786
- if (obj.id !== undefined)
787
- return `obj_${obj.id}`;
788
- if (obj._id !== undefined)
789
- return `obj_${obj._id}`;
790
- if (obj.uuid !== undefined)
791
- return `obj_${obj.uuid}`;
792
- if (obj._uuid !== undefined)
793
- return `obj_${obj._uuid}`;
794
- return `obj_${Math.random().toString(36).substr(2, 9)}`;
795
- }
796
- catch {
797
- return `obj_${Math.random().toString(36).substr(2, 9)}`;
798
- }
799
- }
800
- /**
801
- * 展开懒加载对象(供调试面板调用)
802
- */
803
- expandLazyObject(entityId, componentIndex, propertyPath) {
804
- try {
805
- const scene = Core.scene;
806
- if (!scene)
807
- return null;
808
- const entityList = scene.entities;
809
- if (!entityList?.buffer)
810
- return null;
811
- // 找到对应的实体
812
- const entity = entityList.buffer.find((e) => e.id === entityId);
813
- if (!entity)
814
- return null;
815
- // 找到对应的组件
816
- if (componentIndex >= entity.components.length)
817
- return null;
818
- const component = entity.components[componentIndex];
819
- // 根据属性路径找到对象
820
- const targetObject = this.getObjectByPath(component, propertyPath);
821
- if (!targetObject)
822
- return null;
823
- // 展开这个对象的第一层属性
824
- return this.formatObjectFirstLevel(targetObject);
825
- }
826
- catch (error) {
827
- return {
828
- error: `展开失败: ${error instanceof Error ? error.message : String(error)}`
829
- };
830
- }
831
- }
832
- /**
833
- * 根据路径获取对象
834
- */
835
- getObjectByPath(root, path) {
836
- if (!path)
837
- return root;
838
- const parts = path.split('.');
839
- let current = root;
840
- for (const part of parts) {
841
- if (current === null || current === undefined)
842
- return null;
843
- // 处理数组索引
844
- if (part.includes('[') && part.includes(']')) {
845
- const arrayName = part.substring(0, part.indexOf('['));
846
- const index = parseInt(part.substring(part.indexOf('[') + 1, part.indexOf(']')));
847
- if (arrayName) {
848
- current = current[arrayName];
849
- }
850
- if (Array.isArray(current) && index >= 0 && index < current.length) {
851
- current = current[index];
852
- }
853
- else {
854
- return null;
855
- }
856
- }
857
- else {
858
- current = current[part];
859
- }
860
- }
861
- return current;
862
- }
863
- }
864
- //# sourceMappingURL=EntityDataCollector.js.map