babylonjs.proceduralTextures.js 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
  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-procedural-textures", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-procedural-textures"] = factory(require("babylonjs"));
  8. else
  9. root["PTLIB"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
  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. !*** ../node_modules/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 || Function("return this")() || (1, eval)("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. /***/ "./legacy/legacy.ts":
  122. /*!**************************!*\
  123. !*** ./legacy/legacy.ts ***!
  124. \**************************/
  125. /*! no static exports found */
  126. /***/ (function(module, exports, __webpack_require__) {
  127. "use strict";
  128. /* WEBPACK VAR INJECTION */(function(global) {
  129. function __export(m) {
  130. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  131. }
  132. Object.defineProperty(exports, "__esModule", { value: true });
  133. var ProceduralTexturesLib = __webpack_require__(/*! ../src/index */ "./src/index.ts");
  134. /**
  135. * Legacy support, defining window.BABYLON.GridMaterial... (global variable).
  136. *
  137. * This is the entry point for the UMD module.
  138. * The entry point for a future ESM package should be index.ts
  139. */
  140. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  141. if (typeof globalObject !== "undefined") {
  142. globalObject.BABYLON = globalObject.BABYLON || {};
  143. for (var mat in ProceduralTexturesLib) {
  144. if (ProceduralTexturesLib.hasOwnProperty(mat)) {
  145. globalObject.BABYLON[mat] = ProceduralTexturesLib[mat];
  146. }
  147. }
  148. }
  149. __export(__webpack_require__(/*! ../src/index */ "./src/index.ts"));
  150. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  151. /***/ }),
  152. /***/ "./src/brick/brickProceduralTexture.fragment.ts":
  153. /*!******************************************************!*\
  154. !*** ./src/brick/brickProceduralTexture.fragment.ts ***!
  155. \******************************************************/
  156. /*! no static exports found */
  157. /***/ (function(module, exports, __webpack_require__) {
  158. "use strict";
  159. Object.defineProperty(exports, "__esModule", { value: true });
  160. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  161. var name = 'brickProceduralTexturePixelShader';
  162. exports.name = name;
  163. var shader = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfBricksHeight;\nuniform float numberOfBricksWidth;\nuniform vec3 brickColor;\nuniform vec3 jointColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvoid main(void)\n{\nfloat brickW=1.0/numberOfBricksWidth;\nfloat brickH=1.0/numberOfBricksHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.05;\nvec3 color=brickColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0) == 0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat brickColorSwitch=mod(floor(yi)+floor(xi),3.0);\nif (brickColorSwitch == 0.0)\ncolor=mix(color,vec3(0.33,0.33,0.33),0.3);\nelse if (brickColorSwitch == 2.0)\ncolor=mix(color,vec3(0.11,0.11,0.11),0.3);\n}\ngl_FragColor=vec4(color,1.0);\n}";
  164. exports.shader = shader;
  165. babylonjs_1.Effect.ShadersStore[name] = shader;
  166. /***/ }),
  167. /***/ "./src/brick/brickProceduralTexture.ts":
  168. /*!*********************************************!*\
  169. !*** ./src/brick/brickProceduralTexture.ts ***!
  170. \*********************************************/
  171. /*! no static exports found */
  172. /***/ (function(module, exports, __webpack_require__) {
  173. "use strict";
  174. var __extends = (this && this.__extends) || (function () {
  175. var extendStatics = function (d, b) {
  176. extendStatics = Object.setPrototypeOf ||
  177. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  178. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  179. return extendStatics(d, b);
  180. }
  181. return function (d, b) {
  182. extendStatics(d, b);
  183. function __() { this.constructor = d; }
  184. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  185. };
  186. })();
  187. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  188. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  189. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  190. 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;
  191. return c > 3 && r && Object.defineProperty(target, key, r), r;
  192. };
  193. Object.defineProperty(exports, "__esModule", { value: true });
  194. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  195. __webpack_require__(/*! ./brickProceduralTexture.fragment */ "./src/brick/brickProceduralTexture.fragment.ts");
  196. var BrickProceduralTexture = /** @class */ (function (_super) {
  197. __extends(BrickProceduralTexture, _super);
  198. function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  199. var _this = _super.call(this, name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  200. _this._numberOfBricksHeight = 15;
  201. _this._numberOfBricksWidth = 5;
  202. _this._jointColor = new babylonjs_1.Color3(0.72, 0.72, 0.72);
  203. _this._brickColor = new babylonjs_1.Color3(0.77, 0.47, 0.40);
  204. _this.updateShaderUniforms();
  205. return _this;
  206. }
  207. BrickProceduralTexture.prototype.updateShaderUniforms = function () {
  208. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  209. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  210. this.setColor3("brickColor", this._brickColor);
  211. this.setColor3("jointColor", this._jointColor);
  212. };
  213. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
  214. get: function () {
  215. return this._numberOfBricksHeight;
  216. },
  217. set: function (value) {
  218. this._numberOfBricksHeight = value;
  219. this.updateShaderUniforms();
  220. },
  221. enumerable: true,
  222. configurable: true
  223. });
  224. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
  225. get: function () {
  226. return this._numberOfBricksWidth;
  227. },
  228. set: function (value) {
  229. this._numberOfBricksWidth = value;
  230. this.updateShaderUniforms();
  231. },
  232. enumerable: true,
  233. configurable: true
  234. });
  235. Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
  236. get: function () {
  237. return this._jointColor;
  238. },
  239. set: function (value) {
  240. this._jointColor = value;
  241. this.updateShaderUniforms();
  242. },
  243. enumerable: true,
  244. configurable: true
  245. });
  246. Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
  247. get: function () {
  248. return this._brickColor;
  249. },
  250. set: function (value) {
  251. this._brickColor = value;
  252. this.updateShaderUniforms();
  253. },
  254. enumerable: true,
  255. configurable: true
  256. });
  257. /**
  258. * Serializes this brick procedural texture
  259. * @returns a serialized brick procedural texture object
  260. */
  261. BrickProceduralTexture.prototype.serialize = function () {
  262. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  263. serializationObject.customType = "BABYLON.BrickProceduralTexture";
  264. return serializationObject;
  265. };
  266. /**
  267. * Creates a Brick Procedural Texture from parsed brick procedural texture data
  268. * @param parsedTexture defines parsed texture data
  269. * @param scene defines the current scene
  270. * @param rootUrl defines the root URL containing brick procedural texture information
  271. * @returns a parsed Brick Procedural Texture
  272. */
  273. BrickProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  274. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  275. return texture;
  276. };
  277. __decorate([
  278. babylonjs_1.serialize()
  279. ], BrickProceduralTexture.prototype, "numberOfBricksHeight", null);
  280. __decorate([
  281. babylonjs_1.serialize()
  282. ], BrickProceduralTexture.prototype, "numberOfBricksWidth", null);
  283. __decorate([
  284. babylonjs_1.serializeAsColor3()
  285. ], BrickProceduralTexture.prototype, "jointColor", null);
  286. __decorate([
  287. babylonjs_1.serializeAsColor3()
  288. ], BrickProceduralTexture.prototype, "brickColor", null);
  289. return BrickProceduralTexture;
  290. }(babylonjs_1.ProceduralTexture));
  291. exports.BrickProceduralTexture = BrickProceduralTexture;
  292. /***/ }),
  293. /***/ "./src/brick/index.ts":
  294. /*!****************************!*\
  295. !*** ./src/brick/index.ts ***!
  296. \****************************/
  297. /*! no static exports found */
  298. /***/ (function(module, exports, __webpack_require__) {
  299. "use strict";
  300. function __export(m) {
  301. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  302. }
  303. Object.defineProperty(exports, "__esModule", { value: true });
  304. __export(__webpack_require__(/*! ./brickProceduralTexture */ "./src/brick/brickProceduralTexture.ts"));
  305. /***/ }),
  306. /***/ "./src/cloud/cloudProceduralTexture.fragment.ts":
  307. /*!******************************************************!*\
  308. !*** ./src/cloud/cloudProceduralTexture.fragment.ts ***!
  309. \******************************************************/
  310. /*! no static exports found */
  311. /***/ (function(module, exports, __webpack_require__) {
  312. "use strict";
  313. Object.defineProperty(exports, "__esModule", { value: true });
  314. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  315. var name = 'cloudProceduralTexturePixelShader';
  316. exports.name = name;
  317. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 skyColor;\nuniform vec4 cloudColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main() {\nvec2 p=vUV*12.0;\nvec4 c=mix(skyColor,cloudColor,fbm(p));\ngl_FragColor=c;\n}\n";
  318. exports.shader = shader;
  319. babylonjs_1.Effect.ShadersStore[name] = shader;
  320. /***/ }),
  321. /***/ "./src/cloud/cloudProceduralTexture.ts":
  322. /*!*********************************************!*\
  323. !*** ./src/cloud/cloudProceduralTexture.ts ***!
  324. \*********************************************/
  325. /*! no static exports found */
  326. /***/ (function(module, exports, __webpack_require__) {
  327. "use strict";
  328. var __extends = (this && this.__extends) || (function () {
  329. var extendStatics = function (d, b) {
  330. extendStatics = Object.setPrototypeOf ||
  331. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  332. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  333. return extendStatics(d, b);
  334. }
  335. return function (d, b) {
  336. extendStatics(d, b);
  337. function __() { this.constructor = d; }
  338. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  339. };
  340. })();
  341. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  342. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  343. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  344. 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;
  345. return c > 3 && r && Object.defineProperty(target, key, r), r;
  346. };
  347. Object.defineProperty(exports, "__esModule", { value: true });
  348. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  349. __webpack_require__(/*! ./cloudProceduralTexture.fragment */ "./src/cloud/cloudProceduralTexture.fragment.ts");
  350. var CloudProceduralTexture = /** @class */ (function (_super) {
  351. __extends(CloudProceduralTexture, _super);
  352. function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  353. var _this = _super.call(this, name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  354. _this._skyColor = new babylonjs_1.Color4(0.15, 0.68, 1.0, 1.0);
  355. _this._cloudColor = new babylonjs_1.Color4(1, 1, 1, 1.0);
  356. _this.updateShaderUniforms();
  357. return _this;
  358. }
  359. CloudProceduralTexture.prototype.updateShaderUniforms = function () {
  360. this.setColor4("skyColor", this._skyColor);
  361. this.setColor4("cloudColor", this._cloudColor);
  362. };
  363. Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
  364. get: function () {
  365. return this._skyColor;
  366. },
  367. set: function (value) {
  368. this._skyColor = value;
  369. this.updateShaderUniforms();
  370. },
  371. enumerable: true,
  372. configurable: true
  373. });
  374. Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
  375. get: function () {
  376. return this._cloudColor;
  377. },
  378. set: function (value) {
  379. this._cloudColor = value;
  380. this.updateShaderUniforms();
  381. },
  382. enumerable: true,
  383. configurable: true
  384. });
  385. /**
  386. * Serializes this cloud procedural texture
  387. * @returns a serialized cloud procedural texture object
  388. */
  389. CloudProceduralTexture.prototype.serialize = function () {
  390. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  391. serializationObject.customType = "BABYLON.CloudProceduralTexture";
  392. return serializationObject;
  393. };
  394. /**
  395. * Creates a Cloud Procedural Texture from parsed cloud procedural texture data
  396. * @param parsedTexture defines parsed texture data
  397. * @param scene defines the current scene
  398. * @param rootUrl defines the root URL containing cloud procedural texture information
  399. * @returns a parsed Cloud Procedural Texture
  400. */
  401. CloudProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  402. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  403. return texture;
  404. };
  405. __decorate([
  406. babylonjs_1.serializeAsColor4()
  407. ], CloudProceduralTexture.prototype, "skyColor", null);
  408. __decorate([
  409. babylonjs_1.serializeAsColor4()
  410. ], CloudProceduralTexture.prototype, "cloudColor", null);
  411. return CloudProceduralTexture;
  412. }(babylonjs_1.ProceduralTexture));
  413. exports.CloudProceduralTexture = CloudProceduralTexture;
  414. /***/ }),
  415. /***/ "./src/cloud/index.ts":
  416. /*!****************************!*\
  417. !*** ./src/cloud/index.ts ***!
  418. \****************************/
  419. /*! no static exports found */
  420. /***/ (function(module, exports, __webpack_require__) {
  421. "use strict";
  422. function __export(m) {
  423. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  424. }
  425. Object.defineProperty(exports, "__esModule", { value: true });
  426. __export(__webpack_require__(/*! ./cloudProceduralTexture */ "./src/cloud/cloudProceduralTexture.ts"));
  427. /***/ }),
  428. /***/ "./src/fire/fireProceduralTexture.fragment.ts":
  429. /*!****************************************************!*\
  430. !*** ./src/fire/fireProceduralTexture.fragment.ts ***!
  431. \****************************************************/
  432. /*! no static exports found */
  433. /***/ (function(module, exports, __webpack_require__) {
  434. "use strict";
  435. Object.defineProperty(exports, "__esModule", { value: true });
  436. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  437. var name = 'fireProceduralTexturePixelShader';
  438. exports.name = name;
  439. var shader = "precision highp float;\nuniform float time;\nuniform vec3 c1;\nuniform vec3 c2;\nuniform vec3 c3;\nuniform vec3 c4;\nuniform vec3 c5;\nuniform vec3 c6;\nuniform vec2 speed;\nuniform float shift;\nuniform float alphaThreshold;\nvarying vec2 vUV;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main() {\nvec2 p=vUV*8.0;\nfloat q=fbm(p-time*0.1);\nvec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));\nvec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);\nvec3 color=c*cos(shift*vUV.y);\nfloat luminance=dot(color.rgb,vec3(0.3,0.59,0.11));\ngl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));\n}";
  440. exports.shader = shader;
  441. babylonjs_1.Effect.ShadersStore[name] = shader;
  442. /***/ }),
  443. /***/ "./src/fire/fireProceduralTexture.ts":
  444. /*!*******************************************!*\
  445. !*** ./src/fire/fireProceduralTexture.ts ***!
  446. \*******************************************/
  447. /*! no static exports found */
  448. /***/ (function(module, exports, __webpack_require__) {
  449. "use strict";
  450. var __extends = (this && this.__extends) || (function () {
  451. var extendStatics = function (d, b) {
  452. extendStatics = Object.setPrototypeOf ||
  453. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  454. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  455. return extendStatics(d, b);
  456. }
  457. return function (d, b) {
  458. extendStatics(d, b);
  459. function __() { this.constructor = d; }
  460. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  461. };
  462. })();
  463. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  464. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  465. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  466. 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;
  467. return c > 3 && r && Object.defineProperty(target, key, r), r;
  468. };
  469. Object.defineProperty(exports, "__esModule", { value: true });
  470. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  471. __webpack_require__(/*! ./fireProceduralTexture.fragment */ "./src/fire/fireProceduralTexture.fragment.ts");
  472. var FireProceduralTexture = /** @class */ (function (_super) {
  473. __extends(FireProceduralTexture, _super);
  474. function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  475. var _this = _super.call(this, name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  476. _this._time = 0.0;
  477. _this._speed = new babylonjs_1.Vector2(0.5, 0.3);
  478. _this._autoGenerateTime = true;
  479. _this._alphaThreshold = 0.5;
  480. _this._fireColors = FireProceduralTexture.RedFireColors;
  481. _this.updateShaderUniforms();
  482. return _this;
  483. }
  484. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  485. this.setFloat("time", this._time);
  486. this.setVector2("speed", this._speed);
  487. this.setColor3("c1", this._fireColors[0]);
  488. this.setColor3("c2", this._fireColors[1]);
  489. this.setColor3("c3", this._fireColors[2]);
  490. this.setColor3("c4", this._fireColors[3]);
  491. this.setColor3("c5", this._fireColors[4]);
  492. this.setColor3("c6", this._fireColors[5]);
  493. this.setFloat("alphaThreshold", this._alphaThreshold);
  494. };
  495. FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
  496. var scene = this.getScene();
  497. if (this._autoGenerateTime && scene) {
  498. this._time += scene.getAnimationRatio() * 0.03;
  499. this.updateShaderUniforms();
  500. }
  501. _super.prototype.render.call(this, useCameraPostProcess);
  502. };
  503. Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
  504. get: function () {
  505. return [
  506. new babylonjs_1.Color3(0.5, 0.0, 1.0),
  507. new babylonjs_1.Color3(0.9, 0.0, 1.0),
  508. new babylonjs_1.Color3(0.2, 0.0, 1.0),
  509. new babylonjs_1.Color3(1.0, 0.9, 1.0),
  510. new babylonjs_1.Color3(0.1, 0.1, 1.0),
  511. new babylonjs_1.Color3(0.9, 0.9, 1.0)
  512. ];
  513. },
  514. enumerable: true,
  515. configurable: true
  516. });
  517. Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
  518. get: function () {
  519. return [
  520. new babylonjs_1.Color3(0.5, 1.0, 0.0),
  521. new babylonjs_1.Color3(0.5, 1.0, 0.0),
  522. new babylonjs_1.Color3(0.3, 0.4, 0.0),
  523. new babylonjs_1.Color3(0.5, 1.0, 0.0),
  524. new babylonjs_1.Color3(0.2, 0.0, 0.0),
  525. new babylonjs_1.Color3(0.5, 1.0, 0.0)
  526. ];
  527. },
  528. enumerable: true,
  529. configurable: true
  530. });
  531. Object.defineProperty(FireProceduralTexture, "RedFireColors", {
  532. get: function () {
  533. return [
  534. new babylonjs_1.Color3(0.5, 0.0, 0.1),
  535. new babylonjs_1.Color3(0.9, 0.0, 0.0),
  536. new babylonjs_1.Color3(0.2, 0.0, 0.0),
  537. new babylonjs_1.Color3(1.0, 0.9, 0.0),
  538. new babylonjs_1.Color3(0.1, 0.1, 0.1),
  539. new babylonjs_1.Color3(0.9, 0.9, 0.9)
  540. ];
  541. },
  542. enumerable: true,
  543. configurable: true
  544. });
  545. Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
  546. get: function () {
  547. return [
  548. new babylonjs_1.Color3(0.1, 0.0, 0.5),
  549. new babylonjs_1.Color3(0.0, 0.0, 0.5),
  550. new babylonjs_1.Color3(0.1, 0.0, 0.2),
  551. new babylonjs_1.Color3(0.0, 0.0, 1.0),
  552. new babylonjs_1.Color3(0.1, 0.2, 0.3),
  553. new babylonjs_1.Color3(0.0, 0.2, 0.9)
  554. ];
  555. },
  556. enumerable: true,
  557. configurable: true
  558. });
  559. Object.defineProperty(FireProceduralTexture.prototype, "autoGenerateTime", {
  560. get: function () {
  561. return this._autoGenerateTime;
  562. },
  563. set: function (value) {
  564. this._autoGenerateTime = value;
  565. },
  566. enumerable: true,
  567. configurable: true
  568. });
  569. Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
  570. get: function () {
  571. return this._fireColors;
  572. },
  573. set: function (value) {
  574. this._fireColors = value;
  575. this.updateShaderUniforms();
  576. },
  577. enumerable: true,
  578. configurable: true
  579. });
  580. Object.defineProperty(FireProceduralTexture.prototype, "time", {
  581. get: function () {
  582. return this._time;
  583. },
  584. set: function (value) {
  585. this._time = value;
  586. this.updateShaderUniforms();
  587. },
  588. enumerable: true,
  589. configurable: true
  590. });
  591. Object.defineProperty(FireProceduralTexture.prototype, "speed", {
  592. get: function () {
  593. return this._speed;
  594. },
  595. set: function (value) {
  596. this._speed = value;
  597. this.updateShaderUniforms();
  598. },
  599. enumerable: true,
  600. configurable: true
  601. });
  602. Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
  603. get: function () {
  604. return this._alphaThreshold;
  605. },
  606. set: function (value) {
  607. this._alphaThreshold = value;
  608. this.updateShaderUniforms();
  609. },
  610. enumerable: true,
  611. configurable: true
  612. });
  613. /**
  614. * Serializes this fire procedural texture
  615. * @returns a serialized fire procedural texture object
  616. */
  617. FireProceduralTexture.prototype.serialize = function () {
  618. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  619. serializationObject.customType = "BABYLON.FireProceduralTexture";
  620. serializationObject.fireColors = [];
  621. for (var i = 0; i < this._fireColors.length; i++) {
  622. serializationObject.fireColors.push(this._fireColors[i].asArray());
  623. }
  624. return serializationObject;
  625. };
  626. /**
  627. * Creates a Fire Procedural Texture from parsed fire procedural texture data
  628. * @param parsedTexture defines parsed texture data
  629. * @param scene defines the current scene
  630. * @param rootUrl defines the root URL containing fire procedural texture information
  631. * @returns a parsed Fire Procedural Texture
  632. */
  633. FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  634. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  635. var colors = [];
  636. for (var i = 0; i < parsedTexture.fireColors.length; i++) {
  637. colors.push(babylonjs_1.Color3.FromArray(parsedTexture.fireColors[i]));
  638. }
  639. texture.fireColors = colors;
  640. return texture;
  641. };
  642. __decorate([
  643. babylonjs_1.serialize()
  644. ], FireProceduralTexture.prototype, "autoGenerateTime", null);
  645. __decorate([
  646. babylonjs_1.serialize()
  647. ], FireProceduralTexture.prototype, "time", null);
  648. __decorate([
  649. babylonjs_1.serializeAsVector2()
  650. ], FireProceduralTexture.prototype, "speed", null);
  651. __decorate([
  652. babylonjs_1.serialize()
  653. ], FireProceduralTexture.prototype, "alphaThreshold", null);
  654. return FireProceduralTexture;
  655. }(babylonjs_1.ProceduralTexture));
  656. exports.FireProceduralTexture = FireProceduralTexture;
  657. /***/ }),
  658. /***/ "./src/fire/index.ts":
  659. /*!***************************!*\
  660. !*** ./src/fire/index.ts ***!
  661. \***************************/
  662. /*! no static exports found */
  663. /***/ (function(module, exports, __webpack_require__) {
  664. "use strict";
  665. function __export(m) {
  666. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  667. }
  668. Object.defineProperty(exports, "__esModule", { value: true });
  669. __export(__webpack_require__(/*! ./fireProceduralTexture */ "./src/fire/fireProceduralTexture.ts"));
  670. /***/ }),
  671. /***/ "./src/grass/grassProceduralTexture.fragment.ts":
  672. /*!******************************************************!*\
  673. !*** ./src/grass/grassProceduralTexture.fragment.ts ***!
  674. \******************************************************/
  675. /*! no static exports found */
  676. /***/ (function(module, exports, __webpack_require__) {
  677. "use strict";
  678. Object.defineProperty(exports, "__esModule", { value: true });
  679. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  680. var name = 'grassProceduralTexturePixelShader';
  681. exports.name = name;
  682. var shader = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform vec3 herb1Color;\nuniform vec3 herb2Color;\nuniform vec3 herb3Color;\nuniform vec3 groundColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main(void) {\nvec3 color=mix(groundColor,herb1Color,rand(gl_FragCoord.xy*4.0));\ncolor=mix(color,herb2Color,rand(gl_FragCoord.xy*8.0));\ncolor=mix(color,herb3Color,rand(gl_FragCoord.xy));\ncolor=mix(color,herb1Color,fbm(gl_FragCoord.xy*16.0));\ngl_FragColor=vec4(color,1.0);\n}";
  683. exports.shader = shader;
  684. babylonjs_1.Effect.ShadersStore[name] = shader;
  685. /***/ }),
  686. /***/ "./src/grass/grassProceduralTexture.ts":
  687. /*!*********************************************!*\
  688. !*** ./src/grass/grassProceduralTexture.ts ***!
  689. \*********************************************/
  690. /*! no static exports found */
  691. /***/ (function(module, exports, __webpack_require__) {
  692. "use strict";
  693. var __extends = (this && this.__extends) || (function () {
  694. var extendStatics = function (d, b) {
  695. extendStatics = Object.setPrototypeOf ||
  696. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  697. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  698. return extendStatics(d, b);
  699. }
  700. return function (d, b) {
  701. extendStatics(d, b);
  702. function __() { this.constructor = d; }
  703. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  704. };
  705. })();
  706. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  707. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  708. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  709. 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;
  710. return c > 3 && r && Object.defineProperty(target, key, r), r;
  711. };
  712. Object.defineProperty(exports, "__esModule", { value: true });
  713. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  714. __webpack_require__(/*! ./grassProceduralTexture.fragment */ "./src/grass/grassProceduralTexture.fragment.ts");
  715. var GrassProceduralTexture = /** @class */ (function (_super) {
  716. __extends(GrassProceduralTexture, _super);
  717. function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  718. var _this = _super.call(this, name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  719. _this._groundColor = new babylonjs_1.Color3(1, 1, 1);
  720. _this._grassColors = [
  721. new babylonjs_1.Color3(0.29, 0.38, 0.02),
  722. new babylonjs_1.Color3(0.36, 0.49, 0.09),
  723. new babylonjs_1.Color3(0.51, 0.6, 0.28)
  724. ];
  725. _this.updateShaderUniforms();
  726. return _this;
  727. }
  728. GrassProceduralTexture.prototype.updateShaderUniforms = function () {
  729. this.setColor3("herb1Color", this._grassColors[0]);
  730. this.setColor3("herb2Color", this._grassColors[1]);
  731. this.setColor3("herb3Color", this._grassColors[2]);
  732. this.setColor3("groundColor", this._groundColor);
  733. };
  734. Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
  735. get: function () {
  736. return this._grassColors;
  737. },
  738. set: function (value) {
  739. this._grassColors = value;
  740. this.updateShaderUniforms();
  741. },
  742. enumerable: true,
  743. configurable: true
  744. });
  745. Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
  746. get: function () {
  747. return this._groundColor;
  748. },
  749. set: function (value) {
  750. this._groundColor = value;
  751. this.updateShaderUniforms();
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. /**
  757. * Serializes this grass procedural texture
  758. * @returns a serialized grass procedural texture object
  759. */
  760. GrassProceduralTexture.prototype.serialize = function () {
  761. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  762. serializationObject.customType = "BABYLON.GrassProceduralTexture";
  763. serializationObject.grassColors = [];
  764. for (var i = 0; i < this._grassColors.length; i++) {
  765. serializationObject.grassColors.push(this._grassColors[i].asArray());
  766. }
  767. return serializationObject;
  768. };
  769. /**
  770. * Creates a Grass Procedural Texture from parsed grass procedural texture data
  771. * @param parsedTexture defines parsed texture data
  772. * @param scene defines the current scene
  773. * @param rootUrl defines the root URL containing grass procedural texture information
  774. * @returns a parsed Grass Procedural Texture
  775. */
  776. GrassProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  777. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  778. var colors = [];
  779. for (var i = 0; i < parsedTexture.grassColors.length; i++) {
  780. colors.push(babylonjs_1.Color3.FromArray(parsedTexture.grassColors[i]));
  781. }
  782. texture.grassColors = colors;
  783. return texture;
  784. };
  785. __decorate([
  786. babylonjs_1.serializeAsColor3()
  787. ], GrassProceduralTexture.prototype, "groundColor", null);
  788. return GrassProceduralTexture;
  789. }(babylonjs_1.ProceduralTexture));
  790. exports.GrassProceduralTexture = GrassProceduralTexture;
  791. /***/ }),
  792. /***/ "./src/grass/index.ts":
  793. /*!****************************!*\
  794. !*** ./src/grass/index.ts ***!
  795. \****************************/
  796. /*! no static exports found */
  797. /***/ (function(module, exports, __webpack_require__) {
  798. "use strict";
  799. function __export(m) {
  800. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  801. }
  802. Object.defineProperty(exports, "__esModule", { value: true });
  803. __export(__webpack_require__(/*! ./grassProceduralTexture */ "./src/grass/grassProceduralTexture.ts"));
  804. /***/ }),
  805. /***/ "./src/index.ts":
  806. /*!**********************!*\
  807. !*** ./src/index.ts ***!
  808. \**********************/
  809. /*! no static exports found */
  810. /***/ (function(module, exports, __webpack_require__) {
  811. "use strict";
  812. function __export(m) {
  813. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  814. }
  815. Object.defineProperty(exports, "__esModule", { value: true });
  816. __export(__webpack_require__(/*! ./brick */ "./src/brick/index.ts"));
  817. __export(__webpack_require__(/*! ./cloud */ "./src/cloud/index.ts"));
  818. __export(__webpack_require__(/*! ./fire */ "./src/fire/index.ts"));
  819. __export(__webpack_require__(/*! ./grass */ "./src/grass/index.ts"));
  820. __export(__webpack_require__(/*! ./marble */ "./src/marble/index.ts"));
  821. __export(__webpack_require__(/*! ./normalMap */ "./src/normalMap/index.ts"));
  822. __export(__webpack_require__(/*! ./perlinNoise */ "./src/perlinNoise/index.ts"));
  823. __export(__webpack_require__(/*! ./road */ "./src/road/index.ts"));
  824. __export(__webpack_require__(/*! ./starfield */ "./src/starfield/index.ts"));
  825. __export(__webpack_require__(/*! ./wood */ "./src/wood/index.ts"));
  826. /***/ }),
  827. /***/ "./src/marble/index.ts":
  828. /*!*****************************!*\
  829. !*** ./src/marble/index.ts ***!
  830. \*****************************/
  831. /*! no static exports found */
  832. /***/ (function(module, exports, __webpack_require__) {
  833. "use strict";
  834. function __export(m) {
  835. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  836. }
  837. Object.defineProperty(exports, "__esModule", { value: true });
  838. __export(__webpack_require__(/*! ./marbleProceduralTexture */ "./src/marble/marbleProceduralTexture.ts"));
  839. /***/ }),
  840. /***/ "./src/marble/marbleProceduralTexture.fragment.ts":
  841. /*!********************************************************!*\
  842. !*** ./src/marble/marbleProceduralTexture.fragment.ts ***!
  843. \********************************************************/
  844. /*! no static exports found */
  845. /***/ (function(module, exports, __webpack_require__) {
  846. "use strict";
  847. Object.defineProperty(exports, "__esModule", { value: true });
  848. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  849. var name = 'marbleProceduralTexturePixelShader';
  850. exports.name = name;
  851. var shader = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfTilesHeight;\nuniform float numberOfTilesWidth;\nuniform float amplitude;\nuniform vec3 marbleColor;\nuniform vec3 jointColor;\nconst vec3 tileSize=vec3(1.1,1.0,1.1);\nconst vec3 tilePct=vec3(0.98,1.0,0.98);\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat turbulence(vec2 P)\n{\nfloat val=0.0;\nfloat freq=1.0;\nfor (int i=0; i<4; i++)\n{\nval+=abs(noise(P*freq)/freq);\nfreq*=2.07;\n}\nreturn val;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvec3 marble_color(float x)\n{\nvec3 col;\nx=0.5*(x+1.);\nx=sqrt(x);\nx=sqrt(x);\nx=sqrt(x);\ncol=vec3(.2+.75*x);\ncol.b*=0.95;\nreturn col;\n}\nvoid main()\n{\nfloat brickW=1.0/numberOfTilesWidth;\nfloat brickH=1.0/numberOfTilesHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.01;\nvec3 color=marbleColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0) == 0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));\nt+=amplitude*turbulence(brickvUV.xy);\nt=sin(t);\ncolor=marble_color(t);\n}\ngl_FragColor=vec4(color,0.0);\n}";
  852. exports.shader = shader;
  853. babylonjs_1.Effect.ShadersStore[name] = shader;
  854. /***/ }),
  855. /***/ "./src/marble/marbleProceduralTexture.ts":
  856. /*!***********************************************!*\
  857. !*** ./src/marble/marbleProceduralTexture.ts ***!
  858. \***********************************************/
  859. /*! no static exports found */
  860. /***/ (function(module, exports, __webpack_require__) {
  861. "use strict";
  862. var __extends = (this && this.__extends) || (function () {
  863. var extendStatics = function (d, b) {
  864. extendStatics = Object.setPrototypeOf ||
  865. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  866. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  867. return extendStatics(d, b);
  868. }
  869. return function (d, b) {
  870. extendStatics(d, b);
  871. function __() { this.constructor = d; }
  872. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  873. };
  874. })();
  875. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  876. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  877. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  878. 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;
  879. return c > 3 && r && Object.defineProperty(target, key, r), r;
  880. };
  881. Object.defineProperty(exports, "__esModule", { value: true });
  882. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  883. __webpack_require__(/*! ./marbleProceduralTexture.fragment */ "./src/marble/marbleProceduralTexture.fragment.ts");
  884. var MarbleProceduralTexture = /** @class */ (function (_super) {
  885. __extends(MarbleProceduralTexture, _super);
  886. function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  887. var _this = _super.call(this, name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  888. _this._numberOfTilesHeight = 3;
  889. _this._numberOfTilesWidth = 3;
  890. _this._amplitude = 9.0;
  891. _this._jointColor = new babylonjs_1.Color3(0.72, 0.72, 0.72);
  892. _this.updateShaderUniforms();
  893. return _this;
  894. }
  895. MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
  896. this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
  897. this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
  898. this.setFloat("amplitude", this._amplitude);
  899. this.setColor3("jointColor", this._jointColor);
  900. };
  901. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
  902. get: function () {
  903. return this._numberOfTilesHeight;
  904. },
  905. set: function (value) {
  906. this._numberOfTilesHeight = value;
  907. this.updateShaderUniforms();
  908. },
  909. enumerable: true,
  910. configurable: true
  911. });
  912. Object.defineProperty(MarbleProceduralTexture.prototype, "amplitude", {
  913. get: function () {
  914. return this._amplitude;
  915. },
  916. set: function (value) {
  917. this._amplitude = value;
  918. this.updateShaderUniforms();
  919. },
  920. enumerable: true,
  921. configurable: true
  922. });
  923. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
  924. get: function () {
  925. return this._numberOfTilesWidth;
  926. },
  927. set: function (value) {
  928. this._numberOfTilesWidth = value;
  929. this.updateShaderUniforms();
  930. },
  931. enumerable: true,
  932. configurable: true
  933. });
  934. Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
  935. get: function () {
  936. return this._jointColor;
  937. },
  938. set: function (value) {
  939. this._jointColor = value;
  940. this.updateShaderUniforms();
  941. },
  942. enumerable: true,
  943. configurable: true
  944. });
  945. /**
  946. * Serializes this marble procedural texture
  947. * @returns a serialized marble procedural texture object
  948. */
  949. MarbleProceduralTexture.prototype.serialize = function () {
  950. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  951. serializationObject.customType = "BABYLON.MarbleProceduralTexture";
  952. return serializationObject;
  953. };
  954. /**
  955. * Creates a Marble Procedural Texture from parsed marble procedural texture data
  956. * @param parsedTexture defines parsed texture data
  957. * @param scene defines the current scene
  958. * @param rootUrl defines the root URL containing marble procedural texture information
  959. * @returns a parsed Marble Procedural Texture
  960. */
  961. MarbleProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  962. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new MarbleProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  963. return texture;
  964. };
  965. __decorate([
  966. babylonjs_1.serialize()
  967. ], MarbleProceduralTexture.prototype, "numberOfTilesHeight", null);
  968. __decorate([
  969. babylonjs_1.serialize()
  970. ], MarbleProceduralTexture.prototype, "amplitude", null);
  971. __decorate([
  972. babylonjs_1.serialize()
  973. ], MarbleProceduralTexture.prototype, "numberOfTilesWidth", null);
  974. __decorate([
  975. babylonjs_1.serialize()
  976. ], MarbleProceduralTexture.prototype, "jointColor", null);
  977. return MarbleProceduralTexture;
  978. }(babylonjs_1.ProceduralTexture));
  979. exports.MarbleProceduralTexture = MarbleProceduralTexture;
  980. /***/ }),
  981. /***/ "./src/normalMap/index.ts":
  982. /*!********************************!*\
  983. !*** ./src/normalMap/index.ts ***!
  984. \********************************/
  985. /*! no static exports found */
  986. /***/ (function(module, exports, __webpack_require__) {
  987. "use strict";
  988. function __export(m) {
  989. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  990. }
  991. Object.defineProperty(exports, "__esModule", { value: true });
  992. __export(__webpack_require__(/*! ./normalMapProceduralTexture */ "./src/normalMap/normalMapProceduralTexture.ts"));
  993. /***/ }),
  994. /***/ "./src/normalMap/normalMapProceduralTexture.fragment.ts":
  995. /*!**************************************************************!*\
  996. !*** ./src/normalMap/normalMapProceduralTexture.fragment.ts ***!
  997. \**************************************************************/
  998. /*! no static exports found */
  999. /***/ (function(module, exports, __webpack_require__) {
  1000. "use strict";
  1001. Object.defineProperty(exports, "__esModule", { value: true });
  1002. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1003. var name = 'normalMapProceduralTexturePixelShader';
  1004. exports.name = name;
  1005. var shader = "precision highp float;\n\nuniform sampler2D baseSampler;\nuniform float size;\n\nvarying vec2 vUV;\n\nconst vec3 LUMA_COEFFICIENT=vec3(0.2126,0.7152,0.0722);\nfloat lumaAtCoord(vec2 coord)\n{\nvec3 pixel=texture2D(baseSampler,coord).rgb;\nfloat luma=dot(pixel,LUMA_COEFFICIENT);\nreturn luma;\n}\nvoid main()\n{\nfloat lumaU0=lumaAtCoord(vUV+vec2(-1.0,0.0)/size);\nfloat lumaU1=lumaAtCoord(vUV+vec2( 1.0,0.0)/size);\nfloat lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);\nfloat lumaV1=lumaAtCoord(vUV+vec2( 0.0,1.0)/size);\nvec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;\ngl_FragColor=vec4(slope,1.0,1.0);\n}\n";
  1006. exports.shader = shader;
  1007. babylonjs_1.Effect.ShadersStore[name] = shader;
  1008. /***/ }),
  1009. /***/ "./src/normalMap/normalMapProceduralTexture.ts":
  1010. /*!*****************************************************!*\
  1011. !*** ./src/normalMap/normalMapProceduralTexture.ts ***!
  1012. \*****************************************************/
  1013. /*! no static exports found */
  1014. /***/ (function(module, exports, __webpack_require__) {
  1015. "use strict";
  1016. var __extends = (this && this.__extends) || (function () {
  1017. var extendStatics = function (d, b) {
  1018. extendStatics = Object.setPrototypeOf ||
  1019. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1020. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1021. return extendStatics(d, b);
  1022. }
  1023. return function (d, b) {
  1024. extendStatics(d, b);
  1025. function __() { this.constructor = d; }
  1026. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1027. };
  1028. })();
  1029. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1030. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1031. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1032. 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;
  1033. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1034. };
  1035. Object.defineProperty(exports, "__esModule", { value: true });
  1036. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1037. __webpack_require__(/*! ./normalMapProceduralTexture.fragment */ "./src/normalMap/normalMapProceduralTexture.fragment.ts");
  1038. var NormalMapProceduralTexture = /** @class */ (function (_super) {
  1039. __extends(NormalMapProceduralTexture, _super);
  1040. function NormalMapProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1041. var _this = _super.call(this, name, size, "normalMapProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1042. _this.updateShaderUniforms();
  1043. return _this;
  1044. }
  1045. NormalMapProceduralTexture.prototype.updateShaderUniforms = function () {
  1046. this.setTexture("baseSampler", this._baseTexture);
  1047. this.setFloat("size", this.getRenderSize());
  1048. };
  1049. NormalMapProceduralTexture.prototype.render = function (useCameraPostProcess) {
  1050. _super.prototype.render.call(this, useCameraPostProcess);
  1051. };
  1052. NormalMapProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  1053. _super.prototype.resize.call(this, size, generateMipMaps);
  1054. // We need to update the "size" uniform
  1055. this.updateShaderUniforms();
  1056. };
  1057. Object.defineProperty(NormalMapProceduralTexture.prototype, "baseTexture", {
  1058. get: function () {
  1059. return this._baseTexture;
  1060. },
  1061. set: function (texture) {
  1062. this._baseTexture = texture;
  1063. this.updateShaderUniforms();
  1064. },
  1065. enumerable: true,
  1066. configurable: true
  1067. });
  1068. /**
  1069. * Serializes this normal map procedural texture
  1070. * @returns a serialized normal map procedural texture object
  1071. */
  1072. NormalMapProceduralTexture.prototype.serialize = function () {
  1073. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1074. serializationObject.customType = "BABYLON.NormalMapProceduralTexture";
  1075. return serializationObject;
  1076. };
  1077. /**
  1078. * Creates a Normal Map Procedural Texture from parsed normal map procedural texture data
  1079. * @param parsedTexture defines parsed texture data
  1080. * @param scene defines the current scene
  1081. * @param rootUrl defines the root URL containing normal map procedural texture information
  1082. * @returns a parsed Normal Map Procedural Texture
  1083. */
  1084. NormalMapProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1085. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new NormalMapProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1086. return texture;
  1087. };
  1088. __decorate([
  1089. babylonjs_1.serializeAsTexture()
  1090. ], NormalMapProceduralTexture.prototype, "baseTexture", null);
  1091. return NormalMapProceduralTexture;
  1092. }(babylonjs_1.ProceduralTexture));
  1093. exports.NormalMapProceduralTexture = NormalMapProceduralTexture;
  1094. /***/ }),
  1095. /***/ "./src/perlinNoise/index.ts":
  1096. /*!**********************************!*\
  1097. !*** ./src/perlinNoise/index.ts ***!
  1098. \**********************************/
  1099. /*! no static exports found */
  1100. /***/ (function(module, exports, __webpack_require__) {
  1101. "use strict";
  1102. function __export(m) {
  1103. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1104. }
  1105. Object.defineProperty(exports, "__esModule", { value: true });
  1106. __export(__webpack_require__(/*! ./perlinNoiseProceduralTexture */ "./src/perlinNoise/perlinNoiseProceduralTexture.ts"));
  1107. /***/ }),
  1108. /***/ "./src/perlinNoise/perlinNoiseProceduralTexture.fragment.ts":
  1109. /*!******************************************************************!*\
  1110. !*** ./src/perlinNoise/perlinNoiseProceduralTexture.fragment.ts ***!
  1111. \******************************************************************/
  1112. /*! no static exports found */
  1113. /***/ (function(module, exports, __webpack_require__) {
  1114. "use strict";
  1115. Object.defineProperty(exports, "__esModule", { value: true });
  1116. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1117. var name = 'perlinNoiseProceduralTexturePixelShader';
  1118. exports.name = name;
  1119. var shader = "\nprecision highp float;\n\nuniform float size;\nuniform float time;\nuniform float translationSpeed;\n\nvarying vec2 vUV;\n\nfloat r(float n)\n{\nreturn fract(cos(n*89.42)*343.42);\n}\nvec2 r(vec2 n)\n{\nreturn vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89));\n}\nfloat worley(vec2 n,float s)\n{\nfloat dis=1.0;\nfor(int x=-1; x<=1; x++)\n{\nfor(int y=-1; y<=1; y++)\n{\nvec2 p=floor(n/s)+vec2(x,y);\nfloat d=length(r(p)+vec2(x,y)-fract(n/s));\nif (dis>d)\ndis=d;\n}\n}\nreturn 1.0-dis;\n}\nvec3 hash33(vec3 p3)\n{\np3=fract(p3*vec3(0.1031,0.11369,0.13787));\np3+=dot(p3,p3.yxz+19.19);\nreturn -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));\n}\nfloat perlinNoise(vec3 p)\n{\nvec3 pi=floor(p);\nvec3 pf=p-pi;\nvec3 w=pf*pf*(3.0-2.0*pf);\nreturn mix(\nmix(\nmix(\ndot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),\ndot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),\nw.x\n),\nmix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),\nw.x\n),\nw.z\n),\nmix(\nmix(\ndot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),\ndot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),\nw.x\n),\nmix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),\nw.x\n),\nw.z\n),\nw.y\n);\n}\n\nvoid main(void)\n{\nvec2 uv=gl_FragCoord.xy+translationSpeed;\nfloat dis=(\n1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))\n*(1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))\n);\ngl_FragColor=vec4(vec3(dis/4.0),1.0);\n}\n";
  1120. exports.shader = shader;
  1121. babylonjs_1.Effect.ShadersStore[name] = shader;
  1122. /***/ }),
  1123. /***/ "./src/perlinNoise/perlinNoiseProceduralTexture.ts":
  1124. /*!*********************************************************!*\
  1125. !*** ./src/perlinNoise/perlinNoiseProceduralTexture.ts ***!
  1126. \*********************************************************/
  1127. /*! no static exports found */
  1128. /***/ (function(module, exports, __webpack_require__) {
  1129. "use strict";
  1130. var __extends = (this && this.__extends) || (function () {
  1131. var extendStatics = function (d, b) {
  1132. extendStatics = Object.setPrototypeOf ||
  1133. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1134. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1135. return extendStatics(d, b);
  1136. }
  1137. return function (d, b) {
  1138. extendStatics(d, b);
  1139. function __() { this.constructor = d; }
  1140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1141. };
  1142. })();
  1143. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1144. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1145. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1146. 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;
  1147. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1148. };
  1149. Object.defineProperty(exports, "__esModule", { value: true });
  1150. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1151. __webpack_require__(/*! ./perlinNoiseProceduralTexture.fragment */ "./src/perlinNoise/perlinNoiseProceduralTexture.fragment.ts");
  1152. var PerlinNoiseProceduralTexture = /** @class */ (function (_super) {
  1153. __extends(PerlinNoiseProceduralTexture, _super);
  1154. function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1155. var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1156. _this.time = 0.0;
  1157. _this.timeScale = 1.0;
  1158. _this.translationSpeed = 1.0;
  1159. _this._currentTranslation = 0;
  1160. _this.updateShaderUniforms();
  1161. return _this;
  1162. }
  1163. PerlinNoiseProceduralTexture.prototype.updateShaderUniforms = function () {
  1164. this.setFloat("size", this.getRenderSize());
  1165. var scene = this.getScene();
  1166. if (!scene) {
  1167. return;
  1168. }
  1169. var deltaTime = scene.getEngine().getDeltaTime();
  1170. this.time += deltaTime;
  1171. this.setFloat("time", this.time * this.timeScale / 1000);
  1172. this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
  1173. this.setFloat("translationSpeed", this._currentTranslation);
  1174. };
  1175. PerlinNoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  1176. this.updateShaderUniforms();
  1177. _super.prototype.render.call(this, useCameraPostProcess);
  1178. };
  1179. PerlinNoiseProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  1180. _super.prototype.resize.call(this, size, generateMipMaps);
  1181. };
  1182. /**
  1183. * Serializes this perlin noise procedural texture
  1184. * @returns a serialized perlin noise procedural texture object
  1185. */
  1186. PerlinNoiseProceduralTexture.prototype.serialize = function () {
  1187. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1188. serializationObject.customType = "BABYLON.PerlinNoiseProceduralTexture";
  1189. return serializationObject;
  1190. };
  1191. /**
  1192. * Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data
  1193. * @param parsedTexture defines parsed texture data
  1194. * @param scene defines the current scene
  1195. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  1196. * @returns a parsed Perlin Noise Procedural Texture
  1197. */
  1198. PerlinNoiseProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1199. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new PerlinNoiseProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1200. return texture;
  1201. };
  1202. __decorate([
  1203. babylonjs_1.serialize()
  1204. ], PerlinNoiseProceduralTexture.prototype, "time", void 0);
  1205. __decorate([
  1206. babylonjs_1.serialize()
  1207. ], PerlinNoiseProceduralTexture.prototype, "timeScale", void 0);
  1208. __decorate([
  1209. babylonjs_1.serialize()
  1210. ], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);
  1211. return PerlinNoiseProceduralTexture;
  1212. }(babylonjs_1.ProceduralTexture));
  1213. exports.PerlinNoiseProceduralTexture = PerlinNoiseProceduralTexture;
  1214. /***/ }),
  1215. /***/ "./src/road/index.ts":
  1216. /*!***************************!*\
  1217. !*** ./src/road/index.ts ***!
  1218. \***************************/
  1219. /*! no static exports found */
  1220. /***/ (function(module, exports, __webpack_require__) {
  1221. "use strict";
  1222. function __export(m) {
  1223. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1224. }
  1225. Object.defineProperty(exports, "__esModule", { value: true });
  1226. __export(__webpack_require__(/*! ./roadProceduralTexture */ "./src/road/roadProceduralTexture.ts"));
  1227. /***/ }),
  1228. /***/ "./src/road/roadProceduralTexture.fragment.ts":
  1229. /*!****************************************************!*\
  1230. !*** ./src/road/roadProceduralTexture.fragment.ts ***!
  1231. \****************************************************/
  1232. /*! no static exports found */
  1233. /***/ (function(module, exports, __webpack_require__) {
  1234. "use strict";
  1235. Object.defineProperty(exports, "__esModule", { value: true });
  1236. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1237. var name = 'roadProceduralTexturePixelShader';
  1238. exports.name = name;
  1239. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec3 roadColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main(void) {\nfloat ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));\nvec3 color=roadColor*ratioy;\ngl_FragColor=vec4(color,1.0);\n}";
  1240. exports.shader = shader;
  1241. babylonjs_1.Effect.ShadersStore[name] = shader;
  1242. /***/ }),
  1243. /***/ "./src/road/roadProceduralTexture.ts":
  1244. /*!*******************************************!*\
  1245. !*** ./src/road/roadProceduralTexture.ts ***!
  1246. \*******************************************/
  1247. /*! no static exports found */
  1248. /***/ (function(module, exports, __webpack_require__) {
  1249. "use strict";
  1250. var __extends = (this && this.__extends) || (function () {
  1251. var extendStatics = function (d, b) {
  1252. extendStatics = Object.setPrototypeOf ||
  1253. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1254. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1255. return extendStatics(d, b);
  1256. }
  1257. return function (d, b) {
  1258. extendStatics(d, b);
  1259. function __() { this.constructor = d; }
  1260. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1261. };
  1262. })();
  1263. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1264. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1265. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1266. 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;
  1267. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1268. };
  1269. Object.defineProperty(exports, "__esModule", { value: true });
  1270. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1271. __webpack_require__(/*! ./roadProceduralTexture.fragment */ "./src/road/roadProceduralTexture.fragment.ts");
  1272. var RoadProceduralTexture = /** @class */ (function (_super) {
  1273. __extends(RoadProceduralTexture, _super);
  1274. function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1275. var _this = _super.call(this, name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1276. _this._roadColor = new babylonjs_1.Color3(0.53, 0.53, 0.53);
  1277. _this.updateShaderUniforms();
  1278. return _this;
  1279. }
  1280. RoadProceduralTexture.prototype.updateShaderUniforms = function () {
  1281. this.setColor3("roadColor", this._roadColor);
  1282. };
  1283. Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
  1284. get: function () {
  1285. return this._roadColor;
  1286. },
  1287. set: function (value) {
  1288. this._roadColor = value;
  1289. this.updateShaderUniforms();
  1290. },
  1291. enumerable: true,
  1292. configurable: true
  1293. });
  1294. /**
  1295. * Serializes this road procedural texture
  1296. * @returns a serialized road procedural texture object
  1297. */
  1298. RoadProceduralTexture.prototype.serialize = function () {
  1299. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1300. serializationObject.customType = "BABYLON.RoadProceduralTexture";
  1301. return serializationObject;
  1302. };
  1303. /**
  1304. * Creates a Road Procedural Texture from parsed road procedural texture data
  1305. * @param parsedTexture defines parsed texture data
  1306. * @param scene defines the current scene
  1307. * @param rootUrl defines the root URL containing road procedural texture information
  1308. * @returns a parsed Road Procedural Texture
  1309. */
  1310. RoadProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1311. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1312. return texture;
  1313. };
  1314. __decorate([
  1315. babylonjs_1.serializeAsColor3()
  1316. ], RoadProceduralTexture.prototype, "roadColor", null);
  1317. return RoadProceduralTexture;
  1318. }(babylonjs_1.ProceduralTexture));
  1319. exports.RoadProceduralTexture = RoadProceduralTexture;
  1320. /***/ }),
  1321. /***/ "./src/starfield/index.ts":
  1322. /*!********************************!*\
  1323. !*** ./src/starfield/index.ts ***!
  1324. \********************************/
  1325. /*! no static exports found */
  1326. /***/ (function(module, exports, __webpack_require__) {
  1327. "use strict";
  1328. function __export(m) {
  1329. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1330. }
  1331. Object.defineProperty(exports, "__esModule", { value: true });
  1332. __export(__webpack_require__(/*! ./starfieldProceduralTexture */ "./src/starfield/starfieldProceduralTexture.ts"));
  1333. /***/ }),
  1334. /***/ "./src/starfield/starfieldProceduralTexture.fragment.ts":
  1335. /*!**************************************************************!*\
  1336. !*** ./src/starfield/starfieldProceduralTexture.fragment.ts ***!
  1337. \**************************************************************/
  1338. /*! no static exports found */
  1339. /***/ (function(module, exports, __webpack_require__) {
  1340. "use strict";
  1341. Object.defineProperty(exports, "__esModule", { value: true });
  1342. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1343. var name = 'starfieldProceduralTexturePixelShader';
  1344. exports.name = name;
  1345. var shader = "precision highp float;\n\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float time;\nuniform float alpha;\nuniform float beta;\nuniform float zoom;\nuniform float formuparam;\nuniform float stepsize;\nuniform float tile;\nuniform float brightness;\nuniform float darkmatter;\nuniform float distfading;\nuniform float saturation;\nvoid main()\n{\nvec3 dir=vec3(vUV*zoom,1.);\nfloat localTime=time*0.0001;\n\nmat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));\nmat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));\ndir.xz*=rot1;\ndir.xy*=rot2;\nvec3 from=vec3(1.,.5,0.5);\nfrom+=vec3(-2.,localTime*2.,localTime);\nfrom.xz*=rot1;\nfrom.xy*=rot2;\n\nfloat s=0.1,fade=1.;\nvec3 v=vec3(0.);\nfor (int r=0; r<volsteps; r++) {\nvec3 p=from+s*dir*.5;\np=abs(vec3(tile)-mod(p,vec3(tile*2.)));\nfloat pa,a=pa=0.;\nfor (int i=0; i<iterations; i++) {\np=abs(p)/dot(p,p)-formuparam;\na+=abs(length(p)-pa);\npa=length(p);\n}\nfloat dm=max(0.,darkmatter-a*a*.001);\na*=a*a;\nif (r>6) fade*=1.-dm;\n\nv+=fade;\nv+=vec3(s,s*s,s*s*s*s)*a*brightness*fade;\nfade*=distfading;\ns+=stepsize;\n}\nv=mix(vec3(length(v)),v,saturation);\ngl_FragColor=vec4(v*.01,1.);\n}";
  1346. exports.shader = shader;
  1347. babylonjs_1.Effect.ShadersStore[name] = shader;
  1348. /***/ }),
  1349. /***/ "./src/starfield/starfieldProceduralTexture.ts":
  1350. /*!*****************************************************!*\
  1351. !*** ./src/starfield/starfieldProceduralTexture.ts ***!
  1352. \*****************************************************/
  1353. /*! no static exports found */
  1354. /***/ (function(module, exports, __webpack_require__) {
  1355. "use strict";
  1356. var __extends = (this && this.__extends) || (function () {
  1357. var extendStatics = function (d, b) {
  1358. extendStatics = Object.setPrototypeOf ||
  1359. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1360. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1361. return extendStatics(d, b);
  1362. }
  1363. return function (d, b) {
  1364. extendStatics(d, b);
  1365. function __() { this.constructor = d; }
  1366. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1367. };
  1368. })();
  1369. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1370. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1371. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1372. 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;
  1373. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1374. };
  1375. Object.defineProperty(exports, "__esModule", { value: true });
  1376. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1377. __webpack_require__(/*! ./starfieldProceduralTexture.fragment */ "./src/starfield/starfieldProceduralTexture.fragment.ts");
  1378. var StarfieldProceduralTexture = /** @class */ (function (_super) {
  1379. __extends(StarfieldProceduralTexture, _super);
  1380. function StarfieldProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1381. var _this = _super.call(this, name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1382. _this._time = 1;
  1383. _this._alpha = 0.5;
  1384. _this._beta = 0.8;
  1385. _this._zoom = 0.8;
  1386. _this._formuparam = 0.53;
  1387. _this._stepsize = 0.1;
  1388. _this._tile = 0.850;
  1389. _this._brightness = 0.0015;
  1390. _this._darkmatter = 0.400;
  1391. _this._distfading = 0.730;
  1392. _this._saturation = 0.850;
  1393. _this.updateShaderUniforms();
  1394. return _this;
  1395. }
  1396. StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
  1397. this.setFloat("time", this._time);
  1398. this.setFloat("alpha", this._alpha);
  1399. this.setFloat("beta", this._beta);
  1400. this.setFloat("zoom", this._zoom);
  1401. this.setFloat("formuparam", this._formuparam);
  1402. this.setFloat("stepsize", this._stepsize);
  1403. this.setFloat("tile", this._tile);
  1404. this.setFloat("brightness", this._brightness);
  1405. this.setFloat("darkmatter", this._darkmatter);
  1406. this.setFloat("distfading", this._distfading);
  1407. this.setFloat("saturation", this._saturation);
  1408. };
  1409. Object.defineProperty(StarfieldProceduralTexture.prototype, "time", {
  1410. get: function () {
  1411. return this._time;
  1412. },
  1413. set: function (value) {
  1414. this._time = value;
  1415. this.updateShaderUniforms();
  1416. },
  1417. enumerable: true,
  1418. configurable: true
  1419. });
  1420. Object.defineProperty(StarfieldProceduralTexture.prototype, "alpha", {
  1421. get: function () {
  1422. return this._alpha;
  1423. },
  1424. set: function (value) {
  1425. this._alpha = value;
  1426. this.updateShaderUniforms();
  1427. },
  1428. enumerable: true,
  1429. configurable: true
  1430. });
  1431. Object.defineProperty(StarfieldProceduralTexture.prototype, "beta", {
  1432. get: function () {
  1433. return this._beta;
  1434. },
  1435. set: function (value) {
  1436. this._beta = value;
  1437. this.updateShaderUniforms();
  1438. },
  1439. enumerable: true,
  1440. configurable: true
  1441. });
  1442. Object.defineProperty(StarfieldProceduralTexture.prototype, "formuparam", {
  1443. get: function () {
  1444. return this._formuparam;
  1445. },
  1446. set: function (value) {
  1447. this._formuparam = value;
  1448. this.updateShaderUniforms();
  1449. },
  1450. enumerable: true,
  1451. configurable: true
  1452. });
  1453. Object.defineProperty(StarfieldProceduralTexture.prototype, "stepsize", {
  1454. get: function () {
  1455. return this._stepsize;
  1456. },
  1457. set: function (value) {
  1458. this._stepsize = value;
  1459. this.updateShaderUniforms();
  1460. },
  1461. enumerable: true,
  1462. configurable: true
  1463. });
  1464. Object.defineProperty(StarfieldProceduralTexture.prototype, "zoom", {
  1465. get: function () {
  1466. return this._zoom;
  1467. },
  1468. set: function (value) {
  1469. this._zoom = value;
  1470. this.updateShaderUniforms();
  1471. },
  1472. enumerable: true,
  1473. configurable: true
  1474. });
  1475. Object.defineProperty(StarfieldProceduralTexture.prototype, "tile", {
  1476. get: function () {
  1477. return this._tile;
  1478. },
  1479. set: function (value) {
  1480. this._tile = value;
  1481. this.updateShaderUniforms();
  1482. },
  1483. enumerable: true,
  1484. configurable: true
  1485. });
  1486. Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
  1487. get: function () {
  1488. return this._brightness;
  1489. },
  1490. set: function (value) {
  1491. this._brightness = value;
  1492. this.updateShaderUniforms();
  1493. },
  1494. enumerable: true,
  1495. configurable: true
  1496. });
  1497. Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
  1498. get: function () {
  1499. return this._darkmatter;
  1500. },
  1501. set: function (value) {
  1502. this._darkmatter = value;
  1503. this.updateShaderUniforms();
  1504. },
  1505. enumerable: true,
  1506. configurable: true
  1507. });
  1508. Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
  1509. get: function () {
  1510. return this._distfading;
  1511. },
  1512. set: function (value) {
  1513. this._distfading = value;
  1514. this.updateShaderUniforms();
  1515. },
  1516. enumerable: true,
  1517. configurable: true
  1518. });
  1519. Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
  1520. get: function () {
  1521. return this._saturation;
  1522. },
  1523. set: function (value) {
  1524. this._saturation = value;
  1525. this.updateShaderUniforms();
  1526. },
  1527. enumerable: true,
  1528. configurable: true
  1529. });
  1530. /**
  1531. * Serializes this starfield procedural texture
  1532. * @returns a serialized starfield procedural texture object
  1533. */
  1534. StarfieldProceduralTexture.prototype.serialize = function () {
  1535. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1536. serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
  1537. return serializationObject;
  1538. };
  1539. /**
  1540. * Creates a Starfield Procedural Texture from parsed startfield procedural texture data
  1541. * @param parsedTexture defines parsed texture data
  1542. * @param scene defines the current scene
  1543. * @param rootUrl defines the root URL containing startfield procedural texture information
  1544. * @returns a parsed Starfield Procedural Texture
  1545. */
  1546. StarfieldProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1547. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1548. return texture;
  1549. };
  1550. __decorate([
  1551. babylonjs_1.serialize()
  1552. ], StarfieldProceduralTexture.prototype, "time", null);
  1553. __decorate([
  1554. babylonjs_1.serialize()
  1555. ], StarfieldProceduralTexture.prototype, "alpha", null);
  1556. __decorate([
  1557. babylonjs_1.serialize()
  1558. ], StarfieldProceduralTexture.prototype, "beta", null);
  1559. __decorate([
  1560. babylonjs_1.serialize()
  1561. ], StarfieldProceduralTexture.prototype, "formuparam", null);
  1562. __decorate([
  1563. babylonjs_1.serialize()
  1564. ], StarfieldProceduralTexture.prototype, "stepsize", null);
  1565. __decorate([
  1566. babylonjs_1.serialize()
  1567. ], StarfieldProceduralTexture.prototype, "zoom", null);
  1568. __decorate([
  1569. babylonjs_1.serialize()
  1570. ], StarfieldProceduralTexture.prototype, "tile", null);
  1571. __decorate([
  1572. babylonjs_1.serialize()
  1573. ], StarfieldProceduralTexture.prototype, "brightness", null);
  1574. __decorate([
  1575. babylonjs_1.serialize()
  1576. ], StarfieldProceduralTexture.prototype, "darkmatter", null);
  1577. __decorate([
  1578. babylonjs_1.serialize()
  1579. ], StarfieldProceduralTexture.prototype, "distfading", null);
  1580. __decorate([
  1581. babylonjs_1.serialize()
  1582. ], StarfieldProceduralTexture.prototype, "saturation", null);
  1583. return StarfieldProceduralTexture;
  1584. }(babylonjs_1.ProceduralTexture));
  1585. exports.StarfieldProceduralTexture = StarfieldProceduralTexture;
  1586. /***/ }),
  1587. /***/ "./src/wood/index.ts":
  1588. /*!***************************!*\
  1589. !*** ./src/wood/index.ts ***!
  1590. \***************************/
  1591. /*! no static exports found */
  1592. /***/ (function(module, exports, __webpack_require__) {
  1593. "use strict";
  1594. function __export(m) {
  1595. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1596. }
  1597. Object.defineProperty(exports, "__esModule", { value: true });
  1598. __export(__webpack_require__(/*! ./woodProceduralTexture */ "./src/wood/woodProceduralTexture.ts"));
  1599. /***/ }),
  1600. /***/ "./src/wood/woodProceduralTexture.fragment.ts":
  1601. /*!****************************************************!*\
  1602. !*** ./src/wood/woodProceduralTexture.fragment.ts ***!
  1603. \****************************************************/
  1604. /*! no static exports found */
  1605. /***/ (function(module, exports, __webpack_require__) {
  1606. "use strict";
  1607. Object.defineProperty(exports, "__esModule", { value: true });
  1608. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1609. var name = 'woodProceduralTexturePixelShader';
  1610. exports.name = name;
  1611. var shader = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float ampScale;\nuniform vec3 woodColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main(void) {\nfloat ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));\nvec3 wood=woodColor*ratioy;\ngl_FragColor=vec4(wood,1.0);\n}";
  1612. exports.shader = shader;
  1613. babylonjs_1.Effect.ShadersStore[name] = shader;
  1614. /***/ }),
  1615. /***/ "./src/wood/woodProceduralTexture.ts":
  1616. /*!*******************************************!*\
  1617. !*** ./src/wood/woodProceduralTexture.ts ***!
  1618. \*******************************************/
  1619. /*! no static exports found */
  1620. /***/ (function(module, exports, __webpack_require__) {
  1621. "use strict";
  1622. var __extends = (this && this.__extends) || (function () {
  1623. var extendStatics = function (d, b) {
  1624. extendStatics = Object.setPrototypeOf ||
  1625. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1626. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1627. return extendStatics(d, b);
  1628. }
  1629. return function (d, b) {
  1630. extendStatics(d, b);
  1631. function __() { this.constructor = d; }
  1632. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1633. };
  1634. })();
  1635. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1636. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1637. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1638. 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;
  1639. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1640. };
  1641. Object.defineProperty(exports, "__esModule", { value: true });
  1642. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1643. __webpack_require__(/*! ./woodProceduralTexture.fragment */ "./src/wood/woodProceduralTexture.fragment.ts");
  1644. var WoodProceduralTexture = /** @class */ (function (_super) {
  1645. __extends(WoodProceduralTexture, _super);
  1646. function WoodProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1647. var _this = _super.call(this, name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1648. _this._ampScale = 100.0;
  1649. _this._woodColor = new babylonjs_1.Color3(0.32, 0.17, 0.09);
  1650. _this.updateShaderUniforms();
  1651. return _this;
  1652. }
  1653. WoodProceduralTexture.prototype.updateShaderUniforms = function () {
  1654. this.setFloat("ampScale", this._ampScale);
  1655. this.setColor3("woodColor", this._woodColor);
  1656. };
  1657. Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
  1658. get: function () {
  1659. return this._ampScale;
  1660. },
  1661. set: function (value) {
  1662. this._ampScale = value;
  1663. this.updateShaderUniforms();
  1664. },
  1665. enumerable: true,
  1666. configurable: true
  1667. });
  1668. Object.defineProperty(WoodProceduralTexture.prototype, "woodColor", {
  1669. get: function () {
  1670. return this._woodColor;
  1671. },
  1672. set: function (value) {
  1673. this._woodColor = value;
  1674. this.updateShaderUniforms();
  1675. },
  1676. enumerable: true,
  1677. configurable: true
  1678. });
  1679. /**
  1680. * Serializes this wood procedural texture
  1681. * @returns a serialized wood procedural texture object
  1682. */
  1683. WoodProceduralTexture.prototype.serialize = function () {
  1684. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1685. serializationObject.customType = "BABYLON.WoodProceduralTexture";
  1686. return serializationObject;
  1687. };
  1688. /**
  1689. * Creates a Wood Procedural Texture from parsed wood procedural texture data
  1690. * @param parsedTexture defines parsed texture data
  1691. * @param scene defines the current scene
  1692. * @param rootUrl defines the root URL containing wood procedural texture information
  1693. * @returns a parsed Wood Procedural Texture
  1694. */
  1695. WoodProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1696. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1697. return texture;
  1698. };
  1699. __decorate([
  1700. babylonjs_1.serialize()
  1701. ], WoodProceduralTexture.prototype, "ampScale", null);
  1702. __decorate([
  1703. babylonjs_1.serializeAsColor3()
  1704. ], WoodProceduralTexture.prototype, "woodColor", null);
  1705. return WoodProceduralTexture;
  1706. }(babylonjs_1.ProceduralTexture));
  1707. exports.WoodProceduralTexture = WoodProceduralTexture;
  1708. /***/ }),
  1709. /***/ "babylonjs":
  1710. /*!****************************************************************************************************!*\
  1711. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  1712. \****************************************************************************************************/
  1713. /*! no static exports found */
  1714. /***/ (function(module, exports) {
  1715. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  1716. /***/ })
  1717. /******/ });
  1718. });
  1719. //# sourceMappingURL=babylonjs.proceduralTextures.js.map