babylon.fireMaterial.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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-materials", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-materials"] = factory(require("babylonjs"));
  8. else
  9. root["MATLIB"] = 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-fire.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../Tools/Gulp/node_modules/webpack/buildin/global.js":
  99. /*!***********************************!*\
  100. !*** (webpack)/buildin/global.js ***!
  101. \***********************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || 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. /***/ "../src/fire/fire.fragment.fx":
  122. /*!************************************!*\
  123. !*** ../src/fire/fire.fragment.fx ***!
  124. \************************************/
  125. /*! no static exports found */
  126. /***/ (function(module, exports) {
  127. module.exports = "precision highp float;\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\nuniform sampler2D distortionSampler;\nuniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{\nreturn vec4(2.0)*x-vec4(1.0);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\n\nfloat alpha=1.0;\n#ifdef DIFFUSE\n\nconst float distortionAmount0=0.092;\nconst float distortionAmount1=0.092;\nconst float distortionAmount2=0.092;\nvec2 heightAttenuation=vec2(0.3,0.39);\nvec4 noise0=texture2D(distortionSampler,vDistortionCoords1);\nvec4 noise1=texture2D(distortionSampler,vDistortionCoords2);\nvec4 noise2=texture2D(distortionSampler,vDistortionCoords3);\nvec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;\nvec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);\nvec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;\nbaseColor*=opacityColor;\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}"
  128. /***/ }),
  129. /***/ "../src/fire/fire.vertex.fx":
  130. /*!**********************************!*\
  131. !*** ../src/fire/fire.vertex.fx ***!
  132. \**********************************/
  133. /*! no static exports found */
  134. /***/ (function(module, exports) {
  135. module.exports = "precision highp float;\n\nattribute vec3 position;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n\nuniform float time;\nuniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#ifdef DIFFUSE\nvDiffuseUV=uv;\nvDiffuseUV.y-=0.2;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\n\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;\nvDistortionCoords1.x=uv.x;\nvDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;\nvDistortionCoords2.x=uv.x;\nvDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;\nvDistortionCoords3.x=uv.x;\nvDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n}\n"
  136. /***/ }),
  137. /***/ "../src/fire/fireMaterial.ts":
  138. /*!***********************************!*\
  139. !*** ../src/fire/fireMaterial.ts ***!
  140. \***********************************/
  141. /*! no static exports found */
  142. /***/ (function(module, exports, __webpack_require__) {
  143. "use strict";
  144. var __extends = (this && this.__extends) || (function () {
  145. var extendStatics = function (d, b) {
  146. extendStatics = Object.setPrototypeOf ||
  147. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  148. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  149. return extendStatics(d, b);
  150. }
  151. return function (d, b) {
  152. extendStatics(d, b);
  153. function __() { this.constructor = d; }
  154. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  155. };
  156. })();
  157. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  158. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  159. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  160. 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;
  161. return c > 3 && r && Object.defineProperty(target, key, r), r;
  162. };
  163. Object.defineProperty(exports, "__esModule", { value: true });
  164. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  165. babylonjs_1.Effect.ShadersStore["firePixelShader"] = __webpack_require__(/*! ./fire.fragment.fx */ "../src/fire/fire.fragment.fx");
  166. babylonjs_1.Effect.ShadersStore["fireVertexShader"] = __webpack_require__(/*! ./fire.vertex.fx */ "../src/fire/fire.vertex.fx");
  167. var FireMaterialDefines = /** @class */ (function (_super) {
  168. __extends(FireMaterialDefines, _super);
  169. function FireMaterialDefines() {
  170. var _this = _super.call(this) || this;
  171. _this.DIFFUSE = false;
  172. _this.CLIPPLANE = false;
  173. _this.CLIPPLANE2 = false;
  174. _this.CLIPPLANE3 = false;
  175. _this.CLIPPLANE4 = false;
  176. _this.ALPHATEST = false;
  177. _this.DEPTHPREPASS = false;
  178. _this.POINTSIZE = false;
  179. _this.FOG = false;
  180. _this.UV1 = false;
  181. _this.VERTEXCOLOR = false;
  182. _this.VERTEXALPHA = false;
  183. _this.BonesPerMesh = 0;
  184. _this.NUM_BONE_INFLUENCERS = 0;
  185. _this.INSTANCES = false;
  186. _this.rebuild();
  187. return _this;
  188. }
  189. return FireMaterialDefines;
  190. }(babylonjs_1.MaterialDefines));
  191. var FireMaterial = /** @class */ (function (_super) {
  192. __extends(FireMaterial, _super);
  193. function FireMaterial(name, scene) {
  194. var _this = _super.call(this, name, scene) || this;
  195. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  196. _this.speed = 1.0;
  197. _this._scaledDiffuse = new babylonjs_1.Color3();
  198. _this._lastTime = 0;
  199. return _this;
  200. }
  201. FireMaterial.prototype.needAlphaBlending = function () {
  202. return false;
  203. };
  204. FireMaterial.prototype.needAlphaTesting = function () {
  205. return true;
  206. };
  207. FireMaterial.prototype.getAlphaTestTexture = function () {
  208. return null;
  209. };
  210. // Methods
  211. FireMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  212. if (this.isFrozen) {
  213. if (this._wasPreviouslyReady && subMesh.effect) {
  214. return true;
  215. }
  216. }
  217. if (!subMesh._materialDefines) {
  218. subMesh._materialDefines = new FireMaterialDefines();
  219. }
  220. var defines = subMesh._materialDefines;
  221. var scene = this.getScene();
  222. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  223. if (this._renderId === scene.getRenderId()) {
  224. return true;
  225. }
  226. }
  227. var engine = scene.getEngine();
  228. // Textures
  229. if (defines._areTexturesDirty) {
  230. defines._needUVs = false;
  231. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  232. if (!this._diffuseTexture.isReady()) {
  233. return false;
  234. }
  235. else {
  236. defines._needUVs = true;
  237. defines.DIFFUSE = true;
  238. }
  239. }
  240. }
  241. defines.ALPHATEST = this._opacityTexture ? true : false;
  242. // Misc.
  243. if (defines._areMiscDirty) {
  244. defines.POINTSIZE = (this.pointsCloud || scene.forcePointsCloud);
  245. defines.FOG = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE && this.fogEnabled);
  246. }
  247. // Values that need to be evaluated on every frame
  248. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  249. // Attribs
  250. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
  251. // Get correct effect
  252. if (defines.isDirty) {
  253. defines.markAsProcessed();
  254. scene.resetCachedMaterial();
  255. // Fallbacks
  256. var fallbacks = new babylonjs_1.EffectFallbacks();
  257. if (defines.FOG) {
  258. fallbacks.addFallback(1, "FOG");
  259. }
  260. if (defines.NUM_BONE_INFLUENCERS > 0) {
  261. fallbacks.addCPUSkinningFallback(0, mesh);
  262. }
  263. //Attributes
  264. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  265. if (defines.UV1) {
  266. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  267. }
  268. if (defines.VERTEXCOLOR) {
  269. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  270. }
  271. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  272. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  273. // Legacy browser patch
  274. var shaderName = "fire";
  275. var join = defines.toString();
  276. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  277. attributes: attribs,
  278. uniformsNames: ["world", "view", "viewProjection", "vEyePosition",
  279. "vFogInfos", "vFogColor", "pointSize",
  280. "vDiffuseInfos",
  281. "mBones",
  282. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
  283. // Fire
  284. "time", "speed"
  285. ],
  286. uniformBuffersNames: [],
  287. samplers: ["diffuseSampler",
  288. // Fire
  289. "distortionSampler", "opacitySampler"
  290. ],
  291. defines: join,
  292. fallbacks: fallbacks,
  293. onCompiled: this.onCompiled,
  294. onError: this.onError,
  295. indexParameters: null,
  296. maxSimultaneousLights: 4,
  297. transformFeedbackVaryings: null
  298. }, engine), defines);
  299. }
  300. if (!subMesh.effect || !subMesh.effect.isReady()) {
  301. return false;
  302. }
  303. this._renderId = scene.getRenderId();
  304. this._wasPreviouslyReady = true;
  305. return true;
  306. };
  307. FireMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  308. var scene = this.getScene();
  309. var defines = subMesh._materialDefines;
  310. if (!defines) {
  311. return;
  312. }
  313. var effect = subMesh.effect;
  314. if (!effect) {
  315. return;
  316. }
  317. this._activeEffect = effect;
  318. // Matrices
  319. this.bindOnlyWorldMatrix(world);
  320. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  321. // Bones
  322. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  323. if (this._mustRebind(scene, effect)) {
  324. // Textures
  325. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  326. this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
  327. this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  328. this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
  329. this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
  330. this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
  331. }
  332. // Clip plane
  333. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  334. // Point size
  335. if (this.pointsCloud) {
  336. this._activeEffect.setFloat("pointSize", this.pointSize);
  337. }
  338. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  339. }
  340. this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
  341. // View
  342. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  343. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  344. }
  345. // Fog
  346. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  347. // Time
  348. this._lastTime += scene.getEngine().getDeltaTime();
  349. this._activeEffect.setFloat("time", this._lastTime);
  350. // Speed
  351. this._activeEffect.setFloat("speed", this.speed);
  352. this._afterBind(mesh, this._activeEffect);
  353. };
  354. FireMaterial.prototype.getAnimatables = function () {
  355. var results = [];
  356. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  357. results.push(this._diffuseTexture);
  358. }
  359. if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
  360. results.push(this._distortionTexture);
  361. }
  362. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  363. results.push(this._opacityTexture);
  364. }
  365. return results;
  366. };
  367. FireMaterial.prototype.getActiveTextures = function () {
  368. var activeTextures = _super.prototype.getActiveTextures.call(this);
  369. if (this._diffuseTexture) {
  370. activeTextures.push(this._diffuseTexture);
  371. }
  372. if (this._distortionTexture) {
  373. activeTextures.push(this._distortionTexture);
  374. }
  375. if (this._opacityTexture) {
  376. activeTextures.push(this._opacityTexture);
  377. }
  378. return activeTextures;
  379. };
  380. FireMaterial.prototype.hasTexture = function (texture) {
  381. if (_super.prototype.hasTexture.call(this, texture)) {
  382. return true;
  383. }
  384. if (this._diffuseTexture === texture) {
  385. return true;
  386. }
  387. if (this._distortionTexture === texture) {
  388. return true;
  389. }
  390. if (this._opacityTexture === texture) {
  391. return true;
  392. }
  393. return false;
  394. };
  395. FireMaterial.prototype.getClassName = function () {
  396. return "FireMaterial";
  397. };
  398. FireMaterial.prototype.dispose = function (forceDisposeEffect) {
  399. if (this._diffuseTexture) {
  400. this._diffuseTexture.dispose();
  401. }
  402. if (this._distortionTexture) {
  403. this._distortionTexture.dispose();
  404. }
  405. _super.prototype.dispose.call(this, forceDisposeEffect);
  406. };
  407. FireMaterial.prototype.clone = function (name) {
  408. var _this = this;
  409. return babylonjs_1.SerializationHelper.Clone(function () { return new FireMaterial(name, _this.getScene()); }, this);
  410. };
  411. FireMaterial.prototype.serialize = function () {
  412. var serializationObject = _super.prototype.serialize.call(this);
  413. serializationObject.customType = "BABYLON.FireMaterial";
  414. serializationObject.diffuseColor = this.diffuseColor.asArray();
  415. serializationObject.speed = this.speed;
  416. if (this._diffuseTexture) {
  417. serializationObject._diffuseTexture = this._diffuseTexture.serialize();
  418. }
  419. if (this._distortionTexture) {
  420. serializationObject._distortionTexture = this._distortionTexture.serialize();
  421. }
  422. if (this._opacityTexture) {
  423. serializationObject._opacityTexture = this._opacityTexture.serialize();
  424. }
  425. return serializationObject;
  426. };
  427. FireMaterial.Parse = function (source, scene, rootUrl) {
  428. var material = new FireMaterial(source.name, scene);
  429. material.diffuseColor = babylonjs_1.Color3.FromArray(source.diffuseColor);
  430. material.speed = source.speed;
  431. material.alpha = source.alpha;
  432. material.id = source.id;
  433. babylonjs_1.Tags.AddTagsTo(material, source.tags);
  434. material.backFaceCulling = source.backFaceCulling;
  435. material.wireframe = source.wireframe;
  436. if (source._diffuseTexture) {
  437. material._diffuseTexture = babylonjs_1.Texture.Parse(source._diffuseTexture, scene, rootUrl);
  438. }
  439. if (source._distortionTexture) {
  440. material._distortionTexture = babylonjs_1.Texture.Parse(source._distortionTexture, scene, rootUrl);
  441. }
  442. if (source._opacityTexture) {
  443. material._opacityTexture = babylonjs_1.Texture.Parse(source._opacityTexture, scene, rootUrl);
  444. }
  445. if (source.checkReadyOnlyOnce) {
  446. material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
  447. }
  448. return material;
  449. };
  450. __decorate([
  451. babylonjs_1.serializeAsTexture("diffuseTexture")
  452. ], FireMaterial.prototype, "_diffuseTexture", void 0);
  453. __decorate([
  454. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  455. ], FireMaterial.prototype, "diffuseTexture", void 0);
  456. __decorate([
  457. babylonjs_1.serializeAsTexture("distortionTexture")
  458. ], FireMaterial.prototype, "_distortionTexture", void 0);
  459. __decorate([
  460. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  461. ], FireMaterial.prototype, "distortionTexture", void 0);
  462. __decorate([
  463. babylonjs_1.serializeAsTexture("opacityTexture")
  464. ], FireMaterial.prototype, "_opacityTexture", void 0);
  465. __decorate([
  466. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  467. ], FireMaterial.prototype, "opacityTexture", void 0);
  468. __decorate([
  469. babylonjs_1.serializeAsColor3("diffuse")
  470. ], FireMaterial.prototype, "diffuseColor", void 0);
  471. __decorate([
  472. babylonjs_1.serialize()
  473. ], FireMaterial.prototype, "speed", void 0);
  474. return FireMaterial;
  475. }(babylonjs_1.PushMaterial));
  476. exports.FireMaterial = FireMaterial;
  477. /***/ }),
  478. /***/ "../src/fire/index.ts":
  479. /*!****************************!*\
  480. !*** ../src/fire/index.ts ***!
  481. \****************************/
  482. /*! no static exports found */
  483. /***/ (function(module, exports, __webpack_require__) {
  484. "use strict";
  485. function __export(m) {
  486. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  487. }
  488. Object.defineProperty(exports, "__esModule", { value: true });
  489. __export(__webpack_require__(/*! ./fireMaterial */ "../src/fire/fireMaterial.ts"));
  490. /***/ }),
  491. /***/ "./legacy-fire.ts":
  492. /*!************************!*\
  493. !*** ./legacy-fire.ts ***!
  494. \************************/
  495. /*! no static exports found */
  496. /***/ (function(module, exports, __webpack_require__) {
  497. "use strict";
  498. /* WEBPACK VAR INJECTION */(function(global) {
  499. function __export(m) {
  500. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  501. }
  502. Object.defineProperty(exports, "__esModule", { value: true });
  503. var MatLib = __webpack_require__(/*! ../src/fire/index */ "../src/fire/index.ts");
  504. /**
  505. * This is the entry point for the UMD module.
  506. * The entry point for a future ESM package should be index.ts
  507. */
  508. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  509. if (typeof globalObject !== "undefined") {
  510. for (var key in MatLib) {
  511. globalObject.BABYLON[key] = MatLib[key];
  512. }
  513. }
  514. __export(__webpack_require__(/*! ../src/fire/index */ "../src/fire/index.ts"));
  515. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../Tools/Gulp/node_modules/webpack/buildin/global.js */ "../../Tools/Gulp/node_modules/webpack/buildin/global.js")))
  516. /***/ }),
  517. /***/ "babylonjs":
  518. /*!****************************************************************************************************!*\
  519. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  520. \****************************************************************************************************/
  521. /*! no static exports found */
  522. /***/ (function(module, exports) {
  523. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  524. /***/ })
  525. /******/ });
  526. });
  527. //# sourceMappingURL=babylon.fireMaterial.js.map