12345678910111213141516 |
- !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(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,s){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},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 s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(s,n,function(e){return t[e]}.bind(null,n));return s},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 n})),r.d(e,"a",(function(){return i}));
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation.
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
- ***************************************************************************** */
- var s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function n(t,e){function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,r,s){var n,i=arguments.length,o=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(i<3?n(o):i>3?n(e,r,o):n(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o}Object.create;Object.create},17:function(t,e,r){"use strict";r.r(e),r.d(e,"CustomShaderStructure",(function(){return i})),r.d(e,"ShaderSpecialParts",(function(){return o})),r.d(e,"CustomMaterial",(function(){return a})),r.d(e,"ShaderAlebdoParts",(function(){return u})),r.d(e,"PBRCustomMaterial",(function(){return _}));var s=r(1),n=r(0),i=function(){},o=function(){},a=function(t){function e(e,r){var s=t.call(this,e,r)||this;return s.CustomParts=new o,s.customShaderNameResolve=s.Builder,s.FragmentShader=n.Effect.ShadersStore.defaultPixelShader,s.VertexShader=n.Effect.ShadersStore.defaultVertexShader,s}return Object(s.b)(e,t),e.prototype.AttachAfterBind=function(t,e){if(this._newUniformInstances)for(var r in this._newUniformInstances){"vec2"==(s=r.toString().split("-"))[0]?e.setVector2(s[1],this._newUniformInstances[r]):"vec3"==s[0]?e.setVector3(s[1],this._newUniformInstances[r]):"vec4"==s[0]?e.setVector4(s[1],this._newUniformInstances[r]):"mat4"==s[0]?e.setMatrix(s[1],this._newUniformInstances[r]):"float"==s[0]&&e.setFloat(s[1],this._newUniformInstances[r])}if(this._newSamplerInstances)for(var r in this._newSamplerInstances){var s;"sampler2D"==(s=r.toString().split("-"))[0]&&this._newSamplerInstances[r].isReady&&this._newSamplerInstances[r].isReady()&&e.setTexture(s[1],this._newSamplerInstances[r])}},e.prototype.ReviewUniform=function(t,e){if("uniform"==t&&this._newUniforms)for(var r=0;r<this._newUniforms.length;r++)-1==this._customUniform[r].indexOf("sampler")&&e.push(this._newUniforms[r]);if("sampler"==t&&this._newUniforms)for(r=0;r<this._newUniforms.length;r++)-1!=this._customUniform[r].indexOf("sampler")&&e.push(this._newUniforms[r]);return e},e.prototype.Builder=function(t,r,s,i,o,a){var u=this;if(a&&this._customAttributes&&this._customAttributes.length>0&&a.push.apply(a,this._customAttributes),this.ReviewUniform("uniform",r),this.ReviewUniform("sampler",i),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,e.ShaderIndexer++;var _="custom_"+e.ShaderIndexer,f=this._afterBind.bind(this);return this._afterBind=function(t,e){if(e){u.AttachAfterBind(t,e);try{f(t,e)}catch(e){}}},n.Effect.ShadersStore[_+"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:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(n.Effect.ShadersStore[_+"VertexShader"]=n.Effect.ShadersStore[_+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),n.Effect.ShadersStore[_+"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_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:""),this.CustomParts.Fragment_Before_Fog&&(n.Effect.ShadersStore[_+"PixelShader"]=n.Effect.ShadersStore[_+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=_,_},e.prototype.AddUniform=function(t,e,r){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),r&&(-1!=e.indexOf("sampler")?this._newSamplerInstances[e+"-"+t]=r:this._newUniformInstances[e+"-"+t]=r),this._customUniform.push("uniform "+e+" "+t+";"),this._newUniforms.push(t),this},e.prototype.AddAttribute=function(t){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.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_Lights=function(t){return this.CustomParts.Fragment_Before_Lights=t,this},e.prototype.Fragment_Before_Fog=function(t){return this.CustomParts.Fragment_Before_Fog=t,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.prototype.Vertex_After_WorldPosComputed=function(t){return this.CustomParts.Vertex_After_WorldPosComputed=t,this},e.prototype.Vertex_MainEnd=function(t){return this.CustomParts.Vertex_MainEnd=t,this},e.ShaderIndexer=1,e}(n.StandardMaterial);n._TypeStore.RegisteredTypes["BABYLON.CustomMaterial"]=a;var u=function(){},_=function(t){function e(e,r){var s=t.call(this,e,r)||this;return s.CustomParts=new u,s.customShaderNameResolve=s.Builder,s.FragmentShader=n.Effect.ShadersStore.pbrPixelShader,s.VertexShader=n.Effect.ShadersStore.pbrVertexShader,s.FragmentShader=s.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g,n.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),s.FragmentShader=s.FragmentShader.replace(/#include<pbrBlockReflectivity>/g,n.Effect.IncludesShadersStore.pbrBlockReflectivity),s.FragmentShader=s.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g,n.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),s}return Object(s.b)(e,t),e.prototype.AttachAfterBind=function(t,e){if(this._newUniformInstances)for(var r in this._newUniformInstances){"vec2"==(s=r.toString().split("-"))[0]?e.setVector2(s[1],this._newUniformInstances[r]):"vec3"==s[0]?e.setVector3(s[1],this._newUniformInstances[r]):"vec4"==s[0]?e.setVector4(s[1],this._newUniformInstances[r]):"mat4"==s[0]?e.setMatrix(s[1],this._newUniformInstances[r]):"float"==s[0]&&e.setFloat(s[1],this._newUniformInstances[r])}if(this._newSamplerInstances)for(var r in this._newSamplerInstances){var s;"sampler2D"==(s=r.toString().split("-"))[0]&&this._newSamplerInstances[r].isReady&&this._newSamplerInstances[r].isReady()&&e.setTexture(s[1],this._newSamplerInstances[r])}},e.prototype.ReviewUniform=function(t,e){if("uniform"==t&&this._newUniforms)for(var r=0;r<this._newUniforms.length;r++)-1==this._customUniform[r].indexOf("sampler")&&e.push(this._newUniforms[r]);if("sampler"==t&&this._newUniforms)for(r=0;r<this._newUniforms.length;r++)-1!=this._customUniform[r].indexOf("sampler")&&e.push(this._newUniforms[r]);return e},e.prototype.Builder=function(t,r,s,i,o,a){var u=this;if(a&&this._customAttributes&&this._customAttributes.length>0&&a.push.apply(a,this._customAttributes),this.ReviewUniform("uniform",r),this.ReviewUniform("sampler",i),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,e.ShaderIndexer++;var _="custom_"+e.ShaderIndexer,f=this._afterBind.bind(this);return this._afterBind=function(t,e){if(e){u.AttachAfterBind(t,e);try{f(t,e)}catch(e){}}},n.Effect.ShadersStore[_+"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:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(n.Effect.ShadersStore[_+"VertexShader"]=n.Effect.ShadersStore[_+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),n.Effect.ShadersStore[_+"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_ALBEDO",this.CustomParts.Fragment_Custom_Albedo?this.CustomParts.Fragment_Custom_Albedo:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS",this.CustomParts.Fragment_Custom_MetallicRoughness?this.CustomParts.Fragment_Custom_MetallicRoughness:"").replace("#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE",this.CustomParts.Fragment_Custom_MicroSurface?this.CustomParts.Fragment_Custom_MicroSurface:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:""),this.CustomParts.Fragment_Before_Fog&&(n.Effect.ShadersStore[_+"PixelShader"]=n.Effect.ShadersStore[_+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=_,_},e.prototype.AddUniform=function(t,e,r){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),r&&(-1!=e.indexOf("sampler")?this._newSamplerInstances[e+"-"+t]=r:this._newUniformInstances[e+"-"+t]=r),this._customUniform.push("uniform "+e+" "+t+";"),this._newUniforms.push(t),this},e.prototype.AddAttribute=function(t){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.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_Albedo=function(t){return this.CustomParts.Fragment_Custom_Albedo=t.replace("result","surfaceAlbedo"),this},e.prototype.Fragment_Custom_Alpha=function(t){return this.CustomParts.Fragment_Custom_Alpha=t.replace("result","alpha"),this},e.prototype.Fragment_Before_Lights=function(t){return this.CustomParts.Fragment_Before_Lights=t,this},e.prototype.Fragment_Custom_MetallicRoughness=function(t){return this.CustomParts.Fragment_Custom_MetallicRoughness=t,this},e.prototype.Fragment_Custom_MicroSurface=function(t){return this.CustomParts.Fragment_Custom_MicroSurface=t,this},e.prototype.Fragment_Before_Fog=function(t){return this.CustomParts.Fragment_Before_Fog=t,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.prototype.Vertex_After_WorldPosComputed=function(t){return this.CustomParts.Vertex_After_WorldPosComputed=t,this},e.prototype.Vertex_MainEnd=function(t){return this.CustomParts.Vertex_MainEnd=t,this},e.ShaderIndexer=1,e}(n.PBRMaterial);n._TypeStore.RegisteredTypes["BABYLON.PBRCustomMaterial"]=_},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 s=r(17);r.d(e,"CustomShaderStructure",(function(){return s.CustomShaderStructure})),r.d(e,"ShaderSpecialParts",(function(){return s.ShaderSpecialParts})),r.d(e,"CustomMaterial",(function(){return s.CustomMaterial})),r.d(e,"ShaderAlebdoParts",(function(){return s.ShaderAlebdoParts})),r.d(e,"PBRCustomMaterial",(function(){return s.PBRCustomMaterial}));var n=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==n)for(var i in s)n.BABYLON[i]=s[i]}.call(this,r(2))}})}));
|