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(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.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 s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));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 s}),r.d(e,"a",function(){return i});
- /*! *****************************************************************************
- 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 s(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,r,n){var s,i=arguments.length,o=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(i<3?s(o):i>3?s(e,r,o):s(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o}},17:function(t,e,r){"use strict";r.r(e);var n=r(1),s=r(0),i=function(){},o=function(){},a=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.CustomParts=new o,n.customShaderNameResolve=n.Builder,n.FragmentShader=s.Effect.ShadersStore.defaultPixelShader,n.VertexShader=s.Effect.ShadersStore.defaultVertexShader,n}return Object(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,i,o){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",i);var _=this._afterBind.bind(this);return this._afterBind=function(t,e){if(e){a.AttachAfterBind(t,e);try{_(t,e)}catch(e){}}},s.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:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),s.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_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog?this.CustomParts.Fragment_Before_Fog:"").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_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_MainEnd=function(t){return this.CustomParts.Vertex_MainEnd=t,this},e.ShaderIndexer=1,e}(s.StandardMaterial);s._TypeStore.RegisteredTypes["BABYLON.CustomMaterial"]=a;var u=function(){},_=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.CustomParts=new u,n.customShaderNameResolve=n.Builder,n.FragmentShader=s.Effect.ShadersStore.pbrPixelShader,n.VertexShader=s.Effect.ShadersStore.pbrVertexShader,n}return Object(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,i,o){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",i);var _=this._afterBind.bind(this);return this._afterBind=function(t,e){if(e){a.AttachAfterBind(t,e);try{_(t,e)}catch(e){}}},s.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:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),s.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_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_FOG",this.CustomParts.Fragment_Before_Fog?this.CustomParts.Fragment_Before_Fog:"").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_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_MainEnd=function(t){return this.CustomParts.Vertex_MainEnd=t,this},e.ShaderIndexer=1,e}(s.PBRMaterial);s._TypeStore.RegisteredTypes["BABYLON.PBRCustomMaterial"]=_,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 _})},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}),r.d(e,"ShaderAlebdoParts",function(){return n.ShaderAlebdoParts}),r.d(e,"PBRCustomMaterial",function(){return n.PBRCustomMaterial});var s=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==s)for(var i in n)s.BABYLON[i]=n[i]}.call(this,r(2))}})});
|