@babylonjs/post-processes 5.0.0-rc.2 → 5.0.0-rc.5

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,9 +1,9 @@
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";
1
+ import { Nullable } from "@babylonjs/core/types.js";
2
+ import { 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 { Scene } from "@babylonjs/core/scene.js";
6
+ import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
7
7
  import "./asciiart.fragment";
8
8
  /**
9
9
  * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
@@ -32,13 +32,13 @@ export declare class AsciiArtFontTexture extends BaseTexture {
32
32
  * @param font the font to use, use the W3C CSS notation
33
33
  * @return the max char width
34
34
  */
35
- private getFontWidth;
35
+ private _getFontWidth;
36
36
  /**
37
37
  * Gets the max char height of a font.
38
38
  * @param font the font to use, use the W3C CSS notation
39
39
  * @return the max char height
40
40
  */
41
- private getFontHeight;
41
+ private _getFontHeight;
42
42
  /**
43
43
  * Clones the current AsciiArtTexture.
44
44
  * @return the clone of the texture.
@@ -100,6 +100,7 @@ export declare class AsciiArtPostProcess extends PostProcess {
100
100
  * Instantiates a new Ascii Art Post Process.
101
101
  * @param name the name to give to the postprocess
102
102
  * @camera the camera to apply the post process to.
103
+ * @param camera
103
104
  * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
104
105
  */
105
106
  constructor(name: string, camera: Camera, options?: string | IAsciiArtPostProcessOptions);
@@ -34,8 +34,8 @@ var AsciiArtFontTexture = /** @class */ (function (_super) {
34
34
  _this.wrapV = Texture.CLAMP_ADDRESSMODE;
35
35
  //this.anisotropicFilteringLevel = 1;
36
36
  // Get the font specific info.
37
- var maxCharHeight = _this.getFontHeight(font);
38
- var maxCharWidth = _this.getFontWidth(font);
37
+ var maxCharHeight = _this._getFontHeight(font);
38
+ var maxCharWidth = _this._getFontWidth(font);
39
39
  _this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
40
40
  // This is an approximate size, but should always be able to fit at least the maxCharCount.
41
41
  var textureWidth = Math.ceil(_this._charSize * text.length);
@@ -76,10 +76,10 @@ var AsciiArtFontTexture = /** @class */ (function (_super) {
76
76
  * @param font the font to use, use the W3C CSS notation
77
77
  * @return the max char width
78
78
  */
79
- AsciiArtFontTexture.prototype.getFontWidth = function (font) {
79
+ AsciiArtFontTexture.prototype._getFontWidth = function (font) {
80
80
  var fontDraw = document.createElement("canvas");
81
- var ctx = fontDraw.getContext('2d');
82
- ctx.fillStyle = 'white';
81
+ var ctx = fontDraw.getContext("2d");
82
+ ctx.fillStyle = "white";
83
83
  ctx.font = font;
84
84
  return ctx.measureText("W").width;
85
85
  };
@@ -89,14 +89,14 @@ var AsciiArtFontTexture = /** @class */ (function (_super) {
89
89
  * @param font the font to use, use the W3C CSS notation
90
90
  * @return the max char height
91
91
  */
92
- AsciiArtFontTexture.prototype.getFontHeight = function (font) {
92
+ AsciiArtFontTexture.prototype._getFontHeight = function (font) {
93
93
  var fontDraw = document.createElement("canvas");
94
- var ctx = fontDraw.getContext('2d');
94
+ var ctx = fontDraw.getContext("2d");
95
95
  ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
96
- ctx.textBaseline = 'top';
97
- ctx.fillStyle = 'white';
96
+ ctx.textBaseline = "top";
97
+ ctx.fillStyle = "white";
98
98
  ctx.font = font;
99
- ctx.fillText('jH|', 0, 0);
99
+ ctx.fillText("jH|", 0, 0);
100
100
  var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
101
101
  var start = -1;
102
102
  var end = -1;
@@ -119,7 +119,7 @@ var AsciiArtFontTexture = /** @class */ (function (_super) {
119
119
  }
120
120
  }
121
121
  }
122
- return { height: (end - start) + 1, offset: start - 1 };
122
+ return { height: end - start + 1, offset: start - 1 };
123
123
  };
124
124
  /**
125
125
  * Clones the current AsciiArtTexture.
@@ -159,12 +159,13 @@ var AsciiArtPostProcess = /** @class */ (function (_super) {
159
159
  * Instantiates a new Ascii Art Post Process.
160
160
  * @param name the name to give to the postprocess
161
161
  * @camera the camera to apply the post process to.
162
+ * @param camera
162
163
  * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
163
164
  */
164
165
  function AsciiArtPostProcess(name, camera, options) {
165
- var _this = _super.call(this, name, 'asciiart', ['asciiArtFontInfos', 'asciiArtOptions'], ['asciiArtFont'], {
166
+ var _this = _super.call(this, name, "asciiart", ["asciiArtFontInfos", "asciiArtOptions"], ["asciiArtFont"], {
166
167
  width: camera.getEngine().getRenderWidth(),
167
- height: camera.getEngine().getRenderHeight()
168
+ height: camera.getEngine().getRenderHeight(),
168
169
  }, camera, Texture.TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
169
170
  /**
170
171
  * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
@@ -181,7 +182,7 @@ var AsciiArtPostProcess = /** @class */ (function (_super) {
181
182
  var characterSet = " `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";
182
183
  // Use options.
183
184
  if (options) {
184
- if (typeof (options) === "string") {
185
+ if (typeof options === "string") {
185
186
  font = options;
186
187
  }
187
188
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"asciiArtPostProcess.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/asciiArt/asciiArtPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EA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AAC,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":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AAEtE,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;IAAyC,uCAAW;IAgBh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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 { Nullable } from \"core/types\";\r\nimport { serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Effect } from \"core/Materials/effect\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport { 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
1
  /** @hidden */
2
- export declare var asciiartPixelShader: {
2
+ export declare const asciiartPixelShader: {
3
3
  name: string;
4
4
  shader: string;
5
5
  };
@@ -1,6 +1,8 @@
1
+ // Do not edit.
1
2
  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}";
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
4
6
  ShaderStore.ShadersStore[name] = shader;
5
7
  /** @hidden */
6
8
  export var asciiartPixelShader = { name: name, shader: shader };
@@ -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
- {"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,9 +1,9 @@
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";
1
+ import { Nullable } from "@babylonjs/core/types.js";
2
+ import { 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 { Scene } from "@babylonjs/core/scene.js";
6
+ import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
7
7
  import "./digitalrain.fragment";
8
8
  /**
9
9
  * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
@@ -32,13 +32,13 @@ export declare class DigitalRainFontTexture extends BaseTexture {
32
32
  * @param font the font to use, use the W3C CSS notation
33
33
  * @return the max char width
34
34
  */
35
- private getFontWidth;
35
+ private _getFontWidth;
36
36
  /**
37
37
  * Gets the max char height of a font.
38
38
  * @param font the font to use, use the W3C CSS notation
39
39
  * @return the max char height
40
40
  */
41
- private getFontHeight;
41
+ private _getFontHeight;
42
42
  /**
43
43
  * Clones the current DigitalRainFontTexture.
44
44
  * @return the clone of the texture.
@@ -100,6 +100,7 @@ export declare class DigitalRainPostProcess extends PostProcess {
100
100
  * Instantiates a new Digital Rain Post Process.
101
101
  * @param name the name to give to the postprocess
102
102
  * @camera the camera to apply the post process to.
103
+ * @param camera
103
104
  * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
104
105
  */
105
106
  constructor(name: string, camera: Camera, options?: string | IDigitalRainPostProcessOptions);
@@ -34,8 +34,8 @@ var DigitalRainFontTexture = /** @class */ (function (_super) {
34
34
  _this.wrapU = Texture.CLAMP_ADDRESSMODE;
35
35
  _this.wrapV = Texture.CLAMP_ADDRESSMODE;
36
36
  // Get the font specific info.
37
- var maxCharHeight = _this.getFontHeight(font);
38
- var maxCharWidth = _this.getFontWidth(font);
37
+ var maxCharHeight = _this._getFontHeight(font);
38
+ var maxCharWidth = _this._getFontWidth(font);
39
39
  _this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
40
40
  // This is an approximate size, but should always be able to fit at least the maxCharCount.
41
41
  var textureWidth = _this._charSize;
@@ -76,10 +76,10 @@ var DigitalRainFontTexture = /** @class */ (function (_super) {
76
76
  * @param font the font to use, use the W3C CSS notation
77
77
  * @return the max char width
78
78
  */
79
- DigitalRainFontTexture.prototype.getFontWidth = function (font) {
79
+ DigitalRainFontTexture.prototype._getFontWidth = function (font) {
80
80
  var fontDraw = document.createElement("canvas");
81
- var ctx = fontDraw.getContext('2d');
82
- ctx.fillStyle = 'white';
81
+ var ctx = fontDraw.getContext("2d");
82
+ ctx.fillStyle = "white";
83
83
  ctx.font = font;
84
84
  return ctx.measureText("W").width;
85
85
  };
@@ -89,14 +89,14 @@ var DigitalRainFontTexture = /** @class */ (function (_super) {
89
89
  * @param font the font to use, use the W3C CSS notation
90
90
  * @return the max char height
91
91
  */
92
- DigitalRainFontTexture.prototype.getFontHeight = function (font) {
92
+ DigitalRainFontTexture.prototype._getFontHeight = function (font) {
93
93
  var fontDraw = document.createElement("canvas");
94
- var ctx = fontDraw.getContext('2d');
94
+ var ctx = fontDraw.getContext("2d");
95
95
  ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
96
- ctx.textBaseline = 'top';
97
- ctx.fillStyle = 'white';
96
+ ctx.textBaseline = "top";
97
+ ctx.fillStyle = "white";
98
98
  ctx.font = font;
99
- ctx.fillText('jH|', 0, 0);
99
+ ctx.fillText("jH|", 0, 0);
100
100
  var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
101
101
  var start = -1;
102
102
  var end = -1;
@@ -119,7 +119,7 @@ var DigitalRainFontTexture = /** @class */ (function (_super) {
119
119
  }
120
120
  }
121
121
  }
122
- return { height: (end - start) + 1, offset: start - 1 };
122
+ return { height: end - start + 1, offset: start - 1 };
123
123
  };
124
124
  /**
125
125
  * Clones the current DigitalRainFontTexture.
@@ -159,12 +159,13 @@ var DigitalRainPostProcess = /** @class */ (function (_super) {
159
159
  * Instantiates a new Digital Rain Post Process.
160
160
  * @param name the name to give to the postprocess
161
161
  * @camera the camera to apply the post process to.
162
+ * @param camera
162
163
  * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
163
164
  */
164
165
  function DigitalRainPostProcess(name, camera, options) {
165
- var _this = _super.call(this, name, 'digitalrain', ['digitalRainFontInfos', 'digitalRainOptions', 'cosTimeZeroOne', 'matrixSpeed'], ['digitalRainFont'], {
166
+ var _this = _super.call(this, name, "digitalrain", ["digitalRainFontInfos", "digitalRainOptions", "cosTimeZeroOne", "matrixSpeed"], ["digitalRainFont"], {
166
167
  width: camera.getEngine().getRenderWidth(),
167
- height: camera.getEngine().getRenderHeight()
168
+ height: camera.getEngine().getRenderHeight(),
168
169
  }, camera, Texture.TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
169
170
  /**
170
171
  * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
@@ -185,7 +186,7 @@ var DigitalRainPostProcess = /** @class */ (function (_super) {
185
186
  var characterSet = "古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";
186
187
  // Use options.
187
188
  if (options) {
188
- if (typeof (options) === "string") {
189
+ if (typeof options === "string") {
189
190
  font = options;
190
191
  }
191
192
  else {
@@ -206,7 +207,7 @@ var DigitalRainPostProcess = /** @class */ (function (_super) {
206
207
  effect.setMatrix("matrixSpeed", matrix);
207
208
  alpha += _this.speed;
208
209
  cosTimeZeroOne = alpha;
209
- effect.setFloat('cosTimeZeroOne', cosTimeZeroOne);
210
+ effect.setFloat("cosTimeZeroOne", cosTimeZeroOne);
210
211
  };
211
212
  return _this;
212
213
  }
@@ -1 +1 @@
1
- {"version":3,"file":"digitalRainPostProcess.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/digitalRain/digitalRainPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,M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,CAAC;IACL,6BAAC;AAAD,CAAC,AA/FD,CAA4C,WAAW,GA+FtD","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { serialize, SerializationHelper } from \"@babylonjs/core/Misc/decorators\";\r\nimport { Matrix } from \"@babylonjs/core/Maths/math.vector\";\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 \"./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\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 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 = this._charSize;\r\n var 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 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], 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 * @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 DigitalRainFontTexture.\r\n * @return the clone of the texture.\r\n */\r\n public 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 * @return the parsed texture\r\n */\r\n public static Parse(source: any, scene: Scene): DigitalRainFontTexture {\r\n var texture = SerializationHelper.Parse(() => new DigitalRainFontTexture(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 Digital Rain Post Process.\r\n */\r\nexport interface IDigitalRainPostProcessOptions {\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 * 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 /**\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 options can either be the font name or an option object following the IDigitalRainPostProcessOptions format\r\n */\r\n constructor(name: string, camera: Camera, options?: string | IDigitalRainPostProcessOptions) {\r\n super(name,\r\n 'digitalrain',\r\n ['digitalRainFontInfos', 'digitalRainOptions', 'cosTimeZeroOne', 'matrixSpeed'],\r\n ['digitalRainFont'],\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 = \"15px Monospace\";\r\n var characterSet = \"古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす\";\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 = (<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 this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, camera.getScene());\r\n var textureSize = this._digitalRainFontTexture.getSize();\r\n\r\n var alpha = 0.0;\r\n var cosTimeZeroOne = 0.0;\r\n var matrix = Matrix.FromValues(\r\n Math.random(), Math.random(), Math.random(), Math.random(),\r\n Math.random(), Math.random(), Math.random(), Math.random(),\r\n Math.random(), Math.random(), Math.random(), Math.random(),\r\n Math.random(), Math.random(), Math.random(), 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\",\r\n this._digitalRainFontTexture.charSize,\r\n characterSet.length,\r\n textureSize.width,\r\n textureSize.height);\r\n\r\n effect.setFloat4(\"digitalRainOptions\",\r\n this.width,\r\n this.height,\r\n this.mixToNormal,\r\n this.mixToTile);\r\n\r\n effect.setMatrix(\"matrixSpeed\",\r\n 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":["../../../../../lts/postProcesses/generated/digitalRain/digitalRainPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,2CAA6B;AACtE,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;IAA4C,0CAAW;IAgBnD;;;;;;OAMG;IACH,gCAAY,IAAY,EAAE,IAAY,EAAE,IAAY,E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,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,KAAI,CAAC,OAAO,GAAG,UAAC,MAAc;YAC1B,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,KAAI,CAAC,uBAAuB,CAAC,CAAC;YAEnE,MAAM,CAAC,SAAS,CAAC,sBAAsB,EAAE,KAAI,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,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,MAAM,EAAE,KAAI,CAAC,WAAW,EAAE,KAAI,CAAC,SAAS,CAAC,CAAC;YAElG,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAExC,KAAK,IAAI,KAAI,CAAC,KAAK,CAAC;YACpB,cAAc,GAAG,KAAK,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QACtD,CAAC,CAAC;;IACN,CAAC;IACL,6BAAC;AAAD,CAAC,AApGD,CAA4C,WAAW,GAoGtD","sourcesContent":["import { Nullable } from \"core/types\";\r\nimport { serialize, SerializationHelper } from \"core/Misc/decorators\";\r\nimport { Matrix } from \"core/Maths/math.vector\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Effect } from \"core/Materials/effect\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport { 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 * @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 DigitalRainFontTexture.\r\n * @return the clone of the texture.\r\n */\r\n public 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 * @return 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: Camera, options?: string | IDigitalRainPostProcessOptions) {\r\n super(\r\n name,\r\n \"digitalrain\",\r\n [\"digitalRainFontInfos\", \"digitalRainOptions\", \"cosTimeZeroOne\", \"matrixSpeed\"],\r\n [\"digitalRainFont\"],\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 = \"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 this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, camera.getScene());\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,5 +1,5 @@
1
1
  /** @hidden */
2
- export declare var digitalrainPixelShader: {
2
+ export declare const digitalrainPixelShader: {
3
3
  name: string;
4
4
  shader: string;
5
5
  };
@@ -1,6 +1,8 @@
1
+ // Do not edit.
1
2
  import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
2
- var name = 'digitalrainPixelShader';
3
- var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D digitalRainFont;\n\nuniform vec4 digitalRainFontInfos;\nuniform vec4 digitalRainOptions;\nuniform mat4 matrixSpeed;\nuniform float cosTimeZeroOne;\n\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\n\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat caracterSize=digitalRainFontInfos.x;\nfloat numChar=digitalRainFontInfos.y-1.0;\nfloat fontx=digitalRainFontInfos.z;\nfloat fonty=digitalRainFontInfos.w;\nfloat screenx=digitalRainOptions.x;\nfloat screeny=digitalRainOptions.y;\nfloat ratio=screeny/fonty;\nfloat columnx=float(floor((gl_FragCoord.x)/caracterSize));\nfloat tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;\nfloat tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;\nvec2 tileUV=vec2(tileX,tileY);\nvec4 tileColor=texture2D(textureSampler,tileUV);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat tileLuminance=getLuminance(tileColor.rgb);\nint st=int(mod(columnx,4.0));\nfloat speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6);\nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;\nfloat y=float(mod(speed+gl_FragCoord.y/screeny,1.0));\ny*=ratio;\nvec4 finalColor=texture2D(digitalRainFont,vec2(x,1.0-y));\nvec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));\nfinalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));\nfinalColor.rgb+=high;\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\nfinalColor.a=1.0;\nfinalColor=mix(finalColor,tileColor,digitalRainOptions.w);\nfinalColor=mix(finalColor,baseColor,digitalRainOptions.z);\ngl_FragColor=finalColor;\n}";
3
+ var name = "digitalrainPixelShader";
4
+ var shader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D digitalRainFont;uniform vec4 digitalRainFontInfos;uniform vec4 digitalRainOptions;uniform mat4 matrixSpeed;uniform float cosTimeZeroOne;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=digitalRainFontInfos.x;float numChar=digitalRainFontInfos.y-1.0;float fontx=digitalRainFontInfos.z;float fonty=digitalRainFontInfos.w;float screenx=digitalRainOptions.x;float screeny=digitalRainOptions.y;float ratio=screeny/fonty;float columnx=float(floor((gl_FragCoord.x)/caracterSize));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);int st=int(mod(columnx,4.0));float speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6); \nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;float y=float(mod(speed+gl_FragCoord.y/screeny,1.0));y*=ratio;vec4 finalColor= texture2D(digitalRainFont,vec2(x,1.0-y));vec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));finalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));finalColor.rgb+=high;finalColor.rgb=clamp(finalColor.rgb,0.,1.);finalColor.a=1.0;finalColor= mix(finalColor,tileColor,digitalRainOptions.w);finalColor= mix(finalColor,baseColor,digitalRainOptions.z);gl_FragColor=finalColor;}";
5
+ // Sideeffect
4
6
  ShaderStore.ShadersStore[name] = shader;
5
7
  /** @hidden */
6
8
  export var digitalrainPixelShader = { name: name, shader: shader };
@@ -1 +1 @@
1
- {"version":3,"file":"digitalrain.fragment.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/digitalRain/digitalrain.fragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,IAAI,IAAI,GAAG,wBAAwB,CAAC;AACpC,IAAI,MAAM,GAAG,qqDA8CX,CAAC;AAEH,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAI,sBAAsB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["import { ShaderStore } from \"@babylonjs/core/Engines/shaderStore\";\n\nlet name = 'digitalrainPixelShader';\nlet shader = `\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D digitalRainFont;\n\nuniform vec4 digitalRainFontInfos;\nuniform vec4 digitalRainOptions;\nuniform mat4 matrixSpeed;\nuniform float cosTimeZeroOne;\n\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\n\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat caracterSize=digitalRainFontInfos.x;\nfloat numChar=digitalRainFontInfos.y-1.0;\nfloat fontx=digitalRainFontInfos.z;\nfloat fonty=digitalRainFontInfos.w;\nfloat screenx=digitalRainOptions.x;\nfloat screeny=digitalRainOptions.y;\nfloat ratio=screeny/fonty;\nfloat columnx=float(floor((gl_FragCoord.x)/caracterSize));\nfloat tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;\nfloat tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;\nvec2 tileUV=vec2(tileX,tileY);\nvec4 tileColor=texture2D(textureSampler,tileUV);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat tileLuminance=getLuminance(tileColor.rgb);\nint st=int(mod(columnx,4.0));\nfloat speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6);\nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;\nfloat y=float(mod(speed+gl_FragCoord.y/screeny,1.0));\ny*=ratio;\nvec4 finalColor=texture2D(digitalRainFont,vec2(x,1.0-y));\nvec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));\nfinalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));\nfinalColor.rgb+=high;\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\nfinalColor.a=1.0;\nfinalColor=mix(finalColor,tileColor,digitalRainOptions.w);\nfinalColor=mix(finalColor,baseColor,digitalRainOptions.z);\ngl_FragColor=finalColor;\n}`;\n\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport var digitalrainPixelShader = { name, shader };\n"]}
1
+ {"version":3,"file":"digitalrain.fragment.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/digitalRain/digitalrain.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,IAAM,MAAM,GAAG,wlDAKwhB,CAAC;AACxiB,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAM,sBAAsB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"digitalrainPixelShader\";\nconst shader = `varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D digitalRainFont;uniform vec4 digitalRainFontInfos;uniform vec4 digitalRainOptions;uniform mat4 matrixSpeed;uniform float cosTimeZeroOne;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=digitalRainFontInfos.x;float numChar=digitalRainFontInfos.y-1.0;float fontx=digitalRainFontInfos.z;float fonty=digitalRainFontInfos.w;float screenx=digitalRainOptions.x;float screeny=digitalRainOptions.y;float ratio=screeny/fonty;float columnx=float(floor((gl_FragCoord.x)/caracterSize));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);int st=int(mod(columnx,4.0));float speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6); \nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;float y=float(mod(speed+gl_FragCoord.y/screeny,1.0));y*=ratio;vec4 finalColor= texture2D(digitalRainFont,vec2(x,1.0-y));vec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));finalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));finalColor.rgb+=high;finalColor.rgb=clamp(finalColor.rgb,0.,1.);finalColor.a=1.0;finalColor= mix(finalColor,tileColor,digitalRainOptions.w);finalColor= mix(finalColor,baseColor,digitalRainOptions.z);gl_FragColor=finalColor;}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const digitalrainPixelShader = { name, shader };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/digitalRain/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./digitalRainPostProcess\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/digitalRain/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./digitalRainPostProcess\";\r\n"]}
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../sourceES6/postProcessesLibrary/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./asciiArt/index\";\r\nexport * from \"./digitalRain/index\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/postProcesses/generated/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./asciiArt/index\";\r\nexport * from \"./digitalRain/index\";\r\n"]}
@@ -1 +1 @@
1
- export * from "../asciiArt/index";
1
+ export * from "./asciiArt/index.js";
@@ -1,13 +1,13 @@
1
- import * as postProcessLibrary from "../asciiArt/index.js";
1
+ import * as postProcessLibrary from "./asciiArt/index.js";
2
2
  /**
3
3
  * This is the entry point for the UMD module.
4
4
  * The entry point for a future ESM package should be index.ts
5
5
  */
6
- var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
6
+ var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
7
7
  if (typeof globalObject !== "undefined") {
8
8
  for (var key in postProcessLibrary) {
9
9
  globalObject.BABYLON[key] = postProcessLibrary[key];
10
10
  }
11
11
  }
12
- export * from "../asciiArt/index.js";
12
+ export * from "./asciiArt/index.js";
13
13
  //# sourceMappingURL=legacy-asciiArt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-asciiArt.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/legacy/legacy-asciiArt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,mBAAmB,CAAC;AAExD;;;GAGG;AACH,IAAI,YAAY,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACrH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACrC,KAAK,IAAI,GAAG,IAAI,kBAAkB,EAAE;QAC1B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;KACrE;CACJ;AAED,cAAc,mBAAmB,CAAC","sourcesContent":["import * as postProcessLibrary from \"../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\nvar globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);\r\nif (typeof globalObject !== \"undefined\") {\r\n for (var key in postProcessLibrary) {\r\n (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];\r\n }\r\n}\r\n\r\nexport * from \"../asciiArt/index\";"]}
1
+ {"version":3,"file":"legacy-asciiArt.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/legacy/legacy-asciiArt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,4BAAsC;AAEpE;;;GAGG;AACH,IAAM,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;IACrC,KAAK,IAAM,GAAG,IAAI,kBAAkB,EAAE;QAC5B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;KACrE;CACJ;AAED,oCAA8C","sourcesContent":["import * 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
- export * from "../digitalRain/index";
1
+ export * from "./digitalRain/index.js";
@@ -1,13 +1,13 @@
1
- import * as postProcessLibrary from "../digitalRain/index.js";
1
+ import * as postProcessLibrary from "./digitalRain/index.js";
2
2
  /**
3
3
  * This is the entry point for the UMD module.
4
4
  * The entry point for a future ESM package should be index.ts
5
5
  */
6
- var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
6
+ var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
7
7
  if (typeof globalObject !== "undefined") {
8
8
  for (var key in postProcessLibrary) {
9
9
  globalObject.BABYLON[key] = postProcessLibrary[key];
10
10
  }
11
11
  }
12
- export * from "../digitalRain/index.js";
12
+ export * from "./digitalRain/index.js";
13
13
  //# sourceMappingURL=legacy-digitalRain.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-digitalRain.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/legacy/legacy-digitalRain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAE3D;;;GAGG;AACH,IAAI,YAAY,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACrH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACrC,KAAK,IAAI,GAAG,IAAI,kBAAkB,EAAE;QAC1B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;KACrE;CACJ;AAED,cAAc,sBAAsB,CAAC","sourcesContent":["import * as postProcessLibrary from \"../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\nvar globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);\r\nif (typeof globalObject !== \"undefined\") {\r\n for (var key in postProcessLibrary) {\r\n (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];\r\n }\r\n}\r\n\r\nexport * from \"../digitalRain/index\";"]}
1
+ {"version":3,"file":"legacy-digitalRain.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/legacy/legacy-digitalRain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,+BAAyC;AAEvE;;;GAGG;AACH,IAAM,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;IACrC,KAAK,IAAM,GAAG,IAAI,kBAAkB,EAAE;QAC5B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;KACrE;CACJ;AAED,uCAAiD","sourcesContent":["import * 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"]}
@@ -1 +1 @@
1
- export * from "../index";
1
+ export * from "./index.js";
package/legacy/legacy.js CHANGED
@@ -1,14 +1,14 @@
1
- import * as postProcessLibrary from "../index.js";
1
+ import * as postProcessLibrary from "./index.js";
2
2
  /**
3
3
  *
4
4
  * This is the entry point for the UMD module.
5
5
  * The entry point for a future ESM package should be index.ts
6
6
  */
7
- var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
7
+ var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
8
8
  if (typeof globalObject !== "undefined") {
9
9
  for (var key in postProcessLibrary) {
10
10
  globalObject.BABYLON[key] = postProcessLibrary[key];
11
11
  }
12
12
  }
13
- export * from "../index.js";
13
+ export * from "./index.js";
14
14
  //# sourceMappingURL=legacy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../sourceES6/postProcessesLibrary/src/legacy/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,IAAI,YAAY,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACrH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACrC,KAAK,IAAI,GAAG,IAAI,kBAAkB,EAAE;QAC1B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;KACrE;CACJ;AAED,cAAc,UAAU,CAAC","sourcesContent":["import * as postProcessLibrary from \"../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\nvar globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);\r\nif (typeof globalObject !== \"undefined\") {\r\n for (var key in postProcessLibrary) {\r\n (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];\r\n }\r\n}\r\n\r\nexport * from \"../index\";"]}
1
+ {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../../../lts/postProcesses/generated/legacy/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,mBAA6B;AAE3D;;;;GAIG;AACH,IAAM,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;IACrC,KAAK,IAAM,GAAG,IAAI,kBAAkB,EAAE;QAC5B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,kBAAmB,CAAC,GAAG,CAAC,CAAC;KACrE;CACJ;AAED,2BAAqC","sourcesContent":["import * 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,65 +1,31 @@
1
1
  {
2
- "author": {
3
- "name": "David CATUHE"
4
- },
5
2
  "name": "@babylonjs/post-processes",
6
- "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
7
- "version": "5.0.0-rc.2",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/BabylonJS/Babylon.js.git"
11
- },
3
+ "version": "5.0.0-rc.5",
12
4
  "main": "index.js",
5
+ "module": "index.js",
6
+ "types": "index.d.ts",
13
7
  "files": [
14
- "asciiArt/asciiart.fragment.d.ts",
15
- "asciiArt/asciiart.fragment.js",
16
- "asciiArt/asciiart.fragment.js.map",
17
- "asciiArt/asciiArtPostProcess.d.ts",
18
- "asciiArt/asciiArtPostProcess.js",
19
- "asciiArt/asciiArtPostProcess.js.map",
20
- "asciiArt/index.d.ts",
21
- "asciiArt/index.js",
22
- "asciiArt/index.js.map",
23
- "digitalRain/digitalrain.fragment.d.ts",
24
- "digitalRain/digitalrain.fragment.js",
25
- "digitalRain/digitalrain.fragment.js.map",
26
- "digitalRain/digitalRainPostProcess.d.ts",
27
- "digitalRain/digitalRainPostProcess.js",
28
- "digitalRain/digitalRainPostProcess.js.map",
29
- "digitalRain/index.d.ts",
30
- "digitalRain/index.js",
31
- "digitalRain/index.js.map",
32
- "index.d.ts",
33
- "index.js",
34
- "index.js.map",
35
- "legacy/legacy-asciiArt.d.ts",
36
- "legacy/legacy-asciiArt.js",
37
- "legacy/legacy-asciiArt.js.map",
38
- "legacy/legacy-digitalRain.d.ts",
39
- "legacy/legacy-digitalRain.js",
40
- "legacy/legacy-digitalRain.js.map",
41
- "legacy/legacy.d.ts",
42
- "legacy/legacy.js",
43
- "legacy/legacy.js.map",
8
+ "**/*.js",
9
+ "**/*.d.ts",
10
+ "**/*.map",
44
11
  "readme.md"
45
12
  ],
46
- "typings": "index.d.ts",
47
- "keywords": [
48
- "3D",
49
- "javascript",
50
- "html5",
51
- "webgl",
52
- "post process"
53
- ],
54
- "license": "Apache-2.0",
13
+ "scripts": {
14
+ "build": "npm run clean && npm run compile",
15
+ "clean": "rimraf dist && rimraf *.tsbuildinfo && rimraf \"./**/*.!(md|json|build.json)\"",
16
+ "compile": "tsc -b tsconfig.build.json",
17
+ "postcompile": "build-tools -c add-js-to-es6 --path ./dist/**/*.js",
18
+ "prepublishOnly": "build-tools -c prepare-es6-build"
19
+ },
55
20
  "dependencies": {
56
- "@babylonjs/core": "5.0.0-rc.2",
21
+ "@babylonjs/core": "^5.0.0-rc.5",
57
22
  "tslib": "^2.3.1"
58
23
  },
59
- "engines": {
60
- "node": "*"
24
+ "devDependencies": {
25
+ "@dev/build-tools": "^1.0.0",
26
+ "@lts/post-processes": "^1.0.0",
27
+ "rimraf": "^3.0.2",
28
+ "typescript": "^4.4.4"
61
29
  },
62
- "module": "index.js",
63
- "esnext": "index.js",
64
- "type": "module"
65
- }
30
+ "sideEffects": true
31
+ }
package/readme.md CHANGED
@@ -13,7 +13,7 @@ npm install --save @babylonjs/core @babylonjs/post-processes
13
13
 
14
14
  # How to use
15
15
 
16
- Afterwards it can be imported to the your project using:
16
+ Afterwards it can be imported to your project using:
17
17
 
18
18
  ```
19
19
  import { AsciiArtPostProcess } from '@babylonjs/post-processes/asciiArt';
@@ -28,4 +28,4 @@ let postProcess = new AsciiArtPostProcess("AsciiArt", camera);
28
28
  // Some more awesome code
29
29
  ```
30
30
 
31
- For more information you can have a look at our [our ES6 dedicated documentation](https://doc.babylonjs.com/features/es6_support).
31
+ For more information you can have a look at our [ES6 dedicated documentation](https://doc.babylonjs.com/features/es6_support).