@2112-lab/central-plant 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/index.js +1 -15140
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -353
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1292
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1543
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4374
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -465
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -117
- package/dist/cjs/src/animationManager.js +1 -121
- package/dist/cjs/src/componentManager.js +1 -151
- package/dist/cjs/src/debugLogger.js +1 -176
- package/dist/cjs/src/disposalManager.js +1 -185
- package/dist/cjs/src/environmentManager.js +1 -1308
- package/dist/cjs/src/hotReloadManager.js +1 -252
- package/dist/cjs/src/index.js +1 -128
- package/dist/cjs/src/keyboardControlsManager.js +1 -206
- package/dist/cjs/src/nameUtils.js +1 -106
- package/dist/cjs/src/pathfindingManager.js +1 -321
- package/dist/cjs/src/performanceMonitor.js +1 -718
- package/dist/cjs/src/sceneExportManager.js +1 -292
- package/dist/cjs/src/sceneInitializationManager.js +1 -540
- package/dist/cjs/src/textureConfig.js +1 -624
- package/dist/cjs/src/transformControlsManager.js +1 -851
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -328
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1287
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1537
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4370
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -461
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -113
- package/dist/esm/src/animationManager.js +1 -112
- package/dist/esm/src/componentManager.js +1 -123
- package/dist/esm/src/debugLogger.js +1 -167
- package/dist/esm/src/disposalManager.js +1 -155
- package/dist/esm/src/environmentManager.js +1 -1282
- package/dist/esm/src/hotReloadManager.js +1 -244
- package/dist/esm/src/index.js +1 -118
- package/dist/esm/src/keyboardControlsManager.js +1 -196
- package/dist/esm/src/nameUtils.js +1 -99
- package/dist/esm/src/pathfindingManager.js +1 -295
- package/dist/esm/src/performanceMonitor.js +1 -712
- package/dist/esm/src/sceneExportManager.js +1 -286
- package/dist/esm/src/sceneInitializationManager.js +1 -513
- package/dist/esm/src/textureConfig.js +1 -595
- package/dist/esm/src/transformControlsManager.js +1 -827
- package/dist/index.d.ts +0 -4
- package/package.json +1 -1
- package/dist/cjs/src/ConnectionManager.js +0 -114
- package/dist/cjs/src/Pathfinder.js +0 -88
- package/dist/cjs/src/modelPreloader.js +0 -488
- package/dist/cjs/src/sceneOperationsManager.js +0 -596
- package/dist/esm/src/ConnectionManager.js +0 -110
- package/dist/esm/src/Pathfinder.js +0 -84
- package/dist/esm/src/modelPreloader.js +0 -464
- package/dist/esm/src/sceneOperationsManager.js +0 -572
|
@@ -1,718 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
require('three');
|
|
7
|
-
var debugLogger = require('./debugLogger.js');
|
|
8
|
-
|
|
9
|
-
var PerformanceMonitor = /*#__PURE__*/function () {
|
|
10
|
-
function PerformanceMonitor() {
|
|
11
|
-
var renderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
12
|
-
_rollupPluginBabelHelpers.classCallCheck(this, PerformanceMonitor);
|
|
13
|
-
this.renderer = renderer;
|
|
14
|
-
this.stats = {
|
|
15
|
-
fps: {
|
|
16
|
-
current: 0,
|
|
17
|
-
average: 0,
|
|
18
|
-
min: Infinity,
|
|
19
|
-
max: 0,
|
|
20
|
-
history: []
|
|
21
|
-
},
|
|
22
|
-
frameTime: {
|
|
23
|
-
current: 0,
|
|
24
|
-
average: 0,
|
|
25
|
-
min: Infinity,
|
|
26
|
-
max: 0,
|
|
27
|
-
history: []
|
|
28
|
-
},
|
|
29
|
-
memory: {
|
|
30
|
-
geometries: 0,
|
|
31
|
-
textures: 0,
|
|
32
|
-
programs: 0,
|
|
33
|
-
heapUsed: 0,
|
|
34
|
-
heapTotal: 0
|
|
35
|
-
},
|
|
36
|
-
drawCalls: {
|
|
37
|
-
current: 0,
|
|
38
|
-
average: 0,
|
|
39
|
-
triangles: 0,
|
|
40
|
-
points: 0,
|
|
41
|
-
lines: 0
|
|
42
|
-
},
|
|
43
|
-
gpu: {
|
|
44
|
-
memoryUsage: 0,
|
|
45
|
-
extensions: []
|
|
46
|
-
},
|
|
47
|
-
scene: {
|
|
48
|
-
objects: 0,
|
|
49
|
-
lights: 0,
|
|
50
|
-
meshes: 0,
|
|
51
|
-
materials: 0,
|
|
52
|
-
visible: 0
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
this.frameCount = 0;
|
|
56
|
-
this.historySize = 120; // 120 frames = ~2 seconds at 60fps
|
|
57
|
-
this.isRunning = false;
|
|
58
|
-
this.lastUpdateTime = 0;
|
|
59
|
-
this.warningThresholds = {
|
|
60
|
-
fps: 30,
|
|
61
|
-
frameTime: 16,
|
|
62
|
-
// ms (60fps)
|
|
63
|
-
drawCalls: 1000,
|
|
64
|
-
triangles: 1000000,
|
|
65
|
-
geometries: 1000,
|
|
66
|
-
textures: 100
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Event callbacks
|
|
70
|
-
this.callbacks = {
|
|
71
|
-
update: [],
|
|
72
|
-
warning: []
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Bind methods
|
|
76
|
-
this._update = this._update.bind(this);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Start the performance monitor
|
|
81
|
-
*/
|
|
82
|
-
return _rollupPluginBabelHelpers.createClass(PerformanceMonitor, [{
|
|
83
|
-
key: "start",
|
|
84
|
-
value: function start() {
|
|
85
|
-
if (this.isRunning) return;
|
|
86
|
-
this.isRunning = true;
|
|
87
|
-
this.lastUpdateTime = performance.now();
|
|
88
|
-
|
|
89
|
-
// Get GPU info if available
|
|
90
|
-
this._getGPUInfo();
|
|
91
|
-
|
|
92
|
-
// Start update loop
|
|
93
|
-
requestAnimationFrame(this._update);
|
|
94
|
-
debugLogger.logger.info('Performance monitoring started');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Stop the performance monitor
|
|
99
|
-
*/
|
|
100
|
-
}, {
|
|
101
|
-
key: "stop",
|
|
102
|
-
value: function stop() {
|
|
103
|
-
this.isRunning = false;
|
|
104
|
-
debugLogger.logger.info('Performance monitoring stopped');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Reset statistics
|
|
109
|
-
*/
|
|
110
|
-
}, {
|
|
111
|
-
key: "reset",
|
|
112
|
-
value: function reset() {
|
|
113
|
-
// Reset FPS stats
|
|
114
|
-
this.stats.fps = {
|
|
115
|
-
current: 0,
|
|
116
|
-
average: 0,
|
|
117
|
-
min: Infinity,
|
|
118
|
-
max: 0,
|
|
119
|
-
history: []
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// Reset frame time stats
|
|
123
|
-
this.stats.frameTime = {
|
|
124
|
-
current: 0,
|
|
125
|
-
average: 0,
|
|
126
|
-
min: Infinity,
|
|
127
|
-
max: 0,
|
|
128
|
-
history: []
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Reset frame count
|
|
132
|
-
this.frameCount = 0;
|
|
133
|
-
debugLogger.logger.info('Performance statistics reset');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Update method called every animation frame
|
|
138
|
-
*/
|
|
139
|
-
}, {
|
|
140
|
-
key: "_update",
|
|
141
|
-
value: function _update() {
|
|
142
|
-
if (!this.isRunning) return;
|
|
143
|
-
|
|
144
|
-
// Calculate frame time
|
|
145
|
-
var now = performance.now();
|
|
146
|
-
var frameTime = now - this.lastUpdateTime;
|
|
147
|
-
this.lastUpdateTime = now;
|
|
148
|
-
|
|
149
|
-
// Calculate FPS
|
|
150
|
-
var fps = 1000 / frameTime;
|
|
151
|
-
|
|
152
|
-
// Update frame time stats
|
|
153
|
-
this._updateStat('frameTime', frameTime);
|
|
154
|
-
|
|
155
|
-
// Update FPS stats
|
|
156
|
-
this._updateStat('fps', fps);
|
|
157
|
-
|
|
158
|
-
// Get WebGL info if renderer is available
|
|
159
|
-
if (this.renderer) {
|
|
160
|
-
this._getWebGLInfo();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Get memory info
|
|
164
|
-
this._getMemoryInfo();
|
|
165
|
-
|
|
166
|
-
// Increment frame count
|
|
167
|
-
this.frameCount++;
|
|
168
|
-
|
|
169
|
-
// Check for warnings
|
|
170
|
-
this._checkWarnings();
|
|
171
|
-
|
|
172
|
-
// Trigger update callbacks
|
|
173
|
-
this._triggerCallbacks('update', this.stats);
|
|
174
|
-
|
|
175
|
-
// Continue update loop
|
|
176
|
-
requestAnimationFrame(this._update);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Update statistics for a specific metric
|
|
181
|
-
*/
|
|
182
|
-
}, {
|
|
183
|
-
key: "_updateStat",
|
|
184
|
-
value: function _updateStat(metric, value) {
|
|
185
|
-
if (!this.stats[metric]) return;
|
|
186
|
-
var stats = this.stats[metric];
|
|
187
|
-
|
|
188
|
-
// Update current value
|
|
189
|
-
stats.current = value;
|
|
190
|
-
|
|
191
|
-
// Update min and max
|
|
192
|
-
stats.min = Math.min(stats.min, value);
|
|
193
|
-
stats.max = Math.max(stats.max, value);
|
|
194
|
-
|
|
195
|
-
// Add to history
|
|
196
|
-
stats.history.push(value);
|
|
197
|
-
|
|
198
|
-
// Limit history size
|
|
199
|
-
if (stats.history.length > this.historySize) {
|
|
200
|
-
stats.history.shift();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Calculate average
|
|
204
|
-
stats.average = stats.history.reduce(function (sum, val) {
|
|
205
|
-
return sum + val;
|
|
206
|
-
}, 0) / stats.history.length;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Get WebGL info from the renderer
|
|
211
|
-
*/
|
|
212
|
-
}, {
|
|
213
|
-
key: "_getWebGLInfo",
|
|
214
|
-
value: function _getWebGLInfo() {
|
|
215
|
-
var _info$render, _info$render2, _info$memory, _info$memory2, _info$programs;
|
|
216
|
-
if (!this.renderer) return;
|
|
217
|
-
var info = this.renderer.info;
|
|
218
|
-
|
|
219
|
-
// Update draw calls
|
|
220
|
-
this.stats.drawCalls.current = ((_info$render = info.render) === null || _info$render === void 0 ? void 0 : _info$render.calls) || 0;
|
|
221
|
-
this.stats.drawCalls.triangles = ((_info$render2 = info.render) === null || _info$render2 === void 0 ? void 0 : _info$render2.triangles) || 0;
|
|
222
|
-
|
|
223
|
-
// Add draw calls to history and calculate average
|
|
224
|
-
if (!this.stats.drawCalls.history) {
|
|
225
|
-
this.stats.drawCalls.history = [];
|
|
226
|
-
}
|
|
227
|
-
this.stats.drawCalls.history.push(this.stats.drawCalls.current);
|
|
228
|
-
if (this.stats.drawCalls.history.length > this.historySize) {
|
|
229
|
-
this.stats.drawCalls.history.shift();
|
|
230
|
-
}
|
|
231
|
-
this.stats.drawCalls.average = this.stats.drawCalls.history.reduce(function (sum, val) {
|
|
232
|
-
return sum + val;
|
|
233
|
-
}, 0) / this.stats.drawCalls.history.length;
|
|
234
|
-
|
|
235
|
-
// Update memory stats
|
|
236
|
-
this.stats.memory.geometries = ((_info$memory = info.memory) === null || _info$memory === void 0 ? void 0 : _info$memory.geometries) || 0;
|
|
237
|
-
this.stats.memory.textures = ((_info$memory2 = info.memory) === null || _info$memory2 === void 0 ? void 0 : _info$memory2.textures) || 0;
|
|
238
|
-
|
|
239
|
-
// Update programs count
|
|
240
|
-
this.stats.memory.programs = ((_info$programs = info.programs) === null || _info$programs === void 0 ? void 0 : _info$programs.length) || 0;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Get system memory info
|
|
245
|
-
*/
|
|
246
|
-
}, {
|
|
247
|
-
key: "_getMemoryInfo",
|
|
248
|
-
value: function _getMemoryInfo() {
|
|
249
|
-
if (typeof window !== 'undefined' && window.performance && window.performance.memory) {
|
|
250
|
-
this.stats.memory.heapUsed = window.performance.memory.usedJSHeapSize;
|
|
251
|
-
this.stats.memory.heapTotal = window.performance.memory.totalJSHeapSize;
|
|
252
|
-
} else {
|
|
253
|
-
// Fallback to navigator.deviceMemory if available
|
|
254
|
-
if (typeof navigator !== 'undefined' && navigator.deviceMemory) {
|
|
255
|
-
this.stats.memory.deviceMemory = navigator.deviceMemory;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Get GPU info if available
|
|
262
|
-
*/
|
|
263
|
-
}, {
|
|
264
|
-
key: "_getGPUInfo",
|
|
265
|
-
value: function _getGPUInfo() {
|
|
266
|
-
if (!this.renderer) return;
|
|
267
|
-
var gl = this.renderer.getContext();
|
|
268
|
-
|
|
269
|
-
// Get extensions
|
|
270
|
-
var debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
|
|
271
|
-
if (debugInfo) {
|
|
272
|
-
this.stats.gpu.vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
|
|
273
|
-
this.stats.gpu.renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
|
|
274
|
-
} else {
|
|
275
|
-
this.stats.gpu.vendor = gl.getParameter(gl.VENDOR);
|
|
276
|
-
this.stats.gpu.renderer = gl.getParameter(gl.RENDERER);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Get extensions
|
|
280
|
-
this.stats.gpu.extensions = gl.getSupportedExtensions();
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Check for performance warnings
|
|
285
|
-
*/
|
|
286
|
-
}, {
|
|
287
|
-
key: "_checkWarnings",
|
|
288
|
-
value: function _checkWarnings() {
|
|
289
|
-
var warnings = [];
|
|
290
|
-
|
|
291
|
-
// Check FPS
|
|
292
|
-
if (this.stats.fps.average < this.warningThresholds.fps) {
|
|
293
|
-
warnings.push({
|
|
294
|
-
type: 'fps',
|
|
295
|
-
message: "Low FPS: ".concat(this.stats.fps.average.toFixed(1), " (threshold: ").concat(this.warningThresholds.fps, ")"),
|
|
296
|
-
value: this.stats.fps.average,
|
|
297
|
-
threshold: this.warningThresholds.fps
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Check frame time
|
|
302
|
-
if (this.stats.frameTime.average > this.warningThresholds.frameTime) {
|
|
303
|
-
warnings.push({
|
|
304
|
-
type: 'frameTime',
|
|
305
|
-
message: "High frame time: ".concat(this.stats.frameTime.average.toFixed(1), "ms (threshold: ").concat(this.warningThresholds.frameTime, "ms)"),
|
|
306
|
-
value: this.stats.frameTime.average,
|
|
307
|
-
threshold: this.warningThresholds.frameTime
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Check draw calls
|
|
312
|
-
if (this.stats.drawCalls.average > this.warningThresholds.drawCalls) {
|
|
313
|
-
warnings.push({
|
|
314
|
-
type: 'drawCalls',
|
|
315
|
-
message: "High draw calls: ".concat(this.stats.drawCalls.average.toFixed(0), " (threshold: ").concat(this.warningThresholds.drawCalls, ")"),
|
|
316
|
-
value: this.stats.drawCalls.average,
|
|
317
|
-
threshold: this.warningThresholds.drawCalls
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// Check triangles
|
|
322
|
-
if (this.stats.drawCalls.triangles > this.warningThresholds.triangles) {
|
|
323
|
-
warnings.push({
|
|
324
|
-
type: 'triangles',
|
|
325
|
-
message: "High triangle count: ".concat(this.stats.drawCalls.triangles.toFixed(0), " (threshold: ").concat(this.warningThresholds.triangles, ")"),
|
|
326
|
-
value: this.stats.drawCalls.triangles,
|
|
327
|
-
threshold: this.warningThresholds.triangles
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// Check geometries
|
|
332
|
-
if (this.stats.memory.geometries > this.warningThresholds.geometries) {
|
|
333
|
-
warnings.push({
|
|
334
|
-
type: 'geometries',
|
|
335
|
-
message: "High geometry count: ".concat(this.stats.memory.geometries, " (threshold: ").concat(this.warningThresholds.geometries, ")"),
|
|
336
|
-
value: this.stats.memory.geometries,
|
|
337
|
-
threshold: this.warningThresholds.geometries
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Check textures
|
|
342
|
-
if (this.stats.memory.textures > this.warningThresholds.textures) {
|
|
343
|
-
warnings.push({
|
|
344
|
-
type: 'textures',
|
|
345
|
-
message: "High texture count: ".concat(this.stats.memory.textures, " (threshold: ").concat(this.warningThresholds.textures, ")"),
|
|
346
|
-
value: this.stats.memory.textures,
|
|
347
|
-
threshold: this.warningThresholds.textures
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Trigger warnings if any
|
|
352
|
-
if (warnings.length > 0) {
|
|
353
|
-
this._triggerCallbacks('warning', warnings);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Register an event callback
|
|
359
|
-
*/
|
|
360
|
-
}, {
|
|
361
|
-
key: "on",
|
|
362
|
-
value: function on(event, callback) {
|
|
363
|
-
if (!this.callbacks[event]) return;
|
|
364
|
-
this.callbacks[event].push(callback);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Remove an event callback
|
|
369
|
-
*/
|
|
370
|
-
}, {
|
|
371
|
-
key: "off",
|
|
372
|
-
value: function off(event, callback) {
|
|
373
|
-
if (!this.callbacks[event]) return;
|
|
374
|
-
var index = this.callbacks[event].indexOf(callback);
|
|
375
|
-
if (index !== -1) {
|
|
376
|
-
this.callbacks[event].splice(index, 1);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Trigger callbacks for an event
|
|
382
|
-
*/
|
|
383
|
-
}, {
|
|
384
|
-
key: "_triggerCallbacks",
|
|
385
|
-
value: function _triggerCallbacks(event, data) {
|
|
386
|
-
if (!this.callbacks[event]) return;
|
|
387
|
-
this.callbacks[event].forEach(function (callback) {
|
|
388
|
-
try {
|
|
389
|
-
callback(data);
|
|
390
|
-
} catch (error) {
|
|
391
|
-
console.error("Error in performance monitor ".concat(event, " callback:"), error);
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Log performance summary to console
|
|
398
|
-
*/
|
|
399
|
-
}, {
|
|
400
|
-
key: "logSummary",
|
|
401
|
-
value: function logSummary() {
|
|
402
|
-
console.group('📊 Performance Summary');
|
|
403
|
-
console.log("FPS: ".concat(this.stats.fps.current.toFixed(1), " (avg: ").concat(this.stats.fps.average.toFixed(1), ", min: ").concat(this.stats.fps.min.toFixed(1), ", max: ").concat(this.stats.fps.max.toFixed(1), ")"));
|
|
404
|
-
console.log("Frame Time: ".concat(this.stats.frameTime.current.toFixed(1), "ms (avg: ").concat(this.stats.frameTime.average.toFixed(1), "ms)"));
|
|
405
|
-
console.log("Draw Calls: ".concat(this.stats.drawCalls.current, " (avg: ").concat(this.stats.drawCalls.average.toFixed(1), ")"));
|
|
406
|
-
console.log("Triangles: ".concat(this.stats.drawCalls.triangles));
|
|
407
|
-
console.log("Geometries: ".concat(this.stats.memory.geometries));
|
|
408
|
-
console.log("Textures: ".concat(this.stats.memory.textures));
|
|
409
|
-
console.log("Shader Programs: ".concat(this.stats.memory.programs));
|
|
410
|
-
if (this.stats.gpu.renderer) {
|
|
411
|
-
console.log("GPU: ".concat(this.stats.gpu.renderer));
|
|
412
|
-
}
|
|
413
|
-
console.log("Total Frames: ".concat(this.frameCount));
|
|
414
|
-
console.groupEnd();
|
|
415
|
-
return this.stats;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Export performance data
|
|
420
|
-
*/
|
|
421
|
-
}, {
|
|
422
|
-
key: "exportData",
|
|
423
|
-
value: function exportData() {
|
|
424
|
-
return {
|
|
425
|
-
timestamp: new Date().toISOString(),
|
|
426
|
-
frameCount: this.frameCount,
|
|
427
|
-
stats: JSON.parse(JSON.stringify(this.stats)),
|
|
428
|
-
gpu: this.stats.gpu,
|
|
429
|
-
warnings: this._getActiveWarnings()
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Get active warnings
|
|
435
|
-
*/
|
|
436
|
-
}, {
|
|
437
|
-
key: "_getActiveWarnings",
|
|
438
|
-
value: function _getActiveWarnings() {
|
|
439
|
-
var warnings = [];
|
|
440
|
-
|
|
441
|
-
// Check all thresholds
|
|
442
|
-
if (this.stats.fps.average < this.warningThresholds.fps) {
|
|
443
|
-
warnings.push({
|
|
444
|
-
type: 'fps',
|
|
445
|
-
value: this.stats.fps.average
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
if (this.stats.frameTime.average > this.warningThresholds.frameTime) {
|
|
449
|
-
warnings.push({
|
|
450
|
-
type: 'frameTime',
|
|
451
|
-
value: this.stats.frameTime.average
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
if (this.stats.drawCalls.average > this.warningThresholds.drawCalls) {
|
|
455
|
-
warnings.push({
|
|
456
|
-
type: 'drawCalls',
|
|
457
|
-
value: this.stats.drawCalls.average
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
if (this.stats.drawCalls.triangles > this.warningThresholds.triangles) {
|
|
461
|
-
warnings.push({
|
|
462
|
-
type: 'triangles',
|
|
463
|
-
value: this.stats.drawCalls.triangles
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
if (this.stats.memory.geometries > this.warningThresholds.geometries) {
|
|
467
|
-
warnings.push({
|
|
468
|
-
type: 'geometries',
|
|
469
|
-
value: this.stats.memory.geometries
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
if (this.stats.memory.textures > this.warningThresholds.textures) {
|
|
473
|
-
warnings.push({
|
|
474
|
-
type: 'textures',
|
|
475
|
-
value: this.stats.memory.textures
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
return warnings;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Set warning thresholds
|
|
483
|
-
*/
|
|
484
|
-
}, {
|
|
485
|
-
key: "setWarningThresholds",
|
|
486
|
-
value: function setWarningThresholds(thresholds) {
|
|
487
|
-
Object.assign(this.warningThresholds, thresholds);
|
|
488
|
-
}
|
|
489
|
-
}]);
|
|
490
|
-
}();
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Performance UI class for displaying performance statistics
|
|
494
|
-
*/
|
|
495
|
-
var PerformanceUI = /*#__PURE__*/function () {
|
|
496
|
-
function PerformanceUI(monitor, container) {
|
|
497
|
-
var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'dark';
|
|
498
|
-
_rollupPluginBabelHelpers.classCallCheck(this, PerformanceUI);
|
|
499
|
-
this.monitor = monitor;
|
|
500
|
-
this.container = container;
|
|
501
|
-
this.theme = theme;
|
|
502
|
-
this.isVisible = false;
|
|
503
|
-
this.element = null;
|
|
504
|
-
this.graphs = {};
|
|
505
|
-
this._createUI();
|
|
506
|
-
this._setupUpdateLoop();
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Create the UI element
|
|
511
|
-
*/
|
|
512
|
-
return _rollupPluginBabelHelpers.createClass(PerformanceUI, [{
|
|
513
|
-
key: "_createUI",
|
|
514
|
-
value: function _createUI() {
|
|
515
|
-
var _this = this;
|
|
516
|
-
// Create container element
|
|
517
|
-
this.element = document.createElement('div');
|
|
518
|
-
this.element.className = 'performance-monitor';
|
|
519
|
-
this.element.style.position = 'absolute';
|
|
520
|
-
this.element.style.top = '10px';
|
|
521
|
-
this.element.style.right = '10px';
|
|
522
|
-
this.element.style.zIndex = '1000';
|
|
523
|
-
this.element.style.padding = '10px';
|
|
524
|
-
this.element.style.borderRadius = '5px';
|
|
525
|
-
this.element.style.fontFamily = 'monospace';
|
|
526
|
-
this.element.style.fontSize = '12px';
|
|
527
|
-
this.element.style.lineHeight = '1.2';
|
|
528
|
-
this.element.style.transition = 'opacity 0.3s ease';
|
|
529
|
-
this.element.style.userSelect = 'none';
|
|
530
|
-
|
|
531
|
-
// Apply theme
|
|
532
|
-
this.setTheme(this.theme);
|
|
533
|
-
|
|
534
|
-
// Create header with close button
|
|
535
|
-
var header = document.createElement('div');
|
|
536
|
-
header.style.display = 'flex';
|
|
537
|
-
header.style.justifyContent = 'space-between';
|
|
538
|
-
header.style.marginBottom = '5px';
|
|
539
|
-
var title = document.createElement('div');
|
|
540
|
-
title.textContent = 'Performance Monitor';
|
|
541
|
-
title.style.fontWeight = 'bold';
|
|
542
|
-
var closeButton = document.createElement('div');
|
|
543
|
-
closeButton.textContent = '×';
|
|
544
|
-
closeButton.style.cursor = 'pointer';
|
|
545
|
-
closeButton.style.paddingLeft = '10px';
|
|
546
|
-
closeButton.onclick = function () {
|
|
547
|
-
return _this.hide();
|
|
548
|
-
};
|
|
549
|
-
header.appendChild(title);
|
|
550
|
-
header.appendChild(closeButton);
|
|
551
|
-
this.element.appendChild(header);
|
|
552
|
-
|
|
553
|
-
// Create stats container
|
|
554
|
-
var statsContainer = document.createElement('div');
|
|
555
|
-
this.statsElement = statsContainer;
|
|
556
|
-
this.element.appendChild(statsContainer);
|
|
557
|
-
|
|
558
|
-
// Hide initially
|
|
559
|
-
this.element.style.opacity = '0';
|
|
560
|
-
this.element.style.pointerEvents = 'none';
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* Set UI theme
|
|
565
|
-
*/
|
|
566
|
-
}, {
|
|
567
|
-
key: "setTheme",
|
|
568
|
-
value: function setTheme(theme) {
|
|
569
|
-
this.theme = theme;
|
|
570
|
-
if (theme === 'dark') {
|
|
571
|
-
this.element.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
|
|
572
|
-
this.element.style.color = 'white';
|
|
573
|
-
this.element.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.5)';
|
|
574
|
-
} else {
|
|
575
|
-
this.element.style.backgroundColor = 'rgba(255, 255, 255, 0.85)';
|
|
576
|
-
this.element.style.color = 'black';
|
|
577
|
-
this.element.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.1)';
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* Setup update loop for refreshing the UI
|
|
583
|
-
*/
|
|
584
|
-
}, {
|
|
585
|
-
key: "_setupUpdateLoop",
|
|
586
|
-
value: function _setupUpdateLoop() {
|
|
587
|
-
var _this2 = this;
|
|
588
|
-
var updateStats = function updateStats() {
|
|
589
|
-
if (!_this2.isVisible || !_this2.monitor) return;
|
|
590
|
-
|
|
591
|
-
// Create stats HTML
|
|
592
|
-
var html = '';
|
|
593
|
-
|
|
594
|
-
// FPS
|
|
595
|
-
var fpsColor = _this2._getMetricColor(_this2.monitor.stats.fps.current, 60, 30);
|
|
596
|
-
html += "<div>FPS: <span style=\"color: ".concat(fpsColor, "\">").concat(_this2.monitor.stats.fps.current.toFixed(1), "</span> ");
|
|
597
|
-
html += "(avg: ".concat(_this2.monitor.stats.fps.average.toFixed(1), ")</div>");
|
|
598
|
-
|
|
599
|
-
// Frame time
|
|
600
|
-
var frameTimeColor = _this2._getMetricColor(16 - _this2.monitor.stats.frameTime.current, 0, 16, true);
|
|
601
|
-
html += "<div>Frame: <span style=\"color: ".concat(frameTimeColor, "\">").concat(_this2.monitor.stats.frameTime.current.toFixed(1), "ms</span></div>");
|
|
602
|
-
|
|
603
|
-
// Draw calls
|
|
604
|
-
var drawCallColor = _this2._getMetricColor(1000 - _this2.monitor.stats.drawCalls.current, 0, 1000, true);
|
|
605
|
-
html += "<div>Calls: <span style=\"color: ".concat(drawCallColor, "\">").concat(_this2.monitor.stats.drawCalls.current, "</span> ");
|
|
606
|
-
html += "Tris: ".concat(_this2._formatNumber(_this2.monitor.stats.drawCalls.triangles), "</div>");
|
|
607
|
-
|
|
608
|
-
// Memory
|
|
609
|
-
html += "<div>Geo: ".concat(_this2.monitor.stats.memory.geometries, " ");
|
|
610
|
-
html += "Tex: ".concat(_this2.monitor.stats.memory.textures, "</div>");
|
|
611
|
-
|
|
612
|
-
// Update stats element
|
|
613
|
-
_this2.statsElement.innerHTML = html;
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
// Update every 500ms to avoid performance impact
|
|
617
|
-
setInterval(updateStats, 500);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Get color for a metric based on its value
|
|
622
|
-
*/
|
|
623
|
-
}, {
|
|
624
|
-
key: "_getMetricColor",
|
|
625
|
-
value: function _getMetricColor(value, good, bad) {
|
|
626
|
-
var invert = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
627
|
-
// Normalize value between 0 and 1
|
|
628
|
-
var normalized = (value - bad) / (good - bad);
|
|
629
|
-
|
|
630
|
-
// Clamp between 0 and 1
|
|
631
|
-
normalized = Math.max(0, Math.min(1, normalized));
|
|
632
|
-
if (invert) {
|
|
633
|
-
normalized = 1 - normalized;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// Green to yellow to red
|
|
637
|
-
var r = normalized < 0.5 ? 255 : Math.floor(255 * (1 - normalized) * 2);
|
|
638
|
-
var g = normalized > 0.5 ? 255 : Math.floor(255 * normalized * 2);
|
|
639
|
-
var b = 0;
|
|
640
|
-
return "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")");
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Format number for display
|
|
645
|
-
*/
|
|
646
|
-
}, {
|
|
647
|
-
key: "_formatNumber",
|
|
648
|
-
value: function _formatNumber(number) {
|
|
649
|
-
if (number >= 1000000) {
|
|
650
|
-
return (number / 1000000).toFixed(1) + 'M';
|
|
651
|
-
} else if (number >= 1000) {
|
|
652
|
-
return (number / 1000).toFixed(1) + 'K';
|
|
653
|
-
}
|
|
654
|
-
return number.toString();
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* Show the UI
|
|
659
|
-
*/
|
|
660
|
-
}, {
|
|
661
|
-
key: "show",
|
|
662
|
-
value: function show() {
|
|
663
|
-
if (this.isVisible) return;
|
|
664
|
-
this.isVisible = true;
|
|
665
|
-
this.element.style.opacity = '1';
|
|
666
|
-
this.element.style.pointerEvents = 'auto';
|
|
667
|
-
|
|
668
|
-
// Add to container if not already added
|
|
669
|
-
if (!this.element.parentElement) {
|
|
670
|
-
this.container.appendChild(this.element);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Hide the UI
|
|
676
|
-
*/
|
|
677
|
-
}, {
|
|
678
|
-
key: "hide",
|
|
679
|
-
value: function hide() {
|
|
680
|
-
if (!this.isVisible) return;
|
|
681
|
-
this.isVisible = false;
|
|
682
|
-
this.element.style.opacity = '0';
|
|
683
|
-
this.element.style.pointerEvents = 'none';
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Toggle visibility
|
|
688
|
-
*/
|
|
689
|
-
}, {
|
|
690
|
-
key: "toggle",
|
|
691
|
-
value: function toggle() {
|
|
692
|
-
if (this.isVisible) {
|
|
693
|
-
this.hide();
|
|
694
|
-
} else {
|
|
695
|
-
this.show();
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* Clean up resources
|
|
701
|
-
*/
|
|
702
|
-
}, {
|
|
703
|
-
key: "dispose",
|
|
704
|
-
value: function dispose() {
|
|
705
|
-
if (this.element.parentElement) {
|
|
706
|
-
this.element.parentElement.removeChild(this.element);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
}]);
|
|
710
|
-
}();
|
|
711
|
-
var performanceMonitor = {
|
|
712
|
-
PerformanceMonitor: PerformanceMonitor,
|
|
713
|
-
PerformanceUI: PerformanceUI
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
exports.PerformanceMonitor = PerformanceMonitor;
|
|
717
|
-
exports.PerformanceUI = PerformanceUI;
|
|
718
|
-
exports["default"] = performanceMonitor;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../_virtual/_rollupPluginBabelHelpers.js");require("three");var i=require("./debugLogger.js"),e=function(){return t.createClass(function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t.classCallCheck(this,i),this.renderer=e,this.stats={fps:{current:0,average:0,min:1/0,max:0,history:[]},frameTime:{current:0,average:0,min:1/0,max:0,history:[]},memory:{geometries:0,textures:0,programs:0,heapUsed:0,heapTotal:0},drawCalls:{current:0,average:0,triangles:0,points:0,lines:0},gpu:{memoryUsage:0,extensions:[]},scene:{objects:0,lights:0,meshes:0,materials:0,visible:0}},this.frameCount=0,this.historySize=120,this.isRunning=!1,this.lastUpdateTime=0,this.warningThresholds={fps:30,frameTime:16,drawCalls:1e3,triangles:1e6,geometries:1e3,textures:100},this.callbacks={update:[],warning:[]},this.i=this.i.bind(this)},[{key:"start",value:function(){this.isRunning||(this.isRunning=!0,this.lastUpdateTime=performance.now(),this.h(),requestAnimationFrame(this.i),i.logger.info("Performance monitoring started"))}},{key:"stop",value:function(){this.isRunning=!1,i.logger.info("Performance monitoring stopped")}},{key:"reset",value:function(){this.stats.fps={current:0,average:0,min:1/0,max:0,history:[]},this.stats.frameTime={current:0,average:0,min:1/0,max:0,history:[]},this.frameCount=0,i.logger.info("Performance statistics reset")}},{key:"_update",value:function(){if(this.isRunning){var t=performance.now(),i=t-this.lastUpdateTime;this.lastUpdateTime=t;var e=1e3/i;this.o("frameTime",i),this.o("fps",e),this.renderer&&this.u(),this.l(),this.frameCount++,this.v(),this.m("update",this.stats),requestAnimationFrame(this.i)}}},{key:"_updateStat",value:function(t,i){if(this.stats[t]){var e=this.stats[t];e.current=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.history.push(i),e.history.length>this.historySize&&e.history.shift(),e.average=e.history.reduce(function(t,i){return t+i},0)/e.history.length}}},{key:"_getWebGLInfo",value:function(){var t,i,e,s,h;if(this.renderer){var r=this.renderer.info;this.stats.drawCalls.current=(null===(t=r.render)||void 0===t?void 0:t.calls)||0,this.stats.drawCalls.triangles=(null===(i=r.render)||void 0===i?void 0:i.triangles)||0,this.stats.drawCalls.history||(this.stats.drawCalls.history=[]),this.stats.drawCalls.history.push(this.stats.drawCalls.current),this.stats.drawCalls.history.length>this.historySize&&this.stats.drawCalls.history.shift(),this.stats.drawCalls.average=this.stats.drawCalls.history.reduce(function(t,i){return t+i},0)/this.stats.drawCalls.history.length,this.stats.memory.geometries=(null===(e=r.memory)||void 0===e?void 0:e.geometries)||0,this.stats.memory.textures=(null===(s=r.memory)||void 0===s?void 0:s.textures)||0,this.stats.memory.programs=(null===(h=r.programs)||void 0===h?void 0:h.length)||0}}},{key:"_getMemoryInfo",value:function(){"undefined"!=typeof window&&window.performance&&window.performance.memory?(this.stats.memory.heapUsed=window.performance.memory.usedJSHeapSize,this.stats.memory.heapTotal=window.performance.memory.totalJSHeapSize):"undefined"!=typeof navigator&&navigator.deviceMemory&&(this.stats.memory.deviceMemory=navigator.deviceMemory)}},{key:"_getGPUInfo",value:function(){if(this.renderer){var t=this.renderer.getContext(),i=t.getExtension("WEBGL_debug_renderer_info");i?(this.stats.gpu.vendor=t.getParameter(i.UNMASKED_VENDOR_WEBGL),this.stats.gpu.renderer=t.getParameter(i.UNMASKED_RENDERER_WEBGL)):(this.stats.gpu.vendor=t.getParameter(t.VENDOR),this.stats.gpu.renderer=t.getParameter(t.RENDERER)),this.stats.gpu.extensions=t.getSupportedExtensions()}}},{key:"_checkWarnings",value:function(){var t=[];this.stats.fps.average<this.warningThresholds.fps&&t.push({type:"fps",message:"Low FPS: ".concat(this.stats.fps.average.toFixed(1)," (threshold: ").concat(this.warningThresholds.fps,")"),value:this.stats.fps.average,threshold:this.warningThresholds.fps}),this.stats.frameTime.average>this.warningThresholds.frameTime&&t.push({type:"frameTime",message:"High frame time: ".concat(this.stats.frameTime.average.toFixed(1),"ms (threshold: ").concat(this.warningThresholds.frameTime,"ms)"),value:this.stats.frameTime.average,threshold:this.warningThresholds.frameTime}),this.stats.drawCalls.average>this.warningThresholds.drawCalls&&t.push({type:"drawCalls",message:"High draw calls: ".concat(this.stats.drawCalls.average.toFixed(0)," (threshold: ").concat(this.warningThresholds.drawCalls,")"),value:this.stats.drawCalls.average,threshold:this.warningThresholds.drawCalls}),this.stats.drawCalls.triangles>this.warningThresholds.triangles&&t.push({type:"triangles",message:"High triangle count: ".concat(this.stats.drawCalls.triangles.toFixed(0)," (threshold: ").concat(this.warningThresholds.triangles,")"),value:this.stats.drawCalls.triangles,threshold:this.warningThresholds.triangles}),this.stats.memory.geometries>this.warningThresholds.geometries&&t.push({type:"geometries",message:"High geometry count: ".concat(this.stats.memory.geometries," (threshold: ").concat(this.warningThresholds.geometries,")"),value:this.stats.memory.geometries,threshold:this.warningThresholds.geometries}),this.stats.memory.textures>this.warningThresholds.textures&&t.push({type:"textures",message:"High texture count: ".concat(this.stats.memory.textures," (threshold: ").concat(this.warningThresholds.textures,")"),value:this.stats.memory.textures,threshold:this.warningThresholds.textures}),t.length>0&&this.m("warning",t)}},{key:"on",value:function(t,i){this.callbacks[t]&&this.callbacks[t].push(i)}},{key:"off",value:function(t,i){if(this.callbacks[t]){var e=this.callbacks[t].indexOf(i);-1!==e&&this.callbacks[t].splice(e,1)}}},{key:"_triggerCallbacks",value:function(t,i){this.callbacks[t]&&this.callbacks[t].forEach(function(t){try{t(i)}catch(t){}})}},{key:"logSummary",value:function(){return this.stats.gpu.renderer,this.stats}},{key:"exportData",value:function(){return{timestamp:(new Date).toISOString(),frameCount:this.frameCount,stats:JSON.parse(JSON.stringify(this.stats)),gpu:this.stats.gpu,warnings:this.p()}}},{key:"_getActiveWarnings",value:function(){var t=[];return this.stats.fps.average<this.warningThresholds.fps&&t.push({type:"fps",value:this.stats.fps.average}),this.stats.frameTime.average>this.warningThresholds.frameTime&&t.push({type:"frameTime",value:this.stats.frameTime.average}),this.stats.drawCalls.average>this.warningThresholds.drawCalls&&t.push({type:"drawCalls",value:this.stats.drawCalls.average}),this.stats.drawCalls.triangles>this.warningThresholds.triangles&&t.push({type:"triangles",value:this.stats.drawCalls.triangles}),this.stats.memory.geometries>this.warningThresholds.geometries&&t.push({type:"geometries",value:this.stats.memory.geometries}),this.stats.memory.textures>this.warningThresholds.textures&&t.push({type:"textures",value:this.stats.memory.textures}),t}},{key:"setWarningThresholds",value:function(t){Object.assign(this.warningThresholds,t)}}])}(),s=function(){return t.createClass(function i(e,s){var h=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dark";t.classCallCheck(this,i),this.monitor=e,this.container=s,this.theme=h,this.isVisible=!1,this.element=null,this.graphs={},this.k(),this._()},[{key:"_createUI",value:function(){var t=this;this.element=document.createElement("div"),this.element.className="performance-monitor",this.element.style.position="absolute",this.element.style.top="10px",this.element.style.right="10px",this.element.style.zIndex="1000",this.element.style.padding="10px",this.element.style.borderRadius="5px",this.element.style.fontFamily="monospace",this.element.style.fontSize="12px",this.element.style.lineHeight="1.2",this.element.style.transition="opacity 0.3s ease",this.element.style.userSelect="none",this.setTheme(this.theme);var i=document.createElement("div");i.style.display="flex",i.style.justifyContent="space-between",i.style.marginBottom="5px";var e=document.createElement("div");e.textContent="Performance Monitor",e.style.fontWeight="bold";var s=document.createElement("div");s.textContent="×",s.style.cursor="pointer",s.style.paddingLeft="10px",s.onclick=function(){return t.hide()},i.appendChild(e),i.appendChild(s),this.element.appendChild(i);var h=document.createElement("div");this.statsElement=h,this.element.appendChild(h),this.element.style.opacity="0",this.element.style.pointerEvents="none"}},{key:"setTheme",value:function(t){this.theme=t,"dark"===t?(this.element.style.backgroundColor="rgba(0, 0, 0, 0.7)",this.element.style.color="white",this.element.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.5)"):(this.element.style.backgroundColor="rgba(255, 255, 255, 0.85)",this.element.style.color="black",this.element.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.1)")}},{key:"_setupUpdateLoop",value:function(){var t=this;setInterval(function(){if(t.isVisible&&t.monitor){var i="",e=t.M(t.monitor.stats.fps.current,60,30);i+='<div>FPS: <span style="color: '.concat(e,'">').concat(t.monitor.stats.fps.current.toFixed(1),"</span> "),i+="(avg: ".concat(t.monitor.stats.fps.average.toFixed(1),")</div>");var s=t.M(16-t.monitor.stats.frameTime.current,0,16,!0);i+='<div>Frame: <span style="color: '.concat(s,'">').concat(t.monitor.stats.frameTime.current.toFixed(1),"ms</span></div>");var h=t.M(1e3-t.monitor.stats.drawCalls.current,0,1e3,!0);i+='<div>Calls: <span style="color: '.concat(h,'">').concat(t.monitor.stats.drawCalls.current,"</span> "),i+="Tris: ".concat(t.P(t.monitor.stats.drawCalls.triangles),"</div>"),i+="<div>Geo: ".concat(t.monitor.stats.memory.geometries," "),i+="Tex: ".concat(t.monitor.stats.memory.textures,"</div>"),t.statsElement.innerHTML=i}},500)}},{key:"_getMetricColor",value:function(t,i,e){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],h=(t-e)/(i-e);h=Math.max(0,Math.min(1,h)),s&&(h=1-h);var r=h<.5?255:Math.floor(255*(1-h)*2),a=h>.5?255:Math.floor(255*h*2);return"rgb(".concat(r,", ").concat(a,", ").concat(0,")")}},{key:"_formatNumber",value:function(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}},{key:"show",value:function(){this.isVisible||(this.isVisible=!0,this.element.style.opacity="1",this.element.style.pointerEvents="auto",this.element.parentElement||this.container.appendChild(this.element))}},{key:"hide",value:function(){this.isVisible&&(this.isVisible=!1,this.element.style.opacity="0",this.element.style.pointerEvents="none")}},{key:"toggle",value:function(){this.isVisible?this.hide():this.show()}},{key:"dispose",value:function(){this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}])}(),h={PerformanceMonitor:e,PerformanceUI:s};exports.PerformanceMonitor=e,exports.PerformanceUI=s,exports.default=h;
|