!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-materials"]=e(require("babylonjs")):t.MATERIALS=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=21)}({0:function(e,r){e.exports=t},1:function(t,e,r){"use strict";r.d(e,"b",function(){return i}),r.d(e,"a",function(){return o}); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function o(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s}},17:function(t,e,r){"use strict";r.r(e);var n=r(1),i=r(0),o=function(){return function(){}}(),s=function(){return function(){}}(),a=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.CustomParts=new s,n.customShaderNameResolve=n.Builder,n.FragmentShader=i.Effect.ShadersStore.defaultPixelShader,n.VertexShader=i.Effect.ShadersStore.defaultVertexShader,n}return n.b(e,t),e.prototype.AttachAfterBind=function(t,e){for(var r in this._newUniformInstances){"vec2"==(n=r.toString().split("-"))[0]?e.setVector2(n[1],this._newUniformInstances[r]):"vec3"==n[0]?e.setVector3(n[1],this._newUniformInstances[r]):"vec4"==n[0]?e.setVector4(n[1],this._newUniformInstances[r]):"mat4"==n[0]?e.setMatrix(n[1],this._newUniformInstances[r]):"float"==n[0]&&e.setFloat(n[1],this._newUniformInstances[r])}for(var r in this._newSamplerInstances){var n;"sampler2D"==(n=r.toString().split("-"))[0]&&this._newSamplerInstances[r].isReady&&this._newSamplerInstances[r].isReady()&&e.setTexture(n[1],this._newSamplerInstances[r])}},e.prototype.ReviewUniform=function(t,e){if("uniform"==t)for(var r in this._newUniforms)-1==this._customUniform[r].indexOf("sampler")&&e.push(this._newUniforms[r]);if("sampler"==t)for(var r in this._newUniforms)-1!=this._customUniform[r].indexOf("sampler")&&e.push(this._newUniforms[r]);return e},e.prototype.Builder=function(t,r,n,o,s){var a=this;if(this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,e.ShaderIndexer++;var u="custom_"+e.ShaderIndexer;this.ReviewUniform("uniform",r),this.ReviewUniform("sampler",o);var f=this._afterBind.bind(this);return this._afterBind=function(t,e){if(e){a.AttachAfterBind(t,e);try{f(t,e)}catch(e){}}},i.Effect.ShadersStore[u+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:""),i.Effect.ShadersStore[u+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE",this.CustomParts.Fragment_Custom_Diffuse?this.CustomParts.Fragment_Custom_Diffuse:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:""),this._isCreatedShader=!0,this._createdShaderName=u,u},e.prototype.AddUniform=function(t,e,r){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances=new Array,this._newUniformInstances=new Array),r&&(e.indexOf("sampler"),this._newUniformInstances[e+"-"+t]=r),this._customUniform.push("uniform "+e+" "+t+";"),this._newUniforms.push(t),this},e.prototype.Fragment_Begin=function(t){return this.CustomParts.Fragment_Begin=t,this},e.prototype.Fragment_Definitions=function(t){return this.CustomParts.Fragment_Definitions=t,this},e.prototype.Fragment_MainBegin=function(t){return this.CustomParts.Fragment_MainBegin=t,this},e.prototype.Fragment_Custom_Diffuse=function(t){return this.CustomParts.Fragment_Custom_Diffuse=t.replace("result","diffuseColor"),this},e.prototype.Fragment_Custom_Alpha=function(t){return this.CustomParts.Fragment_Custom_Alpha=t.replace("result","alpha"),this},e.prototype.Fragment_Before_FragColor=function(t){return this.CustomParts.Fragment_Before_FragColor=t.replace("result","color"),this},e.prototype.Vertex_Begin=function(t){return this.CustomParts.Vertex_Begin=t,this},e.prototype.Vertex_Definitions=function(t){return this.CustomParts.Vertex_Definitions=t,this},e.prototype.Vertex_MainBegin=function(t){return this.CustomParts.Vertex_MainBegin=t,this},e.prototype.Vertex_Before_PositionUpdated=function(t){return this.CustomParts.Vertex_Before_PositionUpdated=t.replace("result","positionUpdated"),this},e.prototype.Vertex_Before_NormalUpdated=function(t){return this.CustomParts.Vertex_Before_NormalUpdated=t.replace("result","normalUpdated"),this},e.ShaderIndexer=1,e}(i.StandardMaterial);i._TypeStore.RegisteredTypes["BABYLON.CustomMaterial"]=a,r.d(e,"CustomShaderStructure",function(){return o}),r.d(e,"ShaderSpecialParts",function(){return s}),r.d(e,"CustomMaterial",function(){return a})},2:function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},21:function(t,e,r){"use strict";r.r(e),function(t){var n=r(17);r.d(e,"CustomShaderStructure",function(){return n.CustomShaderStructure}),r.d(e,"ShaderSpecialParts",function(){return n.ShaderSpecialParts}),r.d(e,"CustomMaterial",function(){return n.CustomMaterial});var i=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==i)for(var o in n)i.BABYLON[o]=n[o]}.call(this,r(2))}})});