@babylonjs/loaders 5.0.0-rc.1 → 5.0.0-rc.12
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.d.ts +4 -4
- package/OBJ/index.js +4 -4
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +41 -40
- package/OBJ/mtlFileLoader.js +232 -231
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +126 -133
- package/OBJ/objFileLoader.js +296 -300
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +43 -43
- package/OBJ/objLoadingOptions.js +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +154 -153
- package/OBJ/solidParser.js +693 -699
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.d.ts +1 -1
- package/STL/index.js +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +64 -71
- package/STL/stlFileLoader.js +233 -239
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +13 -13
- package/glTF/1.0/glTFBinaryExtension.js +60 -61
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +136 -106
- package/glTF/1.0/glTFLoader.js +1814 -1696
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +412 -412
- package/glTF/1.0/glTFLoaderInterfaces.js +95 -95
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +63 -62
- package/glTF/1.0/glTFLoaderUtils.js +250 -232
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +10 -10
- package/glTF/1.0/glTFMaterialsCommonExtension.js +129 -127
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.d.ts +5 -5
- package/glTF/1.0/index.js +5 -5
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +43 -36
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +117 -110
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +36 -28
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +88 -80
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +34 -27
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +49 -42
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +29 -21
- package/glTF/2.0/Extensions/EXT_texture_webp.js +40 -32
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +50 -32
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +73 -55
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +112 -101
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +36 -28
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +89 -81
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +94 -86
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +53 -45
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +42 -34
- package/glTF/2.0/Extensions/KHR_materials_ior.js +62 -54
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +80 -72
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +84 -76
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_specular.js +74 -66
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +83 -76
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +288 -277
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +73 -65
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +87 -76
- package/glTF/2.0/Extensions/KHR_materials_variants.js +254 -243
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_volume.js +85 -78
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +22 -19
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +23 -21
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +29 -21
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +40 -32
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +33 -25
- package/glTF/2.0/Extensions/KHR_texture_transform.js +61 -53
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +32 -29
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +49 -46
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +54 -38
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +240 -216
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +109 -75
- package/glTF/2.0/Extensions/MSFT_lod.js +369 -333
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +14 -14
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +36 -36
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +14 -14
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +36 -36
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +26 -26
- package/glTF/2.0/Extensions/index.js +26 -26
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +406 -357
- package/glTF/2.0/glTFLoader.js +2366 -2266
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +152 -152
- package/glTF/2.0/glTFLoaderExtension.js +1 -1
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +211 -209
- package/glTF/2.0/glTFLoaderInterfaces.js +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.d.ts +4 -4
- package/glTF/2.0/index.js +5 -4
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +433 -373
- package/glTF/glTFFileLoader.js +927 -870
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +29 -29
- package/glTF/glTFValidation.js +123 -121
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.d.ts +5 -5
- package/glTF/index.js +6 -5
- package/glTF/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +4 -3
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +18 -18
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +2 -2
- package/legacy/legacy-glTF1.js +15 -14
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.d.ts +2 -2
- package/legacy/legacy-glTF1FileLoader.js +3 -2
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +2 -2
- package/legacy/legacy-glTF2.js +33 -32
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.d.ts +2 -2
- package/legacy/legacy-glTF2FileLoader.js +3 -2
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.d.ts +3 -3
- package/legacy/legacy-glTFFileLoader.js +4 -3
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +13 -12
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +13 -12
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +6 -6
- package/legacy/legacy.js +8 -6
- package/legacy/legacy.js.map +1 -1
- package/license.md +71 -0
- package/package.json +37 -193
- package/readme.md +2 -2
package/OBJ/objFileLoader.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"objFileLoader.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/OBJ/objFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAA8H,MAAM,qCAAqC,CAAC;AAC9L,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH;IA8DI;;;;OAIG;IACH,uBAAY,cAAkC;QAlB9C;;WAEG;QACI,SAAI,GAAG,KAAK,CAAC;QACpB;;WAEG;QACI,eAAU,GAAG,MAAM,CAAC;QAEnB,oBAAe,GAA6B,IAAI,CAAC;QAUrD,IAAI,CAAC,eAAe,GAAG,cAAc,IAAI,aAAa,CAAC,qBAAqB,CAAC;IACjF,CAAC;IAxDD,sBAAkB,iCAAgB;QAHlC;;WAEG;aACH;YACI,OAAO,aAAa,CAAC,gBAAgB,CAAC;QAC1C,CAAC;aAED,UAAmC,KAAc;YAC7C,aAAa,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC3C,CAAC;;;OAJA;IAwDD,sBAAmB,sCAAqB;aAAxC;YACI,OAAO;gBACH,cAAc,EAAE,aAAa,CAAC,eAAe;gBAC7C,eAAe,EAAE,aAAa,CAAC,gBAAgB;gBAC/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AAC,CAAC,CAAC;IAC7C;;OAEG;IACW,4BAAc,GAAG,KAAK,CAAC;IAErC;;;;OAIG;IACW,6CAA+B,GAAG,IAAI,CAAC;IA8PzD,oBAAC;CAAA,AA9SD,IA8SC;SA9SY,aAAa;AAgT1B,IAAI,WAAW,EAAE;IACb,0CAA0C;IAC1C,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;CACnD","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Vector2 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { SceneLoader, ISceneLoaderPluginAsync, ISceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderAsyncResult } from \"@babylonjs/core/Loading/sceneLoader\";\nimport { AssetContainer } from \"@babylonjs/core/assetContainer\";\nimport { Scene } from \"@babylonjs/core/scene\";\nimport { WebRequest } from '@babylonjs/core/Misc/webRequest';\nimport { MTLFileLoader } from './mtlFileLoader';\nimport { OBJLoadingOptions } from \"./objLoadingOptions\";\nimport { SolidParser } from \"./solidParser\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\n\n/**\n * OBJ file type loader.\n * This is a babylon scene loader plugin.\n */\nexport class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\n\n /**\n * Defines if UVs are optimized by default during load.\n */\n public static OPTIMIZE_WITH_UV = true;\n /**\n * Invert model on y-axis (does a model scaling inversion)\n */\n public static INVERT_Y = false;\n /**\n * Invert Y-Axis of referenced textures on load\n */\n public static get INVERT_TEXTURE_Y() {\n return MTLFileLoader.INVERT_TEXTURE_Y;\n }\n\n public static set INVERT_TEXTURE_Y(value: boolean) {\n MTLFileLoader.INVERT_TEXTURE_Y = value;\n }\n\n /**\n * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.\n */\n public static IMPORT_VERTEX_COLORS = false;\n /**\n * Compute the normals for the model, even if normals are present in the file.\n */\n public static COMPUTE_NORMALS = false;\n /**\n * 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.\n * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.\n */\n public static OPTIMIZE_NORMALS = false;\n /**\n * Defines custom scaling of UV coordinates of loaded meshes.\n */\n public static UV_SCALING = new Vector2(1, 1);\n /**\n * Skip loading the materials even if defined in the OBJ file (materials are ignored).\n */\n public static SKIP_MATERIALS = false;\n\n /**\n * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.\n *\n * Defaults to true for backwards compatibility.\n */\n public static MATERIAL_LOADING_FAILS_SILENTLY = true;\n /**\n * Defines the name of the plugin.\n */\n public name = \"obj\";\n /**\n * Defines the extension the plugin is able to load.\n */\n public extensions = \".obj\";\n\n private _assetContainer: Nullable<AssetContainer> = null;\n\n private _loadingOptions: OBJLoadingOptions;\n\n /**\n * Creates loader for .OBJ files\n *\n * @param loadingOptions options for loading and parsing OBJ/MTL files.\n */\n constructor(loadingOptions?: OBJLoadingOptions) {\n this._loadingOptions = loadingOptions || OBJFileLoader.DefaultLoadingOptions;\n }\n\n private static get DefaultLoadingOptions(): OBJLoadingOptions {\n return {\n computeNormals: OBJFileLoader.COMPUTE_NORMALS,\n optimizeNormals: OBJFileLoader.OPTIMIZE_NORMALS,\n importVertexColors: OBJFileLoader.IMPORT_VERTEX_COLORS,\n invertY: OBJFileLoader.INVERT_Y,\n invertTextureY: OBJFileLoader.INVERT_TEXTURE_Y,\n UVScaling: OBJFileLoader.UV_SCALING,\n materialLoadingFailsSilently: OBJFileLoader.MATERIAL_LOADING_FAILS_SILENTLY,\n optimizeWithUV: OBJFileLoader.OPTIMIZE_WITH_UV,\n skipMaterials: OBJFileLoader.SKIP_MATERIALS\n };\n }\n\n /**\n * Calls synchronously the MTL file attached to this obj.\n * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.\n * Without this function materials are not displayed in the first frame (but displayed after).\n * In consequence it is impossible to get material information in your HTML file\n *\n * @param url The URL of the MTL file\n * @param rootUrl defines where to load data from\n * @param onSuccess Callback function to be called when the MTL file is loaded\n */\n private _loadMTL(url: string, rootUrl: string, onSuccess: (response: string | ArrayBuffer, responseUrl?: string) => any, onFailure: (pathOfFile: string, exception?: any) => void) {\n //The complete path to the mtl file\n var pathOfFile = rootUrl + url;\n\n // Loads through the babylon tools to allow fileInput search.\n Tools.LoadFile(\n pathOfFile,\n onSuccess,\n undefined,\n undefined,\n false,\n (request?: WebRequest | undefined, exception?: any) => {\n onFailure(pathOfFile, exception);\n }\n );\n }\n\n /**\n * Instantiates a OBJ file loader plugin.\n * @returns the created plugin\n */\n createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin {\n return new OBJFileLoader(OBJFileLoader.DefaultLoadingOptions);\n }\n\n /**\n * If the data string can be loaded directly.\n *\n * @param data string containing the file data\n * @returns if the data can be loaded directly\n */\n public canDirectLoad(data: string): boolean {\n return false;\n }\n\n /**\n * Imports one or more meshes from the loaded OBJ data and adds them to the scene\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\n * @param scene the scene the meshes should be added to\n * @param data the OBJ data to load\n * @param rootUrl root url to load from\n * @param onProgress event that fires when loading progress has occured\n * @param fileName Defines the name of the file to load\n * @returns a promise containg the loaded meshes, particles, skeletons and animations\n */\n public importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult> {\n //get the meshes from OBJ file\n return this._parseSolid(meshesNames, scene, data, rootUrl).then((meshes) => {\n return {\n meshes: meshes,\n particleSystems: [],\n skeletons: [],\n animationGroups: [],\n transformNodes: [],\n geometries: [],\n lights: []\n };\n });\n }\n\n /**\n * Imports all objects from the loaded OBJ data and adds them to the scene\n * @param scene the scene the objects should be added to\n * @param data the OBJ data to load\n * @param rootUrl root url to load from\n * @param onProgress event that fires when loading progress has occured\n * @param fileName Defines the name of the file to load\n * @returns a promise which completes when objects have been loaded to the scene\n */\n public loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void> {\n //Get the 3D model\n return this.importMeshAsync(null, scene, data, rootUrl, onProgress).then(() => {\n // return void\n });\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 onProgress The callback when the load progresses\n * @param fileName Defines the name of the file to load\n * @returns The loaded asset container\n */\n public loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer> {\n var container = new AssetContainer(scene);\n this._assetContainer = container;\n\n return this.importMeshAsync(null, scene, data, rootUrl).then((result) => {\n result.meshes.forEach((mesh) => container.meshes.push(mesh));\n result.meshes.forEach((mesh) => {\n var material = mesh.material;\n if (material) {\n // Materials\n if (container.materials.indexOf(material) == -1) {\n container.materials.push(material);\n\n // Textures\n var textures = material.getActiveTextures();\n textures.forEach((t) => {\n if (container.textures.indexOf(t) == -1) {\n container.textures.push(t);\n }\n });\n }\n }\n });\n this._assetContainer = null;\n return container;\n }).catch((ex) => {\n this._assetContainer = null;\n throw ex;\n });\n }\n\n /**\n * Read the OBJ file and create an Array of meshes.\n * Each mesh contains all information given by the OBJ and the MTL file.\n * i.e. vertices positions and indices, optional normals values, optional UV values, optional material\n * @param meshesNames defines a string or array of strings of the mesh names that should be loaded from the file\n * @param scene defines the scene where are displayed the data\n * @param data defines the content of the obj file\n * @param rootUrl defines the path to the folder\n * @returns the list of loaded meshes\n */\n private _parseSolid(meshesNames: any, scene: Scene, data: string, rootUrl: string): Promise<Array<AbstractMesh>> {\n var fileToLoad: string = \"\"; //The name of the mtlFile to load\n var materialsFromMTLFile: MTLFileLoader = new MTLFileLoader();\n var materialToUse = new Array<string>();\n var babylonMeshesArray: Array<Mesh> = []; //The mesh for babylon\n\n // Main function\n const solidParser = new SolidParser(materialToUse, babylonMeshesArray, this._loadingOptions);\n\n solidParser.parse(meshesNames, data, scene, this._assetContainer, (fileName: string) => {\n fileToLoad = fileName;\n });\n\n // load the materials\n let mtlPromises: Array<Promise<void>> = [];\n // Check if we have a file to load\n if (fileToLoad !== \"\" && !this._loadingOptions.skipMaterials) {\n //Load the file synchronously\n mtlPromises.push(new Promise((resolve, reject) => {\n this._loadMTL(fileToLoad, rootUrl, (dataLoaded) => {\n try {\n //Create materials thanks MTLLoader function\n materialsFromMTLFile.parseMTL(scene, dataLoaded, rootUrl, this._assetContainer);\n //Look at each material loaded in the mtl file\n for (var n = 0; n < materialsFromMTLFile.materials.length; n++) {\n //Three variables to get all meshes with the same material\n var startIndex = 0;\n var _indices = [];\n var _index;\n\n //The material from MTL file is used in the meshes loaded\n //Push the indice in an array\n //Check if the material is not used for another mesh\n while ((_index = materialToUse.indexOf(materialsFromMTLFile.materials[n].name, startIndex)) > -1) {\n _indices.push(_index);\n startIndex = _index + 1;\n }\n //If the material is not used dispose it\n if (_index === -1 && _indices.length === 0) {\n //If the material is not needed, remove it\n materialsFromMTLFile.materials[n].dispose();\n } else {\n for (var o = 0; o < _indices.length; o++) {\n //Apply the material to the Mesh for each mesh with the material\n const mesh = babylonMeshesArray[_indices[o]];\n const material = materialsFromMTLFile.materials[n];\n mesh.material = material;\n\n if (!mesh.getTotalIndices()) {\n // No indices, we need to turn on point cloud\n material.pointsCloud = true;\n }\n }\n }\n }\n resolve();\n } catch (e) {\n Tools.Warn(`Error processing MTL file: '${fileToLoad}'`);\n if (this._loadingOptions.materialLoadingFailsSilently) {\n resolve();\n } else {\n reject(e);\n }\n }\n }, (pathOfFile: string, exception?: any) => {\n Tools.Warn(`Error downloading MTL file: '${fileToLoad}'`);\n if (this._loadingOptions.materialLoadingFailsSilently) {\n resolve();\n } else {\n reject(exception);\n }\n });\n }));\n\n }\n //Return an array with all Mesh\n return Promise.all(mtlPromises).then(() => {\n return babylonMeshesArray;\n });\n }\n\n}\n\nif (SceneLoader) {\n //Add this loader into the register plugin\n SceneLoader.RegisterPlugin(new OBJFileLoader());\n}"]}
|
1
|
+
{"version":3,"file":"objFileLoader.js","sourceRoot":"","sources":["../../../../../lts/loaders/generated/OBJ/objFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAGxC,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,cAAc,EAAE,0CAA4B;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH;IA6DI;;;;OAIG;IACH,uBAAY,cAAkC;QAlB9C;;WAEG;QACI,SAAI,GAAG,KAAK,CAAC;QACpB;;WAEG;QACI,eAAU,GAAG,MAAM,CAAC;QAEnB,oBAAe,GAA6B,IAAI,CAAC;QAUrD,IAAI,CAAC,eAAe,GAAG,cAAc,IAAI,aAAa,CAAC,sBAAsB,CAAC;IAClF,CAAC;IAxDD,sBAAkB,iCAAgB;QAHlC;;WAEG;aACH;YACI,OAAO,aAAa,CAAC,gBAAgB,CAAC;QAC1C,CAAC;aAED,UAAmC,KAAc;YAC7C,aAAa,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC3C,CAAC;;;OAJA;IAwDD,sBAAmB,uCAAsB;aAAzC;YACI,OAAO;gBACH,cAAc,EAAE,aAAa,CAAC,eAAe;gBAC7C,eAAe,EAAE,aAAa,CAAC,gBAAgB;gBAC/C,kBAAkB,EAAE,aAAa,CAAC,oBAAoB;gBACtD,OAAO,EAAE,aAAa,CAAC,QAAQ;gBAC/B,cAAc,EAAE,aAAa,CAAC,gBAAgB;gBAC9C,gEAAgE;gBAChE,SAAS,EAAE,aAAa,CAAC,UAAU;gBACnC,4BAA4B,EAAE,a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port { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderAsyncResult } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { WebRequest } from \"core/Misc/webRequest\";\r\nimport { MTLFileLoader } from \"./mtlFileLoader\";\r\nimport type { OBJLoadingOptions } from \"./objLoadingOptions\";\r\nimport { SolidParser } from \"./solidParser\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\n\r\n/**\r\n * OBJ file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /**\r\n * Defines if UVs are optimized by default during load.\r\n */\r\n public static OPTIMIZE_WITH_UV = true;\r\n /**\r\n * Invert model on y-axis (does a model scaling inversion)\r\n */\r\n public static INVERT_Y = false;\r\n /**\r\n * Invert Y-Axis of referenced textures on load\r\n */\r\n public static get INVERT_TEXTURE_Y() {\r\n return MTLFileLoader.INVERT_TEXTURE_Y;\r\n }\r\n\r\n public static set INVERT_TEXTURE_Y(value: boolean) {\r\n MTLFileLoader.INVERT_TEXTURE_Y = value;\r\n }\r\n\r\n /**\r\n * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.\r\n */\r\n public static IMPORT_VERTEX_COLORS = false;\r\n /**\r\n * Compute the normals for the model, even if normals are present in the file.\r\n */\r\n public static COMPUTE_NORMALS = false;\r\n /**\r\n * 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.\r\n * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.\r\n */\r\n public static OPTIMIZE_NORMALS = false;\r\n /**\r\n * Defines custom scaling of UV coordinates of loaded meshes.\r\n */\r\n public static UV_SCALING = new Vector2(1, 1);\r\n /**\r\n * Skip loading the materials even if defined in the OBJ file (materials are ignored).\r\n */\r\n public static SKIP_MATERIALS = false;\r\n\r\n /**\r\n * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.\r\n *\r\n * Defaults to true for backwards compatibility.\r\n */\r\n public static MATERIAL_LOADING_FAILS_SILENTLY = true;\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"obj\";\r\n /**\r\n * Defines the extension the plugin is able to load.\r\n */\r\n public extensions = \".obj\";\r\n\r\n private _assetContainer: Nullable<AssetContainer> = null;\r\n\r\n private _loadingOptions: OBJLoadingOptions;\r\n\r\n /**\r\n * Creates loader for .OBJ files\r\n *\r\n * @param loadingOptions options for loading and parsing OBJ/MTL files.\r\n */\r\n constructor(loadingOptions?: OBJLoadingOptions) {\r\n this._loadingOptions = loadingOptions || OBJFileLoader._DefaultLoadingOptions;\r\n }\r\n\r\n private static get _DefaultLoadingOptions(): OBJLoadingOptions {\r\n return {\r\n computeNormals: OBJFileLoader.COMPUTE_NORMALS,\r\n optimizeNormals: OBJFileLoader.OPTIMIZE_NORMALS,\r\n importVertexColors: OBJFileLoader.IMPORT_VERTEX_COLORS,\r\n invertY: OBJFileLoader.INVERT_Y,\r\n invertTextureY: OBJFileLoader.INVERT_TEXTURE_Y,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n UVScaling: OBJFileLoader.UV_SCALING,\r\n materialLoadingFailsSilently: OBJFileLoader.MATERIAL_LOADING_FAILS_SILENTLY,\r\n optimizeWithUV: OBJFileLoader.OPTIMIZE_WITH_UV,\r\n skipMaterials: OBJFileLoader.SKIP_MATERIALS,\r\n };\r\n }\r\n\r\n /**\r\n * Calls synchronously the MTL file attached to this obj.\r\n * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.\r\n * Without this function materials are not displayed in the first frame (but displayed after).\r\n * In consequence it is impossible to get material information in your HTML file\r\n *\r\n * @param url The URL of the MTL file\r\n * @param rootUrl defines where to load data from\r\n * @param onSuccess Callback function to be called when the MTL file is loaded\r\n * @param onFailure\r\n */\r\n private _loadMTL(\r\n url: string,\r\n rootUrl: string,\r\n onSuccess: (response: string | ArrayBuffer, responseUrl?: string) => any,\r\n onFailure: (pathOfFile: string, exception?: any) => void\r\n ) {\r\n //The complete path to the mtl file\r\n const pathOfFile = rootUrl + url;\r\n\r\n // Loads through the babylon tools to allow fileInput search.\r\n Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, (request?: WebRequest | undefined, exception?: any) => {\r\n onFailure(pathOfFile, exception);\r\n });\r\n }\r\n\r\n /**\r\n * Instantiates a OBJ file loader plugin.\r\n * @returns the created plugin\r\n */\r\n createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin {\r\n return new OBJFileLoader(OBJFileLoader._DefaultLoadingOptions);\r\n }\r\n\r\n /**\r\n * If the data string can be loaded directly.\r\n * @returns if the data can be loaded directly\r\n */\r\n public canDirectLoad(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Imports one or more meshes from the loaded OBJ data and adds them to the scene\r\n * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file\r\n * @param scene the scene the meshes should be added to\r\n * @param data the OBJ data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise containing the loaded meshes, particles, skeletons and animations\r\n */\r\n public importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string): Promise<ISceneLoaderAsyncResult> {\r\n //get the meshes from OBJ file\r\n return this._parseSolid(meshesNames, scene, data, rootUrl).then((meshes) => {\r\n return {\r\n meshes: meshes,\r\n particleSystems: [],\r\n skeletons: [],\r\n animationGroups: [],\r\n transformNodes: [],\r\n geometries: [],\r\n lights: [],\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * Imports all objects from the loaded OBJ data and adds them to the scene\r\n * @param scene the scene the objects should be added to\r\n * @param data the OBJ data to load\r\n * @param rootUrl root url to load from\r\n * @returns a promise which completes when objects have been loaded to the scene\r\n */\r\n public loadAsync(scene: Scene, data: string, rootUrl: string): Promise<void> {\r\n //Get the 3D model\r\n return this.importMeshAsync(null, scene, data, rootUrl).then(() => {\r\n // return void\r\n });\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string): Promise<AssetContainer> {\r\n const container = new AssetContainer(scene);\r\n this._assetContainer = container;\r\n\r\n return this.importMeshAsync(null, scene, data, rootUrl)\r\n .then((result) => {\r\n result.meshes.forEach((mesh) => container.meshes.push(mesh));\r\n result.meshes.forEach((mesh) => {\r\n const material = mesh.material;\r\n if (material) {\r\n // Materials\r\n if (container.materials.indexOf(material) == -1) {\r\n container.materials.push(material);\r\n\r\n // Textures\r\n const textures = material.getActiveTextures();\r\n textures.forEach((t) => {\r\n if (container.textures.indexOf(t) == -1) {\r\n container.textures.push(t);\r\n }\r\n });\r\n }\r\n }\r\n });\r\n this._assetContainer = null;\r\n return container;\r\n })\r\n .catch((ex) => {\r\n this._assetContainer = null;\r\n throw ex;\r\n });\r\n }\r\n\r\n /**\r\n * Read the OBJ file and create an Array of meshes.\r\n * Each mesh contains all information given by the OBJ and the MTL file.\r\n * i.e. vertices positions and indices, optional normals values, optional UV values, optional material\r\n * @param meshesNames defines a string or array of strings of the mesh names that should be loaded from the file\r\n * @param scene defines the scene where are displayed the data\r\n * @param data defines the content of the obj file\r\n * @param rootUrl defines the path to the folder\r\n * @returns the list of loaded meshes\r\n */\r\n private _parseSolid(meshesNames: any, scene: Scene, data: string, rootUrl: string): Promise<Array<AbstractMesh>> {\r\n let fileToLoad: string = \"\"; //The name of the mtlFile to load\r\n const materialsFromMTLFile: MTLFileLoader = new MTLFileLoader();\r\n const materialToUse = new Array<string>();\r\n const babylonMeshesArray: Array<Mesh> = []; //The mesh for babylon\r\n\r\n // Main function\r\n const solidParser = new SolidParser(materialToUse, babylonMeshesArray, this._loadingOptions);\r\n\r\n solidParser.parse(meshesNames, data, scene, this._assetContainer, (fileName: string) => {\r\n fileToLoad = fileName;\r\n });\r\n\r\n // load the materials\r\n const mtlPromises: Array<Promise<void>> = [];\r\n // Check if we have a file to load\r\n if (fileToLoad !== \"\" && !this._loadingOptions.skipMaterials) {\r\n //Load the file synchronously\r\n mtlPromises.push(\r\n new Promise((resolve, reject) => {\r\n this._loadMTL(\r\n fileToLoad,\r\n rootUrl,\r\n (dataLoaded) => {\r\n try {\r\n //Create materials thanks MTLLoader function\r\n materialsFromMTLFile.parseMTL(scene, dataLoaded, rootUrl, this._assetContainer);\r\n //Look at each material loaded in the mtl file\r\n for (let n = 0; n < materialsFromMTLFile.materials.length; n++) {\r\n //Three variables to get all meshes with the same material\r\n let startIndex = 0;\r\n const _indices = [];\r\n let _index;\r\n\r\n //The material from MTL file is used in the meshes loaded\r\n //Push the indice in an array\r\n //Check if the material is not used for another mesh\r\n while ((_index = materialToUse.indexOf(materialsFromMTLFile.materials[n].name, startIndex)) > -1) {\r\n _indices.push(_index);\r\n startIndex = _index + 1;\r\n }\r\n //If the material is not used dispose it\r\n if (_index === -1 && _indices.length === 0) {\r\n //If the material is not needed, remove it\r\n materialsFromMTLFile.materials[n].dispose();\r\n } else {\r\n for (let o = 0; o < _indices.length; o++) {\r\n //Apply the material to the Mesh for each mesh with the material\r\n const mesh = babylonMeshesArray[_indices[o]];\r\n const material = materialsFromMTLFile.materials[n];\r\n mesh.material = material;\r\n\r\n if (!mesh.getTotalIndices()) {\r\n // No indices, we need to turn on point cloud\r\n material.pointsCloud = true;\r\n }\r\n }\r\n }\r\n }\r\n resolve();\r\n } catch (e) {\r\n Tools.Warn(`Error processing MTL file: '${fileToLoad}'`);\r\n if (this._loadingOptions.materialLoadingFailsSilently) {\r\n resolve();\r\n } else {\r\n reject(e);\r\n }\r\n }\r\n },\r\n (pathOfFile: string, exception?: any) => {\r\n Tools.Warn(`Error downloading MTL file: '${fileToLoad}'`);\r\n if (this._loadingOptions.materialLoadingFailsSilently) {\r\n resolve();\r\n } else {\r\n reject(exception);\r\n }\r\n }\r\n );\r\n })\r\n );\r\n }\r\n //Return an array with all Mesh\r\n return Promise.all(mtlPromises).then(() => {\r\n return babylonMeshesArray;\r\n });\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n //Add this loader into the register plugin\r\n SceneLoader.RegisterPlugin(new OBJFileLoader());\r\n}\r\n"]}
|
@@ -1,43 +1,43 @@
|
|
1
|
-
import { Vector2 } from "@babylonjs/core/Maths/math.vector";
|
2
|
-
/**
|
3
|
-
* Options for loading OBJ/MTL files
|
4
|
-
*/
|
5
|
-
export declare type OBJLoadingOptions = {
|
6
|
-
/**
|
7
|
-
* Defines if UVs are optimized by default during load.
|
8
|
-
*/
|
9
|
-
optimizeWithUV: boolean;
|
10
|
-
/**
|
11
|
-
* Defines custom scaling of UV coordinates of loaded meshes.
|
12
|
-
*/
|
13
|
-
UVScaling: Vector2;
|
14
|
-
/**
|
15
|
-
* Invert model on y-axis (does a model scaling inversion)
|
16
|
-
*/
|
17
|
-
invertY: boolean;
|
18
|
-
/**
|
19
|
-
* Invert Y-Axis of referenced textures on load
|
20
|
-
*/
|
21
|
-
invertTextureY: boolean;
|
22
|
-
/**
|
23
|
-
* Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
|
24
|
-
*/
|
25
|
-
importVertexColors: boolean;
|
26
|
-
/**
|
27
|
-
* Compute the normals for the model, even if normals are present in the file.
|
28
|
-
*/
|
29
|
-
computeNormals: boolean;
|
30
|
-
/**
|
31
|
-
* 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.
|
32
|
-
* Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
|
33
|
-
*/
|
34
|
-
optimizeNormals: boolean;
|
35
|
-
/**
|
36
|
-
* Skip loading the materials even if defined in the OBJ file (materials are ignored).
|
37
|
-
*/
|
38
|
-
skipMaterials: boolean;
|
39
|
-
/**
|
40
|
-
* When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
|
41
|
-
*/
|
42
|
-
materialLoadingFailsSilently: boolean;
|
43
|
-
};
|
1
|
+
import type { Vector2 } from "@babylonjs/core/Maths/math.vector.js";
|
2
|
+
/**
|
3
|
+
* Options for loading OBJ/MTL files
|
4
|
+
*/
|
5
|
+
export declare type OBJLoadingOptions = {
|
6
|
+
/**
|
7
|
+
* Defines if UVs are optimized by default during load.
|
8
|
+
*/
|
9
|
+
optimizeWithUV: boolean;
|
10
|
+
/**
|
11
|
+
* Defines custom scaling of UV coordinates of loaded meshes.
|
12
|
+
*/
|
13
|
+
UVScaling: Vector2;
|
14
|
+
/**
|
15
|
+
* Invert model on y-axis (does a model scaling inversion)
|
16
|
+
*/
|
17
|
+
invertY: boolean;
|
18
|
+
/**
|
19
|
+
* Invert Y-Axis of referenced textures on load
|
20
|
+
*/
|
21
|
+
invertTextureY: boolean;
|
22
|
+
/**
|
23
|
+
* Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
|
24
|
+
*/
|
25
|
+
importVertexColors: boolean;
|
26
|
+
/**
|
27
|
+
* Compute the normals for the model, even if normals are present in the file.
|
28
|
+
*/
|
29
|
+
computeNormals: boolean;
|
30
|
+
/**
|
31
|
+
* 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.
|
32
|
+
* Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
|
33
|
+
*/
|
34
|
+
optimizeNormals: boolean;
|
35
|
+
/**
|
36
|
+
* Skip loading the materials even if defined in the OBJ file (materials are ignored).
|
37
|
+
*/
|
38
|
+
skipMaterials: boolean;
|
39
|
+
/**
|
40
|
+
* When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
|
41
|
+
*/
|
42
|
+
materialLoadingFailsSilently: boolean;
|
43
|
+
};
|
package/OBJ/objLoadingOptions.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
2
2
|
//# sourceMappingURL=objLoadingOptions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"objLoadingOptions.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"objLoadingOptions.js","sourceRoot":"","sources":["../../../../../lts/loaders/generated/OBJ/objLoadingOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Options for loading OBJ/MTL files\r\n */\r\nexport type OBJLoadingOptions = {\r\n /**\r\n * Defines if UVs are optimized by default during load.\r\n */\r\n optimizeWithUV: boolean;\r\n /**\r\n * Defines custom scaling of UV coordinates of loaded meshes.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n UVScaling: Vector2;\r\n /**\r\n * Invert model on y-axis (does a model scaling inversion)\r\n */\r\n invertY: boolean;\r\n /**\r\n * Invert Y-Axis of referenced textures on load\r\n */\r\n invertTextureY: boolean;\r\n /**\r\n * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.\r\n */\r\n importVertexColors: boolean;\r\n /**\r\n * Compute the normals for the model, even if normals are present in the file.\r\n */\r\n computeNormals: boolean;\r\n /**\r\n * 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.\r\n * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.\r\n */\r\n optimizeNormals: boolean;\r\n /**\r\n * Skip loading the materials even if defined in the OBJ file (materials are ignored).\r\n */\r\n skipMaterials: boolean;\r\n /**\r\n * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.\r\n */\r\n materialLoadingFailsSilently: boolean;\r\n};\r\n"]}
|
package/OBJ/solidParser.d.ts
CHANGED
@@ -1,153 +1,154 @@
|
|
1
|
-
import { AssetContainer } from "@babylonjs/core/assetContainer";
|
2
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh";
|
3
|
-
import { Scene } from "@babylonjs/core/scene";
|
4
|
-
import { Nullable } from "@babylonjs/core/types";
|
5
|
-
import { OBJLoadingOptions } from "./objLoadingOptions";
|
6
|
-
/**
|
7
|
-
* Class used to load mesh data from OBJ content
|
8
|
-
*/
|
9
|
-
export declare class SolidParser {
|
10
|
-
/** Object descriptor */
|
11
|
-
static ObjectDescriptor: RegExp;
|
12
|
-
/** Group descriptor */
|
13
|
-
static GroupDescriptor: RegExp;
|
14
|
-
/** Material lib descriptor */
|
15
|
-
static MtlLibGroupDescriptor: RegExp;
|
16
|
-
/** Use a material descriptor */
|
17
|
-
static UseMtlDescriptor: RegExp;
|
18
|
-
/** Smooth descriptor */
|
19
|
-
static SmoothDescriptor: RegExp;
|
20
|
-
/** Pattern used to detect a vertex */
|
21
|
-
static VertexPattern: RegExp;
|
22
|
-
/** Pattern used to detect a normal */
|
23
|
-
static NormalPattern: RegExp;
|
24
|
-
/** Pattern used to detect a UV set */
|
25
|
-
static UVPattern: RegExp;
|
26
|
-
/** Pattern used to detect a first kind of face (f vertex vertex vertex) */
|
27
|
-
static FacePattern1: RegExp;
|
28
|
-
/** Pattern used to detect a second kind of face (f vertex/uvs vertex/uvs vertex/uvs) */
|
29
|
-
static FacePattern2: RegExp;
|
30
|
-
/** Pattern used to detect a third kind of face (f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal) */
|
31
|
-
static FacePattern3: RegExp;
|
32
|
-
/** Pattern used to detect a fourth kind of face (f vertex//normal vertex//normal vertex//normal)*/
|
33
|
-
static FacePattern4: RegExp;
|
34
|
-
/** Pattern used to detect a fifth kind of face (f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal) */
|
35
|
-
static FacePattern5: RegExp;
|
36
|
-
private _loadingOptions;
|
37
|
-
private _positions;
|
38
|
-
private _normals;
|
39
|
-
private _uvs;
|
40
|
-
private _colors;
|
41
|
-
private _meshesFromObj;
|
42
|
-
private _handledMesh;
|
43
|
-
private _indicesForBabylon;
|
44
|
-
private _wrappedPositionForBabylon;
|
45
|
-
private _wrappedUvsForBabylon;
|
46
|
-
private _wrappedColorsForBabylon;
|
47
|
-
private _wrappedNormalsForBabylon;
|
48
|
-
private _tuplePosNorm;
|
49
|
-
private _curPositionInIndices;
|
50
|
-
private _hasMeshes;
|
51
|
-
private _unwrappedPositionsForBabylon;
|
52
|
-
private _unwrappedColorsForBabylon;
|
53
|
-
private _unwrappedNormalsForBabylon;
|
54
|
-
private _unwrappedUVForBabylon;
|
55
|
-
private _triangles;
|
56
|
-
private _materialNameFromObj;
|
57
|
-
private _objMeshName;
|
58
|
-
private _increment;
|
59
|
-
private _isFirstMaterial;
|
60
|
-
private _grayColor;
|
61
|
-
private _materialToUse;
|
62
|
-
private _babylonMeshesArray;
|
63
|
-
/**
|
64
|
-
* Creates a new SolidParser
|
65
|
-
* @param materialToUse defines the array to fill with the list of materials to use (it will be filled by the parse function)
|
66
|
-
* @param babylonMeshesArray defines the array to fill with the list of loaded meshes (it will be filled by the parse function)
|
67
|
-
* @param loadingOptions defines the loading options to use
|
68
|
-
*/
|
69
|
-
constructor(materialToUse: string[], babylonMeshesArray: Array<Mesh>, loadingOptions: OBJLoadingOptions);
|
70
|
-
/**
|
71
|
-
* Search for obj in the given array.
|
72
|
-
* This function is called to check if a couple of data already exists in an array.
|
73
|
-
*
|
74
|
-
* If found, returns the index of the founded tuple index. Returns -1 if not found
|
75
|
-
* @param arr Array<{ normals: Array<number>, idx: Array<number> }>
|
76
|
-
* @param obj Array<number>
|
77
|
-
* @returns {boolean}
|
78
|
-
*/
|
79
|
-
private _isInArray;
|
80
|
-
private _isInArrayUV;
|
81
|
-
/**
|
82
|
-
* This function set the data for each triangle.
|
83
|
-
* Data are position, normals and uvs
|
84
|
-
* If a tuple of (position, normal) is not set, add the data into the corresponding array
|
85
|
-
* If the tuple already exist, add only their indice
|
86
|
-
*
|
87
|
-
* @param indicePositionFromObj Integer The index in positions array
|
88
|
-
* @param indiceUvsFromObj Integer The index in uvs array
|
89
|
-
* @param indiceNormalFromObj Integer The index in normals array
|
90
|
-
* @param positionVectorFromOBJ Vector3 The value of position at index objIndice
|
91
|
-
* @param textureVectorFromOBJ Vector3 The value of uvs
|
92
|
-
* @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
*
|
102
|
-
*
|
103
|
-
*
|
104
|
-
*
|
105
|
-
*
|
106
|
-
*
|
107
|
-
*
|
108
|
-
*
|
109
|
-
*
|
110
|
-
* @param
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
*
|
116
|
-
*
|
117
|
-
* @param
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
*
|
123
|
-
*
|
124
|
-
* @param
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
*
|
130
|
-
*
|
131
|
-
* @param
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
*
|
137
|
-
*
|
138
|
-
* @param
|
139
|
-
|
140
|
-
|
141
|
-
private
|
142
|
-
private
|
143
|
-
private
|
144
|
-
|
145
|
-
|
146
|
-
*
|
147
|
-
* @param
|
148
|
-
* @param
|
149
|
-
* @param
|
150
|
-
* @param
|
151
|
-
|
152
|
-
|
153
|
-
|
1
|
+
import type { AssetContainer } from "@babylonjs/core/assetContainer.js";
|
2
|
+
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
3
|
+
import type { Scene } from "@babylonjs/core/scene.js";
|
4
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
5
|
+
import type { OBJLoadingOptions } from "./objLoadingOptions";
|
6
|
+
/**
|
7
|
+
* Class used to load mesh data from OBJ content
|
8
|
+
*/
|
9
|
+
export declare class SolidParser {
|
10
|
+
/** Object descriptor */
|
11
|
+
static ObjectDescriptor: RegExp;
|
12
|
+
/** Group descriptor */
|
13
|
+
static GroupDescriptor: RegExp;
|
14
|
+
/** Material lib descriptor */
|
15
|
+
static MtlLibGroupDescriptor: RegExp;
|
16
|
+
/** Use a material descriptor */
|
17
|
+
static UseMtlDescriptor: RegExp;
|
18
|
+
/** Smooth descriptor */
|
19
|
+
static SmoothDescriptor: RegExp;
|
20
|
+
/** Pattern used to detect a vertex */
|
21
|
+
static VertexPattern: RegExp;
|
22
|
+
/** Pattern used to detect a normal */
|
23
|
+
static NormalPattern: RegExp;
|
24
|
+
/** Pattern used to detect a UV set */
|
25
|
+
static UVPattern: RegExp;
|
26
|
+
/** Pattern used to detect a first kind of face (f vertex vertex vertex) */
|
27
|
+
static FacePattern1: RegExp;
|
28
|
+
/** Pattern used to detect a second kind of face (f vertex/uvs vertex/uvs vertex/uvs) */
|
29
|
+
static FacePattern2: RegExp;
|
30
|
+
/** Pattern used to detect a third kind of face (f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal) */
|
31
|
+
static FacePattern3: RegExp;
|
32
|
+
/** Pattern used to detect a fourth kind of face (f vertex//normal vertex//normal vertex//normal)*/
|
33
|
+
static FacePattern4: RegExp;
|
34
|
+
/** Pattern used to detect a fifth kind of face (f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal) */
|
35
|
+
static FacePattern5: RegExp;
|
36
|
+
private _loadingOptions;
|
37
|
+
private _positions;
|
38
|
+
private _normals;
|
39
|
+
private _uvs;
|
40
|
+
private _colors;
|
41
|
+
private _meshesFromObj;
|
42
|
+
private _handledMesh;
|
43
|
+
private _indicesForBabylon;
|
44
|
+
private _wrappedPositionForBabylon;
|
45
|
+
private _wrappedUvsForBabylon;
|
46
|
+
private _wrappedColorsForBabylon;
|
47
|
+
private _wrappedNormalsForBabylon;
|
48
|
+
private _tuplePosNorm;
|
49
|
+
private _curPositionInIndices;
|
50
|
+
private _hasMeshes;
|
51
|
+
private _unwrappedPositionsForBabylon;
|
52
|
+
private _unwrappedColorsForBabylon;
|
53
|
+
private _unwrappedNormalsForBabylon;
|
54
|
+
private _unwrappedUVForBabylon;
|
55
|
+
private _triangles;
|
56
|
+
private _materialNameFromObj;
|
57
|
+
private _objMeshName;
|
58
|
+
private _increment;
|
59
|
+
private _isFirstMaterial;
|
60
|
+
private _grayColor;
|
61
|
+
private _materialToUse;
|
62
|
+
private _babylonMeshesArray;
|
63
|
+
/**
|
64
|
+
* Creates a new SolidParser
|
65
|
+
* @param materialToUse defines the array to fill with the list of materials to use (it will be filled by the parse function)
|
66
|
+
* @param babylonMeshesArray defines the array to fill with the list of loaded meshes (it will be filled by the parse function)
|
67
|
+
* @param loadingOptions defines the loading options to use
|
68
|
+
*/
|
69
|
+
constructor(materialToUse: string[], babylonMeshesArray: Array<Mesh>, loadingOptions: OBJLoadingOptions);
|
70
|
+
/**
|
71
|
+
* Search for obj in the given array.
|
72
|
+
* This function is called to check if a couple of data already exists in an array.
|
73
|
+
*
|
74
|
+
* If found, returns the index of the founded tuple index. Returns -1 if not found
|
75
|
+
* @param arr Array<{ normals: Array<number>, idx: Array<number> }>
|
76
|
+
* @param obj Array<number>
|
77
|
+
* @returns {boolean}
|
78
|
+
*/
|
79
|
+
private _isInArray;
|
80
|
+
private _isInArrayUV;
|
81
|
+
/**
|
82
|
+
* This function set the data for each triangle.
|
83
|
+
* Data are position, normals and uvs
|
84
|
+
* If a tuple of (position, normal) is not set, add the data into the corresponding array
|
85
|
+
* If the tuple already exist, add only their indice
|
86
|
+
*
|
87
|
+
* @param indicePositionFromObj Integer The index in positions array
|
88
|
+
* @param indiceUvsFromObj Integer The index in uvs array
|
89
|
+
* @param indiceNormalFromObj Integer The index in normals array
|
90
|
+
* @param positionVectorFromOBJ Vector3 The value of position at index objIndice
|
91
|
+
* @param textureVectorFromOBJ Vector3 The value of uvs
|
92
|
+
* @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
|
93
|
+
* @param positionColorsFromOBJ
|
94
|
+
*/
|
95
|
+
private _setData;
|
96
|
+
/**
|
97
|
+
* Transform Vector() and BABYLON.Color() objects into numbers in an array
|
98
|
+
*/
|
99
|
+
private _unwrapData;
|
100
|
+
/**
|
101
|
+
* Create triangles from polygons
|
102
|
+
* It is important to notice that a triangle is a polygon
|
103
|
+
* We get 5 patterns of face defined in OBJ File :
|
104
|
+
* facePattern1 = ["1","2","3","4","5","6"]
|
105
|
+
* facePattern2 = ["1/1","2/2","3/3","4/4","5/5","6/6"]
|
106
|
+
* facePattern3 = ["1/1/1","2/2/2","3/3/3","4/4/4","5/5/5","6/6/6"]
|
107
|
+
* facePattern4 = ["1//1","2//2","3//3","4//4","5//5","6//6"]
|
108
|
+
* facePattern5 = ["-1/-1/-1","-2/-2/-2","-3/-3/-3","-4/-4/-4","-5/-5/-5","-6/-6/-6"]
|
109
|
+
* Each pattern is divided by the same method
|
110
|
+
* @param faces Array[String] The indices of elements
|
111
|
+
* @param v Integer The variable to increment
|
112
|
+
*/
|
113
|
+
private _getTriangles;
|
114
|
+
/**
|
115
|
+
* Create triangles and push the data for each polygon for the pattern 1
|
116
|
+
* In this pattern we get vertice positions
|
117
|
+
* @param face
|
118
|
+
* @param v
|
119
|
+
*/
|
120
|
+
private _setDataForCurrentFaceWithPattern1;
|
121
|
+
/**
|
122
|
+
* Create triangles and push the data for each polygon for the pattern 2
|
123
|
+
* In this pattern we get vertice positions and uvsu
|
124
|
+
* @param face
|
125
|
+
* @param v
|
126
|
+
*/
|
127
|
+
private _setDataForCurrentFaceWithPattern2;
|
128
|
+
/**
|
129
|
+
* Create triangles and push the data for each polygon for the pattern 3
|
130
|
+
* In this pattern we get vertice positions, uvs and normals
|
131
|
+
* @param face
|
132
|
+
* @param v
|
133
|
+
*/
|
134
|
+
private _setDataForCurrentFaceWithPattern3;
|
135
|
+
/**
|
136
|
+
* Create triangles and push the data for each polygon for the pattern 4
|
137
|
+
* In this pattern we get vertice positions and normals
|
138
|
+
* @param face
|
139
|
+
* @param v
|
140
|
+
*/
|
141
|
+
private _setDataForCurrentFaceWithPattern4;
|
142
|
+
private _setDataForCurrentFaceWithPattern5;
|
143
|
+
private _addPreviousObjMesh;
|
144
|
+
private _optimizeNormals;
|
145
|
+
/**
|
146
|
+
* Function used to parse an OBJ string
|
147
|
+
* @param meshesNames defines the list of meshes to load (all if not defined)
|
148
|
+
* @param data defines the OBJ string
|
149
|
+
* @param scene defines the hosting scene
|
150
|
+
* @param assetContainer defines the asset container to load data in
|
151
|
+
* @param onFileToLoadFound defines a callback that will be called if a MTL file is found
|
152
|
+
*/
|
153
|
+
parse(meshesNames: any, data: string, scene: Scene, assetContainer: Nullable<AssetContainer>, onFileToLoadFound: (fileToLoad: string) => void): void;
|
154
|
+
}
|