babylon.fireMaterial.js 26 KB

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