@eva/plugin-stats 1.2.7-fix.4 → 1.2.7-fix.6

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,5 +1,6 @@
1
1
  window.EVA = window.EVA || {};
2
2
  window.EVA.plugin = window.EVA.plugin || {};
3
+
3
4
  var _EVA_IIFE_stats = function (exports, eva_js) {
4
5
  'use strict';
5
6
 
@@ -13,39 +14,53 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
13
14
  if (b.hasOwnProperty(p)) d[p] = b[p];
14
15
  }
15
16
  };
17
+
16
18
  return _extendStatics(d, b);
17
19
  };
20
+
18
21
  function __extends(d, b) {
19
22
  _extendStatics(d, b);
23
+
20
24
  function __() {
21
25
  this.constructor = d;
22
26
  }
27
+
23
28
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24
29
  }
30
+
25
31
  var _assign = function __assign() {
26
32
  _assign = Object.assign || function __assign(t) {
27
33
  for (var s, i = 1, n = arguments.length; i < n; i++) {
28
34
  s = arguments[i];
35
+
29
36
  for (var p in s) {
30
37
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
31
38
  }
32
39
  }
40
+
33
41
  return t;
34
42
  };
43
+
35
44
  return _assign.apply(this, arguments);
36
45
  };
46
+
37
47
  var StatsComponent = function (_super) {
38
48
  __extends(StatsComponent, _super);
49
+
39
50
  function StatsComponent() {
40
51
  return _super !== null && _super.apply(this, arguments) || this;
41
52
  }
53
+
42
54
  StatsComponent.prototype.update = function () {
43
55
  this.stats && this.stats.begin();
44
56
  };
57
+
45
58
  StatsComponent.componentName = 'Stats';
46
59
  return StatsComponent;
47
60
  }(eva_js.Component);
61
+
48
62
  var Stats$2 = StatsComponent;
63
+
49
64
  var Stats = function Stats(style) {
50
65
  style = _assign({
51
66
  width: 20,
@@ -54,9 +69,9 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
54
69
  y: 0
55
70
  }, style);
56
71
  var width = style.width,
57
- height = style.height,
58
- x = style.x,
59
- y = style.y;
72
+ height = style.height,
73
+ x = style.x,
74
+ y = style.y;
60
75
  var mode = 0;
61
76
  var container = document.createElement('div');
62
77
  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;";
@@ -64,27 +79,33 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
64
79
  event.preventDefault();
65
80
  showPanel(++mode % container.children.length);
66
81
  }, false);
82
+
67
83
  function addPanel(panel) {
68
84
  container.appendChild(panel.dom);
69
85
  return panel;
70
86
  }
87
+
71
88
  function showPanel(id) {
72
89
  for (var i = 0; i < container.children.length; i++) {
73
90
  container.children[i].style.display = i === id ? 'block' : 'none';
74
91
  }
92
+
75
93
  mode = id;
76
94
  }
95
+
77
96
  var beginTime = (performance || Date).now(),
78
- prevTime = beginTime,
79
- frames = 0;
97
+ prevTime = beginTime,
98
+ frames = 0;
80
99
  var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
81
100
  var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
82
101
  var dcPanel = addPanel(Stats.Panel('DrawCall', '#330570', '#A69700'));
83
102
  var tcPanel = addPanel(Stats.Panel('TC:', '#A62500', '#00B454'));
84
103
  var memPanel;
104
+
85
105
  if (self.performance && self.performance.memory) {
86
106
  memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
87
107
  }
108
+
88
109
  showPanel(0);
89
110
  return {
90
111
  REVISION: 16,
@@ -98,19 +119,23 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
98
119
  frames++;
99
120
  var time = (performance || Date).now();
100
121
  msPanel.update(time - beginTime, 200);
122
+
101
123
  if (hook) {
102
124
  dcPanel.update(hook.deltaDrawCalls, Math.max(50, hook.maxDeltaDrawCalls));
103
125
  tcPanel.update(hook.texturesCount, Math.max(20, hook.maxTextureCount));
104
126
  }
127
+
105
128
  if (time >= prevTime + 1000) {
106
129
  fpsPanel.update(frames * 1000 / (time - prevTime), 100);
107
130
  prevTime = time;
108
131
  frames = 0;
132
+
109
133
  if (memPanel) {
110
134
  var memory = performance.memory;
111
135
  memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
112
136
  }
113
137
  }
138
+
114
139
  return time;
115
140
  },
116
141
  update: function update() {
@@ -120,19 +145,20 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
120
145
  setMode: showPanel
121
146
  };
122
147
  };
148
+
123
149
  Stats.Panel = function (name, fg, bg) {
124
150
  var min = Infinity,
125
- max = 0;
151
+ max = 0;
126
152
  var round = Math.round;
127
153
  var PR = round(window.devicePixelRatio || 1);
128
154
  var WIDTH = 80 * PR,
129
- HEIGHT = 48 * PR,
130
- TEXT_X = 3 * PR,
131
- TEXT_Y = 2 * PR,
132
- GRAPH_X = 3 * PR,
133
- GRAPH_Y = 15 * PR,
134
- GRAPH_WIDTH = 74 * PR,
135
- GRAPH_HEIGHT = 30 * PR;
155
+ HEIGHT = 48 * PR,
156
+ TEXT_X = 3 * PR,
157
+ TEXT_Y = 2 * PR,
158
+ GRAPH_X = 3 * PR,
159
+ GRAPH_Y = 15 * PR,
160
+ GRAPH_WIDTH = 74 * PR,
161
+ GRAPH_HEIGHT = 30 * PR;
136
162
  var canvas = document.createElement('canvas');
137
163
  canvas.width = WIDTH;
138
164
  canvas.height = HEIGHT;
@@ -166,12 +192,16 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
166
192
  }
167
193
  };
168
194
  };
195
+
169
196
  var Stats$1 = Stats;
197
+
170
198
  var GLHook = function () {
171
199
  function GLHook(_gl) {
172
200
  this.drawPasses = 0;
173
201
  this.isInit = false;
202
+
174
203
  this.realGLDrawElements = function () {};
204
+
175
205
  if (_gl) {
176
206
  if (_gl.__proto__.drawElements) {
177
207
  this.gl = _gl;
@@ -183,28 +213,37 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
183
213
  console.error("[GLHook] GL can't be NULL");
184
214
  }
185
215
  }
216
+
186
217
  GLHook.prototype.fakeGLdrawElements = function (mode, count, type, offset) {
187
218
  this.drawPasses++;
188
219
  this.realGLDrawElements.call(this.gl, mode, count, type, offset);
189
220
  };
221
+
190
222
  GLHook.prototype.reset = function () {
191
223
  this.drawPasses = 0;
192
224
  };
225
+
193
226
  GLHook.prototype.release = function () {
194
227
  if (this.isInit) {
195
228
  this.gl.__proto__.drawElements = this.realGLDrawElements;
196
229
  }
230
+
197
231
  this.isInit = false;
198
232
  };
233
+
199
234
  return GLHook;
200
235
  }();
236
+
201
237
  var TextureHook = function () {
202
238
  function TextureHook(_gl) {
203
239
  this.createdTextures = new Array();
204
240
  this.maxTexturesCount = 0;
205
241
  this.isInit = false;
242
+
206
243
  this.realGLCreateTexture = function () {};
244
+
207
245
  this.realGLDeleteTexture = function () {};
246
+
208
247
  if (_gl) {
209
248
  if (_gl.__proto__.createTexture) {
210
249
  this.gl = _gl;
@@ -218,6 +257,7 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
218
257
  console.error("[TextureHook] GL can't be NULL");
219
258
  }
220
259
  }
260
+
221
261
  Object.defineProperty(TextureHook.prototype, "currentTextureCount", {
222
262
  get: function get() {
223
263
  return this.createdTextures.length;
@@ -225,50 +265,63 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
225
265
  enumerable: false,
226
266
  configurable: true
227
267
  });
268
+
228
269
  TextureHook.prototype.registerTexture = function (texture) {
229
270
  this.createdTextures.push(texture);
230
271
  this.maxTexturesCount = Math.max(this.createdTextures.length, this.maxTexturesCount);
231
272
  };
273
+
232
274
  TextureHook.prototype.fakeGLCreateTexture = function () {
233
275
  var texture = this.realGLCreateTexture.call(this.gl);
234
276
  this.registerTexture(texture);
235
277
  return texture;
236
278
  };
279
+
237
280
  TextureHook.prototype.fakeGLDeleteTexture = function (texture) {
238
281
  var index = this.createdTextures.indexOf(texture);
282
+
239
283
  if (index > -1) {
240
284
  this.createdTextures.splice(index, 1);
241
285
  }
286
+
242
287
  this.realGLDeleteTexture.call(this.gl, texture);
243
288
  };
289
+
244
290
  TextureHook.prototype.reset = function () {
245
291
  this.createdTextures = new Array();
246
292
  this.maxTexturesCount = 0;
247
293
  };
294
+
248
295
  TextureHook.prototype.release = function () {
249
296
  if (this.isInit) {
250
297
  this.gl.__proto__.createTexture = this.realGLCreateTexture;
251
298
  this.gl.__proto__.deleteTexture = this.realGLDeleteTexture;
252
299
  console.log('[TextureHook] Hook was removed!');
253
300
  }
301
+
254
302
  this.isInit = false;
255
303
  };
304
+
256
305
  return TextureHook;
257
306
  }();
307
+
258
308
  var BaseHooks = function () {
259
309
  function BaseHooks() {
260
310
  this._drawCalls = -1;
261
311
  this._maxDeltaDrawCalls = -1;
262
312
  }
313
+
263
314
  BaseHooks.prototype.attach = function (gl) {
264
315
  this.glhook = new GLHook(gl);
265
316
  this.texturehook = new TextureHook(gl);
266
317
  };
318
+
267
319
  Object.defineProperty(BaseHooks.prototype, "drawCalls", {
268
320
  get: function get() {
269
321
  if (this.glhook && this.glhook.isInit) {
270
322
  return this.glhook.drawPasses;
271
323
  }
324
+
272
325
  return -1;
273
326
  },
274
327
  enumerable: false,
@@ -287,6 +340,7 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
287
340
  this._drawCalls = this.drawCalls;
288
341
  return 0;
289
342
  }
343
+
290
344
  var dc = this.drawCalls;
291
345
  var delta = dc - this._drawCalls;
292
346
  this._drawCalls = dc;
@@ -312,41 +366,51 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
312
366
  enumerable: false,
313
367
  configurable: true
314
368
  });
369
+
315
370
  BaseHooks.prototype.reset = function () {
316
371
  this._maxDeltaDrawCalls = -1;
317
372
  this._drawCalls = -1;
318
373
  if (this.glhook) this.glhook.reset();
319
374
  if (this.texturehook) this.texturehook.reset();
320
375
  };
376
+
321
377
  BaseHooks.prototype.release = function () {
322
378
  if (this.glhook) this.glhook.release();
323
379
  if (this.texturehook) this.texturehook.release();
324
380
  };
381
+
325
382
  return BaseHooks;
326
383
  }();
384
+
327
385
  var StatsSystem = function (_super) {
328
386
  __extends(StatsSystem, _super);
387
+
329
388
  function StatsSystem() {
330
389
  var _this = _super !== null && _super.apply(this, arguments) || this;
390
+
331
391
  _this.show = true;
332
392
  return _this;
333
393
  }
394
+
334
395
  StatsSystem.prototype.init = function (param) {
335
396
  if (param === void 0) {
336
397
  param = {
337
398
  show: true
338
399
  };
339
400
  }
401
+
340
402
  this.show = param.show;
341
403
  this.style = param.style;
342
404
  this.renderSystem = this.game.getSystem('Renderer');
343
405
  this.app = this.renderSystem.application;
406
+
344
407
  if (this.app && this.show) {
345
408
  var gl = this.app.renderer.gl;
346
409
  this.hook = new BaseHooks();
347
410
  this.hook.attach(gl);
348
411
  }
349
412
  };
413
+
350
414
  StatsSystem.prototype.start = function () {
351
415
  if (!this.show) return;
352
416
  this.component = this.game.scene.addComponent(new Stats$2());
@@ -355,13 +419,16 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
355
419
  this.stats.showPanel(0);
356
420
  document.body.appendChild(this.stats.dom);
357
421
  };
422
+
358
423
  StatsSystem.prototype.lateUpdate = function () {
359
424
  if (!this.show) return;
360
425
  this.stats && this.stats.end(this.hook);
361
426
  };
427
+
362
428
  StatsSystem.systemName = 'Stats';
363
429
  return StatsSystem;
364
430
  }(eva_js.System);
431
+
365
432
  var StatsSystem$1 = StatsSystem;
366
433
  var index = {
367
434
  Components: [Stats$2],
@@ -369,10 +436,11 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
369
436
  };
370
437
  exports.Stats = Stats$2;
371
438
  exports.StatsSystem = StatsSystem$1;
372
- exports["default"] = index;
439
+ exports['default'] = index;
373
440
  Object.defineProperty(exports, '__esModule', {
374
441
  value: true
375
442
  });
376
443
  return exports;
377
444
  }({}, EVA);
445
+
378
446
  window.EVA.plugin.stats = window.EVA.plugin.stats || _EVA_IIFE_stats;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EVA.plugin.stats.js","sources":["../../../node_modules/tslib/tslib.es6.js","../lib/StatsComponent.ts","../lib/Stats.ts","../lib/StatsSystem.ts","../lib/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { Component } from '@eva/eva.js';\n\nexport default class StatsComponent extends Component {\n static componentName: string = 'Stats';\n stats;\n\n update() {\n this.stats && this.stats.begin();\n }\n}\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst Stats = function (style) {\n style = { ...{ width: 20, height: 12, x: 0, y: 0 }, ...style };\n const { width, height, x, y } = style;\n let mode = 0;\n\n const container = document.createElement('div');\n 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;`;\n container.addEventListener(\n 'click',\n function (event) {\n event.preventDefault();\n showPanel(++mode % container.children.length);\n },\n false,\n );\n\n function addPanel(panel) {\n container.appendChild(panel.dom);\n return panel;\n }\n\n function showPanel(id) {\n for (let i = 0; i < container.children.length; i++) {\n // @ts-ignore\n container.children[i].style.display = i === id ? 'block' : 'none';\n }\n\n mode = id;\n }\n\n let beginTime = (performance || Date).now(),\n prevTime = beginTime,\n frames = 0;\n\n const fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));\n const msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));\n let memPanel;\n // @ts-ignore\n if (self.performance && self.performance.memory) {\n memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));\n }\n\n showPanel(0);\n\n return {\n REVISION: 16,\n\n dom: container,\n\n addPanel: addPanel,\n showPanel: showPanel,\n\n begin: function (time) {\n beginTime = time || (performance || Date).now();\n },\n\n end: function () {\n frames++;\n\n const time = (performance || Date).now();\n\n msPanel.update(time - beginTime, 200);\n\n if (time >= prevTime + 1000) {\n fpsPanel.update((frames * 1000) / (time - prevTime), 100);\n\n prevTime = time;\n frames = 0;\n\n if (memPanel) {\n // @ts-ignore\n const memory = performance.memory;\n memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);\n }\n }\n\n return time;\n },\n\n update: function () {\n beginTime = this.end();\n },\n\n // Backwards Compatibility\n\n domElement: container,\n setMode: showPanel,\n };\n};\n\nStats.Panel = function (name, fg, bg) {\n let min = Infinity,\n max = 0;\n const round = Math.round;\n const PR = round(window.devicePixelRatio || 1);\n\n const WIDTH = 80 * PR,\n HEIGHT = 48 * PR,\n TEXT_X = 3 * PR,\n TEXT_Y = 2 * PR,\n GRAPH_X = 3 * PR,\n GRAPH_Y = 15 * PR,\n GRAPH_WIDTH = 74 * PR,\n GRAPH_HEIGHT = 30 * PR;\n\n const canvas = document.createElement('canvas');\n canvas.width = WIDTH;\n canvas.height = HEIGHT;\n canvas.style.cssText = 'width:100%;height:100%';\n\n const context = canvas.getContext('2d');\n context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';\n context.textBaseline = 'top';\n\n context.fillStyle = bg;\n context.fillRect(0, 0, WIDTH, HEIGHT);\n\n context.fillStyle = fg;\n context.fillText(name, TEXT_X, TEXT_Y);\n context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);\n\n context.fillStyle = bg;\n context.globalAlpha = 0.9;\n context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);\n\n return {\n dom: canvas,\n\n update: function (value, maxValue) {\n min = Math.min(min, value);\n max = Math.max(max, value);\n\n context.fillStyle = bg;\n context.globalAlpha = 1;\n context.fillRect(0, 0, WIDTH, GRAPH_Y);\n context.fillStyle = fg;\n context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);\n\n context.drawImage(\n canvas,\n GRAPH_X + PR,\n GRAPH_Y,\n GRAPH_WIDTH - PR,\n GRAPH_HEIGHT,\n GRAPH_X,\n GRAPH_Y,\n GRAPH_WIDTH - PR,\n GRAPH_HEIGHT,\n );\n\n context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);\n\n context.fillStyle = bg;\n context.globalAlpha = 0.9;\n context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));\n },\n };\n};\n\nexport default Stats;\n","import { System } from '@eva/eva.js';\nimport StatsComponent from './StatsComponent';\nimport Stats from './Stats';\n\ninterface StatsParams {\n show?: boolean;\n style?: {\n width: number;\n height: number;\n x: number;\n y: number;\n };\n}\n\nexport default class StatsSystem extends System {\n static systemName = 'Stats';\n show: boolean = true;\n stats;\n style;\n component: StatsComponent;\n init(param: StatsParams = { show: true }) {\n this.show = param.show;\n this.style = param.style;\n }\n start() {\n if (!this.show) return;\n this.component = this.game.scene.addComponent(new StatsComponent());\n this.stats = Stats(this.style);\n this.component.stats = this.stats;\n this.stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom\n document.body.appendChild(this.stats.dom);\n }\n lateUpdate() {\n if (!this.show) return;\n this.stats && this.stats.end();\n }\n}\n","import Stats from './StatsComponent';\nimport StatsSystem from './StatsSystem';\n\nexport default {\n Components: [Stats],\n Systems: [StatsSystem],\n};\n\nexport { Stats, StatsSystem };\n"],"names":["Component","StatsComponent","Stats","System","StatsSystem"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACA;IACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;IACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;IACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;IACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC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AAC,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SAC3C;QACD,gCAAU,GAAV;YACE,IAAI,CAAC,IAAI,CAAC,IAAI;gBAAE,OAAO;YACvB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;SAChC;QApBM,sBAAU,GAAG,OAAO,CAAC;QAqB9B,kBAAC;KAAA,CAtBwCC,aAAM,GAsB9C;wBAtBoB,WAAW;;ACXhC,gBAAe;QACb,UAAU,EAAE,CAACD,OAAK,CAAC;QACnB,OAAO,EAAE,CAACE,aAAW,CAAC;KACvB;;;;;;;;;;;;"}
@@ -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(e){var r=(e=n({width:20,height:12,x:0,y:0},e)).width,o=e.height,i=e.x,s=e.y,a=0,l=document.createElement("div");function h(t){return l.appendChild(t.dom),t}function u(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";a=t}l.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: "+r+"vw;height: "+o+"vw;left: "+i+"vw;top: "+s+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),u(++a%l.children.length)}),!1);var c,p=(performance||Date).now(),f=p,d=0,x=h(t.Panel("FPS","#0ff","#002")),w=h(t.Panel("MS","#0f0","#020")),m=h(t.Panel("DrawCall","#330570","#A69700")),_=h(t.Panel("TC:","#A62500","#00B454"));return self.performance&&self.performance.memory&&(c=h(t.Panel("MB","#f08","#201"))),u(0),{REVISION:16,dom:l,addPanel:h,showPanel:u,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:u}};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,h=3*s,u=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,h,u),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)+")",h,u),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,h=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.bind(this),this.isInit=!0):console.error("[GLHook] GL can't be NULL")}return t.prototype.fakeGLdrawElements=function(t,e,r,o){this.drawPasses++,this.realGLDrawElements.call(this.gl,t,e,r,o)},t.prototype.reset=function(){this.drawPasses=0},t.prototype.release=function(){this.isInit&&(this.gl.__proto__.drawElements=this.realGLDrawElements),this.isInit=!1},t}(),u=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.bind(this),t.__proto__.deleteTexture=this.fakeGLDeleteTexture.bind(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(){var t=this.realGLCreateTexture.call(this.gl);return this.registerTexture(t),t},t.prototype.fakeGLDeleteTexture=function(t){var e=this.createdTextures.indexOf(t);e>-1&&this.createdTextures.splice(e,1),this.realGLDeleteTexture.call(this.gl,t)},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 h(t),this.texturehook=new u(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
+ 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])})(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}).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=function t(e){var r=(e=n({width:20,height:12,x:0,y:0},e)).width,o=e.height,i=e.x,s=e.y,a=0,l=document.createElement("div");function h(t){return l.appendChild(t.dom),t}function u(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";a=t}l.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: "+r+"vw;height: "+o+"vw;left: "+i+"vw;top: "+s+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),u(++a%l.children.length)}),!1);var c,p=(performance||Date).now(),f=p,d=0,x=h(t.Panel("FPS","#0ff","#002")),w=h(t.Panel("MS","#0f0","#020")),m=h(t.Panel("DrawCall","#330570","#A69700")),_=h(t.Panel("TC:","#A62500","#00B454"));return self.performance&&self.performance.memory&&(c=h(t.Panel("MB","#f08","#201"))),u(0),{REVISION:16,dom:l,addPanel:h,showPanel:u,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:u}};s.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,h=3*s,u=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,h,u),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)+")",h,u),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 a=s,l=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.bind(this),this.isInit=!0):console.error("[GLHook] GL can't be NULL")}return t.prototype.fakeGLdrawElements=function(t,e,r,o){this.drawPasses++,this.realGLDrawElements.call(this.gl,t,e,r,o)},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.bind(this),t.__proto__.deleteTexture=this.fakeGLDeleteTexture.bind(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(){var t=this.realGLCreateTexture.call(this.gl);return this.registerTexture(t),t},t.prototype.fakeGLDeleteTexture=function(t){var e=this.createdTextures.indexOf(t);e>-1&&this.createdTextures.splice(e,1),this.realGLDeleteTexture.call(this.gl,t)},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}(),u=function(){function t(){this._drawCalls=-1,this._maxDeltaDrawCalls=-1}return t.prototype.attach=function(t){this.glhook=new l(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}(),c=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 u,this.hook.attach(e)}},e.prototype.start=function(){this.show&&(this.component=this.game.scene.addComponent(new i),this.stats=a(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),p={Components:[i],Systems:[c]};return t.Stats=i,t.StatsSystem=c,t.default=p,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);window.EVA.plugin.stats=window.EVA.plugin.stats||_EVA_IIFE_stats;
@@ -1,18 +1,24 @@
1
1
  import { __extends, __assign } from 'tslib';
2
2
  import { Component, System } from '@eva/eva.js/dist/miniprogram';
3
3
  import { documentAlias, performance, windowAlias } from '@eva/miniprogram-adapter';
4
+
4
5
  var StatsComponent = function (_super) {
5
6
  __extends(StatsComponent, _super);
7
+
6
8
  function StatsComponent() {
7
9
  return _super !== null && _super.apply(this, arguments) || this;
8
10
  }
11
+
9
12
  StatsComponent.prototype.update = function () {
10
13
  this.stats && this.stats.begin();
11
14
  };
15
+
12
16
  StatsComponent.componentName = 'Stats';
13
17
  return StatsComponent;
14
18
  }(Component);
19
+
15
20
  var Stats$2 = StatsComponent;
21
+
16
22
  var Stats = function Stats(style) {
17
23
  style = __assign({
18
24
  width: 20,
@@ -21,9 +27,9 @@ var Stats = function Stats(style) {
21
27
  y: 0
22
28
  }, style);
23
29
  var width = style.width,
24
- height = style.height,
25
- x = style.x,
26
- y = style.y;
30
+ height = style.height,
31
+ x = style.x,
32
+ y = style.y;
27
33
  var mode = 0;
28
34
  var container = documentAlias.createElement('div');
29
35
  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;";
@@ -31,27 +37,33 @@ var Stats = function Stats(style) {
31
37
  event.preventDefault();
32
38
  showPanel(++mode % container.children.length);
33
39
  }, false);
40
+
34
41
  function addPanel(panel) {
35
42
  container.appendChild(panel.dom);
36
43
  return panel;
37
44
  }
45
+
38
46
  function showPanel(id) {
39
47
  for (var i = 0; i < container.children.length; i++) {
40
48
  container.children[i].style.display = i === id ? 'block' : 'none';
41
49
  }
50
+
42
51
  mode = id;
43
52
  }
53
+
44
54
  var beginTime = (performance || Date).now(),
45
- prevTime = beginTime,
46
- frames = 0;
55
+ prevTime = beginTime,
56
+ frames = 0;
47
57
  var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
48
58
  var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
49
59
  var dcPanel = addPanel(Stats.Panel('DrawCall', '#330570', '#A69700'));
50
60
  var tcPanel = addPanel(Stats.Panel('TC:', '#A62500', '#00B454'));
51
61
  var memPanel;
62
+
52
63
  if (self.performance && self.performance.memory) {
53
64
  memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
54
65
  }
66
+
55
67
  showPanel(0);
56
68
  return {
57
69
  REVISION: 16,
@@ -65,19 +77,23 @@ var Stats = function Stats(style) {
65
77
  frames++;
66
78
  var time = (performance || Date).now();
67
79
  msPanel.update(time - beginTime, 200);
80
+
68
81
  if (hook) {
69
82
  dcPanel.update(hook.deltaDrawCalls, Math.max(50, hook.maxDeltaDrawCalls));
70
83
  tcPanel.update(hook.texturesCount, Math.max(20, hook.maxTextureCount));
71
84
  }
85
+
72
86
  if (time >= prevTime + 1000) {
73
87
  fpsPanel.update(frames * 1000 / (time - prevTime), 100);
74
88
  prevTime = time;
75
89
  frames = 0;
90
+
76
91
  if (memPanel) {
77
92
  var memory = performance.memory;
78
93
  memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
79
94
  }
80
95
  }
96
+
81
97
  return time;
82
98
  },
83
99
  update: function update() {
@@ -87,19 +103,20 @@ var Stats = function Stats(style) {
87
103
  setMode: showPanel
88
104
  };
89
105
  };
106
+
90
107
  Stats.Panel = function (name, fg, bg) {
91
108
  var min = Infinity,
92
- max = 0;
109
+ max = 0;
93
110
  var round = Math.round;
94
111
  var PR = round(windowAlias.devicePixelRatio || 1);
95
112
  var WIDTH = 80 * PR,
96
- HEIGHT = 48 * PR,
97
- TEXT_X = 3 * PR,
98
- TEXT_Y = 2 * PR,
99
- GRAPH_X = 3 * PR,
100
- GRAPH_Y = 15 * PR,
101
- GRAPH_WIDTH = 74 * PR,
102
- GRAPH_HEIGHT = 30 * PR;
113
+ HEIGHT = 48 * PR,
114
+ TEXT_X = 3 * PR,
115
+ TEXT_Y = 2 * PR,
116
+ GRAPH_X = 3 * PR,
117
+ GRAPH_Y = 15 * PR,
118
+ GRAPH_WIDTH = 74 * PR,
119
+ GRAPH_HEIGHT = 30 * PR;
103
120
  var canvas = documentAlias.createElement('canvas');
104
121
  canvas.width = WIDTH;
105
122
  canvas.height = HEIGHT;
@@ -133,12 +150,16 @@ Stats.Panel = function (name, fg, bg) {
133
150
  }
134
151
  };
135
152
  };
153
+
136
154
  var Stats$1 = Stats;
155
+
137
156
  var GLHook = function () {
138
157
  function GLHook(_gl) {
139
158
  this.drawPasses = 0;
140
159
  this.isInit = false;
160
+
141
161
  this.realGLDrawElements = function () {};
162
+
142
163
  if (_gl) {
143
164
  if (_gl.__proto__.drawElements) {
144
165
  this.gl = _gl;
@@ -150,28 +171,37 @@ var GLHook = function () {
150
171
  console.error("[GLHook] GL can't be NULL");
151
172
  }
152
173
  }
174
+
153
175
  GLHook.prototype.fakeGLdrawElements = function (mode, count, type, offset) {
154
176
  this.drawPasses++;
155
177
  this.realGLDrawElements.call(this.gl, mode, count, type, offset);
156
178
  };
179
+
157
180
  GLHook.prototype.reset = function () {
158
181
  this.drawPasses = 0;
159
182
  };
183
+
160
184
  GLHook.prototype.release = function () {
161
185
  if (this.isInit) {
162
186
  this.gl.__proto__.drawElements = this.realGLDrawElements;
163
187
  }
188
+
164
189
  this.isInit = false;
165
190
  };
191
+
166
192
  return GLHook;
167
193
  }();
194
+
168
195
  var TextureHook = function () {
169
196
  function TextureHook(_gl) {
170
197
  this.createdTextures = new Array();
171
198
  this.maxTexturesCount = 0;
172
199
  this.isInit = false;
200
+
173
201
  this.realGLCreateTexture = function () {};
202
+
174
203
  this.realGLDeleteTexture = function () {};
204
+
175
205
  if (_gl) {
176
206
  if (_gl.__proto__.createTexture) {
177
207
  this.gl = _gl;
@@ -185,6 +215,7 @@ var TextureHook = function () {
185
215
  console.error("[TextureHook] GL can't be NULL");
186
216
  }
187
217
  }
218
+
188
219
  Object.defineProperty(TextureHook.prototype, "currentTextureCount", {
189
220
  get: function get() {
190
221
  return this.createdTextures.length;
@@ -192,50 +223,63 @@ var TextureHook = function () {
192
223
  enumerable: false,
193
224
  configurable: true
194
225
  });
226
+
195
227
  TextureHook.prototype.registerTexture = function (texture) {
196
228
  this.createdTextures.push(texture);
197
229
  this.maxTexturesCount = Math.max(this.createdTextures.length, this.maxTexturesCount);
198
230
  };
231
+
199
232
  TextureHook.prototype.fakeGLCreateTexture = function () {
200
233
  var texture = this.realGLCreateTexture.call(this.gl);
201
234
  this.registerTexture(texture);
202
235
  return texture;
203
236
  };
237
+
204
238
  TextureHook.prototype.fakeGLDeleteTexture = function (texture) {
205
239
  var index = this.createdTextures.indexOf(texture);
240
+
206
241
  if (index > -1) {
207
242
  this.createdTextures.splice(index, 1);
208
243
  }
244
+
209
245
  this.realGLDeleteTexture.call(this.gl, texture);
210
246
  };
247
+
211
248
  TextureHook.prototype.reset = function () {
212
249
  this.createdTextures = new Array();
213
250
  this.maxTexturesCount = 0;
214
251
  };
252
+
215
253
  TextureHook.prototype.release = function () {
216
254
  if (this.isInit) {
217
255
  this.gl.__proto__.createTexture = this.realGLCreateTexture;
218
256
  this.gl.__proto__.deleteTexture = this.realGLDeleteTexture;
219
257
  console.log('[TextureHook] Hook was removed!');
220
258
  }
259
+
221
260
  this.isInit = false;
222
261
  };
262
+
223
263
  return TextureHook;
224
264
  }();
265
+
225
266
  var BaseHooks = function () {
226
267
  function BaseHooks() {
227
268
  this._drawCalls = -1;
228
269
  this._maxDeltaDrawCalls = -1;
229
270
  }
271
+
230
272
  BaseHooks.prototype.attach = function (gl) {
231
273
  this.glhook = new GLHook(gl);
232
274
  this.texturehook = new TextureHook(gl);
233
275
  };
276
+
234
277
  Object.defineProperty(BaseHooks.prototype, "drawCalls", {
235
278
  get: function get() {
236
279
  if (this.glhook && this.glhook.isInit) {
237
280
  return this.glhook.drawPasses;
238
281
  }
282
+
239
283
  return -1;
240
284
  },
241
285
  enumerable: false,
@@ -254,6 +298,7 @@ var BaseHooks = function () {
254
298
  this._drawCalls = this.drawCalls;
255
299
  return 0;
256
300
  }
301
+
257
302
  var dc = this.drawCalls;
258
303
  var delta = dc - this._drawCalls;
259
304
  this._drawCalls = dc;
@@ -279,41 +324,51 @@ var BaseHooks = function () {
279
324
  enumerable: false,
280
325
  configurable: true
281
326
  });
327
+
282
328
  BaseHooks.prototype.reset = function () {
283
329
  this._maxDeltaDrawCalls = -1;
284
330
  this._drawCalls = -1;
285
331
  if (this.glhook) this.glhook.reset();
286
332
  if (this.texturehook) this.texturehook.reset();
287
333
  };
334
+
288
335
  BaseHooks.prototype.release = function () {
289
336
  if (this.glhook) this.glhook.release();
290
337
  if (this.texturehook) this.texturehook.release();
291
338
  };
339
+
292
340
  return BaseHooks;
293
341
  }();
342
+
294
343
  var StatsSystem = function (_super) {
295
344
  __extends(StatsSystem, _super);
345
+
296
346
  function StatsSystem() {
297
347
  var _this = _super !== null && _super.apply(this, arguments) || this;
348
+
298
349
  _this.show = true;
299
350
  return _this;
300
351
  }
352
+
301
353
  StatsSystem.prototype.init = function (param) {
302
354
  if (param === void 0) {
303
355
  param = {
304
356
  show: true
305
357
  };
306
358
  }
359
+
307
360
  this.show = param.show;
308
361
  this.style = param.style;
309
362
  this.renderSystem = this.game.getSystem('Renderer');
310
363
  this.app = this.renderSystem.application;
364
+
311
365
  if (this.app && this.show) {
312
366
  var gl = this.app.renderer.gl;
313
367
  this.hook = new BaseHooks();
314
368
  this.hook.attach(gl);
315
369
  }
316
370
  };
371
+
317
372
  StatsSystem.prototype.start = function () {
318
373
  if (!this.show) return;
319
374
  this.component = this.game.scene.addComponent(new Stats$2());
@@ -322,13 +377,16 @@ var StatsSystem = function (_super) {
322
377
  this.stats.showPanel(0);
323
378
  documentAlias.body.appendChild(this.stats.dom);
324
379
  };
380
+
325
381
  StatsSystem.prototype.lateUpdate = function () {
326
382
  if (!this.show) return;
327
383
  this.stats && this.stats.end(this.hook);
328
384
  };
385
+
329
386
  StatsSystem.systemName = 'Stats';
330
387
  return StatsSystem;
331
388
  }(System);
389
+
332
390
  var StatsSystem$1 = StatsSystem;
333
391
  var index = {
334
392
  Components: [Stats$2],
@@ -374,4 +374,4 @@ var index = {
374
374
 
375
375
  exports.Stats = Stats$2;
376
376
  exports.StatsSystem = StatsSystem$1;
377
- exports["default"] = index;
377
+ exports['default'] = index;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-stats.cjs.js","sources":["../lib/StatsComponent.ts","../lib/Stats.ts","../lib/StatsSystem.ts","../lib/index.ts"],"sourcesContent":["import { Component } from '@eva/eva.js';\n\nexport default class StatsComponent extends Component {\n static componentName: string = 'Stats';\n stats;\n\n update() {\n this.stats && this.stats.begin();\n }\n}\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst Stats = function (style) {\n style = { ...{ width: 20, height: 12, x: 0, y: 0 }, ...style };\n const { width, height, x, y } = style;\n let mode = 0;\n\n const container = document.createElement('div');\n 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;`;\n container.addEventListener(\n 'click',\n function (event) {\n event.preventDefault();\n showPanel(++mode % container.children.length);\n },\n false,\n );\n\n function addPanel(panel) {\n container.appendChild(panel.dom);\n return panel;\n }\n\n function showPanel(id) {\n for (let i = 0; i < container.children.length; i++) {\n // @ts-ignore\n container.children[i].style.display = i === id ? 'block' : 'none';\n }\n\n mode = id;\n }\n\n let beginTime = (performance || Date).now(),\n prevTime = beginTime,\n frames = 0;\n\n const fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));\n const msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));\n let memPanel;\n // @ts-ignore\n if (self.performance && self.performance.memory) {\n memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));\n }\n\n showPanel(0);\n\n return {\n REVISION: 16,\n\n dom: container,\n\n addPanel: addPanel,\n showPanel: showPanel,\n\n begin: function (time) {\n beginTime = time || (performance || Date).now();\n },\n\n end: function () {\n frames++;\n\n const time = (performance || Date).now();\n\n msPanel.update(time - beginTime, 200);\n\n if (time >= prevTime + 1000) {\n fpsPanel.update((frames * 1000) / (time - prevTime), 100);\n\n prevTime = time;\n frames = 0;\n\n if (memPanel) {\n // @ts-ignore\n const memory = performance.memory;\n memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);\n }\n }\n\n return time;\n },\n\n update: function () {\n beginTime = this.end();\n },\n\n // Backwards Compatibility\n\n domElement: container,\n setMode: showPanel,\n };\n};\n\nStats.Panel = function (name, fg, bg) {\n let min = Infinity,\n max = 0;\n const round = Math.round;\n const PR = round(window.devicePixelRatio || 1);\n\n const WIDTH = 80 * PR,\n HEIGHT = 48 * PR,\n TEXT_X = 3 * PR,\n TEXT_Y = 2 * PR,\n GRAPH_X = 3 * PR,\n GRAPH_Y = 15 * PR,\n GRAPH_WIDTH = 74 * PR,\n GRAPH_HEIGHT = 30 * PR;\n\n const canvas = document.createElement('canvas');\n canvas.width = WIDTH;\n canvas.height = HEIGHT;\n canvas.style.cssText = 'width:100%;height:100%';\n\n const context = canvas.getContext('2d');\n context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';\n context.textBaseline = 'top';\n\n context.fillStyle = bg;\n context.fillRect(0, 0, WIDTH, HEIGHT);\n\n context.fillStyle = fg;\n context.fillText(name, TEXT_X, TEXT_Y);\n context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);\n\n context.fillStyle = bg;\n context.globalAlpha = 0.9;\n context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);\n\n return {\n dom: canvas,\n\n update: function (value, maxValue) {\n min = Math.min(min, value);\n max = Math.max(max, value);\n\n context.fillStyle = bg;\n context.globalAlpha = 1;\n context.fillRect(0, 0, WIDTH, GRAPH_Y);\n context.fillStyle = fg;\n context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);\n\n context.drawImage(\n canvas,\n GRAPH_X + PR,\n GRAPH_Y,\n GRAPH_WIDTH - PR,\n GRAPH_HEIGHT,\n GRAPH_X,\n GRAPH_Y,\n GRAPH_WIDTH - PR,\n GRAPH_HEIGHT,\n );\n\n context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);\n\n context.fillStyle = bg;\n context.globalAlpha = 0.9;\n context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));\n },\n };\n};\n\nexport default Stats;\n","import { System } from '@eva/eva.js';\nimport StatsComponent from './StatsComponent';\nimport Stats from './Stats';\n\ninterface StatsParams {\n show?: boolean;\n style?: {\n width: number;\n height: number;\n x: number;\n y: number;\n };\n}\n\nexport default class StatsSystem extends System {\n static systemName = 'Stats';\n show: boolean = true;\n stats;\n style;\n component: StatsComponent;\n init(param: StatsParams = { show: true }) {\n this.show = param.show;\n this.style = param.style;\n }\n start() {\n if (!this.show) return;\n this.component = this.game.scene.addComponent(new StatsComponent());\n this.stats = Stats(this.style);\n this.component.stats = this.stats;\n this.stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom\n document.body.appendChild(this.stats.dom);\n }\n lateUpdate() {\n if (!this.show) return;\n this.stats && this.stats.end();\n }\n}\n","import Stats from './StatsComponent';\nimport StatsSystem from './StatsSystem';\n\nexport default {\n Components: [Stats],\n Systems: [StatsSystem],\n};\n\nexport { Stats, StatsSystem };\n"],"names":["Component","StatsComponent","Stats","System","StatsSystem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAA4C,kCAAS;IAArD;;KAOC;IAHC,+BAAM,GAAN;QACE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;KAClC;IALM,4BAAa,GAAW,OAAO,CAAC;IAMzC,qBAAC;CAAA,CAP2CA,gBAAS,GAOpD;cAPoB,cAAc;;ACEnC,IAAM,KAAK,GAAG,UAAU,KAAK;IAC3B,KAAK,YAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAK,KAAK,CAAE,CAAC;IACvD,IAAA,KAAK,GAAmB,KAAK,MAAxB,EAAE,MAAM,GAAW,KAAK,OAAhB,EAAE,CAAC,GAAQ,KAAK,EAAb,EAAE,CAAC,GAAK,KAAK,EAAV,CAAW;IACtC,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,IAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,iFAA+E,KAAK,mBAAc,MAAM,iBAAY,CAAC,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;AAEF,cAAe,KAAK;;ACrJpB;IAAyC,+BAAM;IAA/C;QAAA,qEAsBC;QApBC,UAAI,GAAY,IAAI,CAAC;;KAoBtB;IAhBC,0BAAI,GAAJ,UAAK,KAAmC;QAAnC,sBAAA,EAAA,UAAuB,IAAI,EAAE,IAAI,EAAE;QACtC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;KAC1B;IACD,2BAAK,GAAL;QACE,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAIC,OAAc,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,KAAK,GAAGC,OAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAC3C;IACD,gCAAU,GAAV;QACE,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QACvB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;KAChC;IApBM,sBAAU,GAAG,OAAO,CAAC;IAqB9B,kBAAC;CAAA,CAtBwCC,aAAM,GAsB9C;oBAtBoB,WAAW;;ACXhC,YAAe;IACb,UAAU,EAAE,CAACD,OAAK,CAAC;IACnB,OAAO,EAAE,CAACE,aAAW,CAAC;CACvB;;;;;;"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=function(t,r){return e=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])},e(t,r)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=function(t,r){return(e=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])})(t,r)};
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -12,4 +12,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */function r(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},o.apply(this,arguments)},s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.update=function(){this.stats&&this.stats.begin()},e.componentName="Stats",e}(t.Component),n=function(t){var e=(t=o({width:20,height:12,x:0,y:0},t)).width,r=t.height,s=t.x,i=t.y,a=0,l=document.createElement("div");function h(t){return l.appendChild(t.dom),t}function u(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";a=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: "+s+"vw;top: "+i+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),u(++a%l.children.length)}),!1);var c,p=(performance||Date).now(),f=p,d=0,x=h(n.Panel("FPS","#0ff","#002")),m=h(n.Panel("MS","#0f0","#020")),w=h(n.Panel("DrawCall","#330570","#A69700")),y=h(n.Panel("TC:","#A62500","#00B454"));return self.performance&&self.performance.memory&&(c=h(n.Panel("MB","#f08","#201"))),u(0),{REVISION:16,dom:l,addPanel:h,showPanel:u,begin:function(t){p=t||(performance||Date).now()},end:function(t){d++;var e=(performance||Date).now();if(m.update(e-p,200),t&&(w.update(t.deltaDrawCalls,Math.max(50,t.maxDeltaDrawCalls)),y.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:u}};n.Panel=function(t,e,r){var o=1/0,s=0,n=Math.round,i=n(window.devicePixelRatio||1),a=80*i,l=48*i,h=3*i,u=2*i,c=3*i,p=15*i,f=74*i,d=30*i,x=document.createElement("canvas");x.width=a,x.height=l,x.style.cssText="width:100%;height:100%";var m=x.getContext("2d");return m.font="bold "+9*i+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=r,m.fillRect(0,0,a,l),m.fillStyle=e,m.fillText(t,h,u),m.fillRect(c,p,f,d),m.fillStyle=r,m.globalAlpha=.9,m.fillRect(c,p,f,d),{dom:x,update:function(l,w){o=Math.min(o,l),s=Math.max(s,l),m.fillStyle=r,m.globalAlpha=1,m.fillRect(0,0,a,p),m.fillStyle=e,m.fillText(n(l)+" "+t+" ("+n(o)+"-"+n(s)+")",h,u),m.drawImage(x,c+i,p,f-i,d,c,p,f-i,d),m.fillRect(c+f-i,p,i,d),m.fillStyle=r,m.globalAlpha=.9,m.fillRect(c+f-i,p,i,n((1-l/w)*d))}}};var i=n,a=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.bind(this),this.isInit=!0):console.error("[GLHook] GL can't be NULL")}return t.prototype.fakeGLdrawElements=function(t,e,r,o){this.drawPasses++,this.realGLDrawElements.call(this.gl,t,e,r,o)},t.prototype.reset=function(){this.drawPasses=0},t.prototype.release=function(){this.isInit&&(this.gl.__proto__.drawElements=this.realGLDrawElements),this.isInit=!1},t}(),l=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.bind(this),t.__proto__.deleteTexture=this.fakeGLDeleteTexture.bind(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(){var t=this.realGLCreateTexture.call(this.gl);return this.registerTexture(t),t},t.prototype.fakeGLDeleteTexture=function(t){var e=this.createdTextures.indexOf(t);e>-1&&this.createdTextures.splice(e,1),this.realGLDeleteTexture.call(this.gl,t)},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}(),h=function(){function t(){this._drawCalls=-1,this._maxDeltaDrawCalls=-1}return t.prototype.attach=function(t){this.glhook=new a(t),this.texturehook=new l(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}(),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.show=!0,e}return r(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 h,this.hook.attach(e)}},e.prototype.start=function(){this.show&&(this.component=this.game.scene.addComponent(new s),this.stats=i(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}(t.System),c={Components:[s],Systems:[u]};exports.Stats=s,exports.StatsSystem=u,exports.default=c;
15
+ ***************************************************************************** */function r(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.update=function(){this.stats&&this.stats.begin()},e.componentName="Stats",e}(t.Component),n=function(t){var e=(t=o({width:20,height:12,x:0,y:0},t)).width,r=t.height,s=t.x,i=t.y,a=0,l=document.createElement("div");function h(t){return l.appendChild(t.dom),t}function u(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";a=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: "+s+"vw;top: "+i+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),u(++a%l.children.length)}),!1);var c,p=(performance||Date).now(),f=p,d=0,x=h(n.Panel("FPS","#0ff","#002")),m=h(n.Panel("MS","#0f0","#020")),w=h(n.Panel("DrawCall","#330570","#A69700")),y=h(n.Panel("TC:","#A62500","#00B454"));return self.performance&&self.performance.memory&&(c=h(n.Panel("MB","#f08","#201"))),u(0),{REVISION:16,dom:l,addPanel:h,showPanel:u,begin:function(t){p=t||(performance||Date).now()},end:function(t){d++;var e=(performance||Date).now();if(m.update(e-p,200),t&&(w.update(t.deltaDrawCalls,Math.max(50,t.maxDeltaDrawCalls)),y.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:u}};n.Panel=function(t,e,r){var o=1/0,s=0,n=Math.round,i=n(window.devicePixelRatio||1),a=80*i,l=48*i,h=3*i,u=2*i,c=3*i,p=15*i,f=74*i,d=30*i,x=document.createElement("canvas");x.width=a,x.height=l,x.style.cssText="width:100%;height:100%";var m=x.getContext("2d");return m.font="bold "+9*i+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=r,m.fillRect(0,0,a,l),m.fillStyle=e,m.fillText(t,h,u),m.fillRect(c,p,f,d),m.fillStyle=r,m.globalAlpha=.9,m.fillRect(c,p,f,d),{dom:x,update:function(l,w){o=Math.min(o,l),s=Math.max(s,l),m.fillStyle=r,m.globalAlpha=1,m.fillRect(0,0,a,p),m.fillStyle=e,m.fillText(n(l)+" "+t+" ("+n(o)+"-"+n(s)+")",h,u),m.drawImage(x,c+i,p,f-i,d,c,p,f-i,d),m.fillRect(c+f-i,p,i,d),m.fillStyle=r,m.globalAlpha=.9,m.fillRect(c+f-i,p,i,n((1-l/w)*d))}}};var i=n,a=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.bind(this),this.isInit=!0):console.error("[GLHook] GL can't be NULL")}return t.prototype.fakeGLdrawElements=function(t,e,r,o){this.drawPasses++,this.realGLDrawElements.call(this.gl,t,e,r,o)},t.prototype.reset=function(){this.drawPasses=0},t.prototype.release=function(){this.isInit&&(this.gl.__proto__.drawElements=this.realGLDrawElements),this.isInit=!1},t}(),l=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.bind(this),t.__proto__.deleteTexture=this.fakeGLDeleteTexture.bind(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(){var t=this.realGLCreateTexture.call(this.gl);return this.registerTexture(t),t},t.prototype.fakeGLDeleteTexture=function(t){var e=this.createdTextures.indexOf(t);e>-1&&this.createdTextures.splice(e,1),this.realGLDeleteTexture.call(this.gl,t)},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}(),h=function(){function t(){this._drawCalls=-1,this._maxDeltaDrawCalls=-1}return t.prototype.attach=function(t){this.glhook=new a(t),this.texturehook=new l(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}(),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.show=!0,e}return r(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 h,this.hook.attach(e)}},e.prototype.start=function(){this.show&&(this.component=this.game.scene.addComponent(new s),this.stats=i(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}(t.System),c={Components:[s],Systems:[u]};exports.Stats=s,exports.StatsSystem=u,exports.default=c;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-stats.esm.js","sources":["../lib/StatsComponent.ts","../lib/Stats.ts","../lib/StatsSystem.ts","../lib/index.ts"],"sourcesContent":["import { Component } from '@eva/eva.js';\n\nexport default class StatsComponent extends Component {\n static componentName: string = 'Stats';\n stats;\n\n update() {\n this.stats && this.stats.begin();\n }\n}\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst Stats = function (style) {\n style = { ...{ width: 20, height: 12, x: 0, y: 0 }, ...style };\n const { width, height, x, y } = style;\n let mode = 0;\n\n const container = document.createElement('div');\n 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;`;\n container.addEventListener(\n 'click',\n function (event) {\n event.preventDefault();\n showPanel(++mode % container.children.length);\n },\n false,\n );\n\n function addPanel(panel) {\n container.appendChild(panel.dom);\n return panel;\n }\n\n function showPanel(id) {\n for (let i = 0; i < container.children.length; i++) {\n // @ts-ignore\n container.children[i].style.display = i === id ? 'block' : 'none';\n }\n\n mode = id;\n }\n\n let beginTime = (performance || Date).now(),\n prevTime = beginTime,\n frames = 0;\n\n const fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));\n const msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));\n let memPanel;\n // @ts-ignore\n if (self.performance && self.performance.memory) {\n memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));\n }\n\n showPanel(0);\n\n return {\n REVISION: 16,\n\n dom: container,\n\n addPanel: addPanel,\n showPanel: showPanel,\n\n begin: function (time) {\n beginTime = time || (performance || Date).now();\n },\n\n end: function () {\n frames++;\n\n const time = (performance || Date).now();\n\n msPanel.update(time - beginTime, 200);\n\n if (time >= prevTime + 1000) {\n fpsPanel.update((frames * 1000) / (time - prevTime), 100);\n\n prevTime = time;\n frames = 0;\n\n if (memPanel) {\n // @ts-ignore\n const memory = performance.memory;\n memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);\n }\n }\n\n return time;\n },\n\n update: function () {\n beginTime = this.end();\n },\n\n // Backwards Compatibility\n\n domElement: container,\n setMode: showPanel,\n };\n};\n\nStats.Panel = function (name, fg, bg) {\n let min = Infinity,\n max = 0;\n const round = Math.round;\n const PR = round(window.devicePixelRatio || 1);\n\n const WIDTH = 80 * PR,\n HEIGHT = 48 * PR,\n TEXT_X = 3 * PR,\n TEXT_Y = 2 * PR,\n GRAPH_X = 3 * PR,\n GRAPH_Y = 15 * PR,\n GRAPH_WIDTH = 74 * PR,\n GRAPH_HEIGHT = 30 * PR;\n\n const canvas = document.createElement('canvas');\n canvas.width = WIDTH;\n canvas.height = HEIGHT;\n canvas.style.cssText = 'width:100%;height:100%';\n\n const context = canvas.getContext('2d');\n context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';\n context.textBaseline = 'top';\n\n context.fillStyle = bg;\n context.fillRect(0, 0, WIDTH, HEIGHT);\n\n context.fillStyle = fg;\n context.fillText(name, TEXT_X, TEXT_Y);\n context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);\n\n context.fillStyle = bg;\n context.globalAlpha = 0.9;\n context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);\n\n return {\n dom: canvas,\n\n update: function (value, maxValue) {\n min = Math.min(min, value);\n max = Math.max(max, value);\n\n context.fillStyle = bg;\n context.globalAlpha = 1;\n context.fillRect(0, 0, WIDTH, GRAPH_Y);\n context.fillStyle = fg;\n context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);\n\n context.drawImage(\n canvas,\n GRAPH_X + PR,\n GRAPH_Y,\n GRAPH_WIDTH - PR,\n GRAPH_HEIGHT,\n GRAPH_X,\n GRAPH_Y,\n GRAPH_WIDTH - PR,\n GRAPH_HEIGHT,\n );\n\n context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);\n\n context.fillStyle = bg;\n context.globalAlpha = 0.9;\n context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));\n },\n };\n};\n\nexport default Stats;\n","import { System } from '@eva/eva.js';\nimport StatsComponent from './StatsComponent';\nimport Stats from './Stats';\n\ninterface StatsParams {\n show?: boolean;\n style?: {\n width: number;\n height: number;\n x: number;\n y: number;\n };\n}\n\nexport default class StatsSystem extends System {\n static systemName = 'Stats';\n show: boolean = true;\n stats;\n style;\n component: StatsComponent;\n init(param: StatsParams = { show: true }) {\n this.show = param.show;\n this.style = param.style;\n }\n start() {\n if (!this.show) return;\n this.component = this.game.scene.addComponent(new StatsComponent());\n this.stats = Stats(this.style);\n this.component.stats = this.stats;\n this.stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom\n document.body.appendChild(this.stats.dom);\n }\n lateUpdate() {\n if (!this.show) return;\n this.stats && this.stats.end();\n }\n}\n","import Stats from './StatsComponent';\nimport StatsSystem from './StatsSystem';\n\nexport default {\n Components: [Stats],\n Systems: [StatsSystem],\n};\n\nexport { Stats, StatsSystem };\n"],"names":["StatsComponent","Stats","StatsSystem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAA4C,kCAAS;IAArD;;KAOC;IAHC,+BAAM,GAAN;QACE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;KAClC;IALM,4BAAa,GAAW,OAAO,CAAC;IAMzC,qBAAC;CAAA,CAP2C,SAAS,GAOpD;cAPoB,cAAc;;ACEnC,IAAM,KAAK,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CAAC,GAAG,CAAC,CAAC;KAC3C;IACD,gCAAU,GAAV;QACE,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QACvB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;KAChC;IApBM,sBAAU,GAAG,OAAO,CAAC;IAqB9B,kBAAC;CAAA,CAtBwC,MAAM,GAsB9C;oBAtBoB,WAAW;;ACXhC,YAAe;IACb,UAAU,EAAE,CAACA,OAAK,CAAC;IACnB,OAAO,EAAE,CAACC,aAAW,CAAC;CACvB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-stats",
3
- "version": "1.2.7-fix.4",
3
+ "version": "1.2.7-fix.6",
4
4
  "description": "@eva/plugin-stats",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-stats.esm.js",
@@ -18,7 +18,7 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "1.2.7-fix.4",
21
+ "@eva/eva.js": "1.2.7-fix.6",
22
22
  "lodash-es": "^4.17.21"
23
23
  }
24
24
  }