babylonjs.postProcess.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-post-process", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-post-process"] = factory(require("babylonjs"));
  8. else
  9. root["POSTPROCESSES"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_decorators__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/webpack/buildin/global.js":
  99. /*!***********************************!*\
  100. !*** (webpack)/buildin/global.js ***!
  101. \***********************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || new Function("return this")();
  112. } catch (e) {
  113. // This works if the window reference is available
  114. if (typeof window === "object") g = window;
  115. }
  116. // g can still be undefined, but nothing to do about it...
  117. // We return undefined, instead of nothing here, so it's
  118. // easier to handle this case. if(!global) { ...}
  119. module.exports = g;
  120. /***/ }),
  121. /***/ "../node_modules/tslib/tslib.es6.js":
  122. /*!******************************************!*\
  123. !*** ../node_modules/tslib/tslib.es6.js ***!
  124. \******************************************/
  125. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127. "use strict";
  128. __webpack_require__.r(__webpack_exports__);
  129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  148. /*! *****************************************************************************
  149. Copyright (c) Microsoft Corporation. All rights reserved.
  150. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  151. this file except in compliance with the License. You may obtain a copy of the
  152. License at http://www.apache.org/licenses/LICENSE-2.0
  153. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  154. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  155. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  156. MERCHANTABLITY OR NON-INFRINGEMENT.
  157. See the Apache Version 2.0 License for specific language governing permissions
  158. and limitations under the License.
  159. ***************************************************************************** */
  160. /* global Reflect, Promise */
  161. var extendStatics = function(d, b) {
  162. extendStatics = Object.setPrototypeOf ||
  163. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  164. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  165. return extendStatics(d, b);
  166. };
  167. function __extends(d, b) {
  168. extendStatics(d, b);
  169. function __() { this.constructor = d; }
  170. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  171. }
  172. var __assign = function() {
  173. __assign = Object.assign || function __assign(t) {
  174. for (var s, i = 1, n = arguments.length; i < n; i++) {
  175. s = arguments[i];
  176. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  177. }
  178. return t;
  179. }
  180. return __assign.apply(this, arguments);
  181. }
  182. function __rest(s, e) {
  183. var t = {};
  184. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  185. t[p] = s[p];
  186. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  187. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  188. t[p[i]] = s[p[i]];
  189. return t;
  190. }
  191. function __decorate(decorators, target, key, desc) {
  192. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  193. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  194. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  195. return c > 3 && r && Object.defineProperty(target, key, r), r;
  196. }
  197. function __param(paramIndex, decorator) {
  198. return function (target, key) { decorator(target, key, paramIndex); }
  199. }
  200. function __metadata(metadataKey, metadataValue) {
  201. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  202. }
  203. function __awaiter(thisArg, _arguments, P, generator) {
  204. return new (P || (P = Promise))(function (resolve, reject) {
  205. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  206. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  207. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  208. step((generator = generator.apply(thisArg, _arguments || [])).next());
  209. });
  210. }
  211. function __generator(thisArg, body) {
  212. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  213. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  214. function verb(n) { return function (v) { return step([n, v]); }; }
  215. function step(op) {
  216. if (f) throw new TypeError("Generator is already executing.");
  217. while (_) try {
  218. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  219. if (y = 0, t) op = [op[0] & 2, t.value];
  220. switch (op[0]) {
  221. case 0: case 1: t = op; break;
  222. case 4: _.label++; return { value: op[1], done: false };
  223. case 5: _.label++; y = op[1]; op = [0]; continue;
  224. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  225. default:
  226. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  227. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  228. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  229. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  230. if (t[2]) _.ops.pop();
  231. _.trys.pop(); continue;
  232. }
  233. op = body.call(thisArg, _);
  234. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  235. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  236. }
  237. }
  238. function __exportStar(m, exports) {
  239. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  240. }
  241. function __values(o) {
  242. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  243. if (m) return m.call(o);
  244. return {
  245. next: function () {
  246. if (o && i >= o.length) o = void 0;
  247. return { value: o && o[i++], done: !o };
  248. }
  249. };
  250. }
  251. function __read(o, n) {
  252. var m = typeof Symbol === "function" && o[Symbol.iterator];
  253. if (!m) return o;
  254. var i = m.call(o), r, ar = [], e;
  255. try {
  256. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  257. }
  258. catch (error) { e = { error: error }; }
  259. finally {
  260. try {
  261. if (r && !r.done && (m = i["return"])) m.call(i);
  262. }
  263. finally { if (e) throw e.error; }
  264. }
  265. return ar;
  266. }
  267. function __spread() {
  268. for (var ar = [], i = 0; i < arguments.length; i++)
  269. ar = ar.concat(__read(arguments[i]));
  270. return ar;
  271. }
  272. function __await(v) {
  273. return this instanceof __await ? (this.v = v, this) : new __await(v);
  274. }
  275. function __asyncGenerator(thisArg, _arguments, generator) {
  276. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  277. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  278. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  279. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  280. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  281. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  282. function fulfill(value) { resume("next", value); }
  283. function reject(value) { resume("throw", value); }
  284. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  285. }
  286. function __asyncDelegator(o) {
  287. var i, p;
  288. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  289. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  290. }
  291. function __asyncValues(o) {
  292. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  293. var m = o[Symbol.asyncIterator], i;
  294. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  295. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  296. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  297. }
  298. function __makeTemplateObject(cooked, raw) {
  299. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  300. return cooked;
  301. };
  302. function __importStar(mod) {
  303. if (mod && mod.__esModule) return mod;
  304. var result = {};
  305. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  306. result.default = mod;
  307. return result;
  308. }
  309. function __importDefault(mod) {
  310. return (mod && mod.__esModule) ? mod : { default: mod };
  311. }
  312. /***/ }),
  313. /***/ "./asciiArt/asciiArtPostProcess.ts":
  314. /*!*****************************************!*\
  315. !*** ./asciiArt/asciiArtPostProcess.ts ***!
  316. \*****************************************/
  317. /*! exports provided: AsciiArtFontTexture, AsciiArtPostProcess */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsciiArtFontTexture", function() { return AsciiArtFontTexture; });
  322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsciiArtPostProcess", function() { return AsciiArtPostProcess; });
  323. <<<<<<< HEAD
  324. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  325. =======
  326. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  327. >>>>>>> 818e3fe07aba4c9e29fe98b3fc85b07945a71d09
  328. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
  329. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  330. /* harmony import */ var _asciiart_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./asciiart.fragment */ "./asciiArt/asciiart.fragment.ts");
  331. /**
  332. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  333. *
  334. * It basically takes care rendering the font front the given font size to a texture.
  335. * This is used later on in the postprocess.
  336. */
  337. var AsciiArtFontTexture = /** @class */ (function (_super) {
  338. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AsciiArtFontTexture, _super);
  339. /**
  340. * Create a new instance of the Ascii Art FontTexture class
  341. * @param name the name of the texture
  342. * @param font the font to use, use the W3C CSS notation
  343. * @param text the caracter set to use in the rendering.
  344. * @param scene the scene that owns the texture
  345. */
  346. function AsciiArtFontTexture(name, font, text, scene) {
  347. if (scene === void 0) { scene = null; }
  348. var _this = _super.call(this, scene) || this;
  349. scene = _this.getScene();
  350. if (!scene) {
  351. return _this;
  352. }
  353. _this.name = name;
  354. _this._text == text;
  355. _this._font == font;
  356. _this.wrapU = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  357. _this.wrapV = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  358. //this.anisotropicFilteringLevel = 1;
  359. // Get the font specific info.
  360. var maxCharHeight = _this.getFontHeight(font);
  361. var maxCharWidth = _this.getFontWidth(font);
  362. _this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
  363. // This is an approximate size, but should always be able to fit at least the maxCharCount.
  364. var textureWidth = Math.ceil(_this._charSize * text.length);
  365. var textureHeight = _this._charSize;
  366. // Create the texture that will store the font characters.
  367. _this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE);
  368. //scene.getEngine().setclamp
  369. var textureSize = _this.getSize();
  370. // Create a canvas with the final size: the one matching the texture.
  371. var canvas = document.createElement("canvas");
  372. canvas.width = textureSize.width;
  373. canvas.height = textureSize.height;
  374. var context = canvas.getContext("2d");
  375. context.textBaseline = "top";
  376. context.font = font;
  377. context.fillStyle = "white";
  378. context.imageSmoothingEnabled = false;
  379. // Sets the text in the texture.
  380. for (var i = 0; i < text.length; i++) {
  381. context.fillText(text[i], i * _this._charSize, -maxCharHeight.offset);
  382. }
  383. // Flush the text in the dynamic texture.
  384. scene.getEngine().updateDynamicTexture(_this._texture, canvas, false, true);
  385. return _this;
  386. }
  387. Object.defineProperty(AsciiArtFontTexture.prototype, "charSize", {
  388. /**
  389. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  390. */
  391. get: function () {
  392. return this._charSize;
  393. },
  394. enumerable: true,
  395. configurable: true
  396. });
  397. /**
  398. * Gets the max char width of a font.
  399. * @param font the font to use, use the W3C CSS notation
  400. * @return the max char width
  401. */
  402. AsciiArtFontTexture.prototype.getFontWidth = function (font) {
  403. var fontDraw = document.createElement("canvas");
  404. var ctx = fontDraw.getContext('2d');
  405. ctx.fillStyle = 'white';
  406. ctx.font = font;
  407. return ctx.measureText("W").width;
  408. };
  409. // More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/
  410. /**
  411. * Gets the max char height of a font.
  412. * @param font the font to use, use the W3C CSS notation
  413. * @return the max char height
  414. */
  415. AsciiArtFontTexture.prototype.getFontHeight = function (font) {
  416. var fontDraw = document.createElement("canvas");
  417. var ctx = fontDraw.getContext('2d');
  418. ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
  419. ctx.textBaseline = 'top';
  420. ctx.fillStyle = 'white';
  421. ctx.font = font;
  422. ctx.fillText('jH|', 0, 0);
  423. var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
  424. var start = -1;
  425. var end = -1;
  426. for (var row = 0; row < fontDraw.height; row++) {
  427. for (var column = 0; column < fontDraw.width; column++) {
  428. var index = (row * fontDraw.width + column) * 4;
  429. if (pixels[index] === 0) {
  430. if (column === fontDraw.width - 1 && start !== -1) {
  431. end = row;
  432. row = fontDraw.height;
  433. break;
  434. }
  435. continue;
  436. }
  437. else {
  438. if (start === -1) {
  439. start = row;
  440. }
  441. break;
  442. }
  443. }
  444. }
  445. return { height: (end - start) + 1, offset: start - 1 };
  446. };
  447. /**
  448. * Clones the current AsciiArtTexture.
  449. * @return the clone of the texture.
  450. */
  451. AsciiArtFontTexture.prototype.clone = function () {
  452. return new AsciiArtFontTexture(this.name, this._font, this._text, this.getScene());
  453. };
  454. /**
  455. * Parses a json object representing the texture and returns an instance of it.
  456. * @param source the source JSON representation
  457. * @param scene the scene to create the texture for
  458. * @return the parsed texture
  459. */
  460. AsciiArtFontTexture.Parse = function (source, scene) {
  461. var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new AsciiArtFontTexture(source.name, source.font, source.text, scene); }, source, scene, null);
  462. return texture;
  463. };
  464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  465. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("font")
  466. ], AsciiArtFontTexture.prototype, "_font", void 0);
  467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  468. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("text")
  469. ], AsciiArtFontTexture.prototype, "_text", void 0);
  470. return AsciiArtFontTexture;
  471. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["BaseTexture"]));
  472. /**
  473. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  474. *
  475. * Simmply add it to your scene and let the nerd that lives in you have fun.
  476. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  477. */
  478. var AsciiArtPostProcess = /** @class */ (function (_super) {
  479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AsciiArtPostProcess, _super);
  480. /**
  481. * Instantiates a new Ascii Art Post Process.
  482. * @param name the name to give to the postprocess
  483. * @camera the camera to apply the post process to.
  484. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  485. */
  486. function AsciiArtPostProcess(name, camera, options) {
  487. var _this = _super.call(this, name, 'asciiart', ['asciiArtFontInfos', 'asciiArtOptions'], ['asciiArtFont'], {
  488. width: camera.getEngine().getRenderWidth(),
  489. height: camera.getEngine().getRenderHeight()
  490. }, camera, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
  491. /**
  492. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  493. * This number is defined between 0 and 1;
  494. */
  495. _this.mixToTile = 0;
  496. /**
  497. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  498. * This number is defined between 0 and 1;
  499. */
  500. _this.mixToNormal = 0;
  501. // Default values.
  502. var font = "40px Monospace";
  503. var characterSet = " `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";
  504. // Use options.
  505. if (options) {
  506. if (typeof (options) === "string") {
  507. font = options;
  508. }
  509. else {
  510. font = options.font || font;
  511. characterSet = options.characterSet || characterSet;
  512. _this.mixToTile = options.mixToTile || _this.mixToTile;
  513. _this.mixToNormal = options.mixToNormal || _this.mixToNormal;
  514. }
  515. }
  516. _this._asciiArtFontTexture = new AsciiArtFontTexture(name, font, characterSet, camera.getScene());
  517. var textureSize = _this._asciiArtFontTexture.getSize();
  518. _this.onApply = function (effect) {
  519. effect.setTexture("asciiArtFont", _this._asciiArtFontTexture);
  520. effect.setFloat4("asciiArtFontInfos", _this._asciiArtFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);
  521. effect.setFloat4("asciiArtOptions", _this.width, _this.height, _this.mixToNormal, _this.mixToTile);
  522. };
  523. return _this;
  524. }
  525. return AsciiArtPostProcess;
  526. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  527. /***/ }),
  528. /***/ "./asciiArt/asciiart.fragment.ts":
  529. /*!***************************************!*\
  530. !*** ./asciiArt/asciiart.fragment.ts ***!
  531. \***************************************/
  532. /*! exports provided: asciiartPixelShader */
  533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  534. "use strict";
  535. __webpack_require__.r(__webpack_exports__);
  536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "asciiartPixelShader", function() { return asciiartPixelShader; });
  537. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
  538. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  539. var name = 'asciiartPixelShader';
  540. 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\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}";
  541. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  542. /** @hidden */
  543. var asciiartPixelShader = { name: name, shader: shader };
  544. /***/ }),
  545. /***/ "./asciiArt/index.ts":
  546. /*!***************************!*\
  547. !*** ./asciiArt/index.ts ***!
  548. \***************************/
  549. /*! exports provided: AsciiArtFontTexture, AsciiArtPostProcess */
  550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  551. "use strict";
  552. __webpack_require__.r(__webpack_exports__);
  553. /* harmony import */ var _asciiArtPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./asciiArtPostProcess */ "./asciiArt/asciiArtPostProcess.ts");
  554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsciiArtFontTexture", function() { return _asciiArtPostProcess__WEBPACK_IMPORTED_MODULE_0__["AsciiArtFontTexture"]; });
  555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsciiArtPostProcess", function() { return _asciiArtPostProcess__WEBPACK_IMPORTED_MODULE_0__["AsciiArtPostProcess"]; });
  556. /***/ }),
  557. /***/ "./digitalRain/digitalRainPostProcess.ts":
  558. /*!***********************************************!*\
  559. !*** ./digitalRain/digitalRainPostProcess.ts ***!
  560. \***********************************************/
  561. /*! exports provided: DigitalRainFontTexture, DigitalRainPostProcess */
  562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  563. "use strict";
  564. __webpack_require__.r(__webpack_exports__);
  565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DigitalRainFontTexture", function() { return DigitalRainFontTexture; });
  566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DigitalRainPostProcess", function() { return DigitalRainPostProcess; });
  567. <<<<<<< HEAD
  568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  569. =======
  570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  571. >>>>>>> 818e3fe07aba4c9e29fe98b3fc85b07945a71d09
  572. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
  573. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  574. /* harmony import */ var _digitalrain_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./digitalrain.fragment */ "./digitalRain/digitalrain.fragment.ts");
  575. /**
  576. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  577. *
  578. * It basically takes care rendering the font front the given font size to a texture.
  579. * This is used later on in the postprocess.
  580. */
  581. var DigitalRainFontTexture = /** @class */ (function (_super) {
  582. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DigitalRainFontTexture, _super);
  583. /**
  584. * Create a new instance of the Digital Rain FontTexture class
  585. * @param name the name of the texture
  586. * @param font the font to use, use the W3C CSS notation
  587. * @param text the caracter set to use in the rendering.
  588. * @param scene the scene that owns the texture
  589. */
  590. function DigitalRainFontTexture(name, font, text, scene) {
  591. if (scene === void 0) { scene = null; }
  592. var _this = _super.call(this, scene) || this;
  593. scene = _this.getScene();
  594. if (!scene) {
  595. return _this;
  596. }
  597. _this.name = name;
  598. _this._text == text;
  599. _this._font == font;
  600. _this.wrapU = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  601. _this.wrapV = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  602. // Get the font specific info.
  603. var maxCharHeight = _this.getFontHeight(font);
  604. var maxCharWidth = _this.getFontWidth(font);
  605. _this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
  606. // This is an approximate size, but should always be able to fit at least the maxCharCount.
  607. var textureWidth = _this._charSize;
  608. var textureHeight = Math.ceil(_this._charSize * text.length);
  609. // Create the texture that will store the font characters.
  610. _this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE);
  611. //scene.getEngine().setclamp
  612. var textureSize = _this.getSize();
  613. // Create a canvas with the final size: the one matching the texture.
  614. var canvas = document.createElement("canvas");
  615. canvas.width = textureSize.width;
  616. canvas.height = textureSize.height;
  617. var context = canvas.getContext("2d");
  618. context.textBaseline = "top";
  619. context.font = font;
  620. context.fillStyle = "white";
  621. context.imageSmoothingEnabled = false;
  622. // Sets the text in the texture.
  623. for (var i = 0; i < text.length; i++) {
  624. context.fillText(text[i], 0, i * _this._charSize - maxCharHeight.offset);
  625. }
  626. // Flush the text in the dynamic texture.
  627. scene.getEngine().updateDynamicTexture(_this._texture, canvas, false, true);
  628. return _this;
  629. }
  630. Object.defineProperty(DigitalRainFontTexture.prototype, "charSize", {
  631. /**
  632. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  633. */
  634. get: function () {
  635. return this._charSize;
  636. },
  637. enumerable: true,
  638. configurable: true
  639. });
  640. /**
  641. * Gets the max char width of a font.
  642. * @param font the font to use, use the W3C CSS notation
  643. * @return the max char width
  644. */
  645. DigitalRainFontTexture.prototype.getFontWidth = function (font) {
  646. var fontDraw = document.createElement("canvas");
  647. var ctx = fontDraw.getContext('2d');
  648. ctx.fillStyle = 'white';
  649. ctx.font = font;
  650. return ctx.measureText("W").width;
  651. };
  652. // More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/
  653. /**
  654. * Gets the max char height of a font.
  655. * @param font the font to use, use the W3C CSS notation
  656. * @return the max char height
  657. */
  658. DigitalRainFontTexture.prototype.getFontHeight = function (font) {
  659. var fontDraw = document.createElement("canvas");
  660. var ctx = fontDraw.getContext('2d');
  661. ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
  662. ctx.textBaseline = 'top';
  663. ctx.fillStyle = 'white';
  664. ctx.font = font;
  665. ctx.fillText('jH|', 0, 0);
  666. var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
  667. var start = -1;
  668. var end = -1;
  669. for (var row = 0; row < fontDraw.height; row++) {
  670. for (var column = 0; column < fontDraw.width; column++) {
  671. var index = (row * fontDraw.width + column) * 4;
  672. if (pixels[index] === 0) {
  673. if (column === fontDraw.width - 1 && start !== -1) {
  674. end = row;
  675. row = fontDraw.height;
  676. break;
  677. }
  678. continue;
  679. }
  680. else {
  681. if (start === -1) {
  682. start = row;
  683. }
  684. break;
  685. }
  686. }
  687. }
  688. return { height: (end - start) + 1, offset: start - 1 };
  689. };
  690. /**
  691. * Clones the current DigitalRainFontTexture.
  692. * @return the clone of the texture.
  693. */
  694. DigitalRainFontTexture.prototype.clone = function () {
  695. return new DigitalRainFontTexture(this.name, this._font, this._text, this.getScene());
  696. };
  697. /**
  698. * Parses a json object representing the texture and returns an instance of it.
  699. * @param source the source JSON representation
  700. * @param scene the scene to create the texture for
  701. * @return the parsed texture
  702. */
  703. DigitalRainFontTexture.Parse = function (source, scene) {
  704. var texture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DigitalRainFontTexture(source.name, source.font, source.text, scene); }, source, scene, null);
  705. return texture;
  706. };
  707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  708. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("font")
  709. ], DigitalRainFontTexture.prototype, "_font", void 0);
  710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  711. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("text")
  712. ], DigitalRainFontTexture.prototype, "_text", void 0);
  713. return DigitalRainFontTexture;
  714. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["BaseTexture"]));
  715. /**
  716. * DigitalRainPostProcess helps rendering everithing in digital rain.
  717. *
  718. * Simmply add it to your scene and let the nerd that lives in you have fun.
  719. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  720. */
  721. var DigitalRainPostProcess = /** @class */ (function (_super) {
  722. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DigitalRainPostProcess, _super);
  723. /**
  724. * Instantiates a new Digital Rain Post Process.
  725. * @param name the name to give to the postprocess
  726. * @camera the camera to apply the post process to.
  727. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  728. */
  729. function DigitalRainPostProcess(name, camera, options) {
  730. var _this = _super.call(this, name, 'digitalrain', ['digitalRainFontInfos', 'digitalRainOptions', 'cosTimeZeroOne', 'matrixSpeed'], ['digitalRainFont'], {
  731. width: camera.getEngine().getRenderWidth(),
  732. height: camera.getEngine().getRenderHeight()
  733. }, camera, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
  734. /**
  735. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  736. * This number is defined between 0 and 1;
  737. */
  738. _this.mixToTile = 0;
  739. /**
  740. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  741. * This number is defined between 0 and 1;
  742. */
  743. _this.mixToNormal = 0;
  744. // Default values.
  745. var font = "15px Monospace";
  746. var characterSet = "古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";
  747. // Use options.
  748. if (options) {
  749. if (typeof (options) === "string") {
  750. font = options;
  751. }
  752. else {
  753. font = options.font || font;
  754. _this.mixToTile = options.mixToTile || _this.mixToTile;
  755. _this.mixToNormal = options.mixToNormal || _this.mixToNormal;
  756. }
  757. }
  758. _this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, camera.getScene());
  759. var textureSize = _this._digitalRainFontTexture.getSize();
  760. var alpha = 0.0;
  761. var cosTimeZeroOne = 0.0;
  762. var matrix = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["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());
  763. _this.onApply = function (effect) {
  764. effect.setTexture("digitalRainFont", _this._digitalRainFontTexture);
  765. effect.setFloat4("digitalRainFontInfos", _this._digitalRainFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);
  766. effect.setFloat4("digitalRainOptions", _this.width, _this.height, _this.mixToNormal, _this.mixToTile);
  767. effect.setMatrix("matrixSpeed", matrix);
  768. alpha += 0.003;
  769. cosTimeZeroOne = alpha;
  770. effect.setFloat('cosTimeZeroOne', cosTimeZeroOne);
  771. };
  772. return _this;
  773. }
  774. return DigitalRainPostProcess;
  775. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  776. /***/ }),
  777. /***/ "./digitalRain/digitalrain.fragment.ts":
  778. /*!*********************************************!*\
  779. !*** ./digitalRain/digitalrain.fragment.ts ***!
  780. \*********************************************/
  781. /*! exports provided: digitalrainPixelShader */
  782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  783. "use strict";
  784. __webpack_require__.r(__webpack_exports__);
  785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "digitalrainPixelShader", function() { return digitalrainPixelShader; });
  786. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
  787. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  788. var name = 'digitalrainPixelShader';
  789. 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\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}";
  790. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  791. /** @hidden */
  792. var digitalrainPixelShader = { name: name, shader: shader };
  793. /***/ }),
  794. /***/ "./digitalRain/index.ts":
  795. /*!******************************!*\
  796. !*** ./digitalRain/index.ts ***!
  797. \******************************/
  798. /*! exports provided: DigitalRainFontTexture, DigitalRainPostProcess */
  799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  800. "use strict";
  801. __webpack_require__.r(__webpack_exports__);
  802. /* harmony import */ var _digitalRainPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./digitalRainPostProcess */ "./digitalRain/digitalRainPostProcess.ts");
  803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DigitalRainFontTexture", function() { return _digitalRainPostProcess__WEBPACK_IMPORTED_MODULE_0__["DigitalRainFontTexture"]; });
  804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DigitalRainPostProcess", function() { return _digitalRainPostProcess__WEBPACK_IMPORTED_MODULE_0__["DigitalRainPostProcess"]; });
  805. /***/ }),
  806. /***/ "./index.ts":
  807. /*!******************!*\
  808. !*** ./index.ts ***!
  809. \******************/
  810. /*! exports provided: AsciiArtFontTexture, AsciiArtPostProcess, DigitalRainFontTexture, DigitalRainPostProcess, OceanPostProcess */
  811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  812. "use strict";
  813. __webpack_require__.r(__webpack_exports__);
  814. /* harmony import */ var _asciiArt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./asciiArt */ "./asciiArt/index.ts");
  815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsciiArtFontTexture", function() { return _asciiArt__WEBPACK_IMPORTED_MODULE_0__["AsciiArtFontTexture"]; });
  816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsciiArtPostProcess", function() { return _asciiArt__WEBPACK_IMPORTED_MODULE_0__["AsciiArtPostProcess"]; });
  817. /* harmony import */ var _digitalRain__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./digitalRain */ "./digitalRain/index.ts");
  818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DigitalRainFontTexture", function() { return _digitalRain__WEBPACK_IMPORTED_MODULE_1__["DigitalRainFontTexture"]; });
  819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DigitalRainPostProcess", function() { return _digitalRain__WEBPACK_IMPORTED_MODULE_1__["DigitalRainPostProcess"]; });
  820. /* harmony import */ var _ocean__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ocean */ "./ocean/index.ts");
  821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OceanPostProcess", function() { return _ocean__WEBPACK_IMPORTED_MODULE_2__["OceanPostProcess"]; });
  822. /***/ }),
  823. /***/ "./legacy/legacy.ts":
  824. /*!**************************!*\
  825. !*** ./legacy/legacy.ts ***!
  826. \**************************/
  827. /*! exports provided: AsciiArtFontTexture, AsciiArtPostProcess, DigitalRainFontTexture, DigitalRainPostProcess, OceanPostProcess */
  828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  829. "use strict";
  830. __webpack_require__.r(__webpack_exports__);
  831. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsciiArtFontTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsciiArtFontTexture"]; });
  833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsciiArtPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsciiArtPostProcess"]; });
  834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DigitalRainFontTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DigitalRainFontTexture"]; });
  835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DigitalRainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DigitalRainPostProcess"]; });
  836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OceanPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OceanPostProcess"]; });
  837. /**
  838. *
  839. * This is the entry point for the UMD module.
  840. * The entry point for a future ESM package should be index.ts
  841. */
  842. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  843. if (typeof globalObject !== "undefined") {
  844. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  845. globalObject.BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  846. }
  847. }
  848. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  849. /***/ }),
  850. /***/ "./ocean/index.ts":
  851. /*!************************!*\
  852. !*** ./ocean/index.ts ***!
  853. \************************/
  854. /*! exports provided: OceanPostProcess */
  855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  856. "use strict";
  857. __webpack_require__.r(__webpack_exports__);
  858. /* harmony import */ var _oceanPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./oceanPostProcess */ "./ocean/oceanPostProcess.ts");
  859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OceanPostProcess", function() { return _oceanPostProcess__WEBPACK_IMPORTED_MODULE_0__["OceanPostProcess"]; });
  860. /***/ }),
  861. /***/ "./ocean/oceanPostProcess.fragment.ts":
  862. /*!********************************************!*\
  863. !*** ./ocean/oceanPostProcess.fragment.ts ***!
  864. \********************************************/
  865. /*! exports provided: oceanPostProcessPixelShader */
  866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  867. "use strict";
  868. __webpack_require__.r(__webpack_exports__);
  869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "oceanPostProcessPixelShader", function() { return oceanPostProcessPixelShader; });
  870. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
  871. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  872. var name = 'oceanPostProcessPixelShader';
  873. var shader = "\n\nuniform sampler2D textureSampler;\nuniform sampler2D positionSampler;\n#ifdef REFLECTION_ENABLED\nuniform sampler2D reflectionSampler;\n#endif\n#ifdef REFRACTION_ENABLED\nuniform sampler2D refractionSampler;\n#endif\nuniform float time;\nuniform vec2 resolution;\nuniform vec3 cameraRotation;\nuniform vec3 cameraPosition;\n\nvarying vec2 vUV;\n\nconst int NUM_STEPS=8;\nconst float PI=3.141592;\nconst float EPSILON=1e-3;\n#define EPSILON_NRM (0.1/resolution.x)\n\nconst int ITER_GEOMETRY=8;\nconst int ITER_FRAGMENT=5;\nconst float SEA_HEIGHT=0.6;\nconst float SEA_CHOPPY=4.0;\nconst float SEA_SPEED=0.8;\nconst float SEA_FREQ=0.16;\nconst vec3 SEA_BASE=vec3(0.1,0.19,0.22);\nconst vec3 SEA_WATER_COLOR=vec3(0.8,0.9,0.6);\n#define SEA_TIME (1.0+time*SEA_SPEED)\nconst mat2 octave_m=mat2(1.6,1.2,-1.2,1.6);\n\nmat3 fromEuler(vec3 ang)\n{\nvec2 a1=vec2(sin(ang.x),cos(ang.x));\nvec2 a2=vec2(sin(ang.y),cos(ang.y));\nvec2 a3=vec2(sin(ang.z),cos(ang.z));\nmat3 m;\nm[0]=vec3(a1.y*a3.y+a1.x*a2.x*a3.x,a1.y*a2.x*a3.x+a3.y*a1.x,-a2.y*a3.x);\nm[1]=vec3(-a2.y*a1.x,a1.y*a2.y,a2.x);\nm[2]=vec3(a3.y*a1.x*a2.x+a1.y*a3.x,a1.x*a3.x-a1.y*a3.y*a2.x,a2.y*a3.y);\nreturn m;\n}\nfloat hash( vec2 p )\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn fract(sin(h)*43758.5453123);\n}\nfloat noise( in vec2 p )\n{\nvec2 i=floor( p );\nvec2 f=fract( p );\nvec2 u=f*f*(3.0-2.0*f);\nreturn -1.0+2.0*mix( mix( hash( i+vec2(0.0,0.0) ),\nhash( i+vec2(1.0,0.0) ),u.x),\nmix( hash( i+vec2(0.0,1.0) ),\nhash( i+vec2(1.0,1.0) ),u.x),u.y);\n}\n\nfloat diffuse(vec3 n,vec3 l,float p)\n{\nreturn pow(dot(n,l)*0.4+0.6,p);\n}\nfloat specular(vec3 n,vec3 l,vec3 e,float s)\n{\nfloat nrm=(s+8.0)/(PI*8.0);\nreturn pow(max(dot(reflect(e,n),l),0.0),s)*nrm;\n}\n\nfloat sea_octave(vec2 uv,float choppy)\n{\nuv+=noise(uv);\nvec2 wv=1.0-abs(sin(uv));\nvec2 swv=abs(cos(uv));\nwv=mix(wv,swv,wv);\nreturn pow(1.0-pow(wv.x*wv.y,0.65),choppy);\n}\nfloat map(vec3 p)\n{\nfloat freq=SEA_FREQ;\nfloat amp=SEA_HEIGHT;\nfloat choppy=SEA_CHOPPY;\nvec2 uv=p.xz; uv.x*=0.75;\nfloat d,h=0.0;\nfor(int i=0; i<ITER_GEOMETRY; i++)\n{\nd=sea_octave((uv+SEA_TIME)*freq,choppy);\nd+=sea_octave((uv-SEA_TIME)*freq,choppy);\nh+=d*amp;\nuv*=octave_m; freq*=1.9; amp*=0.22;\nchoppy=mix(choppy,1.0,0.2);\n}\nreturn p.y-h;\n}\nfloat map_detailed(vec3 p)\n{\nfloat freq=SEA_FREQ;\nfloat amp=SEA_HEIGHT;\nfloat choppy=SEA_CHOPPY;\nvec2 uv=p.xz; uv.x*=0.75;\nfloat d,h=0.0;\nfor(int i=0; i<ITER_FRAGMENT; i++)\n{\nd=sea_octave((uv+SEA_TIME)*freq,choppy);\nd+=sea_octave((uv-SEA_TIME)*freq,choppy);\nh+=d*amp;\nuv*=octave_m; freq*=1.9; amp*=0.22;\nchoppy=mix(choppy,1.0,0.2);\n}\nreturn p.y-h;\n}\nvec3 getSeaColor(vec3 p,vec3 n,vec3 l,vec3 eye,vec3 dist)\n{\nfloat fresnel=clamp(1.0-dot(n,-eye),0.0,1.0);\nfresnel=pow(fresnel,3.0)*0.65;\n#if defined(REFLECTION_ENABLED) || defined(REFRACTION_ENABLED)\nvec2 reflectionUv=vec2(vUV.x,vUV.y+normalize(n).y);\n#endif\n#ifdef REFLECTION_ENABLED\nvec3 reflected=texture2D(reflectionSampler,reflectionUv).rgb*(1.0-fresnel);\n#else\nvec3 eyeNormal=reflect(eye,n);\neyeNormal.y=max(eyeNormal.y,0.0);\nvec3 reflected=vec3(pow(1.0-eyeNormal.y,2.0),1.0-eyeNormal.y,0.6+(1.0-eyeNormal.y)*0.4);\n#endif\n#ifdef REFRACTION_ENABLED\nvec3 refracted=SEA_BASE+diffuse(n,l,80.0)*SEA_WATER_COLOR*0.12;\nrefracted+=(texture2D(refractionSampler,reflectionUv).rgb*fresnel);\n#else\nvec3 refracted=SEA_BASE+diffuse(n,l,80.0)*SEA_WATER_COLOR*0.12;\n#endif\nvec3 color=mix(refracted,reflected,fresnel);\nfloat atten=max(1.0-dot(dist,dist)*0.001,0.0);\ncolor+=SEA_WATER_COLOR*(p.y-SEA_HEIGHT)*0.18*atten;\ncolor+=vec3(specular(n,l,eye,60.0));\nreturn color;\n}\n\nvec3 getNormal(vec3 p,float eps)\n{\nvec3 n;\nn.y=map_detailed(p);\nn.x=map_detailed(vec3(p.x+eps,p.y,p.z))-n.y;\nn.z=map_detailed(vec3(p.x,p.y,p.z+eps))-n.y;\nn.y=eps;\nreturn normalize(n);\n}\nfloat heightMapTracing(vec3 ori,vec3 dir,out vec3 p)\n{\nfloat tm=0.0;\nfloat tx=1000.0;\nfloat hx=map(ori+dir*tx);\nif(hx>0.0) return tx;\nfloat hm=map(ori+dir*tm);\nfloat tmid=0.0;\nfor(int i=0; i<NUM_STEPS; i++)\n{\ntmid=mix(tm,tx,hm/(hm-hx));\np=ori+dir*tmid;\nfloat hmid=map(p);\nif(hmid<0.0)\n{\ntx=tmid;\nhx=hmid;\n}\nelse\n{\ntm=tmid;\nhm=hmid;\n}\n}\nreturn tmid;\n}\n\nvoid main()\n{\n#ifdef NOT_SUPPORTED\n\ngl_FragColor=texture2D(textureSampler,vUV);\n#else\nvec2 uv=vUV;\nuv=uv*2.0-1.0;\nuv.x*=resolution.x/resolution.y;\n\nvec3 ang=vec3(cameraRotation.z,cameraRotation.x,cameraRotation.y);\nvec3 ori=vec3(cameraPosition.x,cameraPosition.y,-cameraPosition.z);\nvec3 dir=normalize(vec3(uv.xy,-3.0));\ndir=normalize(dir)*fromEuler(ang);\n\nvec3 p;\nheightMapTracing(ori,dir,p);\nvec3 dist=p-ori;\nvec3 n=getNormal(p,dot(dist,dist)*EPSILON_NRM);\nvec3 light=normalize(vec3(0.0,1.0,0.8));\n\nfloat seaFact=clamp(max(ori.y,0.0),0.0,1.0);\nvec3 position=texture2D(positionSampler,vUV).rgb;\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 color=baseColor;\nif (max(position.y,0.0)<p.y)\n{\n\ncolor=mix(\nbaseColor,\ngetSeaColor(p,n,light,dir,dist),\npow(smoothstep(0.0,-0.05,dir.y),0.3)\n)*seaFact;\n}\ncolor=mix(\ncolor,\nbaseColor*SEA_BASE+diffuse(n,n,80.0)*SEA_WATER_COLOR*0.12,\n1.0-seaFact\n);\n\ngl_FragColor=vec4(pow(color,vec3(0.75)),1.0);\n#endif\n}\n";
  874. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  875. /** @hidden */
  876. var oceanPostProcessPixelShader = { name: name, shader: shader };
  877. /***/ }),
  878. /***/ "./ocean/oceanPostProcess.ts":
  879. /*!***********************************!*\
  880. !*** ./ocean/oceanPostProcess.ts ***!
  881. \***********************************/
  882. /*! exports provided: OceanPostProcess */
  883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  884. "use strict";
  885. __webpack_require__.r(__webpack_exports__);
  886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OceanPostProcess", function() { return OceanPostProcess; });
  887. <<<<<<< HEAD
  888. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  889. =======
  890. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  891. >>>>>>> 818e3fe07aba4c9e29fe98b3fc85b07945a71d09
  892. /* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/decorators");
  893. /* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__);
  894. /* harmony import */ var _oceanPostProcess_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oceanPostProcess.fragment */ "./ocean/oceanPostProcess.fragment.ts");
  895. /**
  896. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  897. *
  898. * Simmply add it to your scene and let the nerd that lives in you have fun.
  899. * Example usage:
  900. * var pp = new OceanPostProcess("myOcean", camera);
  901. * pp.reflectionEnabled = true;
  902. * pp.refractionEnabled = true;
  903. */
  904. var OceanPostProcess = /** @class */ (function (_super) {
  905. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OceanPostProcess, _super);
  906. /**
  907. * Instantiates a new Ocean Post Process.
  908. * @param name the name to give to the postprocess.
  909. * @camera the camera to apply the post process to.
  910. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  911. */
  912. function OceanPostProcess(name, camera, options) {
  913. if (options === void 0) { options = {}; }
  914. var _this = _super.call(this, name, "oceanPostProcess", ["time", "resolution", "cameraPosition", "cameraRotation"], ["positionSampler", "reflectionSampler", "refractionSampler"], {
  915. width: camera.getEngine().getRenderWidth(),
  916. height: camera.getEngine().getRenderHeight()
  917. }, camera, babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
  918. _this._time = 0;
  919. _this._cameraRotation = babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  920. _this._cameraViewMatrix = babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  921. _this._reflectionEnabled = false;
  922. _this._refractionEnabled = false;
  923. // Get geometry shader
  924. _this._geometryRenderer = camera.getScene().enableGeometryBufferRenderer(1.0);
  925. if (_this._geometryRenderer && _this._geometryRenderer.isSupported) {
  926. // Eanble position buffer
  927. _this._geometryRenderer.enablePosition = true;
  928. // Create mirror textures
  929. _this.reflectionTexture = new babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["MirrorTexture"]("oceanPostProcessReflection", options.reflectionSize || { width: 512, height: 512 }, camera.getScene());
  930. _this.reflectionTexture.mirrorPlane = babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Plane"].FromPositionAndNormal(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), new babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, -1, 0));
  931. _this.refractionTexture = new babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]("oceanPostProcessRefraction", options.refractionSize || { width: 512, height: 512 }, camera.getScene());
  932. }
  933. else {
  934. _this.updateEffect("#define NOT_SUPPORTED\n");
  935. }
  936. // On apply the post-process
  937. _this.onApply = function (effect) {
  938. if (!_this._geometryRenderer || !_this._geometryRenderer.isSupported) {
  939. return;
  940. }
  941. var engine = camera.getEngine();
  942. var scene = camera.getScene();
  943. _this._time += engine.getDeltaTime() * 0.001;
  944. effect.setFloat("time", _this._time);
  945. effect.setVector2("resolution", new babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Vector2"](engine.getRenderWidth(), engine.getRenderHeight()));
  946. if (scene) {
  947. // Position
  948. effect.setVector3("cameraPosition", camera.globalPosition);
  949. // Rotation
  950. _this._computeCameraRotation(camera);
  951. effect.setVector3("cameraRotation", _this._cameraRotation);
  952. // Samplers
  953. effect.setTexture("positionSampler", _this._geometryRenderer.getGBuffer().textures[2]);
  954. if (_this._reflectionEnabled) {
  955. effect.setTexture("reflectionSampler", _this.reflectionTexture);
  956. }
  957. if (_this._refractionEnabled) {
  958. effect.setTexture("refractionSampler", _this.refractionTexture);
  959. }
  960. }
  961. };
  962. return _this;
  963. }
  964. Object.defineProperty(OceanPostProcess.prototype, "reflectionEnabled", {
  965. /**
  966. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  967. */
  968. get: function () {
  969. return this._reflectionEnabled;
  970. },
  971. /**
  972. * Sets weither or not the real-time reflection is enabled on the ocean.
  973. * Is set to true, the reflection mirror texture will be used as reflection texture.
  974. */
  975. set: function (enabled) {
  976. if (this._reflectionEnabled === enabled) {
  977. return;
  978. }
  979. this._reflectionEnabled = enabled;
  980. this.updateEffect(this._getDefines());
  981. // Remove or add custom render target
  982. var customRenderTargets = this.getCamera().getScene().customRenderTargets;
  983. if (!enabled) {
  984. var index = customRenderTargets.indexOf(this.reflectionTexture);
  985. if (index !== -1) {
  986. customRenderTargets.splice(index, 1);
  987. }
  988. }
  989. else {
  990. customRenderTargets.push(this.reflectionTexture);
  991. }
  992. },
  993. enumerable: true,
  994. configurable: true
  995. });
  996. Object.defineProperty(OceanPostProcess.prototype, "refractionEnabled", {
  997. /**
  998. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  999. */
  1000. get: function () {
  1001. return this._refractionEnabled;
  1002. },
  1003. /**
  1004. * Sets weither or not the real-time refraction is enabled on the ocean.
  1005. * Is set to true, the refraction render target texture will be used as refraction texture.
  1006. */
  1007. set: function (enabled) {
  1008. if (this._refractionEnabled === enabled) {
  1009. return;
  1010. }
  1011. this._refractionEnabled = enabled;
  1012. this.updateEffect(this._getDefines());
  1013. // Remove or add custom render target
  1014. var customRenderTargets = this.getCamera().getScene().customRenderTargets;
  1015. if (!enabled) {
  1016. var index = customRenderTargets.indexOf(this.refractionTexture);
  1017. if (index !== -1) {
  1018. customRenderTargets.splice(index, 1);
  1019. }
  1020. }
  1021. else {
  1022. customRenderTargets.push(this.refractionTexture);
  1023. }
  1024. },
  1025. enumerable: true,
  1026. configurable: true
  1027. });
  1028. Object.defineProperty(OceanPostProcess.prototype, "isSupported", {
  1029. /**
  1030. * Gets wether or not the post-processes is supported by the running hardware.
  1031. * This requires draw buffer supports.
  1032. */
  1033. get: function () {
  1034. return this._geometryRenderer !== null && this._geometryRenderer.isSupported;
  1035. },
  1036. enumerable: true,
  1037. configurable: true
  1038. });
  1039. /**
  1040. * Returns the appropriate defines according to the current configuration.
  1041. */
  1042. OceanPostProcess.prototype._getDefines = function () {
  1043. var defines = [];
  1044. if (this._reflectionEnabled) {
  1045. defines.push("#define REFLECTION_ENABLED");
  1046. }
  1047. if (this._refractionEnabled) {
  1048. defines.push("#define REFRACTION_ENABLED");
  1049. }
  1050. return defines.join("\n");
  1051. };
  1052. /**
  1053. * Computes the current camera rotation as the shader requires a camera rotation.
  1054. */
  1055. OceanPostProcess.prototype._computeCameraRotation = function (camera) {
  1056. camera.upVector.normalize();
  1057. var target = camera.getTarget();
  1058. camera._initialFocalDistance = target.subtract(camera.position).length();
  1059. if (camera.position.z === target.z) {
  1060. camera.position.z += babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  1061. }
  1062. var direction = target.subtract(camera.position);
  1063. camera._viewMatrix.invertToRef(this._cameraViewMatrix);
  1064. this._cameraRotation.x = Math.atan(this._cameraViewMatrix.m[6] / this._cameraViewMatrix.m[10]);
  1065. if (direction.x >= 0.0) {
  1066. this._cameraRotation.y = (-Math.atan(direction.z / direction.x) + Math.PI / 2.0);
  1067. }
  1068. else {
  1069. this._cameraRotation.y = (-Math.atan(direction.z / direction.x) - Math.PI / 2.0);
  1070. }
  1071. this._cameraRotation.z = 0;
  1072. if (isNaN(this._cameraRotation.x)) {
  1073. this._cameraRotation.x = 0;
  1074. }
  1075. if (isNaN(this._cameraRotation.y)) {
  1076. this._cameraRotation.y = 0;
  1077. }
  1078. if (isNaN(this._cameraRotation.z)) {
  1079. this._cameraRotation.z = 0;
  1080. }
  1081. };
  1082. return OceanPostProcess;
  1083. }(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  1084. /***/ }),
  1085. /***/ "babylonjs/Misc/decorators":
  1086. /*!****************************************************************************************************!*\
  1087. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  1088. \****************************************************************************************************/
  1089. /*! no static exports found */
  1090. /***/ (function(module, exports) {
  1091. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_decorators__;
  1092. /***/ })
  1093. /******/ });
  1094. });
  1095. //# sourceMappingURL=babylonjs.postProcess.js.map