index.js 125 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. if(typeof require !== 'undefined'){
  2. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
  3. var BABYLON = globalObject["BABYLON"] || {};
  4. var BABYLON0 = require('babylonjs/core');
  5. if(BABYLON !== BABYLON0) __extends(BABYLON, BABYLON0);
  6. var BABYLON;
  7. (function (BABYLON) {
  8. var DefaultLoadingScreen = /** @class */ (function () {
  9. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  10. if (_loadingText === void 0) { _loadingText = ""; }
  11. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  12. var _this = this;
  13. this._renderingCanvas = _renderingCanvas;
  14. this._loadingText = _loadingText;
  15. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  16. // Resize
  17. this._resizeLoadingUI = function () {
  18. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  19. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  20. if (!_this._loadingDiv) {
  21. return;
  22. }
  23. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  24. _this._loadingDiv.style.left = canvasRect.left + "px";
  25. _this._loadingDiv.style.top = canvasRect.top + "px";
  26. _this._loadingDiv.style.width = canvasRect.width + "px";
  27. _this._loadingDiv.style.height = canvasRect.height + "px";
  28. };
  29. }
  30. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  31. if (this._loadingDiv) {
  32. // Do not add a loading screen if there is already one
  33. return;
  34. }
  35. this._loadingDiv = document.createElement("div");
  36. this._loadingDiv.id = "babylonjsLoadingDiv";
  37. this._loadingDiv.style.opacity = "0";
  38. this._loadingDiv.style.transition = "opacity 1.5s ease";
  39. this._loadingDiv.style.pointerEvents = "none";
  40. // Loading text
  41. this._loadingTextDiv = document.createElement("div");
  42. this._loadingTextDiv.style.position = "absolute";
  43. this._loadingTextDiv.style.left = "0";
  44. this._loadingTextDiv.style.top = "50%";
  45. this._loadingTextDiv.style.marginTop = "80px";
  46. this._loadingTextDiv.style.width = "100%";
  47. this._loadingTextDiv.style.height = "20px";
  48. this._loadingTextDiv.style.fontFamily = "Arial";
  49. this._loadingTextDiv.style.fontSize = "14px";
  50. this._loadingTextDiv.style.color = "white";
  51. this._loadingTextDiv.style.textAlign = "center";
  52. this._loadingTextDiv.innerHTML = "Loading";
  53. this._loadingDiv.appendChild(this._loadingTextDiv);
  54. //set the predefined text
  55. this._loadingTextDiv.innerHTML = this._loadingText;
  56. // Generating keyframes
  57. var style = document.createElement('style');
  58. style.type = 'text/css';
  59. var keyFrames = "@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }";
  60. style.innerHTML = keyFrames;
  61. document.getElementsByTagName('head')[0].appendChild(style);
  62. // Loading img
  63. var imgBack = new Image();
  64. imgBack.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAX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pB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC";
  65. imgBack.style.position = "absolute";
  66. imgBack.style.left = "50%";
  67. imgBack.style.top = "50%";
  68. imgBack.style.marginLeft = "-60px";
  69. imgBack.style.marginTop = "-60px";
  70. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  71. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  72. imgBack.style.transformOrigin = "50% 50%";
  73. imgBack.style.webkitTransformOrigin = "50% 50%";
  74. this._loadingDiv.appendChild(imgBack);
  75. this._resizeLoadingUI();
  76. window.addEventListener("resize", this._resizeLoadingUI);
  77. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  78. document.body.appendChild(this._loadingDiv);
  79. this._loadingDiv.style.opacity = "1";
  80. };
  81. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  82. var _this = this;
  83. if (!this._loadingDiv) {
  84. return;
  85. }
  86. var onTransitionEnd = function () {
  87. if (!_this._loadingDiv) {
  88. return;
  89. }
  90. document.body.removeChild(_this._loadingDiv);
  91. window.removeEventListener("resize", _this._resizeLoadingUI);
  92. _this._loadingDiv = null;
  93. };
  94. this._loadingDiv.style.opacity = "0";
  95. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  96. };
  97. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  98. set: function (text) {
  99. this._loadingText = text;
  100. if (this._loadingTextDiv) {
  101. this._loadingTextDiv.innerHTML = this._loadingText;
  102. }
  103. },
  104. enumerable: true,
  105. configurable: true
  106. });
  107. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  108. get: function () {
  109. return this._loadingDivBackgroundColor;
  110. },
  111. set: function (color) {
  112. this._loadingDivBackgroundColor = color;
  113. if (!this._loadingDiv) {
  114. return;
  115. }
  116. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  117. },
  118. enumerable: true,
  119. configurable: true
  120. });
  121. return DefaultLoadingScreen;
  122. }());
  123. BABYLON.DefaultLoadingScreen = DefaultLoadingScreen;
  124. })(BABYLON || (BABYLON = {}));
  125. //# sourceMappingURL=babylon.loadingScreen.js.map
  126. var BABYLON;
  127. (function (BABYLON) {
  128. var SceneLoaderProgressEvent = /** @class */ (function () {
  129. function SceneLoaderProgressEvent(lengthComputable, loaded, total) {
  130. this.lengthComputable = lengthComputable;
  131. this.loaded = loaded;
  132. this.total = total;
  133. }
  134. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  135. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  136. };
  137. return SceneLoaderProgressEvent;
  138. }());
  139. BABYLON.SceneLoaderProgressEvent = SceneLoaderProgressEvent;
  140. var SceneLoader = /** @class */ (function () {
  141. function SceneLoader() {
  142. }
  143. Object.defineProperty(SceneLoader, "NO_LOGGING", {
  144. get: function () {
  145. return 0;
  146. },
  147. enumerable: true,
  148. configurable: true
  149. });
  150. Object.defineProperty(SceneLoader, "MINIMAL_LOGGING", {
  151. get: function () {
  152. return 1;
  153. },
  154. enumerable: true,
  155. configurable: true
  156. });
  157. Object.defineProperty(SceneLoader, "SUMMARY_LOGGING", {
  158. get: function () {
  159. return 2;
  160. },
  161. enumerable: true,
  162. configurable: true
  163. });
  164. Object.defineProperty(SceneLoader, "DETAILED_LOGGING", {
  165. get: function () {
  166. return 3;
  167. },
  168. enumerable: true,
  169. configurable: true
  170. });
  171. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  172. get: function () {
  173. return SceneLoader._ForceFullSceneLoadingForIncremental;
  174. },
  175. set: function (value) {
  176. SceneLoader._ForceFullSceneLoadingForIncremental = value;
  177. },
  178. enumerable: true,
  179. configurable: true
  180. });
  181. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  182. get: function () {
  183. return SceneLoader._ShowLoadingScreen;
  184. },
  185. set: function (value) {
  186. SceneLoader._ShowLoadingScreen = value;
  187. },
  188. enumerable: true,
  189. configurable: true
  190. });
  191. Object.defineProperty(SceneLoader, "loggingLevel", {
  192. get: function () {
  193. return SceneLoader._loggingLevel;
  194. },
  195. set: function (value) {
  196. SceneLoader._loggingLevel = value;
  197. },
  198. enumerable: true,
  199. configurable: true
  200. });
  201. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  202. get: function () {
  203. return SceneLoader._CleanBoneMatrixWeights;
  204. },
  205. set: function (value) {
  206. SceneLoader._CleanBoneMatrixWeights = value;
  207. },
  208. enumerable: true,
  209. configurable: true
  210. });
  211. SceneLoader._getDefaultPlugin = function () {
  212. return SceneLoader._registeredPlugins[".babylon"];
  213. };
  214. SceneLoader._getPluginForExtension = function (extension) {
  215. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  216. if (registeredPlugin) {
  217. return registeredPlugin;
  218. }
  219. BABYLON.Tools.Warn("Unable to find a plugin to load " + extension + " files. Trying to use .babylon default plugin.");
  220. return SceneLoader._getDefaultPlugin();
  221. };
  222. SceneLoader._getPluginForDirectLoad = function (data) {
  223. for (var extension in SceneLoader._registeredPlugins) {
  224. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  225. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  226. return SceneLoader._registeredPlugins[extension];
  227. }
  228. }
  229. return SceneLoader._getDefaultPlugin();
  230. };
  231. SceneLoader._getPluginForFilename = function (sceneFilename) {
  232. if (sceneFilename.name) {
  233. sceneFilename = sceneFilename.name;
  234. }
  235. var queryStringPosition = sceneFilename.indexOf("?");
  236. if (queryStringPosition !== -1) {
  237. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  238. }
  239. var dotPosition = sceneFilename.lastIndexOf(".");
  240. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  241. return SceneLoader._getPluginForExtension(extension);
  242. };
  243. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  244. SceneLoader._getDirectLoad = function (sceneFilename) {
  245. if (sceneFilename.substr && sceneFilename.substr(0, 5) === "data:") {
  246. return sceneFilename.substr(5);
  247. }
  248. return null;
  249. };
  250. SceneLoader._loadData = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  251. var directLoad = SceneLoader._getDirectLoad(sceneFilename);
  252. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(sceneFilename) : SceneLoader._getPluginForFilename(sceneFilename));
  253. var plugin;
  254. if (registeredPlugin.plugin.createPlugin) {
  255. plugin = registeredPlugin.plugin.createPlugin();
  256. }
  257. else {
  258. plugin = registeredPlugin.plugin;
  259. }
  260. var useArrayBuffer = registeredPlugin.isBinary;
  261. var database;
  262. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  263. var dataCallback = function (data, responseURL) {
  264. if (scene.isDisposed) {
  265. onError("Scene has been disposed");
  266. return;
  267. }
  268. scene.database = database;
  269. onSuccess(plugin, data, responseURL);
  270. };
  271. var request = null;
  272. var pluginDisposed = false;
  273. var onDisposeObservable = plugin.onDisposeObservable;
  274. if (onDisposeObservable) {
  275. onDisposeObservable.add(function () {
  276. pluginDisposed = true;
  277. if (request) {
  278. request.abort();
  279. request = null;
  280. }
  281. onDispose();
  282. });
  283. }
  284. var manifestChecked = function () {
  285. if (pluginDisposed) {
  286. return;
  287. }
  288. var url = rootUrl + sceneFilename;
  289. request = BABYLON.Tools.LoadFile(url, dataCallback, onProgress ? function (event) {
  290. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  291. } : undefined, database, useArrayBuffer, function (request, exception) {
  292. onError("Failed to load scene." + (exception ? "" : " " + exception.message), exception);
  293. });
  294. };
  295. if (directLoad) {
  296. dataCallback(directLoad);
  297. return plugin;
  298. }
  299. if (rootUrl.indexOf("file:") === -1) {
  300. if (scene.getEngine().enableOfflineSupport) {
  301. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  302. database = new BABYLON.Database(rootUrl + sceneFilename, manifestChecked);
  303. }
  304. else {
  305. manifestChecked();
  306. }
  307. }
  308. else {
  309. var fileOrString = sceneFilename;
  310. if (fileOrString.name) {
  311. request = BABYLON.Tools.ReadFile(fileOrString, dataCallback, onProgress, useArrayBuffer);
  312. }
  313. else if (BABYLON.FilesInput.FilesToLoad[sceneFilename]) {
  314. request = BABYLON.Tools.ReadFile(BABYLON.FilesInput.FilesToLoad[sceneFilename], dataCallback, onProgress, useArrayBuffer);
  315. }
  316. else {
  317. onError("Unable to find file named " + sceneFilename);
  318. }
  319. }
  320. return plugin;
  321. };
  322. // Public functions
  323. SceneLoader.GetPluginForExtension = function (extension) {
  324. return SceneLoader._getPluginForExtension(extension).plugin;
  325. };
  326. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  327. return !!SceneLoader._registeredPlugins[extension];
  328. };
  329. SceneLoader.RegisterPlugin = function (plugin) {
  330. if (typeof plugin.extensions === "string") {
  331. var extension = plugin.extensions;
  332. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  333. plugin: plugin,
  334. isBinary: false
  335. };
  336. }
  337. else {
  338. var extensions = plugin.extensions;
  339. Object.keys(extensions).forEach(function (extension) {
  340. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  341. plugin: plugin,
  342. isBinary: extensions[extension].isBinary
  343. };
  344. });
  345. }
  346. };
  347. /**
  348. * Import meshes into a scene
  349. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  350. * @param rootUrl a string that defines the root url for scene and resources
  351. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  352. * @param scene the instance of BABYLON.Scene to append to
  353. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  354. * @param onProgress a callback with a progress event for each file being loaded
  355. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  356. */
  357. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  358. if (onSuccess === void 0) { onSuccess = null; }
  359. if (onProgress === void 0) { onProgress = null; }
  360. if (onError === void 0) { onError = null; }
  361. if (pluginExtension === void 0) { pluginExtension = null; }
  362. if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
  363. BABYLON.Tools.Error("Wrong sceneFilename parameter");
  364. return null;
  365. }
  366. var loadingToken = {};
  367. scene._addPendingData(loadingToken);
  368. var disposeHandler = function () {
  369. scene._removePendingData(loadingToken);
  370. };
  371. var errorHandler = function (message, exception) {
  372. var errorMessage = "Unable to import meshes from " + rootUrl + sceneFilename + ": " + message;
  373. if (onError) {
  374. onError(scene, errorMessage, exception);
  375. }
  376. else {
  377. BABYLON.Tools.Error(errorMessage);
  378. // should the exception be thrown?
  379. }
  380. disposeHandler();
  381. };
  382. var progressHandler = onProgress ? function (event) {
  383. try {
  384. onProgress(event);
  385. }
  386. catch (e) {
  387. errorHandler("Error in onProgress callback", e);
  388. }
  389. } : undefined;
  390. var successHandler = function (meshes, particleSystems, skeletons) {
  391. scene.importedMeshesFiles.push(rootUrl + sceneFilename);
  392. if (onSuccess) {
  393. try {
  394. onSuccess(meshes, particleSystems, skeletons);
  395. }
  396. catch (e) {
  397. errorHandler("Error in onSuccess callback", e);
  398. }
  399. }
  400. scene._removePendingData(loadingToken);
  401. };
  402. return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
  403. if (plugin.rewriteRootURL) {
  404. rootUrl = plugin.rewriteRootURL(rootUrl, responseURL);
  405. }
  406. if (plugin.importMesh) {
  407. var syncedPlugin = plugin;
  408. var meshes = new Array();
  409. var particleSystems = new Array();
  410. var skeletons = new Array();
  411. if (!syncedPlugin.importMesh(meshNames, scene, data, rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  412. return;
  413. }
  414. scene.loadingPluginName = plugin.name;
  415. successHandler(meshes, particleSystems, skeletons);
  416. }
  417. else {
  418. var asyncedPlugin = plugin;
  419. asyncedPlugin.importMeshAsync(meshNames, scene, data, rootUrl, function (meshes, particleSystems, skeletons) {
  420. scene.loadingPluginName = plugin.name;
  421. successHandler(meshes, particleSystems, skeletons);
  422. }, progressHandler, errorHandler);
  423. }
  424. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  425. };
  426. /**
  427. * Load a scene
  428. * @param rootUrl a string that defines the root url for scene and resources
  429. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  430. * @param engine is the instance of BABYLON.Engine to use to create the scene
  431. * @param onSuccess a callback with the scene when import succeeds
  432. * @param onProgress a callback with a progress event for each file being loaded
  433. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  434. */
  435. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  436. if (onSuccess === void 0) { onSuccess = null; }
  437. if (onProgress === void 0) { onProgress = null; }
  438. if (onError === void 0) { onError = null; }
  439. if (pluginExtension === void 0) { pluginExtension = null; }
  440. return SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onSuccess, onProgress, onError, pluginExtension);
  441. };
  442. /**
  443. * Append a scene
  444. * @param rootUrl a string that defines the root url for scene and resources
  445. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  446. * @param scene is the instance of BABYLON.Scene to append to
  447. * @param onSuccess a callback with the scene when import succeeds
  448. * @param onProgress a callback with a progress event for each file being loaded
  449. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  450. */
  451. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  452. if (onSuccess === void 0) { onSuccess = null; }
  453. if (onProgress === void 0) { onProgress = null; }
  454. if (onError === void 0) { onError = null; }
  455. if (pluginExtension === void 0) { pluginExtension = null; }
  456. if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
  457. BABYLON.Tools.Error("Wrong sceneFilename parameter");
  458. return null;
  459. }
  460. if (SceneLoader.ShowLoadingScreen) {
  461. scene.getEngine().displayLoadingUI();
  462. }
  463. var loadingToken = {};
  464. scene._addPendingData(loadingToken);
  465. var disposeHandler = function () {
  466. scene._removePendingData(loadingToken);
  467. scene.getEngine().hideLoadingUI();
  468. };
  469. var errorHandler = function (message, exception) {
  470. var errorMessage = "Unable to load from " + rootUrl + sceneFilename + (message ? ": " + message : "");
  471. if (onError) {
  472. onError(scene, errorMessage, exception);
  473. }
  474. else {
  475. BABYLON.Tools.Error(errorMessage);
  476. // should the exception be thrown?
  477. }
  478. disposeHandler();
  479. };
  480. var progressHandler = onProgress ? function (event) {
  481. try {
  482. onProgress(event);
  483. }
  484. catch (e) {
  485. errorHandler("Error in onProgress callback", e);
  486. }
  487. } : undefined;
  488. var successHandler = function () {
  489. if (onSuccess) {
  490. try {
  491. onSuccess(scene);
  492. }
  493. catch (e) {
  494. errorHandler("Error in onSuccess callback", e);
  495. }
  496. }
  497. scene._removePendingData(loadingToken);
  498. };
  499. return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
  500. if (plugin.load) {
  501. var syncedPlugin = plugin;
  502. if (!syncedPlugin.load(scene, data, rootUrl, errorHandler)) {
  503. return;
  504. }
  505. scene.loadingPluginName = plugin.name;
  506. successHandler();
  507. }
  508. else {
  509. var asyncedPlugin = plugin;
  510. asyncedPlugin.loadAsync(scene, data, rootUrl, function () {
  511. scene.loadingPluginName = plugin.name;
  512. successHandler();
  513. }, progressHandler, errorHandler);
  514. }
  515. if (SceneLoader.ShowLoadingScreen) {
  516. scene.executeWhenReady(function () {
  517. scene.getEngine().hideLoadingUI();
  518. });
  519. }
  520. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  521. };
  522. // Flags
  523. SceneLoader._ForceFullSceneLoadingForIncremental = false;
  524. SceneLoader._ShowLoadingScreen = true;
  525. SceneLoader._CleanBoneMatrixWeights = false;
  526. SceneLoader._loggingLevel = SceneLoader.NO_LOGGING;
  527. // Members
  528. SceneLoader.OnPluginActivatedObservable = new BABYLON.Observable();
  529. SceneLoader._registeredPlugins = {};
  530. return SceneLoader;
  531. }());
  532. BABYLON.SceneLoader = SceneLoader;
  533. ;
  534. })(BABYLON || (BABYLON = {}));
  535. //# sourceMappingURL=babylon.sceneLoader.js.map
  536. BABYLON.Effect.ShadersStore['defaultVertexShader'] = "#include<__decl__defaultVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\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<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,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 MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\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#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n}";
  537. BABYLON.Effect.ShadersStore['defaultPixelShader'] = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\ngl_FragColor=color;\n}";
  538. var BABYLON;
  539. (function (BABYLON) {
  540. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  541. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  542. var parsedMaterial = parsedData.materials[index];
  543. if (parsedMaterial.id === id) {
  544. return BABYLON.Material.Parse(parsedMaterial, scene, rootUrl);
  545. }
  546. }
  547. return null;
  548. };
  549. var isDescendantOf = function (mesh, names, hierarchyIds) {
  550. for (var i in names) {
  551. if (mesh.name === names[i]) {
  552. hierarchyIds.push(mesh.id);
  553. return true;
  554. }
  555. }
  556. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  557. hierarchyIds.push(mesh.id);
  558. return true;
  559. }
  560. return false;
  561. };
  562. var logOperation = function (operation, producer) {
  563. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  564. };
  565. BABYLON.SceneLoader.RegisterPlugin({
  566. name: "babylon.js",
  567. extensions: ".babylon",
  568. canDirectLoad: function (data) {
  569. if (data.indexOf("babylon") !== -1) {
  570. return true;
  571. }
  572. return false;
  573. },
  574. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  575. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  576. // when SceneLoader.debugLogging = true (default), or exception encountered.
  577. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  578. // and avoid problems with multiple concurrent .babylon loads.
  579. var log = "importMesh has failed JSON parse";
  580. try {
  581. var parsedData = JSON.parse(data);
  582. log = "";
  583. var fullDetails = BABYLON.SceneLoader.loggingLevel === BABYLON.SceneLoader.DETAILED_LOGGING;
  584. if (!meshesNames) {
  585. meshesNames = null;
  586. }
  587. else if (!Array.isArray(meshesNames)) {
  588. meshesNames = [meshesNames];
  589. }
  590. var hierarchyIds = new Array();
  591. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  592. var loadedSkeletonsIds = [];
  593. var loadedMaterialsIds = [];
  594. var index;
  595. var cache;
  596. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  597. var parsedMesh = parsedData.meshes[index];
  598. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  599. if (meshesNames !== null) {
  600. // Remove found mesh name from list.
  601. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  602. }
  603. //Geometry?
  604. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  605. //does the file contain geometries?
  606. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  607. //find the correct geometry and add it to the scene
  608. var found = false;
  609. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  610. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  611. return;
  612. }
  613. else {
  614. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  615. if (parsedGeometryData.id === parsedMesh.geometryId) {
  616. switch (geometryType) {
  617. case "boxes":
  618. BABYLON.BoxGeometry.Parse(parsedGeometryData, scene);
  619. break;
  620. case "spheres":
  621. BABYLON.SphereGeometry.Parse(parsedGeometryData, scene);
  622. break;
  623. case "cylinders":
  624. BABYLON.CylinderGeometry.Parse(parsedGeometryData, scene);
  625. break;
  626. case "toruses":
  627. BABYLON.TorusGeometry.Parse(parsedGeometryData, scene);
  628. break;
  629. case "grounds":
  630. BABYLON.GroundGeometry.Parse(parsedGeometryData, scene);
  631. break;
  632. case "planes":
  633. BABYLON.PlaneGeometry.Parse(parsedGeometryData, scene);
  634. break;
  635. case "torusKnots":
  636. BABYLON.TorusKnotGeometry.Parse(parsedGeometryData, scene);
  637. break;
  638. case "vertexData":
  639. BABYLON.Geometry.Parse(parsedGeometryData, scene, rootUrl);
  640. break;
  641. }
  642. found = true;
  643. }
  644. });
  645. }
  646. });
  647. if (found === false) {
  648. BABYLON.Tools.Warn("Geometry not found for mesh " + parsedMesh.id);
  649. }
  650. }
  651. }
  652. // Material ?
  653. if (parsedMesh.materialId) {
  654. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  655. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  656. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  657. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  658. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  659. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  660. var subMatId = parsedMultiMaterial.materials[matIndex];
  661. loadedMaterialsIds.push(subMatId);
  662. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  663. log += "\n\tMaterial " + mat.toString(fullDetails);
  664. }
  665. loadedMaterialsIds.push(parsedMultiMaterial.id);
  666. var mmat = BABYLON.Material.ParseMultiMaterial(parsedMultiMaterial, scene);
  667. materialFound = true;
  668. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  669. break;
  670. }
  671. }
  672. }
  673. if (materialFound === false) {
  674. loadedMaterialsIds.push(parsedMesh.materialId);
  675. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  676. if (!mat) {
  677. BABYLON.Tools.Warn("Material not found for mesh " + parsedMesh.id);
  678. }
  679. else {
  680. log += "\n\tMaterial " + mat.toString(fullDetails);
  681. }
  682. }
  683. }
  684. // Skeleton ?
  685. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  686. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  687. if (skeletonAlreadyLoaded === false) {
  688. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  689. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  690. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  691. var skeleton = BABYLON.Skeleton.Parse(parsedSkeleton, scene);
  692. skeletons.push(skeleton);
  693. loadedSkeletonsIds.push(parsedSkeleton.id);
  694. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  695. }
  696. }
  697. }
  698. }
  699. var mesh = BABYLON.Mesh.Parse(parsedMesh, scene, rootUrl);
  700. meshes.push(mesh);
  701. log += "\n\tMesh " + mesh.toString(fullDetails);
  702. }
  703. }
  704. // Connecting parents
  705. var currentMesh;
  706. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  707. currentMesh = scene.meshes[index];
  708. if (currentMesh._waitingParentId) {
  709. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  710. currentMesh._waitingParentId = null;
  711. }
  712. }
  713. // freeze and compute world matrix application
  714. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  715. currentMesh = scene.meshes[index];
  716. if (currentMesh._waitingFreezeWorldMatrix) {
  717. currentMesh.freezeWorldMatrix();
  718. currentMesh._waitingFreezeWorldMatrix = null;
  719. }
  720. else {
  721. currentMesh.computeWorldMatrix(true);
  722. }
  723. }
  724. }
  725. // Particles
  726. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  727. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  728. var parsedParticleSystem = parsedData.particleSystems[index];
  729. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  730. particleSystems.push(BABYLON.ParticleSystem.Parse(parsedParticleSystem, scene, rootUrl));
  731. }
  732. }
  733. }
  734. return true;
  735. }
  736. catch (err) {
  737. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  738. if (onError) {
  739. onError(msg, err);
  740. }
  741. else {
  742. BABYLON.Tools.Log(msg);
  743. throw err;
  744. }
  745. }
  746. finally {
  747. if (log !== null && BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.NO_LOGGING) {
  748. BABYLON.Tools.Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.MINIMAL_LOGGING ? log : ""));
  749. }
  750. }
  751. return false;
  752. },
  753. load: function (scene, data, rootUrl, onError) {
  754. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  755. // when SceneLoader.debugLogging = true (default), or exception encountered.
  756. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  757. // and avoid problems with multiple concurrent .babylon loads.
  758. var log = "importScene has failed JSON parse";
  759. try {
  760. var parsedData = JSON.parse(data);
  761. log = "";
  762. var fullDetails = BABYLON.SceneLoader.loggingLevel === BABYLON.SceneLoader.DETAILED_LOGGING;
  763. // Scene
  764. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  765. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !BABYLON.SceneLoader.ForceFullSceneLoadingForIncremental;
  766. }
  767. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  768. scene.autoClear = parsedData.autoClear;
  769. }
  770. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  771. scene.clearColor = BABYLON.Color4.FromArray(parsedData.clearColor);
  772. }
  773. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  774. scene.ambientColor = BABYLON.Color3.FromArray(parsedData.ambientColor);
  775. }
  776. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  777. scene.gravity = BABYLON.Vector3.FromArray(parsedData.gravity);
  778. }
  779. // Fog
  780. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  781. scene.fogMode = parsedData.fogMode;
  782. scene.fogColor = BABYLON.Color3.FromArray(parsedData.fogColor);
  783. scene.fogStart = parsedData.fogStart;
  784. scene.fogEnd = parsedData.fogEnd;
  785. scene.fogDensity = parsedData.fogDensity;
  786. log += "\tFog mode for scene: ";
  787. switch (scene.fogMode) {
  788. // getters not compiling, so using hardcoded
  789. case 1:
  790. log += "exp\n";
  791. break;
  792. case 2:
  793. log += "exp2\n";
  794. break;
  795. case 3:
  796. log += "linear\n";
  797. break;
  798. }
  799. }
  800. //Physics
  801. if (parsedData.physicsEnabled) {
  802. var physicsPlugin;
  803. if (parsedData.physicsEngine === "cannon") {
  804. physicsPlugin = new BABYLON.CannonJSPlugin();
  805. }
  806. else if (parsedData.physicsEngine === "oimo") {
  807. physicsPlugin = new BABYLON.OimoJSPlugin();
  808. }
  809. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  810. //else - default engine, which is currently oimo
  811. var physicsGravity = parsedData.physicsGravity ? BABYLON.Vector3.FromArray(parsedData.physicsGravity) : null;
  812. scene.enablePhysics(physicsGravity, physicsPlugin);
  813. }
  814. // Metadata
  815. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  816. scene.metadata = parsedData.metadata;
  817. }
  818. //collisions, if defined. otherwise, default is true
  819. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  820. scene.collisionsEnabled = parsedData.collisionsEnabled;
  821. }
  822. scene.workerCollisions = !!parsedData.workerCollisions;
  823. var index;
  824. var cache;
  825. // Lights
  826. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  827. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  828. var parsedLight = parsedData.lights[index];
  829. var light = BABYLON.Light.Parse(parsedLight, scene);
  830. if (light) {
  831. log += (index === 0 ? "\n\tLights:" : "");
  832. log += "\n\t\t" + light.toString(fullDetails);
  833. }
  834. }
  835. }
  836. // Animations
  837. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  838. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  839. var parsedAnimation = parsedData.animations[index];
  840. var animation = BABYLON.Animation.Parse(parsedAnimation);
  841. scene.animations.push(animation);
  842. log += (index === 0 ? "\n\tAnimations:" : "");
  843. log += "\n\t\t" + animation.toString(fullDetails);
  844. }
  845. }
  846. if (parsedData.autoAnimate) {
  847. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  848. }
  849. // Materials
  850. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  851. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  852. var parsedMaterial = parsedData.materials[index];
  853. var mat = BABYLON.Material.Parse(parsedMaterial, scene, rootUrl);
  854. log += (index === 0 ? "\n\tMaterials:" : "");
  855. log += "\n\t\t" + mat.toString(fullDetails);
  856. }
  857. }
  858. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  859. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  860. var parsedMultiMaterial = parsedData.multiMaterials[index];
  861. var mmat = BABYLON.Material.ParseMultiMaterial(parsedMultiMaterial, scene);
  862. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  863. log += "\n\t\t" + mmat.toString(fullDetails);
  864. }
  865. }
  866. // Morph targets
  867. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  868. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  869. var managerData = _a[_i];
  870. BABYLON.MorphTargetManager.Parse(managerData, scene);
  871. }
  872. }
  873. // Skeletons
  874. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  875. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  876. var parsedSkeleton = parsedData.skeletons[index];
  877. var skeleton = BABYLON.Skeleton.Parse(parsedSkeleton, scene);
  878. log += (index === 0 ? "\n\tSkeletons:" : "");
  879. log += "\n\t\t" + skeleton.toString(fullDetails);
  880. }
  881. }
  882. // Geometries
  883. var geometries = parsedData.geometries;
  884. if (geometries !== undefined && geometries !== null) {
  885. // Boxes
  886. var boxes = geometries.boxes;
  887. if (boxes !== undefined && boxes !== null) {
  888. for (index = 0, cache = boxes.length; index < cache; index++) {
  889. var parsedBox = boxes[index];
  890. BABYLON.BoxGeometry.Parse(parsedBox, scene);
  891. }
  892. }
  893. // Spheres
  894. var spheres = geometries.spheres;
  895. if (spheres !== undefined && spheres !== null) {
  896. for (index = 0, cache = spheres.length; index < cache; index++) {
  897. var parsedSphere = spheres[index];
  898. BABYLON.SphereGeometry.Parse(parsedSphere, scene);
  899. }
  900. }
  901. // Cylinders
  902. var cylinders = geometries.cylinders;
  903. if (cylinders !== undefined && cylinders !== null) {
  904. for (index = 0, cache = cylinders.length; index < cache; index++) {
  905. var parsedCylinder = cylinders[index];
  906. BABYLON.CylinderGeometry.Parse(parsedCylinder, scene);
  907. }
  908. }
  909. // Toruses
  910. var toruses = geometries.toruses;
  911. if (toruses !== undefined && toruses !== null) {
  912. for (index = 0, cache = toruses.length; index < cache; index++) {
  913. var parsedTorus = toruses[index];
  914. BABYLON.TorusGeometry.Parse(parsedTorus, scene);
  915. }
  916. }
  917. // Grounds
  918. var grounds = geometries.grounds;
  919. if (grounds !== undefined && grounds !== null) {
  920. for (index = 0, cache = grounds.length; index < cache; index++) {
  921. var parsedGround = grounds[index];
  922. BABYLON.GroundGeometry.Parse(parsedGround, scene);
  923. }
  924. }
  925. // Planes
  926. var planes = geometries.planes;
  927. if (planes !== undefined && planes !== null) {
  928. for (index = 0, cache = planes.length; index < cache; index++) {
  929. var parsedPlane = planes[index];
  930. BABYLON.PlaneGeometry.Parse(parsedPlane, scene);
  931. }
  932. }
  933. // TorusKnots
  934. var torusKnots = geometries.torusKnots;
  935. if (torusKnots !== undefined && torusKnots !== null) {
  936. for (index = 0, cache = torusKnots.length; index < cache; index++) {
  937. var parsedTorusKnot = torusKnots[index];
  938. BABYLON.TorusKnotGeometry.Parse(parsedTorusKnot, scene);
  939. }
  940. }
  941. // VertexData
  942. var vertexData = geometries.vertexData;
  943. if (vertexData !== undefined && vertexData !== null) {
  944. for (index = 0, cache = vertexData.length; index < cache; index++) {
  945. var parsedVertexData = vertexData[index];
  946. BABYLON.Geometry.Parse(parsedVertexData, scene, rootUrl);
  947. }
  948. }
  949. }
  950. // Transform nodes
  951. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  952. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  953. var parsedTransformNode = parsedData.transformNodes[index];
  954. BABYLON.TransformNode.Parse(parsedTransformNode, scene, rootUrl);
  955. }
  956. }
  957. // Meshes
  958. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  959. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  960. var parsedMesh = parsedData.meshes[index];
  961. var mesh = BABYLON.Mesh.Parse(parsedMesh, scene, rootUrl);
  962. log += (index === 0 ? "\n\tMeshes:" : "");
  963. log += "\n\t\t" + mesh.toString(fullDetails);
  964. }
  965. }
  966. // Cameras
  967. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  968. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  969. var parsedCamera = parsedData.cameras[index];
  970. var camera = BABYLON.Camera.Parse(parsedCamera, scene);
  971. log += (index === 0 ? "\n\tCameras:" : "");
  972. log += "\n\t\t" + camera.toString(fullDetails);
  973. }
  974. }
  975. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  976. scene.setActiveCameraByID(parsedData.activeCameraID);
  977. }
  978. // Browsing all the graph to connect the dots
  979. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  980. var camera = scene.cameras[index];
  981. if (camera._waitingParentId) {
  982. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  983. camera._waitingParentId = null;
  984. }
  985. }
  986. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  987. var light_1 = scene.lights[index];
  988. if (light_1 && light_1._waitingParentId) {
  989. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  990. light_1._waitingParentId = null;
  991. }
  992. }
  993. // Sounds
  994. var loadedSounds = [];
  995. var loadedSound;
  996. if (BABYLON.AudioEngine && parsedData.sounds !== undefined && parsedData.sounds !== null) {
  997. for (index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  998. var parsedSound = parsedData.sounds[index];
  999. if (BABYLON.Engine.audioEngine.canUseWebAudio) {
  1000. if (!parsedSound.url)
  1001. parsedSound.url = parsedSound.name;
  1002. if (!loadedSounds[parsedSound.url]) {
  1003. loadedSound = BABYLON.Sound.Parse(parsedSound, scene, rootUrl);
  1004. loadedSounds[parsedSound.url] = loadedSound;
  1005. }
  1006. else {
  1007. BABYLON.Sound.Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]);
  1008. }
  1009. }
  1010. else {
  1011. new BABYLON.Sound(parsedSound.name, null, scene);
  1012. }
  1013. }
  1014. }
  1015. loadedSounds = [];
  1016. // Connect parents & children and parse actions
  1017. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  1018. var transformNode = scene.transformNodes[index];
  1019. if (transformNode._waitingParentId) {
  1020. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  1021. transformNode._waitingParentId = null;
  1022. }
  1023. }
  1024. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  1025. var mesh = scene.meshes[index];
  1026. if (mesh._waitingParentId) {
  1027. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  1028. mesh._waitingParentId = null;
  1029. }
  1030. if (mesh._waitingActions) {
  1031. BABYLON.ActionManager.Parse(mesh._waitingActions, mesh, scene);
  1032. mesh._waitingActions = null;
  1033. }
  1034. }
  1035. // freeze world matrix application
  1036. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  1037. var currentMesh = scene.meshes[index];
  1038. if (currentMesh._waitingFreezeWorldMatrix) {
  1039. currentMesh.freezeWorldMatrix();
  1040. currentMesh._waitingFreezeWorldMatrix = null;
  1041. }
  1042. else {
  1043. currentMesh.computeWorldMatrix(true);
  1044. }
  1045. }
  1046. // Particles Systems
  1047. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  1048. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  1049. var parsedParticleSystem = parsedData.particleSystems[index];
  1050. BABYLON.ParticleSystem.Parse(parsedParticleSystem, scene, rootUrl);
  1051. }
  1052. }
  1053. // Environment texture
  1054. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  1055. scene.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  1056. if (parsedData.createDefaultSkybox === true) {
  1057. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  1058. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  1059. scene.createDefaultSkybox(undefined, true, skyboxScale, skyboxBlurLevel);
  1060. }
  1061. }
  1062. // Lens flares
  1063. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  1064. for (index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  1065. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  1066. BABYLON.LensFlareSystem.Parse(parsedLensFlareSystem, scene, rootUrl);
  1067. }
  1068. }
  1069. // Shadows
  1070. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  1071. for (index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  1072. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  1073. BABYLON.ShadowGenerator.Parse(parsedShadowGenerator, scene);
  1074. }
  1075. }
  1076. // Lights exclusions / inclusions
  1077. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  1078. var light_2 = scene.lights[index];
  1079. // Excluded check
  1080. if (light_2._excludedMeshesIds.length > 0) {
  1081. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  1082. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  1083. if (excludedMesh) {
  1084. light_2.excludedMeshes.push(excludedMesh);
  1085. }
  1086. }
  1087. light_2._excludedMeshesIds = [];
  1088. }
  1089. // Included check
  1090. if (light_2._includedOnlyMeshesIds.length > 0) {
  1091. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  1092. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  1093. if (includedOnlyMesh) {
  1094. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  1095. }
  1096. }
  1097. light_2._includedOnlyMeshesIds = [];
  1098. }
  1099. }
  1100. // Actions (scene)
  1101. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  1102. BABYLON.ActionManager.Parse(parsedData.actions, null, scene);
  1103. }
  1104. // Finish
  1105. return true;
  1106. }
  1107. catch (err) {
  1108. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  1109. if (onError) {
  1110. onError(msg, err);
  1111. }
  1112. else {
  1113. BABYLON.Tools.Log(msg);
  1114. throw err;
  1115. }
  1116. }
  1117. finally {
  1118. if (log !== null && BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.NO_LOGGING) {
  1119. BABYLON.Tools.Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.MINIMAL_LOGGING ? log : ""));
  1120. }
  1121. }
  1122. return false;
  1123. }
  1124. });
  1125. })(BABYLON || (BABYLON = {}));
  1126. //# sourceMappingURL=babylon.babylonFileLoader.js.map
  1127. var BABYLON;
  1128. (function (BABYLON) {
  1129. var FilesInput = /** @class */ (function () {
  1130. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  1131. this.onProcessFileCallback = function () { return true; };
  1132. this._engine = engine;
  1133. this._currentScene = scene;
  1134. this._sceneLoadedCallback = sceneLoadedCallback;
  1135. this._progressCallback = progressCallback;
  1136. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  1137. this._textureLoadingCallback = textureLoadingCallback;
  1138. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  1139. this._onReloadCallback = onReloadCallback;
  1140. this._errorCallback = errorCallback;
  1141. }
  1142. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  1143. var _this = this;
  1144. if (elementToMonitor) {
  1145. this._elementToMonitor = elementToMonitor;
  1146. this._dragEnterHandler = function (e) { _this.drag(e); };
  1147. this._dragOverHandler = function (e) { _this.drag(e); };
  1148. this._dropHandler = function (e) { _this.drop(e); };
  1149. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  1150. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  1151. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  1152. }
  1153. };
  1154. FilesInput.prototype.dispose = function () {
  1155. if (!this._elementToMonitor) {
  1156. return;
  1157. }
  1158. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  1159. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  1160. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  1161. };
  1162. FilesInput.prototype.renderFunction = function () {
  1163. if (this._additionalRenderLoopLogicCallback) {
  1164. this._additionalRenderLoopLogicCallback();
  1165. }
  1166. if (this._currentScene) {
  1167. if (this._textureLoadingCallback) {
  1168. var remaining = this._currentScene.getWaitingItemsCount();
  1169. if (remaining > 0) {
  1170. this._textureLoadingCallback(remaining);
  1171. }
  1172. }
  1173. this._currentScene.render();
  1174. }
  1175. };
  1176. FilesInput.prototype.drag = function (e) {
  1177. e.stopPropagation();
  1178. e.preventDefault();
  1179. };
  1180. FilesInput.prototype.drop = function (eventDrop) {
  1181. eventDrop.stopPropagation();
  1182. eventDrop.preventDefault();
  1183. this.loadFiles(eventDrop);
  1184. };
  1185. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  1186. var _this = this;
  1187. var reader = folder.createReader();
  1188. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  1189. reader.readEntries(function (entries) {
  1190. remaining.count += entries.length;
  1191. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  1192. var entry = entries_1[_i];
  1193. if (entry.isFile) {
  1194. entry.file(function (file) {
  1195. file.correctName = relativePath + file.name;
  1196. files.push(file);
  1197. if (--remaining.count === 0) {
  1198. callback();
  1199. }
  1200. });
  1201. }
  1202. else if (entry.isDirectory) {
  1203. _this._traverseFolder(entry, files, remaining, callback);
  1204. }
  1205. }
  1206. if (--remaining.count) {
  1207. callback();
  1208. }
  1209. });
  1210. };
  1211. FilesInput.prototype._processFiles = function (files) {
  1212. for (var i = 0; i < files.length; i++) {
  1213. var name = files[i].correctName.toLowerCase();
  1214. var extension = name.split('.').pop();
  1215. if (!this.onProcessFileCallback(files[i], name, extension)) {
  1216. continue;
  1217. }
  1218. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  1219. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  1220. this._sceneFileToLoad = files[i];
  1221. }
  1222. else {
  1223. FilesInput.FilesToLoad[name] = files[i];
  1224. }
  1225. }
  1226. };
  1227. FilesInput.prototype.loadFiles = function (event) {
  1228. var _this = this;
  1229. if (this._startingProcessingFilesCallback)
  1230. this._startingProcessingFilesCallback();
  1231. // Handling data transfer via drag'n'drop
  1232. if (event && event.dataTransfer && event.dataTransfer.files) {
  1233. this._filesToLoad = event.dataTransfer.files;
  1234. }
  1235. // Handling files from input files
  1236. if (event && event.target && event.target.files) {
  1237. this._filesToLoad = event.target.files;
  1238. }
  1239. if (this._filesToLoad && this._filesToLoad.length > 0) {
  1240. var files_1 = new Array();
  1241. var folders = [];
  1242. var items = event.dataTransfer ? event.dataTransfer.items : null;
  1243. for (var i = 0; i < this._filesToLoad.length; i++) {
  1244. var fileToLoad = this._filesToLoad[i];
  1245. var name_1 = fileToLoad.name.toLowerCase();
  1246. var entry = void 0;
  1247. fileToLoad.correctName = name_1;
  1248. if (items) {
  1249. var item = items[i];
  1250. if (item.getAsEntry) {
  1251. entry = item.getAsEntry();
  1252. }
  1253. else if (item.webkitGetAsEntry) {
  1254. entry = item.webkitGetAsEntry();
  1255. }
  1256. }
  1257. if (!entry) {
  1258. files_1.push(fileToLoad);
  1259. }
  1260. else {
  1261. if (entry.isDirectory) {
  1262. folders.push(entry);
  1263. }
  1264. else {
  1265. files_1.push(fileToLoad);
  1266. }
  1267. }
  1268. }
  1269. if (folders.length === 0) {
  1270. this._processFiles(files_1);
  1271. this._processReload();
  1272. }
  1273. else {
  1274. var remaining = { count: folders.length };
  1275. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  1276. var folder = folders_1[_i];
  1277. this._traverseFolder(folder, files_1, remaining, function () {
  1278. _this._processFiles(files_1);
  1279. if (remaining.count === 0) {
  1280. _this._processReload();
  1281. }
  1282. });
  1283. }
  1284. }
  1285. }
  1286. };
  1287. FilesInput.prototype._processReload = function () {
  1288. if (this._onReloadCallback) {
  1289. this._onReloadCallback(this._sceneFileToLoad);
  1290. }
  1291. else {
  1292. this.reload();
  1293. }
  1294. };
  1295. FilesInput.prototype.reload = function () {
  1296. var _this = this;
  1297. // If a scene file has been provided
  1298. if (this._sceneFileToLoad) {
  1299. if (this._currentScene) {
  1300. if (BABYLON.Tools.errorsCount > 0) {
  1301. BABYLON.Tools.ClearLogCache();
  1302. }
  1303. this._engine.stopRenderLoop();
  1304. this._currentScene.dispose();
  1305. }
  1306. BABYLON.SceneLoader.Load("file:", this._sceneFileToLoad, this._engine, function (newScene) {
  1307. _this._currentScene = newScene;
  1308. if (_this._sceneLoadedCallback) {
  1309. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  1310. }
  1311. // Wait for textures and shaders to be ready
  1312. _this._currentScene.executeWhenReady(function () {
  1313. _this._engine.runRenderLoop(function () {
  1314. _this.renderFunction();
  1315. });
  1316. });
  1317. }, function (progress) {
  1318. if (_this._progressCallback) {
  1319. _this._progressCallback(progress);
  1320. }
  1321. }, function (scene, message) {
  1322. _this._currentScene = scene;
  1323. if (_this._errorCallback) {
  1324. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, message);
  1325. }
  1326. });
  1327. }
  1328. else {
  1329. BABYLON.Tools.Error("Please provide a valid .babylon file.");
  1330. }
  1331. };
  1332. FilesInput.FilesToLoad = {};
  1333. return FilesInput;
  1334. }());
  1335. BABYLON.FilesInput = FilesInput;
  1336. })(BABYLON || (BABYLON = {}));
  1337. //# sourceMappingURL=babylon.filesInput.js.map
  1338. BABYLON.Effect.IncludesShadersStore['depthPrePass'] = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  1339. BABYLON.Effect.IncludesShadersStore['bonesDeclaration'] = "#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif";
  1340. BABYLON.Effect.IncludesShadersStore['instancesDeclaration'] = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  1341. BABYLON.Effect.IncludesShadersStore['pointCloudVertexDeclaration'] = "#ifdef POINTSIZE\nuniform float pointSize;\n#endif";
  1342. BABYLON.Effect.IncludesShadersStore['bumpVertexDeclaration'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
  1343. BABYLON.Effect.IncludesShadersStore['clipPlaneVertexDeclaration'] = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif";
  1344. BABYLON.Effect.IncludesShadersStore['fogVertexDeclaration'] = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  1345. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexGlobalDeclaration'] = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  1346. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexDeclaration'] = "#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif";
  1347. BABYLON.Effect.IncludesShadersStore['logDepthDeclaration'] = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  1348. BABYLON.Effect.IncludesShadersStore['morphTargetsVertex'] = "#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif";
  1349. BABYLON.Effect.IncludesShadersStore['instancesVertex'] = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  1350. BABYLON.Effect.IncludesShadersStore['bonesVertex'] = "#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif";
  1351. BABYLON.Effect.IncludesShadersStore['bumpVertex'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  1352. BABYLON.Effect.IncludesShadersStore['clipPlaneVertex'] = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif";
  1353. BABYLON.Effect.IncludesShadersStore['fogVertex'] = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  1354. BABYLON.Effect.IncludesShadersStore['shadowsVertex'] = "#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif";
  1355. BABYLON.Effect.IncludesShadersStore['pointCloudVertex'] = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  1356. BABYLON.Effect.IncludesShadersStore['logDepthVertex'] = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  1357. BABYLON.Effect.IncludesShadersStore['helperFunctions'] = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nvec3 dither(vec2 seed,vec3 color) {\nfloat rand=getRand(seed);\ncolor+=mix(-0.5/255.0,0.5/255.0,rand);\ncolor=max(color,0.0);\nreturn color;\n}";
  1358. BABYLON.Effect.IncludesShadersStore['lightFragmentDeclaration'] = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\n#endif\n#ifdef HEMILIGHT{X}\nuniform vec3 vLightGround{X};\n#endif\n#endif";
  1359. BABYLON.Effect.IncludesShadersStore['lightsFragmentFunctions'] = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n";
  1360. BABYLON.Effect.IncludesShadersStore['lightUboDeclaration'] = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\n#endif\n#ifdef HEMILIGHT{X}\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";
  1361. BABYLON.Effect.IncludesShadersStore['defaultVertexDeclaration'] = "\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";
  1362. BABYLON.Effect.IncludesShadersStore['defaultFragmentDeclaration'] = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  1363. BABYLON.Effect.IncludesShadersStore['defaultUboDeclaration'] = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  1364. BABYLON.Effect.IncludesShadersStore['shadowsFragmentFunctions'] = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#endif\n";
  1365. BABYLON.Effect.IncludesShadersStore['fresnelFunction'] = "#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif";
  1366. BABYLON.Effect.IncludesShadersStore['reflectionFunction'] = "vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat t=clamp(direction.y*-0.5+0.5,0.,1.0);\nfloat s=atan(direction.z,direction.x)*RECIPROCAL_PI2+0.5;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=reflect(cameraToVertex,worldNormal);\nfloat t=clamp(r.y*-0.5+0.5,0.,1.0);\nfloat s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  1367. BABYLON.Effect.IncludesShadersStore['imageProcessingDeclaration'] = "#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif";
  1368. BABYLON.Effect.IncludesShadersStore['imageProcessingFunctions'] = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  1369. BABYLON.Effect.IncludesShadersStore['bumpFragmentFunctions'] = "#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif";
  1370. BABYLON.Effect.IncludesShadersStore['clipPlaneFragmentDeclaration'] = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif";
  1371. BABYLON.Effect.IncludesShadersStore['fogFragmentDeclaration'] = "#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif";
  1372. BABYLON.Effect.IncludesShadersStore['clipPlaneFragment'] = "#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif";
  1373. BABYLON.Effect.IncludesShadersStore['bumpFragment'] = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif";
  1374. BABYLON.Effect.IncludesShadersStore['lightFragment'] = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else\n#ifdef SHADOWESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else \n#ifdef SHADOWPCF{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  1375. BABYLON.Effect.IncludesShadersStore['logDepthFragment'] = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  1376. BABYLON.Effect.IncludesShadersStore['fogFragment'] = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  1377. (function() {
  1378. var EXPORTS = {};EXPORTS['DefaultLoadingScreen'] = BABYLON['DefaultLoadingScreen'];EXPORTS['SceneLoaderProgressEvent'] = BABYLON['SceneLoaderProgressEvent'];EXPORTS['SceneLoader'] = BABYLON['SceneLoader'];EXPORTS['FilesInput'] = BABYLON['FilesInput'];
  1379. globalObject["BABYLON"] = globalObject["BABYLON"] || BABYLON;
  1380. module.exports = EXPORTS;
  1381. })();
  1382. }