@eva/plugin-stats 2.0.0-beta.9 → 2.0.1-beta.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
globalThis.EVA = globalThis.EVA || {};
|
|
3
|
+
globalThis.EVA.plugin = globalThis.EVA.plugin || {};
|
|
4
4
|
var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
@@ -313,4 +313,4 @@ var _EVA_IIFE_stats = function (exports, eva_js) {
|
|
|
313
313
|
});
|
|
314
314
|
return exports;
|
|
315
315
|
}({}, EVA);
|
|
316
|
-
|
|
316
|
+
globalThis.EVA.plugin.stats = globalThis.EVA.plugin.stats || _EVA_IIFE_stats;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},_extends.apply(null,arguments)}
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{};var _EVA_IIFE_stats=function(t,e){"use strict";class s extends e.Component{update(){this.stats&&this.stats.begin()}}s.componentName="Stats";const r=function(t){t=_extends({width:20,height:12,x:0,y:0},t);const{width:e,height:s,x:a,y:l}=t;let i=0;const n=document.createElement("div");function o(t){return n.appendChild(t.dom),t}function h(t){for(let e=0;e<n.children.length;e++)n.children[e].style.display=e===t?"block":"none";i=t}n.style.cssText=`position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: ${e}vw;height: ${s}vw;left: ${a}vw;top: ${l}vw;`,n.addEventListener("click",(function(t){t.preventDefault(),h(++i%n.children.length)}),!1);let u=(performance||Date).now(),c=u,d=0;const x=o(r.Panel("FPS","#0ff","#002")),m=o(r.Panel("MS","#0f0","#020")),p=o(r.Panel("DrawCall","#330570","#A69700")),_=o(r.Panel("TC:","#A62500","#00B454"));let f;return self.performance&&self.performance.memory&&(f=o(r.Panel("MB","#f08","#201"))),h(0),{REVISION:16,dom:n,addPanel:o,showPanel:h,begin:function(t){u=t||(performance||Date).now()},end:function(t){d++;const e=(performance||Date).now();if(m.update(e-u,200),t&&(p.update(t.deltaDrawCalls,Math.max(50,t.maxDeltaDrawCalls)),_.update(t.texturesCount,Math.max(20,t.maxTextureCount))),e>=c+1e3&&(x.update(1e3*d/(e-c),100),c=e,d=0,f)){const t=performance.memory;f.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){u=this.end()},domElement:n,setMode:h}};r.Panel=function(t,e,s){let r=1/0,a=0;const l=Math.round,i=l(window.devicePixelRatio||1),n=80*i,o=48*i,h=3*i,u=2*i,c=3*i,d=15*i,x=74*i,m=30*i,p=document.createElement("canvas");p.width=n,p.height=o,p.style.cssText="width:100%;height:100%";const _=p.getContext("2d");return _.font="bold "+9*i+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=s,_.fillRect(0,0,n,o),_.fillStyle=e,_.fillText(t,h,u),_.fillRect(c,d,x,m),_.fillStyle=s,_.globalAlpha=.9,_.fillRect(c,d,x,m),{dom:p,update:function(o,f){r=Math.min(r,o),a=Math.max(a,o),_.fillStyle=s,_.globalAlpha=1,_.fillRect(0,0,n,d),_.fillStyle=e,_.fillText(l(o)+" "+t+" ("+l(r)+"-"+l(a)+")",h,u),_.drawImage(p,c+i,d,x-i,m,c,d,x-i,m),_.fillRect(c+x-i,d,i,m),_.fillStyle=s,_.globalAlpha=.9,_.fillRect(c+x-i,d,i,l((1-o/f)*m))}}};var a=r;class l{constructor(t){this.drawPasses=0,this.isInit=!1,this.realGLDrawElements=function(){},t?t.__proto__.drawElements&&(this.gl=t,this.realGLDrawElements=t.__proto__.drawElements,t.__proto__.drawElements=this.fakeGLdrawElements(this),this.isInit=!0):console.error("[GLHook] GL can't be NULL")}fakeGLdrawElements(t){return function(e,s,r,a){t.drawPasses++,t.realGLDrawElements.call(this,e,s,r,a)}}reset(){this.drawPasses=0}release(){this.isInit&&(this.gl.__proto__.drawElements=this.realGLDrawElements),this.isInit=!1}}class i{constructor(t){this.createdTextures=new Array,this.maxTexturesCount=0,this.isInit=!1,this.realGLCreateTexture=function(){},this.realGLDeleteTexture=function(){},t?t.__proto__.createTexture&&(this.gl=t,this.realGLCreateTexture=t.__proto__.createTexture,this.realGLDeleteTexture=t.__proto__.deleteTexture,t.__proto__.createTexture=this.fakeGLCreateTexture(this),t.__proto__.deleteTexture=this.fakeGLDeleteTexture(this),this.isInit=!0):console.error("[TextureHook] GL can't be NULL")}get currentTextureCount(){return this.createdTextures.length}registerTexture(t){this.createdTextures.push(t),this.maxTexturesCount=Math.max(this.createdTextures.length,this.maxTexturesCount)}fakeGLCreateTexture(t){return function(){var e=t.realGLCreateTexture.call(this);return t.registerTexture(e),e}}fakeGLDeleteTexture(t){return function(e){var s=t.createdTextures.indexOf(e);s>-1&&t.createdTextures.splice(s,1),t.realGLDeleteTexture.call(this,e)}}reset(){this.createdTextures=new Array,this.maxTexturesCount=0}release(){this.isInit&&(this.gl.__proto__.createTexture=this.realGLCreateTexture,this.gl.__proto__.deleteTexture=this.realGLDeleteTexture,console.log("[TextureHook] Hook was removed!")),this.isInit=!1}}class n{constructor(){this._drawCalls=-1,this._maxDeltaDrawCalls=-1}attach(t){this.glhook=new l(t),this.texturehook=new i(t)}get drawCalls(){return this.glhook&&this.glhook.isInit?this.glhook.drawPasses:-1}get maxDeltaDrawCalls(){return this._maxDeltaDrawCalls}get deltaDrawCalls(){if(-1==this._drawCalls)return this._drawCalls=this.drawCalls,0;var t=this.drawCalls,e=t-this._drawCalls;return this._drawCalls=t,this._maxDeltaDrawCalls=Math.max(this._maxDeltaDrawCalls,e),e}get maxTextureCount(){return this.texturehook&&this.texturehook.isInit?this.texturehook.maxTexturesCount:0}get texturesCount(){return this.texturehook&&this.texturehook.isInit?this.texturehook.currentTextureCount:0}reset(){this._maxDeltaDrawCalls=-1,this._drawCalls=-1,this.glhook&&this.glhook.reset(),this.texturehook&&this.texturehook.reset()}release(){this.glhook&&this.glhook.release(),this.texturehook&&this.texturehook.release()}}class o extends e.System{constructor(){super(...arguments),this.show=!0}init(t={show:!0}){if(this.show=t.show,this.style=t.style,this.renderSystem=this.game.getSystem("Renderer"),this.app=this.renderSystem.application,this.app&&this.show){const t=this.app.renderer.gl;this.hook=new n,this.hook.attach(t)}}start(){this.show&&(this.component=this.game.scene.addComponent(new s),this.stats=a(this.style),this.component.stats=this.stats,this.stats.showPanel(0),document.body.appendChild(this.stats.dom))}lateUpdate(){this.show&&this.stats&&this.stats.end(this.hook)}}o.systemName="Stats";var h={Components:[s],Systems:[o]};return t.Stats=s,t.StatsSystem=o,t.default=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA);globalThis.EVA.plugin.stats=globalThis.EVA.plugin.stats||_EVA_IIFE_stats;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-stats",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1-beta.0",
|
|
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": "2.0.
|
|
21
|
+
"@eva/eva.js": "2.0.1-beta.0",
|
|
22
22
|
"lodash-es": "^4.17.21"
|
|
23
23
|
}
|
|
24
24
|
}
|