babylonjs.proceduralTextures.js 85 KB

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