(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("babylonjs")); else if(typeof define === 'function' && define.amd) define("babylonjs-procedural-textures", ["babylonjs"], factory); else if(typeof exports === 'object') exports["babylonjs-procedural-textures"] = factory(require("babylonjs")); else root["BABYLON"] = factory(root["BABYLON"]); })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy-fire.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "../Tools/Gulp/node_modules/webpack/buildin/global.js": /*!************************************************************!*\ !*** ../Tools/Gulp/node_modules/webpack/buildin/global.js ***! \************************************************************/ /*! no static exports found */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1, eval)("this"); } catch (e) { // This works if the window reference is available if (typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /***/ "./legacy/legacy-fire.ts": /*!*******************************!*\ !*** ./legacy/legacy-fire.ts ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) { function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); var proceduralTexture = __webpack_require__(/*! ../src/fire */ "./src/fire/index.ts"); /** * This is the entry point for the UMD module. * The entry point for a future ESM package should be index.ts */ var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined); if (typeof globalObject !== "undefined") { for (var key in proceduralTexture) { globalObject.BABYLON[key] = proceduralTexture[key]; } } __export(__webpack_require__(/*! ../src/fire */ "./src/fire/index.ts")); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../Tools/Gulp/node_modules/webpack/buildin/global.js */ "../Tools/Gulp/node_modules/webpack/buildin/global.js"))) /***/ }), /***/ "./src/fire/fireProceduralTexture.fragment.fx": /*!****************************************************!*\ !*** ./src/fire/fireProceduralTexture.fragment.fx ***! \****************************************************/ /*! no static exports found */ /***/ (function(module, exports) { 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}" /***/ }), /***/ "./src/fire/fireProceduralTexture.ts": /*!*******************************************!*\ !*** ./src/fire/fireProceduralTexture.ts ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs"); babylonjs_1.Effect.ShadersStore["fireProceduralTexturePixelShader"] = __webpack_require__(/*! ./fireProceduralTexture.fragment.fx */ "./src/fire/fireProceduralTexture.fragment.fx"); var FireProceduralTexture = /** @class */ (function (_super) { __extends(FireProceduralTexture, _super); function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) { var _this = _super.call(this, name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps) || this; _this._time = 0.0; _this._speed = new babylonjs_1.Vector2(0.5, 0.3); _this._autoGenerateTime = true; _this._alphaThreshold = 0.5; _this._fireColors = FireProceduralTexture.RedFireColors; _this.updateShaderUniforms(); return _this; } FireProceduralTexture.prototype.updateShaderUniforms = function () { this.setFloat("time", this._time); this.setVector2("speed", this._speed); this.setColor3("c1", this._fireColors[0]); this.setColor3("c2", this._fireColors[1]); this.setColor3("c3", this._fireColors[2]); this.setColor3("c4", this._fireColors[3]); this.setColor3("c5", this._fireColors[4]); this.setColor3("c6", this._fireColors[5]); this.setFloat("alphaThreshold", this._alphaThreshold); }; FireProceduralTexture.prototype.render = function (useCameraPostProcess) { var scene = this.getScene(); if (this._autoGenerateTime && scene) { this._time += scene.getAnimationRatio() * 0.03; this.updateShaderUniforms(); } _super.prototype.render.call(this, useCameraPostProcess); }; Object.defineProperty(FireProceduralTexture, "PurpleFireColors", { get: function () { return [ new babylonjs_1.Color3(0.5, 0.0, 1.0), new babylonjs_1.Color3(0.9, 0.0, 1.0), new babylonjs_1.Color3(0.2, 0.0, 1.0), new babylonjs_1.Color3(1.0, 0.9, 1.0), new babylonjs_1.Color3(0.1, 0.1, 1.0), new babylonjs_1.Color3(0.9, 0.9, 1.0) ]; }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture, "GreenFireColors", { get: function () { return [ new babylonjs_1.Color3(0.5, 1.0, 0.0), new babylonjs_1.Color3(0.5, 1.0, 0.0), new babylonjs_1.Color3(0.3, 0.4, 0.0), new babylonjs_1.Color3(0.5, 1.0, 0.0), new babylonjs_1.Color3(0.2, 0.0, 0.0), new babylonjs_1.Color3(0.5, 1.0, 0.0) ]; }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture, "RedFireColors", { get: function () { return [ new babylonjs_1.Color3(0.5, 0.0, 0.1), new babylonjs_1.Color3(0.9, 0.0, 0.0), new babylonjs_1.Color3(0.2, 0.0, 0.0), new babylonjs_1.Color3(1.0, 0.9, 0.0), new babylonjs_1.Color3(0.1, 0.1, 0.1), new babylonjs_1.Color3(0.9, 0.9, 0.9) ]; }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture, "BlueFireColors", { get: function () { return [ new babylonjs_1.Color3(0.1, 0.0, 0.5), new babylonjs_1.Color3(0.0, 0.0, 0.5), new babylonjs_1.Color3(0.1, 0.0, 0.2), new babylonjs_1.Color3(0.0, 0.0, 1.0), new babylonjs_1.Color3(0.1, 0.2, 0.3), new babylonjs_1.Color3(0.0, 0.2, 0.9) ]; }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture.prototype, "autoGenerateTime", { get: function () { return this._autoGenerateTime; }, set: function (value) { this._autoGenerateTime = value; }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture.prototype, "fireColors", { get: function () { return this._fireColors; }, set: function (value) { this._fireColors = value; this.updateShaderUniforms(); }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture.prototype, "time", { get: function () { return this._time; }, set: function (value) { this._time = value; this.updateShaderUniforms(); }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture.prototype, "speed", { get: function () { return this._speed; }, set: function (value) { this._speed = value; this.updateShaderUniforms(); }, enumerable: true, configurable: true }); Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", { get: function () { return this._alphaThreshold; }, set: function (value) { this._alphaThreshold = value; this.updateShaderUniforms(); }, enumerable: true, configurable: true }); /** * Serializes this fire procedural texture * @returns a serialized fire procedural texture object */ FireProceduralTexture.prototype.serialize = function () { var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this)); serializationObject.customType = "BABYLON.FireProceduralTexture"; serializationObject.fireColors = []; for (var i = 0; i < this._fireColors.length; i++) { serializationObject.fireColors.push(this._fireColors[i].asArray()); } return serializationObject; }; /** * Creates a Fire Procedural Texture from parsed fire procedural texture data * @param parsedTexture defines parsed texture data * @param scene defines the current scene * @param rootUrl defines the root URL containing fire procedural texture information * @returns a parsed Fire Procedural Texture */ FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) { var texture = babylonjs_1.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl); var colors = []; for (var i = 0; i < parsedTexture.fireColors.length; i++) { colors.push(babylonjs_1.Color3.FromArray(parsedTexture.fireColors[i])); } texture.fireColors = colors; return texture; }; __decorate([ babylonjs_1.serialize() ], FireProceduralTexture.prototype, "autoGenerateTime", null); __decorate([ babylonjs_1.serialize() ], FireProceduralTexture.prototype, "time", null); __decorate([ babylonjs_1.serializeAsVector2() ], FireProceduralTexture.prototype, "speed", null); __decorate([ babylonjs_1.serialize() ], FireProceduralTexture.prototype, "alphaThreshold", null); return FireProceduralTexture; }(babylonjs_1.ProceduralTexture)); exports.FireProceduralTexture = FireProceduralTexture; /***/ }), /***/ "./src/fire/index.ts": /*!***************************!*\ !*** ./src/fire/index.ts ***! \***************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); __export(__webpack_require__(/*! ./fireProceduralTexture */ "./src/fire/fireProceduralTexture.ts")); /***/ }), /***/ "babylonjs": /*!****************************************************************************************************!*\ !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! \****************************************************************************************************/ /*! no static exports found */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__; /***/ }) /******/ }); }); //# sourceMappingURL=babylon.fireProceduralTexture.min.js.map