babylon.skyMaterial.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-materials", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-materials"] = factory(require("babylonjs"));
  8. else
  9. root["MATLIB"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy-sky.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../Tools/Gulp/node_modules/webpack/buildin/global.js":
  99. /*!************************************************************!*\
  100. !*** ../Tools/Gulp/node_modules/webpack/buildin/global.js ***!
  101. \************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || Function("return this")() || (1, eval)("this");
  112. } catch (e) {
  113. // This works if the window reference is available
  114. if (typeof window === "object") g = window;
  115. }
  116. // g can still be undefined, but nothing to do about it...
  117. // We return undefined, instead of nothing here, so it's
  118. // easier to handle this case. if(!global) { ...}
  119. module.exports = g;
  120. /***/ }),
  121. /***/ "./legacy/legacy-sky.ts":
  122. /*!******************************!*\
  123. !*** ./legacy/legacy-sky.ts ***!
  124. \******************************/
  125. /*! no static exports found */
  126. /***/ (function(module, exports, __webpack_require__) {
  127. "use strict";
  128. /* WEBPACK VAR INJECTION */(function(global) {
  129. function __export(m) {
  130. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  131. }
  132. Object.defineProperty(exports, "__esModule", { value: true });
  133. var MatLib = __webpack_require__(/*! ../src/sky */ "./src/sky/index.ts");
  134. /**
  135. * This is the entry point for the UMD module.
  136. * The entry point for a future ESM package should be index.ts
  137. */
  138. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  139. if (typeof globalObject !== "undefined") {
  140. for (var key in MatLib) {
  141. globalObject.BABYLON[key] = MatLib[key];
  142. }
  143. }
  144. __export(__webpack_require__(/*! ../src/sky */ "./src/sky/index.ts"));
  145. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../Tools/Gulp/node_modules/webpack/buildin/global.js */ "../Tools/Gulp/node_modules/webpack/buildin/global.js")))
  146. /***/ }),
  147. /***/ "./src/sky/index.ts":
  148. /*!**************************!*\
  149. !*** ./src/sky/index.ts ***!
  150. \**************************/
  151. /*! no static exports found */
  152. /***/ (function(module, exports, __webpack_require__) {
  153. "use strict";
  154. function __export(m) {
  155. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  156. }
  157. Object.defineProperty(exports, "__esModule", { value: true });
  158. __export(__webpack_require__(/*! ./skyMaterial */ "./src/sky/skyMaterial.ts"));
  159. /***/ }),
  160. /***/ "./src/sky/sky.fragment.fx":
  161. /*!*********************************!*\
  162. !*** ./src/sky/sky.fragment.fx ***!
  163. \*********************************/
  164. /*! no static exports found */
  165. /***/ (function(module, exports) {
  166. module.exports = "precision highp float;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\nuniform vec3 cameraPosition;\nuniform float luminance;\nuniform float turbidity;\nuniform float rayleigh;\nuniform float mieCoefficient;\nuniform float mieDirectionalG;\nuniform vec3 sunPosition;\n\n#include<fogFragmentDeclaration>\n\nconst float e=2.71828182845904523536028747135266249775724709369995957;\nconst float pi=3.141592653589793238462643383279502884197169;\nconst float n=1.0003;\nconst float N=2.545E25;\nconst float pn=0.035;\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\nconst vec3 K=vec3(0.686,0.678,0.666);\nconst float v=4.0;\nconst float rayleighZenithLength=8.4E3;\nconst float mieZenithLength=1.25E3;\nconst vec3 up=vec3(0.0,1.0,0.0);\nconst float EE=1000.0;\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\nconst float cutoffAngle=pi/1.95;\nconst float steepness=1.5;\nvec3 totalRayleigh(vec3 lambda)\n{\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\n}\nvec3 simplifiedRayleigh()\n{\nreturn 0.0005/vec3(94,40,18);\n}\nfloat rayleighPhase(float cosTheta)\n{ \nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\n}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{\nfloat c=(0.2*T )*10E-18;\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\n}\nfloat hgPhase(float cosTheta,float g)\n{\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\n}\nfloat sunIntensity(float zenithAngleCos)\n{\nreturn EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));\n}\nfloat A=0.15;\nfloat B=0.50;\nfloat C=0.10;\nfloat D=0.20;\nfloat EEE=0.02;\nfloat F=0.30;\nfloat W=1000.0;\nvec3 Uncharted2Tonemap(vec3 x)\n{\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\n\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\nvec3 sunDirection=normalize(sunPosition);\nfloat sunE=sunIntensity(dot(sunDirection,up));\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition))));\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\nvec3 betaRTheta=betaR*rPhase;\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\nvec3 betaMTheta=betaM*mPhase;\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\nvec3 direction=normalize(vPositionW-cameraPosition);\nfloat theta=acos(direction.y);\nfloat phi=atan(direction.z,direction.x);\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\nvec3 L0=vec3(0.1)*Fex;\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\nL0+=(sunE*19000.0*Fex)*sundisk;\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\nvec3 texColor=(Lin+L0); \ntexColor*=0.04 ;\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\nfloat g_fMaxLuminance=1.0;\nfloat fLumScaled=0.1/luminance; \nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled); \nfloat ExposureBias=fLumCompressed;\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\n\n\n\nvec3 retColor=curr*whiteScale;\n\n\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n\n#include<fogFragment>\ngl_FragColor=color;\n}\n"
  167. /***/ }),
  168. /***/ "./src/sky/sky.vertex.fx":
  169. /*!*******************************!*\
  170. !*** ./src/sky/sky.vertex.fx ***!
  171. \*******************************/
  172. /*! no static exports found */
  173. /***/ (function(module, exports) {
  174. module.exports = "precision highp float;\n\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nvoid main(void) {\ngl_Position=viewProjection*world*vec4(position,1.0);\nvec4 worldPos=world*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n"
  175. /***/ }),
  176. /***/ "./src/sky/skyMaterial.ts":
  177. /*!********************************!*\
  178. !*** ./src/sky/skyMaterial.ts ***!
  179. \********************************/
  180. /*! no static exports found */
  181. /***/ (function(module, exports, __webpack_require__) {
  182. "use strict";
  183. var __extends = (this && this.__extends) || (function () {
  184. var extendStatics = function (d, b) {
  185. extendStatics = Object.setPrototypeOf ||
  186. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  187. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  188. return extendStatics(d, b);
  189. }
  190. return function (d, b) {
  191. extendStatics(d, b);
  192. function __() { this.constructor = d; }
  193. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  194. };
  195. })();
  196. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  197. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  198. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  199. 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;
  200. return c > 3 && r && Object.defineProperty(target, key, r), r;
  201. };
  202. Object.defineProperty(exports, "__esModule", { value: true });
  203. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  204. babylonjs_1.Effect.ShadersStore["skyPixelShader"] = __webpack_require__(/*! ./sky.fragment.fx */ "./src/sky/sky.fragment.fx");
  205. babylonjs_1.Effect.ShadersStore["skyVertexShader"] = __webpack_require__(/*! ./sky.vertex.fx */ "./src/sky/sky.vertex.fx");
  206. var SkyMaterialDefines = /** @class */ (function (_super) {
  207. __extends(SkyMaterialDefines, _super);
  208. function SkyMaterialDefines() {
  209. var _this = _super.call(this) || this;
  210. _this.CLIPPLANE = false;
  211. _this.CLIPPLANE2 = false;
  212. _this.CLIPPLANE3 = false;
  213. _this.CLIPPLANE4 = false;
  214. _this.POINTSIZE = false;
  215. _this.FOG = false;
  216. _this.VERTEXCOLOR = false;
  217. _this.VERTEXALPHA = false;
  218. _this.rebuild();
  219. return _this;
  220. }
  221. return SkyMaterialDefines;
  222. }(babylonjs_1.MaterialDefines));
  223. var SkyMaterial = /** @class */ (function (_super) {
  224. __extends(SkyMaterial, _super);
  225. function SkyMaterial(name, scene) {
  226. var _this = _super.call(this, name, scene) || this;
  227. // Public members
  228. _this.luminance = 1.0;
  229. _this.turbidity = 10.0;
  230. _this.rayleigh = 2.0;
  231. _this.mieCoefficient = 0.005;
  232. _this.mieDirectionalG = 0.8;
  233. _this.distance = 500;
  234. _this.inclination = 0.49;
  235. _this.azimuth = 0.25;
  236. _this.sunPosition = new babylonjs_1.Vector3(0, 100, 0);
  237. _this.useSunPosition = false;
  238. // Private members
  239. _this._cameraPosition = babylonjs_1.Vector3.Zero();
  240. return _this;
  241. }
  242. SkyMaterial.prototype.needAlphaBlending = function () {
  243. return (this.alpha < 1.0);
  244. };
  245. SkyMaterial.prototype.needAlphaTesting = function () {
  246. return false;
  247. };
  248. SkyMaterial.prototype.getAlphaTestTexture = function () {
  249. return null;
  250. };
  251. // Methods
  252. SkyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  253. if (this.isFrozen) {
  254. if (this._wasPreviouslyReady && subMesh.effect) {
  255. return true;
  256. }
  257. }
  258. if (!subMesh._materialDefines) {
  259. subMesh._materialDefines = new SkyMaterialDefines();
  260. }
  261. var defines = subMesh._materialDefines;
  262. var scene = this.getScene();
  263. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  264. if (this._renderId === scene.getRenderId()) {
  265. return true;
  266. }
  267. }
  268. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, false, defines);
  269. // Attribs
  270. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, false);
  271. // Get correct effect
  272. if (defines.isDirty) {
  273. defines.markAsProcessed();
  274. scene.resetCachedMaterial();
  275. // Fallbacks
  276. var fallbacks = new babylonjs_1.EffectFallbacks();
  277. if (defines.FOG) {
  278. fallbacks.addFallback(1, "FOG");
  279. }
  280. //Attributes
  281. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  282. if (defines.VERTEXCOLOR) {
  283. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  284. }
  285. var shaderName = "sky";
  286. var join = defines.toString();
  287. subMesh.setEffect(scene.getEngine().createEffect(shaderName, attribs, ["world", "viewProjection", "view",
  288. "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
  289. "luminance", "turbidity", "rayleigh", "mieCoefficient", "mieDirectionalG", "sunPosition",
  290. "cameraPosition"
  291. ], [], join, fallbacks, this.onCompiled, this.onError), defines);
  292. }
  293. if (!subMesh.effect || !subMesh.effect.isReady()) {
  294. return false;
  295. }
  296. this._renderId = scene.getRenderId();
  297. this._wasPreviouslyReady = true;
  298. return true;
  299. };
  300. SkyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  301. var scene = this.getScene();
  302. var defines = subMesh._materialDefines;
  303. if (!defines) {
  304. return;
  305. }
  306. var effect = subMesh.effect;
  307. if (!effect) {
  308. return;
  309. }
  310. this._activeEffect = effect;
  311. // Matrices
  312. this.bindOnlyWorldMatrix(world);
  313. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  314. if (this._mustRebind(scene, effect)) {
  315. BABYLON.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  316. // Point size
  317. if (this.pointsCloud) {
  318. this._activeEffect.setFloat("pointSize", this.pointSize);
  319. }
  320. }
  321. // View
  322. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  323. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  324. }
  325. // Fog
  326. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  327. // Sky
  328. var camera = scene.activeCamera;
  329. if (camera) {
  330. var cameraWorldMatrix = camera.getWorldMatrix();
  331. this._cameraPosition.x = cameraWorldMatrix.m[12];
  332. this._cameraPosition.y = cameraWorldMatrix.m[13];
  333. this._cameraPosition.z = cameraWorldMatrix.m[14];
  334. this._activeEffect.setVector3("cameraPosition", this._cameraPosition);
  335. }
  336. if (this.luminance > 0) {
  337. this._activeEffect.setFloat("luminance", this.luminance);
  338. }
  339. this._activeEffect.setFloat("turbidity", this.turbidity);
  340. this._activeEffect.setFloat("rayleigh", this.rayleigh);
  341. this._activeEffect.setFloat("mieCoefficient", this.mieCoefficient);
  342. this._activeEffect.setFloat("mieDirectionalG", this.mieDirectionalG);
  343. if (!this.useSunPosition) {
  344. var theta = Math.PI * (this.inclination - 0.5);
  345. var phi = 2 * Math.PI * (this.azimuth - 0.5);
  346. this.sunPosition.x = this.distance * Math.cos(phi);
  347. this.sunPosition.y = this.distance * Math.sin(phi) * Math.sin(theta);
  348. this.sunPosition.z = this.distance * Math.sin(phi) * Math.cos(theta);
  349. }
  350. this._activeEffect.setVector3("sunPosition", this.sunPosition);
  351. this._afterBind(mesh, this._activeEffect);
  352. };
  353. SkyMaterial.prototype.getAnimatables = function () {
  354. return [];
  355. };
  356. SkyMaterial.prototype.dispose = function (forceDisposeEffect) {
  357. _super.prototype.dispose.call(this, forceDisposeEffect);
  358. };
  359. SkyMaterial.prototype.clone = function (name) {
  360. var _this = this;
  361. return babylonjs_1.SerializationHelper.Clone(function () { return new SkyMaterial(name, _this.getScene()); }, this);
  362. };
  363. SkyMaterial.prototype.serialize = function () {
  364. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  365. serializationObject.customType = "BABYLON.SkyMaterial";
  366. return serializationObject;
  367. };
  368. SkyMaterial.prototype.getClassName = function () {
  369. return "SkyMaterial";
  370. };
  371. // Statics
  372. SkyMaterial.Parse = function (source, scene, rootUrl) {
  373. return babylonjs_1.SerializationHelper.Parse(function () { return new SkyMaterial(source.name, scene); }, source, scene, rootUrl);
  374. };
  375. __decorate([
  376. babylonjs_1.serialize()
  377. ], SkyMaterial.prototype, "luminance", void 0);
  378. __decorate([
  379. babylonjs_1.serialize()
  380. ], SkyMaterial.prototype, "turbidity", void 0);
  381. __decorate([
  382. babylonjs_1.serialize()
  383. ], SkyMaterial.prototype, "rayleigh", void 0);
  384. __decorate([
  385. babylonjs_1.serialize()
  386. ], SkyMaterial.prototype, "mieCoefficient", void 0);
  387. __decorate([
  388. babylonjs_1.serialize()
  389. ], SkyMaterial.prototype, "mieDirectionalG", void 0);
  390. __decorate([
  391. babylonjs_1.serialize()
  392. ], SkyMaterial.prototype, "distance", void 0);
  393. __decorate([
  394. babylonjs_1.serialize()
  395. ], SkyMaterial.prototype, "inclination", void 0);
  396. __decorate([
  397. babylonjs_1.serialize()
  398. ], SkyMaterial.prototype, "azimuth", void 0);
  399. __decorate([
  400. babylonjs_1.serializeAsVector3()
  401. ], SkyMaterial.prototype, "sunPosition", void 0);
  402. __decorate([
  403. babylonjs_1.serialize()
  404. ], SkyMaterial.prototype, "useSunPosition", void 0);
  405. return SkyMaterial;
  406. }(babylonjs_1.PushMaterial));
  407. exports.SkyMaterial = SkyMaterial;
  408. /***/ }),
  409. /***/ "babylonjs":
  410. /*!****************************************************************************************************!*\
  411. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  412. \****************************************************************************************************/
  413. /*! no static exports found */
  414. /***/ (function(module, exports) {
  415. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  416. /***/ })
  417. /******/ });
  418. });
  419. //# sourceMappingURL=babylon.skyMaterial.js.map