@babylonjs/post-processes 5.0.0-rc.7 → 5.0.0-rc.9
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.
- package/asciiArt/asciiArtPostProcess.d.ts +107 -107
- package/asciiArt/asciiArtPostProcess.js +206 -206
- package/asciiArt/asciiart.fragment.d.ts +5 -5
- package/asciiArt/asciiart.fragment.js +8 -8
- package/asciiArt/index.d.ts +1 -1
- package/asciiArt/index.js +1 -1
- package/digitalRain/digitalRainPostProcess.d.ts +107 -107
- package/digitalRain/digitalRainPostProcess.js +216 -216
- package/digitalRain/digitalrain.fragment.d.ts +5 -5
- package/digitalRain/digitalrain.fragment.js +8 -8
- package/digitalRain/index.d.ts +1 -1
- package/digitalRain/index.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/legacy/legacy-asciiArt.d.ts +1 -1
- package/legacy/legacy-asciiArt.js +12 -12
- package/legacy/legacy-digitalRain.d.ts +1 -1
- package/legacy/legacy-digitalRain.js +12 -12
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +13 -13
- package/package.json +2 -2
@@ -1,217 +1,217 @@
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
2
|
-
import { serialize, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
|
-
import { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
4
|
-
import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
5
|
-
import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
6
|
-
import { PostProcess } from "@babylonjs/core/PostProcesses/postProcess.js";
|
7
|
-
import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
|
8
|
-
import "./digitalrain.fragment
|
9
|
-
/**
|
10
|
-
* DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
|
11
|
-
*
|
12
|
-
* It basically takes care rendering the font front the given font size to a texture.
|
13
|
-
* This is used later on in the postprocess.
|
14
|
-
*/
|
15
|
-
var DigitalRainFontTexture = /** @class */ (function (_super) {
|
16
|
-
__extends(DigitalRainFontTexture, _super);
|
17
|
-
/**
|
18
|
-
* Create a new instance of the Digital Rain FontTexture class
|
19
|
-
* @param name the name of the texture
|
20
|
-
* @param font the font to use, use the W3C CSS notation
|
21
|
-
* @param text the caracter set to use in the rendering.
|
22
|
-
* @param scene the scene that owns the texture
|
23
|
-
*/
|
24
|
-
function DigitalRainFontTexture(name, font, text, scene) {
|
25
|
-
if (scene === void 0) { scene = null; }
|
26
|
-
var _this = _super.call(this, scene) || this;
|
27
|
-
scene = _this.getScene();
|
28
|
-
if (!scene) {
|
29
|
-
return _this;
|
30
|
-
}
|
31
|
-
_this.name = name;
|
32
|
-
_this._text == text;
|
33
|
-
_this._font == font;
|
34
|
-
_this.wrapU = Texture.CLAMP_ADDRESSMODE;
|
35
|
-
_this.wrapV = Texture.CLAMP_ADDRESSMODE;
|
36
|
-
// Get the font specific info.
|
37
|
-
var maxCharHeight = _this._getFontHeight(font);
|
38
|
-
var maxCharWidth = _this._getFontWidth(font);
|
39
|
-
_this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
|
40
|
-
// This is an approximate size, but should always be able to fit at least the maxCharCount.
|
41
|
-
var textureWidth = _this._charSize;
|
42
|
-
var textureHeight = Math.ceil(_this._charSize * text.length);
|
43
|
-
// Create the texture that will store the font characters.
|
44
|
-
_this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, Texture.NEAREST_SAMPLINGMODE);
|
45
|
-
//scene.getEngine().setclamp
|
46
|
-
var textureSize = _this.getSize();
|
47
|
-
// Create a canvas with the final size: the one matching the texture.
|
48
|
-
var canvas = document.createElement("canvas");
|
49
|
-
canvas.width = textureSize.width;
|
50
|
-
canvas.height = textureSize.height;
|
51
|
-
var context = canvas.getContext("2d");
|
52
|
-
context.textBaseline = "top";
|
53
|
-
context.font = font;
|
54
|
-
context.fillStyle = "white";
|
55
|
-
context.imageSmoothingEnabled = false;
|
56
|
-
// Sets the text in the texture.
|
57
|
-
for (var i = 0; i < text.length; i++) {
|
58
|
-
context.fillText(text[i], 0, i * _this._charSize - maxCharHeight.offset);
|
59
|
-
}
|
60
|
-
// Flush the text in the dynamic texture.
|
61
|
-
scene.getEngine().updateDynamicTexture(_this._texture, canvas, false, true);
|
62
|
-
return _this;
|
63
|
-
}
|
64
|
-
Object.defineProperty(DigitalRainFontTexture.prototype, "charSize", {
|
65
|
-
/**
|
66
|
-
* Gets the size of one char in the texture (each char fits in size * size space in the texture).
|
67
|
-
*/
|
68
|
-
get: function () {
|
69
|
-
return this._charSize;
|
70
|
-
},
|
71
|
-
enumerable: false,
|
72
|
-
configurable: true
|
73
|
-
});
|
74
|
-
/**
|
75
|
-
* Gets the max char width of a font.
|
76
|
-
* @param font the font to use, use the W3C CSS notation
|
77
|
-
* @return the max char width
|
78
|
-
*/
|
79
|
-
DigitalRainFontTexture.prototype._getFontWidth = function (font) {
|
80
|
-
var fontDraw = document.createElement("canvas");
|
81
|
-
var ctx = fontDraw.getContext("2d");
|
82
|
-
ctx.fillStyle = "white";
|
83
|
-
ctx.font = font;
|
84
|
-
return ctx.measureText("W").width;
|
85
|
-
};
|
86
|
-
// More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/
|
87
|
-
/**
|
88
|
-
* Gets the max char height of a font.
|
89
|
-
* @param font the font to use, use the W3C CSS notation
|
90
|
-
* @return the max char height
|
91
|
-
*/
|
92
|
-
DigitalRainFontTexture.prototype._getFontHeight = function (font) {
|
93
|
-
var fontDraw = document.createElement("canvas");
|
94
|
-
var ctx = fontDraw.getContext("2d");
|
95
|
-
ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
|
96
|
-
ctx.textBaseline = "top";
|
97
|
-
ctx.fillStyle = "white";
|
98
|
-
ctx.font = font;
|
99
|
-
ctx.fillText("jH|", 0, 0);
|
100
|
-
var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
|
101
|
-
var start = -1;
|
102
|
-
var end = -1;
|
103
|
-
for (var row = 0; row < fontDraw.height; row++) {
|
104
|
-
for (var column = 0; column < fontDraw.width; column++) {
|
105
|
-
var index = (row * fontDraw.width + column) * 4;
|
106
|
-
if (pixels[index] === 0) {
|
107
|
-
if (column === fontDraw.width - 1 && start !== -1) {
|
108
|
-
end = row;
|
109
|
-
row = fontDraw.height;
|
110
|
-
break;
|
111
|
-
}
|
112
|
-
continue;
|
113
|
-
}
|
114
|
-
else {
|
115
|
-
if (start === -1) {
|
116
|
-
start = row;
|
117
|
-
}
|
118
|
-
break;
|
119
|
-
}
|
120
|
-
}
|
121
|
-
}
|
122
|
-
return { height: end - start + 1, offset: start - 1 };
|
123
|
-
};
|
124
|
-
/**
|
125
|
-
* Clones the current DigitalRainFontTexture.
|
126
|
-
* @return the clone of the texture.
|
127
|
-
*/
|
128
|
-
DigitalRainFontTexture.prototype.clone = function () {
|
129
|
-
return new DigitalRainFontTexture(this.name, this._font, this._text, this.getScene());
|
130
|
-
};
|
131
|
-
/**
|
132
|
-
* Parses a json object representing the texture and returns an instance of it.
|
133
|
-
* @param source the source JSON representation
|
134
|
-
* @param scene the scene to create the texture for
|
135
|
-
* @return the parsed texture
|
136
|
-
*/
|
137
|
-
DigitalRainFontTexture.Parse = function (source, scene) {
|
138
|
-
var texture = SerializationHelper.Parse(function () { return new DigitalRainFontTexture(source.name, source.font, source.text, scene); }, source, scene, null);
|
139
|
-
return texture;
|
140
|
-
};
|
141
|
-
__decorate([
|
142
|
-
serialize("font")
|
143
|
-
], DigitalRainFontTexture.prototype, "_font", void 0);
|
144
|
-
__decorate([
|
145
|
-
serialize("text")
|
146
|
-
], DigitalRainFontTexture.prototype, "_text", void 0);
|
147
|
-
return DigitalRainFontTexture;
|
148
|
-
}(BaseTexture));
|
149
|
-
export { DigitalRainFontTexture };
|
150
|
-
/**
|
151
|
-
* DigitalRainPostProcess helps rendering everithing in digital rain.
|
152
|
-
*
|
153
|
-
* Simmply add it to your scene and let the nerd that lives in you have fun.
|
154
|
-
* Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
|
155
|
-
*/
|
156
|
-
var DigitalRainPostProcess = /** @class */ (function (_super) {
|
157
|
-
__extends(DigitalRainPostProcess, _super);
|
158
|
-
/**
|
159
|
-
* Instantiates a new Digital Rain Post Process.
|
160
|
-
* @param name the name to give to the postprocess
|
161
|
-
* @camera the camera to apply the post process to.
|
162
|
-
* @param camera
|
163
|
-
* @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
|
164
|
-
*/
|
165
|
-
function DigitalRainPostProcess(name, camera, options) {
|
166
|
-
var _this = _super.call(this, name, "digitalrain", ["digitalRainFontInfos", "digitalRainOptions", "cosTimeZeroOne", "matrixSpeed"], ["digitalRainFont"], {
|
167
|
-
width: camera.getEngine().getRenderWidth(),
|
168
|
-
height: camera.getEngine().getRenderHeight(),
|
169
|
-
}, camera, Texture.TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
|
170
|
-
/**
|
171
|
-
* This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
|
172
|
-
* This number is defined between 0 and 1;
|
173
|
-
*/
|
174
|
-
_this.mixToTile = 0;
|
175
|
-
/**
|
176
|
-
* This defines the amount you want to mix the normal rendering pass in the digital rain.
|
177
|
-
* This number is defined between 0 and 1;
|
178
|
-
*/
|
179
|
-
_this.mixToNormal = 0;
|
180
|
-
/**
|
181
|
-
* Speed of the effect
|
182
|
-
*/
|
183
|
-
_this.speed = 0.003;
|
184
|
-
// Default values.
|
185
|
-
var font = "15px Monospace";
|
186
|
-
var characterSet = "古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";
|
187
|
-
// Use options.
|
188
|
-
if (options) {
|
189
|
-
if (typeof options === "string") {
|
190
|
-
font = options;
|
191
|
-
}
|
192
|
-
else {
|
193
|
-
font = options.font || font;
|
194
|
-
_this.mixToTile = options.mixToTile || _this.mixToTile;
|
195
|
-
_this.mixToNormal = options.mixToNormal || _this.mixToNormal;
|
196
|
-
}
|
197
|
-
}
|
198
|
-
_this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, camera.getScene());
|
199
|
-
var textureSize = _this._digitalRainFontTexture.getSize();
|
200
|
-
var alpha = 0.0;
|
201
|
-
var cosTimeZeroOne = 0.0;
|
202
|
-
var matrix = Matrix.FromValues(Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random());
|
203
|
-
_this.onApply = function (effect) {
|
204
|
-
effect.setTexture("digitalRainFont", _this._digitalRainFontTexture);
|
205
|
-
effect.setFloat4("digitalRainFontInfos", _this._digitalRainFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);
|
206
|
-
effect.setFloat4("digitalRainOptions", _this.width, _this.height, _this.mixToNormal, _this.mixToTile);
|
207
|
-
effect.setMatrix("matrixSpeed", matrix);
|
208
|
-
alpha += _this.speed;
|
209
|
-
cosTimeZeroOne = alpha;
|
210
|
-
effect.setFloat("cosTimeZeroOne", cosTimeZeroOne);
|
211
|
-
};
|
212
|
-
return _this;
|
213
|
-
}
|
214
|
-
return DigitalRainPostProcess;
|
215
|
-
}(PostProcess));
|
216
|
-
export { DigitalRainPostProcess };
|
1
|
+
import { __decorate, __extends } from "tslib";
|
2
|
+
import { serialize, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
|
+
import { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
4
|
+
import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
5
|
+
import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
6
|
+
import { PostProcess } from "@babylonjs/core/PostProcesses/postProcess.js";
|
7
|
+
import "@babylonjs/core/Engines/Extensions/engine.dynamicTexture.js";
|
8
|
+
import "./digitalrain.fragment";
|
9
|
+
/**
|
10
|
+
* DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
|
11
|
+
*
|
12
|
+
* It basically takes care rendering the font front the given font size to a texture.
|
13
|
+
* This is used later on in the postprocess.
|
14
|
+
*/
|
15
|
+
var DigitalRainFontTexture = /** @class */ (function (_super) {
|
16
|
+
__extends(DigitalRainFontTexture, _super);
|
17
|
+
/**
|
18
|
+
* Create a new instance of the Digital Rain FontTexture class
|
19
|
+
* @param name the name of the texture
|
20
|
+
* @param font the font to use, use the W3C CSS notation
|
21
|
+
* @param text the caracter set to use in the rendering.
|
22
|
+
* @param scene the scene that owns the texture
|
23
|
+
*/
|
24
|
+
function DigitalRainFontTexture(name, font, text, scene) {
|
25
|
+
if (scene === void 0) { scene = null; }
|
26
|
+
var _this = _super.call(this, scene) || this;
|
27
|
+
scene = _this.getScene();
|
28
|
+
if (!scene) {
|
29
|
+
return _this;
|
30
|
+
}
|
31
|
+
_this.name = name;
|
32
|
+
_this._text == text;
|
33
|
+
_this._font == font;
|
34
|
+
_this.wrapU = Texture.CLAMP_ADDRESSMODE;
|
35
|
+
_this.wrapV = Texture.CLAMP_ADDRESSMODE;
|
36
|
+
// Get the font specific info.
|
37
|
+
var maxCharHeight = _this._getFontHeight(font);
|
38
|
+
var maxCharWidth = _this._getFontWidth(font);
|
39
|
+
_this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
|
40
|
+
// This is an approximate size, but should always be able to fit at least the maxCharCount.
|
41
|
+
var textureWidth = _this._charSize;
|
42
|
+
var textureHeight = Math.ceil(_this._charSize * text.length);
|
43
|
+
// Create the texture that will store the font characters.
|
44
|
+
_this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, Texture.NEAREST_SAMPLINGMODE);
|
45
|
+
//scene.getEngine().setclamp
|
46
|
+
var textureSize = _this.getSize();
|
47
|
+
// Create a canvas with the final size: the one matching the texture.
|
48
|
+
var canvas = document.createElement("canvas");
|
49
|
+
canvas.width = textureSize.width;
|
50
|
+
canvas.height = textureSize.height;
|
51
|
+
var context = canvas.getContext("2d");
|
52
|
+
context.textBaseline = "top";
|
53
|
+
context.font = font;
|
54
|
+
context.fillStyle = "white";
|
55
|
+
context.imageSmoothingEnabled = false;
|
56
|
+
// Sets the text in the texture.
|
57
|
+
for (var i = 0; i < text.length; i++) {
|
58
|
+
context.fillText(text[i], 0, i * _this._charSize - maxCharHeight.offset);
|
59
|
+
}
|
60
|
+
// Flush the text in the dynamic texture.
|
61
|
+
scene.getEngine().updateDynamicTexture(_this._texture, canvas, false, true);
|
62
|
+
return _this;
|
63
|
+
}
|
64
|
+
Object.defineProperty(DigitalRainFontTexture.prototype, "charSize", {
|
65
|
+
/**
|
66
|
+
* Gets the size of one char in the texture (each char fits in size * size space in the texture).
|
67
|
+
*/
|
68
|
+
get: function () {
|
69
|
+
return this._charSize;
|
70
|
+
},
|
71
|
+
enumerable: false,
|
72
|
+
configurable: true
|
73
|
+
});
|
74
|
+
/**
|
75
|
+
* Gets the max char width of a font.
|
76
|
+
* @param font the font to use, use the W3C CSS notation
|
77
|
+
* @return the max char width
|
78
|
+
*/
|
79
|
+
DigitalRainFontTexture.prototype._getFontWidth = function (font) {
|
80
|
+
var fontDraw = document.createElement("canvas");
|
81
|
+
var ctx = fontDraw.getContext("2d");
|
82
|
+
ctx.fillStyle = "white";
|
83
|
+
ctx.font = font;
|
84
|
+
return ctx.measureText("W").width;
|
85
|
+
};
|
86
|
+
// More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/
|
87
|
+
/**
|
88
|
+
* Gets the max char height of a font.
|
89
|
+
* @param font the font to use, use the W3C CSS notation
|
90
|
+
* @return the max char height
|
91
|
+
*/
|
92
|
+
DigitalRainFontTexture.prototype._getFontHeight = function (font) {
|
93
|
+
var fontDraw = document.createElement("canvas");
|
94
|
+
var ctx = fontDraw.getContext("2d");
|
95
|
+
ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
|
96
|
+
ctx.textBaseline = "top";
|
97
|
+
ctx.fillStyle = "white";
|
98
|
+
ctx.font = font;
|
99
|
+
ctx.fillText("jH|", 0, 0);
|
100
|
+
var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
|
101
|
+
var start = -1;
|
102
|
+
var end = -1;
|
103
|
+
for (var row = 0; row < fontDraw.height; row++) {
|
104
|
+
for (var column = 0; column < fontDraw.width; column++) {
|
105
|
+
var index = (row * fontDraw.width + column) * 4;
|
106
|
+
if (pixels[index] === 0) {
|
107
|
+
if (column === fontDraw.width - 1 && start !== -1) {
|
108
|
+
end = row;
|
109
|
+
row = fontDraw.height;
|
110
|
+
break;
|
111
|
+
}
|
112
|
+
continue;
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
if (start === -1) {
|
116
|
+
start = row;
|
117
|
+
}
|
118
|
+
break;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
return { height: end - start + 1, offset: start - 1 };
|
123
|
+
};
|
124
|
+
/**
|
125
|
+
* Clones the current DigitalRainFontTexture.
|
126
|
+
* @return the clone of the texture.
|
127
|
+
*/
|
128
|
+
DigitalRainFontTexture.prototype.clone = function () {
|
129
|
+
return new DigitalRainFontTexture(this.name, this._font, this._text, this.getScene());
|
130
|
+
};
|
131
|
+
/**
|
132
|
+
* Parses a json object representing the texture and returns an instance of it.
|
133
|
+
* @param source the source JSON representation
|
134
|
+
* @param scene the scene to create the texture for
|
135
|
+
* @return the parsed texture
|
136
|
+
*/
|
137
|
+
DigitalRainFontTexture.Parse = function (source, scene) {
|
138
|
+
var texture = SerializationHelper.Parse(function () { return new DigitalRainFontTexture(source.name, source.font, source.text, scene); }, source, scene, null);
|
139
|
+
return texture;
|
140
|
+
};
|
141
|
+
__decorate([
|
142
|
+
serialize("font")
|
143
|
+
], DigitalRainFontTexture.prototype, "_font", void 0);
|
144
|
+
__decorate([
|
145
|
+
serialize("text")
|
146
|
+
], DigitalRainFontTexture.prototype, "_text", void 0);
|
147
|
+
return DigitalRainFontTexture;
|
148
|
+
}(BaseTexture));
|
149
|
+
export { DigitalRainFontTexture };
|
150
|
+
/**
|
151
|
+
* DigitalRainPostProcess helps rendering everithing in digital rain.
|
152
|
+
*
|
153
|
+
* Simmply add it to your scene and let the nerd that lives in you have fun.
|
154
|
+
* Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
|
155
|
+
*/
|
156
|
+
var DigitalRainPostProcess = /** @class */ (function (_super) {
|
157
|
+
__extends(DigitalRainPostProcess, _super);
|
158
|
+
/**
|
159
|
+
* Instantiates a new Digital Rain Post Process.
|
160
|
+
* @param name the name to give to the postprocess
|
161
|
+
* @camera the camera to apply the post process to.
|
162
|
+
* @param camera
|
163
|
+
* @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
|
164
|
+
*/
|
165
|
+
function DigitalRainPostProcess(name, camera, options) {
|
166
|
+
var _this = _super.call(this, name, "digitalrain", ["digitalRainFontInfos", "digitalRainOptions", "cosTimeZeroOne", "matrixSpeed"], ["digitalRainFont"], {
|
167
|
+
width: camera.getEngine().getRenderWidth(),
|
168
|
+
height: camera.getEngine().getRenderHeight(),
|
169
|
+
}, camera, Texture.TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
|
170
|
+
/**
|
171
|
+
* This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
|
172
|
+
* This number is defined between 0 and 1;
|
173
|
+
*/
|
174
|
+
_this.mixToTile = 0;
|
175
|
+
/**
|
176
|
+
* This defines the amount you want to mix the normal rendering pass in the digital rain.
|
177
|
+
* This number is defined between 0 and 1;
|
178
|
+
*/
|
179
|
+
_this.mixToNormal = 0;
|
180
|
+
/**
|
181
|
+
* Speed of the effect
|
182
|
+
*/
|
183
|
+
_this.speed = 0.003;
|
184
|
+
// Default values.
|
185
|
+
var font = "15px Monospace";
|
186
|
+
var characterSet = "古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";
|
187
|
+
// Use options.
|
188
|
+
if (options) {
|
189
|
+
if (typeof options === "string") {
|
190
|
+
font = options;
|
191
|
+
}
|
192
|
+
else {
|
193
|
+
font = options.font || font;
|
194
|
+
_this.mixToTile = options.mixToTile || _this.mixToTile;
|
195
|
+
_this.mixToNormal = options.mixToNormal || _this.mixToNormal;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
_this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, camera.getScene());
|
199
|
+
var textureSize = _this._digitalRainFontTexture.getSize();
|
200
|
+
var alpha = 0.0;
|
201
|
+
var cosTimeZeroOne = 0.0;
|
202
|
+
var matrix = Matrix.FromValues(Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random());
|
203
|
+
_this.onApply = function (effect) {
|
204
|
+
effect.setTexture("digitalRainFont", _this._digitalRainFontTexture);
|
205
|
+
effect.setFloat4("digitalRainFontInfos", _this._digitalRainFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);
|
206
|
+
effect.setFloat4("digitalRainOptions", _this.width, _this.height, _this.mixToNormal, _this.mixToTile);
|
207
|
+
effect.setMatrix("matrixSpeed", matrix);
|
208
|
+
alpha += _this.speed;
|
209
|
+
cosTimeZeroOne = alpha;
|
210
|
+
effect.setFloat("cosTimeZeroOne", cosTimeZeroOne);
|
211
|
+
};
|
212
|
+
return _this;
|
213
|
+
}
|
214
|
+
return DigitalRainPostProcess;
|
215
|
+
}(PostProcess));
|
216
|
+
export { DigitalRainPostProcess };
|
217
217
|
//# sourceMappingURL=digitalRainPostProcess.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
/** @hidden */
|
2
|
-
export declare const digitalrainPixelShader: {
|
3
|
-
name: string;
|
4
|
-
shader: string;
|
5
|
-
};
|
1
|
+
/** @hidden */
|
2
|
+
export declare const digitalrainPixelShader: {
|
3
|
+
name: string;
|
4
|
+
shader: string;
|
5
|
+
};
|
@@ -1,9 +1,9 @@
|
|
1
|
-
// Do not edit.
|
2
|
-
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
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
|
6
|
-
ShaderStore.ShadersStore[name] = shader;
|
7
|
-
/** @hidden */
|
8
|
-
export var digitalrainPixelShader = { name: name, shader: shader };
|
1
|
+
// Do not edit.
|
2
|
+
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
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
|
6
|
+
ShaderStore.ShadersStore[name] = shader;
|
7
|
+
/** @hidden */
|
8
|
+
export var digitalrainPixelShader = { name: name, shader: shader };
|
9
9
|
//# sourceMappingURL=digitalrain.fragment.js.map
|
package/digitalRain/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from "./digitalRainPostProcess";
|
1
|
+
export * from "./digitalRainPostProcess";
|
package/digitalRain/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from "./digitalRainPostProcess
|
1
|
+
export * from "./digitalRainPostProcess";
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from "./asciiArt/index";
|
2
|
-
export * from "./digitalRain/index";
|
1
|
+
export * from "./asciiArt/index";
|
2
|
+
export * from "./digitalRain/index";
|
package/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from "./asciiArt/index
|
2
|
-
export * from "./digitalRain/index
|
1
|
+
export * from "./asciiArt/index";
|
2
|
+
export * from "./digitalRain/index";
|
3
3
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
export * from "./asciiArt/index.js";
|
1
|
+
export * from "./asciiArt/index.js";
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import * as postProcessLibrary from "./asciiArt/index.js";
|
2
|
-
/**
|
3
|
-
* This is the entry point for the UMD module.
|
4
|
-
* The entry point for a future ESM package should be index.ts
|
5
|
-
*/
|
6
|
-
var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
7
|
-
if (typeof globalObject !== "undefined") {
|
8
|
-
for (var key in postProcessLibrary) {
|
9
|
-
globalObject.BABYLON[key] = postProcessLibrary[key];
|
10
|
-
}
|
11
|
-
}
|
12
|
-
export * from "./asciiArt/index.js";
|
1
|
+
import * as postProcessLibrary from "./asciiArt/index.js";
|
2
|
+
/**
|
3
|
+
* This is the entry point for the UMD module.
|
4
|
+
* The entry point for a future ESM package should be index.ts
|
5
|
+
*/
|
6
|
+
var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
7
|
+
if (typeof globalObject !== "undefined") {
|
8
|
+
for (var key in postProcessLibrary) {
|
9
|
+
globalObject.BABYLON[key] = postProcessLibrary[key];
|
10
|
+
}
|
11
|
+
}
|
12
|
+
export * from "./asciiArt/index.js";
|
13
13
|
//# sourceMappingURL=legacy-asciiArt.js.map
|
@@ -1 +1 @@
|
|
1
|
-
export * from "./digitalRain/index.js";
|
1
|
+
export * from "./digitalRain/index.js";
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import * as postProcessLibrary from "./digitalRain/index.js";
|
2
|
-
/**
|
3
|
-
* This is the entry point for the UMD module.
|
4
|
-
* The entry point for a future ESM package should be index.ts
|
5
|
-
*/
|
6
|
-
var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
7
|
-
if (typeof globalObject !== "undefined") {
|
8
|
-
for (var key in postProcessLibrary) {
|
9
|
-
globalObject.BABYLON[key] = postProcessLibrary[key];
|
10
|
-
}
|
11
|
-
}
|
12
|
-
export * from "./digitalRain/index.js";
|
1
|
+
import * as postProcessLibrary from "./digitalRain/index.js";
|
2
|
+
/**
|
3
|
+
* This is the entry point for the UMD module.
|
4
|
+
* The entry point for a future ESM package should be index.ts
|
5
|
+
*/
|
6
|
+
var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
7
|
+
if (typeof globalObject !== "undefined") {
|
8
|
+
for (var key in postProcessLibrary) {
|
9
|
+
globalObject.BABYLON[key] = postProcessLibrary[key];
|
10
|
+
}
|
11
|
+
}
|
12
|
+
export * from "./digitalRain/index.js";
|
13
13
|
//# sourceMappingURL=legacy-digitalRain.js.map
|
package/legacy/legacy.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from "./index.js";
|
1
|
+
export * from "./index.js";
|
package/legacy/legacy.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
import * as postProcessLibrary from "./index.js";
|
2
|
-
/**
|
3
|
-
*
|
4
|
-
* This is the entry point for the UMD module.
|
5
|
-
* The entry point for a future ESM package should be index.ts
|
6
|
-
*/
|
7
|
-
var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
8
|
-
if (typeof globalObject !== "undefined") {
|
9
|
-
for (var key in postProcessLibrary) {
|
10
|
-
globalObject.BABYLON[key] = postProcessLibrary[key];
|
11
|
-
}
|
12
|
-
}
|
13
|
-
export * from "./index.js";
|
1
|
+
import * as postProcessLibrary from "./index.js";
|
2
|
+
/**
|
3
|
+
*
|
4
|
+
* This is the entry point for the UMD module.
|
5
|
+
* The entry point for a future ESM package should be index.ts
|
6
|
+
*/
|
7
|
+
var globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
8
|
+
if (typeof globalObject !== "undefined") {
|
9
|
+
for (var key in postProcessLibrary) {
|
10
|
+
globalObject.BABYLON[key] = postProcessLibrary[key];
|
11
|
+
}
|
12
|
+
}
|
13
|
+
export * from "./index.js";
|
14
14
|
//# sourceMappingURL=legacy.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/post-processes",
|
3
|
-
"version": "5.0.0-rc.
|
3
|
+
"version": "5.0.0-rc.9",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"prepublishOnly": "build-tools -c prepare-es6-build"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"@babylonjs/core": "^5.0.0-rc.
|
21
|
+
"@babylonjs/core": "^5.0.0-rc.9",
|
22
22
|
"tslib": "^2.3.1"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|