@eva/plugin-stats 1.2.7-editor.9 → 1.2.7-fix.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.stats.js +1 -1
- package/dist/EVA.plugin.stats.js.map +1 -0
- package/dist/EVA.plugin.stats.min.js +1 -1
- package/dist/miniprogram.js +395 -0
- package/dist/plugin-stats.cjs.js +1 -1
- package/dist/plugin-stats.cjs.js.map +1 -0
- package/dist/plugin-stats.cjs.prod.js +2 -2
- package/dist/plugin-stats.esm.js.map +1 -0
- package/package.json +2 -2
package/dist/EVA.plugin.stats.js
CHANGED
|
@@ -436,7 +436,7 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
436
436
|
};
|
|
437
437
|
exports.Stats = Stats$2;
|
|
438
438
|
exports.StatsSystem = StatsSystem$1;
|
|
439
|
-
exports[
|
|
439
|
+
exports['default'] = index;
|
|
440
440
|
Object.defineProperty(exports, '__esModule', {
|
|
441
441
|
value: true
|
|
442
442
|
});
|
|
@@ -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;IAC/B,CAAC,CAAC;AACF;IACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;IAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,IAAI,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE;IAC3C,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzF,CAAC;AACD;IACO,IAAI,QAAQ,GAAG,WAAW;IACjC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,EAAE;IACrD,Q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ugin||{};var _EVA_IIFE_stats=function(t,e){"use strict";var r=function(t,e){return
|
|
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;
|
|
@@ -0,0 +1,395 @@
|
|
|
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
|
+
|
|
8
|
+
function StatsComponent() {
|
|
9
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
StatsComponent.prototype.update = function () {
|
|
13
|
+
this.stats && this.stats.begin();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
StatsComponent.componentName = 'Stats';
|
|
17
|
+
return StatsComponent;
|
|
18
|
+
}(Component);
|
|
19
|
+
|
|
20
|
+
var Stats$2 = StatsComponent;
|
|
21
|
+
|
|
22
|
+
var Stats = function Stats(style) {
|
|
23
|
+
style = __assign({
|
|
24
|
+
width: 20,
|
|
25
|
+
height: 12,
|
|
26
|
+
x: 0,
|
|
27
|
+
y: 0
|
|
28
|
+
}, style);
|
|
29
|
+
var width = style.width,
|
|
30
|
+
height = style.height,
|
|
31
|
+
x = style.x,
|
|
32
|
+
y = style.y;
|
|
33
|
+
var mode = 0;
|
|
34
|
+
var container = documentAlias.createElement('div');
|
|
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;";
|
|
36
|
+
container.addEventListener('click', function (event) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
showPanel(++mode % container.children.length);
|
|
39
|
+
}, false);
|
|
40
|
+
|
|
41
|
+
function addPanel(panel) {
|
|
42
|
+
container.appendChild(panel.dom);
|
|
43
|
+
return panel;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function showPanel(id) {
|
|
47
|
+
for (var i = 0; i < container.children.length; i++) {
|
|
48
|
+
container.children[i].style.display = i === id ? 'block' : 'none';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
mode = id;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var beginTime = (performance || Date).now(),
|
|
55
|
+
prevTime = beginTime,
|
|
56
|
+
frames = 0;
|
|
57
|
+
var fpsPanel = addPanel(Stats.Panel('FPS', '#0ff', '#002'));
|
|
58
|
+
var msPanel = addPanel(Stats.Panel('MS', '#0f0', '#020'));
|
|
59
|
+
var dcPanel = addPanel(Stats.Panel('DrawCall', '#330570', '#A69700'));
|
|
60
|
+
var tcPanel = addPanel(Stats.Panel('TC:', '#A62500', '#00B454'));
|
|
61
|
+
var memPanel;
|
|
62
|
+
|
|
63
|
+
if (self.performance && self.performance.memory) {
|
|
64
|
+
memPanel = addPanel(Stats.Panel('MB', '#f08', '#201'));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
showPanel(0);
|
|
68
|
+
return {
|
|
69
|
+
REVISION: 16,
|
|
70
|
+
dom: container,
|
|
71
|
+
addPanel: addPanel,
|
|
72
|
+
showPanel: showPanel,
|
|
73
|
+
begin: function begin(time) {
|
|
74
|
+
beginTime = time || (performance || Date).now();
|
|
75
|
+
},
|
|
76
|
+
end: function end(hook) {
|
|
77
|
+
frames++;
|
|
78
|
+
var time = (performance || Date).now();
|
|
79
|
+
msPanel.update(time - beginTime, 200);
|
|
80
|
+
|
|
81
|
+
if (hook) {
|
|
82
|
+
dcPanel.update(hook.deltaDrawCalls, Math.max(50, hook.maxDeltaDrawCalls));
|
|
83
|
+
tcPanel.update(hook.texturesCount, Math.max(20, hook.maxTextureCount));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (time >= prevTime + 1000) {
|
|
87
|
+
fpsPanel.update(frames * 1000 / (time - prevTime), 100);
|
|
88
|
+
prevTime = time;
|
|
89
|
+
frames = 0;
|
|
90
|
+
|
|
91
|
+
if (memPanel) {
|
|
92
|
+
var memory = performance.memory;
|
|
93
|
+
memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return time;
|
|
98
|
+
},
|
|
99
|
+
update: function update() {
|
|
100
|
+
beginTime = this.end();
|
|
101
|
+
},
|
|
102
|
+
domElement: container,
|
|
103
|
+
setMode: showPanel
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Stats.Panel = function (name, fg, bg) {
|
|
108
|
+
var min = Infinity,
|
|
109
|
+
max = 0;
|
|
110
|
+
var round = Math.round;
|
|
111
|
+
var PR = round(windowAlias.devicePixelRatio || 1);
|
|
112
|
+
var WIDTH = 80 * 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;
|
|
120
|
+
var canvas = documentAlias.createElement('canvas');
|
|
121
|
+
canvas.width = WIDTH;
|
|
122
|
+
canvas.height = HEIGHT;
|
|
123
|
+
canvas.style.cssText = 'width:100%;height:100%';
|
|
124
|
+
var context = canvas.getContext('2d');
|
|
125
|
+
context.font = 'bold ' + 9 * PR + 'px Helvetica,Arial,sans-serif';
|
|
126
|
+
context.textBaseline = 'top';
|
|
127
|
+
context.fillStyle = bg;
|
|
128
|
+
context.fillRect(0, 0, WIDTH, HEIGHT);
|
|
129
|
+
context.fillStyle = fg;
|
|
130
|
+
context.fillText(name, TEXT_X, TEXT_Y);
|
|
131
|
+
context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
|
|
132
|
+
context.fillStyle = bg;
|
|
133
|
+
context.globalAlpha = 0.9;
|
|
134
|
+
context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
|
|
135
|
+
return {
|
|
136
|
+
dom: canvas,
|
|
137
|
+
update: function update(value, maxValue) {
|
|
138
|
+
min = Math.min(min, value);
|
|
139
|
+
max = Math.max(max, value);
|
|
140
|
+
context.fillStyle = bg;
|
|
141
|
+
context.globalAlpha = 1;
|
|
142
|
+
context.fillRect(0, 0, WIDTH, GRAPH_Y);
|
|
143
|
+
context.fillStyle = fg;
|
|
144
|
+
context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y);
|
|
145
|
+
context.drawImage(canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT);
|
|
146
|
+
context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);
|
|
147
|
+
context.fillStyle = bg;
|
|
148
|
+
context.globalAlpha = 0.9;
|
|
149
|
+
context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
var Stats$1 = Stats;
|
|
155
|
+
|
|
156
|
+
var GLHook = function () {
|
|
157
|
+
function GLHook(_gl) {
|
|
158
|
+
this.drawPasses = 0;
|
|
159
|
+
this.isInit = false;
|
|
160
|
+
|
|
161
|
+
this.realGLDrawElements = function () {};
|
|
162
|
+
|
|
163
|
+
if (_gl) {
|
|
164
|
+
if (_gl.__proto__.drawElements) {
|
|
165
|
+
this.gl = _gl;
|
|
166
|
+
this.realGLDrawElements = _gl.__proto__.drawElements;
|
|
167
|
+
_gl.__proto__.drawElements = this.fakeGLdrawElements.bind(this);
|
|
168
|
+
this.isInit = true;
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
console.error("[GLHook] GL can't be NULL");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
GLHook.prototype.fakeGLdrawElements = function (mode, count, type, offset) {
|
|
176
|
+
this.drawPasses++;
|
|
177
|
+
this.realGLDrawElements.call(this.gl, mode, count, type, offset);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
GLHook.prototype.reset = function () {
|
|
181
|
+
this.drawPasses = 0;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
GLHook.prototype.release = function () {
|
|
185
|
+
if (this.isInit) {
|
|
186
|
+
this.gl.__proto__.drawElements = this.realGLDrawElements;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
this.isInit = false;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return GLHook;
|
|
193
|
+
}();
|
|
194
|
+
|
|
195
|
+
var TextureHook = function () {
|
|
196
|
+
function TextureHook(_gl) {
|
|
197
|
+
this.createdTextures = new Array();
|
|
198
|
+
this.maxTexturesCount = 0;
|
|
199
|
+
this.isInit = false;
|
|
200
|
+
|
|
201
|
+
this.realGLCreateTexture = function () {};
|
|
202
|
+
|
|
203
|
+
this.realGLDeleteTexture = function () {};
|
|
204
|
+
|
|
205
|
+
if (_gl) {
|
|
206
|
+
if (_gl.__proto__.createTexture) {
|
|
207
|
+
this.gl = _gl;
|
|
208
|
+
this.realGLCreateTexture = _gl.__proto__.createTexture;
|
|
209
|
+
this.realGLDeleteTexture = _gl.__proto__.deleteTexture;
|
|
210
|
+
_gl.__proto__.createTexture = this.fakeGLCreateTexture.bind(this);
|
|
211
|
+
_gl.__proto__.deleteTexture = this.fakeGLDeleteTexture.bind(this);
|
|
212
|
+
this.isInit = true;
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
console.error("[TextureHook] GL can't be NULL");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
Object.defineProperty(TextureHook.prototype, "currentTextureCount", {
|
|
220
|
+
get: function get() {
|
|
221
|
+
return this.createdTextures.length;
|
|
222
|
+
},
|
|
223
|
+
enumerable: false,
|
|
224
|
+
configurable: true
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
TextureHook.prototype.registerTexture = function (texture) {
|
|
228
|
+
this.createdTextures.push(texture);
|
|
229
|
+
this.maxTexturesCount = Math.max(this.createdTextures.length, this.maxTexturesCount);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
TextureHook.prototype.fakeGLCreateTexture = function () {
|
|
233
|
+
var texture = this.realGLCreateTexture.call(this.gl);
|
|
234
|
+
this.registerTexture(texture);
|
|
235
|
+
return texture;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
TextureHook.prototype.fakeGLDeleteTexture = function (texture) {
|
|
239
|
+
var index = this.createdTextures.indexOf(texture);
|
|
240
|
+
|
|
241
|
+
if (index > -1) {
|
|
242
|
+
this.createdTextures.splice(index, 1);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
this.realGLDeleteTexture.call(this.gl, texture);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
TextureHook.prototype.reset = function () {
|
|
249
|
+
this.createdTextures = new Array();
|
|
250
|
+
this.maxTexturesCount = 0;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
TextureHook.prototype.release = function () {
|
|
254
|
+
if (this.isInit) {
|
|
255
|
+
this.gl.__proto__.createTexture = this.realGLCreateTexture;
|
|
256
|
+
this.gl.__proto__.deleteTexture = this.realGLDeleteTexture;
|
|
257
|
+
console.log('[TextureHook] Hook was removed!');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
this.isInit = false;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return TextureHook;
|
|
264
|
+
}();
|
|
265
|
+
|
|
266
|
+
var BaseHooks = function () {
|
|
267
|
+
function BaseHooks() {
|
|
268
|
+
this._drawCalls = -1;
|
|
269
|
+
this._maxDeltaDrawCalls = -1;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
BaseHooks.prototype.attach = function (gl) {
|
|
273
|
+
this.glhook = new GLHook(gl);
|
|
274
|
+
this.texturehook = new TextureHook(gl);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
Object.defineProperty(BaseHooks.prototype, "drawCalls", {
|
|
278
|
+
get: function get() {
|
|
279
|
+
if (this.glhook && this.glhook.isInit) {
|
|
280
|
+
return this.glhook.drawPasses;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return -1;
|
|
284
|
+
},
|
|
285
|
+
enumerable: false,
|
|
286
|
+
configurable: true
|
|
287
|
+
});
|
|
288
|
+
Object.defineProperty(BaseHooks.prototype, "maxDeltaDrawCalls", {
|
|
289
|
+
get: function get() {
|
|
290
|
+
return this._maxDeltaDrawCalls;
|
|
291
|
+
},
|
|
292
|
+
enumerable: false,
|
|
293
|
+
configurable: true
|
|
294
|
+
});
|
|
295
|
+
Object.defineProperty(BaseHooks.prototype, "deltaDrawCalls", {
|
|
296
|
+
get: function get() {
|
|
297
|
+
if (this._drawCalls == -1) {
|
|
298
|
+
this._drawCalls = this.drawCalls;
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
var dc = this.drawCalls;
|
|
303
|
+
var delta = dc - this._drawCalls;
|
|
304
|
+
this._drawCalls = dc;
|
|
305
|
+
this._maxDeltaDrawCalls = Math.max(this._maxDeltaDrawCalls, delta);
|
|
306
|
+
return delta;
|
|
307
|
+
},
|
|
308
|
+
enumerable: false,
|
|
309
|
+
configurable: true
|
|
310
|
+
});
|
|
311
|
+
Object.defineProperty(BaseHooks.prototype, "maxTextureCount", {
|
|
312
|
+
get: function get() {
|
|
313
|
+
if (this.texturehook && this.texturehook.isInit) return this.texturehook.maxTexturesCount;
|
|
314
|
+
return 0;
|
|
315
|
+
},
|
|
316
|
+
enumerable: false,
|
|
317
|
+
configurable: true
|
|
318
|
+
});
|
|
319
|
+
Object.defineProperty(BaseHooks.prototype, "texturesCount", {
|
|
320
|
+
get: function get() {
|
|
321
|
+
if (this.texturehook && this.texturehook.isInit) return this.texturehook.currentTextureCount;
|
|
322
|
+
return 0;
|
|
323
|
+
},
|
|
324
|
+
enumerable: false,
|
|
325
|
+
configurable: true
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
BaseHooks.prototype.reset = function () {
|
|
329
|
+
this._maxDeltaDrawCalls = -1;
|
|
330
|
+
this._drawCalls = -1;
|
|
331
|
+
if (this.glhook) this.glhook.reset();
|
|
332
|
+
if (this.texturehook) this.texturehook.reset();
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
BaseHooks.prototype.release = function () {
|
|
336
|
+
if (this.glhook) this.glhook.release();
|
|
337
|
+
if (this.texturehook) this.texturehook.release();
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
return BaseHooks;
|
|
341
|
+
}();
|
|
342
|
+
|
|
343
|
+
var StatsSystem = function (_super) {
|
|
344
|
+
__extends(StatsSystem, _super);
|
|
345
|
+
|
|
346
|
+
function StatsSystem() {
|
|
347
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
348
|
+
|
|
349
|
+
_this.show = true;
|
|
350
|
+
return _this;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
StatsSystem.prototype.init = function (param) {
|
|
354
|
+
if (param === void 0) {
|
|
355
|
+
param = {
|
|
356
|
+
show: true
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
this.show = param.show;
|
|
361
|
+
this.style = param.style;
|
|
362
|
+
this.renderSystem = this.game.getSystem('Renderer');
|
|
363
|
+
this.app = this.renderSystem.application;
|
|
364
|
+
|
|
365
|
+
if (this.app && this.show) {
|
|
366
|
+
var gl = this.app.renderer.gl;
|
|
367
|
+
this.hook = new BaseHooks();
|
|
368
|
+
this.hook.attach(gl);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
StatsSystem.prototype.start = function () {
|
|
373
|
+
if (!this.show) return;
|
|
374
|
+
this.component = this.game.scene.addComponent(new Stats$2());
|
|
375
|
+
this.stats = Stats$1(this.style);
|
|
376
|
+
this.component.stats = this.stats;
|
|
377
|
+
this.stats.showPanel(0);
|
|
378
|
+
documentAlias.body.appendChild(this.stats.dom);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
StatsSystem.prototype.lateUpdate = function () {
|
|
382
|
+
if (!this.show) return;
|
|
383
|
+
this.stats && this.stats.end(this.hook);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
StatsSystem.systemName = 'Stats';
|
|
387
|
+
return StatsSystem;
|
|
388
|
+
}(System);
|
|
389
|
+
|
|
390
|
+
var StatsSystem$1 = StatsSystem;
|
|
391
|
+
var index = {
|
|
392
|
+
Components: [Stats$2],
|
|
393
|
+
Systems: [StatsSystem$1]
|
|
394
|
+
};
|
|
395
|
+
export { Stats$2 as Stats, StatsSystem$1 as StatsSystem, index as default };
|
package/dist/plugin-stats.cjs.js
CHANGED
|
@@ -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;;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,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
|
|
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
|
|
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,KA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AAC;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,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-
|
|
3
|
+
"version": "1.2.7-fix.5",
|
|
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-
|
|
21
|
+
"@eva/eva.js": "1.2.7-fix.5",
|
|
22
22
|
"lodash-es": "^4.17.21"
|
|
23
23
|
}
|
|
24
24
|
}
|