@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.
@@ -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
- var extendStatics = function (d, b) {
6
- extendStatics = Object.setPrototypeOf || {
7
- __proto__: []
8
- } instanceof Array && function (d, b) {
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
- var __assign = function () {
23
- __assign = Object.assign || function __assign(t) {
24
- for (var s, i = 1, n = arguments.length; i < n; i++) {
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
- var width = style.width,
52
- height = style.height,
53
- x = style.x,
54
- y = style.y;
55
- var mode = 0;
56
- var container = document.createElement('div');
57
- 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;";
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 (var i = 0; i < container.children.length; i++) {
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
- var beginTime = (performance || Date).now(),
43
+ let beginTime = (performance || Date).now(),
73
44
  prevTime = beginTime,
74
45
  frames = 0;
75
- var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
76
- var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
77
- var dcPanel = addPanel(Stats.Panel('DrawCall', '#330570', '#A69700'));
78
- var tcPanel = addPanel(Stats.Panel('TC:', '#A62500', '#00B454'));
79
- var memPanel;
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
- var time = (performance || Date).now();
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
- var memory = performance.memory;
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
- var min = Infinity,
90
+ let min = Infinity,
120
91
  max = 0;
121
- var round = Math.round;
122
- var PR = round(window.devicePixelRatio || 1);
123
- var WIDTH = 80 * PR,
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
- var canvas = document.createElement('canvas');
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
- var context = canvas.getContext('2d');
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
- var GLHook = function () {
166
- function GLHook(_gl) {
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
- GLHook.prototype.fakeGLdrawElements = function (context) {
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
- GLHook.prototype.reset = function () {
157
+ }
158
+ reset() {
188
159
  this.drawPasses = 0;
189
- };
190
- GLHook.prototype.release = function () {
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
- return GLHook;
197
- }();
198
- var TextureHook = function () {
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
- Object.defineProperty(TextureHook.prototype, "currentTextureCount", {
219
- get: function () {
220
- return this.createdTextures.length;
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
- TextureHook.prototype.fakeGLCreateTexture = function (context) {
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
- TextureHook.prototype.fakeGLDeleteTexture = function (context) {
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
- TextureHook.prototype.reset = function () {
210
+ }
211
+ reset() {
246
212
  this.createdTextures = new Array();
247
213
  this.maxTexturesCount = 0;
248
- };
249
- TextureHook.prototype.release = function () {
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
- return TextureHook;
258
- }();
259
- var BaseHooks = function () {
260
- function BaseHooks() {
222
+ }
223
+ }
224
+ class BaseHooks {
225
+ constructor() {
261
226
  this._drawCalls = -1;
262
227
  this._maxDeltaDrawCalls = -1;
263
228
  }
264
- BaseHooks.prototype.attach = function (gl) {
229
+ attach(gl) {
265
230
  this.glhook = new GLHook(gl);
266
231
  this.texturehook = new TextureHook(gl);
267
- };
268
- Object.defineProperty(BaseHooks.prototype, "drawCalls", {
269
- get: function () {
270
- if (this.glhook && this.glhook.isInit) {
271
- return this.glhook.drawPasses;
272
- }
273
- return -1;
274
- },
275
- enumerable: false,
276
- configurable: true
277
- });
278
- Object.defineProperty(BaseHooks.prototype, "maxDeltaDrawCalls", {
279
- get: function () {
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
- enumerable: false,
314
- configurable: true
315
- });
316
- BaseHooks.prototype.reset = function () {
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
- BaseHooks.prototype.release = function () {
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
- StatsSystem.prototype.init = function (param) {
336
- if (param === void 0) {
337
- param = {
338
- show: true
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
- var gl = this.app.renderer.gl;
285
+ const gl = this.app.renderer.gl;
347
286
  this.hook = new BaseHooks();
348
287
  this.hook.attach(gl);
349
288
  }
350
- };
351
- StatsSystem.prototype.start = function () {
289
+ }
290
+ start() {
352
291
  if (!this.show) return;
353
- this.component = this.game.scene.addComponent(new Stats$2());
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
- StatsSystem.prototype.lateUpdate = function () {
297
+ }
298
+ lateUpdate() {
360
299
  if (!this.show) return;
361
300
  this.stats && this.stats.end(this.hook);
362
- };
363
- StatsSystem.systemName = 'Stats';
364
- return StatsSystem;
365
- }(eva_js.System);
366
- var StatsSystem$1 = StatsSystem;
301
+ }
302
+ }
303
+ StatsSystem.systemName = 'Stats';
367
304
  var index = {
368
- Components: [Stats$2],
369
- Systems: [StatsSystem$1]
305
+ Components: [StatsComponent],
306
+ Systems: [StatsSystem]
370
307
  };
371
- exports.Stats = Stats$2;
372
- exports.StatsSystem = StatsSystem$1;
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
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_stats=function(t,e){"use strict";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},r(t,e)};function o(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},n.apply(this,arguments)},i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.update=function(){this.stats&&this.stats.begin()},e.componentName="Stats",e}(e.Component),s=i,a=function(t){var e=(t=n({width:20,height:12,x:0,y:0},t)).width,r=t.height,o=t.x,i=t.y,s=0,l=document.createElement("div");function u(t){return l.appendChild(t.dom),t}function h(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";s=t}l.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: "+e+"vw;height: "+r+"vw;left: "+o+"vw;top: "+i+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),h(++s%l.children.length)}),!1);var c,p=(performance||Date).now(),f=p,d=0,x=u(a.Panel("FPS","#0ff","#002")),w=u(a.Panel("MS","#0f0","#020")),m=u(a.Panel("DrawCall","#330570","#A69700")),_=u(a.Panel("TC:","#A62500","#00B454"));return self.performance&&self.performance.memory&&(c=u(a.Panel("MB","#f08","#201"))),h(0),{REVISION:16,dom:l,addPanel:u,showPanel:h,begin:function(t){p=t||(performance||Date).now()},end:function(t){d++;var e=(performance||Date).now();if(w.update(e-p,200),t&&(m.update(t.deltaDrawCalls,Math.max(50,t.maxDeltaDrawCalls)),_.update(t.texturesCount,Math.max(20,t.maxTextureCount))),e>=f+1e3&&(x.update(1e3*d/(e-f),100),f=e,d=0,c)){var r=performance.memory;c.update(r.usedJSHeapSize/1048576,r.jsHeapSizeLimit/1048576)}return e},update:function(){p=this.end()},domElement:l,setMode:h}};a.Panel=function(t,e,r){var o=1/0,n=0,i=Math.round,s=i(window.devicePixelRatio||1),a=80*s,l=48*s,u=3*s,h=2*s,c=3*s,p=15*s,f=74*s,d=30*s,x=document.createElement("canvas");x.width=a,x.height=l,x.style.cssText="width:100%;height:100%";var w=x.getContext("2d");return w.font="bold "+9*s+"px Helvetica,Arial,sans-serif",w.textBaseline="top",w.fillStyle=r,w.fillRect(0,0,a,l),w.fillStyle=e,w.fillText(t,u,h),w.fillRect(c,p,f,d),w.fillStyle=r,w.globalAlpha=.9,w.fillRect(c,p,f,d),{dom:x,update:function(l,m){o=Math.min(o,l),n=Math.max(n,l),w.fillStyle=r,w.globalAlpha=1,w.fillRect(0,0,a,p),w.fillStyle=e,w.fillText(i(l)+" "+t+" ("+i(o)+"-"+i(n)+")",u,h),w.drawImage(x,c+s,p,f-s,d,c,p,f-s,d),w.fillRect(c+f-s,p,s,d),w.fillStyle=r,w.globalAlpha=.9,w.fillRect(c+f-s,p,s,i((1-l/m)*d))}}};var l=a,u=function(){function t(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")}return t.prototype.fakeGLdrawElements=function(t){return function(e,r,o,n){t.drawPasses++,t.realGLDrawElements.call(this,e,r,o,n)}},t.prototype.reset=function(){this.drawPasses=0},t.prototype.release=function(){this.isInit&&(this.gl.__proto__.drawElements=this.realGLDrawElements),this.isInit=!1},t}(),h=function(){function t(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")}return Object.defineProperty(t.prototype,"currentTextureCount",{get:function(){return this.createdTextures.length},enumerable:!1,configurable:!0}),t.prototype.registerTexture=function(t){this.createdTextures.push(t),this.maxTexturesCount=Math.max(this.createdTextures.length,this.maxTexturesCount)},t.prototype.fakeGLCreateTexture=function(t){return function(){var e=t.realGLCreateTexture.call(this);return t.registerTexture(e),e}},t.prototype.fakeGLDeleteTexture=function(t){return function(e){var r=t.createdTextures.indexOf(e);r>-1&&t.createdTextures.splice(r,1),t.realGLDeleteTexture.call(this,e)}},t.prototype.reset=function(){this.createdTextures=new Array,this.maxTexturesCount=0},t.prototype.release=function(){this.isInit&&(this.gl.__proto__.createTexture=this.realGLCreateTexture,this.gl.__proto__.deleteTexture=this.realGLDeleteTexture,console.log("[TextureHook] Hook was removed!")),this.isInit=!1},t}(),c=function(){function t(){this._drawCalls=-1,this._maxDeltaDrawCalls=-1}return t.prototype.attach=function(t){this.glhook=new u(t),this.texturehook=new h(t)},Object.defineProperty(t.prototype,"drawCalls",{get:function(){return this.glhook&&this.glhook.isInit?this.glhook.drawPasses:-1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDeltaDrawCalls",{get:function(){return this._maxDeltaDrawCalls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaDrawCalls",{get:function(){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},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxTextureCount",{get:function(){return this.texturehook&&this.texturehook.isInit?this.texturehook.maxTexturesCount:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texturesCount",{get:function(){return this.texturehook&&this.texturehook.isInit?this.texturehook.currentTextureCount:0},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this._maxDeltaDrawCalls=-1,this._drawCalls=-1,this.glhook&&this.glhook.reset(),this.texturehook&&this.texturehook.reset()},t.prototype.release=function(){this.glhook&&this.glhook.release(),this.texturehook&&this.texturehook.release()},t}(),p=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.show=!0,e}return o(e,t),e.prototype.init=function(t){if(void 0===t&&(t={show:!0}),this.show=t.show,this.style=t.style,this.renderSystem=this.game.getSystem("Renderer"),this.app=this.renderSystem.application,this.app&&this.show){var e=this.app.renderer.gl;this.hook=new c,this.hook.attach(e)}},e.prototype.start=function(){this.show&&(this.component=this.game.scene.addComponent(new s),this.stats=l(this.style),this.component.stats=this.stats,this.stats.showPanel(0),document.body.appendChild(this.stats.dom))},e.prototype.lateUpdate=function(){this.show&&this.stats&&this.stats.end(this.hook)},e.systemName="Stats",e}(e.System),f=p,d={Components:[s],Systems:[f]};return t.Stats=s,t.StatsSystem=f,t.default=d,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.stats=window.EVA.plugin.stats||_EVA_IIFE_stats;
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;