@eva/plugin-stats 1.1.1-fix.0 → 1.1.1-fix.1

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.
@@ -193,4 +193,4 @@ var index = {
193
193
 
194
194
  exports.Stats = Stats$2;
195
195
  exports.StatsSystem = StatsSystem$1;
196
- exports['default'] = index;
196
+ exports["default"] = index;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},e(t,n)};
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 n(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.update=function(){this.stats&&this.stats.begin()},e.componentName="Stats",e}(t.Component),s=function(t){var e=(t=o({width:20,height:12,x:0,y:0},t)).width,n=t.height,i=t.x,a=t.y,r=0,l=document.createElement("div");function c(t){return l.appendChild(t.dom),t}function p(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";r=t}l.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: "+e+"vw;height: "+n+"vw;left: "+i+"vw;top: "+a+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),p(++r%l.children.length)}),!1);var f,h=(performance||Date).now(),u=h,d=0,y=c(s.Panel("FPS","#0ff","#002")),m=c(s.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(f=c(s.Panel("MB","#f08","#201"))),p(0),{REVISION:16,dom:l,addPanel:c,showPanel:p,begin:function(t){h=t||(performance||Date).now()},end:function(){d++;var t=(performance||Date).now();if(m.update(t-h,200),t>=u+1e3&&(y.update(1e3*d/(t-u),100),u=t,d=0,f)){var e=performance.memory;f.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576)}return t},update:function(){h=this.end()},domElement:l,setMode:p}};s.Panel=function(t,e,n){var o=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),r=80*a,l=48*a,c=3*a,p=2*a,f=3*a,h=15*a,u=74*a,d=30*a,y=document.createElement("canvas");y.width=r,y.height=l,y.style.cssText="width:100%;height:100%";var m=y.getContext("2d");return m.font="bold "+9*a+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,r,l),m.fillStyle=e,m.fillText(t,c,p),m.fillRect(f,h,u,d),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(f,h,u,d),{dom:y,update:function(l,v){o=Math.min(o,l),i=Math.max(i,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,r,h),m.fillStyle=e,m.fillText(s(l)+" "+t+" ("+s(o)+"-"+s(i)+")",c,p),m.drawImage(y,f+a,h,u-a,d,f,h,u-a,d),m.fillRect(f+u-a,h,a,d),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(f+u-a,h,a,s((1-l/v)*d))}}};var a=s,r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.show=!0,e}return n(e,t),e.prototype.init=function(t){void 0===t&&(t={show:!0}),this.show=t.show,this.style=t.style},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()},e.systemName="Stats",e}(t.System),l={Components:[i],Systems:[r]};exports.Stats=i,exports.StatsSystem=r,exports.default=l;
15
+ ***************************************************************************** */function n(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)},i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.update=function(){this.stats&&this.stats.begin()},e.componentName="Stats",e}(t.Component),s=function(t){var e=(t=o({width:20,height:12,x:0,y:0},t)).width,n=t.height,i=t.x,a=t.y,r=0,l=document.createElement("div");function c(t){return l.appendChild(t.dom),t}function p(t){for(var e=0;e<l.children.length;e++)l.children[e].style.display=e===t?"block":"none";r=t}l.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: "+e+"vw;height: "+n+"vw;left: "+i+"vw;top: "+a+"vw;",l.addEventListener("click",(function(t){t.preventDefault(),p(++r%l.children.length)}),!1);var f,h=(performance||Date).now(),u=h,d=0,y=c(s.Panel("FPS","#0ff","#002")),m=c(s.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(f=c(s.Panel("MB","#f08","#201"))),p(0),{REVISION:16,dom:l,addPanel:c,showPanel:p,begin:function(t){h=t||(performance||Date).now()},end:function(){d++;var t=(performance||Date).now();if(m.update(t-h,200),t>=u+1e3&&(y.update(1e3*d/(t-u),100),u=t,d=0,f)){var e=performance.memory;f.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576)}return t},update:function(){h=this.end()},domElement:l,setMode:p}};s.Panel=function(t,e,n){var o=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),r=80*a,l=48*a,c=3*a,p=2*a,f=3*a,h=15*a,u=74*a,d=30*a,y=document.createElement("canvas");y.width=r,y.height=l,y.style.cssText="width:100%;height:100%";var m=y.getContext("2d");return m.font="bold "+9*a+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,r,l),m.fillStyle=e,m.fillText(t,c,p),m.fillRect(f,h,u,d),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(f,h,u,d),{dom:y,update:function(l,v){o=Math.min(o,l),i=Math.max(i,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,r,h),m.fillStyle=e,m.fillText(s(l)+" "+t+" ("+s(o)+"-"+s(i)+")",c,p),m.drawImage(y,f+a,h,u-a,d,f,h,u-a,d),m.fillRect(f+u-a,h,a,d),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(f+u-a,h,a,s((1-l/v)*d))}}};var a=s,r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.show=!0,e}return n(e,t),e.prototype.init=function(t){void 0===t&&(t={show:!0}),this.show=t.show,this.style=t.style},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()},e.systemName="Stats",e}(t.System),l={Components:[i],Systems:[r]};exports.Stats=i,exports.StatsSystem=r,exports.default=l;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-stats",
3
- "version": "1.1.1-fix.0",
3
+ "version": "1.1.1-fix.1",
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.1.1-fix.0",
21
+ "@eva/eva.js": "1.1.1-fix.1",
22
22
  "lodash-es": "^4.17.21"
23
23
  }
24
24
  }
@@ -1,200 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@eva/eva.js')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@eva/eva.js'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.EVA = global.EVA || {}, global.EVA.plugin = global.EVA.plugin || {}, global.EVA.plugin.stats = {}), global.EVA));
5
- }(this, (function (exports, eva_js) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
-
23
- var extendStatics = function(d, b) {
24
- extendStatics = Object.setPrototypeOf ||
25
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27
- return extendStatics(d, b);
28
- };
29
-
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
-
36
- var __assign = function() {
37
- __assign = Object.assign || function __assign(t) {
38
- for (var s, i = 1, n = arguments.length; i < n; i++) {
39
- s = arguments[i];
40
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41
- }
42
- return t;
43
- };
44
- return __assign.apply(this, arguments);
45
- };
46
-
47
- var StatsComponent = (function (_super) {
48
- __extends(StatsComponent, _super);
49
- function StatsComponent() {
50
- return _super !== null && _super.apply(this, arguments) || this;
51
- }
52
- StatsComponent.prototype.update = function () {
53
- this.stats && this.stats.begin();
54
- };
55
- StatsComponent.componentName = 'Stats';
56
- return StatsComponent;
57
- }(eva_js.Component));
58
- var Stats$2 = StatsComponent;
59
-
60
- var Stats = function (style) {
61
- style = __assign({ width: 20, height: 12, x: 0, y: 0 }, style);
62
- var width = style.width, height = style.height, x = style.x, y = style.y;
63
- var mode = 0;
64
- var container = document.createElement('div');
65
- container.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: " + width + "vw;height: " + height + "vw;left: " + x + "vw;top: " + y + "vw;";
66
- container.addEventListener('click', function (event) {
67
- event.preventDefault();
68
- showPanel(++mode % container.children.length);
69
- }, false);
70
- function addPanel(panel) {
71
- container.appendChild(panel.dom);
72
- return panel;
73
- }
74
- function showPanel(id) {
75
- for (var i = 0; i < container.children.length; i++) {
76
- container.children[i].style.display = i === id ? 'block' : 'none';
77
- }
78
- mode = id;
79
- }
80
- var beginTime = (performance || Date).now(), prevTime = beginTime, frames = 0;
81
- var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
82
- var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
83
- var memPanel;
84
- if (self.performance && self.performance.memory) {
85
- memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
86
- }
87
- showPanel(0);
88
- return {
89
- REVISION: 16,
90
- dom: container,
91
- addPanel: addPanel,
92
- showPanel: showPanel,
93
- begin: function (time) {
94
- beginTime = time || (performance || Date).now();
95
- },
96
- end: function () {
97
- frames++;
98
- var time = (performance || Date).now();
99
- msPanel.update(time - beginTime, 200);
100
- if (time >= prevTime + 1000) {
101
- fpsPanel.update((frames * 1000) / (time - prevTime), 100);
102
- prevTime = time;
103
- frames = 0;
104
- if (memPanel) {
105
- var memory = performance.memory;
106
- memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
107
- }
108
- }
109
- return time;
110
- },
111
- update: function () {
112
- beginTime = this.end();
113
- },
114
- domElement: container,
115
- setMode: showPanel,
116
- };
117
- };
118
- Stats.Panel = function (name, fg, bg) {
119
- var min = Infinity, max = 0;
120
- var round = Math.round;
121
- var PR = round(window.devicePixelRatio || 1);
122
- var WIDTH = 80 * PR, HEIGHT = 48 * PR, TEXT_X = 3 * PR, TEXT_Y = 2 * PR, GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR, GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;
123
- var canvas = document.createElement('canvas');
124
- canvas.width = WIDTH;
125
- canvas.height = HEIGHT;
126
- canvas.style.cssText = 'width:100%;height:100%';
127
- var context = canvas.getContext('2d');
128
- context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';
129
- context.textBaseline = 'top';
130
- context.fillStyle = bg;
131
- context.fillRect(0, 0, WIDTH, HEIGHT);
132
- context.fillStyle = fg;
133
- context.fillText(name, TEXT_X, TEXT_Y);
134
- context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
135
- context.fillStyle = bg;
136
- context.globalAlpha = 0.9;
137
- context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
138
- return {
139
- dom: canvas,
140
- update: function (value, maxValue) {
141
- min = Math.min(min, value);
142
- max = Math.max(max, value);
143
- context.fillStyle = bg;
144
- context.globalAlpha = 1;
145
- context.fillRect(0, 0, WIDTH, GRAPH_Y);
146
- context.fillStyle = fg;
147
- context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);
148
- context.drawImage(canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT);
149
- context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);
150
- context.fillStyle = bg;
151
- context.globalAlpha = 0.9;
152
- context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));
153
- },
154
- };
155
- };
156
- var Stats$1 = Stats;
157
-
158
- var StatsSystem = (function (_super) {
159
- __extends(StatsSystem, _super);
160
- function StatsSystem() {
161
- var _this = _super !== null && _super.apply(this, arguments) || this;
162
- _this.show = true;
163
- return _this;
164
- }
165
- StatsSystem.prototype.init = function (param) {
166
- if (param === void 0) { param = { show: true }; }
167
- this.show = param.show;
168
- this.style = param.style;
169
- };
170
- StatsSystem.prototype.start = function () {
171
- if (!this.show)
172
- return;
173
- this.component = this.game.scene.addComponent(new Stats$2());
174
- this.stats = Stats$1(this.style);
175
- this.component.stats = this.stats;
176
- this.stats.showPanel(0);
177
- document.body.appendChild(this.stats.dom);
178
- };
179
- StatsSystem.prototype.lateUpdate = function () {
180
- if (!this.show)
181
- return;
182
- this.stats && this.stats.end();
183
- };
184
- StatsSystem.systemName = 'Stats';
185
- return StatsSystem;
186
- }(eva_js.System));
187
- var StatsSystem$1 = StatsSystem;
188
-
189
- var index = {
190
- Components: [Stats$2],
191
- Systems: [StatsSystem$1],
192
- };
193
-
194
- exports.Stats = Stats$2;
195
- exports.StatsSystem = StatsSystem$1;
196
- exports['default'] = index;
197
-
198
- Object.defineProperty(exports, '__esModule', { value: true });
199
-
200
- })));
@@ -1 +0,0 @@
1
- var t,e;t=this,e=function(t,e){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},a=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){var e=(t=i({width:20,height:12,x:0,y:0},t)).width,n=t.height,o=t.x,a=t.y,l=0,r=document.createElement("div");function f(t){return r.appendChild(t.dom),t}function p(t){for(var e=0;e<r.children.length;e++)r.children[e].style.display=e===t?"block":"none";l=t}r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: "+e+"vw;height: "+n+"vw;left: "+o+"vw;top: "+a+"vw;",r.addEventListener("click",(function(t){t.preventDefault(),p(++l%r.children.length)}),!1);var c,h=(performance||Date).now(),u=h,d=0,y=f(s.Panel("FPS","#0ff","#002")),m=f(s.Panel("MS","#0f0","#020"));return self.performance&&self.performance.memory&&(c=f(s.Panel("MB","#f08","#201"))),p(0),{REVISION:16,dom:r,addPanel:f,showPanel:p,begin:function(t){h=t||(performance||Date).now()},end:function(){d++;var t=(performance||Date).now();if(m.update(t-h,200),t>=u+1e3&&(y.update(1e3*d/(t-u),100),u=t,d=0,c)){var e=performance.memory;c.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576)}return t},update:function(){h=this.end()},domElement:r,setMode:p}};s.Panel=function(t,e,n){var o=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),l=80*s,r=48*s,f=3*s,p=2*s,c=3*s,h=15*s,u=74*s,d=30*s,y=document.createElement("canvas");y.width=l,y.height=r,y.style.cssText="width:100%;height:100%";var m=y.getContext("2d");return m.font="bold "+9*s+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,l,r),m.fillStyle=e,m.fillText(t,f,p),m.fillRect(c,h,u,d),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(c,h,u,d),{dom:y,update:function(r,v){o=Math.min(o,r),i=Math.max(i,r),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,l,h),m.fillStyle=e,m.fillText(a(r)+" "+t+" ("+a(o)+"-"+a(i)+")",f,p),m.drawImage(y,c+s,h,u-s,d,c,h,u-s,d),m.fillRect(c+u-s,h,s,d),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(c+u-s,h,s,a((1-r/v)*d))}}};var l=s,r=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){void 0===t&&(t={show:!0}),this.show=t.show,this.style=t.style},e.prototype.start=function(){this.show&&(this.component=this.game.scene.addComponent(new a),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()},e.systemName="Stats",e}(e.System),f={Components:[a],Systems:[r]};t.Stats=a,t.StatsSystem=r,t.default=f,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@eva/eva.js")):"function"==typeof define&&define.amd?define(["exports","@eva/eva.js"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).EVA=t.EVA||{},t.EVA.plugin=t.EVA.plugin||{},t.EVA.plugin.stats={}),t.EVA);
@@ -1,152 +0,0 @@
1
- import { __extends, __assign } from 'tslib';
2
- import { Component, System } from '@eva/eva.js/dist/miniprogram';
3
- import { documentAlias, performance, windowAlias } from '@eva/miniprogram-adapter';
4
-
5
- var StatsComponent = (function (_super) {
6
- __extends(StatsComponent, _super);
7
- function StatsComponent() {
8
- return _super !== null && _super.apply(this, arguments) || this;
9
- }
10
- StatsComponent.prototype.update = function () {
11
- this.stats && this.stats.begin();
12
- };
13
- StatsComponent.componentName = 'Stats';
14
- return StatsComponent;
15
- }(Component));
16
- var Stats$2 = StatsComponent;
17
-
18
- var Stats = function (style) {
19
- style = __assign({ width: 20, height: 12, x: 0, y: 0 }, style);
20
- var width = style.width, height = style.height, x = style.x, y = style.y;
21
- var mode = 0;
22
- var container = documentAlias.createElement('div');
23
- 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;";
24
- container.addEventListener('click', function (event) {
25
- event.preventDefault();
26
- showPanel(++mode % container.children.length);
27
- }, false);
28
- function addPanel(panel) {
29
- container.appendChild(panel.dom);
30
- return panel;
31
- }
32
- function showPanel(id) {
33
- for (var i = 0; i < container.children.length; i++) {
34
- container.children[i].style.display = i === id ? 'block' : 'none';
35
- }
36
- mode = id;
37
- }
38
- var beginTime = (performance || Date).now(), prevTime = beginTime, frames = 0;
39
- var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
40
- var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
41
- var memPanel;
42
- if (self.performance && self.performance.memory) {
43
- memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
44
- }
45
- showPanel(0);
46
- return {
47
- REVISION: 16,
48
- dom: container,
49
- addPanel: addPanel,
50
- showPanel: showPanel,
51
- begin: function (time) {
52
- beginTime = time || (performance || Date).now();
53
- },
54
- end: function () {
55
- frames++;
56
- var time = (performance || Date).now();
57
- msPanel.update(time - beginTime, 200);
58
- if (time >= prevTime + 1000) {
59
- fpsPanel.update((frames * 1000) / (time - prevTime), 100);
60
- prevTime = time;
61
- frames = 0;
62
- if (memPanel) {
63
- var memory = performance.memory;
64
- memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
65
- }
66
- }
67
- return time;
68
- },
69
- update: function () {
70
- beginTime = this.end();
71
- },
72
- domElement: container,
73
- setMode: showPanel,
74
- };
75
- };
76
- Stats.Panel = function (name, fg, bg) {
77
- var min = Infinity, max = 0;
78
- var round = Math.round;
79
- var PR = round(windowAlias.devicePixelRatio || 1);
80
- var WIDTH = 80 * PR, HEIGHT = 48 * PR, TEXT_X = 3 * PR, TEXT_Y = 2 * PR, GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR, GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;
81
- var canvas = documentAlias.createElement('canvas');
82
- canvas.width = WIDTH;
83
- canvas.height = HEIGHT;
84
- canvas.style.cssText = 'width:100%;height:100%';
85
- var context = canvas.getContext('2d');
86
- context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';
87
- context.textBaseline = 'top';
88
- context.fillStyle = bg;
89
- context.fillRect(0, 0, WIDTH, HEIGHT);
90
- context.fillStyle = fg;
91
- context.fillText(name, TEXT_X, TEXT_Y);
92
- context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
93
- context.fillStyle = bg;
94
- context.globalAlpha = 0.9;
95
- context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
96
- return {
97
- dom: canvas,
98
- update: function (value, maxValue) {
99
- min = Math.min(min, value);
100
- max = Math.max(max, value);
101
- context.fillStyle = bg;
102
- context.globalAlpha = 1;
103
- context.fillRect(0, 0, WIDTH, GRAPH_Y);
104
- context.fillStyle = fg;
105
- context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);
106
- context.drawImage(canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT);
107
- context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);
108
- context.fillStyle = bg;
109
- context.globalAlpha = 0.9;
110
- context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));
111
- },
112
- };
113
- };
114
- var Stats$1 = Stats;
115
-
116
- var StatsSystem = (function (_super) {
117
- __extends(StatsSystem, _super);
118
- function StatsSystem() {
119
- var _this = _super !== null && _super.apply(this, arguments) || this;
120
- _this.show = true;
121
- return _this;
122
- }
123
- StatsSystem.prototype.init = function (param) {
124
- if (param === void 0) { param = { show: true }; }
125
- this.show = param.show;
126
- this.style = param.style;
127
- };
128
- StatsSystem.prototype.start = function () {
129
- if (!this.show)
130
- return;
131
- this.component = this.game.scene.addComponent(new Stats$2());
132
- this.stats = Stats$1(this.style);
133
- this.component.stats = this.stats;
134
- this.stats.showPanel(0);
135
- documentAlias.body.appendChild(this.stats.dom);
136
- };
137
- StatsSystem.prototype.lateUpdate = function () {
138
- if (!this.show)
139
- return;
140
- this.stats && this.stats.end();
141
- };
142
- StatsSystem.systemName = 'Stats';
143
- return StatsSystem;
144
- }(System));
145
- var StatsSystem$1 = StatsSystem;
146
-
147
- var index = {
148
- Components: [Stats$2],
149
- Systems: [StatsSystem$1],
150
- };
151
-
152
- export { Stats$2 as Stats, StatsSystem$1 as StatsSystem, index as default };
@@ -1,37 +0,0 @@
1
- import { Component } from '@eva/eva.js';
2
- import { System } from '@eva/eva.js';
3
-
4
- declare const _default: {
5
- Components: (typeof Stats)[];
6
- Systems: (typeof StatsSystem)[];
7
- };
8
- export default _default;
9
-
10
- export declare class Stats extends Component {
11
- static componentName: string;
12
- stats: any;
13
- update(): void;
14
- }
15
-
16
- declare interface StatsParams {
17
- show?: boolean;
18
- style?: {
19
- width: number;
20
- height: number;
21
- x: number;
22
- y: number;
23
- };
24
- }
25
-
26
- export declare class StatsSystem extends System {
27
- static systemName: string;
28
- show: boolean;
29
- stats: any;
30
- style: any;
31
- component: Stats;
32
- init(param?: StatsParams): void;
33
- start(): void;
34
- lateUpdate(): void;
35
- }
36
-
37
- export { }