123 |
- /*! For license information please see babylonjs.postProcess.min.js.LICENSE.txt */
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-post-process",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-post-process"]=e(require("babylonjs")):t.POSTPROCESSES=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(t){return(()=>{"use strict";var e={520:e=>{e.exports=t}},o={};function i(t){var r=o[t];if(void 0!==r)return r.exports;var n=o[t]={exports:{}};return e[t](n,n.exports,i),n.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{i.d(r,{default:()=>h});var t={};i.r(t),i.d(t,{AsciiArtFontTexture:()=>c,AsciiArtPostProcess:()=>f,DigitalRainFontTexture:()=>s,DigitalRainPostProcess:()=>u});var e={};i.r(e),i.d(e,{AsciiArtFontTexture:()=>c,AsciiArtPostProcess:()=>f,DigitalRainFontTexture:()=>s,DigitalRainPostProcess:()=>u});var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},o(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function a(t,e,o,i){var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a}Object.create,Object.create;var l=i(520);l.ShaderStore.ShadersStore.asciiartPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D asciiArtFont;uniform vec4 asciiArtFontInfos;uniform vec4 asciiArtOptions;float getLuminance(vec3 color)\n{return clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{float caracterSize=asciiArtFontInfos.x;float numChar=asciiArtFontInfos.y-1.0;float fontx=asciiArtFontInfos.z;float fonty=asciiArtFontInfos.w;float screenx=asciiArtOptions.x;float screeny=asciiArtOptions.y;float tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;float tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;vec2 tileUV=vec2(tileX,tileY);vec4 tileColor=texture2D(textureSampler,tileUV);vec4 baseColor=texture2D(textureSampler,vUV);float tileLuminance=getLuminance(tileColor.rgb);float offsetx=(float(floor(tileLuminance*numChar)))*caracterSize/fontx;float offsety=0.0;float x=float(mod(gl_FragCoord.x,caracterSize))/fontx;float y=float(mod(gl_FragCoord.y,caracterSize))/fonty;vec4 finalColor= texture2D(asciiArtFont,vec2(offsetx+x,offsety+(caracterSize/fonty-y)));finalColor.rgb*=tileColor.rgb;finalColor.a=1.0;finalColor= mix(finalColor,tileColor,asciiArtOptions.w);finalColor= mix(finalColor,baseColor,asciiArtOptions.z);gl_FragColor=finalColor;}";var c=function(t){function e(e,o,i,r){void 0===r&&(r=null);var n=t.call(this,r)||this;if(!(r=n.getScene()))return n;n.name=e,n._text,n._font,n.wrapU=l.Texture.CLAMP_ADDRESSMODE,n.wrapV=l.Texture.CLAMP_ADDRESSMODE;var a=n.getFontHeight(o),c=n.getFontWidth(o);n._charSize=Math.max(a.height,c);var f=Math.ceil(n._charSize*i.length),s=n._charSize;n._texture=r.getEngine().createDynamicTexture(f,s,!1,l.Texture.NEAREST_SAMPLINGMODE);var u=n.getSize(),g=document.createElement("canvas");g.width=u.width,g.height=u.height;var d=g.getContext("2d");d.textBaseline="top",d.font=o,d.fillStyle="white",d.imageSmoothingEnabled=!1;for(var h=0;h<i.length;h++)d.fillText(i[h],h*n._charSize,-a.offset);return r.getEngine().updateDynamicTexture(n._texture,g,!1,!0),n}return n(e,t),Object.defineProperty(e.prototype,"charSize",{get:function(){return this._charSize},enumerable:!1,configurable:!0}),e.prototype.getFontWidth=function(t){var e=document.createElement("canvas").getContext("2d");return e.fillStyle="white",e.font=t,e.measureText("W").width},e.prototype.getFontHeight=function(t){var e=document.createElement("canvas"),o=e.getContext("2d");o.fillRect(0,0,e.width,e.height),o.textBaseline="top",o.fillStyle="white",o.font=t,o.fillText("jH|",0,0);for(var i=o.getImageData(0,0,e.width,e.height).data,r=-1,n=-1,a=0;a<e.height;a++)for(var l=0;l<e.width;l++){if(0!==i[4*(a*e.width+l)]){-1===r&&(r=a);break}if(l===e.width-1&&-1!==r){n=a,a=e.height;break}}return{height:n-r+1,offset:r-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,o){return l.SerializationHelper.Parse((function(){return new e(t.name,t.font,t.text,o)}),t,o,null)},a([(0,l.serialize)("font")],e.prototype,"_font",void 0),a([(0,l.serialize)("text")],e.prototype,"_text",void 0),e}(l.BaseTexture),f=function(t){function e(e,o,i){var r=t.call(this,e,"asciiart",["asciiArtFontInfos","asciiArtOptions"],["asciiArtFont"],{width:o.getEngine().getRenderWidth(),height:o.getEngine().getRenderHeight()},o,l.Texture.TRILINEAR_SAMPLINGMODE,o.getEngine(),!0)||this;r.mixToTile=0,r.mixToNormal=0;var n="40px Monospace",a=" `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";i&&("string"==typeof i?n=i:(n=i.font||n,a=i.characterSet||a,r.mixToTile=i.mixToTile||r.mixToTile,r.mixToNormal=i.mixToNormal||r.mixToNormal)),r._asciiArtFontTexture=new c(e,n,a,o.getScene());var f=r._asciiArtFontTexture.getSize();return r.onApply=function(t){t.setTexture("asciiArtFont",r._asciiArtFontTexture),t.setFloat4("asciiArtFontInfos",r._asciiArtFontTexture.charSize,a.length,f.width,f.height),t.setFloat4("asciiArtOptions",r.width,r.height,r.mixToNormal,r.mixToTile)},r}return n(e,t),e}(l.PostProcess);l.ShaderStore.ShadersStore.digitalrainPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D digitalRainFont;uniform vec4 digitalRainFontInfos;uniform vec4 digitalRainOptions;uniform mat4 matrixSpeed;uniform float cosTimeZeroOne;float getLuminance(vec3 color)\n{return clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{float caracterSize=digitalRainFontInfos.x;float numChar=digitalRainFontInfos.y-1.0;float fontx=digitalRainFontInfos.z;float fonty=digitalRainFontInfos.w;float screenx=digitalRainOptions.x;float screeny=digitalRainOptions.y;float ratio=screeny/fonty;float columnx=float(floor((gl_FragCoord.x)/caracterSize));float tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;float tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;vec2 tileUV=vec2(tileX,tileY);vec4 tileColor=texture2D(textureSampler,tileUV);vec4 baseColor=texture2D(textureSampler,vUV);float tileLuminance=getLuminance(tileColor.rgb);int st=int(mod(columnx,4.0));float speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6); \nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;float y=float(mod(speed+gl_FragCoord.y/screeny,1.0));y*=ratio;vec4 finalColor= texture2D(digitalRainFont,vec2(x,1.0-y));vec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));finalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));finalColor.rgb+=high;finalColor.rgb=clamp(finalColor.rgb,0.,1.);finalColor.a=1.0;finalColor= mix(finalColor,tileColor,digitalRainOptions.w);finalColor= mix(finalColor,baseColor,digitalRainOptions.z);gl_FragColor=finalColor;}";var s=function(t){function e(e,o,i,r){void 0===r&&(r=null);var n=t.call(this,r)||this;if(!(r=n.getScene()))return n;n.name=e,n._text,n._font,n.wrapU=l.Texture.CLAMP_ADDRESSMODE,n.wrapV=l.Texture.CLAMP_ADDRESSMODE;var a=n.getFontHeight(o),c=n.getFontWidth(o);n._charSize=Math.max(a.height,c);var f=n._charSize,s=Math.ceil(n._charSize*i.length);n._texture=r.getEngine().createDynamicTexture(f,s,!1,l.Texture.NEAREST_SAMPLINGMODE);var u=n.getSize(),g=document.createElement("canvas");g.width=u.width,g.height=u.height;var d=g.getContext("2d");d.textBaseline="top",d.font=o,d.fillStyle="white",d.imageSmoothingEnabled=!1;for(var h=0;h<i.length;h++)d.fillText(i[h],0,h*n._charSize-a.offset);return r.getEngine().updateDynamicTexture(n._texture,g,!1,!0),n}return n(e,t),Object.defineProperty(e.prototype,"charSize",{get:function(){return this._charSize},enumerable:!1,configurable:!0}),e.prototype.getFontWidth=function(t){var e=document.createElement("canvas").getContext("2d");return e.fillStyle="white",e.font=t,e.measureText("W").width},e.prototype.getFontHeight=function(t){var e=document.createElement("canvas"),o=e.getContext("2d");o.fillRect(0,0,e.width,e.height),o.textBaseline="top",o.fillStyle="white",o.font=t,o.fillText("jH|",0,0);for(var i=o.getImageData(0,0,e.width,e.height).data,r=-1,n=-1,a=0;a<e.height;a++)for(var l=0;l<e.width;l++){if(0!==i[4*(a*e.width+l)]){-1===r&&(r=a);break}if(l===e.width-1&&-1!==r){n=a,a=e.height;break}}return{height:n-r+1,offset:r-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,o){return l.SerializationHelper.Parse((function(){return new e(t.name,t.font,t.text,o)}),t,o,null)},a([(0,l.serialize)("font")],e.prototype,"_font",void 0),a([(0,l.serialize)("text")],e.prototype,"_text",void 0),e}(l.BaseTexture),u=function(t){function e(e,o,i){var r=t.call(this,e,"digitalrain",["digitalRainFontInfos","digitalRainOptions","cosTimeZeroOne","matrixSpeed"],["digitalRainFont"],{width:o.getEngine().getRenderWidth(),height:o.getEngine().getRenderHeight()},o,l.Texture.TRILINEAR_SAMPLINGMODE,o.getEngine(),!0)||this;r.mixToTile=0,r.mixToNormal=0,r.speed=.003;var n="15px Monospace",a="古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";i&&("string"==typeof i?n=i:(n=i.font||n,r.mixToTile=i.mixToTile||r.mixToTile,r.mixToNormal=i.mixToNormal||r.mixToNormal)),r._digitalRainFontTexture=new s(e,n,a,o.getScene());var c=r._digitalRainFontTexture.getSize(),f=0,u=0,g=l.Matrix.FromValues(Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random());return r.onApply=function(t){t.setTexture("digitalRainFont",r._digitalRainFontTexture),t.setFloat4("digitalRainFontInfos",r._digitalRainFontTexture.charSize,a.length,c.width,c.height),t.setFloat4("digitalRainOptions",r.width,r.height,r.mixToNormal,r.mixToTile),t.setMatrix("matrixSpeed",g),f+=r.speed,u=f,t.setFloat("cosTimeZeroOne",u)},r}return n(e,t),e}(l.PostProcess),g=void 0!==i.g?i.g:"undefined"!=typeof window?window:void 0;if(void 0!==g)for(var d in t)g.BABYLON[d]=t[d];const h=e})(),r.default})()}));
- //# sourceMappingURL=babylonjs.postProcess.min.js.map
|