@eva/plugin-stats 1.1.1-fix.2 → 1.1.1-fix.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 +201 -446
- package/dist/EVA.plugin.stats.js.map +1 -0
- package/dist/EVA.plugin.stats.min.js +0 -1
- package/dist/plugin-stats.cjs.js +3 -183
- package/dist/plugin-stats.cjs.js.map +1 -0
- package/dist/plugin-stats.cjs.prod.js +0 -1
- package/dist/plugin-stats.esm.js +3 -183
- package/dist/plugin-stats.esm.js.map +1 -0
- package/package.json +2 -2
- package/dist/EVA.plugin.stats.min.js.map +0 -1
- package/dist/plugin-stats.cjs.prod.js.map +0 -1
package/dist/EVA.plugin.stats.js
CHANGED
|
@@ -1,446 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.realGLDrawElements = function () {};
|
|
204
|
-
|
|
205
|
-
if (_gl) {
|
|
206
|
-
if (_gl.__proto__.drawElements) {
|
|
207
|
-
this.gl = _gl;
|
|
208
|
-
this.realGLDrawElements = _gl.__proto__.drawElements;
|
|
209
|
-
_gl.__proto__.drawElements = this.fakeGLdrawElements.bind(this);
|
|
210
|
-
this.isInit = true;
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
console.error("[GLHook] GL can't be NULL");
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
GLHook.prototype.fakeGLdrawElements = function (mode, count, type, offset) {
|
|
218
|
-
this.drawPasses++;
|
|
219
|
-
this.realGLDrawElements.call(this.gl, mode, count, type, offset);
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
GLHook.prototype.reset = function () {
|
|
223
|
-
this.drawPasses = 0;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
GLHook.prototype.release = function () {
|
|
227
|
-
if (this.isInit) {
|
|
228
|
-
this.gl.__proto__.drawElements = this.realGLDrawElements;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
this.isInit = false;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
return GLHook;
|
|
235
|
-
}();
|
|
236
|
-
|
|
237
|
-
var TextureHook = function () {
|
|
238
|
-
function TextureHook(_gl) {
|
|
239
|
-
this.createdTextures = new Array();
|
|
240
|
-
this.maxTexturesCount = 0;
|
|
241
|
-
this.isInit = false;
|
|
242
|
-
|
|
243
|
-
this.realGLCreateTexture = function () {};
|
|
244
|
-
|
|
245
|
-
this.realGLDeleteTexture = function () {};
|
|
246
|
-
|
|
247
|
-
if (_gl) {
|
|
248
|
-
if (_gl.__proto__.createTexture) {
|
|
249
|
-
this.gl = _gl;
|
|
250
|
-
this.realGLCreateTexture = _gl.__proto__.createTexture;
|
|
251
|
-
this.realGLDeleteTexture = _gl.__proto__.deleteTexture;
|
|
252
|
-
_gl.__proto__.createTexture = this.fakeGLCreateTexture.bind(this);
|
|
253
|
-
_gl.__proto__.deleteTexture = this.fakeGLDeleteTexture.bind(this);
|
|
254
|
-
this.isInit = true;
|
|
255
|
-
}
|
|
256
|
-
} else {
|
|
257
|
-
console.error("[TextureHook] GL can't be NULL");
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
Object.defineProperty(TextureHook.prototype, "currentTextureCount", {
|
|
262
|
-
get: function get() {
|
|
263
|
-
return this.createdTextures.length;
|
|
264
|
-
},
|
|
265
|
-
enumerable: false,
|
|
266
|
-
configurable: true
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
TextureHook.prototype.registerTexture = function (texture) {
|
|
270
|
-
this.createdTextures.push(texture);
|
|
271
|
-
this.maxTexturesCount = Math.max(this.createdTextures.length, this.maxTexturesCount);
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
TextureHook.prototype.fakeGLCreateTexture = function () {
|
|
275
|
-
var texture = this.realGLCreateTexture.call(this.gl);
|
|
276
|
-
this.registerTexture(texture);
|
|
277
|
-
return texture;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
TextureHook.prototype.fakeGLDeleteTexture = function (texture) {
|
|
281
|
-
var index = this.createdTextures.indexOf(texture);
|
|
282
|
-
|
|
283
|
-
if (index > -1) {
|
|
284
|
-
this.createdTextures.splice(index, 1);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
this.realGLDeleteTexture.call(this.gl, texture);
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
TextureHook.prototype.reset = function () {
|
|
291
|
-
this.createdTextures = new Array();
|
|
292
|
-
this.maxTexturesCount = 0;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
TextureHook.prototype.release = function () {
|
|
296
|
-
if (this.isInit) {
|
|
297
|
-
this.gl.__proto__.createTexture = this.realGLCreateTexture;
|
|
298
|
-
this.gl.__proto__.deleteTexture = this.realGLDeleteTexture;
|
|
299
|
-
console.log('[TextureHook] Hook was removed!');
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
this.isInit = false;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
return TextureHook;
|
|
306
|
-
}();
|
|
307
|
-
|
|
308
|
-
var BaseHooks = function () {
|
|
309
|
-
function BaseHooks() {
|
|
310
|
-
this._drawCalls = -1;
|
|
311
|
-
this._maxDeltaDrawCalls = -1;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
BaseHooks.prototype.attach = function (gl) {
|
|
315
|
-
this.glhook = new GLHook(gl);
|
|
316
|
-
this.texturehook = new TextureHook(gl);
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
Object.defineProperty(BaseHooks.prototype, "drawCalls", {
|
|
320
|
-
get: function get() {
|
|
321
|
-
if (this.glhook && this.glhook.isInit) {
|
|
322
|
-
return this.glhook.drawPasses;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return -1;
|
|
326
|
-
},
|
|
327
|
-
enumerable: false,
|
|
328
|
-
configurable: true
|
|
329
|
-
});
|
|
330
|
-
Object.defineProperty(BaseHooks.prototype, "maxDeltaDrawCalls", {
|
|
331
|
-
get: function get() {
|
|
332
|
-
return this._maxDeltaDrawCalls;
|
|
333
|
-
},
|
|
334
|
-
enumerable: false,
|
|
335
|
-
configurable: true
|
|
336
|
-
});
|
|
337
|
-
Object.defineProperty(BaseHooks.prototype, "deltaDrawCalls", {
|
|
338
|
-
get: function get() {
|
|
339
|
-
if (this._drawCalls == -1) {
|
|
340
|
-
this._drawCalls = this.drawCalls;
|
|
341
|
-
return 0;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
var dc = this.drawCalls;
|
|
345
|
-
var delta = dc - this._drawCalls;
|
|
346
|
-
this._drawCalls = dc;
|
|
347
|
-
this._maxDeltaDrawCalls = Math.max(this._maxDeltaDrawCalls, delta);
|
|
348
|
-
return delta;
|
|
349
|
-
},
|
|
350
|
-
enumerable: false,
|
|
351
|
-
configurable: true
|
|
352
|
-
});
|
|
353
|
-
Object.defineProperty(BaseHooks.prototype, "maxTextureCount", {
|
|
354
|
-
get: function get() {
|
|
355
|
-
if (this.texturehook && this.texturehook.isInit) return this.texturehook.maxTexturesCount;
|
|
356
|
-
return 0;
|
|
357
|
-
},
|
|
358
|
-
enumerable: false,
|
|
359
|
-
configurable: true
|
|
360
|
-
});
|
|
361
|
-
Object.defineProperty(BaseHooks.prototype, "texturesCount", {
|
|
362
|
-
get: function get() {
|
|
363
|
-
if (this.texturehook && this.texturehook.isInit) return this.texturehook.currentTextureCount;
|
|
364
|
-
return 0;
|
|
365
|
-
},
|
|
366
|
-
enumerable: false,
|
|
367
|
-
configurable: true
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
BaseHooks.prototype.reset = function () {
|
|
371
|
-
this._maxDeltaDrawCalls = -1;
|
|
372
|
-
this._drawCalls = -1;
|
|
373
|
-
if (this.glhook) this.glhook.reset();
|
|
374
|
-
if (this.texturehook) this.texturehook.reset();
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
BaseHooks.prototype.release = function () {
|
|
378
|
-
if (this.glhook) this.glhook.release();
|
|
379
|
-
if (this.texturehook) this.texturehook.release();
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
return BaseHooks;
|
|
383
|
-
}();
|
|
384
|
-
|
|
385
|
-
var StatsSystem = function (_super) {
|
|
386
|
-
__extends(StatsSystem, _super);
|
|
387
|
-
|
|
388
|
-
function StatsSystem() {
|
|
389
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
390
|
-
|
|
391
|
-
_this.show = true;
|
|
392
|
-
return _this;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
StatsSystem.prototype.init = function (param) {
|
|
396
|
-
if (param === void 0) {
|
|
397
|
-
param = {
|
|
398
|
-
show: true
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
this.show = param.show;
|
|
403
|
-
this.style = param.style;
|
|
404
|
-
this.renderSystem = this.game.getSystem('Renderer');
|
|
405
|
-
this.app = this.renderSystem.application;
|
|
406
|
-
|
|
407
|
-
if (this.app && this.show) {
|
|
408
|
-
var gl = this.app.renderer.gl;
|
|
409
|
-
this.hook = new BaseHooks();
|
|
410
|
-
this.hook.attach(gl);
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
StatsSystem.prototype.start = function () {
|
|
415
|
-
if (!this.show) return;
|
|
416
|
-
this.component = this.game.scene.addComponent(new Stats$2());
|
|
417
|
-
this.stats = Stats$1(this.style);
|
|
418
|
-
this.component.stats = this.stats;
|
|
419
|
-
this.stats.showPanel(0);
|
|
420
|
-
document.body.appendChild(this.stats.dom);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
StatsSystem.prototype.lateUpdate = function () {
|
|
424
|
-
if (!this.show) return;
|
|
425
|
-
this.stats && this.stats.end(this.hook);
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
StatsSystem.systemName = 'Stats';
|
|
429
|
-
return StatsSystem;
|
|
430
|
-
}(eva_js.System);
|
|
431
|
-
|
|
432
|
-
var StatsSystem$1 = StatsSystem;
|
|
433
|
-
var index = {
|
|
434
|
-
Components: [Stats$2],
|
|
435
|
-
Systems: [StatsSystem$1]
|
|
436
|
-
};
|
|
437
|
-
exports.Stats = Stats$2;
|
|
438
|
-
exports.StatsSystem = StatsSystem$1;
|
|
439
|
-
exports['default'] = index;
|
|
440
|
-
Object.defineProperty(exports, '__esModule', {
|
|
441
|
-
value: true
|
|
442
|
-
});
|
|
443
|
-
return exports;
|
|
444
|
-
}({}, EVA);
|
|
445
|
-
|
|
446
|
-
window.EVA.plugin.stats = window.EVA.plugin.stats || _EVA_IIFE_stats;
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@eva/eva.js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@eva/eva.js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.EVA = global.EVA || {}, global.EVA.plugin = global.EVA.plugin || {}, global.EVA.plugin.stats = {}), global.EVA));
|
|
5
|
+
}(this, (function (exports, eva_js) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise */
|
|
22
|
+
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf ||
|
|
25
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
+
return extendStatics(d, b);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
extendStatics(d, b);
|
|
32
|
+
function __() { this.constructor = d; }
|
|
33
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var __assign = function() {
|
|
37
|
+
__assign = Object.assign || function __assign(t) {
|
|
38
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
|
+
s = arguments[i];
|
|
40
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
};
|
|
44
|
+
return __assign.apply(this, arguments);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var StatsComponent = (function (_super) {
|
|
48
|
+
__extends(StatsComponent, _super);
|
|
49
|
+
function StatsComponent() {
|
|
50
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
51
|
+
}
|
|
52
|
+
StatsComponent.prototype.update = function () {
|
|
53
|
+
this.stats && this.stats.begin();
|
|
54
|
+
};
|
|
55
|
+
StatsComponent.componentName = 'Stats';
|
|
56
|
+
return StatsComponent;
|
|
57
|
+
}(eva_js.Component));
|
|
58
|
+
var Stats$2 = StatsComponent;
|
|
59
|
+
|
|
60
|
+
var Stats = function (style) {
|
|
61
|
+
style = __assign({ width: 20, height: 12, x: 0, y: 0 }, style);
|
|
62
|
+
var width = style.width, height = style.height, x = style.x, y = style.y;
|
|
63
|
+
var mode = 0;
|
|
64
|
+
var container = document.createElement('div');
|
|
65
|
+
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;";
|
|
66
|
+
container.addEventListener('click', function (event) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
showPanel(++mode % container.children.length);
|
|
69
|
+
}, false);
|
|
70
|
+
function addPanel(panel) {
|
|
71
|
+
container.appendChild(panel.dom);
|
|
72
|
+
return panel;
|
|
73
|
+
}
|
|
74
|
+
function showPanel(id) {
|
|
75
|
+
for (var i = 0; i < container.children.length; i++) {
|
|
76
|
+
container.children[i].style.display = i === id ? 'block' : 'none';
|
|
77
|
+
}
|
|
78
|
+
mode = id;
|
|
79
|
+
}
|
|
80
|
+
var beginTime = (performance || Date).now(), prevTime = beginTime, frames = 0;
|
|
81
|
+
var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
|
|
82
|
+
var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
|
|
83
|
+
var memPanel;
|
|
84
|
+
if (self.performance && self.performance.memory) {
|
|
85
|
+
memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
|
|
86
|
+
}
|
|
87
|
+
showPanel(0);
|
|
88
|
+
return {
|
|
89
|
+
REVISION: 16,
|
|
90
|
+
dom: container,
|
|
91
|
+
addPanel: addPanel,
|
|
92
|
+
showPanel: showPanel,
|
|
93
|
+
begin: function (time) {
|
|
94
|
+
beginTime = time || (performance || Date).now();
|
|
95
|
+
},
|
|
96
|
+
end: function () {
|
|
97
|
+
frames++;
|
|
98
|
+
var time = (performance || Date).now();
|
|
99
|
+
msPanel.update(time - beginTime, 200);
|
|
100
|
+
if (time >= prevTime + 1000) {
|
|
101
|
+
fpsPanel.update((frames * 1000) / (time - prevTime), 100);
|
|
102
|
+
prevTime = time;
|
|
103
|
+
frames = 0;
|
|
104
|
+
if (memPanel) {
|
|
105
|
+
var memory = performance.memory;
|
|
106
|
+
memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return time;
|
|
110
|
+
},
|
|
111
|
+
update: function () {
|
|
112
|
+
beginTime = this.end();
|
|
113
|
+
},
|
|
114
|
+
domElement: container,
|
|
115
|
+
setMode: showPanel,
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
Stats.Panel = function (name, fg, bg) {
|
|
119
|
+
var min = Infinity, max = 0;
|
|
120
|
+
var round = Math.round;
|
|
121
|
+
var PR = round(window.devicePixelRatio || 1);
|
|
122
|
+
var WIDTH = 80 * PR, HEIGHT = 48 * PR, TEXT_X = 3 * PR, TEXT_Y = 2 * PR, GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR, GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;
|
|
123
|
+
var canvas = document.createElement('canvas');
|
|
124
|
+
canvas.width = WIDTH;
|
|
125
|
+
canvas.height = HEIGHT;
|
|
126
|
+
canvas.style.cssText = 'width:100%;height:100%';
|
|
127
|
+
var context = canvas.getContext('2d');
|
|
128
|
+
context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';
|
|
129
|
+
context.textBaseline = 'top';
|
|
130
|
+
context.fillStyle = bg;
|
|
131
|
+
context.fillRect(0, 0, WIDTH, HEIGHT);
|
|
132
|
+
context.fillStyle = fg;
|
|
133
|
+
context.fillText(name, TEXT_X, TEXT_Y);
|
|
134
|
+
context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
|
|
135
|
+
context.fillStyle = bg;
|
|
136
|
+
context.globalAlpha = 0.9;
|
|
137
|
+
context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
|
|
138
|
+
return {
|
|
139
|
+
dom: canvas,
|
|
140
|
+
update: function (value, maxValue) {
|
|
141
|
+
min = Math.min(min, value);
|
|
142
|
+
max = Math.max(max, value);
|
|
143
|
+
context.fillStyle = bg;
|
|
144
|
+
context.globalAlpha = 1;
|
|
145
|
+
context.fillRect(0, 0, WIDTH, GRAPH_Y);
|
|
146
|
+
context.fillStyle = fg;
|
|
147
|
+
context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);
|
|
148
|
+
context.drawImage(canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT);
|
|
149
|
+
context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);
|
|
150
|
+
context.fillStyle = bg;
|
|
151
|
+
context.globalAlpha = 0.9;
|
|
152
|
+
context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
var Stats$1 = Stats;
|
|
157
|
+
|
|
158
|
+
var StatsSystem = (function (_super) {
|
|
159
|
+
__extends(StatsSystem, _super);
|
|
160
|
+
function StatsSystem() {
|
|
161
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
162
|
+
_this.show = true;
|
|
163
|
+
return _this;
|
|
164
|
+
}
|
|
165
|
+
StatsSystem.prototype.init = function (param) {
|
|
166
|
+
if (param === void 0) { param = { show: true }; }
|
|
167
|
+
this.show = param.show;
|
|
168
|
+
this.style = param.style;
|
|
169
|
+
};
|
|
170
|
+
StatsSystem.prototype.start = function () {
|
|
171
|
+
if (!this.show)
|
|
172
|
+
return;
|
|
173
|
+
this.component = this.game.scene.addComponent(new Stats$2());
|
|
174
|
+
this.stats = Stats$1(this.style);
|
|
175
|
+
this.component.stats = this.stats;
|
|
176
|
+
this.stats.showPanel(0);
|
|
177
|
+
document.body.appendChild(this.stats.dom);
|
|
178
|
+
};
|
|
179
|
+
StatsSystem.prototype.lateUpdate = function () {
|
|
180
|
+
if (!this.show)
|
|
181
|
+
return;
|
|
182
|
+
this.stats && this.stats.end();
|
|
183
|
+
};
|
|
184
|
+
StatsSystem.systemName = 'Stats';
|
|
185
|
+
return StatsSystem;
|
|
186
|
+
}(eva_js.System));
|
|
187
|
+
var StatsSystem$1 = StatsSystem;
|
|
188
|
+
|
|
189
|
+
var index = {
|
|
190
|
+
Components: [Stats$2],
|
|
191
|
+
Systems: [StatsSystem$1],
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
exports.Stats = Stats$2;
|
|
195
|
+
exports.StatsSystem = StatsSystem$1;
|
|
196
|
+
exports['default'] = index;
|
|
197
|
+
|
|
198
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
199
|
+
|
|
200
|
+
})));
|
|
201
|
+
//# sourceMappingURL=EVA.plugin.stats.js.map
|