babylon.mixMaterial.js 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  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["MATERIALS"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_decorators__) {
  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-mix.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. <<<<<<< HEAD
  101. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  102. =======
  103. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  104. >>>>>>> c561ead7a93fc6094d0854d66d037d358954fe3b
  105. \***********************************************************/
  106. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108. "use strict";
  109. __webpack_require__.r(__webpack_exports__);
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation. All rights reserved.
  131. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  132. this file except in compliance with the License. You may obtain a copy of the
  133. License at http://www.apache.org/licenses/LICENSE-2.0
  134. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  135. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  136. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  137. MERCHANTABLITY OR NON-INFRINGEMENT.
  138. See the Apache Version 2.0 License for specific language governing permissions
  139. and limitations under the License.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  169. t[p[i]] = s[p[i]];
  170. return t;
  171. }
  172. function __decorate(decorators, target, key, desc) {
  173. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  174. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  175. 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;
  176. return c > 3 && r && Object.defineProperty(target, key, r), r;
  177. }
  178. function __param(paramIndex, decorator) {
  179. return function (target, key) { decorator(target, key, paramIndex); }
  180. }
  181. function __metadata(metadataKey, metadataValue) {
  182. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  183. }
  184. function __awaiter(thisArg, _arguments, P, generator) {
  185. return new (P || (P = Promise))(function (resolve, reject) {
  186. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  187. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  188. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  189. step((generator = generator.apply(thisArg, _arguments || [])).next());
  190. });
  191. }
  192. function __generator(thisArg, body) {
  193. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  194. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  195. function verb(n) { return function (v) { return step([n, v]); }; }
  196. function step(op) {
  197. if (f) throw new TypeError("Generator is already executing.");
  198. while (_) try {
  199. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  200. if (y = 0, t) op = [op[0] & 2, t.value];
  201. switch (op[0]) {
  202. case 0: case 1: t = op; break;
  203. case 4: _.label++; return { value: op[1], done: false };
  204. case 5: _.label++; y = op[1]; op = [0]; continue;
  205. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  206. default:
  207. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  208. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  209. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  210. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  211. if (t[2]) _.ops.pop();
  212. _.trys.pop(); continue;
  213. }
  214. op = body.call(thisArg, _);
  215. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  216. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  217. }
  218. }
  219. function __exportStar(m, exports) {
  220. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  221. }
  222. function __values(o) {
  223. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  224. if (m) return m.call(o);
  225. return {
  226. next: function () {
  227. if (o && i >= o.length) o = void 0;
  228. return { value: o && o[i++], done: !o };
  229. }
  230. };
  231. }
  232. function __read(o, n) {
  233. var m = typeof Symbol === "function" && o[Symbol.iterator];
  234. if (!m) return o;
  235. var i = m.call(o), r, ar = [], e;
  236. try {
  237. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  238. }
  239. catch (error) { e = { error: error }; }
  240. finally {
  241. try {
  242. if (r && !r.done && (m = i["return"])) m.call(i);
  243. }
  244. finally { if (e) throw e.error; }
  245. }
  246. return ar;
  247. }
  248. function __spread() {
  249. for (var ar = [], i = 0; i < arguments.length; i++)
  250. ar = ar.concat(__read(arguments[i]));
  251. return ar;
  252. }
  253. function __await(v) {
  254. return this instanceof __await ? (this.v = v, this) : new __await(v);
  255. }
  256. function __asyncGenerator(thisArg, _arguments, generator) {
  257. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  258. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  259. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  260. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  261. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  262. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  263. function fulfill(value) { resume("next", value); }
  264. function reject(value) { resume("throw", value); }
  265. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  266. }
  267. function __asyncDelegator(o) {
  268. var i, p;
  269. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  270. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  271. }
  272. function __asyncValues(o) {
  273. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  274. var m = o[Symbol.asyncIterator], i;
  275. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  276. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  277. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  278. }
  279. function __makeTemplateObject(cooked, raw) {
  280. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  281. return cooked;
  282. };
  283. function __importStar(mod) {
  284. if (mod && mod.__esModule) return mod;
  285. var result = {};
  286. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  287. result.default = mod;
  288. return result;
  289. }
  290. function __importDefault(mod) {
  291. return (mod && mod.__esModule) ? mod : { default: mod };
  292. }
  293. /***/ }),
  294. /***/ "../../node_modules/webpack/buildin/global.js":
  295. /*!***********************************!*\
  296. !*** (webpack)/buildin/global.js ***!
  297. \***********************************/
  298. /*! no static exports found */
  299. /***/ (function(module, exports) {
  300. var g;
  301. // This works in non-strict mode
  302. g = (function() {
  303. return this;
  304. })();
  305. try {
  306. // This works if eval is allowed (see CSP)
  307. g = g || new Function("return this")();
  308. } catch (e) {
  309. // This works if the window reference is available
  310. if (typeof window === "object") g = window;
  311. }
  312. // g can still be undefined, but nothing to do about it...
  313. // We return undefined, instead of nothing here, so it's
  314. // easier to handle this case. if(!global) { ...}
  315. module.exports = g;
  316. /***/ }),
  317. /***/ "./legacy/legacy-mix.ts":
  318. /*!******************************!*\
  319. !*** ./legacy/legacy-mix.ts ***!
  320. \******************************/
  321. /*! exports provided: MixMaterial */
  322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  323. "use strict";
  324. __webpack_require__.r(__webpack_exports__);
  325. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _mix_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mix/index */ "./mix/index.ts");
  326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return _mix_index__WEBPACK_IMPORTED_MODULE_0__["MixMaterial"]; });
  327. /**
  328. * This is the entry point for the UMD module.
  329. * The entry point for a future ESM package should be index.ts
  330. */
  331. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  332. if (typeof globalObject !== "undefined") {
  333. for (var key in _mix_index__WEBPACK_IMPORTED_MODULE_0__) {
  334. globalObject.BABYLON[key] = _mix_index__WEBPACK_IMPORTED_MODULE_0__[key];
  335. }
  336. }
  337. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  338. /***/ }),
  339. /***/ "./mix/index.ts":
  340. /*!**********************!*\
  341. !*** ./mix/index.ts ***!
  342. \**********************/
  343. /*! exports provided: MixMaterial */
  344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  345. "use strict";
  346. __webpack_require__.r(__webpack_exports__);
  347. /* harmony import */ var _mixMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mixMaterial */ "./mix/mixMaterial.ts");
  348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return _mixMaterial__WEBPACK_IMPORTED_MODULE_0__["MixMaterial"]; });
  349. /***/ }),
  350. /***/ "./mix/mix.fragment.ts":
  351. /*!*****************************!*\
  352. !*** ./mix/mix.fragment.ts ***!
  353. \*****************************/
  354. /*! exports provided: mixPixelShader */
  355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  356. "use strict";
  357. __webpack_require__.r(__webpack_exports__);
  358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mixPixelShader", function() { return mixPixelShader; });
  359. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
  360. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  361. var name = 'mixPixelShader';
  362. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D mixMap1Sampler;\nuniform vec2 vTextureInfos;\n#ifdef MIXMAP2\nuniform sampler2D mixMap2Sampler;\n#endif\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform sampler2D diffuse4Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\nuniform vec2 diffuse4Infos;\n#ifdef MIXMAP2\nuniform sampler2D diffuse5Sampler;\nuniform sampler2D diffuse6Sampler;\nuniform sampler2D diffuse7Sampler;\nuniform sampler2D diffuse8Sampler;\nuniform vec2 diffuse5Infos;\nuniform vec2 diffuse6Infos;\nuniform vec2 diffuse7Infos;\nuniform vec2 diffuse8Infos;\n#endif\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 finalMixColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef MIXMAP2\nvec4 mixColor2=vec4(1.,1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\n#include<depthPrePass>\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\nvec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);\ndiffuse1Color.rgb*=mixColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);\ndiffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\n#ifdef MIXMAP2\nmixColor=texture2D(mixMap2Sampler,vTextureUV);\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);\nvec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);\nvec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);\nvec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);\ndiffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);\ndiffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);\ndiffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\n#endif\n#endif\n#ifdef VERTEXCOLOR\nfinalMixColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*finalMixColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  363. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  364. /** @hidden */
  365. var mixPixelShader = { name: name, shader: shader };
  366. /***/ }),
  367. /***/ "./mix/mix.vertex.ts":
  368. /*!***************************!*\
  369. !*** ./mix/mix.vertex.ts ***!
  370. \***************************/
  371. /*! exports provided: mixVertexShader */
  372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  373. "use strict";
  374. __webpack_require__.r(__webpack_exports__);
  375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mixVertexShader", function() { return mixVertexShader; });
  376. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
  377. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  378. var name = 'mixVertexShader';
  379. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\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 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\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#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  380. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  381. /** @hidden */
  382. var mixVertexShader = { name: name, shader: shader };
  383. /***/ }),
  384. /***/ "./mix/mixMaterial.ts":
  385. /*!****************************!*\
  386. !*** ./mix/mixMaterial.ts ***!
  387. \****************************/
  388. /*! exports provided: MixMaterial */
  389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  390. "use strict";
  391. __webpack_require__.r(__webpack_exports__);
  392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return MixMaterial; });
  393. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  394. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
  395. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  396. /* harmony import */ var _mix_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mix.fragment */ "./mix/mix.fragment.ts");
  397. /* harmony import */ var _mix_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mix.vertex */ "./mix/mix.vertex.ts");
  398. var MixMaterialDefines = /** @class */ (function (_super) {
  399. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MixMaterialDefines, _super);
  400. function MixMaterialDefines() {
  401. var _this = _super.call(this) || this;
  402. _this.DIFFUSE = false;
  403. _this.CLIPPLANE = false;
  404. _this.CLIPPLANE2 = false;
  405. _this.CLIPPLANE3 = false;
  406. _this.CLIPPLANE4 = false;
  407. _this.ALPHATEST = false;
  408. _this.DEPTHPREPASS = false;
  409. _this.POINTSIZE = false;
  410. _this.FOG = false;
  411. _this.SPECULARTERM = false;
  412. _this.NORMAL = false;
  413. _this.UV1 = false;
  414. _this.UV2 = false;
  415. _this.VERTEXCOLOR = false;
  416. _this.VERTEXALPHA = false;
  417. _this.NUM_BONE_INFLUENCERS = 0;
  418. _this.BonesPerMesh = 0;
  419. _this.INSTANCES = false;
  420. _this.MIXMAP2 = false;
  421. _this.rebuild();
  422. return _this;
  423. }
  424. return MixMaterialDefines;
  425. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  426. var MixMaterial = /** @class */ (function (_super) {
  427. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MixMaterial, _super);
  428. function MixMaterial(name, scene) {
  429. var _this = _super.call(this, name, scene) || this;
  430. /**
  431. * Uniforms
  432. */
  433. _this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  434. _this.specularColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0, 0, 0);
  435. _this.specularPower = 64;
  436. _this._disableLighting = false;
  437. _this._maxSimultaneousLights = 4;
  438. return _this;
  439. }
  440. MixMaterial.prototype.needAlphaBlending = function () {
  441. return (this.alpha < 1.0);
  442. };
  443. MixMaterial.prototype.needAlphaTesting = function () {
  444. return false;
  445. };
  446. MixMaterial.prototype.getAlphaTestTexture = function () {
  447. return null;
  448. };
  449. // Methods
  450. MixMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  451. if (this.isFrozen) {
  452. if (this._wasPreviouslyReady && subMesh.effect) {
  453. return true;
  454. }
  455. }
  456. if (!subMesh._materialDefines) {
  457. subMesh._materialDefines = new MixMaterialDefines();
  458. }
  459. var defines = subMesh._materialDefines;
  460. var scene = this.getScene();
  461. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  462. if (this._renderId === scene.getRenderId()) {
  463. return true;
  464. }
  465. }
  466. var engine = scene.getEngine();
  467. // Textures
  468. if (scene.texturesEnabled) {
  469. if (!this._mixTexture1 || !this._mixTexture1.isReady()) {
  470. return false;
  471. }
  472. defines._needUVs = true;
  473. if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
  474. if (!this._diffuseTexture1 || !this._diffuseTexture1.isReady()) {
  475. return false;
  476. }
  477. defines.DIFFUSE = true;
  478. if (!this._diffuseTexture2 || !this._diffuseTexture2.isReady()) {
  479. return false;
  480. }
  481. if (!this._diffuseTexture3 || !this._diffuseTexture3.isReady()) {
  482. return false;
  483. }
  484. if (!this._diffuseTexture4 || !this._diffuseTexture4.isReady()) {
  485. return false;
  486. }
  487. if (this._mixTexture2) {
  488. if (!this._mixTexture2.isReady()) {
  489. return false;
  490. }
  491. defines.MIXMAP2 = true;
  492. if (!this._diffuseTexture5 || !this._diffuseTexture5.isReady()) {
  493. return false;
  494. }
  495. if (!this._diffuseTexture6 || !this._diffuseTexture6.isReady()) {
  496. return false;
  497. }
  498. if (!this._diffuseTexture7 || !this._diffuseTexture7.isReady()) {
  499. return false;
  500. }
  501. if (!this._diffuseTexture8 || !this._diffuseTexture8.isReady()) {
  502. return false;
  503. }
  504. }
  505. }
  506. }
  507. // Misc.
  508. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  509. // Lights
  510. defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  511. // Values that need to be evaluated on every frame
  512. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  513. // Attribs
  514. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
  515. // Get correct effect
  516. if (defines.isDirty) {
  517. defines.markAsProcessed();
  518. scene.resetCachedMaterial();
  519. // Fallbacks
  520. var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
  521. if (defines.FOG) {
  522. fallbacks.addFallback(1, "FOG");
  523. }
  524. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  525. if (defines.NUM_BONE_INFLUENCERS > 0) {
  526. fallbacks.addCPUSkinningFallback(0, mesh);
  527. }
  528. //Attributes
  529. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  530. if (defines.NORMAL) {
  531. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  532. }
  533. if (defines.UV1) {
  534. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  535. }
  536. if (defines.UV2) {
  537. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  538. }
  539. if (defines.VERTEXCOLOR) {
  540. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  541. }
  542. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  543. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  544. // Legacy browser patch
  545. var shaderName = "mix";
  546. var join = defines.toString();
  547. var uniforms = [
  548. "world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  549. "vFogInfos", "vFogColor", "pointSize",
  550. "vTextureInfos",
  551. "mBones",
  552. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMatrix",
  553. "diffuse1Infos", "diffuse2Infos", "diffuse3Infos", "diffuse4Infos",
  554. "diffuse5Infos", "diffuse6Infos", "diffuse7Infos", "diffuse8Infos"
  555. ];
  556. var samplers = [
  557. "mixMap1Sampler", "mixMap2Sampler",
  558. "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "diffuse4Sampler",
  559. "diffuse5Sampler", "diffuse6Sampler", "diffuse7Sampler", "diffuse8Sampler"
  560. ];
  561. var uniformBuffers = new Array();
  562. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  563. uniformsNames: uniforms,
  564. uniformBuffersNames: uniformBuffers,
  565. samplers: samplers,
  566. defines: defines,
  567. maxSimultaneousLights: this.maxSimultaneousLights
  568. });
  569. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  570. attributes: attribs,
  571. uniformsNames: uniforms,
  572. uniformBuffersNames: uniformBuffers,
  573. samplers: samplers,
  574. defines: join,
  575. fallbacks: fallbacks,
  576. onCompiled: this.onCompiled,
  577. onError: this.onError,
  578. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  579. }, engine), defines);
  580. }
  581. if (!subMesh.effect || !subMesh.effect.isReady()) {
  582. return false;
  583. }
  584. this._renderId = scene.getRenderId();
  585. this._wasPreviouslyReady = true;
  586. return true;
  587. };
  588. MixMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  589. var scene = this.getScene();
  590. var defines = subMesh._materialDefines;
  591. if (!defines) {
  592. return;
  593. }
  594. var effect = subMesh.effect;
  595. if (!effect) {
  596. return;
  597. }
  598. this._activeEffect = effect;
  599. // Matrices
  600. this.bindOnlyWorldMatrix(world);
  601. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  602. // Bones
  603. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  604. if (this._mustRebind(scene, effect)) {
  605. // Textures
  606. if (this._mixTexture1) {
  607. this._activeEffect.setTexture("mixMap1Sampler", this._mixTexture1);
  608. this._activeEffect.setFloat2("vTextureInfos", this._mixTexture1.coordinatesIndex, this._mixTexture1.level);
  609. this._activeEffect.setMatrix("textureMatrix", this._mixTexture1.getTextureMatrix());
  610. if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
  611. if (this._diffuseTexture1) {
  612. this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
  613. this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
  614. }
  615. if (this._diffuseTexture2) {
  616. this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
  617. this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
  618. }
  619. if (this._diffuseTexture3) {
  620. this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
  621. this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
  622. }
  623. if (this._diffuseTexture4) {
  624. this._activeEffect.setTexture("diffuse4Sampler", this._diffuseTexture4);
  625. this._activeEffect.setFloat2("diffuse4Infos", this._diffuseTexture4.uScale, this._diffuseTexture4.vScale);
  626. }
  627. }
  628. }
  629. if (this._mixTexture2) {
  630. this._activeEffect.setTexture("mixMap2Sampler", this._mixTexture2);
  631. if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
  632. if (this._diffuseTexture5) {
  633. this._activeEffect.setTexture("diffuse5Sampler", this._diffuseTexture5);
  634. this._activeEffect.setFloat2("diffuse5Infos", this._diffuseTexture5.uScale, this._diffuseTexture5.vScale);
  635. }
  636. if (this._diffuseTexture6) {
  637. this._activeEffect.setTexture("diffuse6Sampler", this._diffuseTexture6);
  638. this._activeEffect.setFloat2("diffuse6Infos", this._diffuseTexture6.uScale, this._diffuseTexture6.vScale);
  639. }
  640. if (this._diffuseTexture7) {
  641. this._activeEffect.setTexture("diffuse7Sampler", this._diffuseTexture7);
  642. this._activeEffect.setFloat2("diffuse7Infos", this._diffuseTexture7.uScale, this._diffuseTexture7.vScale);
  643. }
  644. if (this._diffuseTexture8) {
  645. this._activeEffect.setTexture("diffuse8Sampler", this._diffuseTexture8);
  646. this._activeEffect.setFloat2("diffuse8Infos", this._diffuseTexture8.uScale, this._diffuseTexture8.vScale);
  647. }
  648. }
  649. }
  650. // Clip plane
  651. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  652. // Point size
  653. if (this.pointsCloud) {
  654. this._activeEffect.setFloat("pointSize", this.pointSize);
  655. }
  656. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindEyePosition(effect, scene);
  657. }
  658. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  659. if (defines.SPECULARTERM) {
  660. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  661. }
  662. if (scene.lightsEnabled && !this.disableLighting) {
  663. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  664. }
  665. // View
  666. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  667. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  668. }
  669. // Fog
  670. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
  671. this._afterBind(mesh, this._activeEffect);
  672. };
  673. MixMaterial.prototype.getAnimatables = function () {
  674. var results = [];
  675. if (this._mixTexture1 && this._mixTexture1.animations && this._mixTexture1.animations.length > 0) {
  676. results.push(this._mixTexture1);
  677. }
  678. if (this._mixTexture2 && this._mixTexture2.animations && this._mixTexture2.animations.length > 0) {
  679. results.push(this._mixTexture2);
  680. }
  681. return results;
  682. };
  683. MixMaterial.prototype.getActiveTextures = function () {
  684. var activeTextures = _super.prototype.getActiveTextures.call(this);
  685. // Mix map 1
  686. if (this._mixTexture1) {
  687. activeTextures.push(this._mixTexture1);
  688. }
  689. if (this._diffuseTexture1) {
  690. activeTextures.push(this._diffuseTexture1);
  691. }
  692. if (this._diffuseTexture2) {
  693. activeTextures.push(this._diffuseTexture2);
  694. }
  695. if (this._diffuseTexture3) {
  696. activeTextures.push(this._diffuseTexture3);
  697. }
  698. if (this._diffuseTexture4) {
  699. activeTextures.push(this._diffuseTexture4);
  700. }
  701. // Mix map 2
  702. if (this._mixTexture2) {
  703. activeTextures.push(this._mixTexture2);
  704. }
  705. if (this._diffuseTexture5) {
  706. activeTextures.push(this._diffuseTexture5);
  707. }
  708. if (this._diffuseTexture6) {
  709. activeTextures.push(this._diffuseTexture6);
  710. }
  711. if (this._diffuseTexture7) {
  712. activeTextures.push(this._diffuseTexture7);
  713. }
  714. if (this._diffuseTexture8) {
  715. activeTextures.push(this._diffuseTexture8);
  716. }
  717. return activeTextures;
  718. };
  719. MixMaterial.prototype.hasTexture = function (texture) {
  720. if (_super.prototype.hasTexture.call(this, texture)) {
  721. return true;
  722. }
  723. // Mix map 1
  724. if (this._mixTexture1 === texture) {
  725. return true;
  726. }
  727. if (this._diffuseTexture1 === texture) {
  728. return true;
  729. }
  730. if (this._diffuseTexture2 === texture) {
  731. return true;
  732. }
  733. if (this._diffuseTexture3 === texture) {
  734. return true;
  735. }
  736. if (this._diffuseTexture4 === texture) {
  737. return true;
  738. }
  739. // Mix map 2
  740. if (this._mixTexture2 === texture) {
  741. return true;
  742. }
  743. if (this._diffuseTexture5 === texture) {
  744. return true;
  745. }
  746. if (this._diffuseTexture6 === texture) {
  747. return true;
  748. }
  749. if (this._diffuseTexture7 === texture) {
  750. return true;
  751. }
  752. if (this._diffuseTexture8 === texture) {
  753. return true;
  754. }
  755. return false;
  756. };
  757. MixMaterial.prototype.dispose = function (forceDisposeEffect) {
  758. if (this._mixTexture1) {
  759. this._mixTexture1.dispose();
  760. }
  761. _super.prototype.dispose.call(this, forceDisposeEffect);
  762. };
  763. MixMaterial.prototype.clone = function (name) {
  764. var _this = this;
  765. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new MixMaterial(name, _this.getScene()); }, this);
  766. };
  767. MixMaterial.prototype.serialize = function () {
  768. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  769. serializationObject.customType = "BABYLON.MixMaterial";
  770. return serializationObject;
  771. };
  772. MixMaterial.prototype.getClassName = function () {
  773. return "MixMaterial";
  774. };
  775. // Statics
  776. MixMaterial.Parse = function (source, scene, rootUrl) {
  777. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new MixMaterial(source.name, scene); }, source, scene, rootUrl);
  778. };
  779. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  780. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("mixTexture1")
  781. ], MixMaterial.prototype, "_mixTexture1", void 0);
  782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  783. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  784. ], MixMaterial.prototype, "mixTexture1", void 0);
  785. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  786. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("mixTexture2")
  787. ], MixMaterial.prototype, "_mixTexture2", void 0);
  788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  789. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  790. ], MixMaterial.prototype, "mixTexture2", void 0);
  791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  792. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture1")
  793. ], MixMaterial.prototype, "_diffuseTexture1", void 0);
  794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  795. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  796. ], MixMaterial.prototype, "diffuseTexture1", void 0);
  797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  798. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture2")
  799. ], MixMaterial.prototype, "_diffuseTexture2", void 0);
  800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  801. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  802. ], MixMaterial.prototype, "diffuseTexture2", void 0);
  803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  804. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture3")
  805. ], MixMaterial.prototype, "_diffuseTexture3", void 0);
  806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  807. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  808. ], MixMaterial.prototype, "diffuseTexture3", void 0);
  809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  810. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture4")
  811. ], MixMaterial.prototype, "_diffuseTexture4", void 0);
  812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  813. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  814. ], MixMaterial.prototype, "diffuseTexture4", void 0);
  815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  816. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture1")
  817. ], MixMaterial.prototype, "_diffuseTexture5", void 0);
  818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  819. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  820. ], MixMaterial.prototype, "diffuseTexture5", void 0);
  821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  822. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture2")
  823. ], MixMaterial.prototype, "_diffuseTexture6", void 0);
  824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  825. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  826. ], MixMaterial.prototype, "diffuseTexture6", void 0);
  827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  828. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture3")
  829. ], MixMaterial.prototype, "_diffuseTexture7", void 0);
  830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  831. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  832. ], MixMaterial.prototype, "diffuseTexture7", void 0);
  833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  834. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture4")
  835. ], MixMaterial.prototype, "_diffuseTexture8", void 0);
  836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  837. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  838. ], MixMaterial.prototype, "diffuseTexture8", void 0);
  839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  840. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  841. ], MixMaterial.prototype, "diffuseColor", void 0);
  842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  843. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  844. ], MixMaterial.prototype, "specularColor", void 0);
  845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  846. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  847. ], MixMaterial.prototype, "specularPower", void 0);
  848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  849. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  850. ], MixMaterial.prototype, "_disableLighting", void 0);
  851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  852. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  853. ], MixMaterial.prototype, "disableLighting", void 0);
  854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  855. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  856. ], MixMaterial.prototype, "_maxSimultaneousLights", void 0);
  857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  858. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  859. ], MixMaterial.prototype, "maxSimultaneousLights", void 0);
  860. return MixMaterial;
  861. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  862. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.MixMaterial"] = MixMaterial;
  863. /***/ }),
  864. /***/ "babylonjs/Misc/decorators":
  865. /*!****************************************************************************************************!*\
  866. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  867. \****************************************************************************************************/
  868. /*! no static exports found */
  869. /***/ (function(module, exports) {
  870. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_decorators__;
  871. /***/ })
  872. /******/ });
  873. });
  874. //# sourceMappingURL=babylon.mixMaterial.js.map