@galacean/effects-plugin-stats 2.10.0-alpha.4 → 2.10.0-alpha.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/index.js +2 -2
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime stats for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
6
|
+
* Version: v2.10.0-alpha.5
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -855,7 +855,7 @@ var json = {
|
|
|
855
855
|
|
|
856
856
|
/**
|
|
857
857
|
* 插件版本号
|
|
858
|
-
*/ var version = "2.10.0-alpha.
|
|
858
|
+
*/ var version = "2.10.0-alpha.5";
|
|
859
859
|
EFFECTS.logger.info("Plugin stats version: " + version + ".");
|
|
860
860
|
if (version !== EFFECTS__namespace.version) {
|
|
861
861
|
console.error("注意:请统一 Stats 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Stats plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
|
package/dist/index.min.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime stats for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
7
|
-
*/function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.statsPlugin={}),e.ge)}(this,function(e,t){"use strict";var r=function(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}(t);function n(e,t,r,n,i,s,o){try{var a=e[s](o),h=a.value}catch(e){r(e);return}a.done?t(h):Promise.resolve(h).then(n,i)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(i,s){var o=e.apply(t,r);function a(e){n(o,i,s,a,h,"next",e)}function h(e){n(o,i,s,a,h,"throw",e)}a(void 0)})}}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function o(e,t){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(h){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,h])}}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}"function"==typeof SuppressedError&&SuppressedError;var l=function(){function e(e,t){this.gl=e,this.debug=t,this.drawCall=0,this.triangles=0,this.lines=0,this.points=0,this.hooked=!0,this.realDrawElements=e.drawElements,this.realDrawArrays=e.drawArrays,e.drawElements=this.hookedDrawElements.bind(this),e.drawArrays=this.hookedDrawArrays.bind(this),t&&console.debug("DrawCall is hooked.")}var t=e.prototype;return t.hookedDrawElements=function(e,t,r,n){this.realDrawElements.call(this.gl,e,t,r,n),this.update(t,e)},t.hookedDrawArrays=function(e,t,r){this.realDrawArrays.call(this.gl,e,t,r),this.update(r,e)},t.update=function(e,t){var r=this.gl;switch(this.drawCall++,t){case r.TRIANGLES:this.triangles+=e/3;break;case r.TRIANGLE_STRIP:case r.TRIANGLE_FAN:this.triangles+=e-2;break;case r.LINES:this.lines+=e/2;break;case r.LINE_STRIP:this.lines+=e-1;break;case r.LINE_LOOP:this.lines+=e;break;case r.POINTS:this.points+=e;break;default:console.error("Unknown draw mode: "+t+". Count: "+e)}},t.reset=function(){this.drawCall=0,this.triangles=0,this.lines=0,this.points=0},t.release=function(){this.hooked&&(this.gl.drawElements=this.realDrawElements,this.gl.drawArrays=this.realDrawArrays,this.hooked=!1)},e}(),d=function(){function e(e,t){this.gl=e,this.debug=t,this.programs=0,this.hooked=!0,this.realUseProgram=e.useProgram,e.useProgram=this.hookedUseProgram.bind(this),t&&console.debug("Program is hooked.")}var t=e.prototype;return t.hookedUseProgram=function(e){this.realUseProgram.call(this.gl,e),this.programs++,this.debug&&console.debug("UseProgram: "+e+", program: "+this.programs+".")},t.reset=function(){this.programs=0},t.release=function(){this.hooked&&(this.gl.useProgram=this.realUseProgram,this.hooked=!1)},e}(),u=function(){function e(e,t){this.gl=e,this.debug=t,this.shaders=0,this.hooked=!0,this.realAttachShader=e.attachShader,this.realDetachShader=e.detachShader,e.attachShader=this.hookedAttachShader.bind(this),e.detachShader=this.hookedDetachShader.bind(this),t&&console.debug("Shader is hooked.")}var t=e.prototype;return t.hookedAttachShader=function(e,t){this.realAttachShader.call(this.gl,e,t),this.shaders++,this.debug&&console.debug("AttachShader: "+t+". shaders: "+this.shaders)},t.hookedDetachShader=function(e,t){this.realDetachShader.call(this.gl,e,t),this.shaders--,this.debug&&console.debug("DetachShader. shaders: "+this.shaders)},t.reset=function(){this.shaders=0},t.release=function(){this.hooked&&(this.gl.attachShader=this.realAttachShader,this.gl.detachShader=this.realDetachShader,this.hooked=!1)},e}(),c=function(){function e(e,t){var r=this;this.gl=e,this.debug=t,this.textures=0,this.hooked=!0,this.hookedCreateTexture=function(){for(var e,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];var s=(e=r.realCreateTexture).call.apply(e,[].concat([r.gl],n));return r.textures++,r.debug&&console.debug("CreateTexture: "+s+", textures: "+r.textures+"."),s},this.hookedDeleteTexture=function(){for(var e,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=r.realDeleteTexture).call.apply(e,[].concat([r.gl],n)),r.textures--,r.debug&&console.debug("DeleteTexture, textures: "+r.textures+".")},this.realCreateTexture=e.createTexture,this.realDeleteTexture=e.deleteTexture,e.createTexture=this.hookedCreateTexture.bind(this),e.deleteTexture=this.hookedDeleteTexture.bind(this),t&&console.debug("Texture is hooked.")}var t=e.prototype;return t.reset=function(){this.textures=0},t.release=function(){this.hooked&&(this.gl.createTexture=this.realCreateTexture,this.gl.deleteTexture=this.realDeleteTexture,this.hooked=!1)},e}(),p=function(){function e(e,t){if(void 0===t&&(t=!1),this.gl=e,this.samplingFrames=60,this.samplingIndex=0,this.updateCounter=0,this.updateTime=0,!e)throw Error("Unsupported WebGL context.");this.hook(e,t)}var t=e.prototype;return t.hook=function(e,t){this.drawCallHook=new l(e,t),this.textureHook=new c(e,t),this.shaderHook=new u(e,t),this.programHook=new d(e,t)},t.reset=function(){var e,t;null==(e=this.drawCallHook)||e.reset(),null==(t=this.programHook)||t.reset()},t.release=function(){var e,t,r,n;null==(e=this.drawCallHook)||e.release(),null==(t=this.textureHook)||t.release(),null==(r=this.shaderHook)||r.release(),null==(n=this.programHook)||n.release()},t.update=function(e){var t=performance.now();if(this.updateCounter++,!(t-this.updateTime<1e3)){if(this.samplingIndex!==this.samplingFrames){this.reset(),this.samplingIndex++;return}this.samplingIndex=0;var r={fps:Math.round(1e3*this.updateCounter/(t-this.updateTime)),memory:performance.memory&&performance.memory.usedJSHeapSize/1048576>>0,drawCall:0===this.drawCallHook.drawCall?0:this.drawCallHook.drawCall,triangles:0===this.drawCallHook.triangles?0:this.drawCallHook.triangles,lines:this.drawCallHook.lines,points:this.drawCallHook.points,textures:this.textureHook.textures,shaders:0===this.shaderHook.shaders?0:this.shaderHook.shaders,programs:this.programHook.programs,webglContext:!function e(t,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](t):e(t,r)}(this.gl,WebGL2RenderingContext)?"1.0":"2.0"};return this.reset(),this.updateCounter=0,this.updateTime=t,r}},e}(),f="\n .gl-perf {\n pointer-events: none;\n user-select: none;\n position: absolute;\n top: 0;\n left: 0;\n padding: "+10/7.5+"vh "+10/7.5+"vh 0 "+10/7.5+"vh;\n background: rgba(0, 0, 0, 0.3);\n color: #fff;\n font: "+10/7.5+"vh arial;\n }\n\n .gl-perf dl,\n .gl-perf dt,\n .gl-perf dd {\n padding: 0;\n margin: 0;\n }\n\n .gl-perf dt {\n color: #fff;\n text-shadow: #000 0 0 1px;\n }\n\n .gl-perf dt .unit{\n font-size: "+10/7.5+"vh;\n }\n\n .gl-perf dd {\n font-size: "+20/7.5+"vh;\n padding: "+10/7.5+"vh 0 "+10/7.5+"vh;\n }\n",g=function(e){function t(t,r){var n;return(n=e.call(this)||this).options=r,n.items=["fps","memory","drawCall","triangles","textures","shaders","programs","webglContext"],n.visible=!1,n.data={fps:60,memory:0,drawCall:0,triangles:0,lines:0,points:0,textures:0,shaders:0,programs:0,webglContext:"2.0"},n.core=new p(t,r.debug),n.visible=r.visible,n.createContainer(),n.update=n.update.bind(function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)),n}h(t,e);var r=t.prototype;return r.createContainer=function(){var e=document.createElement("div");this.container=e,this.visible||this.hide(),e.classList.add("gl-perf"),e.innerHTML='\n <dl>\n <dt>FPS</dt>\n <dd>0</dd>\n <dt>Memory <span class="unit">(MB)</span></dt>\n <dd>0</dd>\n <dt>DrawCall</dt>\n <dd>0</dd>\n <dt>Triangles</dt>\n <dd>0</dd>\n <dt>Textures</dt>\n <dd>0</dd>\n <dt>Shaders</dt>\n <dd>0</dd>\n <dt>Program</dt>\n <dd>0</dd>\n <dt>WebGL</dt>\n <dd></dd>\n </dl>\n',e.appendChild(this.createStyle()),this.options.container.appendChild(e),this.doms=Array.prototype.slice.apply(e.querySelectorAll("dd"))},r.createStyle=function(){var e=document.createElement("style");return e.appendChild(document.createTextNode(f)),e},r.update=function(e){var t,r=this.core.update(e);if(r&&0!==r.triangles&&(this.emit("update",r),this.visible))for(var n=0,i=this.items.length;n<i;n++)t=this,function(e,n){var i=t.doms[e],s=r[t.items[e]]||0;requestAnimationFrame(function(){i.innerText=String(s)})}(n)},r.hide=function(){this.visible=!1,this.container.style.display="none"},r.show=function(){this.visible=!0,this.container.style.display="block"},r.reset=function(){var e;this.core.reset();for(var t=0,r=this.items.length;t<r;t++)e=this,function(t,r){var n=e.doms[t],i=e.items[t],s=e.data[i]||0;requestAnimationFrame(function(){n.innerText=String(s)})}(t)},r.release=function(){this.core.release()},r.dispose=function(){this.release(),this.container.remove()},t}(t.EventEmitter),m=function(e){function t(){return e.apply(this,arguments)}h(t,e);var r=t.prototype;return r.init=function(e){var t=this.engine.gl;this.monitor=new g(t,e)},r.onUpdate=function(e){this.monitor.update(e)},r.dispose=function(){e.prototype.dispose.call(this),this.monitor.dispose()},t}(t.Component),b={debug:!1,visible:!0,container:document.body},y={images:[],fonts:[],version:"3.0",shapes:[],plugins:[],type:"ge",compositions:[{id:"2",name:"stats",duration:5,startTime:0,endBehavior:2,previewSize:[750,1624],items:[{id:"05e1c616baf34cc084968a05703719cd"}],camera:{fov:60,far:40,near:.1,clipMode:1,position:[0,0,8],rotation:[0,0,0]},sceneBindings:[]}],components:[],geometries:[],materials:[],items:[{id:"05e1c616baf34cc084968a05703719cd",name:"component",duration:99999,type:"3",visible:!0,endBehavior:0,delay:0,renderLevel:"B+",components:[],transform:{position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},anchor:{x:0,y:0},size:{x:1.2,y:1.2},scale:{x:1,y:1,z:1}},dataType:"VFXItemData"}],shaders:[],bins:[],textures:[],animations:[],compositionId:"2"},v=function(){function e(e,r){this.player=e,this.options=r,this.disposed=!1,this.initialized=new t.Deferred,this.init()}var r=e.prototype;return r.init=function(){var e=this;return i(function(){var t;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),[4,e.player.loadScene(y)];case 1:return(t=r.sent().getItemByName("component"))&&(t.addComponent(m).init(s({},b,e.options)),e.component=t.getComponent(m)),[3,4];case 2:throw Error("Failed to load stats scene: "+r.sent().message+".");case 3:return e.initialized.resolve(),[7];case 4:return[2]}})})()},r.getComponent=function(){var e=this;return i(function(){return o(this,function(t){switch(t.label){case 0:return[4,e.initialized.promise];case 1:return t.sent(),[2,e.component]}})})()},r.hide=function(){var e;null==(e=this.component)||e.monitor.hide()},r.show=function(){var e;null==(e=this.component)||e.monitor.show()},r.dispose=function(){var e;this.disposed||(this.disposed=!0,null==(e=this.component)||e.dispose(),this.component=void 0)},e}(),w="2.10.0-alpha.4";t.logger.info("Plugin stats version: "+w+"."),w!==r.version&&console.error("注意:请统一 Stats 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Stats plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),e.Stats=v,e.version=w,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
6
|
+
* Version: v2.10.0-alpha.5
|
|
7
|
+
*/function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.statsPlugin={}),e.ge)}(this,function(e,t){"use strict";var r=function(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}(t);function n(e,t,r,n,i,s,o){try{var a=e[s](o),h=a.value}catch(e){r(e);return}a.done?t(h):Promise.resolve(h).then(n,i)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(i,s){var o=e.apply(t,r);function a(e){n(o,i,s,a,h,"next",e)}function h(e){n(o,i,s,a,h,"throw",e)}a(void 0)})}}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function o(e,t){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(h){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,h])}}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}"function"==typeof SuppressedError&&SuppressedError;var l=function(){function e(e,t){this.gl=e,this.debug=t,this.drawCall=0,this.triangles=0,this.lines=0,this.points=0,this.hooked=!0,this.realDrawElements=e.drawElements,this.realDrawArrays=e.drawArrays,e.drawElements=this.hookedDrawElements.bind(this),e.drawArrays=this.hookedDrawArrays.bind(this),t&&console.debug("DrawCall is hooked.")}var t=e.prototype;return t.hookedDrawElements=function(e,t,r,n){this.realDrawElements.call(this.gl,e,t,r,n),this.update(t,e)},t.hookedDrawArrays=function(e,t,r){this.realDrawArrays.call(this.gl,e,t,r),this.update(r,e)},t.update=function(e,t){var r=this.gl;switch(this.drawCall++,t){case r.TRIANGLES:this.triangles+=e/3;break;case r.TRIANGLE_STRIP:case r.TRIANGLE_FAN:this.triangles+=e-2;break;case r.LINES:this.lines+=e/2;break;case r.LINE_STRIP:this.lines+=e-1;break;case r.LINE_LOOP:this.lines+=e;break;case r.POINTS:this.points+=e;break;default:console.error("Unknown draw mode: "+t+". Count: "+e)}},t.reset=function(){this.drawCall=0,this.triangles=0,this.lines=0,this.points=0},t.release=function(){this.hooked&&(this.gl.drawElements=this.realDrawElements,this.gl.drawArrays=this.realDrawArrays,this.hooked=!1)},e}(),d=function(){function e(e,t){this.gl=e,this.debug=t,this.programs=0,this.hooked=!0,this.realUseProgram=e.useProgram,e.useProgram=this.hookedUseProgram.bind(this),t&&console.debug("Program is hooked.")}var t=e.prototype;return t.hookedUseProgram=function(e){this.realUseProgram.call(this.gl,e),this.programs++,this.debug&&console.debug("UseProgram: "+e+", program: "+this.programs+".")},t.reset=function(){this.programs=0},t.release=function(){this.hooked&&(this.gl.useProgram=this.realUseProgram,this.hooked=!1)},e}(),u=function(){function e(e,t){this.gl=e,this.debug=t,this.shaders=0,this.hooked=!0,this.realAttachShader=e.attachShader,this.realDetachShader=e.detachShader,e.attachShader=this.hookedAttachShader.bind(this),e.detachShader=this.hookedDetachShader.bind(this),t&&console.debug("Shader is hooked.")}var t=e.prototype;return t.hookedAttachShader=function(e,t){this.realAttachShader.call(this.gl,e,t),this.shaders++,this.debug&&console.debug("AttachShader: "+t+". shaders: "+this.shaders)},t.hookedDetachShader=function(e,t){this.realDetachShader.call(this.gl,e,t),this.shaders--,this.debug&&console.debug("DetachShader. shaders: "+this.shaders)},t.reset=function(){this.shaders=0},t.release=function(){this.hooked&&(this.gl.attachShader=this.realAttachShader,this.gl.detachShader=this.realDetachShader,this.hooked=!1)},e}(),c=function(){function e(e,t){var r=this;this.gl=e,this.debug=t,this.textures=0,this.hooked=!0,this.hookedCreateTexture=function(){for(var e,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];var s=(e=r.realCreateTexture).call.apply(e,[].concat([r.gl],n));return r.textures++,r.debug&&console.debug("CreateTexture: "+s+", textures: "+r.textures+"."),s},this.hookedDeleteTexture=function(){for(var e,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=r.realDeleteTexture).call.apply(e,[].concat([r.gl],n)),r.textures--,r.debug&&console.debug("DeleteTexture, textures: "+r.textures+".")},this.realCreateTexture=e.createTexture,this.realDeleteTexture=e.deleteTexture,e.createTexture=this.hookedCreateTexture.bind(this),e.deleteTexture=this.hookedDeleteTexture.bind(this),t&&console.debug("Texture is hooked.")}var t=e.prototype;return t.reset=function(){this.textures=0},t.release=function(){this.hooked&&(this.gl.createTexture=this.realCreateTexture,this.gl.deleteTexture=this.realDeleteTexture,this.hooked=!1)},e}(),p=function(){function e(e,t){if(void 0===t&&(t=!1),this.gl=e,this.samplingFrames=60,this.samplingIndex=0,this.updateCounter=0,this.updateTime=0,!e)throw Error("Unsupported WebGL context.");this.hook(e,t)}var t=e.prototype;return t.hook=function(e,t){this.drawCallHook=new l(e,t),this.textureHook=new c(e,t),this.shaderHook=new u(e,t),this.programHook=new d(e,t)},t.reset=function(){var e,t;null==(e=this.drawCallHook)||e.reset(),null==(t=this.programHook)||t.reset()},t.release=function(){var e,t,r,n;null==(e=this.drawCallHook)||e.release(),null==(t=this.textureHook)||t.release(),null==(r=this.shaderHook)||r.release(),null==(n=this.programHook)||n.release()},t.update=function(e){var t=performance.now();if(this.updateCounter++,!(t-this.updateTime<1e3)){if(this.samplingIndex!==this.samplingFrames){this.reset(),this.samplingIndex++;return}this.samplingIndex=0;var r={fps:Math.round(1e3*this.updateCounter/(t-this.updateTime)),memory:performance.memory&&performance.memory.usedJSHeapSize/1048576>>0,drawCall:0===this.drawCallHook.drawCall?0:this.drawCallHook.drawCall,triangles:0===this.drawCallHook.triangles?0:this.drawCallHook.triangles,lines:this.drawCallHook.lines,points:this.drawCallHook.points,textures:this.textureHook.textures,shaders:0===this.shaderHook.shaders?0:this.shaderHook.shaders,programs:this.programHook.programs,webglContext:!function e(t,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](t):e(t,r)}(this.gl,WebGL2RenderingContext)?"1.0":"2.0"};return this.reset(),this.updateCounter=0,this.updateTime=t,r}},e}(),f="\n .gl-perf {\n pointer-events: none;\n user-select: none;\n position: absolute;\n top: 0;\n left: 0;\n padding: "+10/7.5+"vh "+10/7.5+"vh 0 "+10/7.5+"vh;\n background: rgba(0, 0, 0, 0.3);\n color: #fff;\n font: "+10/7.5+"vh arial;\n }\n\n .gl-perf dl,\n .gl-perf dt,\n .gl-perf dd {\n padding: 0;\n margin: 0;\n }\n\n .gl-perf dt {\n color: #fff;\n text-shadow: #000 0 0 1px;\n }\n\n .gl-perf dt .unit{\n font-size: "+10/7.5+"vh;\n }\n\n .gl-perf dd {\n font-size: "+20/7.5+"vh;\n padding: "+10/7.5+"vh 0 "+10/7.5+"vh;\n }\n",g=function(e){function t(t,r){var n;return(n=e.call(this)||this).options=r,n.items=["fps","memory","drawCall","triangles","textures","shaders","programs","webglContext"],n.visible=!1,n.data={fps:60,memory:0,drawCall:0,triangles:0,lines:0,points:0,textures:0,shaders:0,programs:0,webglContext:"2.0"},n.core=new p(t,r.debug),n.visible=r.visible,n.createContainer(),n.update=n.update.bind(function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)),n}h(t,e);var r=t.prototype;return r.createContainer=function(){var e=document.createElement("div");this.container=e,this.visible||this.hide(),e.classList.add("gl-perf"),e.innerHTML='\n <dl>\n <dt>FPS</dt>\n <dd>0</dd>\n <dt>Memory <span class="unit">(MB)</span></dt>\n <dd>0</dd>\n <dt>DrawCall</dt>\n <dd>0</dd>\n <dt>Triangles</dt>\n <dd>0</dd>\n <dt>Textures</dt>\n <dd>0</dd>\n <dt>Shaders</dt>\n <dd>0</dd>\n <dt>Program</dt>\n <dd>0</dd>\n <dt>WebGL</dt>\n <dd></dd>\n </dl>\n',e.appendChild(this.createStyle()),this.options.container.appendChild(e),this.doms=Array.prototype.slice.apply(e.querySelectorAll("dd"))},r.createStyle=function(){var e=document.createElement("style");return e.appendChild(document.createTextNode(f)),e},r.update=function(e){var t,r=this.core.update(e);if(r&&0!==r.triangles&&(this.emit("update",r),this.visible))for(var n=0,i=this.items.length;n<i;n++)t=this,function(e,n){var i=t.doms[e],s=r[t.items[e]]||0;requestAnimationFrame(function(){i.innerText=String(s)})}(n)},r.hide=function(){this.visible=!1,this.container.style.display="none"},r.show=function(){this.visible=!0,this.container.style.display="block"},r.reset=function(){var e;this.core.reset();for(var t=0,r=this.items.length;t<r;t++)e=this,function(t,r){var n=e.doms[t],i=e.items[t],s=e.data[i]||0;requestAnimationFrame(function(){n.innerText=String(s)})}(t)},r.release=function(){this.core.release()},r.dispose=function(){this.release(),this.container.remove()},t}(t.EventEmitter),m=function(e){function t(){return e.apply(this,arguments)}h(t,e);var r=t.prototype;return r.init=function(e){var t=this.engine.gl;this.monitor=new g(t,e)},r.onUpdate=function(e){this.monitor.update(e)},r.dispose=function(){e.prototype.dispose.call(this),this.monitor.dispose()},t}(t.Component),b={debug:!1,visible:!0,container:document.body},y={images:[],fonts:[],version:"3.0",shapes:[],plugins:[],type:"ge",compositions:[{id:"2",name:"stats",duration:5,startTime:0,endBehavior:2,previewSize:[750,1624],items:[{id:"05e1c616baf34cc084968a05703719cd"}],camera:{fov:60,far:40,near:.1,clipMode:1,position:[0,0,8],rotation:[0,0,0]},sceneBindings:[]}],components:[],geometries:[],materials:[],items:[{id:"05e1c616baf34cc084968a05703719cd",name:"component",duration:99999,type:"3",visible:!0,endBehavior:0,delay:0,renderLevel:"B+",components:[],transform:{position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},anchor:{x:0,y:0},size:{x:1.2,y:1.2},scale:{x:1,y:1,z:1}},dataType:"VFXItemData"}],shaders:[],bins:[],textures:[],animations:[],compositionId:"2"},v=function(){function e(e,r){this.player=e,this.options=r,this.disposed=!1,this.initialized=new t.Deferred,this.init()}var r=e.prototype;return r.init=function(){var e=this;return i(function(){var t;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),[4,e.player.loadScene(y)];case 1:return(t=r.sent().getItemByName("component"))&&(t.addComponent(m).init(s({},b,e.options)),e.component=t.getComponent(m)),[3,4];case 2:throw Error("Failed to load stats scene: "+r.sent().message+".");case 3:return e.initialized.resolve(),[7];case 4:return[2]}})})()},r.getComponent=function(){var e=this;return i(function(){return o(this,function(t){switch(t.label){case 0:return[4,e.initialized.promise];case 1:return t.sent(),[2,e.component]}})})()},r.hide=function(){var e;null==(e=this.component)||e.monitor.hide()},r.show=function(){var e;null==(e=this.component)||e.monitor.show()},r.dispose=function(){var e;this.disposed||(this.disposed=!0,null==(e=this.component)||e.dispose(),this.component=void 0)},e}(),w="2.10.0-alpha.5";t.logger.info("Plugin stats version: "+w+"."),w!==r.version&&console.error("注意:请统一 Stats 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Stats plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),e.Stats=v,e.version=w,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
8
8
|
//# sourceMappingURL=index.min.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime stats for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
6
|
+
* Version: v2.10.0-alpha.5
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -832,7 +832,7 @@ var json = {
|
|
|
832
832
|
|
|
833
833
|
/**
|
|
834
834
|
* 插件版本号
|
|
835
|
-
*/ var version = "2.10.0-alpha.
|
|
835
|
+
*/ var version = "2.10.0-alpha.5";
|
|
836
836
|
logger.info("Plugin stats version: " + version + ".");
|
|
837
837
|
if (version !== EFFECTS.version) {
|
|
838
838
|
console.error("注意:请统一 Stats 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Stats plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/effects-plugin-stats",
|
|
3
|
-
"version": "2.10.0-alpha.
|
|
3
|
+
"version": "2.10.0-alpha.5",
|
|
4
4
|
"description": "Galacean Effects runtime stats for the web",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"registry": "https://registry.npmjs.org"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@galacean/effects": "2.10.0-alpha.
|
|
31
|
+
"@galacean/effects": "2.10.0-alpha.5"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"dev": "vite",
|