Spaces:
Running
Running
!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 function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=6)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"a",(function(){return r})); | |
/*! ***************************************************************************** | |
Copyright (c) Microsoft Corporation. | |
Permission to use, copy, modify, and/or distribute this software for any | |
purpose with or without fee is hereby granted. | |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
PERFORMANCE OF THIS SOFTWARE. | |
***************************************************************************** */ | |
var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(t,e,n,o){var i,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(a=(r<3?i(a):r>3?i(e,n,a):i(e,n))||a);return r>3&&a&&Object.defineProperty(e,n,a),a}Object.create;Object.create},function(t,e,n){"use strict";n.r(e),n.d(e,"AsciiArtFontTexture",(function(){return a})),n.d(e,"AsciiArtPostProcess",(function(){return l}));var o=n(1),i=n(0),r="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D asciiArtFont;\n\nuniform vec4 asciiArtFontInfos;\nuniform vec4 asciiArtOptions;\n\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\n\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat caracterSize=asciiArtFontInfos.x;\nfloat numChar=asciiArtFontInfos.y-1.0;\nfloat fontx=asciiArtFontInfos.z;\nfloat fonty=asciiArtFontInfos.w;\nfloat screenx=asciiArtOptions.x;\nfloat screeny=asciiArtOptions.y;\nfloat tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;\nfloat tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;\nvec2 tileUV=vec2(tileX,tileY);\nvec4 tileColor=texture2D(textureSampler,tileUV);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat tileLuminance=getLuminance(tileColor.rgb);\nfloat offsetx=(float(floor(tileLuminance*numChar)))*caracterSize/fontx;\nfloat offsety=0.0;\nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;\nfloat y=float(mod(gl_FragCoord.y,caracterSize))/fonty;\nvec4 finalColor=texture2D(asciiArtFont,vec2(offsetx+x,offsety+(caracterSize/fonty-y)));\nfinalColor.rgb*=tileColor.rgb;\nfinalColor.a=1.0;\nfinalColor=mix(finalColor,tileColor,asciiArtOptions.w);\nfinalColor=mix(finalColor,baseColor,asciiArtOptions.z);\ngl_FragColor=finalColor;\n}";i.ShaderStore.ShadersStore.asciiartPixelShader=r;var a=function(t){function e(e,n,o,r){void 0===r&&(r=null);var a=t.call(this,r)||this;if(!(r=a.getScene()))return a;a.name=e,a._text,a._font,a.wrapU=i.Texture.CLAMP_ADDRESSMODE,a.wrapV=i.Texture.CLAMP_ADDRESSMODE;var l=a.getFontHeight(n),c=a.getFontWidth(n);a._charSize=Math.max(l.height,c);var f=Math.ceil(a._charSize*o.length),u=a._charSize;a._texture=r.getEngine().createDynamicTexture(f,u,!1,i.Texture.NEAREST_SAMPLINGMODE);var s=a.getSize(),d=document.createElement("canvas");d.width=s.width,d.height=s.height;var g=d.getContext("2d");g.textBaseline="top",g.font=n,g.fillStyle="white",g.imageSmoothingEnabled=!1;for(var h=0;h<o.length;h++)g.fillText(o[h],h*a._charSize,-l.offset);return r.getEngine().updateDynamicTexture(a._texture,d,!1,!0),a}return Object(o.b)(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"),n=e.getContext("2d");n.fillRect(0,0,e.width,e.height),n.textBaseline="top",n.fillStyle="white",n.font=t,n.fillText("jH|",0,0);for(var o=n.getImageData(0,0,e.width,e.height).data,i=-1,r=-1,a=0;a<e.height;a++)for(var l=0;l<e.width;l++){if(0!==o[4*(a*e.width+l)]){-1===i&&(i=a);break}if(l===e.width-1&&-1!==i){r=a,a=e.height;break}}return{height:r-i+1,offset:i-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,n){return i.SerializationHelper.Parse((function(){return new e(t.name,t.font,t.text,n)}),t,n,null)},Object(o.a)([Object(i.serialize)("font")],e.prototype,"_font",void 0),Object(o.a)([Object(i.serialize)("text")],e.prototype,"_text",void 0),e}(i.BaseTexture),l=function(t){function e(e,n,o){var r=t.call(this,e,"asciiart",["asciiArtFontInfos","asciiArtOptions"],["asciiArtFont"],{width:n.getEngine().getRenderWidth(),height:n.getEngine().getRenderHeight()},n,i.Texture.TRILINEAR_SAMPLINGMODE,n.getEngine(),!0)||this;r.mixToTile=0,r.mixToNormal=0;var l="40px Monospace",c=" `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";o&&("string"==typeof o?l=o:(l=o.font||l,c=o.characterSet||c,r.mixToTile=o.mixToTile||r.mixToTile,r.mixToNormal=o.mixToNormal||r.mixToNormal)),r._asciiArtFontTexture=new a(e,l,c,n.getScene());var f=r._asciiArtFontTexture.getSize();return r.onApply=function(t){t.setTexture("asciiArtFont",r._asciiArtFontTexture),t.setFloat4("asciiArtFontInfos",r._asciiArtFontTexture.charSize,c.length,f.width,f.height),t.setFloat4("asciiArtOptions",r.width,r.height,r.mixToNormal,r.mixToTile)},r}return Object(o.b)(e,t),e}(i.PostProcess)},function(t,e,n){"use strict";n.r(e),n.d(e,"DigitalRainFontTexture",(function(){return a})),n.d(e,"DigitalRainPostProcess",(function(){return l}));var o=n(1),i=n(0),r="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D digitalRainFont;\n\nuniform vec4 digitalRainFontInfos;\nuniform vec4 digitalRainOptions;\nuniform mat4 matrixSpeed;\nuniform float cosTimeZeroOne;\n\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\n\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat caracterSize=digitalRainFontInfos.x;\nfloat numChar=digitalRainFontInfos.y-1.0;\nfloat fontx=digitalRainFontInfos.z;\nfloat fonty=digitalRainFontInfos.w;\nfloat screenx=digitalRainOptions.x;\nfloat screeny=digitalRainOptions.y;\nfloat ratio=screeny/fonty;\nfloat columnx=float(floor((gl_FragCoord.x)/caracterSize));\nfloat tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;\nfloat tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;\nvec2 tileUV=vec2(tileX,tileY);\nvec4 tileColor=texture2D(textureSampler,tileUV);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat tileLuminance=getLuminance(tileColor.rgb);\nint st=int(mod(columnx,4.0));\nfloat speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6);\nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;\nfloat y=float(mod(speed+gl_FragCoord.y/screeny,1.0));\ny*=ratio;\nvec4 finalColor=texture2D(digitalRainFont,vec2(x,1.0-y));\nvec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));\nfinalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));\nfinalColor.rgb+=high;\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\nfinalColor.a=1.0;\nfinalColor=mix(finalColor,tileColor,digitalRainOptions.w);\nfinalColor=mix(finalColor,baseColor,digitalRainOptions.z);\ngl_FragColor=finalColor;\n}";i.ShaderStore.ShadersStore.digitalrainPixelShader=r;var a=function(t){function e(e,n,o,r){void 0===r&&(r=null);var a=t.call(this,r)||this;if(!(r=a.getScene()))return a;a.name=e,a._text,a._font,a.wrapU=i.Texture.CLAMP_ADDRESSMODE,a.wrapV=i.Texture.CLAMP_ADDRESSMODE;var l=a.getFontHeight(n),c=a.getFontWidth(n);a._charSize=Math.max(l.height,c);var f=a._charSize,u=Math.ceil(a._charSize*o.length);a._texture=r.getEngine().createDynamicTexture(f,u,!1,i.Texture.NEAREST_SAMPLINGMODE);var s=a.getSize(),d=document.createElement("canvas");d.width=s.width,d.height=s.height;var g=d.getContext("2d");g.textBaseline="top",g.font=n,g.fillStyle="white",g.imageSmoothingEnabled=!1;for(var h=0;h<o.length;h++)g.fillText(o[h],0,h*a._charSize-l.offset);return r.getEngine().updateDynamicTexture(a._texture,d,!1,!0),a}return Object(o.b)(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"),n=e.getContext("2d");n.fillRect(0,0,e.width,e.height),n.textBaseline="top",n.fillStyle="white",n.font=t,n.fillText("jH|",0,0);for(var o=n.getImageData(0,0,e.width,e.height).data,i=-1,r=-1,a=0;a<e.height;a++)for(var l=0;l<e.width;l++){if(0!==o[4*(a*e.width+l)]){-1===i&&(i=a);break}if(l===e.width-1&&-1!==i){r=a,a=e.height;break}}return{height:r-i+1,offset:i-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,n){return i.SerializationHelper.Parse((function(){return new e(t.name,t.font,t.text,n)}),t,n,null)},Object(o.a)([Object(i.serialize)("font")],e.prototype,"_font",void 0),Object(o.a)([Object(i.serialize)("text")],e.prototype,"_text",void 0),e}(i.BaseTexture),l=function(t){function e(e,n,o){var r=t.call(this,e,"digitalrain",["digitalRainFontInfos","digitalRainOptions","cosTimeZeroOne","matrixSpeed"],["digitalRainFont"],{width:n.getEngine().getRenderWidth(),height:n.getEngine().getRenderHeight()},n,i.Texture.TRILINEAR_SAMPLINGMODE,n.getEngine(),!0)||this;r.mixToTile=0,r.mixToNormal=0,r.speed=.003;var l="15px Monospace",c="ๅคๆฑ ใ่้ฃใณ่พผใๆฐดใฎ้ณใตใใใใใใใใจใณใใใฟใใฎใใจๅใใใ็ฟใๅฐ่ใใปใใไนใฏใคใใใใใใใใฟใฎใใปใใใชใๆฑๆธใฎ้จไฝ็ณๅใใ ๆ้ณฅใใฉใฎใใใชใใใใฎใใ ใปใจใจใใ";o&&("string"==typeof o?l=o:(l=o.font||l,r.mixToTile=o.mixToTile||r.mixToTile,r.mixToNormal=o.mixToNormal||r.mixToNormal)),r._digitalRainFontTexture=new a(e,l,c,n.getScene());var f=r._digitalRainFontTexture.getSize(),u=0,s=0,d=i.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,c.length,f.width,f.height),t.setFloat4("digitalRainOptions",r.width,r.height,r.mixToNormal,r.mixToTile),t.setMatrix("matrixSpeed",d),u+=r.speed,s=u,t.setFloat("cosTimeZeroOne",s)},r}return Object(o.b)(e,t),e}(i.PostProcess)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e);var o=n(2);n.d(e,"AsciiArtFontTexture",(function(){return o.AsciiArtFontTexture})),n.d(e,"AsciiArtPostProcess",(function(){return o.AsciiArtPostProcess}));var i=n(3);n.d(e,"DigitalRainFontTexture",(function(){return i.DigitalRainFontTexture})),n.d(e,"DigitalRainPostProcess",(function(){return i.DigitalRainPostProcess}))},function(t,e,n){"use strict";n.r(e),function(t){var o=n(5);n.d(e,"AsciiArtFontTexture",(function(){return o.AsciiArtFontTexture})),n.d(e,"AsciiArtPostProcess",(function(){return o.AsciiArtPostProcess})),n.d(e,"DigitalRainFontTexture",(function(){return o.DigitalRainFontTexture})),n.d(e,"DigitalRainPostProcess",(function(){return o.DigitalRainPostProcess}));var i=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==i)for(var r in o)i.BABYLON[r]=o[r]}.call(this,n(4))}])})); |