es6.js 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. import * as BABYLON from 'babylonjs/core/es6';
  2. var BABYLON;
  3. (function (BABYLON) {
  4. var DefaultLoadingScreen = /** @class */ (function () {
  5. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  6. if (_loadingText === void 0) { _loadingText = ""; }
  7. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  8. var _this = this;
  9. this._renderingCanvas = _renderingCanvas;
  10. this._loadingText = _loadingText;
  11. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  12. // Resize
  13. this._resizeLoadingUI = function () {
  14. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  15. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  16. if (!_this._loadingDiv) {
  17. return;
  18. }
  19. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  20. _this._loadingDiv.style.left = canvasRect.left + "px";
  21. _this._loadingDiv.style.top = canvasRect.top + "px";
  22. _this._loadingDiv.style.width = canvasRect.width + "px";
  23. _this._loadingDiv.style.height = canvasRect.height + "px";
  24. };
  25. }
  26. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  27. if (this._loadingDiv) {
  28. // Do not add a loading screen if there is already one
  29. return;
  30. }
  31. this._loadingDiv = document.createElement("div");
  32. this._loadingDiv.id = "babylonjsLoadingDiv";
  33. this._loadingDiv.style.opacity = "0";
  34. this._loadingDiv.style.transition = "opacity 1.5s ease";
  35. this._loadingDiv.style.pointerEvents = "none";
  36. // Loading text
  37. this._loadingTextDiv = document.createElement("div");
  38. this._loadingTextDiv.style.position = "absolute";
  39. this._loadingTextDiv.style.left = "0";
  40. this._loadingTextDiv.style.top = "50%";
  41. this._loadingTextDiv.style.marginTop = "80px";
  42. this._loadingTextDiv.style.width = "100%";
  43. this._loadingTextDiv.style.height = "20px";
  44. this._loadingTextDiv.style.fontFamily = "Arial";
  45. this._loadingTextDiv.style.fontSize = "14px";
  46. this._loadingTextDiv.style.color = "white";
  47. this._loadingTextDiv.style.textAlign = "center";
  48. this._loadingTextDiv.innerHTML = "Loading";
  49. this._loadingDiv.appendChild(this._loadingTextDiv);
  50. //set the predefined text
  51. this._loadingTextDiv.innerHTML = this._loadingText;
  52. // Generating keyframes
  53. var style = document.createElement('style');
  54. style.type = 'text/css';
  55. 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 }";
  56. style.innerHTML = keyFrames;
  57. document.getElementsByTagName('head')[0].appendChild(style);
  58. // Loading img
  59. var imgBack = new Image();
  60. imgBack.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnH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C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC";
  61. imgBack.style.position = "absolute";
  62. imgBack.style.left = "50%";
  63. imgBack.style.top = "50%";
  64. imgBack.style.marginLeft = "-60px";
  65. imgBack.style.marginTop = "-60px";
  66. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  67. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  68. imgBack.style.transformOrigin = "50% 50%";
  69. imgBack.style.webkitTransformOrigin = "50% 50%";
  70. this._loadingDiv.appendChild(imgBack);
  71. this._resizeLoadingUI();
  72. window.addEventListener("resize", this._resizeLoadingUI);
  73. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  74. document.body.appendChild(this._loadingDiv);
  75. this._loadingDiv.style.opacity = "1";
  76. };
  77. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  78. var _this = this;
  79. if (!this._loadingDiv) {
  80. return;
  81. }
  82. var onTransitionEnd = function () {
  83. if (!_this._loadingDiv) {
  84. return;
  85. }
  86. document.body.removeChild(_this._loadingDiv);
  87. window.removeEventListener("resize", _this._resizeLoadingUI);
  88. _this._loadingDiv = null;
  89. };
  90. this._loadingDiv.style.opacity = "0";
  91. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  92. };
  93. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  94. set: function (text) {
  95. this._loadingText = text;
  96. if (this._loadingTextDiv) {
  97. this._loadingTextDiv.innerHTML = this._loadingText;
  98. }
  99. },
  100. enumerable: true,
  101. configurable: true
  102. });
  103. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  104. get: function () {
  105. return this._loadingDivBackgroundColor;
  106. },
  107. set: function (color) {
  108. this._loadingDivBackgroundColor = color;
  109. if (!this._loadingDiv) {
  110. return;
  111. }
  112. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  113. },
  114. enumerable: true,
  115. configurable: true
  116. });
  117. return DefaultLoadingScreen;
  118. }());
  119. BABYLON.DefaultLoadingScreen = DefaultLoadingScreen;
  120. })(BABYLON || (BABYLON = {}));
  121. //# sourceMappingURL=babylon.loadingScreen.js.map
  122. var BABYLON;
  123. (function (BABYLON) {
  124. var SceneLoaderProgressEvent = /** @class */ (function () {
  125. function SceneLoaderProgressEvent(lengthComputable, loaded, total) {
  126. this.lengthComputable = lengthComputable;
  127. this.loaded = loaded;
  128. this.total = total;
  129. }
  130. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  131. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  132. };
  133. return SceneLoaderProgressEvent;
  134. }());
  135. BABYLON.SceneLoaderProgressEvent = SceneLoaderProgressEvent;
  136. var SceneLoader = /** @class */ (function () {
  137. function SceneLoader() {
  138. }
  139. Object.defineProperty(SceneLoader, "NO_LOGGING", {
  140. get: function () {
  141. return 0;
  142. },
  143. enumerable: true,
  144. configurable: true
  145. });
  146. Object.defineProperty(SceneLoader, "MINIMAL_LOGGING", {
  147. get: function () {
  148. return 1;
  149. },
  150. enumerable: true,
  151. configurable: true
  152. });
  153. Object.defineProperty(SceneLoader, "SUMMARY_LOGGING", {
  154. get: function () {
  155. return 2;
  156. },
  157. enumerable: true,
  158. configurable: true
  159. });
  160. Object.defineProperty(SceneLoader, "DETAILED_LOGGING", {
  161. get: function () {
  162. return 3;
  163. },
  164. enumerable: true,
  165. configurable: true
  166. });
  167. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  168. get: function () {
  169. return SceneLoader._ForceFullSceneLoadingForIncremental;
  170. },
  171. set: function (value) {
  172. SceneLoader._ForceFullSceneLoadingForIncremental = value;
  173. },
  174. enumerable: true,
  175. configurable: true
  176. });
  177. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  178. get: function () {
  179. return SceneLoader._ShowLoadingScreen;
  180. },
  181. set: function (value) {
  182. SceneLoader._ShowLoadingScreen = value;
  183. },
  184. enumerable: true,
  185. configurable: true
  186. });
  187. Object.defineProperty(SceneLoader, "loggingLevel", {
  188. get: function () {
  189. return SceneLoader._loggingLevel;
  190. },
  191. set: function (value) {
  192. SceneLoader._loggingLevel = value;
  193. },
  194. enumerable: true,
  195. configurable: true
  196. });
  197. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  198. get: function () {
  199. return SceneLoader._CleanBoneMatrixWeights;
  200. },
  201. set: function (value) {
  202. SceneLoader._CleanBoneMatrixWeights = value;
  203. },
  204. enumerable: true,
  205. configurable: true
  206. });
  207. SceneLoader._getDefaultPlugin = function () {
  208. return SceneLoader._registeredPlugins[".babylon"];
  209. };
  210. SceneLoader._getPluginForExtension = function (extension) {
  211. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  212. if (registeredPlugin) {
  213. return registeredPlugin;
  214. }
  215. BABYLON.Tools.Warn("Unable to find a plugin to load " + extension + " files. Trying to use .babylon default plugin.");
  216. return SceneLoader._getDefaultPlugin();
  217. };
  218. SceneLoader._getPluginForDirectLoad = function (data) {
  219. for (var extension in SceneLoader._registeredPlugins) {
  220. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  221. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  222. return SceneLoader._registeredPlugins[extension];
  223. }
  224. }
  225. return SceneLoader._getDefaultPlugin();
  226. };
  227. SceneLoader._getPluginForFilename = function (sceneFilename) {
  228. if (sceneFilename.name) {
  229. sceneFilename = sceneFilename.name;
  230. }
  231. var queryStringPosition = sceneFilename.indexOf("?");
  232. if (queryStringPosition !== -1) {
  233. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  234. }
  235. var dotPosition = sceneFilename.lastIndexOf(".");
  236. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  237. return SceneLoader._getPluginForExtension(extension);
  238. };
  239. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  240. SceneLoader._getDirectLoad = function (sceneFilename) {
  241. if (sceneFilename.substr && sceneFilename.substr(0, 5) === "data:") {
  242. return sceneFilename.substr(5);
  243. }
  244. return null;
  245. };
  246. SceneLoader._loadData = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  247. var directLoad = SceneLoader._getDirectLoad(sceneFilename);
  248. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(sceneFilename) : SceneLoader._getPluginForFilename(sceneFilename));
  249. var plugin;
  250. if (registeredPlugin.plugin.createPlugin) {
  251. plugin = registeredPlugin.plugin.createPlugin();
  252. }
  253. else {
  254. plugin = registeredPlugin.plugin;
  255. }
  256. var useArrayBuffer = registeredPlugin.isBinary;
  257. var database;
  258. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  259. var dataCallback = function (data, responseURL) {
  260. if (scene.isDisposed) {
  261. onError("Scene has been disposed");
  262. return;
  263. }
  264. scene.database = database;
  265. onSuccess(plugin, data, responseURL);
  266. };
  267. var request = null;
  268. var pluginDisposed = false;
  269. var onDisposeObservable = plugin.onDisposeObservable;
  270. if (onDisposeObservable) {
  271. onDisposeObservable.add(function () {
  272. pluginDisposed = true;
  273. if (request) {
  274. request.abort();
  275. request = null;
  276. }
  277. onDispose();
  278. });
  279. }
  280. var manifestChecked = function () {
  281. if (pluginDisposed) {
  282. return;
  283. }
  284. var url = rootUrl + sceneFilename;
  285. request = BABYLON.Tools.LoadFile(url, dataCallback, onProgress ? function (event) {
  286. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  287. } : undefined, database, useArrayBuffer, function (request, exception) {
  288. onError("Failed to load scene." + (exception ? "" : " " + exception.message), exception);
  289. });
  290. };
  291. if (directLoad) {
  292. dataCallback(directLoad);
  293. return plugin;
  294. }
  295. if (rootUrl.indexOf("file:") === -1) {
  296. if (scene.getEngine().enableOfflineSupport) {
  297. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  298. database = new BABYLON.Database(rootUrl + sceneFilename, manifestChecked);
  299. }
  300. else {
  301. manifestChecked();
  302. }
  303. }
  304. else {
  305. var fileOrString = sceneFilename;
  306. if (fileOrString.name) {
  307. request = BABYLON.Tools.ReadFile(fileOrString, dataCallback, onProgress, useArrayBuffer);
  308. }
  309. else if (BABYLON.FilesInput.FilesToLoad[sceneFilename]) {
  310. request = BABYLON.Tools.ReadFile(BABYLON.FilesInput.FilesToLoad[sceneFilename], dataCallback, onProgress, useArrayBuffer);
  311. }
  312. else {
  313. onError("Unable to find file named " + sceneFilename);
  314. }
  315. }
  316. return plugin;
  317. };
  318. // Public functions
  319. SceneLoader.GetPluginForExtension = function (extension) {
  320. return SceneLoader._getPluginForExtension(extension).plugin;
  321. };
  322. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  323. return !!SceneLoader._registeredPlugins[extension];
  324. };
  325. SceneLoader.RegisterPlugin = function (plugin) {
  326. if (typeof plugin.extensions === "string") {
  327. var extension = plugin.extensions;
  328. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  329. plugin: plugin,
  330. isBinary: false
  331. };
  332. }
  333. else {
  334. var extensions = plugin.extensions;
  335. Object.keys(extensions).forEach(function (extension) {
  336. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  337. plugin: plugin,
  338. isBinary: extensions[extension].isBinary
  339. };
  340. });
  341. }
  342. };
  343. /**
  344. * Import meshes into a scene
  345. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  346. * @param rootUrl a string that defines the root url for scene and resources
  347. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  348. * @param scene the instance of BABYLON.Scene to append to
  349. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  350. * @param onProgress a callback with a progress event for each file being loaded
  351. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  352. */
  353. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  354. if (onSuccess === void 0) { onSuccess = null; }
  355. if (onProgress === void 0) { onProgress = null; }
  356. if (onError === void 0) { onError = null; }
  357. if (pluginExtension === void 0) { pluginExtension = null; }
  358. if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
  359. BABYLON.Tools.Error("Wrong sceneFilename parameter");
  360. return null;
  361. }
  362. var loadingToken = {};
  363. scene._addPendingData(loadingToken);
  364. var disposeHandler = function () {
  365. scene._removePendingData(loadingToken);
  366. };
  367. var errorHandler = function (message, exception) {
  368. var errorMessage = "Unable to import meshes from " + rootUrl + sceneFilename + ": " + message;
  369. if (onError) {
  370. onError(scene, errorMessage, exception);
  371. }
  372. else {
  373. BABYLON.Tools.Error(errorMessage);
  374. // should the exception be thrown?
  375. }
  376. disposeHandler();
  377. };
  378. var progressHandler = onProgress ? function (event) {
  379. try {
  380. onProgress(event);
  381. }
  382. catch (e) {
  383. errorHandler("Error in onProgress callback", e);
  384. }
  385. } : undefined;
  386. var successHandler = function (meshes, particleSystems, skeletons) {
  387. scene.importedMeshesFiles.push(rootUrl + sceneFilename);
  388. if (onSuccess) {
  389. try {
  390. onSuccess(meshes, particleSystems, skeletons);
  391. }
  392. catch (e) {
  393. errorHandler("Error in onSuccess callback", e);
  394. }
  395. }
  396. scene._removePendingData(loadingToken);
  397. };
  398. return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
  399. if (plugin.rewriteRootURL) {
  400. rootUrl = plugin.rewriteRootURL(rootUrl, responseURL);
  401. }
  402. if (plugin.importMesh) {
  403. var syncedPlugin = plugin;
  404. var meshes = new Array();
  405. var particleSystems = new Array();
  406. var skeletons = new Array();
  407. if (!syncedPlugin.importMesh(meshNames, scene, data, rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  408. return;
  409. }
  410. scene.loadingPluginName = plugin.name;
  411. successHandler(meshes, particleSystems, skeletons);
  412. }
  413. else {
  414. var asyncedPlugin = plugin;
  415. asyncedPlugin.importMeshAsync(meshNames, scene, data, rootUrl, function (meshes, particleSystems, skeletons) {
  416. scene.loadingPluginName = plugin.name;
  417. successHandler(meshes, particleSystems, skeletons);
  418. }, progressHandler, errorHandler);
  419. }
  420. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  421. };
  422. /**
  423. * Load a scene
  424. * @param rootUrl a string that defines the root url for scene and resources
  425. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  426. * @param engine is the instance of BABYLON.Engine to use to create the scene
  427. * @param onSuccess a callback with the scene when import succeeds
  428. * @param onProgress a callback with a progress event for each file being loaded
  429. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  430. */
  431. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  432. if (onSuccess === void 0) { onSuccess = null; }
  433. if (onProgress === void 0) { onProgress = null; }
  434. if (onError === void 0) { onError = null; }
  435. if (pluginExtension === void 0) { pluginExtension = null; }
  436. return SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onSuccess, onProgress, onError, pluginExtension);
  437. };
  438. /**
  439. * Append a scene
  440. * @param rootUrl a string that defines the root url for scene and resources
  441. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  442. * @param scene is the instance of BABYLON.Scene to append to
  443. * @param onSuccess a callback with the scene when import succeeds
  444. * @param onProgress a callback with a progress event for each file being loaded
  445. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  446. */
  447. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  448. if (onSuccess === void 0) { onSuccess = null; }
  449. if (onProgress === void 0) { onProgress = null; }
  450. if (onError === void 0) { onError = null; }
  451. if (pluginExtension === void 0) { pluginExtension = null; }
  452. if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
  453. BABYLON.Tools.Error("Wrong sceneFilename parameter");
  454. return null;
  455. }
  456. if (SceneLoader.ShowLoadingScreen) {
  457. scene.getEngine().displayLoadingUI();
  458. }
  459. var loadingToken = {};
  460. scene._addPendingData(loadingToken);
  461. var disposeHandler = function () {
  462. scene._removePendingData(loadingToken);
  463. scene.getEngine().hideLoadingUI();
  464. };
  465. var errorHandler = function (message, exception) {
  466. var errorMessage = "Unable to load from " + rootUrl + sceneFilename + (message ? ": " + message : "");
  467. if (onError) {
  468. onError(scene, errorMessage, exception);
  469. }
  470. else {
  471. BABYLON.Tools.Error(errorMessage);
  472. // should the exception be thrown?
  473. }
  474. disposeHandler();
  475. };
  476. var progressHandler = onProgress ? function (event) {
  477. try {
  478. onProgress(event);
  479. }
  480. catch (e) {
  481. errorHandler("Error in onProgress callback", e);
  482. }
  483. } : undefined;
  484. var successHandler = function () {
  485. if (onSuccess) {
  486. try {
  487. onSuccess(scene);
  488. }
  489. catch (e) {
  490. errorHandler("Error in onSuccess callback", e);
  491. }
  492. }
  493. scene._removePendingData(loadingToken);
  494. };
  495. return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
  496. if (plugin.load) {
  497. var syncedPlugin = plugin;
  498. if (!syncedPlugin.load(scene, data, rootUrl, errorHandler)) {
  499. return;
  500. }
  501. scene.loadingPluginName = plugin.name;
  502. successHandler();
  503. }
  504. else {
  505. var asyncedPlugin = plugin;
  506. asyncedPlugin.loadAsync(scene, data, rootUrl, function () {
  507. scene.loadingPluginName = plugin.name;
  508. successHandler();
  509. }, progressHandler, errorHandler);
  510. }
  511. if (SceneLoader.ShowLoadingScreen) {
  512. scene.executeWhenReady(function () {
  513. scene.getEngine().hideLoadingUI();
  514. });
  515. }
  516. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  517. };
  518. // Flags
  519. SceneLoader._ForceFullSceneLoadingForIncremental = false;
  520. SceneLoader._ShowLoadingScreen = true;
  521. SceneLoader._CleanBoneMatrixWeights = false;
  522. SceneLoader._loggingLevel = SceneLoader.NO_LOGGING;
  523. // Members
  524. SceneLoader.OnPluginActivatedObservable = new BABYLON.Observable();
  525. SceneLoader._registeredPlugins = {};
  526. return SceneLoader;
  527. }());
  528. BABYLON.SceneLoader = SceneLoader;
  529. ;
  530. })(BABYLON || (BABYLON = {}));
  531. //# sourceMappingURL=babylon.sceneLoader.js.map
  532. 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}";
  533. 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}";
  534. var BABYLON;
  535. (function (BABYLON) {
  536. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  537. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  538. var parsedMaterial = parsedData.materials[index];
  539. if (parsedMaterial.id === id) {
  540. return BABYLON.Material.Parse(parsedMaterial, scene, rootUrl);
  541. }
  542. }
  543. return null;
  544. };
  545. var isDescendantOf = function (mesh, names, hierarchyIds) {
  546. for (var i in names) {
  547. if (mesh.name === names[i]) {
  548. hierarchyIds.push(mesh.id);
  549. return true;
  550. }
  551. }
  552. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  553. hierarchyIds.push(mesh.id);
  554. return true;
  555. }
  556. return false;
  557. };
  558. var logOperation = function (operation, producer) {
  559. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  560. };
  561. BABYLON.SceneLoader.RegisterPlugin({
  562. name: "babylon.js",
  563. extensions: ".babylon",
  564. canDirectLoad: function (data) {
  565. if (data.indexOf("babylon") !== -1) {
  566. return true;
  567. }
  568. return false;
  569. },
  570. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  571. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  572. // when SceneLoader.debugLogging = true (default), or exception encountered.
  573. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  574. // and avoid problems with multiple concurrent .babylon loads.
  575. var log = "importMesh has failed JSON parse";
  576. try {
  577. var parsedData = JSON.parse(data);
  578. log = "";
  579. var fullDetails = BABYLON.SceneLoader.loggingLevel === BABYLON.SceneLoader.DETAILED_LOGGING;
  580. if (!meshesNames) {
  581. meshesNames = null;
  582. }
  583. else if (!Array.isArray(meshesNames)) {
  584. meshesNames = [meshesNames];
  585. }
  586. var hierarchyIds = new Array();
  587. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  588. var loadedSkeletonsIds = [];
  589. var loadedMaterialsIds = [];
  590. var index;
  591. var cache;
  592. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  593. var parsedMesh = parsedData.meshes[index];
  594. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  595. if (meshesNames !== null) {
  596. // Remove found mesh name from list.
  597. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  598. }
  599. //Geometry?
  600. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  601. //does the file contain geometries?
  602. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  603. //find the correct geometry and add it to the scene
  604. var found = false;
  605. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  606. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  607. return;
  608. }
  609. else {
  610. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  611. if (parsedGeometryData.id === parsedMesh.geometryId) {
  612. switch (geometryType) {
  613. case "boxes":
  614. BABYLON.BoxGeometry.Parse(parsedGeometryData, scene);
  615. break;
  616. case "spheres":
  617. BABYLON.SphereGeometry.Parse(parsedGeometryData, scene);
  618. break;
  619. case "cylinders":
  620. BABYLON.CylinderGeometry.Parse(parsedGeometryData, scene);
  621. break;
  622. case "toruses":
  623. BABYLON.TorusGeometry.Parse(parsedGeometryData, scene);
  624. break;
  625. case "grounds":
  626. BABYLON.GroundGeometry.Parse(parsedGeometryData, scene);
  627. break;
  628. case "planes":
  629. BABYLON.PlaneGeometry.Parse(parsedGeometryData, scene);
  630. break;
  631. case "torusKnots":
  632. BABYLON.TorusKnotGeometry.Parse(parsedGeometryData, scene);
  633. break;
  634. case "vertexData":
  635. BABYLON.Geometry.Parse(parsedGeometryData, scene, rootUrl);
  636. break;
  637. }
  638. found = true;
  639. }
  640. });
  641. }
  642. });
  643. if (found === false) {
  644. BABYLON.Tools.Warn("Geometry not found for mesh " + parsedMesh.id);
  645. }
  646. }
  647. }
  648. // Material ?
  649. if (parsedMesh.materialId) {
  650. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  651. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  652. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  653. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  654. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  655. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  656. var subMatId = parsedMultiMaterial.materials[matIndex];
  657. loadedMaterialsIds.push(subMatId);
  658. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  659. log += "\n\tMaterial " + mat.toString(fullDetails);
  660. }
  661. loadedMaterialsIds.push(parsedMultiMaterial.id);
  662. var mmat = BABYLON.Material.ParseMultiMaterial(parsedMultiMaterial, scene);
  663. materialFound = true;
  664. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  665. break;
  666. }
  667. }
  668. }
  669. if (materialFound === false) {
  670. loadedMaterialsIds.push(parsedMesh.materialId);
  671. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  672. if (!mat) {
  673. BABYLON.Tools.Warn("Material not found for mesh " + parsedMesh.id);
  674. }
  675. else {
  676. log += "\n\tMaterial " + mat.toString(fullDetails);
  677. }
  678. }
  679. }
  680. // Skeleton ?
  681. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  682. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  683. if (skeletonAlreadyLoaded === false) {
  684. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  685. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  686. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  687. var skeleton = BABYLON.Skeleton.Parse(parsedSkeleton, scene);
  688. skeletons.push(skeleton);
  689. loadedSkeletonsIds.push(parsedSkeleton.id);
  690. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  691. }
  692. }
  693. }
  694. }
  695. var mesh = BABYLON.Mesh.Parse(parsedMesh, scene, rootUrl);
  696. meshes.push(mesh);
  697. log += "\n\tMesh " + mesh.toString(fullDetails);
  698. }
  699. }
  700. // Connecting parents
  701. var currentMesh;
  702. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  703. currentMesh = scene.meshes[index];
  704. if (currentMesh._waitingParentId) {
  705. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  706. currentMesh._waitingParentId = null;
  707. }
  708. }
  709. // freeze and compute world matrix application
  710. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  711. currentMesh = scene.meshes[index];
  712. if (currentMesh._waitingFreezeWorldMatrix) {
  713. currentMesh.freezeWorldMatrix();
  714. currentMesh._waitingFreezeWorldMatrix = null;
  715. }
  716. else {
  717. currentMesh.computeWorldMatrix(true);
  718. }
  719. }
  720. }
  721. // Particles
  722. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  723. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  724. var parsedParticleSystem = parsedData.particleSystems[index];
  725. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  726. particleSystems.push(BABYLON.ParticleSystem.Parse(parsedParticleSystem, scene, rootUrl));
  727. }
  728. }
  729. }
  730. return true;
  731. }
  732. catch (err) {
  733. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  734. if (onError) {
  735. onError(msg, err);
  736. }
  737. else {
  738. BABYLON.Tools.Log(msg);
  739. throw err;
  740. }
  741. }
  742. finally {
  743. if (log !== null && BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.NO_LOGGING) {
  744. BABYLON.Tools.Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.MINIMAL_LOGGING ? log : ""));
  745. }
  746. }
  747. return false;
  748. },
  749. load: function (scene, data, rootUrl, onError) {
  750. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  751. // when SceneLoader.debugLogging = true (default), or exception encountered.
  752. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  753. // and avoid problems with multiple concurrent .babylon loads.
  754. var log = "importScene has failed JSON parse";
  755. try {
  756. var parsedData = JSON.parse(data);
  757. log = "";
  758. var fullDetails = BABYLON.SceneLoader.loggingLevel === BABYLON.SceneLoader.DETAILED_LOGGING;
  759. // Scene
  760. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  761. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !BABYLON.SceneLoader.ForceFullSceneLoadingForIncremental;
  762. }
  763. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  764. scene.autoClear = parsedData.autoClear;
  765. }
  766. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  767. scene.clearColor = BABYLON.Color4.FromArray(parsedData.clearColor);
  768. }
  769. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  770. scene.ambientColor = BABYLON.Color3.FromArray(parsedData.ambientColor);
  771. }
  772. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  773. scene.gravity = BABYLON.Vector3.FromArray(parsedData.gravity);
  774. }
  775. // Fog
  776. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  777. scene.fogMode = parsedData.fogMode;
  778. scene.fogColor = BABYLON.Color3.FromArray(parsedData.fogColor);
  779. scene.fogStart = parsedData.fogStart;
  780. scene.fogEnd = parsedData.fogEnd;
  781. scene.fogDensity = parsedData.fogDensity;
  782. log += "\tFog mode for scene: ";
  783. switch (scene.fogMode) {
  784. // getters not compiling, so using hardcoded
  785. case 1:
  786. log += "exp\n";
  787. break;
  788. case 2:
  789. log += "exp2\n";
  790. break;
  791. case 3:
  792. log += "linear\n";
  793. break;
  794. }
  795. }
  796. //Physics
  797. if (parsedData.physicsEnabled) {
  798. var physicsPlugin;
  799. if (parsedData.physicsEngine === "cannon") {
  800. physicsPlugin = new BABYLON.CannonJSPlugin();
  801. }
  802. else if (parsedData.physicsEngine === "oimo") {
  803. physicsPlugin = new BABYLON.OimoJSPlugin();
  804. }
  805. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  806. //else - default engine, which is currently oimo
  807. var physicsGravity = parsedData.physicsGravity ? BABYLON.Vector3.FromArray(parsedData.physicsGravity) : null;
  808. scene.enablePhysics(physicsGravity, physicsPlugin);
  809. }
  810. // Metadata
  811. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  812. scene.metadata = parsedData.metadata;
  813. }
  814. //collisions, if defined. otherwise, default is true
  815. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  816. scene.collisionsEnabled = parsedData.collisionsEnabled;
  817. }
  818. scene.workerCollisions = !!parsedData.workerCollisions;
  819. var index;
  820. var cache;
  821. // Lights
  822. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  823. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  824. var parsedLight = parsedData.lights[index];
  825. var light = BABYLON.Light.Parse(parsedLight, scene);
  826. if (light) {
  827. log += (index === 0 ? "\n\tLights:" : "");
  828. log += "\n\t\t" + light.toString(fullDetails);
  829. }
  830. }
  831. }
  832. // Animations
  833. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  834. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  835. var parsedAnimation = parsedData.animations[index];
  836. var animation = BABYLON.Animation.Parse(parsedAnimation);
  837. scene.animations.push(animation);
  838. log += (index === 0 ? "\n\tAnimations:" : "");
  839. log += "\n\t\t" + animation.toString(fullDetails);
  840. }
  841. }
  842. if (parsedData.autoAnimate) {
  843. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  844. }
  845. // Materials
  846. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  847. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  848. var parsedMaterial = parsedData.materials[index];
  849. var mat = BABYLON.Material.Parse(parsedMaterial, scene, rootUrl);
  850. log += (index === 0 ? "\n\tMaterials:" : "");
  851. log += "\n\t\t" + mat.toString(fullDetails);
  852. }
  853. }
  854. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  855. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  856. var parsedMultiMaterial = parsedData.multiMaterials[index];
  857. var mmat = BABYLON.Material.ParseMultiMaterial(parsedMultiMaterial, scene);
  858. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  859. log += "\n\t\t" + mmat.toString(fullDetails);
  860. }
  861. }
  862. // Morph targets
  863. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  864. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  865. var managerData = _a[_i];
  866. BABYLON.MorphTargetManager.Parse(managerData, scene);
  867. }
  868. }
  869. // Skeletons
  870. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  871. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  872. var parsedSkeleton = parsedData.skeletons[index];
  873. var skeleton = BABYLON.Skeleton.Parse(parsedSkeleton, scene);
  874. log += (index === 0 ? "\n\tSkeletons:" : "");
  875. log += "\n\t\t" + skeleton.toString(fullDetails);
  876. }
  877. }
  878. // Geometries
  879. var geometries = parsedData.geometries;
  880. if (geometries !== undefined && geometries !== null) {
  881. // Boxes
  882. var boxes = geometries.boxes;
  883. if (boxes !== undefined && boxes !== null) {
  884. for (index = 0, cache = boxes.length; index < cache; index++) {
  885. var parsedBox = boxes[index];
  886. BABYLON.BoxGeometry.Parse(parsedBox, scene);
  887. }
  888. }
  889. // Spheres
  890. var spheres = geometries.spheres;
  891. if (spheres !== undefined && spheres !== null) {
  892. for (index = 0, cache = spheres.length; index < cache; index++) {
  893. var parsedSphere = spheres[index];
  894. BABYLON.SphereGeometry.Parse(parsedSphere, scene);
  895. }
  896. }
  897. // Cylinders
  898. var cylinders = geometries.cylinders;
  899. if (cylinders !== undefined && cylinders !== null) {
  900. for (index = 0, cache = cylinders.length; index < cache; index++) {
  901. var parsedCylinder = cylinders[index];
  902. BABYLON.CylinderGeometry.Parse(parsedCylinder, scene);
  903. }
  904. }
  905. // Toruses
  906. var toruses = geometries.toruses;
  907. if (toruses !== undefined && toruses !== null) {
  908. for (index = 0, cache = toruses.length; index < cache; index++) {
  909. var parsedTorus = toruses[index];
  910. BABYLON.TorusGeometry.Parse(parsedTorus, scene);
  911. }
  912. }
  913. // Grounds
  914. var grounds = geometries.grounds;
  915. if (grounds !== undefined && grounds !== null) {
  916. for (index = 0, cache = grounds.length; index < cache; index++) {
  917. var parsedGround = grounds[index];
  918. BABYLON.GroundGeometry.Parse(parsedGround, scene);
  919. }
  920. }
  921. // Planes
  922. var planes = geometries.planes;
  923. if (planes !== undefined && planes !== null) {
  924. for (index = 0, cache = planes.length; index < cache; index++) {
  925. var parsedPlane = planes[index];
  926. BABYLON.PlaneGeometry.Parse(parsedPlane, scene);
  927. }
  928. }
  929. // TorusKnots
  930. var torusKnots = geometries.torusKnots;
  931. if (torusKnots !== undefined && torusKnots !== null) {
  932. for (index = 0, cache = torusKnots.length; index < cache; index++) {
  933. var parsedTorusKnot = torusKnots[index];
  934. BABYLON.TorusKnotGeometry.Parse(parsedTorusKnot, scene);
  935. }
  936. }
  937. // VertexData
  938. var vertexData = geometries.vertexData;
  939. if (vertexData !== undefined && vertexData !== null) {
  940. for (index = 0, cache = vertexData.length; index < cache; index++) {
  941. var parsedVertexData = vertexData[index];
  942. BABYLON.Geometry.Parse(parsedVertexData, scene, rootUrl);
  943. }
  944. }
  945. }
  946. // Transform nodes
  947. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  948. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  949. var parsedTransformNode = parsedData.transformNodes[index];
  950. BABYLON.TransformNode.Parse(parsedTransformNode, scene, rootUrl);
  951. }
  952. }
  953. // Meshes
  954. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  955. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  956. var parsedMesh = parsedData.meshes[index];
  957. var mesh = BABYLON.Mesh.Parse(parsedMesh, scene, rootUrl);
  958. log += (index === 0 ? "\n\tMeshes:" : "");
  959. log += "\n\t\t" + mesh.toString(fullDetails);
  960. }
  961. }
  962. // Cameras
  963. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  964. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  965. var parsedCamera = parsedData.cameras[index];
  966. var camera = BABYLON.Camera.Parse(parsedCamera, scene);
  967. log += (index === 0 ? "\n\tCameras:" : "");
  968. log += "\n\t\t" + camera.toString(fullDetails);
  969. }
  970. }
  971. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  972. scene.setActiveCameraByID(parsedData.activeCameraID);
  973. }
  974. // Browsing all the graph to connect the dots
  975. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  976. var camera = scene.cameras[index];
  977. if (camera._waitingParentId) {
  978. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  979. camera._waitingParentId = null;
  980. }
  981. }
  982. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  983. var light_1 = scene.lights[index];
  984. if (light_1 && light_1._waitingParentId) {
  985. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  986. light_1._waitingParentId = null;
  987. }
  988. }
  989. // Sounds
  990. var loadedSounds = [];
  991. var loadedSound;
  992. if (BABYLON.AudioEngine && parsedData.sounds !== undefined && parsedData.sounds !== null) {
  993. for (index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  994. var parsedSound = parsedData.sounds[index];
  995. if (BABYLON.Engine.audioEngine.canUseWebAudio) {
  996. if (!parsedSound.url)
  997. parsedSound.url = parsedSound.name;
  998. if (!loadedSounds[parsedSound.url]) {
  999. loadedSound = BABYLON.Sound.Parse(parsedSound, scene, rootUrl);
  1000. loadedSounds[parsedSound.url] = loadedSound;
  1001. }
  1002. else {
  1003. BABYLON.Sound.Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]);
  1004. }
  1005. }
  1006. else {
  1007. new BABYLON.Sound(parsedSound.name, null, scene);
  1008. }
  1009. }
  1010. }
  1011. loadedSounds = [];
  1012. // Connect parents & children and parse actions
  1013. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  1014. var transformNode = scene.transformNodes[index];
  1015. if (transformNode._waitingParentId) {
  1016. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  1017. transformNode._waitingParentId = null;
  1018. }
  1019. }
  1020. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  1021. var mesh = scene.meshes[index];
  1022. if (mesh._waitingParentId) {
  1023. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  1024. mesh._waitingParentId = null;
  1025. }
  1026. if (mesh._waitingActions) {
  1027. BABYLON.ActionManager.Parse(mesh._waitingActions, mesh, scene);
  1028. mesh._waitingActions = null;
  1029. }
  1030. }
  1031. // freeze world matrix application
  1032. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  1033. var currentMesh = scene.meshes[index];
  1034. if (currentMesh._waitingFreezeWorldMatrix) {
  1035. currentMesh.freezeWorldMatrix();
  1036. currentMesh._waitingFreezeWorldMatrix = null;
  1037. }
  1038. else {
  1039. currentMesh.computeWorldMatrix(true);
  1040. }
  1041. }
  1042. // Particles Systems
  1043. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  1044. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  1045. var parsedParticleSystem = parsedData.particleSystems[index];
  1046. BABYLON.ParticleSystem.Parse(parsedParticleSystem, scene, rootUrl);
  1047. }
  1048. }
  1049. // Environment texture
  1050. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  1051. scene.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  1052. if (parsedData.createDefaultSkybox === true) {
  1053. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  1054. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  1055. scene.createDefaultSkybox(undefined, true, skyboxScale, skyboxBlurLevel);
  1056. }
  1057. }
  1058. // Lens flares
  1059. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  1060. for (index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  1061. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  1062. BABYLON.LensFlareSystem.Parse(parsedLensFlareSystem, scene, rootUrl);
  1063. }
  1064. }
  1065. // Shadows
  1066. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  1067. for (index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  1068. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  1069. BABYLON.ShadowGenerator.Parse(parsedShadowGenerator, scene);
  1070. }
  1071. }
  1072. // Lights exclusions / inclusions
  1073. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  1074. var light_2 = scene.lights[index];
  1075. // Excluded check
  1076. if (light_2._excludedMeshesIds.length > 0) {
  1077. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  1078. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  1079. if (excludedMesh) {
  1080. light_2.excludedMeshes.push(excludedMesh);
  1081. }
  1082. }
  1083. light_2._excludedMeshesIds = [];
  1084. }
  1085. // Included check
  1086. if (light_2._includedOnlyMeshesIds.length > 0) {
  1087. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  1088. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  1089. if (includedOnlyMesh) {
  1090. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  1091. }
  1092. }
  1093. light_2._includedOnlyMeshesIds = [];
  1094. }
  1095. }
  1096. // Actions (scene)
  1097. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  1098. BABYLON.ActionManager.Parse(parsedData.actions, null, scene);
  1099. }
  1100. // Finish
  1101. return true;
  1102. }
  1103. catch (err) {
  1104. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  1105. if (onError) {
  1106. onError(msg, err);
  1107. }
  1108. else {
  1109. BABYLON.Tools.Log(msg);
  1110. throw err;
  1111. }
  1112. }
  1113. finally {
  1114. if (log !== null && BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.NO_LOGGING) {
  1115. BABYLON.Tools.Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (BABYLON.SceneLoader.loggingLevel !== BABYLON.SceneLoader.MINIMAL_LOGGING ? log : ""));
  1116. }
  1117. }
  1118. return false;
  1119. }
  1120. });
  1121. })(BABYLON || (BABYLON = {}));
  1122. //# sourceMappingURL=babylon.babylonFileLoader.js.map
  1123. var BABYLON;
  1124. (function (BABYLON) {
  1125. var FilesInput = /** @class */ (function () {
  1126. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  1127. this.onProcessFileCallback = function () { return true; };
  1128. this._engine = engine;
  1129. this._currentScene = scene;
  1130. this._sceneLoadedCallback = sceneLoadedCallback;
  1131. this._progressCallback = progressCallback;
  1132. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  1133. this._textureLoadingCallback = textureLoadingCallback;
  1134. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  1135. this._onReloadCallback = onReloadCallback;
  1136. this._errorCallback = errorCallback;
  1137. }
  1138. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  1139. var _this = this;
  1140. if (elementToMonitor) {
  1141. this._elementToMonitor = elementToMonitor;
  1142. this._dragEnterHandler = function (e) { _this.drag(e); };
  1143. this._dragOverHandler = function (e) { _this.drag(e); };
  1144. this._dropHandler = function (e) { _this.drop(e); };
  1145. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  1146. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  1147. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  1148. }
  1149. };
  1150. FilesInput.prototype.dispose = function () {
  1151. if (!this._elementToMonitor) {
  1152. return;
  1153. }
  1154. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  1155. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  1156. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  1157. };
  1158. FilesInput.prototype.renderFunction = function () {
  1159. if (this._additionalRenderLoopLogicCallback) {
  1160. this._additionalRenderLoopLogicCallback();
  1161. }
  1162. if (this._currentScene) {
  1163. if (this._textureLoadingCallback) {
  1164. var remaining = this._currentScene.getWaitingItemsCount();
  1165. if (remaining > 0) {
  1166. this._textureLoadingCallback(remaining);
  1167. }
  1168. }
  1169. this._currentScene.render();
  1170. }
  1171. };
  1172. FilesInput.prototype.drag = function (e) {
  1173. e.stopPropagation();
  1174. e.preventDefault();
  1175. };
  1176. FilesInput.prototype.drop = function (eventDrop) {
  1177. eventDrop.stopPropagation();
  1178. eventDrop.preventDefault();
  1179. this.loadFiles(eventDrop);
  1180. };
  1181. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  1182. var _this = this;
  1183. var reader = folder.createReader();
  1184. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  1185. reader.readEntries(function (entries) {
  1186. remaining.count += entries.length;
  1187. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  1188. var entry = entries_1[_i];
  1189. if (entry.isFile) {
  1190. entry.file(function (file) {
  1191. file.correctName = relativePath + file.name;
  1192. files.push(file);
  1193. if (--remaining.count === 0) {
  1194. callback();
  1195. }
  1196. });
  1197. }
  1198. else if (entry.isDirectory) {
  1199. _this._traverseFolder(entry, files, remaining, callback);
  1200. }
  1201. }
  1202. if (--remaining.count) {
  1203. callback();
  1204. }
  1205. });
  1206. };
  1207. FilesInput.prototype._processFiles = function (files) {
  1208. for (var i = 0; i < files.length; i++) {
  1209. var name = files[i].correctName.toLowerCase();
  1210. var extension = name.split('.').pop();
  1211. if (!this.onProcessFileCallback(files[i], name, extension)) {
  1212. continue;
  1213. }
  1214. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  1215. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  1216. this._sceneFileToLoad = files[i];
  1217. }
  1218. else {
  1219. FilesInput.FilesToLoad[name] = files[i];
  1220. }
  1221. }
  1222. };
  1223. FilesInput.prototype.loadFiles = function (event) {
  1224. var _this = this;
  1225. if (this._startingProcessingFilesCallback)
  1226. this._startingProcessingFilesCallback();
  1227. // Handling data transfer via drag'n'drop
  1228. if (event && event.dataTransfer && event.dataTransfer.files) {
  1229. this._filesToLoad = event.dataTransfer.files;
  1230. }
  1231. // Handling files from input files
  1232. if (event && event.target && event.target.files) {
  1233. this._filesToLoad = event.target.files;
  1234. }
  1235. if (this._filesToLoad && this._filesToLoad.length > 0) {
  1236. var files_1 = new Array();
  1237. var folders = [];
  1238. var items = event.dataTransfer ? event.dataTransfer.items : null;
  1239. for (var i = 0; i < this._filesToLoad.length; i++) {
  1240. var fileToLoad = this._filesToLoad[i];
  1241. var name_1 = fileToLoad.name.toLowerCase();
  1242. var entry = void 0;
  1243. fileToLoad.correctName = name_1;
  1244. if (items) {
  1245. var item = items[i];
  1246. if (item.getAsEntry) {
  1247. entry = item.getAsEntry();
  1248. }
  1249. else if (item.webkitGetAsEntry) {
  1250. entry = item.webkitGetAsEntry();
  1251. }
  1252. }
  1253. if (!entry) {
  1254. files_1.push(fileToLoad);
  1255. }
  1256. else {
  1257. if (entry.isDirectory) {
  1258. folders.push(entry);
  1259. }
  1260. else {
  1261. files_1.push(fileToLoad);
  1262. }
  1263. }
  1264. }
  1265. if (folders.length === 0) {
  1266. this._processFiles(files_1);
  1267. this._processReload();
  1268. }
  1269. else {
  1270. var remaining = { count: folders.length };
  1271. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  1272. var folder = folders_1[_i];
  1273. this._traverseFolder(folder, files_1, remaining, function () {
  1274. _this._processFiles(files_1);
  1275. if (remaining.count === 0) {
  1276. _this._processReload();
  1277. }
  1278. });
  1279. }
  1280. }
  1281. }
  1282. };
  1283. FilesInput.prototype._processReload = function () {
  1284. if (this._onReloadCallback) {
  1285. this._onReloadCallback(this._sceneFileToLoad);
  1286. }
  1287. else {
  1288. this.reload();
  1289. }
  1290. };
  1291. FilesInput.prototype.reload = function () {
  1292. var _this = this;
  1293. // If a scene file has been provided
  1294. if (this._sceneFileToLoad) {
  1295. if (this._currentScene) {
  1296. if (BABYLON.Tools.errorsCount > 0) {
  1297. BABYLON.Tools.ClearLogCache();
  1298. }
  1299. this._engine.stopRenderLoop();
  1300. this._currentScene.dispose();
  1301. }
  1302. BABYLON.SceneLoader.Load("file:", this._sceneFileToLoad, this._engine, function (newScene) {
  1303. _this._currentScene = newScene;
  1304. if (_this._sceneLoadedCallback) {
  1305. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  1306. }
  1307. // Wait for textures and shaders to be ready
  1308. _this._currentScene.executeWhenReady(function () {
  1309. _this._engine.runRenderLoop(function () {
  1310. _this.renderFunction();
  1311. });
  1312. });
  1313. }, function (progress) {
  1314. if (_this._progressCallback) {
  1315. _this._progressCallback(progress);
  1316. }
  1317. }, function (scene, message) {
  1318. _this._currentScene = scene;
  1319. if (_this._errorCallback) {
  1320. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, message);
  1321. }
  1322. });
  1323. }
  1324. else {
  1325. BABYLON.Tools.Error("Please provide a valid .babylon file.");
  1326. }
  1327. };
  1328. FilesInput.FilesToLoad = {};
  1329. return FilesInput;
  1330. }());
  1331. BABYLON.FilesInput = FilesInput;
  1332. })(BABYLON || (BABYLON = {}));
  1333. //# sourceMappingURL=babylon.filesInput.js.map
  1334. BABYLON.Effect.IncludesShadersStore['depthPrePass'] = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  1335. 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";
  1336. 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";
  1337. BABYLON.Effect.IncludesShadersStore['pointCloudVertexDeclaration'] = "#ifdef POINTSIZE\nuniform float pointSize;\n#endif";
  1338. BABYLON.Effect.IncludesShadersStore['bumpVertexDeclaration'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
  1339. BABYLON.Effect.IncludesShadersStore['clipPlaneVertexDeclaration'] = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif";
  1340. BABYLON.Effect.IncludesShadersStore['fogVertexDeclaration'] = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  1341. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexGlobalDeclaration'] = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  1342. 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";
  1343. BABYLON.Effect.IncludesShadersStore['logDepthDeclaration'] = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  1344. 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";
  1345. BABYLON.Effect.IncludesShadersStore['instancesVertex'] = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  1346. 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";
  1347. 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";
  1348. BABYLON.Effect.IncludesShadersStore['clipPlaneVertex'] = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif";
  1349. BABYLON.Effect.IncludesShadersStore['fogVertex'] = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  1350. 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";
  1351. BABYLON.Effect.IncludesShadersStore['pointCloudVertex'] = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  1352. BABYLON.Effect.IncludesShadersStore['logDepthVertex'] = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  1353. 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}";
  1354. 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";
  1355. 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";
  1356. 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";
  1357. 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";
  1358. 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";
  1359. 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};";
  1360. 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";
  1361. 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";
  1362. 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}";
  1363. 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";
  1364. 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}";
  1365. 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";
  1366. BABYLON.Effect.IncludesShadersStore['clipPlaneFragmentDeclaration'] = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif";
  1367. 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";
  1368. BABYLON.Effect.IncludesShadersStore['clipPlaneFragment'] = "#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif";
  1369. 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";
  1370. 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";
  1371. BABYLON.Effect.IncludesShadersStore['logDepthFragment'] = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  1372. BABYLON.Effect.IncludesShadersStore['fogFragment'] = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  1373. var DefaultLoadingScreen = BABYLON.DefaultLoadingScreen;
  1374. var SceneLoaderProgressEvent = BABYLON.SceneLoaderProgressEvent;
  1375. var SceneLoader = BABYLON.SceneLoader;
  1376. var FilesInput = BABYLON.FilesInput;
  1377. export { DefaultLoadingScreen,SceneLoaderProgressEvent,SceneLoader,FilesInput };