@babylonjs/loaders 5.0.0-alpha.8 → 5.0.0-beta.3

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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidParser.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/OBJ/solidParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,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BAAe,GAAG,IAAI,CAAC;IACrC,8BAA8B;IAChB,iCAAqB,GAAG,UAAU,CAAC;IACjD,gCAAgC;IAClB,4BAAgB,GAAG,UAAU,CAAC;IAC5C,wBAAwB;IACV,4BAAgB,GAAG,KAAK,CAAC;IAEvC,WAAW;IACX,sCAAsC;IACxB,yBAAa,GAAG,+BAA+B,CAAC;IAC9D,sCAAsC;IACxB,yBAAa,GAAG,uEAAuE,CAAC;IACtG,sCAAsC;IACxB,qBAAS,GAAG,iDAAiD,CAAC;IAC5E,2EAA2E;IAC7D,wBAAY,GAAG,4BAA4B,CAAC;IAC1D,wFAAwF;IAC1E,wBAAY,GAAG,wCAAwC,CAAC;IACtE,4GAA4G;IAC9F,wBAAY,GAAG,kDAAkD,CAAC;IAChF,mGAAmG;IACrF,wBAAY,GAAG,0CAA0C,CAAC;IACxE,qHAAqH;IACvG,wBAAY,GAAG,qDAAqD,CAAC;IAswBvF,kBAAC;CAAA,AAnyBD,IAmyBC;SAnyBY,WAAW","sourcesContent":["import { AssetContainer } from \"@babylonjs/core/assetContainer\";\r\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\r\nimport { Material } from \"@babylonjs/core/Materials/material\";\r\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial\";\r\nimport { Color3, Color4 } from \"@babylonjs/core/Maths/math.color\";\r\nimport { Vector2, Vector3 } from \"@babylonjs/core/Maths/math.vector\";\r\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\r\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry\";\r\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\r\nimport { VertexData } from \"@babylonjs/core/Meshes/mesh.vertexData\";\r\nimport { Scene } from \"@babylonjs/core/scene\";\r\nimport { FloatArray, IndicesArray, Nullable } from \"@babylonjs/core/types\";\r\nimport { OBJLoadingOptions } from \"./objLoadingOptions\";\r\n\r\ntype MeshObject = {\r\n name: string;\r\n indices?: Array<number>;\r\n positions?: Array<number>;\r\n normals?: Array<number>;\r\n colors?: Array<number>;\r\n uvs?: Array<number>;\r\n materialName: string;\r\n directMaterial?: Nullable<Material>;\r\n};\r\n\r\n/**\r\n * Class used to load mesh data from OBJ content\r\n */\r\nexport class SolidParser {\r\n // Descriptor\r\n /** Object descriptor */\r\n public static ObjectDescriptor = /^o/;\r\n /** Group descriptor */\r\n public static GroupDescriptor = /^g/;\r\n /** Material lib descriptor */\r\n public static MtlLibGroupDescriptor = /^mtllib /;\r\n /** Use a material descriptor */\r\n public static UseMtlDescriptor = /^usemtl /;\r\n /** Smooth descriptor */\r\n public static SmoothDescriptor = /^s /;\r\n\r\n // Patterns\r\n /** Pattern used to detect a vertex */\r\n public static VertexPattern = /v(\\s+[\\d|\\.|\\+|\\-|e|E]+){3,7}/;\r\n /** Pattern used to detect a normal */\r\n public static NormalPattern = /vn(\\s+[\\d|\\.|\\+|\\-|e|E]+)( +[\\d|\\.|\\+|\\-|e|E]+)( +[\\d|\\.|\\+|\\-|e|E]+)/;\r\n /** Pattern used to detect a UV set */\r\n public static UVPattern = /vt(\\s+[\\d|\\.|\\+|\\-|e|E]+)( +[\\d|\\.|\\+|\\-|e|E]+)/;\r\n /** Pattern used to detect a first kind of face (f vertex vertex vertex) */\r\n public static FacePattern1 = /f\\s+(([\\d]{1,}[\\s]?){3,})+/;\r\n /** Pattern used to detect a second kind of face (f vertex/uvs vertex/uvs vertex/uvs) */\r\n public static FacePattern2 = /f\\s+((([\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a third kind of face (f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal) */\r\n public static FacePattern3 = /f\\s+((([\\d]{1,}\\/[\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a fourth kind of face (f vertex//normal vertex//normal vertex//normal)*/\r\n public static FacePattern4 = /f\\s+((([\\d]{1,}\\/\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a fifth kind of face (f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal) */\r\n public static FacePattern5 = /f\\s+(((-[\\d]{1,}\\/-[\\d]{1,}\\/-[\\d]{1,}[\\s]?){3,})+)/;\r\n\r\n private _loadingOptions: OBJLoadingOptions;\r\n private _positions: Array<Vector3> = []; //values for the positions of vertices\r\n private _normals: Array<Vector3> = []; //Values for the normals\r\n private _uvs: Array<Vector2> = []; //Values for the textures\r\n private _colors: Array<Color4> = [];\r\n private _meshesFromObj: Array<MeshObject> = []; //[mesh] Contains all the obj meshes\r\n private _handledMesh: MeshObject; //The current mesh of meshes array\r\n private _indicesForBabylon: Array<number> = []; //The list of indices for VertexData\r\n private _wrappedPositionForBabylon: Array<Vector3> = []; //The list of position in vectors\r\n private _wrappedUvsForBabylon: Array<Vector2> = []; //Array with all value of uvs to match with the indices\r\n private _wrappedColorsForBabylon: Array<Color4> = []; // Array with all color values to match with the indices\r\n private _wrappedNormalsForBabylon: Array<Vector3> = []; //Array with all value of normals to match with the indices\r\n private _tuplePosNorm: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }> = []; //Create a tuple with indice of Position, Normal, UV [pos, norm, uvs]\r\n private _curPositionInIndices = 0;\r\n private _hasMeshes: Boolean = false; //Meshes are defined in the file\r\n private _unwrappedPositionsForBabylon: Array<number> = []; //Value of positionForBabylon w/o Vector3() [x,y,z]\r\n private _unwrappedColorsForBabylon: Array<number> = []; // Value of colorForBabylon w/o Color4() [r,g,b,a]\r\n private _unwrappedNormalsForBabylon: Array<number> = []; //Value of normalsForBabylon w/o Vector3() [x,y,z]\r\n private _unwrappedUVForBabylon: Array<number> = []; //Value of uvsForBabylon w/o Vector3() [x,y,z]\r\n private _triangles: Array<string> = []; //Indices from new triangles coming from polygons\r\n private _materialNameFromObj: string = \"\"; //The name of the current material\r\n private _objMeshName: string = \"\"; //The name of the current obj mesh\r\n private _increment: number = 1; //Id for meshes created by the multimaterial\r\n private _isFirstMaterial: boolean = true;\r\n private _grayColor = new Color4(0.5, 0.5, 0.5, 1);\r\n private _materialToUse: string[];\r\n private _babylonMeshesArray: Array<Mesh>;\r\n\r\n /**\r\n * Creates a new SolidParser\r\n * @param materialToUse defines the array to fill with the list of materials to use (it will be filled by the parse function)\r\n * @param babylonMeshesArray defines the array to fill with the list of loaded meshes (it will be filled by the parse function)\r\n * @param loadingOptions defines the loading options to use\r\n */\r\n public constructor(materialToUse: string[], babylonMeshesArray: Array<Mesh>, loadingOptions: OBJLoadingOptions) {\r\n this._materialToUse = materialToUse;\r\n this._babylonMeshesArray = babylonMeshesArray;\r\n this._loadingOptions = loadingOptions;\r\n }\r\n\r\n /**\r\n * Search for obj in the given array.\r\n * This function is called to check if a couple of data already exists in an array.\r\n *\r\n * If found, returns the index of the founded tuple index. Returns -1 if not found\r\n * @param arr Array<{ normals: Array<number>, idx: Array<number> }>\r\n * @param obj Array<number>\r\n * @returns {boolean}\r\n */\r\n private _isInArray(arr: Array<{ normals: Array<number>; idx: Array<number> }>, obj: Array<number>) {\r\n if (!arr[obj[0]]) { arr[obj[0]] = { normals: [], idx: [] }; }\r\n var idx = arr[obj[0]].normals.indexOf(obj[1]);\r\n\r\n return idx === -1 ? -1 : arr[obj[0]].idx[idx];\r\n }\r\n\r\n private _isInArrayUV(arr: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }>, obj: Array<number>) {\r\n if (!arr[obj[0]]) { arr[obj[0]] = { normals: [], idx: [], uv: [] }; }\r\n var idx = arr[obj[0]].normals.indexOf(obj[1]);\r\n\r\n if (idx != 1 && (obj[2] === arr[obj[0]].uv[idx])) {\r\n return arr[obj[0]].idx[idx];\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * This function set the data for each triangle.\r\n * Data are position, normals and uvs\r\n * If a tuple of (position, normal) is not set, add the data into the corresponding array\r\n * If the tuple already exist, add only their indice\r\n *\r\n * @param indicePositionFromObj Integer The index in positions array\r\n * @param indiceUvsFromObj Integer The index in uvs array\r\n * @param indiceNormalFromObj Integer The index in normals array\r\n * @param positionVectorFromOBJ Vector3 The value of position at index objIndice\r\n * @param textureVectorFromOBJ Vector3 The value of uvs\r\n * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale\r\n */\r\n private _setData(indicePositionFromObj: number, indiceUvsFromObj: number, indiceNormalFromObj: number, positionVectorFromOBJ: Vector3, textureVectorFromOBJ: Vector2, normalsVectorFromOBJ: Vector3, positionColorsFromOBJ?: Color4) {\r\n //Check if this tuple already exists in the list of tuples\r\n var _index: number;\r\n if (this._loadingOptions.optimizeWithUV) {\r\n _index = this._isInArrayUV(\r\n this._tuplePosNorm,\r\n [\r\n indicePositionFromObj,\r\n indiceNormalFromObj,\r\n indiceUvsFromObj\r\n ]\r\n );\r\n }\r\n else {\r\n _index = this._isInArray(\r\n this._tuplePosNorm,\r\n [\r\n indicePositionFromObj,\r\n indiceNormalFromObj\r\n ]\r\n );\r\n }\r\n\r\n //If it not exists\r\n if (_index === -1) {\r\n //Add an new indice.\r\n //The array of indices is only an array with his length equal to the number of triangles - 1.\r\n //We add vertices data in this order\r\n this._indicesForBabylon.push(this._wrappedPositionForBabylon.length);\r\n //Push the position of vertice for Babylon\r\n //Each element is a Vector3(x,y,z)\r\n this._wrappedPositionForBabylon.push(positionVectorFromOBJ);\r\n //Push the uvs for Babylon\r\n //Each element is a Vector3(u,v)\r\n this._wrappedUvsForBabylon.push(textureVectorFromOBJ);\r\n //Push the normals for Babylon\r\n //Each element is a Vector3(x,y,z)\r\n this._wrappedNormalsForBabylon.push(normalsVectorFromOBJ);\r\n\r\n if (positionColorsFromOBJ !== undefined) {\r\n //Push the colors for Babylon\r\n //Each element is a BABYLON.Color4(r,g,b,a)\r\n this._wrappedColorsForBabylon.push(positionColorsFromOBJ);\r\n }\r\n\r\n //Add the tuple in the comparison list\r\n this._tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);\r\n this._tuplePosNorm[indicePositionFromObj].idx.push(this._curPositionInIndices++);\r\n if (this._loadingOptions.optimizeWithUV) { this._tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj); }\r\n } else {\r\n //The tuple already exists\r\n //Add the index of the already existing tuple\r\n //At this index we can get the value of position, normal, color and uvs of vertex\r\n this._indicesForBabylon.push(_index);\r\n }\r\n }\r\n\r\n /**\r\n * Transform Vector() and BABYLON.Color() objects into numbers in an array\r\n */\r\n private _unwrapData() {\r\n //Every array has the same length\r\n for (var l = 0; l < this._wrappedPositionForBabylon.length; l++) {\r\n //Push the x, y, z values of each element in the unwrapped array\r\n this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[l].x, this._wrappedPositionForBabylon[l].y, this._wrappedPositionForBabylon[l].z);\r\n this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[l].x, this._wrappedNormalsForBabylon[l].y, this._wrappedNormalsForBabylon[l].z);\r\n this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[l].x, this._wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON\r\n if (this._loadingOptions.importVertexColors) {\r\n //Push the r, g, b, a values of each element in the unwrapped array\r\n this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[l].r, this._wrappedColorsForBabylon[l].g, this._wrappedColorsForBabylon[l].b, this._wrappedColorsForBabylon[l].a);\r\n }\r\n }\r\n // Reset arrays for the next new meshes\r\n this._wrappedPositionForBabylon = [];\r\n this._wrappedNormalsForBabylon = [];\r\n this._wrappedUvsForBabylon = [];\r\n this._wrappedColorsForBabylon = [];\r\n this._tuplePosNorm = [];\r\n this._curPositionInIndices = 0;\r\n }\r\n\r\n /**\r\n * Create triangles from polygons\r\n * It is important to notice that a triangle is a polygon\r\n * We get 5 patterns of face defined in OBJ File :\r\n * facePattern1 = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]\r\n * facePattern2 = [\"1/1\",\"2/2\",\"3/3\",\"4/4\",\"5/5\",\"6/6\"]\r\n * facePattern3 = [\"1/1/1\",\"2/2/2\",\"3/3/3\",\"4/4/4\",\"5/5/5\",\"6/6/6\"]\r\n * facePattern4 = [\"1//1\",\"2//2\",\"3//3\",\"4//4\",\"5//5\",\"6//6\"]\r\n * facePattern5 = [\"-1/-1/-1\",\"-2/-2/-2\",\"-3/-3/-3\",\"-4/-4/-4\",\"-5/-5/-5\",\"-6/-6/-6\"]\r\n * Each pattern is divided by the same method\r\n * @param face Array[String] The indices of elements\r\n * @param v Integer The variable to increment\r\n */\r\n private _getTriangles(faces: Array<string>, v: number) {\r\n //Work for each element of the array\r\n for (var faceIndex = v; faceIndex < faces.length - 1; faceIndex++) {\r\n //Add on the triangle variable the indexes to obtain triangles\r\n this._triangles.push(faces[0], faces[faceIndex], faces[faceIndex + 1]);\r\n }\r\n\r\n //Result obtained after 2 iterations:\r\n //Pattern1 => triangle = [\"1\",\"2\",\"3\",\"1\",\"3\",\"4\"];\r\n //Pattern2 => triangle = [\"1/1\",\"2/2\",\"3/3\",\"1/1\",\"3/3\",\"4/4\"];\r\n //Pattern3 => triangle = [\"1/1/1\",\"2/2/2\",\"3/3/3\",\"1/1/1\",\"3/3/3\",\"4/4/4\"];\r\n //Pattern4 => triangle = [\"1//1\",\"2//2\",\"3//3\",\"1//1\",\"3//3\",\"4//4\"];\r\n //Pattern5 => triangle = [\"-1/-1/-1\",\"-2/-2/-2\",\"-3/-3/-3\",\"-1/-1/-1\",\"-3/-3/-3\",\"-4/-4/-4\"];\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 1\r\n * In this pattern we get vertice positions\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern1(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n //For each element in the triangles array.\r\n //This var could contains 1 to an infinity of triangles\r\n for (var k = 0; k < this._triangles.length; k++) {\r\n // Set position indice\r\n var indicePositionFromObj = parseInt(this._triangles[k]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n 0, 0, // In the pattern 1, normals and uvs are not defined\r\n this._positions[indicePositionFromObj], // Get the vectors data\r\n Vector2.Zero(), Vector3.Up(), // Create default vectors\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles = [];\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 2\r\n * In this pattern we get vertice positions and uvsu\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern2(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n for (var k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1/1\"\r\n //Split the data for getting position and uv\r\n var point = this._triangles[k].split(\"/\"); // [\"1\", \"1\"]\r\n //Set position indice\r\n var indicePositionFromObj = parseInt(point[0]) - 1;\r\n //Set uv indice\r\n var indiceUvsFromObj = parseInt(point[1]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n 0, //Default value for normals\r\n this._positions[indicePositionFromObj], //Get the values for each element\r\n this._uvs[indiceUvsFromObj],\r\n Vector3.Up(), //Default value for normals\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n\r\n //Reset variable for the next line\r\n this._triangles = [];\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 3\r\n * In this pattern we get vertice positions, uvs and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern3(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n\r\n for (var k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1/1/1\"\r\n //Split the data for getting position, uv, and normals\r\n var point = this._triangles[k].split(\"/\"); // [\"1\", \"1\", \"1\"]\r\n // Set position indice\r\n var indicePositionFromObj = parseInt(point[0]) - 1;\r\n // Set uv indice\r\n var indiceUvsFromObj = parseInt(point[1]) - 1;\r\n // Set normal indice\r\n var indiceNormalFromObj = parseInt(point[2]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj,\r\n this._positions[indicePositionFromObj], this._uvs[indiceUvsFromObj], this._normals[indiceNormalFromObj] //Set the vector for each component\r\n );\r\n\r\n }\r\n //Reset variable for the next line\r\n this._triangles = [];\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 4\r\n * In this pattern we get vertice positions and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern4(face: Array<string>, v: number) {\r\n this._getTriangles(face, v);\r\n\r\n for (var k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1//1\"\r\n //Split the data for getting position and normals\r\n var point = this._triangles[k].split(\"//\"); // [\"1\", \"1\"]\r\n // We check indices, and normals\r\n var indicePositionFromObj = parseInt(point[0]) - 1;\r\n var indiceNormalFromObj = parseInt(point[1]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n 1, //Default value for uv\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj], //Get each vector of data\r\n Vector2.Zero(),\r\n this._normals[indiceNormalFromObj],\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles = [];\r\n }\r\n\r\n /*\r\n * Create triangles and push the data for each polygon for the pattern 3\r\n * In this pattern we get vertice positions, uvs and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern5(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n\r\n for (var k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"-1/-1/-1\"\r\n //Split the data for getting position, uv, and normals\r\n var point = this._triangles[k].split(\"/\"); // [\"-1\", \"-1\", \"-1\"]\r\n // Set position indice\r\n var indicePositionFromObj = this._positions.length + parseInt(point[0]);\r\n // Set uv indice\r\n var indiceUvsFromObj = this._uvs.length + parseInt(point[1]);\r\n // Set normal indice\r\n var indiceNormalFromObj = this._normals.length + parseInt(point[2]);\r\n\r\n this._setData(\r\n indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj,\r\n this._positions[indicePositionFromObj], this._uvs[indiceUvsFromObj], this._normals[indiceNormalFromObj], //Set the vector for each component\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n\r\n }\r\n //Reset variable for the next line\r\n this._triangles = [];\r\n }\r\n\r\n private _addPreviousObjMesh() {\r\n //Check if it is not the first mesh. Otherwise we don't have data.\r\n if (this._meshesFromObj.length > 0) {\r\n //Get the previous mesh for applying the data about the faces\r\n //=> in obj file, faces definition append after the name of the mesh\r\n this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];\r\n\r\n //Set the data into Array for the mesh\r\n this._unwrapData();\r\n\r\n // Reverse tab. Otherwise face are displayed in the wrong sens\r\n this._indicesForBabylon.reverse();\r\n //Set the information for the mesh\r\n //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited\r\n this._handledMesh.indices = this._indicesForBabylon.slice();\r\n this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice();\r\n this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice();\r\n this._handledMesh.uvs = this._unwrappedUVForBabylon.slice();\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n this._handledMesh.colors = this._unwrappedColorsForBabylon.slice();\r\n }\r\n\r\n //Reset the array for the next mesh\r\n this._indicesForBabylon = [];\r\n this._unwrappedPositionsForBabylon = [];\r\n this._unwrappedColorsForBabylon = [];\r\n this._unwrappedNormalsForBabylon = [];\r\n this._unwrappedUVForBabylon = [];\r\n }\r\n }\r\n\r\n private _optimizeNormals(mesh: AbstractMesh): void {\r\n const positions = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = mesh.getVerticesData(VertexBuffer.NormalKind);\r\n const mapVertices: { [key: string]: number[] } = {};\r\n\r\n if (!positions || !normals) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < positions.length / 3; i++) {\r\n const x = positions[i * 3 + 0];\r\n const y = positions[i * 3 + 1];\r\n const z = positions[i * 3 + 2];\r\n const key = x + \"_\" + y + \"_\" + z;\r\n\r\n let lst = mapVertices[key];\r\n if (!lst) {\r\n lst = [];\r\n mapVertices[key] = lst;\r\n }\r\n lst.push(i);\r\n }\r\n\r\n const normal = new Vector3();\r\n for (const key in mapVertices) {\r\n const lst = mapVertices[key];\r\n if (lst.length < 2) {\r\n continue;\r\n }\r\n\r\n const v0Idx = lst[0];\r\n for (let i = 1; i < lst.length; ++i) {\r\n const vIdx = lst[i];\r\n normals[v0Idx * 3 + 0] += normals[vIdx * 3 + 0];\r\n normals[v0Idx * 3 + 1] += normals[vIdx * 3 + 1];\r\n normals[v0Idx * 3 + 2] += normals[vIdx * 3 + 2];\r\n }\r\n\r\n normal.copyFromFloats(normals[v0Idx * 3 + 0], normals[v0Idx * 3 + 1], normals[v0Idx * 3 + 2]);\r\n normal.normalize();\r\n\r\n for (let i = 0; i < lst.length; ++i) {\r\n const vIdx = lst[i];\r\n normals[vIdx * 3 + 0] = normal.x;\r\n normals[vIdx * 3 + 1] = normal.y;\r\n normals[vIdx * 3 + 2] = normal.z;\r\n }\r\n }\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n }\r\n\r\n /**\r\n * Function used to parse an OBJ string\r\n * @param meshesNames defines the list of meshes to load (all if not defined)\r\n * @param data defines the OBJ string\r\n * @param scene defines the hosting scene\r\n * @param assetContainer defines the asset container to load data in\r\n * @param onFileToLoadFound defines a callback that will be called if a MTL file is found\r\n */\r\n public parse(\r\n meshesNames: any, data: string, scene: Scene, assetContainer: Nullable<AssetContainer>, onFileToLoadFound: (fileToLoad: string) => void): void {\r\n // Split the file into lines\r\n var lines = data.split('\\n');\r\n // Look at each line\r\n for (var i = 0; i < lines.length; i++) {\r\n var line = lines[i].trim().replace(/\\s\\s/g, \" \");\r\n var result;\r\n\r\n // Comment or newLine\r\n if (line.length === 0 || line.charAt(0) === '#') {\r\n continue;\r\n\r\n //Get information about one position possible for the vertices\r\n } else if (SolidParser.VertexPattern.test(line)) {\r\n result = line.match(/[^ ]+/g)!; // match will return non-null due to passing regex pattern\r\n\r\n // Value of result with line: \"v 1.0 2.0 3.0\"\r\n // [\"v\", \"1.0\", \"2.0\", \"3.0\"]\r\n // Create a Vector3 with the position x, y, z\r\n this._positions.push(new Vector3(\r\n parseFloat(result[1]),\r\n parseFloat(result[2]),\r\n parseFloat(result[3])\r\n ));\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n if (result.length >= 7) {\r\n const r = parseFloat(result[4]);\r\n const g = parseFloat(result[5]);\r\n const b = parseFloat(result[6]);\r\n\r\n this._colors.push(new Color4(\r\n r > 1 ? r / 255 : r,\r\n g > 1 ? g / 255 : g,\r\n b > 1 ? b / 255 : b,\r\n (result.length === 7 || result[7] === undefined) ? 1 : parseFloat(result[7])\r\n ));\r\n } else {\r\n // TODO: maybe push NULL and if all are NULL to skip (and remove grayColor var).\r\n this._colors.push(this._grayColor);\r\n }\r\n }\r\n\r\n } else if ((result = SolidParser.NormalPattern.exec(line)) !== null) {\r\n //Create a Vector3 with the normals x, y, z\r\n //Value of result\r\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\r\n //Add the Vector in the list of normals\r\n this._normals.push(new Vector3(\r\n parseFloat(result[1]),\r\n parseFloat(result[2]),\r\n parseFloat(result[3])\r\n ));\r\n\r\n } else if ((result = SolidParser.UVPattern.exec(line)) !== null) {\r\n //Create a Vector2 with the normals u, v\r\n //Value of result\r\n // [\"vt 0.1 0.2 0.3\", \"0.1\", \"0.2\"]\r\n //Add the Vector in the list of uvs\r\n this._uvs.push(new Vector2(\r\n parseFloat(result[1]) * this._loadingOptions.UVScaling.x,\r\n parseFloat(result[2]) * this._loadingOptions.UVScaling.y\r\n ));\r\n\r\n //Identify patterns of faces\r\n //Face could be defined in different type of pattern\r\n } else if ((result = SolidParser.FacePattern3.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1/1/1 2/2/2 3/3/3\", \"1/1/1 2/2/2 3/3/3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern3(\r\n result[1].trim().split(\" \"), // [\"1/1/1\", \"2/2/2\", \"3/3/3\"]\r\n 1\r\n );\r\n\r\n } else if ((result = SolidParser.FacePattern4.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1//1 2//2 3//3\", \"1//1 2//2 3//3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern4(\r\n result[1].trim().split(\" \"), // [\"1//1\", \"2//2\", \"3//3\"]\r\n 1\r\n );\r\n\r\n } else if ((result = SolidParser.FacePattern5.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f -1/-1/-1 -2/-2/-2 -3/-3/-3\", \"-1/-1/-1 -2/-2/-2 -3/-3/-3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern5(\r\n result[1].trim().split(\" \"), // [\"-1/-1/-1\", \"-2/-2/-2\", \"-3/-3/-3\"]\r\n 1\r\n );\r\n\r\n } else if ((result = SolidParser.FacePattern2.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1/1 2/2 3/3\", \"1/1 2/2 3/3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern2(\r\n result[1].trim().split(\" \"), // [\"1/1\", \"2/2\", \"3/3\"]\r\n 1\r\n );\r\n\r\n } else if ((result = SolidParser.FacePattern1.exec(line)) !== null) {\r\n //Value of result\r\n //[\"f 1 2 3\", \"1 2 3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern1(\r\n result[1].trim().split(\" \"), // [\"1\", \"2\", \"3\"]\r\n 1\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analysed, create a new Object with all data for creating a babylonMesh\r\n } else if (SolidParser.GroupDescriptor.test(line) || SolidParser.ObjectDescriptor.test(line)) {\r\n // Create a new mesh corresponding to the name of the group.\r\n // Definition of the mesh\r\n var objMesh: MeshObject = {\r\n name: line.substring(2).trim(), //Set the name of the current obj mesh\r\n indices: undefined,\r\n positions: undefined,\r\n normals: undefined,\r\n uvs: undefined,\r\n colors: undefined,\r\n materialName: \"\"\r\n };\r\n this._addPreviousObjMesh();\r\n\r\n //Push the last mesh created with only the name\r\n this._meshesFromObj.push(objMesh);\r\n\r\n //Set this variable to indicate that now meshesFromObj has objects defined inside\r\n this._hasMeshes = true;\r\n this._isFirstMaterial = true;\r\n this._increment = 1;\r\n //Keyword for applying a material\r\n } else if (SolidParser.UseMtlDescriptor.test(line)) {\r\n //Get the name of the material\r\n this._materialNameFromObj = line.substring(7).trim();\r\n\r\n //If this new material is in the same mesh\r\n\r\n if (!this._isFirstMaterial || !this._hasMeshes) {\r\n //Set the data for the previous mesh\r\n this._addPreviousObjMesh();\r\n //Create a new mesh\r\n var objMesh: MeshObject =\r\n //Set the name of the current obj mesh\r\n {\r\n name: (this._objMeshName || \"mesh\") + \"_mm\" + this._increment.toString(), //Set the name of the current obj mesh\r\n indices: undefined,\r\n positions: undefined,\r\n normals: undefined,\r\n uvs: undefined,\r\n colors: undefined,\r\n materialName: this._materialNameFromObj\r\n };\r\n this._increment++;\r\n //If meshes are already defined\r\n this._meshesFromObj.push(objMesh);\r\n this._hasMeshes = true;\r\n }\r\n //Set the material name if the previous line define a mesh\r\n\r\n if (this._hasMeshes && this._isFirstMaterial) {\r\n //Set the material name to the previous mesh (1 material per mesh)\r\n this._meshesFromObj[this._meshesFromObj.length - 1].materialName = this._materialNameFromObj;\r\n this._isFirstMaterial = false;\r\n }\r\n // Keyword for loading the mtl file\r\n } else if (SolidParser.MtlLibGroupDescriptor.test(line)) {\r\n // Get the name of mtl file\r\n onFileToLoadFound(line.substring(7).trim());\r\n\r\n // Apply smoothing\r\n } else if (SolidParser.SmoothDescriptor.test(line)) {\r\n // smooth shading => apply smoothing\r\n // Today I don't know it work with babylon and with obj.\r\n // With the obj file an integer is set\r\n } else {\r\n //If there is another possibility\r\n console.log(\"Unhandled expression at line : \" + line);\r\n }\r\n }\r\n\r\n // At the end of the file, add the last mesh into the meshesFromObj array\r\n if (this._hasMeshes) {\r\n // Set the data for the last mesh\r\n this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];\r\n\r\n //Reverse indices for displaying faces in the good sense\r\n this._indicesForBabylon.reverse();\r\n //Get the good array\r\n this._unwrapData();\r\n //Set array\r\n this._handledMesh.indices = this._indicesForBabylon;\r\n this._handledMesh.positions = this._unwrappedPositionsForBabylon;\r\n this._handledMesh.normals = this._unwrappedNormalsForBabylon;\r\n this._handledMesh.uvs = this._unwrappedUVForBabylon;\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n this._handledMesh.colors = this._unwrappedColorsForBabylon;\r\n }\r\n }\r\n\r\n // If any o or g keyword not found, create a mesh with a random id\r\n if (!this._hasMeshes) {\r\n let newMaterial: Nullable<StandardMaterial> = null;\r\n if (this._indicesForBabylon.length) {\r\n // reverse tab of indices\r\n this._indicesForBabylon.reverse();\r\n //Get positions normals uvs\r\n this._unwrapData();\r\n } else {\r\n // There is no indices in the file. We will have to switch to point cloud rendering\r\n for (var pos of this._positions) {\r\n this._unwrappedPositionsForBabylon.push(pos.x, pos.y, pos.z);\r\n }\r\n\r\n if (this._normals.length) {\r\n for (var normal of this._normals) {\r\n this._unwrappedNormalsForBabylon.push(normal.x, normal.y, normal.z);\r\n }\r\n }\r\n\r\n if (this._uvs.length) {\r\n for (var uv of this._uvs) {\r\n this._unwrappedUVForBabylon.push(uv.x, uv.y);\r\n }\r\n }\r\n\r\n if (this._colors.length) {\r\n for (var color of this._colors) {\r\n this._unwrappedColorsForBabylon.push(color.r, color.g, color.b, color.a);\r\n }\r\n }\r\n\r\n if (!this._materialNameFromObj) {\r\n // Create a material with point cloud on\r\n newMaterial = new StandardMaterial(Geometry.RandomId(), scene);\r\n\r\n newMaterial.pointsCloud = true;\r\n\r\n this._materialNameFromObj = newMaterial.name;\r\n\r\n if (!this._normals.length) {\r\n newMaterial.disableLighting = true;\r\n newMaterial.emissiveColor = Color3.White();\r\n }\r\n }\r\n }\r\n\r\n //Set data for one mesh\r\n this._meshesFromObj.push({\r\n name: Geometry.RandomId(),\r\n indices: this._indicesForBabylon,\r\n positions: this._unwrappedPositionsForBabylon,\r\n colors: this._unwrappedColorsForBabylon,\r\n normals: this._unwrappedNormalsForBabylon,\r\n uvs: this._unwrappedUVForBabylon,\r\n materialName: this._materialNameFromObj,\r\n directMaterial: newMaterial\r\n });\r\n }\r\n\r\n //Set data for each mesh\r\n for (var j = 0; j < this._meshesFromObj.length; j++) {\r\n\r\n //check meshesNames (stlFileLoader)\r\n if (meshesNames && this._meshesFromObj[j].name) {\r\n if (meshesNames instanceof Array) {\r\n if (meshesNames.indexOf(this._meshesFromObj[j].name) === -1) {\r\n continue;\r\n }\r\n }\r\n else {\r\n if (this._meshesFromObj[j].name !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n //Get the current mesh\r\n //Set the data with VertexBuffer for each mesh\r\n this._handledMesh = this._meshesFromObj[j];\r\n //Create a Mesh with the name of the obj mesh\r\n\r\n scene._blockEntityCollection = !!assetContainer;\r\n var babylonMesh = new Mesh(this._meshesFromObj[j].name, scene);\r\n babylonMesh._parentContainer = assetContainer;\r\n scene._blockEntityCollection = false;\r\n\r\n //Push the name of the material to an array\r\n //This is indispensable for the importMesh function\r\n this._materialToUse.push(this._meshesFromObj[j].materialName);\r\n\r\n if (this._handledMesh.positions?.length === 0) {\r\n //Push the mesh into an array\r\n this._babylonMeshesArray.push(babylonMesh);\r\n continue;\r\n }\r\n\r\n var vertexData: VertexData = new VertexData(); //The container for the values\r\n //Set the data for the babylonMesh\r\n vertexData.uvs = this._handledMesh.uvs as FloatArray;\r\n vertexData.indices = this._handledMesh.indices as IndicesArray;\r\n vertexData.positions = this._handledMesh.positions as FloatArray;\r\n if (this._loadingOptions.computeNormals) {\r\n let normals: Array<number> = new Array<number>();\r\n VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, normals);\r\n vertexData.normals = normals;\r\n } else {\r\n vertexData.normals = this._handledMesh.normals as FloatArray;\r\n }\r\n if (this._loadingOptions.importVertexColors) {\r\n vertexData.colors = this._handledMesh.colors as FloatArray;\r\n }\r\n //Set the data from the VertexBuffer to the current Mesh\r\n vertexData.applyToMesh(babylonMesh);\r\n if (this._loadingOptions.invertY) {\r\n babylonMesh.scaling.y *= -1;\r\n }\r\n if (this._loadingOptions.optimizeNormals) {\r\n this._optimizeNormals(babylonMesh);\r\n }\r\n\r\n //Push the mesh into an array\r\n this._babylonMeshesArray.push(babylonMesh);\r\n\r\n if (this._handledMesh.directMaterial) {\r\n babylonMesh.material = this._handledMesh.directMaterial;\r\n }\r\n }\r\n }\r\n}"]}
package/STL/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./stlFileLoader";
1
+ export * from "./stlFileLoader.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -28,6 +28,12 @@ export declare class STLFileLoader implements ISceneLoaderPlugin {
28
28
  * we'll convert to string if it looks like it's an ASCII .stl
29
29
  */
30
30
  extensions: ISceneLoaderPluginExtensions;
31
+ /**
32
+ * Defines if Y and Z axes are swapped or not when loading an STL file.
33
+ * The default is false to maintain backward compatibility. When set to
34
+ * true, coordinates from the STL file are used without change.
35
+ */
36
+ static DO_NOT_ALTER_FILE_COORDINATES: boolean;
31
37
  /**
32
38
  * Import meshes into a scene.
33
39
  * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
@@ -1,8 +1,8 @@
1
- import { Tools } from "@babylonjs/core/Misc/tools";
2
- import { VertexBuffer } from "@babylonjs/core/Meshes/buffer";
3
- import { Mesh } from "@babylonjs/core/Meshes/mesh";
4
- import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader";
5
- import { AssetContainer } from "@babylonjs/core/assetContainer";
1
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
2
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
3
+ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
4
+ import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
5
+ import { AssetContainer } from "@babylonjs/core/assetContainer.js";
6
6
  /**
7
7
  * STL file type loader.
8
8
  * This is a babylon scene loader plugin.
@@ -125,6 +125,11 @@ var STLFileLoader = /** @class */ (function () {
125
125
  // check if file size is correct for binary stl
126
126
  var faceSize, nFaces, reader;
127
127
  reader = new DataView(data);
128
+ // A Binary STL header is 80 bytes, if the data size is not great than
129
+ // that then it's not a binary STL.
130
+ if (reader.byteLength <= 80) {
131
+ return false;
132
+ }
128
133
  faceSize = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
129
134
  nFaces = reader.getUint32(80, true);
130
135
  if (80 + (32 / 8) + (nFaces * faceSize) === reader.byteLength) {
@@ -158,11 +163,19 @@ var STLFileLoader = /** @class */ (function () {
158
163
  var vertexstart = start + i * 12;
159
164
  // ordering is intentional to match ascii import
160
165
  positions[offset] = reader.getFloat32(vertexstart, true);
161
- positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);
162
- positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);
163
166
  normals[offset] = normalX;
164
- normals[offset + 2] = normalY;
165
- normals[offset + 1] = normalZ;
167
+ if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {
168
+ positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);
169
+ positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);
170
+ normals[offset + 2] = normalY;
171
+ normals[offset + 1] = normalZ;
172
+ }
173
+ else {
174
+ positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);
175
+ positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);
176
+ normals[offset + 1] = normalY;
177
+ normals[offset + 2] = normalZ;
178
+ }
166
179
  offset += 3;
167
180
  }
168
181
  indices[indicesCount] = indicesCount++;
@@ -192,8 +205,16 @@ var STLFileLoader = /** @class */ (function () {
192
205
  var normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];
193
206
  var vertexMatch;
194
207
  while (vertexMatch = this.vertexPattern.exec(facet)) {
195
- positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));
196
- normals.push(normal[0], normal[1], normal[2]);
208
+ if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {
209
+ positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));
210
+ normals.push(normal[0], normal[1], normal[2]);
211
+ }
212
+ else {
213
+ positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));
214
+ // Flipping the second and third component because inverted
215
+ // when normal was declared.
216
+ normals.push(normal[0], normal[2], normal[1]);
217
+ }
197
218
  }
198
219
  indices.push(indicesCount++, indicesCount++, indicesCount++);
199
220
  this.vertexPattern.lastIndex = 0;
@@ -204,6 +225,12 @@ var STLFileLoader = /** @class */ (function () {
204
225
  mesh.setIndices(indices);
205
226
  mesh.computeWorldMatrix(true);
206
227
  };
228
+ /**
229
+ * Defines if Y and Z axes are swapped or not when loading an STL file.
230
+ * The default is false to maintain backward compatibility. When set to
231
+ * true, coordinates from the STL file are used without change.
232
+ */
233
+ STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES = false;
207
234
  return STLFileLoader;
208
235
  }());
209
236
  export { STLFileLoader };
@@ -1 +1 @@
1
- {"version":3,"file":"stlFileLoader.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/STL/stlFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAI7D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;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vD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACL,oBAAC;AAAD,CAAC,AA3OD,IA2OC;;AAED,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;CACnD","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { VertexBuffer } from \"@babylonjs/core/Meshes/buffer\";\nimport { Skeleton } from \"@babylonjs/core/Bones/skeleton\";\nimport { IParticleSystem } from \"@babylonjs/core/Particles/IParticleSystem\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { SceneLoader, ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"@babylonjs/core/Loading/sceneLoader\";\nimport { AssetContainer } from \"@babylonjs/core/assetContainer\";\nimport { Scene } from \"@babylonjs/core/scene\";\n\n/**\n * STL file type loader.\n * This is a babylon scene loader plugin.\n */\nexport class STLFileLoader implements ISceneLoaderPlugin {\n\n /** @hidden */\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\n\n /** @hidden */\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\n /** @hidden */\n public normalPattern = /normal[\\s]+([\\-+]?[0-9]+\\.?[0-9]*([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+/g;\n /** @hidden */\n public vertexPattern = /vertex[\\s]+([\\-+]?[0-9]+\\.?[0-9]*([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+/g;\n\n /**\n * Defines the name of the plugin.\n */\n public name = \"stl\";\n\n /**\n * Defines the extensions the stl loader is able to load.\n * force data to come in as an ArrayBuffer\n * we'll convert to string if it looks like it's an ASCII .stl\n */\n public extensions: ISceneLoaderPluginExtensions = {\n \".stl\": { isBinary: true },\n };\n\n /**\n * Import meshes into a scene.\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\n * @param scene The scene to import into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param meshes The meshes array to import into\n * @param particleSystems The particle systems array to import into\n * @param skeletons The skeletons array to import into\n * @param onError The callback when import fails\n * @returns True if successful or false otherwise\n */\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean {\n var matches;\n\n if (typeof data !== \"string\") {\n\n if (this._isBinary(data)) {\n // binary .stl\n var babylonMesh = new Mesh(\"stlmesh\", scene);\n this._parseBinary(babylonMesh, data);\n if (meshes) {\n meshes.push(babylonMesh);\n }\n return true;\n }\n\n // ASCII .stl\n\n // convert to string\n var array_buffer = new Uint8Array(data);\n var str = '';\n for (var i = 0; i < data.byteLength; i++) {\n str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian\n }\n data = str;\n }\n\n //if arrived here, data is a string, containing the STLA data.\n\n while (matches = this.solidPattern.exec(data)) {\n var meshName = matches[1];\n var meshNameFromEnd = matches[3];\n if (meshName != meshNameFromEnd) {\n Tools.Error(\"Error in STL, solid name != endsolid name\");\n return false;\n }\n\n // check meshesNames\n if (meshesNames && meshName) {\n if (meshesNames instanceof Array) {\n if (!meshesNames.indexOf(meshName)) {\n continue;\n }\n } else {\n if (meshName !== meshesNames) {\n continue;\n }\n }\n }\n\n // stl mesh name can be empty as well\n meshName = meshName || \"stlmesh\";\n\n var babylonMesh = new Mesh(meshName, scene);\n this._parseASCII(babylonMesh, matches[2]);\n if (meshes) {\n meshes.push(babylonMesh);\n }\n }\n\n return true;\n\n }\n\n /**\n * Load into a scene.\n * @param scene The scene to load into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param onError The callback when import fails\n * @returns true if successful or false otherwise\n */\n public load(scene: Scene, data: any, rootUrl: string): boolean {\n var result = this.importMesh(null, scene, data, rootUrl, null, null, null);\n return result;\n }\n\n /**\n * Load into an asset container.\n * @param scene The scene to load into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param onError The callback when import fails\n * @returns The loaded asset container\n */\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer {\n var container = new AssetContainer(scene);\n scene._blockEntityCollection = true;\n this.importMesh(null, scene, data, rootUrl, container.meshes, null, null);\n scene._blockEntityCollection = false;\n return container;\n }\n\n private _isBinary(data: any) {\n\n // check if file size is correct for binary stl\n var faceSize, nFaces, reader;\n reader = new DataView(data);\n faceSize = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);\n nFaces = reader.getUint32(80, true);\n\n if (80 + (32 / 8) + (nFaces * faceSize) === reader.byteLength) {\n return true;\n }\n\n // check characters higher than ASCII to confirm binary\n var fileLength = reader.byteLength;\n for (var index = 0; index < fileLength; index++) {\n if (reader.getUint8(index) > 127) {\n return true;\n }\n }\n\n return false;\n }\n\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\n\n var reader = new DataView(data);\n var faces = reader.getUint32(80, true);\n\n var dataOffset = 84;\n var faceLength = 12 * 4 + 2;\n\n var offset = 0;\n\n var positions = new Float32Array(faces * 3 * 3);\n var normals = new Float32Array(faces * 3 * 3);\n var indices = new Uint32Array(faces * 3);\n var indicesCount = 0;\n\n for (var face = 0; face < faces; face++) {\n\n var start = dataOffset + face * faceLength;\n var normalX = reader.getFloat32(start, true);\n var normalY = reader.getFloat32(start + 4, true);\n var normalZ = reader.getFloat32(start + 8, true);\n\n for (var i = 1; i <= 3; i++) {\n\n var vertexstart = start + i * 12;\n\n // ordering is intentional to match ascii import\n positions[offset] = reader.getFloat32(vertexstart, true);\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\n\n normals[offset] = normalX;\n normals[offset + 2] = normalY;\n normals[offset + 1] = normalZ;\n\n offset += 3;\n }\n indices[indicesCount] = indicesCount++;\n indices[indicesCount] = indicesCount++;\n indices[indicesCount] = indicesCount++;\n }\n\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\n mesh.setIndices(indices);\n mesh.computeWorldMatrix(true);\n }\n\n private _parseASCII(mesh: Mesh, solidData: string) {\n\n var positions = [];\n var normals = [];\n var indices = [];\n var indicesCount = 0;\n\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\n var matches;\n while (matches = this.facetsPattern.exec(solidData)) {\n var facet = matches[1];\n //one normal per face\n var normalMatches = this.normalPattern.exec(facet);\n this.normalPattern.lastIndex = 0;\n if (!normalMatches) {\n continue;\n }\n var normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\n\n var vertexMatch;\n while (vertexMatch = this.vertexPattern.exec(facet)) {\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\n normals.push(normal[0], normal[1], normal[2]);\n }\n indices.push(indicesCount++, indicesCount++, indicesCount++);\n this.vertexPattern.lastIndex = 0;\n }\n\n this.facetsPattern.lastIndex = 0;\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\n mesh.setIndices(indices);\n mesh.computeWorldMatrix(true);\n }\n}\n\nif (SceneLoader) {\n SceneLoader.RegisterPlugin(new STLFileLoader());\n}"]}
1
+ {"version":3,"file":"stlFileLoader.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/STL/stlFileLoader.ts"],"names":[],"mappings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AG,KAAK,CAAC;IAkPxD,oBAAC;CAAA,AAjRD,IAiRC;SAjRY,aAAa;AAmR1B,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;CACnD","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\nimport { Skeleton } from \"@babylonjs/core/Bones/skeleton\";\nimport { IParticleSystem } from \"@babylonjs/core/Particles/IParticleSystem\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { SceneLoader, ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"@babylonjs/core/Loading/sceneLoader\";\nimport { AssetContainer } from \"@babylonjs/core/assetContainer\";\nimport { Scene } from \"@babylonjs/core/scene\";\n\n/**\n * STL file type loader.\n * This is a babylon scene loader plugin.\n */\nexport class STLFileLoader implements ISceneLoaderPlugin {\n\n /** @hidden */\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\n\n /** @hidden */\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\n /** @hidden */\n public normalPattern = /normal[\\s]+([\\-+]?[0-9]+\\.?[0-9]*([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+/g;\n /** @hidden */\n public vertexPattern = /vertex[\\s]+([\\-+]?[0-9]+\\.?[0-9]*([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+[\\s]+([\\-+]?[0-9]*\\.?[0-9]+([eE][\\-+]?[0-9]+)?)+/g;\n\n /**\n * Defines the name of the plugin.\n */\n public name = \"stl\";\n\n /**\n * Defines the extensions the stl loader is able to load.\n * force data to come in as an ArrayBuffer\n * we'll convert to string if it looks like it's an ASCII .stl\n */\n public extensions: ISceneLoaderPluginExtensions = {\n \".stl\": { isBinary: true },\n };\n\n /**\n * Defines if Y and Z axes are swapped or not when loading an STL file.\n * The default is false to maintain backward compatibility. When set to\n * true, coordinates from the STL file are used without change.\n */\n public static DO_NOT_ALTER_FILE_COORDINATES = false;\n\n /**\n * Import meshes into a scene.\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\n * @param scene The scene to import into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param meshes The meshes array to import into\n * @param particleSystems The particle systems array to import into\n * @param skeletons The skeletons array to import into\n * @param onError The callback when import fails\n * @returns True if successful or false otherwise\n */\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean {\n var matches;\n\n if (typeof data !== \"string\") {\n\n if (this._isBinary(data)) {\n // binary .stl\n var babylonMesh = new Mesh(\"stlmesh\", scene);\n this._parseBinary(babylonMesh, data);\n if (meshes) {\n meshes.push(babylonMesh);\n }\n return true;\n }\n\n // ASCII .stl\n\n // convert to string\n var array_buffer = new Uint8Array(data);\n var str = '';\n for (var i = 0; i < data.byteLength; i++) {\n str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian\n }\n data = str;\n }\n\n //if arrived here, data is a string, containing the STLA data.\n\n while (matches = this.solidPattern.exec(data)) {\n var meshName = matches[1];\n var meshNameFromEnd = matches[3];\n if (meshName != meshNameFromEnd) {\n Tools.Error(\"Error in STL, solid name != endsolid name\");\n return false;\n }\n\n // check meshesNames\n if (meshesNames && meshName) {\n if (meshesNames instanceof Array) {\n if (!meshesNames.indexOf(meshName)) {\n continue;\n }\n } else {\n if (meshName !== meshesNames) {\n continue;\n }\n }\n }\n\n // stl mesh name can be empty as well\n meshName = meshName || \"stlmesh\";\n\n var babylonMesh = new Mesh(meshName, scene);\n this._parseASCII(babylonMesh, matches[2]);\n if (meshes) {\n meshes.push(babylonMesh);\n }\n }\n\n return true;\n\n }\n\n /**\n * Load into a scene.\n * @param scene The scene to load into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param onError The callback when import fails\n * @returns true if successful or false otherwise\n */\n public load(scene: Scene, data: any, rootUrl: string): boolean {\n var result = this.importMesh(null, scene, data, rootUrl, null, null, null);\n return result;\n }\n\n /**\n * Load into an asset container.\n * @param scene The scene to load into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param onError The callback when import fails\n * @returns The loaded asset container\n */\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer {\n var container = new AssetContainer(scene);\n scene._blockEntityCollection = true;\n this.importMesh(null, scene, data, rootUrl, container.meshes, null, null);\n scene._blockEntityCollection = false;\n return container;\n }\n\n private _isBinary(data: any) {\n\n // check if file size is correct for binary stl\n var faceSize, nFaces, reader;\n reader = new DataView(data);\n\n // A Binary STL header is 80 bytes, if the data size is not great than\n // that then it's not a binary STL.\n if (reader.byteLength <= 80) {\n return false;\n }\n\n faceSize = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);\n nFaces = reader.getUint32(80, true);\n\n if (80 + (32 / 8) + (nFaces * faceSize) === reader.byteLength) {\n return true;\n }\n\n // check characters higher than ASCII to confirm binary\n var fileLength = reader.byteLength;\n for (var index = 0; index < fileLength; index++) {\n if (reader.getUint8(index) > 127) {\n return true;\n }\n }\n\n return false;\n }\n\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\n\n var reader = new DataView(data);\n var faces = reader.getUint32(80, true);\n\n var dataOffset = 84;\n var faceLength = 12 * 4 + 2;\n\n var offset = 0;\n\n var positions = new Float32Array(faces * 3 * 3);\n var normals = new Float32Array(faces * 3 * 3);\n var indices = new Uint32Array(faces * 3);\n var indicesCount = 0;\n\n for (var face = 0; face < faces; face++) {\n\n var start = dataOffset + face * faceLength;\n var normalX = reader.getFloat32(start, true);\n var normalY = reader.getFloat32(start + 4, true);\n var normalZ = reader.getFloat32(start + 8, true);\n\n for (var i = 1; i <= 3; i++) {\n\n var vertexstart = start + i * 12;\n\n // ordering is intentional to match ascii import\n positions[offset] = reader.getFloat32(vertexstart, true);\n normals[offset] = normalX;\n\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\n\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\n\n normals[offset + 2] = normalY;\n normals[offset + 1] = normalZ;\n }\n else {\n\n positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);\n positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);\n\n normals[offset + 1] = normalY;\n normals[offset + 2] = normalZ;\n }\n\n offset += 3;\n }\n indices[indicesCount] = indicesCount++;\n indices[indicesCount] = indicesCount++;\n indices[indicesCount] = indicesCount++;\n }\n\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\n mesh.setIndices(indices);\n mesh.computeWorldMatrix(true);\n }\n\n private _parseASCII(mesh: Mesh, solidData: string) {\n\n var positions = [];\n var normals = [];\n var indices = [];\n var indicesCount = 0;\n\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\n var matches;\n while (matches = this.facetsPattern.exec(solidData)) {\n var facet = matches[1];\n //one normal per face\n var normalMatches = this.normalPattern.exec(facet);\n this.normalPattern.lastIndex = 0;\n if (!normalMatches) {\n continue;\n }\n var normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\n\n var vertexMatch;\n while (vertexMatch = this.vertexPattern.exec(facet)) {\n\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\n\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\n normals.push(normal[0], normal[1], normal[2]);\n }\n else {\n\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));\n\n // Flipping the second and third component because inverted\n // when normal was declared.\n normals.push(normal[0], normal[2], normal[1]);\n }\n }\n indices.push(indicesCount++, indicesCount++, indicesCount++);\n this.vertexPattern.lastIndex = 0;\n }\n\n this.facetsPattern.lastIndex = 0;\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\n mesh.setIndices(indices);\n mesh.computeWorldMatrix(true);\n }\n}\n\nif (SceneLoader) {\n SceneLoader.RegisterPlugin(new STLFileLoader());\n}"]}
@@ -1,8 +1,8 @@
1
1
  import { __extends } from "tslib";
2
- import { GLTFLoaderExtension } from "./glTFLoader";
3
- import { GLTFUtils } from "./glTFLoaderUtils";
4
- import { EComponentType } from "./glTFLoaderInterfaces";
5
- import { GLTFLoader, GLTFLoaderBase } from "./glTFLoader";
2
+ import { GLTFLoaderExtension } from "./glTFLoader.js";
3
+ import { GLTFUtils } from "./glTFLoaderUtils.js";
4
+ import { EComponentType } from "./glTFLoaderInterfaces.js";
5
+ import { GLTFLoader, GLTFLoaderBase } from "./glTFLoader.js";
6
6
  var BinaryExtensionBufferName = "binary_glTF";
7
7
  /** @hidden */
8
8
  var GLTFBinaryExtension = /** @class */ (function (_super) {
@@ -4,7 +4,8 @@ import { Material } from "@babylonjs/core/Materials/material";
4
4
  import { Texture } from "@babylonjs/core/Materials/Textures/texture";
5
5
  import { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader";
6
6
  import { Scene } from "@babylonjs/core/scene";
7
- import { IGLTFLoader, GLTFLoaderState, IGLTFLoaderData } from "../glTFFileLoader";
7
+ import { IGLTFLoader, IGLTFLoaderData } from "../glTFFileLoader";
8
+ import { AssetContainer } from "@babylonjs/core/assetContainer";
8
9
  /**
9
10
  * Implementation of the base glTF spec
10
11
  * @hidden
@@ -26,20 +27,19 @@ export declare class GLTFLoader implements IGLTFLoader {
26
27
  [name: string]: GLTFLoaderExtension;
27
28
  };
28
29
  static RegisterExtension(extension: GLTFLoaderExtension): void;
29
- state: Nullable<GLTFLoaderState>;
30
30
  dispose(): void;
31
31
  private _importMeshAsync;
32
32
  /**
33
33
  * Imports one or more meshes from a loaded gltf file and adds them to the scene
34
34
  * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
35
35
  * @param scene the scene the meshes should be added to
36
- * @param forAssetContainer defines if the entities must be stored in the scene
36
+ * @param assetContainer defines the asset container to use (can be null)
37
37
  * @param data gltf data containing information of the meshes in a loaded file
38
38
  * @param rootUrl root url to load from
39
39
  * @param onProgress event that fires when loading progress has occured
40
40
  * @returns a promise containg the loaded meshes, particles, skeletons and animations
41
41
  */
42
- importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
42
+ importMeshAsync(meshesNames: any, scene: Scene, assetContainer: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
43
43
  private _loadAsync;
44
44
  /**
45
45
  * Imports all objects from a loaded gltf file and adds them to the scene