@babylonjs/post-processes 5.0.0-rc.0 → 5.0.0-rc.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"asciiArtPostProcess.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/asciiArt/asciiArtPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE,OAAO,0DAA0D,CAAC;AAClE,OAAO,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH;IAAyC,uCAAW;IAiBhD;;;;;;OAMG;IACH,6BAAY,IAAY,EAAE,IAAY,EAAE,IAAY,EAAE,KAA6B;QAA7B,sBAAA,EAAA,YAA6B;QAAnF,YACI,kBAAM,KAAK,CAAC,SAiDf;QA/CG,KAAK,GAAG,KAAI,CAAC,QAAQ,EAAE,CAAC;QAExB,IAAI,CAAC,KAAK,EAAE;;SAEX;QAED,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QACnB,KAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAEnB,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACvC,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACvC,qCAAqC;QAErC,8BAA8B;QAC9B,IAAI,aAAa,GAAG,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,YAAY,GAAG,KAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAE3C,KAAI,CAAC,SAAS,GAAG,IAAI,CA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,CAAC,WAAW,IAAI,KAAI,CAAC,WAAW,CAAC;aAC7F;SACJ;QAED,KAAI,CAAC,oBAAoB,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjG,IAAI,WAAW,GAAG,KAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QAEtD,KAAI,CAAC,OAAO,GAAG,UAAC,MAAc;YAC1B,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,KAAI,CAAC,oBAAoB,CAAC,CAAC;YAE7D,MAAM,CAAC,SAAS,CAAC,mBAAmB,EAChC,KAAI,CAAC,oBAAoB,CAAC,QAAQ,EAClC,YAAY,CAAC,MAAM,EACnB,WAAW,CAAC,KAAK,EACjB,WAAW,CAAC,MAAM,CAAC,CAAC;YAExB,MAAM,CAAC,SAAS,CAAC,iBAAiB,EAC9B,KAAI,CAAC,KAAK,EACV,KAAI,CAAC,MAAM,EACX,KAAI,CAAC,WAAW,EAChB,KAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC,CAAC;;IACN,CAAC;IACL,0BAAC;AAAD,CAAC,AA3ED,CAAyC,WAAW,GA2EnD","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { serialize, SerializationHelper } from \"@babylonjs/core/Misc/decorators\";\r\nimport { Camera } from \"@babylonjs/core/Cameras/camera\";\r\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\r\nimport { Effect } from \"@babylonjs/core/Materials/effect\";\r\nimport { PostProcess } from \"@babylonjs/core/PostProcesses/postProcess\";\r\nimport { Scene } from \"@babylonjs/core/scene\";\r\nimport \"@babylonjs/core/Engines/Extensions/engine.dynamicTexture\";\r\nimport \"./asciiart.fragment\";\r\n\r\n/**\r\n * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.\r\n *\r\n * It basically takes care rendering the font front the given font size to a texture.\r\n * This is used later on in the postprocess.\r\n */\r\nexport class AsciiArtFontTexture extends BaseTexture {\r\n\r\n @serialize(\"font\")\r\n private _font: string;\r\n\r\n @serialize(\"text\")\r\n private _text: string;\r\n\r\n private _charSize: number;\r\n\r\n /**\r\n * Gets the size of one char in the texture (each char fits in size * size space in the texture).\r\n */\r\n public get charSize(): number {\r\n return this._charSize;\r\n }\r\n\r\n /**\r\n * Create a new instance of the Ascii Art FontTexture class\r\n * @param name the name of the texture\r\n * @param font the font to use, use the W3C CSS notation\r\n * @param text the caracter set to use in the rendering.\r\n * @param scene the scene that owns the texture\r\n */\r\n constructor(name: string, font: string, text: string, scene: Nullable<Scene> = null) {\r\n super(scene);\r\n\r\n scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n this.name = name;\r\n this._text == text;\r\n this._font == font;\r\n\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n //this.anisotropicFilteringLevel = 1;\r\n\r\n // Get the font specific info.\r\n var maxCharHeight = this.getFontHeight(font);\r\n var maxCharWidth = this.getFontWidth(font);\r\n\r\n this._charSize = Math.max(maxCharHeight.height, maxCharWidth);\r\n\r\n // This is an approximate size, but should always be able to fit at least the maxCharCount.\r\n var textureWidth = Math.ceil(this._charSize * text.length);\r\n var textureHeight = this._charSize;\r\n\r\n // Create the texture that will store the font characters.\r\n this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, Texture.NEAREST_SAMPLINGMODE);\r\n //scene.getEngine().setclamp\r\n var textureSize = this.getSize();\r\n\r\n // Create a canvas with the final size: the one matching the texture.\r\n var canvas = document.createElement(\"canvas\");\r\n canvas.width = textureSize.width;\r\n canvas.height = textureSize.height;\r\n var context = <CanvasRenderingContext2D>canvas.getContext(\"2d\");\r\n context.textBaseline = \"top\";\r\n context.font = font;\r\n context.fillStyle = \"white\";\r\n context.imageSmoothingEnabled = false;\r\n\r\n // Sets the text in the texture.\r\n for (var i = 0; i < text.length; i++) {\r\n context.fillText(text[i], i * this._charSize, -maxCharHeight.offset);\r\n }\r\n\r\n // Flush the text in the dynamic texture.\r\n\r\n scene.getEngine().updateDynamicTexture(this._texture, canvas, false, true);\r\n }\r\n\r\n /**\r\n * Gets the max char width of a font.\r\n * @param font the font to use, use the W3C CSS notation\r\n * @return the max char width\r\n */\r\n private getFontWidth(font: string): number {\r\n var fontDraw = document.createElement(\"canvas\");\r\n var ctx = <CanvasRenderingContext2D>fontDraw.getContext('2d');\r\n ctx.fillStyle = 'white';\r\n ctx.font = font;\r\n\r\n return ctx.measureText(\"W\").width;\r\n }\r\n\r\n // More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/\r\n /**\r\n * Gets the max char height of a font.\r\n * @param font the font to use, use the W3C CSS notation\r\n * @return the max char height\r\n */\r\n private getFontHeight(font: string): { height: number, offset: number } {\r\n var fontDraw = document.createElement(\"canvas\");\r\n var ctx = <CanvasRenderingContext2D>fontDraw.getContext('2d');\r\n ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);\r\n ctx.textBaseline = 'top';\r\n ctx.fillStyle = 'white';\r\n ctx.font = font;\r\n ctx.fillText('jH|', 0, 0);\r\n var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;\r\n var start = -1;\r\n var end = -1;\r\n for (var row = 0; row < fontDraw.height; row++) {\r\n for (var column = 0; column < fontDraw.width; column++) {\r\n var index = (row * fontDraw.width + column) * 4;\r\n if (pixels[index] === 0) {\r\n if (column === fontDraw.width - 1 && start !== -1) {\r\n end = row;\r\n row = fontDraw.height;\r\n break;\r\n }\r\n continue;\r\n }\r\n else {\r\n if (start === -1) {\r\n start = row;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n return { height: (end - start) + 1, offset: start - 1 };\r\n }\r\n\r\n /**\r\n * Clones the current AsciiArtTexture.\r\n * @return the clone of the texture.\r\n */\r\n public clone(): AsciiArtFontTexture {\r\n return new AsciiArtFontTexture(this.name, this._font, this._text, this.getScene());\r\n }\r\n\r\n /**\r\n * Parses a json object representing the texture and returns an instance of it.\r\n * @param source the source JSON representation\r\n * @param scene the scene to create the texture for\r\n * @return the parsed texture\r\n */\r\n public static Parse(source: any, scene: Scene): AsciiArtFontTexture {\r\n var texture = SerializationHelper.Parse(() => new AsciiArtFontTexture(source.name, source.font, source.text, scene),\r\n source, scene, null);\r\n\r\n return texture;\r\n }\r\n}\r\n\r\n/**\r\n * Option available in the Ascii Art Post Process.\r\n */\r\nexport interface IAsciiArtPostProcessOptions {\r\n\r\n /**\r\n * The font to use following the w3c font definition.\r\n */\r\n font?: string;\r\n\r\n /**\r\n * The character set to use in the postprocess.\r\n */\r\n characterSet?: string;\r\n\r\n /**\r\n * This defines the amount you want to mix the \"tile\" or caracter space colored in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n mixToTile?: number;\r\n\r\n /**\r\n * This defines the amount you want to mix the normal rendering pass in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n mixToNormal?: number;\r\n}\r\n\r\n/**\r\n * AsciiArtPostProcess helps rendering everithing in Ascii Art.\r\n *\r\n * Simmply add it to your scene and let the nerd that lives in you have fun.\r\n * Example usage: var pp = new AsciiArtPostProcess(\"myAscii\", \"20px Monospace\", camera);\r\n */\r\nexport class AsciiArtPostProcess extends PostProcess {\r\n\r\n /**\r\n * The font texture used to render the char in the post process.\r\n */\r\n private _asciiArtFontTexture: AsciiArtFontTexture;\r\n\r\n /**\r\n * This defines the amount you want to mix the \"tile\" or caracter space colored in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n public mixToTile: number = 0;\r\n\r\n /**\r\n * This defines the amount you want to mix the normal rendering pass in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n public mixToNormal: number = 0;\r\n\r\n /**\r\n * Instantiates a new Ascii Art Post Process.\r\n * @param name the name to give to the postprocess\r\n * @camera the camera to apply the post process to.\r\n * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format\r\n */\r\n constructor(name: string, camera: Camera, options?: string | IAsciiArtPostProcessOptions) {\r\n super(name,\r\n 'asciiart',\r\n ['asciiArtFontInfos', 'asciiArtOptions'],\r\n ['asciiArtFont'],\r\n {\r\n width: camera.getEngine().getRenderWidth(),\r\n height: camera.getEngine().getRenderHeight()\r\n },\r\n camera,\r\n Texture.TRILINEAR_SAMPLINGMODE,\r\n camera.getEngine(),\r\n true);\r\n\r\n // Default values.\r\n var font = \"40px Monospace\";\r\n var characterSet = \" `-.'_:,\\\"=^;<+!*?/cL\\\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@\";\r\n\r\n // Use options.\r\n if (options) {\r\n if (typeof (options) === \"string\") {\r\n font = <string>options;\r\n }\r\n else {\r\n font = (<IAsciiArtPostProcessOptions>options).font || font;\r\n characterSet = (<IAsciiArtPostProcessOptions>options).characterSet || characterSet;\r\n this.mixToTile = (<IAsciiArtPostProcessOptions>options).mixToTile || this.mixToTile;\r\n this.mixToNormal = (<IAsciiArtPostProcessOptions>options).mixToNormal || this.mixToNormal;\r\n }\r\n }\r\n\r\n this._asciiArtFontTexture = new AsciiArtFontTexture(name, font, characterSet, camera.getScene());\r\n var textureSize = this._asciiArtFontTexture.getSize();\r\n\r\n this.onApply = (effect: Effect) => {\r\n effect.setTexture(\"asciiArtFont\", this._asciiArtFontTexture);\r\n\r\n effect.setFloat4(\"asciiArtFontInfos\",\r\n this._asciiArtFontTexture.charSize,\r\n characterSet.length,\r\n textureSize.width,\r\n textureSize.height);\r\n\r\n effect.setFloat4(\"asciiArtOptions\",\r\n this.width,\r\n this.height,\r\n this.mixToNormal,\r\n this.mixToTile);\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"asciiArtPostProcess.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/asciiArt/asciiArtPostProcess.ts"],"names":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AAc,EAAE,KAAI,CAAC,oBAAoB,CAAC,CAAC;YAE7D,MAAM,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;YAEtI,MAAM,CAAC,SAAS,CAAC,iBAAiB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,MAAM,EAAE,KAAI,CAAC,WAAW,EAAE,KAAI,CAAC,SAAS,CAAC,CAAC;QACnG,CAAC,CAAC;;IACN,CAAC;IACL,0BAAC;AAAD,CAAC,AApED,CAAyC,WAAW,GAoEnD","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport type { Scene } from \"core/scene\";\r\nimport \"core/Engines/Extensions/engine.dynamicTexture\";\r\nimport \"./asciiart.fragment\";\r\n\r\n/**\r\n * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.\r\n *\r\n * It basically takes care rendering the font front the given font size to a texture.\r\n * This is used later on in the postprocess.\r\n */\r\nexport class AsciiArtFontTexture extends BaseTexture {\r\n @serialize(\"font\")\r\n private _font: string;\r\n\r\n @serialize(\"text\")\r\n private _text: string;\r\n\r\n private _charSize: number;\r\n\r\n /**\r\n * Gets the size of one char in the texture (each char fits in size * size space in the texture).\r\n */\r\n public get charSize(): number {\r\n return this._charSize;\r\n }\r\n\r\n /**\r\n * Create a new instance of the Ascii Art FontTexture class\r\n * @param name the name of the texture\r\n * @param font the font to use, use the W3C CSS notation\r\n * @param text the caracter set to use in the rendering.\r\n * @param scene the scene that owns the texture\r\n */\r\n constructor(name: string, font: string, text: string, scene: Nullable<Scene> = null) {\r\n super(scene);\r\n\r\n scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n this.name = name;\r\n this._text == text;\r\n this._font == font;\r\n\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n //this.anisotropicFilteringLevel = 1;\r\n\r\n // Get the font specific info.\r\n const maxCharHeight = this._getFontHeight(font);\r\n const maxCharWidth = this._getFontWidth(font);\r\n\r\n this._charSize = Math.max(maxCharHeight.height, maxCharWidth);\r\n\r\n // This is an approximate size, but should always be able to fit at least the maxCharCount.\r\n const textureWidth = Math.ceil(this._charSize * text.length);\r\n const textureHeight = this._charSize;\r\n\r\n // Create the texture that will store the font characters.\r\n this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, Texture.NEAREST_SAMPLINGMODE);\r\n //scene.getEngine().setclamp\r\n const textureSize = this.getSize();\r\n\r\n // Create a canvas with the final size: the one matching the texture.\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = textureSize.width;\r\n canvas.height = textureSize.height;\r\n const context = <CanvasRenderingContext2D>canvas.getContext(\"2d\");\r\n context.textBaseline = \"top\";\r\n context.font = font;\r\n context.fillStyle = \"white\";\r\n context.imageSmoothingEnabled = false;\r\n\r\n // Sets the text in the texture.\r\n for (let i = 0; i < text.length; i++) {\r\n context.fillText(text[i], i * this._charSize, -maxCharHeight.offset);\r\n }\r\n\r\n // Flush the text in the dynamic texture.\r\n\r\n scene.getEngine().updateDynamicTexture(this._texture, canvas, false, true);\r\n }\r\n\r\n /**\r\n * Gets the max char width of a font.\r\n * @param font the font to use, use the W3C CSS notation\r\n * @return the max char width\r\n */\r\n private _getFontWidth(font: string): number {\r\n const fontDraw = document.createElement(\"canvas\");\r\n const ctx = <CanvasRenderingContext2D>fontDraw.getContext(\"2d\");\r\n ctx.fillStyle = \"white\";\r\n ctx.font = font;\r\n\r\n return ctx.measureText(\"W\").width;\r\n }\r\n\r\n // More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/\r\n /**\r\n * Gets the max char height of a font.\r\n * @param font the font to use, use the W3C CSS notation\r\n * @return the max char height\r\n */\r\n private _getFontHeight(font: string): { height: number; offset: number } {\r\n const fontDraw = document.createElement(\"canvas\");\r\n const ctx = <CanvasRenderingContext2D>fontDraw.getContext(\"2d\");\r\n ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"white\";\r\n ctx.font = font;\r\n ctx.fillText(\"jH|\", 0, 0);\r\n const pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;\r\n let start = -1;\r\n let end = -1;\r\n for (let row = 0; row < fontDraw.height; row++) {\r\n for (let column = 0; column < fontDraw.width; column++) {\r\n const index = (row * fontDraw.width + column) * 4;\r\n if (pixels[index] === 0) {\r\n if (column === fontDraw.width - 1 && start !== -1) {\r\n end = row;\r\n row = fontDraw.height;\r\n break;\r\n }\r\n continue;\r\n } else {\r\n if (start === -1) {\r\n start = row;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n return { height: end - start + 1, offset: start - 1 };\r\n }\r\n\r\n /**\r\n * Clones the current AsciiArtTexture.\r\n * @return the clone of the texture.\r\n */\r\n public clone(): AsciiArtFontTexture {\r\n return new AsciiArtFontTexture(this.name, this._font, this._text, this.getScene());\r\n }\r\n\r\n /**\r\n * Parses a json object representing the texture and returns an instance of it.\r\n * @param source the source JSON representation\r\n * @param scene the scene to create the texture for\r\n * @return the parsed texture\r\n */\r\n public static Parse(source: any, scene: Scene): AsciiArtFontTexture {\r\n const texture = SerializationHelper.Parse(() => new AsciiArtFontTexture(source.name, source.font, source.text, scene), source, scene, null);\r\n\r\n return texture;\r\n }\r\n}\r\n\r\n/**\r\n * Option available in the Ascii Art Post Process.\r\n */\r\nexport interface IAsciiArtPostProcessOptions {\r\n /**\r\n * The font to use following the w3c font definition.\r\n */\r\n font?: string;\r\n\r\n /**\r\n * The character set to use in the postprocess.\r\n */\r\n characterSet?: string;\r\n\r\n /**\r\n * This defines the amount you want to mix the \"tile\" or caracter space colored in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n mixToTile?: number;\r\n\r\n /**\r\n * This defines the amount you want to mix the normal rendering pass in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n mixToNormal?: number;\r\n}\r\n\r\n/**\r\n * AsciiArtPostProcess helps rendering everithing in Ascii Art.\r\n *\r\n * Simmply add it to your scene and let the nerd that lives in you have fun.\r\n * Example usage: var pp = new AsciiArtPostProcess(\"myAscii\", \"20px Monospace\", camera);\r\n */\r\nexport class AsciiArtPostProcess extends PostProcess {\r\n /**\r\n * The font texture used to render the char in the post process.\r\n */\r\n private _asciiArtFontTexture: AsciiArtFontTexture;\r\n\r\n /**\r\n * This defines the amount you want to mix the \"tile\" or caracter space colored in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n public mixToTile: number = 0;\r\n\r\n /**\r\n * This defines the amount you want to mix the normal rendering pass in the ascii art.\r\n * This number is defined between 0 and 1;\r\n */\r\n public mixToNormal: number = 0;\r\n\r\n /**\r\n * Instantiates a new Ascii Art Post Process.\r\n * @param name the name to give to the postprocess\r\n * @camera the camera to apply the post process to.\r\n * @param camera\r\n * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format\r\n */\r\n constructor(name: string, camera: Camera, options?: string | IAsciiArtPostProcessOptions) {\r\n super(\r\n name,\r\n \"asciiart\",\r\n [\"asciiArtFontInfos\", \"asciiArtOptions\"],\r\n [\"asciiArtFont\"],\r\n {\r\n width: camera.getEngine().getRenderWidth(),\r\n height: camera.getEngine().getRenderHeight(),\r\n },\r\n camera,\r\n Texture.TRILINEAR_SAMPLINGMODE,\r\n camera.getEngine(),\r\n true\r\n );\r\n\r\n // Default values.\r\n let font = \"40px Monospace\";\r\n let characterSet = \" `-.'_:,\\\"=^;<+!*?/cL\\\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@\";\r\n\r\n // Use options.\r\n if (options) {\r\n if (typeof options === \"string\") {\r\n font = <string>options;\r\n } else {\r\n font = (<IAsciiArtPostProcessOptions>options).font || font;\r\n characterSet = (<IAsciiArtPostProcessOptions>options).characterSet || characterSet;\r\n this.mixToTile = (<IAsciiArtPostProcessOptions>options).mixToTile || this.mixToTile;\r\n this.mixToNormal = (<IAsciiArtPostProcessOptions>options).mixToNormal || this.mixToNormal;\r\n }\r\n }\r\n\r\n this._asciiArtFontTexture = new AsciiArtFontTexture(name, font, characterSet, camera.getScene());\r\n const textureSize = this._asciiArtFontTexture.getSize();\r\n\r\n this.onApply = (effect: Effect) => {\r\n effect.setTexture(\"asciiArtFont\", this._asciiArtFontTexture);\r\n\r\n effect.setFloat4(\"asciiArtFontInfos\", this._asciiArtFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);\r\n\r\n effect.setFloat4(\"asciiArtOptions\", this.width, this.height, this.mixToNormal, this.mixToTile);\r\n };\r\n }\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
- /** @hidden */
2
- export declare var asciiartPixelShader: {
3
- name: string;
4
- shader: string;
5
- };
1
+ /** @hidden */
2
+ export declare const asciiartPixelShader: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -1,7 +1,9 @@
1
- import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
2
- var name = 'asciiartPixelShader';
3
- var shader = "\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}";
4
- ShaderStore.ShadersStore[name] = shader;
5
- /** @hidden */
6
- export var asciiartPixelShader = { name: name, shader: shader };
1
+ // Do not edit.
2
+ import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
+ var name = "asciiartPixelShader";
4
+ var shader = "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;}";
5
+ // Sideeffect
6
+ ShaderStore.ShadersStore[name] = shader;
7
+ /** @hidden */
8
+ export var asciiartPixelShader = { name: name, shader: shader };
7
9
  //# sourceMappingURL=asciiart.fragment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asciiart.fragment.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/asciiArt/asciiart.fragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,IAAI,IAAI,GAAG,qBAAqB,CAAC;AACjC,IAAI,MAAM,GAAG,40CAsCX,CAAC;AAEH,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAI,mBAAmB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["import { ShaderStore } from \"@babylonjs/core/Engines/shaderStore\";\n\nlet name = 'asciiartPixelShader';\nlet shader = `\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}`;\n\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport var asciiartPixelShader = { name, shader };\n"]}
1
+ {"version":3,"file":"asciiart.fragment.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/asciiArt/asciiart.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,IAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,IAAM,MAAM,GAAG,4wCAI09B,CAAC;AAC1+B,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAM,mBAAmB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"asciiartPixelShader\";\nconst shader = `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;}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const asciiartPixelShader = { name, shader };\n"]}
@@ -1 +1 @@
1
- export * from "./asciiArtPostProcess";
1
+ export * from "./asciiArtPostProcess";
package/asciiArt/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./asciiArtPostProcess.js";
1
+ export * from "./asciiArtPostProcess";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/asciiArt/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./asciiArtPostProcess\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/asciiArt/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./asciiArtPostProcess\";\r\n"]}
@@ -1,106 +1,107 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { Camera } from "@babylonjs/core/Cameras/camera";
3
- import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture";
4
- import { PostProcess } from "@babylonjs/core/PostProcesses/postProcess";
5
- import { Scene } from "@babylonjs/core/scene";
6
- import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture";
7
- import "./digitalrain.fragment";
8
- /**
9
- * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
10
- *
11
- * It basically takes care rendering the font front the given font size to a texture.
12
- * This is used later on in the postprocess.
13
- */
14
- export declare class DigitalRainFontTexture extends BaseTexture {
15
- private _font;
16
- private _text;
17
- private _charSize;
18
- /**
19
- * Gets the size of one char in the texture (each char fits in size * size space in the texture).
20
- */
21
- get charSize(): number;
22
- /**
23
- * Create a new instance of the Digital Rain FontTexture class
24
- * @param name the name of the texture
25
- * @param font the font to use, use the W3C CSS notation
26
- * @param text the caracter set to use in the rendering.
27
- * @param scene the scene that owns the texture
28
- */
29
- constructor(name: string, font: string, text: string, scene?: Nullable<Scene>);
30
- /**
31
- * Gets the max char width of a font.
32
- * @param font the font to use, use the W3C CSS notation
33
- * @return the max char width
34
- */
35
- private getFontWidth;
36
- /**
37
- * Gets the max char height of a font.
38
- * @param font the font to use, use the W3C CSS notation
39
- * @return the max char height
40
- */
41
- private getFontHeight;
42
- /**
43
- * Clones the current DigitalRainFontTexture.
44
- * @return the clone of the texture.
45
- */
46
- clone(): DigitalRainFontTexture;
47
- /**
48
- * Parses a json object representing the texture and returns an instance of it.
49
- * @param source the source JSON representation
50
- * @param scene the scene to create the texture for
51
- * @return the parsed texture
52
- */
53
- static Parse(source: any, scene: Scene): DigitalRainFontTexture;
54
- }
55
- /**
56
- * Option available in the Digital Rain Post Process.
57
- */
58
- export interface IDigitalRainPostProcessOptions {
59
- /**
60
- * The font to use following the w3c font definition.
61
- */
62
- font?: string;
63
- /**
64
- * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
65
- * This number is defined between 0 and 1;
66
- */
67
- mixToTile?: number;
68
- /**
69
- * This defines the amount you want to mix the normal rendering pass in the digital rain.
70
- * This number is defined between 0 and 1;
71
- */
72
- mixToNormal?: number;
73
- }
74
- /**
75
- * DigitalRainPostProcess helps rendering everithing in digital rain.
76
- *
77
- * Simmply add it to your scene and let the nerd that lives in you have fun.
78
- * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
79
- */
80
- export declare class DigitalRainPostProcess extends PostProcess {
81
- /**
82
- * The font texture used to render the char in the post process.
83
- */
84
- private _digitalRainFontTexture;
85
- /**
86
- * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
87
- * This number is defined between 0 and 1;
88
- */
89
- mixToTile: number;
90
- /**
91
- * This defines the amount you want to mix the normal rendering pass in the digital rain.
92
- * This number is defined between 0 and 1;
93
- */
94
- mixToNormal: number;
95
- /**
96
- * Speed of the effect
97
- */
98
- speed: number;
99
- /**
100
- * Instantiates a new Digital Rain Post Process.
101
- * @param name the name to give to the postprocess
102
- * @camera the camera to apply the post process to.
103
- * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
104
- */
105
- constructor(name: string, camera: Camera, options?: string | IDigitalRainPostProcessOptions);
106
- }
1
+ import type { Nullable } from "@babylonjs/core/types.js";
2
+ import type { Camera } from "@babylonjs/core/Cameras/camera.js";
3
+ import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
4
+ import { PostProcess } from "@babylonjs/core/PostProcesses/postProcess.js";
5
+ import type { Scene } from "@babylonjs/core/scene.js";
6
+ import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
7
+ import "./digitalrain.fragment";
8
+ /**
9
+ * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
10
+ *
11
+ * It basically takes care rendering the font front the given font size to a texture.
12
+ * This is used later on in the postprocess.
13
+ */
14
+ export declare class DigitalRainFontTexture extends BaseTexture {
15
+ private _font;
16
+ private _text;
17
+ private _charSize;
18
+ /**
19
+ * Gets the size of one char in the texture (each char fits in size * size space in the texture).
20
+ */
21
+ get charSize(): number;
22
+ /**
23
+ * Create a new instance of the Digital Rain FontTexture class
24
+ * @param name the name of the texture
25
+ * @param font the font to use, use the W3C CSS notation
26
+ * @param text the caracter set to use in the rendering.
27
+ * @param scene the scene that owns the texture
28
+ */
29
+ constructor(name: string, font: string, text: string, scene?: Nullable<Scene>);
30
+ /**
31
+ * Gets the max char width of a font.
32
+ * @param font the font to use, use the W3C CSS notation
33
+ * @return the max char width
34
+ */
35
+ private _getFontWidth;
36
+ /**
37
+ * Gets the max char height of a font.
38
+ * @param font the font to use, use the W3C CSS notation
39
+ * @return the max char height
40
+ */
41
+ private _getFontHeight;
42
+ /**
43
+ * Clones the current DigitalRainFontTexture.
44
+ * @return the clone of the texture.
45
+ */
46
+ clone(): DigitalRainFontTexture;
47
+ /**
48
+ * Parses a json object representing the texture and returns an instance of it.
49
+ * @param source the source JSON representation
50
+ * @param scene the scene to create the texture for
51
+ * @return the parsed texture
52
+ */
53
+ static Parse(source: any, scene: Scene): DigitalRainFontTexture;
54
+ }
55
+ /**
56
+ * Option available in the Digital Rain Post Process.
57
+ */
58
+ export interface IDigitalRainPostProcessOptions {
59
+ /**
60
+ * The font to use following the w3c font definition.
61
+ */
62
+ font?: string;
63
+ /**
64
+ * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
65
+ * This number is defined between 0 and 1;
66
+ */
67
+ mixToTile?: number;
68
+ /**
69
+ * This defines the amount you want to mix the normal rendering pass in the digital rain.
70
+ * This number is defined between 0 and 1;
71
+ */
72
+ mixToNormal?: number;
73
+ }
74
+ /**
75
+ * DigitalRainPostProcess helps rendering everithing in digital rain.
76
+ *
77
+ * Simmply add it to your scene and let the nerd that lives in you have fun.
78
+ * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
79
+ */
80
+ export declare class DigitalRainPostProcess extends PostProcess {
81
+ /**
82
+ * The font texture used to render the char in the post process.
83
+ */
84
+ private _digitalRainFontTexture;
85
+ /**
86
+ * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
87
+ * This number is defined between 0 and 1;
88
+ */
89
+ mixToTile: number;
90
+ /**
91
+ * This defines the amount you want to mix the normal rendering pass in the digital rain.
92
+ * This number is defined between 0 and 1;
93
+ */
94
+ mixToNormal: number;
95
+ /**
96
+ * Speed of the effect
97
+ */
98
+ speed: number;
99
+ /**
100
+ * Instantiates a new Digital Rain Post Process.
101
+ * @param name the name to give to the postprocess
102
+ * @camera the camera to apply the post process to.
103
+ * @param camera
104
+ * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
105
+ */
106
+ constructor(name: string, camera: Camera, options?: string | IDigitalRainPostProcessOptions);
107
+ }