12345678910111213141516 |
- !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.MATERIALS=n(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var n={};function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.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 r in e)t.d(i,r,function(n){return e[n]}.bind(null,r));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=29)}({0:function(n,t){n.exports=e},1:function(e,n,t){"use strict";t.d(n,"b",(function(){return r})),t.d(n,"a",(function(){return o}));
- /*! *****************************************************************************
- 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 i=function(e,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])})(e,n)};function r(e,n){function t(){this.constructor=e}i(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}function o(e,n,t,i){var r,o=arguments.length,a=o<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 l=e.length-1;l>=0;l--)(r=e[l])&&(a=(o<3?r(a):o>3?r(n,t,a):r(n,t))||a);return o>3&&a&&Object.defineProperty(n,t,a),a}Object.create;Object.create},11:function(e,n,t){"use strict";t.r(n),t.d(n,"ShadowOnlyMaterial",(function(){return s}));var i=t(1),r=t(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform float alpha;\nuniform vec3 shadowColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\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..1]\n\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.shadowOnlyPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\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>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.shadowOnlyVertexShader=a;var l=function(e){function n(){var n=e.call(this)||this;return n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.POINTSIZE=!1,n.FOG=!1,n.NORMAL=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.INSTANCES=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.rebuild(),n}return Object(i.b)(n,e),n}(r.MaterialDefines),s=function(e){function n(n,t){var i=e.call(this,n,t)||this;return i._needAlphaBlending=!0,i.shadowColor=r.Color3.Black(),i}return Object(i.b)(n,e),n.prototype.needAlphaBlending=function(){return this._needAlphaBlending},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(n.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!1,configurable:!0}),n.prototype._getFirstShadowLightForMesh=function(e){for(var n=0,t=e.lightSources;n<t.length;n++){var i=t[n];if(i.shadowEnabled)return i}return null},n.prototype.isReadyForSubMesh=function(e,n,t){var i;if(this.isFrozen&&n.effect&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new l);var o=n._materialDefines,a=this.getScene();if(this._isReadyForSubMesh(n))return!0;var s=a.getEngine();if(this._activeLight)for(var c=0,f=e.lightSources;c<f.length;c++){var u=f[c];if(u.shadowEnabled){if(this._activeLight===u)break;var d=e.lightSources.indexOf(this._activeLight);-1!==d&&(e.lightSources.splice(d,1),e.lightSources.splice(0,0,this._activeLight));break}}r.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,!!t),r.MaterialHelper.PrepareDefinesForMisc(e,a,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),o._needNormals=r.MaterialHelper.PrepareDefinesForLights(a,e,o,!1,1);var p=null===(i=this._getFirstShadowLightForMesh(e))||void 0===i?void 0:i.getShadowGenerator();if(this._needAlphaBlending=!0,p&&p.getClassName&&"CascadedShadowGenerator"===p.getClassName()){var h=p;this._needAlphaBlending=!h.autoCalcDepthBounds}if(r.MaterialHelper.PrepareDefinesForAttributes(e,o,!1,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var v=new r.EffectFallbacks;o.FOG&&v.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(o,v,1),o.NUM_BONE_INFLUENCERS>0&&v.addCPUSkinningFallback(0,e),o.IMAGEPROCESSINGPOSTPROCESS=a.imageProcessingConfiguration.applyByPostProcess;var g=[r.VertexBuffer.PositionKind];o.NORMAL&&g.push(r.VertexBuffer.NormalKind),r.MaterialHelper.PrepareAttributesForBones(g,e,o,v),r.MaterialHelper.PrepareAttributesForInstances(g,o);var m=o.toString(),y=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","shadowColor","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6"],P=new Array,S=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:y,uniformBuffersNames:S,samplers:P,defines:o,maxSimultaneousLights:1}),n.setEffect(a.getEngine().createEffect("shadowOnly",{attributes:g,uniformsNames:y,uniformBuffersNames:S,samplers:P,defines:m,fallbacks:v,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},s),o)}return!(!n.effect||!n.effect.isReady())&&(o._renderId=a.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(e,n,t){var i=this.getScene(),o=t._materialDefines;if(o){var a=t.effect;if(a){if(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",i.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(n,this._activeEffect),this._mustRebind(i,a)&&(r.MaterialHelper.BindClipPlane(this._activeEffect,i),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setColor3("shadowColor",this.shadowColor),r.MaterialHelper.BindEyePosition(a,i)),i.lightsEnabled){r.MaterialHelper.BindLights(i,n,this._activeEffect,o,1);var l=this._getFirstShadowLightForMesh(n);l&&(l._renderId=-1)}(i.fogEnabled&&n.applyFog&&i.fogMode!==r.Scene.FOGMODE_NONE||o.SHADOWCSM0)&&this._activeEffect.setMatrix("view",i.getViewMatrix()),r.MaterialHelper.BindFogParameters(i,n,this._activeEffect),this._afterBind(n,this._activeEffect)}}},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.ShadowOnlyMaterial",e},n.prototype.getClassName=function(){return"ShadowOnlyMaterial"},n.Parse=function(e,t,i){return r.SerializationHelper.Parse((function(){return new n(e.name,t)}),e,t,i)},n}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.ShadowOnlyMaterial"]=s},2:function(e,n){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},29:function(e,n,t){"use strict";t.r(n),function(e){var i=t(11);t.d(n,"ShadowOnlyMaterial",(function(){return i.ShadowOnlyMaterial}));var r=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==r)for(var o in i)r.BABYLON[o]=i[o]}.call(this,t(2))}})}));
|