babylon.objFileLoader.min.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-loaders", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-loaders"] = factory(require("babylonjs"));
  8. else
  9. root["LOADERS"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy-objFileLoader.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../Tools/Gulp/node_modules/webpack/buildin/global.js":
  99. /*!************************************************************!*\
  100. !*** ../Tools/Gulp/node_modules/webpack/buildin/global.js ***!
  101. \************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || Function("return this")() || (1, eval)("this");
  112. } catch (e) {
  113. // This works if the window reference is available
  114. if (typeof window === "object") g = window;
  115. }
  116. // g can still be undefined, but nothing to do about it...
  117. // We return undefined, instead of nothing here, so it's
  118. // easier to handle this case. if(!global) { ...}
  119. module.exports = g;
  120. /***/ }),
  121. /***/ "./legacy/legacy-objFileLoader.ts":
  122. /*!****************************************!*\
  123. !*** ./legacy/legacy-objFileLoader.ts ***!
  124. \****************************************/
  125. /*! no static exports found */
  126. /***/ (function(module, exports, __webpack_require__) {
  127. "use strict";
  128. /* WEBPACK VAR INJECTION */(function(global) {
  129. function __export(m) {
  130. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  131. }
  132. Object.defineProperty(exports, "__esModule", { value: true });
  133. var Loaders = __webpack_require__(/*! ../src/OBJ */ "./src/OBJ/index.ts");
  134. /**
  135. * This is the entry point for the UMD module.
  136. * The entry point for a future ESM package should be index.ts
  137. */
  138. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  139. if (typeof globalObject !== "undefined") {
  140. for (var key in Loaders) {
  141. globalObject.BABYLON[key] = Loaders[key];
  142. }
  143. }
  144. __export(__webpack_require__(/*! ../src/OBJ */ "./src/OBJ/index.ts"));
  145. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../Tools/Gulp/node_modules/webpack/buildin/global.js */ "../Tools/Gulp/node_modules/webpack/buildin/global.js")))
  146. /***/ }),
  147. /***/ "./src/OBJ/index.ts":
  148. /*!**************************!*\
  149. !*** ./src/OBJ/index.ts ***!
  150. \**************************/
  151. /*! no static exports found */
  152. /***/ (function(module, exports, __webpack_require__) {
  153. "use strict";
  154. function __export(m) {
  155. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  156. }
  157. Object.defineProperty(exports, "__esModule", { value: true });
  158. __export(__webpack_require__(/*! ./objFileLoader */ "./src/OBJ/objFileLoader.ts"));
  159. /***/ }),
  160. /***/ "./src/OBJ/objFileLoader.ts":
  161. /*!**********************************!*\
  162. !*** ./src/OBJ/objFileLoader.ts ***!
  163. \**********************************/
  164. /*! no static exports found */
  165. /***/ (function(module, exports, __webpack_require__) {
  166. "use strict";
  167. Object.defineProperty(exports, "__esModule", { value: true });
  168. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  169. /**
  170. * Class reading and parsing the MTL file bundled with the obj file.
  171. */
  172. var MTLFileLoader = /** @class */ (function () {
  173. function MTLFileLoader() {
  174. // All material loaded from the mtl will be set here
  175. this.materials = [];
  176. }
  177. /**
  178. * This function will read the mtl file and create each material described inside
  179. * This function could be improve by adding :
  180. * -some component missing (Ni, Tf...)
  181. * -including the specific options available
  182. *
  183. * @param scene
  184. * @param data
  185. * @param rootUrl
  186. */
  187. MTLFileLoader.prototype.parseMTL = function (scene, data, rootUrl) {
  188. if (data instanceof ArrayBuffer) {
  189. return;
  190. }
  191. //Split the lines from the file
  192. var lines = data.split('\n');
  193. //Space char
  194. var delimiter_pattern = /\s+/;
  195. //Array with RGB colors
  196. var color;
  197. //New material
  198. var material = null;
  199. //Look at each line
  200. for (var i = 0; i < lines.length; i++) {
  201. var line = lines[i].trim();
  202. // Blank line or comment
  203. if (line.length === 0 || line.charAt(0) === '#') {
  204. continue;
  205. }
  206. //Get the first parameter (keyword)
  207. var pos = line.indexOf(' ');
  208. var key = (pos >= 0) ? line.substring(0, pos) : line;
  209. key = key.toLowerCase();
  210. //Get the data following the key
  211. var value = (pos >= 0) ? line.substring(pos + 1).trim() : "";
  212. //This mtl keyword will create the new material
  213. if (key === "newmtl") {
  214. //Check if it is the first material.
  215. // Materials specifications are described after this keyword.
  216. if (material) {
  217. //Add the previous material in the material array.
  218. this.materials.push(material);
  219. }
  220. //Create a new material.
  221. // value is the name of the material read in the mtl file
  222. material = new babylonjs_1.StandardMaterial(value, scene);
  223. }
  224. else if (key === "kd" && material) {
  225. // Diffuse color (color under white light) using RGB values
  226. //value = "r g b"
  227. color = value.split(delimiter_pattern, 3).map(parseFloat);
  228. //color = [r,g,b]
  229. //Set tghe color into the material
  230. material.diffuseColor = babylonjs_1.Color3.FromArray(color);
  231. }
  232. else if (key === "ka" && material) {
  233. // Ambient color (color under shadow) using RGB values
  234. //value = "r g b"
  235. color = value.split(delimiter_pattern, 3).map(parseFloat);
  236. //color = [r,g,b]
  237. //Set tghe color into the material
  238. material.ambientColor = babylonjs_1.Color3.FromArray(color);
  239. }
  240. else if (key === "ks" && material) {
  241. // Specular color (color when light is reflected from shiny surface) using RGB values
  242. //value = "r g b"
  243. color = value.split(delimiter_pattern, 3).map(parseFloat);
  244. //color = [r,g,b]
  245. //Set the color into the material
  246. material.specularColor = babylonjs_1.Color3.FromArray(color);
  247. }
  248. else if (key === "ke" && material) {
  249. // Emissive color using RGB values
  250. color = value.split(delimiter_pattern, 3).map(parseFloat);
  251. material.emissiveColor = babylonjs_1.Color3.FromArray(color);
  252. }
  253. else if (key === "ns" && material) {
  254. //value = "Integer"
  255. material.specularPower = parseFloat(value);
  256. }
  257. else if (key === "d" && material) {
  258. //d is dissolve for current material. It mean alpha for BABYLON
  259. material.alpha = parseFloat(value);
  260. //Texture
  261. //This part can be improved by adding the possible options of texture
  262. }
  263. else if (key === "map_ka" && material) {
  264. // ambient texture map with a loaded image
  265. //We must first get the folder of the image
  266. material.ambientTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  267. }
  268. else if (key === "map_kd" && material) {
  269. // Diffuse texture map with a loaded image
  270. material.diffuseTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  271. }
  272. else if (key === "map_ks" && material) {
  273. // Specular texture map with a loaded image
  274. //We must first get the folder of the image
  275. material.specularTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  276. }
  277. else if (key === "map_ns") {
  278. //Specular
  279. //Specular highlight component
  280. //We must first get the folder of the image
  281. //
  282. //Not supported by BABYLON
  283. //
  284. // continue;
  285. }
  286. else if (key === "map_bump" && material) {
  287. //The bump texture
  288. material.bumpTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  289. }
  290. else if (key === "map_d" && material) {
  291. // The dissolve of the material
  292. material.opacityTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  293. //Options for illumination
  294. }
  295. else if (key === "illum") {
  296. //Illumination
  297. if (value === "0") {
  298. //That mean Kd == Kd
  299. }
  300. else if (value === "1") {
  301. //Color on and Ambient on
  302. }
  303. else if (value === "2") {
  304. //Highlight on
  305. }
  306. else if (value === "3") {
  307. //Reflection on and Ray trace on
  308. }
  309. else if (value === "4") {
  310. //Transparency: Glass on, Reflection: Ray trace on
  311. }
  312. else if (value === "5") {
  313. //Reflection: Fresnel on and Ray trace on
  314. }
  315. else if (value === "6") {
  316. //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
  317. }
  318. else if (value === "7") {
  319. //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
  320. }
  321. else if (value === "8") {
  322. //Reflection on and Ray trace off
  323. }
  324. else if (value === "9") {
  325. //Transparency: Glass on, Reflection: Ray trace off
  326. }
  327. else if (value === "10") {
  328. //Casts shadows onto invisible surfaces
  329. }
  330. }
  331. else {
  332. // console.log("Unhandled expression at line : " + i +'\n' + "with value : " + line);
  333. }
  334. }
  335. //At the end of the file, add the last material
  336. if (material) {
  337. this.materials.push(material);
  338. }
  339. };
  340. /**
  341. * Gets the texture for the material.
  342. *
  343. * If the material is imported from input file,
  344. * We sanitize the url to ensure it takes the textre from aside the material.
  345. *
  346. * @param rootUrl The root url to load from
  347. * @param value The value stored in the mtl
  348. * @return The Texture
  349. */
  350. MTLFileLoader._getTexture = function (rootUrl, value, scene) {
  351. if (!value) {
  352. return null;
  353. }
  354. var url = rootUrl;
  355. // Load from input file.
  356. if (rootUrl === "file:") {
  357. var lastDelimiter = value.lastIndexOf("\\");
  358. if (lastDelimiter === -1) {
  359. lastDelimiter = value.lastIndexOf("/");
  360. }
  361. if (lastDelimiter > -1) {
  362. url += value.substr(lastDelimiter + 1);
  363. }
  364. else {
  365. url += value;
  366. }
  367. }
  368. // Not from input file.
  369. else {
  370. url += value;
  371. }
  372. return new babylonjs_1.Texture(url, scene);
  373. };
  374. return MTLFileLoader;
  375. }());
  376. exports.MTLFileLoader = MTLFileLoader;
  377. var OBJFileLoader = /** @class */ (function () {
  378. function OBJFileLoader() {
  379. this.name = "obj";
  380. this.extensions = ".obj";
  381. this.obj = /^o/;
  382. this.group = /^g/;
  383. this.mtllib = /^mtllib /;
  384. this.usemtl = /^usemtl /;
  385. this.smooth = /^s /;
  386. this.vertexPattern = /v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
  387. // vn float float float
  388. this.normalPattern = /vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
  389. // vt float float
  390. this.uvPattern = /vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
  391. // f vertex vertex vertex ...
  392. this.facePattern1 = /f\s+(([\d]{1,}[\s]?){3,})+/;
  393. // f vertex/uvs vertex/uvs vertex/uvs ...
  394. this.facePattern2 = /f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
  395. // f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal ...
  396. this.facePattern3 = /f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
  397. // f vertex//normal vertex//normal vertex//normal ...
  398. this.facePattern4 = /f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;
  399. // f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal ...
  400. this.facePattern5 = /f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/;
  401. }
  402. /**
  403. * Calls synchronously the MTL file attached to this obj.
  404. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  405. * Without this function materials are not displayed in the first frame (but displayed after).
  406. * In consequence it is impossible to get material information in your HTML file
  407. *
  408. * @param url The URL of the MTL file
  409. * @param rootUrl
  410. * @param onSuccess Callback function to be called when the MTL file is loaded
  411. * @private
  412. */
  413. OBJFileLoader.prototype._loadMTL = function (url, rootUrl, onSuccess) {
  414. //The complete path to the mtl file
  415. var pathOfFile = babylonjs_1.Tools.BaseUrl + rootUrl + url;
  416. // Loads through the babylon tools to allow fileInput search.
  417. babylonjs_1.Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, function () { console.warn("Error - Unable to load " + pathOfFile); });
  418. };
  419. /**
  420. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  421. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  422. * @param scene the scene the meshes should be added to
  423. * @param data the glTF data to load
  424. * @param rootUrl root url to load from
  425. * @param onProgress event that fires when loading progress has occured
  426. * @param fileName Defines the name of the file to load
  427. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  428. */
  429. OBJFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
  430. //get the meshes from OBJ file
  431. return this._parseSolid(meshesNames, scene, data, rootUrl).then(function (meshes) {
  432. return {
  433. meshes: meshes,
  434. particleSystems: [],
  435. skeletons: [],
  436. animationGroups: []
  437. };
  438. });
  439. };
  440. /**
  441. * Imports all objects from the loaded glTF data and adds them to the scene
  442. * @param scene the scene the objects should be added to
  443. * @param data the glTF data to load
  444. * @param rootUrl root url to load from
  445. * @param onProgress event that fires when loading progress has occured
  446. * @param fileName Defines the name of the file to load
  447. * @returns a promise which completes when objects have been loaded to the scene
  448. */
  449. OBJFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  450. //Get the 3D model
  451. return this.importMeshAsync(null, scene, data, rootUrl, onProgress).then(function () {
  452. // return void
  453. });
  454. };
  455. /**
  456. * Load into an asset container.
  457. * @param scene The scene to load into
  458. * @param data The data to import
  459. * @param rootUrl The root url for scene and resources
  460. * @param onProgress The callback when the load progresses
  461. * @param fileName Defines the name of the file to load
  462. * @returns The loaded asset container
  463. */
  464. OBJFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
  465. return this.importMeshAsync(null, scene, data, rootUrl).then(function (result) {
  466. var container = new babylonjs_1.AssetContainer(scene);
  467. result.meshes.forEach(function (mesh) { return container.meshes.push(mesh); });
  468. container.removeAllFromScene();
  469. return container;
  470. });
  471. };
  472. /**
  473. * Read the OBJ file and create an Array of meshes.
  474. * Each mesh contains all information given by the OBJ and the MTL file.
  475. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  476. *
  477. * @param meshesNames
  478. * @param scene Scene The scene where are displayed the data
  479. * @param data String The content of the obj file
  480. * @param rootUrl String The path to the folder
  481. * @returns Array<AbstractMesh>
  482. * @private
  483. */
  484. OBJFileLoader.prototype._parseSolid = function (meshesNames, scene, data, rootUrl) {
  485. var _this = this;
  486. var positions = []; //values for the positions of vertices
  487. var normals = []; //Values for the normals
  488. var uvs = []; //Values for the textures
  489. var meshesFromObj = []; //[mesh] Contains all the obj meshes
  490. var handledMesh; //The current mesh of meshes array
  491. var indicesForBabylon = []; //The list of indices for VertexData
  492. var wrappedPositionForBabylon = []; //The list of position in vectors
  493. var wrappedUvsForBabylon = []; //Array with all value of uvs to match with the indices
  494. var wrappedNormalsForBabylon = []; //Array with all value of normals to match with the indices
  495. var tuplePosNorm = []; //Create a tuple with indice of Position, Normal, UV [pos, norm, uvs]
  496. var curPositionInIndices = 0;
  497. var hasMeshes = false; //Meshes are defined in the file
  498. var unwrappedPositionsForBabylon = []; //Value of positionForBabylon w/o Vector3() [x,y,z]
  499. var unwrappedNormalsForBabylon = []; //Value of normalsForBabylon w/o Vector3() [x,y,z]
  500. var unwrappedUVForBabylon = []; //Value of uvsForBabylon w/o Vector3() [x,y,z]
  501. var triangles = []; //Indices from new triangles coming from polygons
  502. var materialNameFromObj = ""; //The name of the current material
  503. var fileToLoad = ""; //The name of the mtlFile to load
  504. var materialsFromMTLFile = new MTLFileLoader();
  505. var objMeshName = ""; //The name of the current obj mesh
  506. var increment = 1; //Id for meshes created by the multimaterial
  507. var isFirstMaterial = true;
  508. /**
  509. * Search for obj in the given array.
  510. * This function is called to check if a couple of data already exists in an array.
  511. *
  512. * If found, returns the index of the founded tuple index. Returns -1 if not found
  513. * @param arr Array<{ normals: Array<number>, idx: Array<number> }>
  514. * @param obj Array<number>
  515. * @returns {boolean}
  516. */
  517. var isInArray = function (arr, obj) {
  518. if (!arr[obj[0]]) {
  519. arr[obj[0]] = { normals: [], idx: [] };
  520. }
  521. var idx = arr[obj[0]].normals.indexOf(obj[1]);
  522. return idx === -1 ? -1 : arr[obj[0]].idx[idx];
  523. };
  524. var isInArrayUV = function (arr, obj) {
  525. if (!arr[obj[0]]) {
  526. arr[obj[0]] = { normals: [], idx: [], uv: [] };
  527. }
  528. var idx = arr[obj[0]].normals.indexOf(obj[1]);
  529. if (idx != 1 && (obj[2] == arr[obj[0]].uv[idx])) {
  530. return arr[obj[0]].idx[idx];
  531. }
  532. return -1;
  533. };
  534. /**
  535. * This function set the data for each triangle.
  536. * Data are position, normals and uvs
  537. * If a tuple of (position, normal) is not set, add the data into the corresponding array
  538. * If the tuple already exist, add only their indice
  539. *
  540. * @param indicePositionFromObj Integer The index in positions array
  541. * @param indiceUvsFromObj Integer The index in uvs array
  542. * @param indiceNormalFromObj Integer The index in normals array
  543. * @param positionVectorFromOBJ Vector3 The value of position at index objIndice
  544. * @param textureVectorFromOBJ Vector3 The value of uvs
  545. * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
  546. */
  547. var setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ) {
  548. //Check if this tuple already exists in the list of tuples
  549. var _index;
  550. if (OBJFileLoader.OPTIMIZE_WITH_UV) {
  551. _index = isInArrayUV(tuplePosNorm, [
  552. indicePositionFromObj,
  553. indiceNormalFromObj,
  554. indiceUvsFromObj
  555. ]);
  556. }
  557. else {
  558. _index = isInArray(tuplePosNorm, [
  559. indicePositionFromObj,
  560. indiceNormalFromObj
  561. ]);
  562. }
  563. //If it not exists
  564. if (_index == -1) {
  565. //Add an new indice.
  566. //The array of indices is only an array with his length equal to the number of triangles - 1.
  567. //We add vertices data in this order
  568. indicesForBabylon.push(wrappedPositionForBabylon.length);
  569. //Push the position of vertice for Babylon
  570. //Each element is a Vector3(x,y,z)
  571. wrappedPositionForBabylon.push(positionVectorFromOBJ);
  572. //Push the uvs for Babylon
  573. //Each element is a Vector3(u,v)
  574. wrappedUvsForBabylon.push(textureVectorFromOBJ);
  575. //Push the normals for Babylon
  576. //Each element is a Vector3(x,y,z)
  577. wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
  578. //Add the tuple in the comparison list
  579. tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
  580. tuplePosNorm[indicePositionFromObj].idx.push(curPositionInIndices++);
  581. if (OBJFileLoader.OPTIMIZE_WITH_UV) {
  582. tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);
  583. }
  584. }
  585. else {
  586. //The tuple already exists
  587. //Add the index of the already existing tuple
  588. //At this index we can get the value of position, normal and uvs of vertex
  589. indicesForBabylon.push(_index);
  590. }
  591. };
  592. /**
  593. * Transform Vector() object onto 3 digits in an array
  594. */
  595. var unwrapData = function () {
  596. //Every array has the same length
  597. for (var l = 0; l < wrappedPositionForBabylon.length; l++) {
  598. //Push the x, y, z values of each element in the unwrapped array
  599. unwrappedPositionsForBabylon.push(wrappedPositionForBabylon[l].x, wrappedPositionForBabylon[l].y, wrappedPositionForBabylon[l].z);
  600. unwrappedNormalsForBabylon.push(wrappedNormalsForBabylon[l].x, wrappedNormalsForBabylon[l].y, wrappedNormalsForBabylon[l].z);
  601. unwrappedUVForBabylon.push(wrappedUvsForBabylon[l].x, wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
  602. }
  603. // Reset arrays for the next new meshes
  604. wrappedPositionForBabylon = [];
  605. wrappedNormalsForBabylon = [];
  606. wrappedUvsForBabylon = [];
  607. tuplePosNorm = [];
  608. curPositionInIndices = 0;
  609. };
  610. /**
  611. * Create triangles from polygons by recursion
  612. * The best to understand how it works is to draw it in the same time you get the recursion.
  613. * It is important to notice that a triangle is a polygon
  614. * We get 5 patterns of face defined in OBJ File :
  615. * facePattern1 = ["1","2","3","4","5","6"]
  616. * facePattern2 = ["1/1","2/2","3/3","4/4","5/5","6/6"]
  617. * facePattern3 = ["1/1/1","2/2/2","3/3/3","4/4/4","5/5/5","6/6/6"]
  618. * facePattern4 = ["1//1","2//2","3//3","4//4","5//5","6//6"]
  619. * facePattern5 = ["-1/-1/-1","-2/-2/-2","-3/-3/-3","-4/-4/-4","-5/-5/-5","-6/-6/-6"]
  620. * Each pattern is divided by the same method
  621. * @param face Array[String] The indices of elements
  622. * @param v Integer The variable to increment
  623. */
  624. var getTriangles = function (face, v) {
  625. //Work for each element of the array
  626. if (v + 1 < face.length) {
  627. //Add on the triangle variable the indexes to obtain triangles
  628. triangles.push(face[0], face[v], face[v + 1]);
  629. //Incrementation for recursion
  630. v += 1;
  631. //Recursion
  632. getTriangles(face, v);
  633. }
  634. //Result obtained after 2 iterations:
  635. //Pattern1 => triangle = ["1","2","3","1","3","4"];
  636. //Pattern2 => triangle = ["1/1","2/2","3/3","1/1","3/3","4/4"];
  637. //Pattern3 => triangle = ["1/1/1","2/2/2","3/3/3","1/1/1","3/3/3","4/4/4"];
  638. //Pattern4 => triangle = ["1//1","2//2","3//3","1//1","3//3","4//4"];
  639. //Pattern5 => triangle = ["-1/-1/-1","-2/-2/-2","-3/-3/-3","-1/-1/-1","-3/-3/-3","-4/-4/-4"];
  640. };
  641. /**
  642. * Create triangles and push the data for each polygon for the pattern 1
  643. * In this pattern we get vertice positions
  644. * @param face
  645. * @param v
  646. */
  647. var setDataForCurrentFaceWithPattern1 = function (face, v) {
  648. //Get the indices of triangles for each polygon
  649. getTriangles(face, v);
  650. //For each element in the triangles array.
  651. //This var could contains 1 to an infinity of triangles
  652. for (var k = 0; k < triangles.length; k++) {
  653. // Set position indice
  654. var indicePositionFromObj = parseInt(triangles[k]) - 1;
  655. setData(indicePositionFromObj, 0, 0, //In the pattern 1, normals and uvs are not defined
  656. positions[indicePositionFromObj], //Get the vectors data
  657. babylonjs_1.Vector2.Zero(), babylonjs_1.Vector3.Up() //Create default vectors
  658. );
  659. }
  660. //Reset variable for the next line
  661. triangles = [];
  662. };
  663. /**
  664. * Create triangles and push the data for each polygon for the pattern 2
  665. * In this pattern we get vertice positions and uvsu
  666. * @param face
  667. * @param v
  668. */
  669. var setDataForCurrentFaceWithPattern2 = function (face, v) {
  670. //Get the indices of triangles for each polygon
  671. getTriangles(face, v);
  672. for (var k = 0; k < triangles.length; k++) {
  673. //triangle[k] = "1/1"
  674. //Split the data for getting position and uv
  675. var point = triangles[k].split("/"); // ["1", "1"]
  676. //Set position indice
  677. var indicePositionFromObj = parseInt(point[0]) - 1;
  678. //Set uv indice
  679. var indiceUvsFromObj = parseInt(point[1]) - 1;
  680. setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
  681. positions[indicePositionFromObj], //Get the values for each element
  682. uvs[indiceUvsFromObj], babylonjs_1.Vector3.Up() //Default value for normals
  683. );
  684. }
  685. //Reset variable for the next line
  686. triangles = [];
  687. };
  688. /**
  689. * Create triangles and push the data for each polygon for the pattern 3
  690. * In this pattern we get vertice positions, uvs and normals
  691. * @param face
  692. * @param v
  693. */
  694. var setDataForCurrentFaceWithPattern3 = function (face, v) {
  695. //Get the indices of triangles for each polygon
  696. getTriangles(face, v);
  697. for (var k = 0; k < triangles.length; k++) {
  698. //triangle[k] = "1/1/1"
  699. //Split the data for getting position, uv, and normals
  700. var point = triangles[k].split("/"); // ["1", "1", "1"]
  701. // Set position indice
  702. var indicePositionFromObj = parseInt(point[0]) - 1;
  703. // Set uv indice
  704. var indiceUvsFromObj = parseInt(point[1]) - 1;
  705. // Set normal indice
  706. var indiceNormalFromObj = parseInt(point[2]) - 1;
  707. setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
  708. );
  709. }
  710. //Reset variable for the next line
  711. triangles = [];
  712. };
  713. /**
  714. * Create triangles and push the data for each polygon for the pattern 4
  715. * In this pattern we get vertice positions and normals
  716. * @param face
  717. * @param v
  718. */
  719. var setDataForCurrentFaceWithPattern4 = function (face, v) {
  720. getTriangles(face, v);
  721. for (var k = 0; k < triangles.length; k++) {
  722. //triangle[k] = "1//1"
  723. //Split the data for getting position and normals
  724. var point = triangles[k].split("//"); // ["1", "1"]
  725. // We check indices, and normals
  726. var indicePositionFromObj = parseInt(point[0]) - 1;
  727. var indiceNormalFromObj = parseInt(point[1]) - 1;
  728. setData(indicePositionFromObj, 1, //Default value for uv
  729. indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
  730. babylonjs_1.Vector2.Zero(), normals[indiceNormalFromObj]);
  731. }
  732. //Reset variable for the next line
  733. triangles = [];
  734. };
  735. /**
  736. * Create triangles and push the data for each polygon for the pattern 3
  737. * In this pattern we get vertice positions, uvs and normals
  738. * @param face
  739. * @param v
  740. */
  741. var setDataForCurrentFaceWithPattern5 = function (face, v) {
  742. //Get the indices of triangles for each polygon
  743. getTriangles(face, v);
  744. for (var k = 0; k < triangles.length; k++) {
  745. //triangle[k] = "-1/-1/-1"
  746. //Split the data for getting position, uv, and normals
  747. var point = triangles[k].split("/"); // ["-1", "-1", "-1"]
  748. // Set position indice
  749. var indicePositionFromObj = positions.length + parseInt(point[0]);
  750. // Set uv indice
  751. var indiceUvsFromObj = uvs.length + parseInt(point[1]);
  752. // Set normal indice
  753. var indiceNormalFromObj = normals.length + parseInt(point[2]);
  754. setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
  755. );
  756. }
  757. //Reset variable for the next line
  758. triangles = [];
  759. };
  760. var addPreviousObjMesh = function () {
  761. //Check if it is not the first mesh. Otherwise we don't have data.
  762. if (meshesFromObj.length > 0) {
  763. //Get the previous mesh for applying the data about the faces
  764. //=> in obj file, faces definition append after the name of the mesh
  765. handledMesh = meshesFromObj[meshesFromObj.length - 1];
  766. //Set the data into Array for the mesh
  767. unwrapData();
  768. // Reverse tab. Otherwise face are displayed in the wrong sens
  769. indicesForBabylon.reverse();
  770. //Set the information for the mesh
  771. //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited
  772. handledMesh.indices = indicesForBabylon.slice();
  773. handledMesh.positions = unwrappedPositionsForBabylon.slice();
  774. handledMesh.normals = unwrappedNormalsForBabylon.slice();
  775. handledMesh.uvs = unwrappedUVForBabylon.slice();
  776. //Reset the array for the next mesh
  777. indicesForBabylon = [];
  778. unwrappedPositionsForBabylon = [];
  779. unwrappedNormalsForBabylon = [];
  780. unwrappedUVForBabylon = [];
  781. }
  782. };
  783. //Main function
  784. //Split the file into lines
  785. var lines = data.split('\n');
  786. //Look at each line
  787. for (var i = 0; i < lines.length; i++) {
  788. var line = lines[i].trim();
  789. var result;
  790. //Comment or newLine
  791. if (line.length === 0 || line.charAt(0) === '#') {
  792. continue;
  793. //Get information about one position possible for the vertices
  794. }
  795. else if ((result = this.vertexPattern.exec(line)) !== null) {
  796. //Create a Vector3 with the position x, y, z
  797. //Value of result:
  798. // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
  799. //Add the Vector in the list of positions
  800. positions.push(new babylonjs_1.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
  801. }
  802. else if ((result = this.normalPattern.exec(line)) !== null) {
  803. //Create a Vector3 with the normals x, y, z
  804. //Value of result
  805. // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
  806. //Add the Vector in the list of normals
  807. normals.push(new babylonjs_1.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
  808. }
  809. else if ((result = this.uvPattern.exec(line)) !== null) {
  810. //Create a Vector2 with the normals u, v
  811. //Value of result
  812. // ["vt 0.1 0.2 0.3", "0.1", "0.2"]
  813. //Add the Vector in the list of uvs
  814. uvs.push(new babylonjs_1.Vector2(parseFloat(result[1]), parseFloat(result[2])));
  815. //Identify patterns of faces
  816. //Face could be defined in different type of pattern
  817. }
  818. else if ((result = this.facePattern3.exec(line)) !== null) {
  819. //Value of result:
  820. //["f 1/1/1 2/2/2 3/3/3", "1/1/1 2/2/2 3/3/3"...]
  821. //Set the data for this face
  822. setDataForCurrentFaceWithPattern3(result[1].trim().split(" "), // ["1/1/1", "2/2/2", "3/3/3"]
  823. 1);
  824. }
  825. else if ((result = this.facePattern4.exec(line)) !== null) {
  826. //Value of result:
  827. //["f 1//1 2//2 3//3", "1//1 2//2 3//3"...]
  828. //Set the data for this face
  829. setDataForCurrentFaceWithPattern4(result[1].trim().split(" "), // ["1//1", "2//2", "3//3"]
  830. 1);
  831. }
  832. else if ((result = this.facePattern5.exec(line)) !== null) {
  833. //Value of result:
  834. //["f -1/-1/-1 -2/-2/-2 -3/-3/-3", "-1/-1/-1 -2/-2/-2 -3/-3/-3"...]
  835. //Set the data for this face
  836. setDataForCurrentFaceWithPattern5(result[1].trim().split(" "), // ["-1/-1/-1", "-2/-2/-2", "-3/-3/-3"]
  837. 1);
  838. }
  839. else if ((result = this.facePattern2.exec(line)) !== null) {
  840. //Value of result:
  841. //["f 1/1 2/2 3/3", "1/1 2/2 3/3"...]
  842. //Set the data for this face
  843. setDataForCurrentFaceWithPattern2(result[1].trim().split(" "), // ["1/1", "2/2", "3/3"]
  844. 1);
  845. }
  846. else if ((result = this.facePattern1.exec(line)) !== null) {
  847. //Value of result
  848. //["f 1 2 3", "1 2 3"...]
  849. //Set the data for this face
  850. setDataForCurrentFaceWithPattern1(result[1].trim().split(" "), // ["1", "2", "3"]
  851. 1);
  852. //Define a mesh or an object
  853. //Each time this keyword is analysed, create a new Object with all data for creating a babylonMesh
  854. }
  855. else if (this.group.test(line) || this.obj.test(line)) {
  856. //Create a new mesh corresponding to the name of the group.
  857. //Definition of the mesh
  858. var objMesh =
  859. //Set the name of the current obj mesh
  860. {
  861. name: line.substring(2).trim(),
  862. indices: undefined,
  863. positions: undefined,
  864. normals: undefined,
  865. uvs: undefined,
  866. materialName: ""
  867. };
  868. addPreviousObjMesh();
  869. //Push the last mesh created with only the name
  870. meshesFromObj.push(objMesh);
  871. //Set this variable to indicate that now meshesFromObj has objects defined inside
  872. hasMeshes = true;
  873. isFirstMaterial = true;
  874. increment = 1;
  875. //Keyword for applying a material
  876. }
  877. else if (this.usemtl.test(line)) {
  878. //Get the name of the material
  879. materialNameFromObj = line.substring(7).trim();
  880. //If this new material is in the same mesh
  881. if (!isFirstMaterial) {
  882. //Set the data for the previous mesh
  883. addPreviousObjMesh();
  884. //Create a new mesh
  885. var objMesh =
  886. //Set the name of the current obj mesh
  887. {
  888. name: objMeshName + "_mm" + increment.toString(),
  889. indices: undefined,
  890. positions: undefined,
  891. normals: undefined,
  892. uvs: undefined,
  893. materialName: materialNameFromObj
  894. };
  895. increment++;
  896. //If meshes are already defined
  897. meshesFromObj.push(objMesh);
  898. }
  899. //Set the material name if the previous line define a mesh
  900. if (hasMeshes && isFirstMaterial) {
  901. //Set the material name to the previous mesh (1 material per mesh)
  902. meshesFromObj[meshesFromObj.length - 1].materialName = materialNameFromObj;
  903. isFirstMaterial = false;
  904. }
  905. //Keyword for loading the mtl file
  906. }
  907. else if (this.mtllib.test(line)) {
  908. //Get the name of mtl file
  909. fileToLoad = line.substring(7).trim();
  910. //Apply smoothing
  911. }
  912. else if (this.smooth.test(line)) {
  913. // smooth shading => apply smoothing
  914. //Toda y I don't know it work with babylon and with obj.
  915. //With the obj file an integer is set
  916. }
  917. else {
  918. //If there is another possibility
  919. console.log("Unhandled expression at line : " + line);
  920. }
  921. }
  922. //At the end of the file, add the last mesh into the meshesFromObj array
  923. if (hasMeshes) {
  924. //Set the data for the last mesh
  925. handledMesh = meshesFromObj[meshesFromObj.length - 1];
  926. //Reverse indices for displaying faces in the good sens
  927. indicesForBabylon.reverse();
  928. //Get the good array
  929. unwrapData();
  930. //Set array
  931. handledMesh.indices = indicesForBabylon;
  932. handledMesh.positions = unwrappedPositionsForBabylon;
  933. handledMesh.normals = unwrappedNormalsForBabylon;
  934. handledMesh.uvs = unwrappedUVForBabylon;
  935. }
  936. //If any o or g keyword found, create a mesj with a random id
  937. if (!hasMeshes) {
  938. // reverse tab of indices
  939. indicesForBabylon.reverse();
  940. //Get positions normals uvs
  941. unwrapData();
  942. //Set data for one mesh
  943. meshesFromObj.push({
  944. name: babylonjs_1.Geometry.RandomId(),
  945. indices: indicesForBabylon,
  946. positions: unwrappedPositionsForBabylon,
  947. normals: unwrappedNormalsForBabylon,
  948. uvs: unwrappedUVForBabylon,
  949. materialName: materialNameFromObj
  950. });
  951. }
  952. //Create a Mesh list
  953. var babylonMeshesArray = []; //The mesh for babylon
  954. var materialToUse = new Array();
  955. //Set data for each mesh
  956. for (var j = 0; j < meshesFromObj.length; j++) {
  957. //check meshesNames (stlFileLoader)
  958. if (meshesNames && meshesFromObj[j].name) {
  959. if (meshesNames instanceof Array) {
  960. if (meshesNames.indexOf(meshesFromObj[j].name) == -1) {
  961. continue;
  962. }
  963. }
  964. else {
  965. if (meshesFromObj[j].name !== meshesNames) {
  966. continue;
  967. }
  968. }
  969. }
  970. //Get the current mesh
  971. //Set the data with VertexBuffer for each mesh
  972. handledMesh = meshesFromObj[j];
  973. //Create a Mesh with the name of the obj mesh
  974. var babylonMesh = new babylonjs_1.Mesh(meshesFromObj[j].name, scene);
  975. //Push the name of the material to an array
  976. //This is indispensable for the importMesh function
  977. materialToUse.push(meshesFromObj[j].materialName);
  978. var vertexData = new babylonjs_1.VertexData(); //The container for the values
  979. //Set the data for the babylonMesh
  980. vertexData.positions = handledMesh.positions;
  981. vertexData.normals = handledMesh.normals;
  982. vertexData.uvs = handledMesh.uvs;
  983. vertexData.indices = handledMesh.indices;
  984. //Set the data from the VertexBuffer to the current Mesh
  985. vertexData.applyToMesh(babylonMesh);
  986. if (OBJFileLoader.INVERT_Y) {
  987. babylonMesh.scaling.y *= -1;
  988. }
  989. //Push the mesh into an array
  990. babylonMeshesArray.push(babylonMesh);
  991. }
  992. var mtlPromises = [];
  993. //load the materials
  994. //Check if we have a file to load
  995. if (fileToLoad !== "") {
  996. //Load the file synchronously
  997. mtlPromises.push(new Promise(function (resolve, reject) {
  998. _this._loadMTL(fileToLoad, rootUrl, function (dataLoaded) {
  999. try {
  1000. //Create materials thanks MTLLoader function
  1001. materialsFromMTLFile.parseMTL(scene, dataLoaded, rootUrl);
  1002. //Look at each material loaded in the mtl file
  1003. for (var n = 0; n < materialsFromMTLFile.materials.length; n++) {
  1004. //Three variables to get all meshes with the same material
  1005. var startIndex = 0;
  1006. var _indices = [];
  1007. var _index;
  1008. //The material from MTL file is used in the meshes loaded
  1009. //Push the indice in an array
  1010. //Check if the material is not used for another mesh
  1011. while ((_index = materialToUse.indexOf(materialsFromMTLFile.materials[n].name, startIndex)) > -1) {
  1012. _indices.push(_index);
  1013. startIndex = _index + 1;
  1014. }
  1015. //If the material is not used dispose it
  1016. if (_index == -1 && _indices.length == 0) {
  1017. //If the material is not needed, remove it
  1018. materialsFromMTLFile.materials[n].dispose();
  1019. }
  1020. else {
  1021. for (var o = 0; o < _indices.length; o++) {
  1022. //Apply the material to the Mesh for each mesh with the material
  1023. babylonMeshesArray[_indices[o]].material = materialsFromMTLFile.materials[n];
  1024. }
  1025. }
  1026. }
  1027. resolve();
  1028. }
  1029. catch (e) {
  1030. reject(e);
  1031. }
  1032. });
  1033. }));
  1034. }
  1035. //Return an array with all Mesh
  1036. return Promise.all(mtlPromises).then(function () {
  1037. return babylonMeshesArray;
  1038. });
  1039. };
  1040. OBJFileLoader.OPTIMIZE_WITH_UV = false;
  1041. OBJFileLoader.INVERT_Y = false;
  1042. return OBJFileLoader;
  1043. }());
  1044. exports.OBJFileLoader = OBJFileLoader;
  1045. if (babylonjs_1.SceneLoader) {
  1046. //Add this loader into the register plugin
  1047. babylonjs_1.SceneLoader.RegisterPlugin(new OBJFileLoader());
  1048. }
  1049. /***/ }),
  1050. /***/ "babylonjs":
  1051. /*!****************************************************************************************************!*\
  1052. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  1053. \****************************************************************************************************/
  1054. /*! no static exports found */
  1055. /***/ (function(module, exports) {
  1056. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  1057. /***/ })
  1058. /******/ });
  1059. });
  1060. //# sourceMappingURL=babylon.objFileLoader.min.js.map