Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function core() {
- function t() {
- const e = "#ifdef GL_FRAGMENT_PRECISION_HIGH\n#define highmedp highp\n#else\n#define highmedp mediump\n#endif\nprecision highmedp float;\n\n// Scene buffer\nuniform sampler2D uMainSampler; \nvarying vec2 outTexCoord;\n\n// Effect parameters\nuniform vec2 texSize;\nuniform float thickness;\nuniform vec3 outlineColor;\n\nconst float DOUBLE_PI = 3.14159265358979323846264 * 2.;\n\nvoid main() {\n vec4 front = texture2D(uMainSampler, outTexCoord);\n\n if (thickness > 0.0) {\n vec2 mag = vec2(thickness/texSize.x, thickness/texSize.y);\n vec4 curColor;\n float maxAlpha = front.a;\n vec2 offset;\n for (float angle = 0.; angle < DOUBLE_PI; angle += #{angleStep}) {\n offset = vec2(mag.x * cos(angle), mag.y * sin(angle)); \n curColor = texture2D(uMainSampler, outTexCoord + offset);\n maxAlpha = max(maxAlpha, curColor.a);\n }\n vec3 resultColor = front.rgb + (outlineColor.rgb * (1. - front.a)) * maxAlpha;\n gl_FragColor = vec4(resultColor, maxAlpha);\n } else {\n gl_FragColor = front;\n }\n}\n";
- var t = function(t) {
- void 0 === t && (t = .1);
- var n = Math.max(100 * t, 1),
- i = (2 * Math.PI / n).toFixed(7);
- return e.replace(/\#\{angleStep\}/, i)
- };
- const n = Phaser.Renderer.WebGL.Pipelines.PostFXPipeline,
- i = Phaser.Utils.Objects.GetValue,
- s = Phaser.Display.Color.IntegerToRGB,
- o = Phaser.Display.Color;
- var r = .1,
- l = t(r);
- class a extends n {
- constructor(e) {
- super({
- name: "rexOutlinePostFx",
- game: e,
- renderTarget: !0,
- fragShader: l
- }), this.thickness = 0, this._outlineColor = new o
- }
- resetFromJSON(e) {
- return this.setThickness(i(e, "thickness", 3)), this.setOutlineColor(i(e, "outlineColor", 16777215)), this
- }
- onPreRender() {
- this.set1f("thickness", this.thickness), this.set3f("outlineColor", this._outlineColor.redGL, this._outlineColor.greenGL, this._outlineColor.blueGL), this.set2f("texSize", this.renderer.width, this.renderer.height)
- }
- setThickness(e) {
- return this.thickness = e, this
- }
- get outlineColor() {
- return this._outlineColor
- }
- set outlineColor(e) {
- "number" == typeof e && (e = s(e)), this._outlineColor.setFromRGB(e)
- }
- setOutlineColor(e) {
- return this.outlineColor = e, this
- }
- static setQuality(e) {
- r !== e && (r = e, l = t(e))
- }
- static getQuality() {
- return r
- }
- }
- const u = Phaser.Game;
- var h = function(e) {
- return e instanceof u
- };
- const f = Phaser.Scene;
- var p = function(e) {
- return e instanceof f
- },
- c = function(e, t, n) {
- var i;
- (i = e, null == i || "object" != typeof i ? null : h(i) ? i : h(i.game) ? i.game : p(i) ? i.sys.game : p(i.scene) ? i.scene.sys.game : void 0).renderer.pipelines.addPostPipeline(t, n)
- };
- const d = Phaser.Utils.Array.SpliceOne;
- class g extends Phaser.Plugins.BasePlugin {
- setPostPipelineClass(e, t) {
- return this.PostFxPipelineClass = e, this.postFxPipelineName = t, this
- }
- start() {
- this.game.events.once("destroy", this.destroy, this), c(this.game, this.postFxPipelineName, this.PostFxPipelineClass)
- }
- add(e, t) {
- return function(e, t, n) {
- void 0 === n && (n = {}), e.setPostPipeline(t);
- var i = e.postPipelines[e.postPipelines.length - 1];
- return i.resetFromJSON(n), n.name && (i.name = n.name), i
- }(e, this.PostFxPipelineClass, t)
- }
- remove(e, t) {
- return function(e, t, n) {
- if (void 0 === n)
- for (var i = (s = e.postPipelines).length - 1; i >= 0; i--)(r = s[i]) instanceof t && (r.destroy(), d(s, i));
- else {
- i = 0;
- for (var s, o = (s = e.postPipelines).length; i < o; i++) {
- var r;
- (r = s[i]) instanceof t && r.name === n && (r.destroy(), d(s, i))
- }
- }
- e.hasPostPipeline = e.postPipelines.length > 0
- }(e, this.PostFxPipelineClass, t), this
- }
- get(e, t) {
- return function(e, t, n) {
- if (void 0 === n) {
- for (var i = [], s = 0, o = (r = e.postPipelines).length; s < o; s++)(l = r[s]) instanceof t && i.push(l);
- return i
- }
- var r;
- for (s = 0, o = (r = e.postPipelines).length; s < o; s++) {
- var l;
- if ((l = r[s]) instanceof t && l.name === n) return l
- }
- }(e, this.PostFxPipelineClass, t)
- }
- }
- var P = function(e) {
- return null == e || "" === e || 0 === e.length
- };
- const m = Phaser.Utils.Objects.GetValue;
- return function(e, t, n, i) {
- if (void 0 === i && (i = "."), "object" == typeof e)
- if (P(t)) {
- if (null == n) return;
- "object" == typeof n && (e = n)
- } else {
- "string" == typeof t && (t = t.split(i));
- var s = t.pop(),
- o = function(e, t, n) {
- var i = e;
- if (P(t));
- else {
- var s;
- "string" == typeof t && (t = t.split("."));
- for (var o = 0, r = t.length; o < r; o++) {
- var l;
- null != i[s = t[o]] && "object" == typeof i[s] || (l = o === r - 1 ? void 0 === n ? {} : n : {}, i[s] = l), i = i[s]
- }
- }
- return i
- }(e, t);
- o[s] = n
- }
- }(window, "RexPlugins.Pipelines.OutlinePostFx", a), class extends g {
- constructor(e) {
- super(e), this.setPostPipelineClass(a, "rexOutlinePostFx")
- }
- add(e, t) {
- return this.setQuality(m(t, "quality", this.quality)), super.add(e, t)
- }
- setQuality(e) {
- return a.setQuality(e), this
- }
- set quality(e) {
- this.setQuality(e)
- }
- get quality() {
- return a.getQuality()
- }
- }
- }, "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).rexoutlinepipelineplugin = t();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement