@eva/plugin-stats 2.0.0-beta.1 → 2.0.0-beta.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/EVA.plugin.stats.js +113 -176
- package/dist/EVA.plugin.stats.min.js +1 -1
- package/dist/plugin-stats.cjs.js +107 -185
- package/dist/plugin-stats.cjs.prod.js +1 -15
- package/dist/plugin-stats.esm.js +106 -184
- package/package.json +2 -2
package/dist/EVA.plugin.stats.js
CHANGED
|
@@ -1,60 +1,31 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
window.EVA = window.EVA || {};
|
|
2
3
|
window.EVA.plugin = window.EVA.plugin || {};
|
|
3
4
|
var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
4
5
|
'use strict';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
d.__proto__ = b;
|
|
10
|
-
} || function (d, b) {
|
|
11
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
12
|
-
};
|
|
13
|
-
return extendStatics(d, b);
|
|
14
|
-
};
|
|
15
|
-
function __extends(d, b) {
|
|
16
|
-
extendStatics(d, b);
|
|
17
|
-
function __() {
|
|
18
|
-
this.constructor = d;
|
|
6
|
+
|
|
7
|
+
class StatsComponent extends eva_js.Component {
|
|
8
|
+
update() {
|
|
9
|
+
this.stats && this.stats.begin();
|
|
19
10
|
}
|
|
20
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
11
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
s = arguments[i];
|
|
26
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
return __assign.apply(this, arguments);
|
|
31
|
-
};
|
|
32
|
-
var StatsComponent = function (_super) {
|
|
33
|
-
__extends(StatsComponent, _super);
|
|
34
|
-
function StatsComponent() {
|
|
35
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
-
}
|
|
37
|
-
StatsComponent.prototype.update = function () {
|
|
38
|
-
this.stats && this.stats.begin();
|
|
39
|
-
};
|
|
40
|
-
StatsComponent.componentName = 'Stats';
|
|
41
|
-
return StatsComponent;
|
|
42
|
-
}(eva_js.Component);
|
|
43
|
-
var Stats$2 = StatsComponent;
|
|
44
|
-
var Stats = function (style) {
|
|
45
|
-
style = __assign({
|
|
12
|
+
StatsComponent.componentName = 'Stats';
|
|
13
|
+
const Stats = function (style) {
|
|
14
|
+
style = _extends({
|
|
46
15
|
width: 20,
|
|
47
16
|
height: 12,
|
|
48
17
|
x: 0,
|
|
49
18
|
y: 0
|
|
50
19
|
}, style);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
20
|
+
const {
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
x,
|
|
24
|
+
y
|
|
25
|
+
} = style;
|
|
26
|
+
let mode = 0;
|
|
27
|
+
const container = document.createElement('div');
|
|
28
|
+
container.style.cssText = `position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: ${width}vw;height: ${height}vw;left: ${x}vw;top: ${y}vw;`;
|
|
58
29
|
container.addEventListener('click', function (event) {
|
|
59
30
|
event.preventDefault();
|
|
60
31
|
showPanel(++mode % container.children.length);
|
|
@@ -64,19 +35,19 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
64
35
|
return panel;
|
|
65
36
|
}
|
|
66
37
|
function showPanel(id) {
|
|
67
|
-
for (
|
|
38
|
+
for (let i = 0; i < container.children.length; i++) {
|
|
68
39
|
container.children[i].style.display = i === id ? 'block' : 'none';
|
|
69
40
|
}
|
|
70
41
|
mode = id;
|
|
71
42
|
}
|
|
72
|
-
|
|
43
|
+
let beginTime = (performance || Date).now(),
|
|
73
44
|
prevTime = beginTime,
|
|
74
45
|
frames = 0;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
46
|
+
const fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
|
|
47
|
+
const msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
|
|
48
|
+
const dcPanel = addPanel(Stats.Panel('DrawCall', '#330570', '#A69700'));
|
|
49
|
+
const tcPanel = addPanel(Stats.Panel('TC:', '#A62500', '#00B454'));
|
|
50
|
+
let memPanel;
|
|
80
51
|
if (self.performance && self.performance.memory) {
|
|
81
52
|
memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
|
|
82
53
|
}
|
|
@@ -91,7 +62,7 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
91
62
|
},
|
|
92
63
|
end: function (hook) {
|
|
93
64
|
frames++;
|
|
94
|
-
|
|
65
|
+
const time = (performance || Date).now();
|
|
95
66
|
msPanel.update(time - beginTime, 200);
|
|
96
67
|
if (hook) {
|
|
97
68
|
dcPanel.update(hook.deltaDrawCalls, Math.max(50, hook.maxDeltaDrawCalls));
|
|
@@ -102,7 +73,7 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
102
73
|
prevTime = time;
|
|
103
74
|
frames = 0;
|
|
104
75
|
if (memPanel) {
|
|
105
|
-
|
|
76
|
+
const memory = performance.memory;
|
|
106
77
|
memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
|
|
107
78
|
}
|
|
108
79
|
}
|
|
@@ -116,11 +87,11 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
116
87
|
};
|
|
117
88
|
};
|
|
118
89
|
Stats.Panel = function (name, fg, bg) {
|
|
119
|
-
|
|
90
|
+
let min = Infinity,
|
|
120
91
|
max = 0;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
92
|
+
const round = Math.round;
|
|
93
|
+
const PR = round(window.devicePixelRatio || 1);
|
|
94
|
+
const WIDTH = 80 * PR,
|
|
124
95
|
HEIGHT = 48 * PR,
|
|
125
96
|
TEXT_X = 3 * PR,
|
|
126
97
|
TEXT_Y = 2 * PR,
|
|
@@ -128,11 +99,11 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
128
99
|
GRAPH_Y = 15 * PR,
|
|
129
100
|
GRAPH_WIDTH = 74 * PR,
|
|
130
101
|
GRAPH_HEIGHT = 30 * PR;
|
|
131
|
-
|
|
102
|
+
const canvas = document.createElement('canvas');
|
|
132
103
|
canvas.width = WIDTH;
|
|
133
104
|
canvas.height = HEIGHT;
|
|
134
105
|
canvas.style.cssText = 'width:100%;height:100%';
|
|
135
|
-
|
|
106
|
+
const context = canvas.getContext('2d');
|
|
136
107
|
context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';
|
|
137
108
|
context.textBaseline = 'top';
|
|
138
109
|
context.fillStyle = bg;
|
|
@@ -162,8 +133,8 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
162
133
|
};
|
|
163
134
|
};
|
|
164
135
|
var Stats$1 = Stats;
|
|
165
|
-
|
|
166
|
-
|
|
136
|
+
class GLHook {
|
|
137
|
+
constructor(_gl) {
|
|
167
138
|
this.drawPasses = 0;
|
|
168
139
|
this.isInit = false;
|
|
169
140
|
this.realGLDrawElements = function () {};
|
|
@@ -178,25 +149,24 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
178
149
|
console.error("[GLHook] GL can't be NULL");
|
|
179
150
|
}
|
|
180
151
|
}
|
|
181
|
-
|
|
152
|
+
fakeGLdrawElements(context) {
|
|
182
153
|
return function (mode, count, type, offset) {
|
|
183
154
|
context.drawPasses++;
|
|
184
155
|
context.realGLDrawElements.call(this, mode, count, type, offset);
|
|
185
156
|
};
|
|
186
|
-
}
|
|
187
|
-
|
|
157
|
+
}
|
|
158
|
+
reset() {
|
|
188
159
|
this.drawPasses = 0;
|
|
189
|
-
}
|
|
190
|
-
|
|
160
|
+
}
|
|
161
|
+
release() {
|
|
191
162
|
if (this.isInit) {
|
|
192
163
|
this.gl.__proto__.drawElements = this.realGLDrawElements;
|
|
193
164
|
}
|
|
194
165
|
this.isInit = false;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
function TextureHook(_gl) {
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
class TextureHook {
|
|
169
|
+
constructor(_gl) {
|
|
200
170
|
this.createdTextures = new Array();
|
|
201
171
|
this.maxTexturesCount = 0;
|
|
202
172
|
this.isInit = false;
|
|
@@ -215,25 +185,21 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
215
185
|
console.error("[TextureHook] GL can't be NULL");
|
|
216
186
|
}
|
|
217
187
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
enumerable: false,
|
|
223
|
-
configurable: true
|
|
224
|
-
});
|
|
225
|
-
TextureHook.prototype.registerTexture = function (texture) {
|
|
188
|
+
get currentTextureCount() {
|
|
189
|
+
return this.createdTextures.length;
|
|
190
|
+
}
|
|
191
|
+
registerTexture(texture) {
|
|
226
192
|
this.createdTextures.push(texture);
|
|
227
193
|
this.maxTexturesCount = Math.max(this.createdTextures.length, this.maxTexturesCount);
|
|
228
|
-
}
|
|
229
|
-
|
|
194
|
+
}
|
|
195
|
+
fakeGLCreateTexture(context) {
|
|
230
196
|
return function () {
|
|
231
197
|
var texture = context.realGLCreateTexture.call(this);
|
|
232
198
|
context.registerTexture(texture);
|
|
233
199
|
return texture;
|
|
234
200
|
};
|
|
235
|
-
}
|
|
236
|
-
|
|
201
|
+
}
|
|
202
|
+
fakeGLDeleteTexture(context) {
|
|
237
203
|
return function (texture) {
|
|
238
204
|
var index = context.createdTextures.indexOf(texture);
|
|
239
205
|
if (index > -1) {
|
|
@@ -241,135 +207,106 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
241
207
|
}
|
|
242
208
|
context.realGLDeleteTexture.call(this, texture);
|
|
243
209
|
};
|
|
244
|
-
}
|
|
245
|
-
|
|
210
|
+
}
|
|
211
|
+
reset() {
|
|
246
212
|
this.createdTextures = new Array();
|
|
247
213
|
this.maxTexturesCount = 0;
|
|
248
|
-
}
|
|
249
|
-
|
|
214
|
+
}
|
|
215
|
+
release() {
|
|
250
216
|
if (this.isInit) {
|
|
251
217
|
this.gl.__proto__.createTexture = this.realGLCreateTexture;
|
|
252
218
|
this.gl.__proto__.deleteTexture = this.realGLDeleteTexture;
|
|
253
219
|
console.log('[TextureHook] Hook was removed!');
|
|
254
220
|
}
|
|
255
221
|
this.isInit = false;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
function BaseHooks() {
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
class BaseHooks {
|
|
225
|
+
constructor() {
|
|
261
226
|
this._drawCalls = -1;
|
|
262
227
|
this._maxDeltaDrawCalls = -1;
|
|
263
228
|
}
|
|
264
|
-
|
|
229
|
+
attach(gl) {
|
|
265
230
|
this.glhook = new GLHook(gl);
|
|
266
231
|
this.texturehook = new TextureHook(gl);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return this._maxDeltaDrawCalls;
|
|
281
|
-
},
|
|
282
|
-
enumerable: false,
|
|
283
|
-
configurable: true
|
|
284
|
-
});
|
|
285
|
-
Object.defineProperty(BaseHooks.prototype, "deltaDrawCalls", {
|
|
286
|
-
get: function () {
|
|
287
|
-
if (this._drawCalls == -1) {
|
|
288
|
-
this._drawCalls = this.drawCalls;
|
|
289
|
-
return 0;
|
|
290
|
-
}
|
|
291
|
-
var dc = this.drawCalls;
|
|
292
|
-
var delta = dc - this._drawCalls;
|
|
293
|
-
this._drawCalls = dc;
|
|
294
|
-
this._maxDeltaDrawCalls = Math.max(this._maxDeltaDrawCalls, delta);
|
|
295
|
-
return delta;
|
|
296
|
-
},
|
|
297
|
-
enumerable: false,
|
|
298
|
-
configurable: true
|
|
299
|
-
});
|
|
300
|
-
Object.defineProperty(BaseHooks.prototype, "maxTextureCount", {
|
|
301
|
-
get: function () {
|
|
302
|
-
if (this.texturehook && this.texturehook.isInit) return this.texturehook.maxTexturesCount;
|
|
303
|
-
return 0;
|
|
304
|
-
},
|
|
305
|
-
enumerable: false,
|
|
306
|
-
configurable: true
|
|
307
|
-
});
|
|
308
|
-
Object.defineProperty(BaseHooks.prototype, "texturesCount", {
|
|
309
|
-
get: function () {
|
|
310
|
-
if (this.texturehook && this.texturehook.isInit) return this.texturehook.currentTextureCount;
|
|
232
|
+
}
|
|
233
|
+
get drawCalls() {
|
|
234
|
+
if (this.glhook && this.glhook.isInit) {
|
|
235
|
+
return this.glhook.drawPasses;
|
|
236
|
+
}
|
|
237
|
+
return -1;
|
|
238
|
+
}
|
|
239
|
+
get maxDeltaDrawCalls() {
|
|
240
|
+
return this._maxDeltaDrawCalls;
|
|
241
|
+
}
|
|
242
|
+
get deltaDrawCalls() {
|
|
243
|
+
if (this._drawCalls == -1) {
|
|
244
|
+
this._drawCalls = this.drawCalls;
|
|
311
245
|
return 0;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
246
|
+
}
|
|
247
|
+
var dc = this.drawCalls;
|
|
248
|
+
var delta = dc - this._drawCalls;
|
|
249
|
+
this._drawCalls = dc;
|
|
250
|
+
this._maxDeltaDrawCalls = Math.max(this._maxDeltaDrawCalls, delta);
|
|
251
|
+
return delta;
|
|
252
|
+
}
|
|
253
|
+
get maxTextureCount() {
|
|
254
|
+
if (this.texturehook && this.texturehook.isInit) return this.texturehook.maxTexturesCount;
|
|
255
|
+
return 0;
|
|
256
|
+
}
|
|
257
|
+
get texturesCount() {
|
|
258
|
+
if (this.texturehook && this.texturehook.isInit) return this.texturehook.currentTextureCount;
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
261
|
+
reset() {
|
|
317
262
|
this._maxDeltaDrawCalls = -1;
|
|
318
263
|
this._drawCalls = -1;
|
|
319
264
|
if (this.glhook) this.glhook.reset();
|
|
320
265
|
if (this.texturehook) this.texturehook.reset();
|
|
321
|
-
}
|
|
322
|
-
|
|
266
|
+
}
|
|
267
|
+
release() {
|
|
323
268
|
if (this.glhook) this.glhook.release();
|
|
324
269
|
if (this.texturehook) this.texturehook.release();
|
|
325
|
-
};
|
|
326
|
-
return BaseHooks;
|
|
327
|
-
}();
|
|
328
|
-
var StatsSystem = function (_super) {
|
|
329
|
-
__extends(StatsSystem, _super);
|
|
330
|
-
function StatsSystem() {
|
|
331
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
332
|
-
_this.show = true;
|
|
333
|
-
return _this;
|
|
334
270
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
271
|
+
}
|
|
272
|
+
class StatsSystem extends eva_js.System {
|
|
273
|
+
constructor() {
|
|
274
|
+
super(...arguments);
|
|
275
|
+
this.show = true;
|
|
276
|
+
}
|
|
277
|
+
init(param = {
|
|
278
|
+
show: true
|
|
279
|
+
}) {
|
|
341
280
|
this.show = param.show;
|
|
342
281
|
this.style = param.style;
|
|
343
282
|
this.renderSystem = this.game.getSystem('Renderer');
|
|
344
283
|
this.app = this.renderSystem.application;
|
|
345
284
|
if (this.app && this.show) {
|
|
346
|
-
|
|
285
|
+
const gl = this.app.renderer.gl;
|
|
347
286
|
this.hook = new BaseHooks();
|
|
348
287
|
this.hook.attach(gl);
|
|
349
288
|
}
|
|
350
|
-
}
|
|
351
|
-
|
|
289
|
+
}
|
|
290
|
+
start() {
|
|
352
291
|
if (!this.show) return;
|
|
353
|
-
this.component = this.game.scene.addComponent(new
|
|
292
|
+
this.component = this.game.scene.addComponent(new StatsComponent());
|
|
354
293
|
this.stats = Stats$1(this.style);
|
|
355
294
|
this.component.stats = this.stats;
|
|
356
295
|
this.stats.showPanel(0);
|
|
357
296
|
document.body.appendChild(this.stats.dom);
|
|
358
|
-
}
|
|
359
|
-
|
|
297
|
+
}
|
|
298
|
+
lateUpdate() {
|
|
360
299
|
if (!this.show) return;
|
|
361
300
|
this.stats && this.stats.end(this.hook);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}(eva_js.System);
|
|
366
|
-
var StatsSystem$1 = StatsSystem;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
StatsSystem.systemName = 'Stats';
|
|
367
304
|
var index = {
|
|
368
|
-
Components: [
|
|
369
|
-
Systems: [StatsSystem
|
|
305
|
+
Components: [StatsComponent],
|
|
306
|
+
Systems: [StatsSystem]
|
|
370
307
|
};
|
|
371
|
-
exports.Stats =
|
|
372
|
-
exports.StatsSystem = StatsSystem
|
|
308
|
+
exports.Stats = StatsComponent;
|
|
309
|
+
exports.StatsSystem = StatsSystem;
|
|
373
310
|
exports["default"] = index;
|
|
374
311
|
Object.defineProperty(exports, '__esModule', {
|
|
375
312
|
value: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_stats=function(t,e){"use strict";class s extends e.Component{update(){this.stats&&this.stats.begin()}}s.componentName="Stats";const r=function(t){t=_extends({width:20,height:12,x:0,y:0},t);const{width:e,height:s,x:a,y:i}=t;let l=0;const n=document.createElement("div");function o(t){return n.appendChild(t.dom),t}function h(t){for(let e=0;e<n.children.length;e++)n.children[e].style.display=e===t?"block":"none";l=t}n.style.cssText=`position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: ${e}vw;height: ${s}vw;left: ${a}vw;top: ${i}vw;`,n.addEventListener("click",(function(t){t.preventDefault(),h(++l%n.children.length)}),!1);let u=(performance||Date).now(),c=u,d=0;const x=o(r.Panel("FPS","#0ff","#002")),w=o(r.Panel("MS","#0f0","#020")),m=o(r.Panel("DrawCall","#330570","#A69700")),p=o(r.Panel("TC:","#A62500","#00B454"));let _;return self.performance&&self.performance.memory&&(_=o(r.Panel("MB","#f08","#201"))),h(0),{REVISION:16,dom:n,addPanel:o,showPanel:h,begin:function(t){u=t||(performance||Date).now()},end:function(t){d++;const e=(performance||Date).now();if(w.update(e-u,200),t&&(m.update(t.deltaDrawCalls,Math.max(50,t.maxDeltaDrawCalls)),p.update(t.texturesCount,Math.max(20,t.maxTextureCount))),e>=c+1e3&&(x.update(1e3*d/(e-c),100),c=e,d=0,_)){const t=performance.memory;_.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){u=this.end()},domElement:n,setMode:h}};r.Panel=function(t,e,s){let r=1/0,a=0;const i=Math.round,l=i(window.devicePixelRatio||1),n=80*l,o=48*l,h=3*l,u=2*l,c=3*l,d=15*l,x=74*l,w=30*l,m=document.createElement("canvas");m.width=n,m.height=o,m.style.cssText="width:100%;height:100%";const p=m.getContext("2d");return p.font="bold "+9*l+"px Helvetica,Arial,sans-serif",p.textBaseline="top",p.fillStyle=s,p.fillRect(0,0,n,o),p.fillStyle=e,p.fillText(t,h,u),p.fillRect(c,d,x,w),p.fillStyle=s,p.globalAlpha=.9,p.fillRect(c,d,x,w),{dom:m,update:function(o,_){r=Math.min(r,o),a=Math.max(a,o),p.fillStyle=s,p.globalAlpha=1,p.fillRect(0,0,n,d),p.fillStyle=e,p.fillText(i(o)+" "+t+" ("+i(r)+"-"+i(a)+")",h,u),p.drawImage(m,c+l,d,x-l,w,c,d,x-l,w),p.fillRect(c+x-l,d,l,w),p.fillStyle=s,p.globalAlpha=.9,p.fillRect(c+x-l,d,l,i((1-o/_)*w))}}};var a=r;class i{constructor(t){this.drawPasses=0,this.isInit=!1,this.realGLDrawElements=function(){},t?t.__proto__.drawElements&&(this.gl=t,this.realGLDrawElements=t.__proto__.drawElements,t.__proto__.drawElements=this.fakeGLdrawElements(this),this.isInit=!0):console.error("[GLHook] GL can't be NULL")}fakeGLdrawElements(t){return function(e,s,r,a){t.drawPasses++,t.realGLDrawElements.call(this,e,s,r,a)}}reset(){this.drawPasses=0}release(){this.isInit&&(this.gl.__proto__.drawElements=this.realGLDrawElements),this.isInit=!1}}class l{constructor(t){this.createdTextures=new Array,this.maxTexturesCount=0,this.isInit=!1,this.realGLCreateTexture=function(){},this.realGLDeleteTexture=function(){},t?t.__proto__.createTexture&&(this.gl=t,this.realGLCreateTexture=t.__proto__.createTexture,this.realGLDeleteTexture=t.__proto__.deleteTexture,t.__proto__.createTexture=this.fakeGLCreateTexture(this),t.__proto__.deleteTexture=this.fakeGLDeleteTexture(this),this.isInit=!0):console.error("[TextureHook] GL can't be NULL")}get currentTextureCount(){return this.createdTextures.length}registerTexture(t){this.createdTextures.push(t),this.maxTexturesCount=Math.max(this.createdTextures.length,this.maxTexturesCount)}fakeGLCreateTexture(t){return function(){var e=t.realGLCreateTexture.call(this);return t.registerTexture(e),e}}fakeGLDeleteTexture(t){return function(e){var s=t.createdTextures.indexOf(e);s>-1&&t.createdTextures.splice(s,1),t.realGLDeleteTexture.call(this,e)}}reset(){this.createdTextures=new Array,this.maxTexturesCount=0}release(){this.isInit&&(this.gl.__proto__.createTexture=this.realGLCreateTexture,this.gl.__proto__.deleteTexture=this.realGLDeleteTexture,console.log("[TextureHook] Hook was removed!")),this.isInit=!1}}class n{constructor(){this._drawCalls=-1,this._maxDeltaDrawCalls=-1}attach(t){this.glhook=new i(t),this.texturehook=new l(t)}get drawCalls(){return this.glhook&&this.glhook.isInit?this.glhook.drawPasses:-1}get maxDeltaDrawCalls(){return this._maxDeltaDrawCalls}get deltaDrawCalls(){if(-1==this._drawCalls)return this._drawCalls=this.drawCalls,0;var t=this.drawCalls,e=t-this._drawCalls;return this._drawCalls=t,this._maxDeltaDrawCalls=Math.max(this._maxDeltaDrawCalls,e),e}get maxTextureCount(){return this.texturehook&&this.texturehook.isInit?this.texturehook.maxTexturesCount:0}get texturesCount(){return this.texturehook&&this.texturehook.isInit?this.texturehook.currentTextureCount:0}reset(){this._maxDeltaDrawCalls=-1,this._drawCalls=-1,this.glhook&&this.glhook.reset(),this.texturehook&&this.texturehook.reset()}release(){this.glhook&&this.glhook.release(),this.texturehook&&this.texturehook.release()}}class o extends e.System{constructor(){super(...arguments),this.show=!0}init(t={show:!0}){if(this.show=t.show,this.style=t.style,this.renderSystem=this.game.getSystem("Renderer"),this.app=this.renderSystem.application,this.app&&this.show){const t=this.app.renderer.gl;this.hook=new n,this.hook.attach(t)}}start(){this.show&&(this.component=this.game.scene.addComponent(new s),this.stats=a(this.style),this.component.stats=this.stats,this.stats.showPanel(0),document.body.appendChild(this.stats.dom))}lateUpdate(){this.show&&this.stats&&this.stats.end(this.hook)}}o.systemName="Stats";var h={Components:[s],Systems:[o]};return t.Stats=s,t.StatsSystem=o,t.default=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.stats=window.EVA.plugin.stats||_EVA_IIFE_stats;
|