@babylonjs/loaders 5.0.0-alpha.9 → 5.0.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. package/OBJ/index.d.ts +2 -0
  2. package/OBJ/index.js +4 -2
  3. package/OBJ/index.js.map +1 -1
  4. package/OBJ/mtlFileLoader.d.ts +4 -2
  5. package/OBJ/mtlFileLoader.js +7 -6
  6. package/OBJ/mtlFileLoader.js.map +1 -1
  7. package/OBJ/objFileLoader.d.ts +12 -84
  8. package/OBJ/objFileLoader.js +50 -667
  9. package/OBJ/objFileLoader.js.map +1 -1
  10. package/OBJ/objLoadingOptions.d.ts +43 -0
  11. package/OBJ/objLoadingOptions.js +2 -0
  12. package/OBJ/objLoadingOptions.js.map +1 -0
  13. package/OBJ/solidParser.d.ts +153 -0
  14. package/OBJ/solidParser.js +700 -0
  15. package/OBJ/solidParser.js.map +1 -0
  16. package/STL/index.js +1 -1
  17. package/STL/stlFileLoader.d.ts +6 -0
  18. package/STL/stlFileLoader.js +38 -11
  19. package/STL/stlFileLoader.js.map +1 -1
  20. package/glTF/1.0/glTFBinaryExtension.js +4 -4
  21. package/glTF/1.0/glTFLoader.d.ts +4 -4
  22. package/glTF/1.0/glTFLoader.js +60 -55
  23. package/glTF/1.0/glTFLoader.js.map +1 -1
  24. package/glTF/1.0/glTFLoaderInterfaces.d.ts +3 -1
  25. package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
  26. package/glTF/1.0/glTFLoaderUtils.js +6 -6
  27. package/glTF/1.0/glTFMaterialsCommonExtension.js +12 -12
  28. package/glTF/1.0/index.js +5 -5
  29. package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -5
  30. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  31. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +3 -3
  32. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  33. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +1 -5
  34. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +5 -21
  35. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  36. package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
  37. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  38. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +1 -1
  39. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +8 -4
  40. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  41. package/glTF/2.0/Extensions/KHR_lights_punctual.js +9 -8
  42. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  43. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +2 -2
  44. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +30 -0
  45. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +46 -0
  46. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -0
  47. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +1 -2
  48. package/glTF/2.0/Extensions/KHR_materials_ior.js +3 -4
  49. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  50. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +3 -4
  51. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  52. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -1
  53. package/glTF/2.0/Extensions/KHR_materials_sheen.js +3 -4
  54. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +1 -2
  56. package/glTF/2.0/Extensions/KHR_materials_specular.js +12 -6
  57. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  58. package/glTF/2.0/Extensions/KHR_materials_translucency.js +6 -6
  59. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  60. package/glTF/2.0/Extensions/KHR_materials_transmission.js +93 -84
  61. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  62. package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
  63. package/glTF/2.0/Extensions/KHR_materials_variants.js +70 -5
  64. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  65. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +31 -0
  66. package/glTF/2.0/Extensions/KHR_materials_volume.js +79 -0
  67. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -0
  68. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +1 -1
  69. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +1 -2
  70. package/glTF/2.0/Extensions/KHR_texture_basisu.js +3 -4
  71. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  72. package/glTF/2.0/Extensions/KHR_texture_transform.js +2 -2
  73. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +2 -2
  74. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +6 -3
  75. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  76. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +6 -7
  77. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  78. package/glTF/2.0/Extensions/MSFT_lod.d.ts +2 -1
  79. package/glTF/2.0/Extensions/MSFT_lod.js +48 -8
  80. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  81. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +2 -2
  82. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +2 -2
  83. package/glTF/2.0/Extensions/index.d.ts +2 -0
  84. package/glTF/2.0/Extensions/index.js +26 -24
  85. package/glTF/2.0/Extensions/index.js.map +1 -1
  86. package/glTF/2.0/glTFLoader.d.ts +6 -11
  87. package/glTF/2.0/glTFLoader.js +129 -95
  88. package/glTF/2.0/glTFLoader.js.map +1 -1
  89. package/glTF/2.0/glTFLoaderInterfaces.d.ts +4 -2
  90. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  91. package/glTF/2.0/index.d.ts +1 -1
  92. package/glTF/2.0/index.js +4 -4
  93. package/glTF/2.0/index.js.map +1 -1
  94. package/glTF/glTFFileLoader.d.ts +15 -9
  95. package/glTF/glTFFileLoader.js +62 -76
  96. package/glTF/glTFFileLoader.js.map +1 -1
  97. package/glTF/glTFValidation.js +1 -1
  98. package/glTF/glTFValidation.js.map +1 -1
  99. package/glTF/index.d.ts +2 -2
  100. package/glTF/index.js +4 -4
  101. package/glTF/index.js.map +1 -1
  102. package/index.d.ts +3 -3
  103. package/index.js +3 -3
  104. package/index.js.map +1 -1
  105. package/legacy/legacy-glTF.js +4 -4
  106. package/legacy/legacy-glTF1.d.ts +1 -1
  107. package/legacy/legacy-glTF1.js +1 -1
  108. package/legacy/legacy-glTF1.js.map +1 -1
  109. package/legacy/legacy-glTF1FileLoader.js +2 -2
  110. package/legacy/legacy-glTF2.d.ts +1 -1
  111. package/legacy/legacy-glTF2.js +3 -3
  112. package/legacy/legacy-glTF2.js.map +1 -1
  113. package/legacy/legacy-glTF2FileLoader.js +2 -2
  114. package/legacy/legacy-glTFFileLoader.js +3 -3
  115. package/legacy/legacy-objFileLoader.d.ts +1 -1
  116. package/legacy/legacy-objFileLoader.js +2 -2
  117. package/legacy/legacy-objFileLoader.js.map +1 -1
  118. package/legacy/legacy-stlFileLoader.d.ts +1 -1
  119. package/legacy/legacy-stlFileLoader.js +2 -2
  120. package/legacy/legacy-stlFileLoader.js.map +1 -1
  121. package/legacy/legacy.js +6 -6
  122. package/package.json +16 -4
package/OBJ/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from "./mtlFileLoader";
2
+ export * from "./objLoadingOptions";
3
+ export * from "./solidParser";
2
4
  export * from "./objFileLoader";
package/OBJ/index.js CHANGED
@@ -1,3 +1,5 @@
1
- export * from "./mtlFileLoader";
2
- export * from "./objFileLoader";
1
+ export * from "./mtlFileLoader.js";
2
+ export * from "./objLoadingOptions.js";
3
+ export * from "./solidParser.js";
4
+ export * from "./objFileLoader.js";
3
5
  //# sourceMappingURL=index.js.map
package/OBJ/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/OBJ/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./mtlFileLoader\";\r\nexport * from \"./objFileLoader\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/OBJ/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./mtlFileLoader\";\r\nexport * from \"./objLoadingOptions\";\r\nexport * from \"./solidParser\";\r\nexport * from \"./objFileLoader\";\r\n"]}
@@ -1,5 +1,7 @@
1
+ import { Nullable } from "@babylonjs/core/types";
1
2
  import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial";
2
3
  import { Scene } from "@babylonjs/core/scene";
4
+ import { AssetContainer } from "@babylonjs/core/assetContainer";
3
5
  /**
4
6
  * Class reading and parsing the MTL file bundled with the obj file.
5
7
  */
@@ -21,9 +23,9 @@ export declare class MTLFileLoader {
21
23
  * @param scene defines the scene the material will be created in
22
24
  * @param data defines the mtl data to parse
23
25
  * @param rootUrl defines the rooturl to use in order to load relative dependencies
24
- * @param forAssetContainer defines if the material should be registered in the scene
26
+ * @param assetContainer defines the asset container to store the material in (can be null)
25
27
  */
26
- parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
28
+ parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, assetContainer: Nullable<AssetContainer>): void;
27
29
  /**
28
30
  * Gets the texture for the material.
29
31
  *
@@ -1,6 +1,6 @@
1
- import { Color3 } from '@babylonjs/core/Maths/math.color';
2
- import { Texture } from "@babylonjs/core/Materials/Textures/texture";
3
- import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial";
1
+ import { Color3 } from '@babylonjs/core/Maths/math.color.js';
2
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
3
+ import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
4
4
  /**
5
5
  * Class reading and parsing the MTL file bundled with the obj file.
6
6
  */
@@ -20,9 +20,9 @@ var MTLFileLoader = /** @class */ (function () {
20
20
  * @param scene defines the scene the material will be created in
21
21
  * @param data defines the mtl data to parse
22
22
  * @param rootUrl defines the rooturl to use in order to load relative dependencies
23
- * @param forAssetContainer defines if the material should be registered in the scene
23
+ * @param assetContainer defines the asset container to store the material in (can be null)
24
24
  */
25
- MTLFileLoader.prototype.parseMTL = function (scene, data, rootUrl, forAssetContainer) {
25
+ MTLFileLoader.prototype.parseMTL = function (scene, data, rootUrl, assetContainer) {
26
26
  if (data instanceof ArrayBuffer) {
27
27
  return;
28
28
  }
@@ -57,8 +57,9 @@ var MTLFileLoader = /** @class */ (function () {
57
57
  }
58
58
  //Create a new material.
59
59
  // value is the name of the material read in the mtl file
60
- scene._blockEntityCollection = forAssetContainer;
60
+ scene._blockEntityCollection = !!assetContainer;
61
61
  material = new StandardMaterial(value, scene);
62
+ material._parentContainer = assetContainer;
62
63
  scene._blockEntityCollection = false;
63
64
  }
64
65
  else if (key === "kd" && material) {
@@ -1 +1 @@
1
- {"version":3,"file":"mtlFileLoader.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/OBJ/mtlFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAG9E;;GAEG;AACH;IAAA;QAMI;;WAEG;QACI,cAAS,GAAuB,EAAE,CA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AAQ,CAAC,CAAC;SACjC;IACL,CAAC;IAED;;;;;;;;;OASG;IACY,yBAAW,GAA1B,UAA2B,OAAe,EAAE,KAAa,EAAE,KAAY;QACnE,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,IAAI,CAAC;SACf;QAED,IAAI,GAAG,GAAG,OAAO,CAAC;QAClB,wBAAwB;QACxB,IAAI,OAAO,KAAK,OAAO,EAAE;YACrB,IAAI,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE;gBACtB,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;aAC1C;YAED,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE;gBACpB,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;aAC1C;iBACI;gBACD,GAAG,IAAI,KAAK,CAAC;aAChB;SACJ;QACD,uBAAuB;aAClB;YACD,GAAG,IAAI,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,CAAC;IA1MF;;OAEG;IACW,8BAAgB,GAAG,IAAI,CAAC;IAwMzC,oBAAC;CAAA,AA5MD,IA4MC;SA5MY,aAAa","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\r\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\r\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial\";\r\n\r\nimport { Scene } from \"@babylonjs/core/scene\";\r\n/**\r\n * Class reading and parsing the MTL file bundled with the obj file.\r\n */\r\nexport class MTLFileLoader {\r\n /**\r\n * Invert Y-Axis of referenced textures on load\r\n */\r\n public static INVERT_TEXTURE_Y = true;\r\n\r\n /**\r\n * All material loaded from the mtl will be set here\r\n */\r\n public materials: StandardMaterial[] = [];\r\n\r\n /**\r\n * This function will read the mtl file and create each material described inside\r\n * This function could be improve by adding :\r\n * -some component missing (Ni, Tf...)\r\n * -including the specific options available\r\n *\r\n * @param scene defines the scene the material will be created in\r\n * @param data defines the mtl data to parse\r\n * @param rootUrl defines the rooturl to use in order to load relative dependencies\r\n * @param forAssetContainer defines if the material should be registered in the scene\r\n */\r\n public parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void {\r\n if (data instanceof ArrayBuffer) {\r\n return;\r\n }\r\n\r\n //Split the lines from the file\r\n var lines = data.split('\\n');\r\n //Space char\r\n var delimiter_pattern = /\\s+/;\r\n //Array with RGB colors\r\n var color: number[];\r\n //New material\r\n var material: Nullable<StandardMaterial> = null;\r\n\r\n //Look at each line\r\n for (var i = 0; i < lines.length; i++) {\r\n var line = lines[i].trim();\r\n\r\n // Blank line or comment\r\n if (line.length === 0 || line.charAt(0) === '#') {\r\n continue;\r\n }\r\n\r\n //Get the first parameter (keyword)\r\n var pos = line.indexOf(' ');\r\n var key = (pos >= 0) ? line.substring(0, pos) : line;\r\n key = key.toLowerCase();\r\n\r\n //Get the data following the key\r\n var value: string = (pos >= 0) ? line.substring(pos + 1).trim() : \"\";\r\n\r\n //This mtl keyword will create the new material\r\n if (key === \"newmtl\") {\r\n //Check if it is the first material.\r\n // Materials specifications are described after this keyword.\r\n if (material) {\r\n //Add the previous material in the material array.\r\n this.materials.push(material);\r\n }\r\n //Create a new material.\r\n // value is the name of the material read in the mtl file\r\n\r\n scene._blockEntityCollection = forAssetContainer;\r\n material = new StandardMaterial(value, scene);\r\n scene._blockEntityCollection = false;\r\n } else if (key === \"kd\" && material) {\r\n // Diffuse color (color under white light) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.diffuseColor = Color3.FromArray(color);\r\n } else if (key === \"ka\" && material) {\r\n // Ambient color (color under shadow) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.ambientColor = Color3.FromArray(color);\r\n } else if (key === \"ks\" && material) {\r\n // Specular color (color when light is reflected from shiny surface) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set the color into the material\r\n material.specularColor = Color3.FromArray(color);\r\n } else if (key === \"ke\" && material) {\r\n // Emissive color using RGB values\r\n color = value.split(delimiter_pattern, 3).map(parseFloat);\r\n material.emissiveColor = Color3.FromArray(color);\r\n } else if (key === \"ns\" && material) {\r\n\r\n //value = \"Integer\"\r\n material.specularPower = parseFloat(value);\r\n } else if (key === \"d\" && material) {\r\n //d is dissolve for current material. It mean alpha for BABYLON\r\n material.alpha = parseFloat(value);\r\n\r\n //Texture\r\n //This part can be improved by adding the possible options of texture\r\n } else if (key === \"map_ka\" && material) {\r\n // ambient texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.ambientTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_kd\" && material) {\r\n // Diffuse texture map with a loaded image\r\n material.diffuseTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ks\" && material) {\r\n // Specular texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.specularTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ns\") {\r\n //Specular\r\n //Specular highlight component\r\n //We must first get the folder of the image\r\n //\r\n //Not supported by BABYLON\r\n //\r\n // continue;\r\n } else if (key === \"map_bump\" && material) {\r\n //The bump texture\r\n material.bumpTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_d\" && material) {\r\n // The dissolve of the material\r\n material.opacityTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n\r\n //Options for illumination\r\n } else if (key === \"illum\") {\r\n //Illumination\r\n if (value === \"0\") {\r\n //That mean Kd == Kd\r\n } else if (value === \"1\") {\r\n //Color on and Ambient on\r\n } else if (value === \"2\") {\r\n //Highlight on\r\n } else if (value === \"3\") {\r\n //Reflection on and Ray trace on\r\n } else if (value === \"4\") {\r\n //Transparency: Glass on, Reflection: Ray trace on\r\n } else if (value === \"5\") {\r\n //Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"6\") {\r\n //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on\r\n } else if (value === \"7\") {\r\n //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"8\") {\r\n //Reflection on and Ray trace off\r\n } else if (value === \"9\") {\r\n //Transparency: Glass on, Reflection: Ray trace off\r\n } else if (value === \"10\") {\r\n //Casts shadows onto invisible surfaces\r\n }\r\n } else {\r\n // console.log(\"Unhandled expression at line : \" + i +'\\n' + \"with value : \" + line);\r\n }\r\n }\r\n //At the end of the file, add the last material\r\n if (material) {\r\n this.materials.push(material);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture for the material.\r\n *\r\n * If the material is imported from input file,\r\n * We sanitize the url to ensure it takes the textre from aside the material.\r\n *\r\n * @param rootUrl The root url to load from\r\n * @param value The value stored in the mtl\r\n * @return The Texture\r\n */\r\n private static _getTexture(rootUrl: string, value: string, scene: Scene): Nullable<Texture> {\r\n if (!value) {\r\n return null;\r\n }\r\n\r\n var url = rootUrl;\r\n // Load from input file.\r\n if (rootUrl === \"file:\") {\r\n var lastDelimiter = value.lastIndexOf(\"\\\\\");\r\n if (lastDelimiter === -1) {\r\n lastDelimiter = value.lastIndexOf(\"/\");\r\n }\r\n\r\n if (lastDelimiter > -1) {\r\n url += value.substr(lastDelimiter + 1);\r\n }\r\n else {\r\n url += value;\r\n }\r\n }\r\n // Not from input file.\r\n else {\r\n url += value;\r\n }\r\n\r\n return new Texture(url, scene, false, MTLFileLoader.INVERT_TEXTURE_Y);\r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MD,IA6MC;SA7MY,aAAa","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\r\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\r\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial\";\r\n\r\nimport { Scene } from \"@babylonjs/core/scene\";\r\nimport { AssetContainer } from \"@babylonjs/core/assetContainer\";\r\n/**\r\n * Class reading and parsing the MTL file bundled with the obj file.\r\n */\r\nexport class MTLFileLoader {\r\n /**\r\n * Invert Y-Axis of referenced textures on load\r\n */\r\n public static INVERT_TEXTURE_Y = true;\r\n\r\n /**\r\n * All material loaded from the mtl will be set here\r\n */\r\n public materials: StandardMaterial[] = [];\r\n\r\n /**\r\n * This function will read the mtl file and create each material described inside\r\n * This function could be improve by adding :\r\n * -some component missing (Ni, Tf...)\r\n * -including the specific options available\r\n *\r\n * @param scene defines the scene the material will be created in\r\n * @param data defines the mtl data to parse\r\n * @param rootUrl defines the rooturl to use in order to load relative dependencies\r\n * @param assetContainer defines the asset container to store the material in (can be null)\r\n */\r\n public parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, assetContainer: Nullable<AssetContainer>): void {\r\n if (data instanceof ArrayBuffer) {\r\n return;\r\n }\r\n\r\n //Split the lines from the file\r\n var lines = data.split('\\n');\r\n //Space char\r\n var delimiter_pattern = /\\s+/;\r\n //Array with RGB colors\r\n var color: number[];\r\n //New material\r\n var material: Nullable<StandardMaterial> = null;\r\n\r\n //Look at each line\r\n for (var i = 0; i < lines.length; i++) {\r\n var line = lines[i].trim();\r\n\r\n // Blank line or comment\r\n if (line.length === 0 || line.charAt(0) === '#') {\r\n continue;\r\n }\r\n\r\n //Get the first parameter (keyword)\r\n var pos = line.indexOf(' ');\r\n var key = (pos >= 0) ? line.substring(0, pos) : line;\r\n key = key.toLowerCase();\r\n\r\n //Get the data following the key\r\n var value: string = (pos >= 0) ? line.substring(pos + 1).trim() : \"\";\r\n\r\n //This mtl keyword will create the new material\r\n if (key === \"newmtl\") {\r\n //Check if it is the first material.\r\n // Materials specifications are described after this keyword.\r\n if (material) {\r\n //Add the previous material in the material array.\r\n this.materials.push(material);\r\n }\r\n //Create a new material.\r\n // value is the name of the material read in the mtl file\r\n\r\n scene._blockEntityCollection = !!assetContainer;\r\n material = new StandardMaterial(value, scene);\r\n material._parentContainer = assetContainer;\r\n scene._blockEntityCollection = false;\r\n } else if (key === \"kd\" && material) {\r\n // Diffuse color (color under white light) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.diffuseColor = Color3.FromArray(color);\r\n } else if (key === \"ka\" && material) {\r\n // Ambient color (color under shadow) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.ambientColor = Color3.FromArray(color);\r\n } else if (key === \"ks\" && material) {\r\n // Specular color (color when light is reflected from shiny surface) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set the color into the material\r\n material.specularColor = Color3.FromArray(color);\r\n } else if (key === \"ke\" && material) {\r\n // Emissive color using RGB values\r\n color = value.split(delimiter_pattern, 3).map(parseFloat);\r\n material.emissiveColor = Color3.FromArray(color);\r\n } else if (key === \"ns\" && material) {\r\n\r\n //value = \"Integer\"\r\n material.specularPower = parseFloat(value);\r\n } else if (key === \"d\" && material) {\r\n //d is dissolve for current material. It mean alpha for BABYLON\r\n material.alpha = parseFloat(value);\r\n\r\n //Texture\r\n //This part can be improved by adding the possible options of texture\r\n } else if (key === \"map_ka\" && material) {\r\n // ambient texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.ambientTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_kd\" && material) {\r\n // Diffuse texture map with a loaded image\r\n material.diffuseTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ks\" && material) {\r\n // Specular texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.specularTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ns\") {\r\n //Specular\r\n //Specular highlight component\r\n //We must first get the folder of the image\r\n //\r\n //Not supported by BABYLON\r\n //\r\n // continue;\r\n } else if (key === \"map_bump\" && material) {\r\n //The bump texture\r\n material.bumpTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n } else if (key === \"map_d\" && material) {\r\n // The dissolve of the material\r\n material.opacityTexture = MTLFileLoader._getTexture(rootUrl, value, scene);\r\n\r\n //Options for illumination\r\n } else if (key === \"illum\") {\r\n //Illumination\r\n if (value === \"0\") {\r\n //That mean Kd == Kd\r\n } else if (value === \"1\") {\r\n //Color on and Ambient on\r\n } else if (value === \"2\") {\r\n //Highlight on\r\n } else if (value === \"3\") {\r\n //Reflection on and Ray trace on\r\n } else if (value === \"4\") {\r\n //Transparency: Glass on, Reflection: Ray trace on\r\n } else if (value === \"5\") {\r\n //Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"6\") {\r\n //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on\r\n } else if (value === \"7\") {\r\n //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"8\") {\r\n //Reflection on and Ray trace off\r\n } else if (value === \"9\") {\r\n //Transparency: Glass on, Reflection: Ray trace off\r\n } else if (value === \"10\") {\r\n //Casts shadows onto invisible surfaces\r\n }\r\n } else {\r\n // console.log(\"Unhandled expression at line : \" + i +'\\n' + \"with value : \" + line);\r\n }\r\n }\r\n //At the end of the file, add the last material\r\n if (material) {\r\n this.materials.push(material);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture for the material.\r\n *\r\n * If the material is imported from input file,\r\n * We sanitize the url to ensure it takes the textre from aside the material.\r\n *\r\n * @param rootUrl The root url to load from\r\n * @param value The value stored in the mtl\r\n * @return The Texture\r\n */\r\n private static _getTexture(rootUrl: string, value: string, scene: Scene): Nullable<Texture> {\r\n if (!value) {\r\n return null;\r\n }\r\n\r\n var url = rootUrl;\r\n // Load from input file.\r\n if (rootUrl === \"file:\") {\r\n var lastDelimiter = value.lastIndexOf(\"\\\\\");\r\n if (lastDelimiter === -1) {\r\n lastDelimiter = value.lastIndexOf(\"/\");\r\n }\r\n\r\n if (lastDelimiter > -1) {\r\n url += value.substr(lastDelimiter + 1);\r\n }\r\n else {\r\n url += value;\r\n }\r\n }\r\n // Not from input file.\r\n else {\r\n url += value;\r\n }\r\n\r\n return new Texture(url, scene, false, MTLFileLoader.INVERT_TEXTURE_Y);\r\n }\r\n}\r\n"]}
@@ -2,48 +2,7 @@ import { Vector2 } from "@babylonjs/core/Maths/math.vector";
2
2
  import { ISceneLoaderPluginAsync, ISceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderAsyncResult } from "@babylonjs/core/Loading/sceneLoader";
3
3
  import { AssetContainer } from "@babylonjs/core/assetContainer";
4
4
  import { Scene } from "@babylonjs/core/scene";
5
- /**
6
- * Options for loading OBJ/MTL files
7
- */
8
- declare type MeshLoadOptions = {
9
- /**
10
- * Defines if UVs are optimized by default during load.
11
- */
12
- OptimizeWithUV: boolean;
13
- /**
14
- * Defines custom scaling of UV coordinates of loaded meshes.
15
- */
16
- UVScaling: Vector2;
17
- /**
18
- * Invert model on y-axis (does a model scaling inversion)
19
- */
20
- InvertY: boolean;
21
- /**
22
- * Invert Y-Axis of referenced textures on load
23
- */
24
- InvertTextureY: boolean;
25
- /**
26
- * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
27
- */
28
- ImportVertexColors: boolean;
29
- /**
30
- * Compute the normals for the model, even if normals are present in the file.
31
- */
32
- ComputeNormals: boolean;
33
- /**
34
- * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
35
- * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
36
- */
37
- OptimizeNormals: boolean;
38
- /**
39
- * Skip loading the materials even if defined in the OBJ file (materials are ignored).
40
- */
41
- SkipMaterials: boolean;
42
- /**
43
- * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
44
- */
45
- MaterialLoadingFailsSilently: boolean;
46
- };
5
+ import { OBJLoadingOptions } from "./objLoadingOptions";
47
6
  /**
48
7
  * OBJ file type loader.
49
8
  * This is a babylon scene loader plugin.
@@ -97,41 +56,15 @@ export declare class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoa
97
56
  * Defines the extension the plugin is able to load.
98
57
  */
99
58
  extensions: string;
100
- /** @hidden */
101
- obj: RegExp;
102
- /** @hidden */
103
- group: RegExp;
104
- /** @hidden */
105
- mtllib: RegExp;
106
- /** @hidden */
107
- usemtl: RegExp;
108
- /** @hidden */
109
- smooth: RegExp;
110
- /** @hidden */
111
- vertexPattern: RegExp;
112
- /** @hidden */
113
- normalPattern: RegExp;
114
- /** @hidden */
115
- uvPattern: RegExp;
116
- /** @hidden */
117
- facePattern1: RegExp;
118
- /** @hidden */
119
- facePattern2: RegExp;
120
- /** @hidden */
121
- facePattern3: RegExp;
122
- /** @hidden */
123
- facePattern4: RegExp;
124
- /** @hidden */
125
- facePattern5: RegExp;
126
- private _forAssetContainer;
127
- private _meshLoadOptions;
59
+ private _assetContainer;
60
+ private _loadingOptions;
128
61
  /**
129
62
  * Creates loader for .OBJ files
130
63
  *
131
- * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
64
+ * @param loadingOptions options for loading and parsing OBJ/MTL files.
132
65
  */
133
- constructor(meshLoadOptions?: MeshLoadOptions);
134
- private static get currentMeshLoadOptions();
66
+ constructor(loadingOptions?: OBJLoadingOptions);
67
+ private static get DefaultLoadingOptions();
135
68
  /**
136
69
  * Calls synchronously the MTL file attached to this obj.
137
70
  * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
@@ -139,9 +72,8 @@ export declare class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoa
139
72
  * In consequence it is impossible to get material information in your HTML file
140
73
  *
141
74
  * @param url The URL of the MTL file
142
- * @param rootUrl
75
+ * @param rootUrl defines where to load data from
143
76
  * @param onSuccess Callback function to be called when the MTL file is loaded
144
- * @private
145
77
  */
146
78
  private _loadMTL;
147
79
  /**
@@ -187,19 +119,15 @@ export declare class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoa
187
119
  * @returns The loaded asset container
188
120
  */
189
121
  loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
190
- private _optimizeNormals;
191
122
  /**
192
123
  * Read the OBJ file and create an Array of meshes.
193
124
  * Each mesh contains all information given by the OBJ and the MTL file.
194
125
  * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
195
- *
196
- * @param meshesNames
197
- * @param scene Scene The scene where are displayed the data
198
- * @param data String The content of the obj file
199
- * @param rootUrl String The path to the folder
200
- * @returns Array<AbstractMesh>
201
- * @private
126
+ * @param meshesNames defines a string or array of strings of the mesh names that should be loaded from the file
127
+ * @param scene defines the scene where are displayed the data
128
+ * @param data defines the content of the obj file
129
+ * @param rootUrl defines the path to the folder
130
+ * @returns the list of loaded meshes
202
131
  */
203
132
  private _parseSolid;
204
133
  }
205
- export {};