@babylonjs/post-processes 7.34.4 → 7.35.1
Sign up to get free protection for your applications and to get access to all the features.
- package/asciiArt/asciiArtPostProcess.js.map +1 -1
- package/digitalRain/digitalRainPostProcess.js.map +1 -1
- package/edgeDetection/edgeDetectionPostProcess.js.map +1 -1
- package/legacy/legacy-asciiArt.js.map +1 -1
- package/legacy/legacy-digitalRain.js.map +1 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"asciiArtPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/asciiArt/asciiArtPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,2CAA6B;AACjD,OAAO,EAAE,mBAAmB,EAAE,yDAA2C;AAEzE,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAClE,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAE1D,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,qEAAuD;AACvD,OAAO,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAShD;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI;QAC/E,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAExB,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAEnB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACvC,qCAAqC;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CAAC,oBAAoB,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QACrF,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QAExD,IAAI,CAAC,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YAC9B,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAE7D,MAAM,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,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,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACnG,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\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 * @returns 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 * @returns 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 * @returns the clone of the texture.\r\n */\r\n public override 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 * @returns 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: Nullable<Camera>, options?: string | IAsciiArtPostProcessOptions) {\r\n super(name, \"asciiart\", [\"asciiArtFontInfos\", \"asciiArtOptions\"], [\"asciiArtFont\"], 1, camera, Texture.TRILINEAR_SAMPLINGMODE, undefined, true);\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 const scene = camera?.getScene() || this._scene;\r\n this._asciiArtFontTexture = new AsciiArtFontTexture(name, font, characterSet, scene);\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
|
+
{"version":3,"file":"asciiArtPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/asciiArt/asciiArtPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,2CAA6B;AACjD,OAAO,EAAE,mBAAmB,EAAE,yDAA2C;AAEzE,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAClE,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAE1D,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,qEAAuD;AACvD,OAAO,qBAAqB,CAAC;AAE7B;;;;;GAKG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,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACnG,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\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 * @returns 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 * @returns 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 * @returns the clone of the texture.\r\n */\r\n public override 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 * @returns 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: Nullable<Camera>, options?: string | IAsciiArtPostProcessOptions) {\r\n super(name, \"asciiart\", [\"asciiArtFontInfos\", \"asciiArtOptions\"], [\"asciiArtFont\"], 1, camera, Texture.TRILINEAR_SAMPLINGMODE, undefined, true);\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 const scene = camera?.getScene() || this._scene;\r\n this._asciiArtFontTexture = new AsciiArtFontTexture(name, font, characterSet, scene);\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 +1 @@
|
|
1
|
-
{"version":3,"file":"digitalRainPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/digitalRain/digitalRainPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,2CAA6B;AACjD,OAAO,EAAE,mBAAmB,EAAE,yDAA2C;AACzE,OAAO,EAAE,MAAM,EAAE,6CAA+B;AAEhD,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAClE,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAE1D,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,qEAAuD;AACvD,OAAO,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IASnD;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI;QAC/E,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAExB,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAEnB,I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AAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAElG,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAExC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;YACpB,cAAc,GAAG,KAAK,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QACtD,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Matrix } from \"core/Maths/math.vector\";\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 \"./digitalrain.fragment\";\r\n\r\n/**\r\n * DigitalRainFontTexture is the helper class used to easily create your digital rain 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 DigitalRainFontTexture 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 Digital Rain 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\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 = this._charSize;\r\n const textureHeight = Math.ceil(this._charSize * text.length);\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], 0, i * this._charSize - maxCharHeight.offset);\r\n }\r\n\r\n // Flush the text in the dynamic texture.\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 * @returns 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 * @returns 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 DigitalRainFontTexture.\r\n * @returns the clone of the texture.\r\n */\r\n public override clone(): DigitalRainFontTexture {\r\n return new DigitalRainFontTexture(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 * @returns the parsed texture\r\n */\r\n public static Parse(source: any, scene: Scene): DigitalRainFontTexture {\r\n const texture = SerializationHelper.Parse(() => new DigitalRainFontTexture(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 Digital Rain Post Process.\r\n */\r\nexport interface IDigitalRainPostProcessOptions {\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 * This defines the amount you want to mix the \"tile\" or caracter space colored in the digital rain.\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 digital rain.\r\n * This number is defined between 0 and 1;\r\n */\r\n mixToNormal?: number;\r\n}\r\n\r\n/**\r\n * DigitalRainPostProcess helps rendering everithing in digital rain.\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 DigitalRainPostProcess(\"digitalRain\", \"20px Monospace\", camera);\r\n */\r\nexport class DigitalRainPostProcess extends PostProcess {\r\n /**\r\n * The font texture used to render the char in the post process.\r\n */\r\n private _digitalRainFontTexture: DigitalRainFontTexture;\r\n\r\n /**\r\n * This defines the amount you want to mix the \"tile\" or caracter space colored in the digital rain.\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 digital rain.\r\n * This number is defined between 0 and 1;\r\n */\r\n public mixToNormal: number = 0;\r\n\r\n /**\r\n * Speed of the effect\r\n */\r\n public speed: number = 0.003;\r\n\r\n /**\r\n * Instantiates a new Digital Rain 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 IDigitalRainPostProcessOptions format\r\n */\r\n constructor(name: string, camera: Nullable<Camera>, options?: string | IDigitalRainPostProcessOptions) {\r\n super(\r\n name,\r\n \"digitalrain\",\r\n [\"digitalRainFontInfos\", \"digitalRainOptions\", \"cosTimeZeroOne\", \"matrixSpeed\"],\r\n [\"digitalRainFont\"],\r\n 1.0,\r\n camera,\r\n Texture.TRILINEAR_SAMPLINGMODE,\r\n undefined,\r\n true\r\n );\r\n\r\n // Default values.\r\n let font = \"15px Monospace\";\r\n const characterSet =\r\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 = (<IDigitalRainPostProcessOptions>options).font || font;\r\n this.mixToTile = (<IDigitalRainPostProcessOptions>options).mixToTile || this.mixToTile;\r\n this.mixToNormal = (<IDigitalRainPostProcessOptions>options).mixToNormal || this.mixToNormal;\r\n }\r\n }\r\n\r\n const scene = camera?.getScene() || null;\r\n this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, scene);\r\n const textureSize = this._digitalRainFontTexture.getSize();\r\n\r\n let alpha = 0.0;\r\n let cosTimeZeroOne = 0.0;\r\n const matrix = Matrix.FromValues(\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random()\r\n );\r\n\r\n this.onApply = (effect: Effect) => {\r\n effect.setTexture(\"digitalRainFont\", this._digitalRainFontTexture);\r\n\r\n effect.setFloat4(\"digitalRainFontInfos\", this._digitalRainFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);\r\n\r\n effect.setFloat4(\"digitalRainOptions\", this.width, this.height, this.mixToNormal, this.mixToTile);\r\n\r\n effect.setMatrix(\"matrixSpeed\", matrix);\r\n\r\n alpha += this.speed;\r\n cosTimeZeroOne = alpha;\r\n effect.setFloat(\"cosTimeZeroOne\", cosTimeZeroOne);\r\n };\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"digitalRainPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/digitalRain/digitalRainPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,2CAA6B;AACjD,OAAO,EAAE,mBAAmB,EAAE,yDAA2C;AACzE,OAAO,EAAE,MAAM,EAAE,6CAA+B;AAEhD,OAAO,EAAE,WAAW,EA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AC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,EACb,IAAI,CAAC,MAAM,EAAE,CAChB,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YAC9B,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;YAEnE,MAAM,CAAC,SAAS,CAAC,sBAAsB,EAAE,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;YAE5I,MAAM,CAAC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAElG,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAExC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;YACpB,cAAc,GAAG,KAAK,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QACtD,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Matrix } from \"core/Maths/math.vector\";\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 \"./digitalrain.fragment\";\r\n\r\n/**\r\n * DigitalRainFontTexture is the helper class used to easily create your digital rain 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 DigitalRainFontTexture 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 Digital Rain 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\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 = this._charSize;\r\n const textureHeight = Math.ceil(this._charSize * text.length);\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], 0, i * this._charSize - maxCharHeight.offset);\r\n }\r\n\r\n // Flush the text in the dynamic texture.\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 * @returns 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 * @returns 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 DigitalRainFontTexture.\r\n * @returns the clone of the texture.\r\n */\r\n public override clone(): DigitalRainFontTexture {\r\n return new DigitalRainFontTexture(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 * @returns the parsed texture\r\n */\r\n public static Parse(source: any, scene: Scene): DigitalRainFontTexture {\r\n const texture = SerializationHelper.Parse(() => new DigitalRainFontTexture(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 Digital Rain Post Process.\r\n */\r\nexport interface IDigitalRainPostProcessOptions {\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 * This defines the amount you want to mix the \"tile\" or caracter space colored in the digital rain.\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 digital rain.\r\n * This number is defined between 0 and 1;\r\n */\r\n mixToNormal?: number;\r\n}\r\n\r\n/**\r\n * DigitalRainPostProcess helps rendering everithing in digital rain.\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 DigitalRainPostProcess(\"digitalRain\", \"20px Monospace\", camera);\r\n */\r\nexport class DigitalRainPostProcess extends PostProcess {\r\n /**\r\n * The font texture used to render the char in the post process.\r\n */\r\n private _digitalRainFontTexture: DigitalRainFontTexture;\r\n\r\n /**\r\n * This defines the amount you want to mix the \"tile\" or caracter space colored in the digital rain.\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 digital rain.\r\n * This number is defined between 0 and 1;\r\n */\r\n public mixToNormal: number = 0;\r\n\r\n /**\r\n * Speed of the effect\r\n */\r\n public speed: number = 0.003;\r\n\r\n /**\r\n * Instantiates a new Digital Rain 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 IDigitalRainPostProcessOptions format\r\n */\r\n constructor(name: string, camera: Nullable<Camera>, options?: string | IDigitalRainPostProcessOptions) {\r\n super(\r\n name,\r\n \"digitalrain\",\r\n [\"digitalRainFontInfos\", \"digitalRainOptions\", \"cosTimeZeroOne\", \"matrixSpeed\"],\r\n [\"digitalRainFont\"],\r\n 1.0,\r\n camera,\r\n Texture.TRILINEAR_SAMPLINGMODE,\r\n undefined,\r\n true\r\n );\r\n\r\n // Default values.\r\n let font = \"15px Monospace\";\r\n const characterSet =\r\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 = (<IDigitalRainPostProcessOptions>options).font || font;\r\n this.mixToTile = (<IDigitalRainPostProcessOptions>options).mixToTile || this.mixToTile;\r\n this.mixToNormal = (<IDigitalRainPostProcessOptions>options).mixToNormal || this.mixToNormal;\r\n }\r\n }\r\n\r\n const scene = camera?.getScene() || null;\r\n this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, scene);\r\n const textureSize = this._digitalRainFontTexture.getSize();\r\n\r\n let alpha = 0.0;\r\n let cosTimeZeroOne = 0.0;\r\n const matrix = Matrix.FromValues(\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random(),\r\n Math.random()\r\n );\r\n\r\n this.onApply = (effect: Effect) => {\r\n effect.setTexture(\"digitalRainFont\", this._digitalRainFontTexture);\r\n\r\n effect.setFloat4(\"digitalRainFontInfos\", this._digitalRainFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);\r\n\r\n effect.setFloat4(\"digitalRainOptions\", this.width, this.height, this.mixToNormal, this.mixToTile);\r\n\r\n effect.setMatrix(\"matrixSpeed\", matrix);\r\n\r\n alpha += this.speed;\r\n cosTimeZeroOne = alpha;\r\n effect.setFloat(\"cosTimeZeroOne\", cosTimeZeroOne);\r\n };\r\n }\r\n}\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"edgeDetectionPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/edgeDetection/edgeDetectionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAI1C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAC7D,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,2EAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,SAAS,EAAE,2CAA6B;AACjD,OAAO,EAAE,mBAAmB,EAAE,yDAA2C;AACzE,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,mBAAmB,EAAE,kEAAoD;AAElF,OAAO,0BAA0B,CAAC;AAElC;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,WAAW;IAiCrD;;;OAGG;IACa,YAAY;QACxB,OAAO,0BAA0B,CAAC;IACtC,CAAC;IAED;;;;;;;;;OASG;IACH,YACI,IAAY,EACZ,KAAY,EACZ,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,QA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IAAI,CAAC,UAAU,CAAC,CAAC;YACjD,CAAC,CAAC;SACL;IACL,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,MAAM,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,oBAAoB,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,MAAM,CAAU,MAAM,CAAC,iBAAsB,EAAE,YAAoB,EAAE,KAAY,EAAE,OAAe;QACrG,OAAO,mBAAmB,CAAC,KAAK,CAC5B,GAAG,EAAE,CACD,IAAI,wBAAwB,CACxB,iBAAiB,CAAC,IAAI,EACtB,KAAK,EACL,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,iBAAiB,CAAC,WAAW,EAC7B,iBAAiB,CAAC,QAAQ,CAC7B,EACL,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AApJU;IADN,SAAS,EAAE;2DACmC;AAQxC;IADN,SAAS,EAAE;+DACuB;AAQ5B;IADN,SAAS,EAAE;2DACmB;AAQxB;IADN,SAAS,EAAE;4DACkB;AA8HlC,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport type { PostProcessOptions } from \"core/PostProcesses/postProcess\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport \"core/Rendering/geometryBufferRendererSceneComponent\";\r\nimport type { GeometryBufferRenderer } from \"core/Rendering/geometryBufferRenderer\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport \"./edgeDetection.fragment\";\r\n\r\n/**\r\n * The Edge Detection effect highlights the edges of objects in the scene like a toon.\r\n * This can be used for stylized rendering, outlining, or visual effects that require edge enhancement.\r\n */\r\nexport class EdgeDetectionPostProcess extends PostProcess {\r\n /**\r\n * Defines the color of the detected edges.\r\n */\r\n @serialize()\r\n public edgeColor: Color3 = new Color3(0, 0, 0);\r\n\r\n /**\r\n * Defines the intensity of the detected edges.\r\n * Higher values result in more pronounced edges.\r\n * default: 0.2 (min:0, max:1)\r\n */\r\n @serialize()\r\n public edgeIntensity: number = 0.2;\r\n\r\n /**\r\n * Defines the width of the detected edges.\r\n * Higher values result in thicker edges.\r\n * default: 0.2 (min:0.125, max:1)\r\n */\r\n @serialize()\r\n public edgeWidth: number = 0.2;\r\n\r\n /**\r\n * Defines the render mode.\r\n * default: 0\r\n * 0: general, 1: normal, 2: depth, 3: outline only\r\n */\r\n @serialize()\r\n public renderMode: number = 0;\r\n\r\n private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;\r\n\r\n /**\r\n * Get the current class name of the current effect\r\n * @returns \"EdgeDetectionPostProcess\"\r\n */\r\n public override getClassName(): string {\r\n return \"EdgeDetectionPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance of EdgeDetectionPostProcess.\r\n * @param name The name of the effect.\r\n * @param scene The scene where the edge detection post-process will be applied.\r\n * @param options The required width/height ratio or specific options for the post-process.\r\n * @param camera The camera to apply the post-process to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: TEXTURE_NEAREST_NEAREST)\r\n * @param reusable If the post-process can be reused on the same frame. (default: false)\r\n * @param textureType The type of textures used when performing the post-process. (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ) {\r\n super(\r\n name,\r\n \"edgeDetection\",\r\n [\"width\", \"height\", \"edgeColor\", \"edgeIntensity\", \"edgeWidth\", \"renderMode\"],\r\n [\"normalSampler\", \"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n scene.getEngine(),\r\n reusable,\r\n null,\r\n textureType\r\n );\r\n\r\n this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();\r\n\r\n if (!this._geometryBufferRenderer) {\r\n // Geometry buffer renderer is not supported. So, work as a passthrough.\r\n Logger.Error(\"Geometry Buffer Renderer support is required for this post-process.\");\r\n } else {\r\n const h1 = new RenderTargetTexture(\"h1\", { width: this.width, height: this.height }, scene, {\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST,\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n });\r\n\r\n // Geometry buffer renderer is supported.\r\n this.onApply = (effect: Effect) => {\r\n effect.setFloat(\"width\", this.width);\r\n effect.setFloat(\"height\", this.height);\r\n effect.setFloat(\"edgeIntensity\", this.edgeIntensity);\r\n effect.setFloat(\"edgeWidth\", this.edgeWidth);\r\n effect.setColor3(\"edgeColor\", this.edgeColor);\r\n\r\n const normalTexture = this._geometryBufferRenderer!.getGBuffer().textures[1];\r\n const depthTexture = this._geometryBufferRenderer!.getGBuffer().textures[0];\r\n\r\n effect.setTexture(\"normalSampler\", normalTexture);\r\n effect.setTexture(\"depthSampler\", depthTexture);\r\n\r\n switch (this.renderMode) {\r\n case 0:\r\n break;\r\n case 1:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[1]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 2:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[0]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 3:\r\n effect.setTexture(\"textureSampler\", h1);\r\n break;\r\n }\r\n effect.setInt(\"renderMode\", this.renderMode);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Support test.\r\n */\r\n public static get IsSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n\r\n return engine.getCaps().drawBuffersExtension;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string) {\r\n return SerializationHelper.Parse(\r\n () =>\r\n new EdgeDetectionPostProcess(\r\n parsedPostProcess.name,\r\n scene,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess.textureType,\r\n parsedPostProcess.reusable\r\n ),\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.EdgeDetectionPostProcess\", EdgeDetectionPostProcess);\r\n"]}
|
1
|
+
{"version":3,"file":"edgeDetectionPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/edgeDetection/edgeDetectionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAI1C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAC7D,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,2EAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,SAAS,EAAE,2CAA6B;AACjD,OAAO,EAAE,mBAAmB,EAAE,yDAA2C;AACzE,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,mBAAmB,EAAE,kEAAoD;AAElF,OAAO,0BAA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AAC,CAAC,CAAC,CAAC,CAAC;wBAC5F,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;wBAChC,MAAM;oBACV,KAAK,CAAC;wBACF,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;wBACxC,MAAM;gBACd,CAAC;gBACD,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YACjD,CAAC,CAAC;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,MAAM,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,oBAAoB,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,MAAM,CAAU,MAAM,CAAC,iBAAsB,EAAE,YAAoB,EAAE,KAAY,EAAE,OAAe;QACrG,OAAO,mBAAmB,CAAC,KAAK,CAC5B,GAAG,EAAE,CACD,IAAI,wBAAwB,CACxB,iBAAiB,CAAC,IAAI,EACtB,KAAK,EACL,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,iBAAiB,CAAC,WAAW,EAC7B,iBAAiB,CAAC,QAAQ,CAC7B,EACL,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AApJU;IADN,SAAS,EAAE;2DACmC;AAQxC;IADN,SAAS,EAAE;+DACuB;AAQ5B;IADN,SAAS,EAAE;2DACmB;AAQxB;IADN,SAAS,EAAE;4DACkB;AA8HlC,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport type { PostProcessOptions } from \"core/PostProcesses/postProcess\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport \"core/Rendering/geometryBufferRendererSceneComponent\";\r\nimport type { GeometryBufferRenderer } from \"core/Rendering/geometryBufferRenderer\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport \"./edgeDetection.fragment\";\r\n\r\n/**\r\n * The Edge Detection effect highlights the edges of objects in the scene like a toon.\r\n * This can be used for stylized rendering, outlining, or visual effects that require edge enhancement.\r\n */\r\nexport class EdgeDetectionPostProcess extends PostProcess {\r\n /**\r\n * Defines the color of the detected edges.\r\n */\r\n @serialize()\r\n public edgeColor: Color3 = new Color3(0, 0, 0);\r\n\r\n /**\r\n * Defines the intensity of the detected edges.\r\n * Higher values result in more pronounced edges.\r\n * default: 0.2 (min:0, max:1)\r\n */\r\n @serialize()\r\n public edgeIntensity: number = 0.2;\r\n\r\n /**\r\n * Defines the width of the detected edges.\r\n * Higher values result in thicker edges.\r\n * default: 0.2 (min:0.125, max:1)\r\n */\r\n @serialize()\r\n public edgeWidth: number = 0.2;\r\n\r\n /**\r\n * Defines the render mode.\r\n * default: 0\r\n * 0: general, 1: normal, 2: depth, 3: outline only\r\n */\r\n @serialize()\r\n public renderMode: number = 0;\r\n\r\n private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;\r\n\r\n /**\r\n * Get the current class name of the current effect\r\n * @returns \"EdgeDetectionPostProcess\"\r\n */\r\n public override getClassName(): string {\r\n return \"EdgeDetectionPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance of EdgeDetectionPostProcess.\r\n * @param name The name of the effect.\r\n * @param scene The scene where the edge detection post-process will be applied.\r\n * @param options The required width/height ratio or specific options for the post-process.\r\n * @param camera The camera to apply the post-process to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: TEXTURE_NEAREST_NEAREST)\r\n * @param reusable If the post-process can be reused on the same frame. (default: false)\r\n * @param textureType The type of textures used when performing the post-process. (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ) {\r\n super(\r\n name,\r\n \"edgeDetection\",\r\n [\"width\", \"height\", \"edgeColor\", \"edgeIntensity\", \"edgeWidth\", \"renderMode\"],\r\n [\"normalSampler\", \"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n scene.getEngine(),\r\n reusable,\r\n null,\r\n textureType\r\n );\r\n\r\n this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();\r\n\r\n if (!this._geometryBufferRenderer) {\r\n // Geometry buffer renderer is not supported. So, work as a passthrough.\r\n Logger.Error(\"Geometry Buffer Renderer support is required for this post-process.\");\r\n } else {\r\n const h1 = new RenderTargetTexture(\"h1\", { width: this.width, height: this.height }, scene, {\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST,\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n });\r\n\r\n // Geometry buffer renderer is supported.\r\n this.onApply = (effect: Effect) => {\r\n effect.setFloat(\"width\", this.width);\r\n effect.setFloat(\"height\", this.height);\r\n effect.setFloat(\"edgeIntensity\", this.edgeIntensity);\r\n effect.setFloat(\"edgeWidth\", this.edgeWidth);\r\n effect.setColor3(\"edgeColor\", this.edgeColor);\r\n\r\n const normalTexture = this._geometryBufferRenderer!.getGBuffer().textures[1];\r\n const depthTexture = this._geometryBufferRenderer!.getGBuffer().textures[0];\r\n\r\n effect.setTexture(\"normalSampler\", normalTexture);\r\n effect.setTexture(\"depthSampler\", depthTexture);\r\n\r\n switch (this.renderMode) {\r\n case 0:\r\n break;\r\n case 1:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[1]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 2:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[0]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 3:\r\n effect.setTexture(\"textureSampler\", h1);\r\n break;\r\n }\r\n effect.setInt(\"renderMode\", this.renderMode);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Support test.\r\n */\r\n public static get IsSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n\r\n return engine.getCaps().drawBuffersExtension;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string) {\r\n return SerializationHelper.Parse(\r\n () =>\r\n new EdgeDetectionPostProcess(\r\n parsedPostProcess.name,\r\n scene,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess.textureType,\r\n parsedPostProcess.reusable\r\n ),\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.EdgeDetectionPostProcess\", EdgeDetectionPostProcess);\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"legacy-asciiArt.js","sourceRoot":"","sources":["../../../../lts/postProcesses/src/legacy/legacy-asciiArt.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,kBAAkB,6BAAsC;AAEpE;;;GAGG;AACH,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;
|
1
|
+
{"version":3,"file":"legacy-asciiArt.js","sourceRoot":"","sources":["../../../../lts/postProcesses/src/legacy/legacy-asciiArt.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,kBAAkB,6BAAsC;AAEpE;;;GAGG;AACH,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC7B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;AACL,CAAC;AAED,qCAA8C","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport * as postProcessLibrary from \"post-processes/asciiArt/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in postProcessLibrary) {\r\n (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];\r\n }\r\n}\r\n\r\nexport * from \"post-processes/asciiArt/index\";\r\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"legacy-digitalRain.js","sourceRoot":"","sources":["../../../../lts/postProcesses/src/legacy/legacy-digitalRain.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,kBAAkB,gCAAyC;AAEvE;;;GAGG;AACH,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;
|
1
|
+
{"version":3,"file":"legacy-digitalRain.js","sourceRoot":"","sources":["../../../../lts/postProcesses/src/legacy/legacy-digitalRain.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,kBAAkB,gCAAyC;AAEvE;;;GAGG;AACH,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC7B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;AACL,CAAC;AAED,wCAAiD","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport * as postProcessLibrary from \"post-processes/digitalRain/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in postProcessLibrary) {\r\n (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];\r\n }\r\n}\r\n\r\nexport * from \"post-processes/digitalRain/index\";\r\n"]}
|
package/legacy/legacy.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../../lts/postProcesses/src/legacy/legacy.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,kBAAkB,oBAA6B;AAE3D;;;;GAIG;AACH,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;
|
1
|
+
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../../lts/postProcesses/src/legacy/legacy.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,KAAK,kBAAkB,oBAA6B;AAE3D;;;;GAIG;AACH,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC7B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;AACL,CAAC;AAED,4BAAqC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport * as postProcessLibrary from \"post-processes/index\";\r\n\r\n/**\r\n *\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in postProcessLibrary) {\r\n (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];\r\n }\r\n}\r\n\r\nexport * from \"post-processes/index\";\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/post-processes",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.35.1",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^7.
|
21
|
+
"@babylonjs/core": "^7.35.1",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/post-processes": "^1.0.0"
|
24
24
|
},
|