12345678910111213141516 |
- !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-procedural-textures",["babylonjs"],o):"object"==typeof exports?exports["babylonjs-procedural-textures"]=o(require("babylonjs")):e.PROCEDURALTEXTURES=o(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var o={};function t(r){if(o[r])return o[r].exports;var n=o[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=o,t.d=function(e,o,r){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:r})},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,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)t.d(r,n,function(o){return e[o]}.bind(null,n));return r},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="",t(t.s=16)}({0:function(o,t){o.exports=e},1:function(e,o,t){"use strict";t.d(o,"b",function(){return n}),t.d(o,"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 r=function(e,o){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var t in o)o.hasOwnProperty(t)&&(e[t]=o[t])})(e,o)};function n(e,o){function t(){this.constructor=e}r(e,o),e.prototype=null===o?Object.create(o):(t.prototype=o.prototype,new t)}function i(e,o,t,r){var n,i=arguments.length,u=i<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,o,t,r);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(u=(i<3?n(u):i>3?n(o,t,u):n(o,t))||u);return i>3&&u&&Object.defineProperty(o,t,u),u}},16:function(e,o,t){"use strict";t.r(o),function(e){var r=t(4);t.d(o,"CloudProceduralTexture",function(){return r.CloudProceduralTexture});var n=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==n)for(var i in r)n.BABYLON[i]=r[i]}.call(this,t(2))},2:function(e,o){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},4:function(e,o,t){"use strict";t.r(o);var r=t(1),n=t(0),i="precision highp float;\nvarying vec2 vUV;\nuniform vec4 skyColor;\nuniform vec4 cloudColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main() {\nvec2 p=vUV*12.0;\nvec4 c=mix(skyColor,cloudColor,fbm(p));\ngl_FragColor=c;\n}\n";n.Effect.ShadersStore.cloudProceduralTexturePixelShader=i;var u=function(e){function o(o,t,r,i,u){var l=e.call(this,o,t,"cloudProceduralTexture",r,i,u)||this;return l._skyColor=new n.Color4(.15,.68,1,1),l._cloudColor=new n.Color4(1,1,1,1),l.updateShaderUniforms(),l}return Object(r.b)(o,e),o.prototype.updateShaderUniforms=function(){this.setColor4("skyColor",this._skyColor),this.setColor4("cloudColor",this._cloudColor)},Object.defineProperty(o.prototype,"skyColor",{get:function(){return this._skyColor},set:function(e){this._skyColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"cloudColor",{get:function(){return this._cloudColor},set:function(e){this._cloudColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),o.prototype.serialize=function(){var o=n.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return o.customType="BABYLON.CloudProceduralTexture",o},o.Parse=function(e,t,r){return n.SerializationHelper.Parse(function(){return new o(e.name,e._size,t,void 0,e._generateMipMaps)},e,t,r)},Object(r.a)([Object(n.serializeAsColor4)()],o.prototype,"skyColor",null),Object(r.a)([Object(n.serializeAsColor4)()],o.prototype,"cloudColor",null),o}(n.ProceduralTexture);n._TypeStore.RegisteredTypes["BABYLON.CloudProceduralTexture"]=u,t.d(o,"CloudProceduralTexture",function(){return u})}})});
|