babylon.triPlanarMaterial.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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-triPlanar.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../Tools/Gulp/node_modules/webpack/buildin/global.js":
  99. /*!************************************************************!*\
  100. !*** ../Tools/Gulp/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-triPlanar.ts":
  122. /*!************************************!*\
  123. !*** ./legacy/legacy-triPlanar.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/triPlanar */ "./src/triPlanar/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/triPlanar */ "./src/triPlanar/index.ts"));
  145. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../Tools/Gulp/node_modules/webpack/buildin/global.js */ "../Tools/Gulp/node_modules/webpack/buildin/global.js")))
  146. /***/ }),
  147. /***/ "./src/triPlanar/index.ts":
  148. /*!********************************!*\
  149. !*** ./src/triPlanar/index.ts ***!
  150. \********************************/
  151. /*! no static exports found */
  152. /***/ (function(module, exports, __webpack_require__) {
  153. "use strict";
  154. function __export(m) {
  155. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  156. }
  157. Object.defineProperty(exports, "__esModule", { value: true });
  158. __export(__webpack_require__(/*! ./triPlanarMaterial */ "./src/triPlanar/triPlanarMaterial.ts"));
  159. /***/ }),
  160. /***/ "./src/triPlanar/triPlanarMaterial.ts":
  161. /*!********************************************!*\
  162. !*** ./src/triPlanar/triPlanarMaterial.ts ***!
  163. \********************************************/
  164. /*! no static exports found */
  165. /***/ (function(module, exports, __webpack_require__) {
  166. "use strict";
  167. var __extends = (this && this.__extends) || (function () {
  168. var extendStatics = function (d, b) {
  169. extendStatics = Object.setPrototypeOf ||
  170. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  171. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  172. return extendStatics(d, b);
  173. }
  174. return function (d, b) {
  175. extendStatics(d, b);
  176. function __() { this.constructor = d; }
  177. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  178. };
  179. })();
  180. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  181. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  182. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  183. 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;
  184. return c > 3 && r && Object.defineProperty(target, key, r), r;
  185. };
  186. Object.defineProperty(exports, "__esModule", { value: true });
  187. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  188. babylonjs_1.Effect.ShadersStore["triPlanarPixelShader"] = __webpack_require__(/*! ./triplanar.fragment.fx */ "./src/triPlanar/triplanar.fragment.fx");
  189. babylonjs_1.Effect.ShadersStore["triPlanarVertexShader"] = __webpack_require__(/*! ./triplanar.vertex.fx */ "./src/triPlanar/triplanar.vertex.fx");
  190. var TriPlanarMaterialDefines = /** @class */ (function (_super) {
  191. __extends(TriPlanarMaterialDefines, _super);
  192. function TriPlanarMaterialDefines() {
  193. var _this = _super.call(this) || this;
  194. _this.DIFFUSEX = false;
  195. _this.DIFFUSEY = false;
  196. _this.DIFFUSEZ = false;
  197. _this.BUMPX = false;
  198. _this.BUMPY = false;
  199. _this.BUMPZ = false;
  200. _this.CLIPPLANE = false;
  201. _this.CLIPPLANE2 = false;
  202. _this.CLIPPLANE3 = false;
  203. _this.CLIPPLANE4 = false;
  204. _this.ALPHATEST = false;
  205. _this.DEPTHPREPASS = false;
  206. _this.POINTSIZE = false;
  207. _this.FOG = false;
  208. _this.SPECULARTERM = false;
  209. _this.NORMAL = false;
  210. _this.VERTEXCOLOR = false;
  211. _this.VERTEXALPHA = false;
  212. _this.NUM_BONE_INFLUENCERS = 0;
  213. _this.BonesPerMesh = 0;
  214. _this.INSTANCES = false;
  215. _this.rebuild();
  216. return _this;
  217. }
  218. return TriPlanarMaterialDefines;
  219. }(babylonjs_1.MaterialDefines));
  220. var TriPlanarMaterial = /** @class */ (function (_super) {
  221. __extends(TriPlanarMaterial, _super);
  222. function TriPlanarMaterial(name, scene) {
  223. var _this = _super.call(this, name, scene) || this;
  224. _this.tileSize = 1;
  225. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  226. _this.specularColor = new babylonjs_1.Color3(0.2, 0.2, 0.2);
  227. _this.specularPower = 64;
  228. _this._disableLighting = false;
  229. _this._maxSimultaneousLights = 4;
  230. return _this;
  231. }
  232. TriPlanarMaterial.prototype.needAlphaBlending = function () {
  233. return (this.alpha < 1.0);
  234. };
  235. TriPlanarMaterial.prototype.needAlphaTesting = function () {
  236. return false;
  237. };
  238. TriPlanarMaterial.prototype.getAlphaTestTexture = function () {
  239. return null;
  240. };
  241. // Methods
  242. TriPlanarMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  243. if (this.isFrozen) {
  244. if (this._wasPreviouslyReady && subMesh.effect) {
  245. return true;
  246. }
  247. }
  248. if (!subMesh._materialDefines) {
  249. subMesh._materialDefines = new TriPlanarMaterialDefines();
  250. }
  251. var defines = subMesh._materialDefines;
  252. var scene = this.getScene();
  253. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  254. if (this._renderId === scene.getRenderId()) {
  255. return true;
  256. }
  257. }
  258. var engine = scene.getEngine();
  259. // Textures
  260. if (defines._areTexturesDirty) {
  261. if (scene.texturesEnabled) {
  262. if (babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  263. var textures = [this.diffuseTextureX, this.diffuseTextureY, this.diffuseTextureZ];
  264. var textureDefines = ["DIFFUSEX", "DIFFUSEY", "DIFFUSEZ"];
  265. for (var i = 0; i < textures.length; i++) {
  266. if (textures[i]) {
  267. if (!textures[i].isReady()) {
  268. return false;
  269. }
  270. else {
  271. defines[textureDefines[i]] = true;
  272. }
  273. }
  274. }
  275. }
  276. if (babylonjs_1.StandardMaterial.BumpTextureEnabled) {
  277. var textures = [this.normalTextureX, this.normalTextureY, this.normalTextureZ];
  278. var textureDefines = ["BUMPX", "BUMPY", "BUMPZ"];
  279. for (var i = 0; i < textures.length; i++) {
  280. if (textures[i]) {
  281. if (!textures[i].isReady()) {
  282. return false;
  283. }
  284. else {
  285. defines[textureDefines[i]] = true;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. // Misc.
  293. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  294. // Lights
  295. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  296. // Values that need to be evaluated on every frame
  297. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  298. // Attribs
  299. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  300. // Get correct effect
  301. if (defines.isDirty) {
  302. defines.markAsProcessed();
  303. scene.resetCachedMaterial();
  304. // Fallbacks
  305. var fallbacks = new babylonjs_1.EffectFallbacks();
  306. if (defines.FOG) {
  307. fallbacks.addFallback(1, "FOG");
  308. }
  309. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  310. if (defines.NUM_BONE_INFLUENCERS > 0) {
  311. fallbacks.addCPUSkinningFallback(0, mesh);
  312. }
  313. //Attributes
  314. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  315. if (defines.NORMAL) {
  316. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  317. }
  318. if (defines.VERTEXCOLOR) {
  319. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  320. }
  321. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  322. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  323. // Legacy browser patch
  324. var shaderName = "triplanar";
  325. var join = defines.toString();
  326. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  327. "vFogInfos", "vFogColor", "pointSize",
  328. "mBones",
  329. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
  330. "tileSize"
  331. ];
  332. var samplers = ["diffuseSamplerX", "diffuseSamplerY", "diffuseSamplerZ",
  333. "normalSamplerX", "normalSamplerY", "normalSamplerZ"
  334. ];
  335. var uniformBuffers = new Array();
  336. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  337. uniformsNames: uniforms,
  338. uniformBuffersNames: uniformBuffers,
  339. samplers: samplers,
  340. defines: defines,
  341. maxSimultaneousLights: this.maxSimultaneousLights
  342. });
  343. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  344. attributes: attribs,
  345. uniformsNames: uniforms,
  346. uniformBuffersNames: uniformBuffers,
  347. samplers: samplers,
  348. defines: join,
  349. fallbacks: fallbacks,
  350. onCompiled: this.onCompiled,
  351. onError: this.onError,
  352. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  353. }, engine), defines);
  354. }
  355. if (!subMesh.effect || !subMesh.effect.isReady()) {
  356. return false;
  357. }
  358. this._renderId = scene.getRenderId();
  359. this._wasPreviouslyReady = true;
  360. return true;
  361. };
  362. TriPlanarMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  363. var scene = this.getScene();
  364. var defines = subMesh._materialDefines;
  365. if (!defines) {
  366. return;
  367. }
  368. var effect = subMesh.effect;
  369. if (!effect) {
  370. return;
  371. }
  372. this._activeEffect = effect;
  373. // Matrices
  374. this.bindOnlyWorldMatrix(world);
  375. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  376. // Bones
  377. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  378. this._activeEffect.setFloat("tileSize", this.tileSize);
  379. if (scene.getCachedMaterial() !== this) {
  380. // Textures
  381. if (this.diffuseTextureX) {
  382. this._activeEffect.setTexture("diffuseSamplerX", this.diffuseTextureX);
  383. }
  384. if (this.diffuseTextureY) {
  385. this._activeEffect.setTexture("diffuseSamplerY", this.diffuseTextureY);
  386. }
  387. if (this.diffuseTextureZ) {
  388. this._activeEffect.setTexture("diffuseSamplerZ", this.diffuseTextureZ);
  389. }
  390. if (this.normalTextureX) {
  391. this._activeEffect.setTexture("normalSamplerX", this.normalTextureX);
  392. }
  393. if (this.normalTextureY) {
  394. this._activeEffect.setTexture("normalSamplerY", this.normalTextureY);
  395. }
  396. if (this.normalTextureZ) {
  397. this._activeEffect.setTexture("normalSamplerZ", this.normalTextureZ);
  398. }
  399. // Clip plane
  400. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  401. // Point size
  402. if (this.pointsCloud) {
  403. this._activeEffect.setFloat("pointSize", this.pointSize);
  404. }
  405. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  406. }
  407. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  408. if (defines.SPECULARTERM) {
  409. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  410. }
  411. if (scene.lightsEnabled && !this.disableLighting) {
  412. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  413. }
  414. // View
  415. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  416. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  417. }
  418. // Fog
  419. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  420. this._afterBind(mesh, this._activeEffect);
  421. };
  422. TriPlanarMaterial.prototype.getAnimatables = function () {
  423. var results = [];
  424. if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
  425. results.push(this.mixTexture);
  426. }
  427. return results;
  428. };
  429. TriPlanarMaterial.prototype.getActiveTextures = function () {
  430. var activeTextures = _super.prototype.getActiveTextures.call(this);
  431. if (this._diffuseTextureX) {
  432. activeTextures.push(this._diffuseTextureX);
  433. }
  434. if (this._diffuseTextureY) {
  435. activeTextures.push(this._diffuseTextureY);
  436. }
  437. if (this._diffuseTextureZ) {
  438. activeTextures.push(this._diffuseTextureZ);
  439. }
  440. if (this._normalTextureX) {
  441. activeTextures.push(this._normalTextureX);
  442. }
  443. if (this._normalTextureY) {
  444. activeTextures.push(this._normalTextureY);
  445. }
  446. if (this._normalTextureZ) {
  447. activeTextures.push(this._normalTextureZ);
  448. }
  449. return activeTextures;
  450. };
  451. TriPlanarMaterial.prototype.hasTexture = function (texture) {
  452. if (_super.prototype.hasTexture.call(this, texture)) {
  453. return true;
  454. }
  455. if (this._diffuseTextureX === texture) {
  456. return true;
  457. }
  458. if (this._diffuseTextureY === texture) {
  459. return true;
  460. }
  461. if (this._diffuseTextureZ === texture) {
  462. return true;
  463. }
  464. if (this._normalTextureX === texture) {
  465. return true;
  466. }
  467. if (this._normalTextureY === texture) {
  468. return true;
  469. }
  470. if (this._normalTextureZ === texture) {
  471. return true;
  472. }
  473. return false;
  474. };
  475. TriPlanarMaterial.prototype.dispose = function (forceDisposeEffect) {
  476. if (this.mixTexture) {
  477. this.mixTexture.dispose();
  478. }
  479. _super.prototype.dispose.call(this, forceDisposeEffect);
  480. };
  481. TriPlanarMaterial.prototype.clone = function (name) {
  482. var _this = this;
  483. return babylonjs_1.SerializationHelper.Clone(function () { return new TriPlanarMaterial(name, _this.getScene()); }, this);
  484. };
  485. TriPlanarMaterial.prototype.serialize = function () {
  486. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  487. serializationObject.customType = "BABYLON.TriPlanarMaterial";
  488. return serializationObject;
  489. };
  490. TriPlanarMaterial.prototype.getClassName = function () {
  491. return "TriPlanarMaterial";
  492. };
  493. // Statics
  494. TriPlanarMaterial.Parse = function (source, scene, rootUrl) {
  495. return babylonjs_1.SerializationHelper.Parse(function () { return new TriPlanarMaterial(source.name, scene); }, source, scene, rootUrl);
  496. };
  497. __decorate([
  498. babylonjs_1.serializeAsTexture()
  499. ], TriPlanarMaterial.prototype, "mixTexture", void 0);
  500. __decorate([
  501. babylonjs_1.serializeAsTexture("diffuseTextureX")
  502. ], TriPlanarMaterial.prototype, "_diffuseTextureX", void 0);
  503. __decorate([
  504. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  505. ], TriPlanarMaterial.prototype, "diffuseTextureX", void 0);
  506. __decorate([
  507. babylonjs_1.serializeAsTexture("diffuseTexturY")
  508. ], TriPlanarMaterial.prototype, "_diffuseTextureY", void 0);
  509. __decorate([
  510. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  511. ], TriPlanarMaterial.prototype, "diffuseTextureY", void 0);
  512. __decorate([
  513. babylonjs_1.serializeAsTexture("diffuseTextureZ")
  514. ], TriPlanarMaterial.prototype, "_diffuseTextureZ", void 0);
  515. __decorate([
  516. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  517. ], TriPlanarMaterial.prototype, "diffuseTextureZ", void 0);
  518. __decorate([
  519. babylonjs_1.serializeAsTexture("normalTextureX")
  520. ], TriPlanarMaterial.prototype, "_normalTextureX", void 0);
  521. __decorate([
  522. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  523. ], TriPlanarMaterial.prototype, "normalTextureX", void 0);
  524. __decorate([
  525. babylonjs_1.serializeAsTexture("normalTextureY")
  526. ], TriPlanarMaterial.prototype, "_normalTextureY", void 0);
  527. __decorate([
  528. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  529. ], TriPlanarMaterial.prototype, "normalTextureY", void 0);
  530. __decorate([
  531. babylonjs_1.serializeAsTexture("normalTextureZ")
  532. ], TriPlanarMaterial.prototype, "_normalTextureZ", void 0);
  533. __decorate([
  534. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  535. ], TriPlanarMaterial.prototype, "normalTextureZ", void 0);
  536. __decorate([
  537. babylonjs_1.serialize()
  538. ], TriPlanarMaterial.prototype, "tileSize", void 0);
  539. __decorate([
  540. babylonjs_1.serializeAsColor3()
  541. ], TriPlanarMaterial.prototype, "diffuseColor", void 0);
  542. __decorate([
  543. babylonjs_1.serializeAsColor3()
  544. ], TriPlanarMaterial.prototype, "specularColor", void 0);
  545. __decorate([
  546. babylonjs_1.serialize()
  547. ], TriPlanarMaterial.prototype, "specularPower", void 0);
  548. __decorate([
  549. babylonjs_1.serialize("disableLighting")
  550. ], TriPlanarMaterial.prototype, "_disableLighting", void 0);
  551. __decorate([
  552. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  553. ], TriPlanarMaterial.prototype, "disableLighting", void 0);
  554. __decorate([
  555. babylonjs_1.serialize("maxSimultaneousLights")
  556. ], TriPlanarMaterial.prototype, "_maxSimultaneousLights", void 0);
  557. __decorate([
  558. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  559. ], TriPlanarMaterial.prototype, "maxSimultaneousLights", void 0);
  560. return TriPlanarMaterial;
  561. }(babylonjs_1.PushMaterial));
  562. exports.TriPlanarMaterial = TriPlanarMaterial;
  563. /***/ }),
  564. /***/ "./src/triPlanar/triplanar.fragment.fx":
  565. /*!*********************************************!*\
  566. !*** ./src/triPlanar/triplanar.fragment.fx ***!
  567. \*********************************************/
  568. /*! no static exports found */
  569. /***/ (function(module, exports) {
  570. module.exports = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=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,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n"
  571. /***/ }),
  572. /***/ "./src/triPlanar/triplanar.vertex.fx":
  573. /*!*******************************************!*\
  574. !*** ./src/triPlanar/triplanar.vertex.fx ***!
  575. \*******************************************/
  576. /*! no static exports found */
  577. /***/ (function(module, exports) {
  578. module.exports = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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 DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\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{\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 DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\n\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,1.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,1.0)).xyz;\nvec3 worldNormal=normalize(cross(worldTangent,worldBinormal));\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\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"
  579. /***/ }),
  580. /***/ "babylonjs":
  581. /*!****************************************************************************************************!*\
  582. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  583. \****************************************************************************************************/
  584. /*! no static exports found */
  585. /***/ (function(module, exports) {
  586. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  587. /***/ })
  588. /******/ });
  589. });
  590. //# sourceMappingURL=babylon.triPlanarMaterial.js.map