12345678910111213141516 |
- !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(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},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=8)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.d(e,"b",function(){return o}),n.d(e,"a",function(){return i});
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function i(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}},,,function(t,e,n){"use strict";n.r(e);var r=n(1),o=n(0),i="\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\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}";o.Effect.ShadersStore.asciiartPixelShader=i;var a=function(t){function e(e,n,r,i){void 0===i&&(i=null);var a=t.call(this,i)||this;if(!(i=a.getScene()))return a;a.name=e,a._text,a._font,a.wrapU=o.Texture.CLAMP_ADDRESSMODE,a.wrapV=o.Texture.CLAMP_ADDRESSMODE;var c=a.getFontHeight(n),f=a.getFontWidth(n);a._charSize=Math.max(c.height,f);var l=Math.ceil(a._charSize*r.length),u=a._charSize;a._texture=i.getEngine().createDynamicTexture(l,u,!1,o.Texture.NEAREST_SAMPLINGMODE);var s=a.getSize(),p=document.createElement("canvas");p.width=s.width,p.height=s.height;var d=p.getContext("2d");d.textBaseline="top",d.font=n,d.fillStyle="white",d.imageSmoothingEnabled=!1;for(var h=0;h<r.length;h++)d.fillText(r[h],h*a._charSize,-c.offset);return i.getEngine().updateDynamicTexture(a._texture,p,!1,!0),a}return r.b(e,t),Object.defineProperty(e.prototype,"charSize",{get:function(){return this._charSize},enumerable:!0,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 r=n.getImageData(0,0,e.width,e.height).data,o=-1,i=-1,a=0;a<e.height;a++)for(var c=0;c<e.width;c++){if(0!==r[4*(a*e.width+c)]){-1===o&&(o=a);break}if(c===e.width-1&&-1!==o){i=a,a=e.height;break}}return{height:i-o+1,offset:o-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,n){return o.SerializationHelper.Parse(function(){return new e(t.name,t.font,t.text,n)},t,n,null)},r.a([Object(o.serialize)("font")],e.prototype,"_font",void 0),r.a([Object(o.serialize)("text")],e.prototype,"_text",void 0),e}(o.BaseTexture),c=function(t){function e(e,n,r){var i=t.call(this,e,"asciiart",["asciiArtFontInfos","asciiArtOptions"],["asciiArtFont"],{width:n.getEngine().getRenderWidth(),height:n.getEngine().getRenderHeight()},n,o.Texture.TRILINEAR_SAMPLINGMODE,n.getEngine(),!0)||this;i.mixToTile=0,i.mixToNormal=0;var c="40px Monospace",f=" `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";r&&("string"==typeof r?c=r:(c=r.font||c,f=r.characterSet||f,i.mixToTile=r.mixToTile||i.mixToTile,i.mixToNormal=r.mixToNormal||i.mixToNormal)),i._asciiArtFontTexture=new a(e,c,f,n.getScene());var l=i._asciiArtFontTexture.getSize();return i.onApply=function(t){t.setTexture("asciiArtFont",i._asciiArtFontTexture),t.setFloat4("asciiArtFontInfos",i._asciiArtFontTexture.charSize,f.length,l.width,l.height),t.setFloat4("asciiArtOptions",i.width,i.height,i.mixToNormal,i.mixToTile)},i}return r.b(e,t),e}(o.PostProcess);n.d(e,"AsciiArtFontTexture",function(){return a}),n.d(e,"AsciiArtPostProcess",function(){return c})},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),function(t){var r=n(4);n.d(e,"AsciiArtFontTexture",function(){return r.AsciiArtFontTexture}),n.d(e,"AsciiArtPostProcess",function(){return r.AsciiArtPostProcess});var o=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in r)o.BABYLON[i]=r[i]}.call(this,n(5))}])});
|