123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("babylonjs"));
- else if(typeof define === 'function' && define.amd)
- define("babylonjs-procedural-textures", ["babylonjs"], factory);
- else if(typeof exports === 'object')
- exports["babylonjs-procedural-textures"] = factory(require("babylonjs"));
- else
- root["PROCEDURALTEXTURESLIB"] = factory(root["BABYLON"]);
- })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy-starfield.ts");
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ "../Tools/Gulp/node_modules/webpack/buildin/global.js":
- /*!************************************************************!*\
- !*** ../Tools/Gulp/node_modules/webpack/buildin/global.js ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- var g;
- // This works in non-strict mode
- g = (function() {
- return this;
- })();
- try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1, eval)("this");
- } catch (e) {
- // This works if the window reference is available
- if (typeof window === "object") g = window;
- }
- // g can still be undefined, but nothing to do about it...
- // We return undefined, instead of nothing here, so it's
- // easier to handle this case. if(!global) { ...}
- module.exports = g;
- /***/ }),
- /***/ "./legacy/legacy-starfield.ts":
- /*!************************************!*\
- !*** ./legacy/legacy-starfield.ts ***!
- \************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {
- function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- var proceduralTexture = __webpack_require__(/*! ../src/starfield */ "./src/starfield/index.ts");
- /**
- * This is the entry point for the UMD module.
- * The entry point for a future ESM package should be index.ts
- */
- var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
- if (typeof globalObject !== "undefined") {
- for (var key in proceduralTexture) {
- globalObject.BABYLON[key] = proceduralTexture[key];
- }
- }
- __export(__webpack_require__(/*! ../src/starfield */ "./src/starfield/index.ts"));
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../Tools/Gulp/node_modules/webpack/buildin/global.js */ "../Tools/Gulp/node_modules/webpack/buildin/global.js")))
- /***/ }),
- /***/ "./src/starfield/index.ts":
- /*!********************************!*\
- !*** ./src/starfield/index.ts ***!
- \********************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./starfieldProceduralTexture */ "./src/starfield/starfieldProceduralTexture.ts"));
- /***/ }),
- /***/ "./src/starfield/starfieldProceduralTexture.fragment.fx":
- /*!**************************************************************!*\
- !*** ./src/starfield/starfieldProceduralTexture.fragment.fx ***!
- \**************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = "precision highp float;\n\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float time;\nuniform float alpha;\nuniform float beta;\nuniform float zoom;\nuniform float formuparam;\nuniform float stepsize;\nuniform float tile;\nuniform float brightness;\nuniform float darkmatter;\nuniform float distfading;\nuniform float saturation;\nvoid main()\n{\nvec3 dir=vec3(vUV*zoom,1.);\nfloat localTime=time*0.0001;\n\nmat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));\nmat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));\ndir.xz*=rot1;\ndir.xy*=rot2;\nvec3 from=vec3(1.,.5,0.5);\nfrom+=vec3(-2.,localTime*2.,localTime);\nfrom.xz*=rot1;\nfrom.xy*=rot2;\n\nfloat s=0.1,fade=1.;\nvec3 v=vec3(0.);\nfor (int r=0; r<volsteps; r++) {\nvec3 p=from+s*dir*.5;\np=abs(vec3(tile)-mod(p,vec3(tile*2.))); \nfloat pa,a=pa=0.;\nfor (int i=0; i<iterations; i++) {\np=abs(p)/dot(p,p)-formuparam; \na+=abs(length(p)-pa); \npa=length(p);\n}\nfloat dm=max(0.,darkmatter-a*a*.001); \na*=a*a; \nif (r>6) fade*=1.-dm; \n\nv+=fade;\nv+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; \nfade*=distfading; \ns+=stepsize;\n}\nv=mix(vec3(length(v)),v,saturation); \ngl_FragColor=vec4(v*.01,1.);\n}"
- /***/ }),
- /***/ "./src/starfield/starfieldProceduralTexture.ts":
- /*!*****************************************************!*\
- !*** ./src/starfield/starfieldProceduralTexture.ts ***!
- \*****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return extendStatics(d, b);
- }
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
- babylonjs_1.Effect.ShadersStore["starfieldProceduralTexturePixelShader"] = __webpack_require__(/*! ./starfieldProceduralTexture.fragment.fx */ "./src/starfield/starfieldProceduralTexture.fragment.fx");
- var StarfieldProceduralTexture = /** @class */ (function (_super) {
- __extends(StarfieldProceduralTexture, _super);
- function StarfieldProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
- var _this = _super.call(this, name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
- _this._time = 1;
- _this._alpha = 0.5;
- _this._beta = 0.8;
- _this._zoom = 0.8;
- _this._formuparam = 0.53;
- _this._stepsize = 0.1;
- _this._tile = 0.850;
- _this._brightness = 0.0015;
- _this._darkmatter = 0.400;
- _this._distfading = 0.730;
- _this._saturation = 0.850;
- _this.updateShaderUniforms();
- return _this;
- }
- StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
- this.setFloat("time", this._time);
- this.setFloat("alpha", this._alpha);
- this.setFloat("beta", this._beta);
- this.setFloat("zoom", this._zoom);
- this.setFloat("formuparam", this._formuparam);
- this.setFloat("stepsize", this._stepsize);
- this.setFloat("tile", this._tile);
- this.setFloat("brightness", this._brightness);
- this.setFloat("darkmatter", this._darkmatter);
- this.setFloat("distfading", this._distfading);
- this.setFloat("saturation", this._saturation);
- };
- Object.defineProperty(StarfieldProceduralTexture.prototype, "time", {
- get: function () {
- return this._time;
- },
- set: function (value) {
- this._time = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "alpha", {
- get: function () {
- return this._alpha;
- },
- set: function (value) {
- this._alpha = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "beta", {
- get: function () {
- return this._beta;
- },
- set: function (value) {
- this._beta = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "formuparam", {
- get: function () {
- return this._formuparam;
- },
- set: function (value) {
- this._formuparam = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "stepsize", {
- get: function () {
- return this._stepsize;
- },
- set: function (value) {
- this._stepsize = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "zoom", {
- get: function () {
- return this._zoom;
- },
- set: function (value) {
- this._zoom = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "tile", {
- get: function () {
- return this._tile;
- },
- set: function (value) {
- this._tile = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
- get: function () {
- return this._brightness;
- },
- set: function (value) {
- this._brightness = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
- get: function () {
- return this._darkmatter;
- },
- set: function (value) {
- this._darkmatter = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
- get: function () {
- return this._distfading;
- },
- set: function (value) {
- this._distfading = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
- get: function () {
- return this._saturation;
- },
- set: function (value) {
- this._saturation = value;
- this.updateShaderUniforms();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Serializes this starfield procedural texture
- * @returns a serialized starfield procedural texture object
- */
- StarfieldProceduralTexture.prototype.serialize = function () {
- var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
- serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
- return serializationObject;
- };
- /**
- * Creates a Starfield Procedural Texture from parsed startfield procedural texture data
- * @param parsedTexture defines parsed texture data
- * @param scene defines the current scene
- * @param rootUrl defines the root URL containing startfield procedural texture information
- * @returns a parsed Starfield Procedural Texture
- */
- StarfieldProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
- var texture = babylonjs_1.SerializationHelper.Parse(function () { return new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
- return texture;
- };
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "time", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "alpha", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "beta", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "formuparam", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "stepsize", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "zoom", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "tile", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "brightness", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "darkmatter", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "distfading", null);
- __decorate([
- babylonjs_1.serialize()
- ], StarfieldProceduralTexture.prototype, "saturation", null);
- return StarfieldProceduralTexture;
- }(babylonjs_1.ProceduralTexture));
- exports.StarfieldProceduralTexture = StarfieldProceduralTexture;
- /***/ }),
- /***/ "babylonjs":
- /*!****************************************************************************************************!*\
- !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
- \****************************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
- /***/ })
- /******/ });
- });
- //# sourceMappingURL=babylon.starfieldProceduralTexture.js.map
|