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