| 12 |
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],n):"object"==typeof exports?exports["babylonjs-materials"]=n(require("babylonjs")):e.MATLIB=n(e.BABYLON)}(window,function(e){return function(e){var n={};function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(i,o,function(n){return e[n]}.bind(null,o));return i},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=1)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),function(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}(t(3))},function(e,n,t){"use strict";(function(e){Object.defineProperty(n,"__esModule",{value:!0});var i=t(0),o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var r in i)o.BABYLON[r]=i[r];!function(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}(t(0))}).call(this,t(2))},function(e,n){var t;t=function(){return this}();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,n,t){"use strict";var i=this&&this.__extends||function(){var e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t])})(n,t)};return function(n,t){function i(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}}(),o=this&&this.__decorate||function(e,n,t,i){var o,r=arguments.length,a=r<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,t):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,n,t,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(n,t,a):o(n,t))||a);return r>3&&a&&Object.defineProperty(n,t,a),a};Object.defineProperty(n,"__esModule",{value:!0});var r=t(4);r.Effect.ShadersStore.gradientPixelShader=t(5),r.Effect.ShadersStore.gradientVertexShader=t(6);var a=function(e){function n(){var n=e.call(this)||this;return n.DIFFUSE=!1,n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.ALPHATEST=!1,n.DEPTHPREPASS=!1,n.POINTSIZE=!1,n.FOG=!1,n.LIGHT0=!1,n.LIGHT1=!1,n.LIGHT2=!1,n.LIGHT3=!1,n.SPOTLIGHT0=!1,n.SPOTLIGHT1=!1,n.SPOTLIGHT2=!1,n.SPOTLIGHT3=!1,n.HEMILIGHT0=!1,n.HEMILIGHT1=!1,n.HEMILIGHT2=!1,n.HEMILIGHT3=!1,n.DIRLIGHT0=!1,n.DIRLIGHT1=!1,n.DIRLIGHT2=!1,n.DIRLIGHT3=!1,n.POINTLIGHT0=!1,n.POINTLIGHT1=!1,n.POINTLIGHT2=!1,n.POINTLIGHT3=!1,n.SHADOW0=!1,n.SHADOW1=!1,n.SHADOW2=!1,n.SHADOW3=!1,n.SHADOWS=!1,n.SHADOWESM0=!1,n.SHADOWESM1=!1,n.SHADOWESM2=!1,n.SHADOWESM3=!1,n.SHADOWPOISSON0=!1,n.SHADOWPOISSON1=!1,n.SHADOWPOISSON2=!1,n.SHADOWPOISSON3=!1,n.SHADOWPCF0=!1,n.SHADOWPCF1=!1,n.SHADOWPCF2=!1,n.SHADOWPCF3=!1,n.SHADOWPCSS0=!1,n.SHADOWPCSS1=!1,n.SHADOWPCSS2=!1,n.SHADOWPCSS3=!1,n.NORMAL=!1,n.UV1=!1,n.UV2=!1,n.VERTEXCOLOR=!1,n.VERTEXALPHA=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.INSTANCES=!1,n.rebuild(),n}return i(n,e),n}(r.MaterialDefines),s=function(e){function n(n,t){var i=e.call(this,n,t)||this;return i._maxSimultaneousLights=4,i.topColor=new r.Color3(1,0,0),i.topColorAlpha=1,i.bottomColor=new r.Color3(0,0,1),i.bottomColorAlpha=1,i.offset=0,i.scale=1,i.smoothness=1,i.disableLighting=!1,i._scaledDiffuse=new r.Color3,i}return i(n,e),n.prototype.needAlphaBlending=function(){return this.alpha<1||this.topColorAlpha<1||this.bottomColorAlpha<1},n.prototype.needAlphaTesting=function(){return!0},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(e,n,t){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new a);var i=n._materialDefines,o=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===o.getRenderId())return!0;var s=o.getEngine();if(r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,s,i,!!t),r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),i),i._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,i,!1,this._maxSimultaneousLights),r.MaterialHelper.PrepareDefinesForAttributes(e,i,!1,!0),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var l=new r.EffectFallbacks;i.FOG&&l.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(i,l),i.NUM_BONE_INFLUENCERS>0&&l.addCPUSkinningFallback(0,e);var f=[r.VertexBuffer.PositionKind];i.NORMAL&&f.push(r.VertexBuffer.NormalKind),i.UV1&&f.push(r.VertexBuffer.UVKind),i.UV2&&f.push(r.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&f.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(f,e,i,l),r.MaterialHelper.PrepareAttributesForInstances(f,i);var c=i.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","diffuseMatrix","topColor","bottomColor","offset","smoothness","scale"],d=["diffuseSampler"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:p,samplers:d,defines:i,maxSimultaneousLights:4}),n.setEffect(o.getEngine().createEffect("gradient",{attributes:f,uniformsNames:u,uniformBuffersNames:p,samplers:d,defines:c,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},s),i)}return!(!n.effect||!n.effect.isReady())&&(this._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(e,n,t){var i=this.getScene(),o=t._materialDefines;if(o){var a=t.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",i.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(n,a),this._mustRebind(i,a)&&(r.MaterialHelper.BindClipPlane(a,i),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,i)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*n.visibility),i.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(i,n,this._activeEffect,o),i.fogEnabled&&n.applyFog&&i.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",i.getViewMatrix()),r.MaterialHelper.BindFogParameters(i,n,this._activeEffect),this._activeEffect.setColor4("topColor",this.topColor,this.topColorAlpha),this._activeEffect.setColor4("bottomColor",this.bottomColor,this.bottomColorAlpha),this._activeEffect.setFloat("offset",this.offset),this._activeEffect.setFloat("scale",this.scale),this._activeEffect.setFloat("smoothness",this.smoothness),this._afterBind(n,this._activeEffect))}},n.prototype.getAnimatables=function(){return[]},n.prototype.dispose=function(n){e.prototype.dispose.call(this,n)},n.prototype.clone=function(e){var t=this;return r.SerializationHelper.Clone(function(){return new n(e,t.getScene())},this)},n.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.GradientMaterial",e},n.prototype.getClassName=function(){return"GradientMaterial"},n.Parse=function(e,t,i){return r.SerializationHelper.Parse(function(){return new n(e.name,t)},e,t,i)},o([r.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),o([r.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),o([r.serializeAsColor3()],n.prototype,"topColor",void 0),o([r.serialize()],n.prototype,"topColorAlpha",void 0),o([r.serializeAsColor3()],n.prototype,"bottomColor",void 0),o([r.serialize()],n.prototype,"bottomColorAlpha",void 0),o([r.serialize()],n.prototype,"offset",void 0),o([r.serialize()],n.prototype,"scale",void 0),o([r.serialize()],n.prototype,"smoothness",void 0),o([r.serialize()],n.prototype,"disableLighting",void 0),n}(r.PushMaterial);n.GradientMaterial=s},function(n,t){n.exports=e},function(e,n){e.exports="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 topColor;\nuniform vec4 bottomColor;\nuniform float offset;\nuniform float scale;\nuniform float smoothness;\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\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]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\nfloat h=vPosition.y*scale+offset;\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\n\nvec3 diffuseColor=baseColor.rgb;\n\nfloat alpha=baseColor.a;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n"},function(e,n){e.exports="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 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\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);\nvPosition=position;\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 (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n"}])});
- //# sourceMappingURL=babylon.gradientMaterial.min.js.map
|