@babylonjs/loaders 5.0.0-beta.1 → 5.0.0-beta.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/OBJ/objFileLoader.js +2 -2
  2. package/OBJ/objFileLoader.js.map +1 -1
  3. package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -8
  4. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  5. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +1 -0
  6. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +5 -4
  7. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  8. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +2 -2
  9. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  10. package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
  11. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  12. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +27 -7
  13. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  14. package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -1
  15. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +7 -7
  17. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  18. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +1 -1
  19. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  20. package/glTF/2.0/Extensions/KHR_materials_ior.js +1 -1
  21. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  22. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +5 -5
  23. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  24. package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -5
  25. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  26. package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -5
  27. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  28. package/glTF/2.0/Extensions/KHR_materials_translucency.js +2 -2
  29. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  30. package/glTF/2.0/Extensions/KHR_materials_transmission.js +2 -2
  31. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  32. package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
  33. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  34. package/glTF/2.0/Extensions/KHR_materials_variants.js +6 -6
  35. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  36. package/glTF/2.0/Extensions/KHR_materials_volume.js +2 -2
  37. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  38. package/glTF/2.0/Extensions/KHR_texture_basisu.js +2 -2
  39. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  40. package/glTF/2.0/Extensions/KHR_texture_transform.js +1 -1
  41. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  42. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +13 -13
  43. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  44. package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -1
  45. package/glTF/2.0/Extensions/MSFT_lod.js +17 -54
  46. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  47. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +1 -1
  48. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  49. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +1 -1
  50. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  51. package/glTF/2.0/glTFLoader.d.ts +4 -2
  52. package/glTF/2.0/glTFLoader.js +289 -206
  53. package/glTF/2.0/glTFLoader.js.map +1 -1
  54. package/glTF/2.0/glTFLoaderInterfaces.d.ts +0 -3
  55. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  56. package/glTF/glTFFileLoader.d.ts +11 -2
  57. package/glTF/glTFFileLoader.js +35 -29
  58. package/glTF/glTFFileLoader.js.map +1 -1
  59. package/glTF/glTFValidation.js +1 -1
  60. package/glTF/glTFValidation.js.map +1 -1
  61. package/package.json +3 -3
@@ -232,7 +232,7 @@ var OBJFileLoader = /** @class */ (function () {
232
232
  resolve();
233
233
  }
234
234
  catch (e) {
235
- Tools.Warn("Error processing MTL file: '" + fileToLoad + "'");
235
+ Tools.Warn("Error processing MTL file: '".concat(fileToLoad, "'"));
236
236
  if (_this._loadingOptions.materialLoadingFailsSilently) {
237
237
  resolve();
238
238
  }
@@ -241,7 +241,7 @@ var OBJFileLoader = /** @class */ (function () {
241
241
  }
242
242
  }
243
243
  }, function (pathOfFile, exception) {
244
- Tools.Warn("Error downloading MTL file: '" + fileToLoad + "'");
244
+ Tools.Warn("Error downloading MTL file: '".concat(fileToLoad, "'"));
245
245
  if (_this._loadingOptions.materialLoadingFailsSilently) {
246
246
  resolve();
247
247
  }
@@ -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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;QACD,+BAA+B;QAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACjC,OAAO,kBAAkB,CAAC;QAC9B,CAAC,CAAC,CAAC;IACP,CAAC;IA1SD;;OAEG;IACW,8BAAgB,GAAG,IAAI,CAAC;IACtC;;OAEG;IACW,sBAAQ,GAAG,KAAK,CAAC;IAY/B;;OAEG;IACW,kCAAoB,GAAG,KAAK,CAAC;IAC3C;;OAEG;IACW,6BAAe,GAAG,KAAK,CAAC;IACtC;;;OAGG;IACW,8BAAgB,GAAG,KAAK,CAAC;IACvC;;OAEG;IACW,wBAAU,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,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":["../../../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,iC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1SD;;OAEG;IACW,8BAAgB,GAAG,IAAI,CAAC;IACtC;;OAEG;IACW,sBAAQ,GAAG,KAAK,CAAC;IAY/B;;OAEG;IACW,kCAAoB,GAAG,KAAK,CAAC;IAC3C;;OAEG;IACW,6BAAe,GAAG,KAAK,CAAC;IACtC;;;OAGG;IACW,8BAAgB,GAAG,KAAK,CAAC;IACvC;;OAEG;IACW,wBAAU,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,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}"]}
@@ -36,9 +36,9 @@ var EXT_lights_image_based = /** @class */ (function () {
36
36
  return GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
37
37
  var promises = new Array();
38
38
  promises.push(_this._loader.loadSceneAsync(context, scene));
39
- _this._loader.logOpen("" + extensionContext);
40
- var light = ArrayItem.Get(extensionContext + "/light", _this._lights, extension.light);
41
- promises.push(_this._loadLightAsync("/extensions/" + _this.name + "/lights/" + extension.light, light).then(function (texture) {
39
+ _this._loader.logOpen("".concat(extensionContext));
40
+ var light = ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light);
41
+ promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) {
42
42
  _this._loader.babylonScene.environmentTexture = texture;
43
43
  }));
44
44
  _this._loader.logClose();
@@ -49,17 +49,17 @@ var EXT_lights_image_based = /** @class */ (function () {
49
49
  var _this = this;
50
50
  if (!light._loaded) {
51
51
  var promises = new Array();
52
- this._loader.logOpen("" + context);
52
+ this._loader.logOpen("".concat(context));
53
53
  var imageData_1 = new Array(light.specularImages.length);
54
54
  var _loop_1 = function (mipmap) {
55
55
  var faces = light.specularImages[mipmap];
56
56
  imageData_1[mipmap] = new Array(faces.length);
57
57
  var _loop_2 = function (face) {
58
- var specularImageContext = context + "/specularImages/" + mipmap + "/" + face;
59
- this_1._loader.logOpen("" + specularImageContext);
58
+ var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face);
59
+ this_1._loader.logOpen("".concat(specularImageContext));
60
60
  var index = faces[face];
61
61
  var image = ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index);
62
- promises.push(this_1._loader.loadImageAsync("/images/" + index, image).then(function (data) {
62
+ promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) {
63
63
  imageData_1[mipmap][face] = data;
64
64
  }));
65
65
  this_1._loader.logClose();
@@ -89,7 +89,7 @@ var EXT_lights_image_based = /** @class */ (function () {
89
89
  Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());
90
90
  }
91
91
  if (!light.irradianceCoefficients) {
92
- throw new Error(context + ": Irradiance coefficients are missing");
92
+ throw new Error("".concat(context, ": Irradiance coefficients are missing"));
93
93
  }
94
94
  var sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);
95
95
  sphericalHarmonics.scaleInPlace(light.intensity);
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_lights_image_based.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAKnF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AAUtC;;GAEG;AACH;IAcI,cAAc;IACd,gCAAY,MAAkB;QAd9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAYxB,IAAI,C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,KAAK,CAAC,sBAAsB,EAAE;oBAC/B,MAAM,IAAI,KAAK,CAAI,OAAO,0CAAuC,CAAC,CAAC;iBACtE;gBAED,IAAM,kBAAkB,GAAG,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACtF,kBAAkB,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBAEjD,kBAAkB,CAAC,qCAAqC,EAAE,CAAC;gBAC3D,IAAM,mBAAmB,GAAG,mBAAmB,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAElF,qFAAqF;gBACrF,IAAM,kBAAkB,GAAG,CAAC,WAAS,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACzF,OAAO,cAAc,CAAC,eAAe,CAAC,WAAS,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;YAC9F,CAAC,CAAC,CAAC;SACN;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YACtB,OAAO,KAAK,CAAC,eAAgB,CAAC;QAClC,CAAC,CAAC,CAAC;IACP,CAAC;IACL,6BAAC;AAAD,CAAC,AAzHD,IAyHC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Scalar } from \"@babylonjs/core/Maths/math.scalar\";\r\nimport { SphericalHarmonics, SphericalPolynomial } from \"@babylonjs/core/Maths/sphericalPolynomial\";\r\nimport { Quaternion, Matrix } from \"@babylonjs/core/Maths/math.vector\";\r\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\r\nimport { RawCubeTexture } from \"@babylonjs/core/Materials/Textures/rawCubeTexture\";\r\n\r\nimport { IEXTLightsImageBased_LightReferenceImageBased, IEXTLightsImageBased_LightImageBased, IEXTLightsImageBased } from \"babylonjs-gltf2interface\";\r\nimport { IScene } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"EXT_lights_image_based\";\r\n\r\ndeclare module \"babylonjs-gltf2interface\" {\r\n /** @hidden */\r\n interface IEXTLightsImageBased_LightImageBased {\r\n _babylonTexture?: BaseTexture;\r\n _loaded?: Promise<void>;\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)\r\n */\r\nexport class EXT_lights_image_based implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n private _lights?: IEXTLightsImageBased_LightImageBased[];\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n delete this._lights;\r\n }\r\n\r\n /** @hidden */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IEXTLightsImageBased;\r\n this._lights = extension.lights;\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IEXTLightsImageBased_LightReferenceImageBased>(context, scene, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n promises.push(this._loader.loadSceneAsync(context, scene));\r\n\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n const light = ArrayItem.Get(`${extensionContext}/light`, this._lights, extension.light);\r\n promises.push(this._loadLightAsync(`/extensions/${this.name}/lights/${extension.light}`, light).then((texture) => {\r\n this._loader.babylonScene.environmentTexture = texture;\r\n }));\r\n\r\n this._loader.logClose();\r\n\r\n return Promise.all(promises).then(() => { });\r\n });\r\n }\r\n\r\n private _loadLightAsync(context: string, light: IEXTLightsImageBased_LightImageBased): Promise<BaseTexture> {\r\n if (!light._loaded) {\r\n const promises = new Array<Promise<any>>();\r\n\r\n this._loader.logOpen(`${context}`);\r\n\r\n const imageData = new Array<Array<ArrayBufferView>>(light.specularImages.length);\r\n for (let mipmap = 0; mipmap < light.specularImages.length; mipmap++) {\r\n const faces = light.specularImages[mipmap];\r\n imageData[mipmap] = new Array<ArrayBufferView>(faces.length);\r\n for (let face = 0; face < faces.length; face++) {\r\n const specularImageContext = `${context}/specularImages/${mipmap}/${face}`;\r\n this._loader.logOpen(`${specularImageContext}`);\r\n\r\n const index = faces[face];\r\n const image = ArrayItem.Get(specularImageContext, this._loader.gltf.images, index);\r\n promises.push(this._loader.loadImageAsync(`/images/${index}`, image).then((data) => {\r\n imageData[mipmap][face] = data;\r\n }));\r\n\r\n this._loader.logClose();\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n\r\n light._loaded = Promise.all(promises).then(() => {\r\n const babylonTexture = new RawCubeTexture(this._loader.babylonScene, null, light.specularImageSize);\r\n babylonTexture.name = light.name || \"environment\";\r\n light._babylonTexture = babylonTexture;\r\n\r\n if (light.intensity != undefined) {\r\n babylonTexture.level = light.intensity;\r\n }\r\n\r\n if (light.rotation) {\r\n let rotation = Quaternion.FromArray(light.rotation);\r\n\r\n // Invert the rotation so that positive rotation is counter-clockwise.\r\n if (!this._loader.babylonScene.useRightHandedSystem) {\r\n rotation = Quaternion.Inverse(rotation);\r\n }\r\n\r\n Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());\r\n }\r\n\r\n if (!light.irradianceCoefficients) {\r\n throw new Error(`${context}: Irradiance coefficients are missing`);\r\n }\r\n\r\n const sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);\r\n sphericalHarmonics.scaleInPlace(light.intensity);\r\n\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n const sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n\r\n // Compute the lod generation scale to fit exactly to the number of levels available.\r\n const lodGenerationScale = (imageData.length - 1) / Scalar.Log2(light.specularImageSize);\r\n return babylonTexture.updateRGBDAsync(imageData, sphericalPolynomial, lodGenerationScale);\r\n });\r\n }\r\n\r\n return light._loaded.then(() => {\r\n return light._babylonTexture!;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_lights_image_based(loader));"]}
1
+ {"version":3,"file":"EXT_lights_image_based.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAKnF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AAUtC;;GAEG;AACH;IAcI,cAAc;IACd,gCAAY,MAAkB;QAd9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAYxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,wCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,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,SAAS,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACtF,kBAAkB,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBAEjD,kBAAkB,CAAC,qCAAqC,EAAE,CAAC;gBAC3D,IAAM,mBAAmB,GAAG,mBAAmB,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAElF,qFAAqF;gBACrF,IAAM,kBAAkB,GAAG,CAAC,WAAS,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACzF,OAAO,cAAc,CAAC,eAAe,CAAC,WAAS,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;YAC9F,CAAC,CAAC,CAAC;SACN;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YACtB,OAAO,KAAK,CAAC,eAAgB,CAAC;QAClC,CAAC,CAAC,CAAC;IACP,CAAC;IACL,6BAAC;AAAD,CAAC,AAzHD,IAyHC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Scalar } from \"@babylonjs/core/Maths/math.scalar\";\r\nimport { SphericalHarmonics, SphericalPolynomial } from \"@babylonjs/core/Maths/sphericalPolynomial\";\r\nimport { Quaternion, Matrix } from \"@babylonjs/core/Maths/math.vector\";\r\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\r\nimport { RawCubeTexture } from \"@babylonjs/core/Materials/Textures/rawCubeTexture\";\r\n\r\nimport { IEXTLightsImageBased_LightReferenceImageBased, IEXTLightsImageBased_LightImageBased, IEXTLightsImageBased } from \"babylonjs-gltf2interface\";\r\nimport { IScene } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"EXT_lights_image_based\";\r\n\r\ndeclare module \"babylonjs-gltf2interface\" {\r\n /** @hidden */\r\n interface IEXTLightsImageBased_LightImageBased {\r\n _babylonTexture?: BaseTexture;\r\n _loaded?: Promise<void>;\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)\r\n */\r\nexport class EXT_lights_image_based implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n private _lights?: IEXTLightsImageBased_LightImageBased[];\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n delete this._lights;\r\n }\r\n\r\n /** @hidden */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IEXTLightsImageBased;\r\n this._lights = extension.lights;\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IEXTLightsImageBased_LightReferenceImageBased>(context, scene, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n\r\n promises.push(this._loader.loadSceneAsync(context, scene));\r\n\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n const light = ArrayItem.Get(`${extensionContext}/light`, this._lights, extension.light);\r\n promises.push(this._loadLightAsync(`/extensions/${this.name}/lights/${extension.light}`, light).then((texture) => {\r\n this._loader.babylonScene.environmentTexture = texture;\r\n }));\r\n\r\n this._loader.logClose();\r\n\r\n return Promise.all(promises).then(() => { });\r\n });\r\n }\r\n\r\n private _loadLightAsync(context: string, light: IEXTLightsImageBased_LightImageBased): Promise<BaseTexture> {\r\n if (!light._loaded) {\r\n const promises = new Array<Promise<any>>();\r\n\r\n this._loader.logOpen(`${context}`);\r\n\r\n const imageData = new Array<Array<ArrayBufferView>>(light.specularImages.length);\r\n for (let mipmap = 0; mipmap < light.specularImages.length; mipmap++) {\r\n const faces = light.specularImages[mipmap];\r\n imageData[mipmap] = new Array<ArrayBufferView>(faces.length);\r\n for (let face = 0; face < faces.length; face++) {\r\n const specularImageContext = `${context}/specularImages/${mipmap}/${face}`;\r\n this._loader.logOpen(`${specularImageContext}`);\r\n\r\n const index = faces[face];\r\n const image = ArrayItem.Get(specularImageContext, this._loader.gltf.images, index);\r\n promises.push(this._loader.loadImageAsync(`/images/${index}`, image).then((data) => {\r\n imageData[mipmap][face] = data;\r\n }));\r\n\r\n this._loader.logClose();\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n\r\n light._loaded = Promise.all(promises).then(() => {\r\n const babylonTexture = new RawCubeTexture(this._loader.babylonScene, null, light.specularImageSize);\r\n babylonTexture.name = light.name || \"environment\";\r\n light._babylonTexture = babylonTexture;\r\n\r\n if (light.intensity != undefined) {\r\n babylonTexture.level = light.intensity;\r\n }\r\n\r\n if (light.rotation) {\r\n let rotation = Quaternion.FromArray(light.rotation);\r\n\r\n // Invert the rotation so that positive rotation is counter-clockwise.\r\n if (!this._loader.babylonScene.useRightHandedSystem) {\r\n rotation = Quaternion.Inverse(rotation);\r\n }\r\n\r\n Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());\r\n }\r\n\r\n if (!light.irradianceCoefficients) {\r\n throw new Error(`${context}: Irradiance coefficients are missing`);\r\n }\r\n\r\n const sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);\r\n sphericalHarmonics.scaleInPlace(light.intensity);\r\n\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n const sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n\r\n // Compute the lod generation scale to fit exactly to the number of levels available.\r\n const lodGenerationScale = (imageData.length - 1) / Scalar.Log2(light.specularImageSize);\r\n return babylonTexture.updateRGBDAsync(imageData, sphericalPolynomial, lodGenerationScale);\r\n });\r\n }\r\n\r\n return light._loaded.then(() => {\r\n return light._babylonTexture!;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_lights_image_based(loader));"]}
@@ -3,6 +3,7 @@ import { Nullable } from "@babylonjs/core/types";
3
3
  import { GLTFLoader } from "../glTFLoader";
4
4
  import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
5
  import { INode } from "../glTFLoaderInterfaces";
6
+ import "@babylonjs/core/Meshes/thinInstanceMesh";
6
7
  /**
7
8
  * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
8
9
  * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
@@ -1,6 +1,7 @@
1
1
  import { Vector3, Quaternion, Matrix } from '@babylonjs/core/Maths/math.vector.js';
2
2
  import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
3
3
  import { TmpVectors } from '@babylonjs/core/Maths/math.vector.js';
4
+ import "@babylonjs/core/Meshes/thinInstanceMesh.js";
4
5
  var NAME = "EXT_mesh_gpu_instancing";
5
6
  /**
6
7
  * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
@@ -26,7 +27,7 @@ var EXT_mesh_gpu_instancing = /** @class */ (function () {
26
27
  var _this = this;
27
28
  return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
28
29
  _this._loader._disableInstancedMesh++;
29
- var promise = _this._loader.loadNodeAsync("/nodes/" + node.index, node, assign);
30
+ var promise = _this._loader.loadNodeAsync("/nodes/".concat(node.index), node, assign);
30
31
  _this._loader._disableInstancedMesh--;
31
32
  if (!node._primitiveBabylonMeshes) {
32
33
  return promise;
@@ -38,13 +39,13 @@ var EXT_mesh_gpu_instancing = /** @class */ (function () {
38
39
  promises.push(Promise.resolve(null));
39
40
  return;
40
41
  }
41
- var accessor = ArrayItem.Get(extensionContext + "/attributes/" + attribute, _this._loader.gltf.accessors, extension.attributes[attribute]);
42
- promises.push(_this._loader._loadFloatAccessorAsync("/accessors/" + accessor.bufferView, accessor));
42
+ var accessor = ArrayItem.Get("".concat(extensionContext, "/attributes/").concat(attribute), _this._loader.gltf.accessors, extension.attributes[attribute]);
43
+ promises.push(_this._loader._loadFloatAccessorAsync("/accessors/".concat(accessor.bufferView), accessor));
43
44
  if (instanceCount === 0) {
44
45
  instanceCount = accessor.count;
45
46
  }
46
47
  else if (instanceCount !== accessor.count) {
47
- throw new Error(extensionContext + "/attributes: Instance buffer accessors do not have the same count.");
48
+ throw new Error("".concat(extensionContext, "/attributes: Instance buffer accessors do not have the same count."));
48
49
  }
49
50
  };
50
51
  loadAttribute("TRANSLATION");
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_mesh_gpu_instancing.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAIhF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAG/D,IAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;;;GAIG;AACH;IAaI,cAAc;IACd,iCAAY,MAAkB;QAb9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAWxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc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,CAAC,CAAC,CAAC;wBAC7F,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;wBAEjF,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBAElH,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;qBACtD;oBAED,KAA0B,UAA6B,EAA7B,KAAA,IAAI,CAAC,uBAAwB,EAA7B,cAA6B,EAA7B,IAA6B,EAAE;wBAApD,IAAM,WAAW,SAAA;wBACjB,WAAoB,CAAC,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;qBAC7E;oBAED,OAAO,oBAAoB,CAAC;gBAChC,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACL,8BAAC;AAAD,CAAC,AAvFD,IAuFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAnC,CAAmC,CAAC,CAAC","sourcesContent":["import { Vector3, Quaternion, Matrix } from '@babylonjs/core/Maths/math.vector';\nimport { Mesh } from '@babylonjs/core/Meshes/mesh';\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Nullable } from \"@babylonjs/core/types\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { INode } from \"../glTFLoaderInterfaces\";\nimport { TmpVectors } from '@babylonjs/core/Maths/math.vector';\nimport { IEXTMeshGpuInstancing } from \"babylonjs-gltf2interface\";\n\nconst NAME = \"EXT_mesh_gpu_instancing\";\n\n/**\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)\n * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)\n * !!! Experimental Extension Subject to Changes !!!\n */\nexport class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IEXTMeshGpuInstancing, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n this._loader._disableInstancedMesh++;\n\n const promise = this._loader.loadNodeAsync(`/nodes/${node.index}`, node, assign);\n\n this._loader._disableInstancedMesh--;\n\n if (!node._primitiveBabylonMeshes) {\n return promise;\n }\n\n const promises = new Array<Promise<Nullable<Float32Array>>>();\n let instanceCount = 0;\n\n const loadAttribute = (attribute: string) => {\n if (extension.attributes[attribute] == undefined) {\n promises.push(Promise.resolve(null));\n return;\n }\n\n const accessor = ArrayItem.Get(`${extensionContext}/attributes/${attribute}`, this._loader.gltf.accessors, extension.attributes[attribute]);\n promises.push(this._loader._loadFloatAccessorAsync(`/accessors/${accessor.bufferView}`, accessor));\n\n if (instanceCount === 0) {\n instanceCount = accessor.count;\n } else if (instanceCount !== accessor.count) {\n throw new Error(`${extensionContext}/attributes: Instance buffer accessors do not have the same count.`);\n }\n };\n\n loadAttribute(\"TRANSLATION\");\n loadAttribute(\"ROTATION\");\n loadAttribute(\"SCALE\");\n\n return promise.then((babylonTransformNode) => {\n return Promise.all(promises).then(([translationBuffer, rotationBuffer, scaleBuffer]) => {\n const matrices = new Float32Array(instanceCount * 16);\n\n TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation\n TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation\n TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale\n\n for (let i = 0; i < instanceCount; ++i) {\n translationBuffer && Vector3.FromArrayToRef(translationBuffer, i * 3, TmpVectors.Vector3[0]);\n rotationBuffer && Quaternion.FromArrayToRef(rotationBuffer, i * 4, TmpVectors.Quaternion[0]);\n scaleBuffer && Vector3.FromArrayToRef(scaleBuffer, i * 3, TmpVectors.Vector3[1]);\n\n Matrix.ComposeToRef(TmpVectors.Vector3[1], TmpVectors.Quaternion[0], TmpVectors.Vector3[0], TmpVectors.Matrix[0]);\n\n TmpVectors.Matrix[0].copyToArray(matrices, i * 16);\n }\n\n for (const babylonMesh of node._primitiveBabylonMeshes!) {\n (babylonMesh as Mesh).thinInstanceSetBuffer(\"matrix\", matrices, 16, true);\n }\n\n return babylonTransformNode;\n });\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_mesh_gpu_instancing(loader));\n"]}
1
+ {"version":3,"file":"EXT_mesh_gpu_instancing.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAIhF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAG/D,OAAO,yCAAyC,CAAC;AAEjD,IAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;;;GAIG;AACH;IAaI,cAAc;IACd,iCAAY,MAAkB;QA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\nimport { Mesh } from '@babylonjs/core/Meshes/mesh';\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Nullable } from \"@babylonjs/core/types\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { INode } from \"../glTFLoaderInterfaces\";\nimport { TmpVectors } from '@babylonjs/core/Maths/math.vector';\nimport { IEXTMeshGpuInstancing } from \"babylonjs-gltf2interface\";\n\nimport \"@babylonjs/core/Meshes/thinInstanceMesh\";\n\nconst NAME = \"EXT_mesh_gpu_instancing\";\n\n/**\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)\n * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)\n * !!! Experimental Extension Subject to Changes !!!\n */\nexport class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IEXTMeshGpuInstancing, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n this._loader._disableInstancedMesh++;\n\n const promise = this._loader.loadNodeAsync(`/nodes/${node.index}`, node, assign);\n\n this._loader._disableInstancedMesh--;\n\n if (!node._primitiveBabylonMeshes) {\n return promise;\n }\n\n const promises = new Array<Promise<Nullable<Float32Array>>>();\n let instanceCount = 0;\n\n const loadAttribute = (attribute: string) => {\n if (extension.attributes[attribute] == undefined) {\n promises.push(Promise.resolve(null));\n return;\n }\n\n const accessor = ArrayItem.Get(`${extensionContext}/attributes/${attribute}`, this._loader.gltf.accessors, extension.attributes[attribute]);\n promises.push(this._loader._loadFloatAccessorAsync(`/accessors/${accessor.bufferView}`, accessor));\n\n if (instanceCount === 0) {\n instanceCount = accessor.count;\n } else if (instanceCount !== accessor.count) {\n throw new Error(`${extensionContext}/attributes: Instance buffer accessors do not have the same count.`);\n }\n };\n\n loadAttribute(\"TRANSLATION\");\n loadAttribute(\"ROTATION\");\n loadAttribute(\"SCALE\");\n\n return promise.then((babylonTransformNode) => {\n return Promise.all(promises).then(([translationBuffer, rotationBuffer, scaleBuffer]) => {\n const matrices = new Float32Array(instanceCount * 16);\n\n TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation\n TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation\n TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale\n\n for (let i = 0; i < instanceCount; ++i) {\n translationBuffer && Vector3.FromArrayToRef(translationBuffer, i * 3, TmpVectors.Vector3[0]);\n rotationBuffer && Quaternion.FromArrayToRef(rotationBuffer, i * 4, TmpVectors.Quaternion[0]);\n scaleBuffer && Vector3.FromArrayToRef(scaleBuffer, i * 3, TmpVectors.Vector3[1]);\n\n Matrix.ComposeToRef(TmpVectors.Vector3[1], TmpVectors.Quaternion[0], TmpVectors.Vector3[0], TmpVectors.Matrix[0]);\n\n TmpVectors.Matrix[0].copyToArray(matrices, i * 16);\n }\n\n for (const babylonMesh of node._primitiveBabylonMeshes!) {\n (babylonMesh as Mesh).thinInstanceSetBuffer(\"matrix\", matrices, 16, true);\n }\n\n return babylonTransformNode;\n });\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_mesh_gpu_instancing(loader));\n"]}
@@ -29,8 +29,8 @@ var EXT_meshopt_compression = /** @class */ (function () {
29
29
  if (bufferViewMeshopt._meshOptData) {
30
30
  return bufferViewMeshopt._meshOptData;
31
31
  }
32
- var buffer = ArrayItem.Get(context + "/buffer", _this._loader.gltf.buffers, extension.buffer);
33
- bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/" + buffer.index, buffer, (extension.byteOffset || 0), extension.byteLength).then(function (buffer) {
32
+ var buffer = ArrayItem.Get("".concat(context, "/buffer"), _this._loader.gltf.buffers, extension.buffer);
33
+ bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/".concat(buffer.index), buffer, (extension.byteOffset || 0), extension.byteLength).then(function (buffer) {
34
34
  return MeshoptCompression.Default.decodeGltfBufferAsync(buffer, extension.count, extension.byteStride, extension.mode, extension.filter);
35
35
  });
36
36
  return bufferViewMeshopt._meshOptData;
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_meshopt_compression.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAE3F,IAAM,IAAI,GAAG,yBAAyB,CAAC;AAMvC;;;;;GAKG;AACH;IAaI,cAAc;IACd,iCAAY,MAAkB;QAb9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAWxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,cAAc;IACP,yCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,cAAc;IACP,qDAAmB,GAA1B,UAA2B,OAAe,EAAE,UAAuB;QAAnE,iBAcC;QAbG,OAAO,UAAU,CAAC,kBAAkB,CAA0C,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,gBAAgB,EAAE,SAAS;YACtI,IAAM,iBAAiB,GAAG,UAAgC,CAAC;YAC3D,IAAI,iBAAiB,CAAC,YAAY,EAAE;gBAChC,OAAO,iBAAiB,CAAC,YAAY,CAAC;aACzC;YAED,IAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAI,OAAO,YAAS,EAAE,KAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;YAC/F,iBAAiB,CAAC,YAAY,GAAG,KAAI,CAAC,OAAO,CAAC,eAAe,CAAC,cAAY,MAAM,CAAC,KAAO,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,UAAC,MAAM;gBAC7J,OAAO,kBAAkB,CAAC,OAAO,CAAC,qBAAqB,CAAC,MAAoB,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;YAC3J,CAAC,CAAC,CAAC;YAEH,OAAO,iBAAiB,CAAC,YAAY,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;IACL,8BAAC;AAAD,CAAC,AAxCD,IAwCC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAnC,CAAmC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { ArrayItem, GLTFLoader } from \"../glTFLoader\";\nimport { IBufferView } from \"../glTFLoaderInterfaces\";\nimport { IEXTMeshoptCompression } from \"babylonjs-gltf2interface\";\nimport { MeshoptCompression } from \"@babylonjs/core/Meshes/Compression/meshoptCompression\";\n\nconst NAME = \"EXT_meshopt_compression\";\n\ninterface IBufferViewMeshopt extends IBufferView {\n _meshOptData?: Promise<ArrayBufferView>;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)\n *\n * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js\n * @since 5.0.0\n */\nexport class EXT_meshopt_compression implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this.enabled = loader.isExtensionUsed(NAME);\n this._loader = loader;\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>> {\n return GLTFLoader.LoadExtensionAsync<IEXTMeshoptCompression, ArrayBufferView>(context, bufferView, this.name, (extensionContext, extension) => {\n const bufferViewMeshopt = bufferView as IBufferViewMeshopt;\n if (bufferViewMeshopt._meshOptData) {\n return bufferViewMeshopt._meshOptData;\n }\n\n const buffer = ArrayItem.Get(`${context}/buffer`, this._loader.gltf.buffers, extension.buffer);\n bufferViewMeshopt._meshOptData = this._loader.loadBufferAsync(`/buffers/${buffer.index}`, buffer, (extension.byteOffset || 0), extension.byteLength).then((buffer) => {\n return MeshoptCompression.Default.decodeGltfBufferAsync(buffer as Uint8Array, extension.count, extension.byteStride, extension.mode, extension.filter);\n });\n\n return bufferViewMeshopt._meshOptData;\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_meshopt_compression(loader));\n"]}
1
+ {"version":3,"file":"EXT_meshopt_compression.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAE3F,IAAM,IAAI,GAAG,yBAAyB,CAAC;AAMvC;;;;;GAKG;AACH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P,CAAC;IACL,8BAAC;AAAD,CAAC,AAxCD,IAwCC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAnC,CAAmC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { ArrayItem, GLTFLoader } from \"../glTFLoader\";\nimport { IBufferView } from \"../glTFLoaderInterfaces\";\nimport { IEXTMeshoptCompression } from \"babylonjs-gltf2interface\";\nimport { MeshoptCompression } from \"@babylonjs/core/Meshes/Compression/meshoptCompression\";\n\nconst NAME = \"EXT_meshopt_compression\";\n\ninterface IBufferViewMeshopt extends IBufferView {\n _meshOptData?: Promise<ArrayBufferView>;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)\n *\n * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js\n * @since 5.0.0\n */\nexport class EXT_meshopt_compression implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this.enabled = loader.isExtensionUsed(NAME);\n this._loader = loader;\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>> {\n return GLTFLoader.LoadExtensionAsync<IEXTMeshoptCompression, ArrayBufferView>(context, bufferView, this.name, (extensionContext, extension) => {\n const bufferViewMeshopt = bufferView as IBufferViewMeshopt;\n if (bufferViewMeshopt._meshOptData) {\n return bufferViewMeshopt._meshOptData;\n }\n\n const buffer = ArrayItem.Get(`${context}/buffer`, this._loader.gltf.buffers, extension.buffer);\n bufferViewMeshopt._meshOptData = this._loader.loadBufferAsync(`/buffers/${buffer.index}`, buffer, (extension.byteOffset || 0), extension.byteLength).then((buffer) => {\n return MeshoptCompression.Default.decodeGltfBufferAsync(buffer as Uint8Array, extension.count, extension.byteStride, extension.mode, extension.filter);\n });\n\n return bufferViewMeshopt._meshOptData;\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_meshopt_compression(loader));\n"]}
@@ -19,8 +19,8 @@ var EXT_texture_webp = /** @class */ (function () {
19
19
  EXT_texture_webp.prototype._loadTextureAsync = function (context, texture, assign) {
20
20
  var _this = this;
21
21
  return GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) {
22
- var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(context + "/sampler", _this._loader.gltf.samplers, texture.sampler));
23
- var image = ArrayItem.Get(extensionContext + "/source", _this._loader.gltf.images, extension.source);
22
+ var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler));
23
+ var image = ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source);
24
24
  return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) {
25
25
  assign(babylonTexture);
26
26
  }, undefined, !texture._textureInfo.nonColorData);
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_texture_webp.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAMtD,IAAM,IAAI,GAAG,kBAAkB,CAAC;AAEhC;;GAEG;AACH;IASI,cAAc;IACd,0BAAY,MAAkB;QAT9B,kCAAkC;QAClB,SAAI,GAAG,IAAI,CAAC;QASxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,M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\nimport { ITexture } from \"../glTFLoaderInterfaces\";\r\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { IEXTTextureWebP } from 'babylonjs-gltf2interface';\r\n\r\nconst NAME = \"EXT_texture_webp\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)\r\n */\r\nexport class EXT_texture_webp implements IGLTFLoaderExtension {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {\r\n return GLTFLoader.LoadExtensionAsync<IEXTTextureWebP, BaseTexture>(context, texture, this.name, (extensionContext, extension) => {\r\n const sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(`${context}/sampler`, this._loader.gltf.samplers, texture.sampler));\r\n const image = ArrayItem.Get(`${extensionContext}/source`, this._loader.gltf.images, extension.source);\r\n return this._loader._createTextureAsync(context, sampler, image, (babylonTexture) => {\r\n assign(babylonTexture);\r\n }, undefined, !texture._textureInfo.nonColorData);\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_texture_webp(loader));\r\n"]}
1
+ {"version":3,"file":"EXT_texture_webp.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAA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8BC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAA5B,CAA4B,CAAC,CAAC","sourcesContent":["import { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport { ITexture } from \"../glTFLoaderInterfaces\";\r\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { IEXTTextureWebP } from 'babylonjs-gltf2interface';\r\n\r\nconst NAME = \"EXT_texture_webp\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)\r\n */\r\nexport class EXT_texture_webp implements IGLTFLoaderExtension {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {\r\n return GLTFLoader.LoadExtensionAsync<IEXTTextureWebP, BaseTexture>(context, texture, this.name, (extensionContext, extension) => {\r\n const sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(`${context}/sampler`, this._loader.gltf.samplers, texture.sampler));\r\n const image = ArrayItem.Get(`${extensionContext}/source`, this._loader.gltf.images, extension.source);\r\n return this._loader._createTextureAsync(context, sampler, image, (babylonTexture) => {\r\n assign(babylonTexture);\r\n }, undefined, !texture._textureInfo.nonColorData);\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new EXT_texture_webp(loader));\r\n"]}
@@ -28,24 +28,44 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
28
28
  if (primitive.mode != undefined) {
29
29
  if (primitive.mode !== 5 /* TRIANGLE_STRIP */ &&
30
30
  primitive.mode !== 4 /* TRIANGLES */) {
31
- throw new Error(context + ": Unsupported mode " + primitive.mode);
31
+ throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode));
32
32
  }
33
33
  // TODO: handle triangle strips
34
34
  if (primitive.mode === 5 /* TRIANGLE_STRIP */) {
35
- throw new Error(context + ": Mode " + primitive.mode + " is not currently supported");
35
+ throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported"));
36
36
  }
37
37
  }
38
38
  var attributes = {};
39
+ var dividers = {};
39
40
  var loadAttribute = function (name, kind) {
40
41
  var uniqueId = extension.attributes[name];
41
- if (uniqueId == undefined) {
42
+ if (uniqueId === undefined || primitive.attributes[name] === undefined) {
42
43
  return;
43
44
  }
45
+ attributes[kind] = uniqueId;
46
+ var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._loader.gltf.accessors, primitive.attributes[name]);
47
+ if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
48
+ var divider = 1;
49
+ switch (accessor.componentType) {
50
+ case 5120 /* BYTE */:
51
+ divider = 127.0;
52
+ break;
53
+ case 5121 /* UNSIGNED_BYTE */:
54
+ divider = 255.0;
55
+ break;
56
+ case 5122 /* SHORT */:
57
+ divider = 32767.0;
58
+ break;
59
+ case 5123 /* UNSIGNED_SHORT */:
60
+ divider = 65535.0;
61
+ break;
62
+ }
63
+ dividers[kind] = divider;
64
+ }
44
65
  babylonMesh._delayInfo = babylonMesh._delayInfo || [];
45
66
  if (babylonMesh._delayInfo.indexOf(kind) === -1) {
46
67
  babylonMesh._delayInfo.push(kind);
47
68
  }
48
- attributes[kind] = uniqueId;
49
69
  };
50
70
  loadAttribute("POSITION", VertexBuffer.PositionKind);
51
71
  loadAttribute("NORMAL", VertexBuffer.NormalKind);
@@ -61,14 +81,14 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
61
81
  loadAttribute("COLOR_0", VertexBuffer.ColorKind);
62
82
  var bufferView = ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView);
63
83
  if (!bufferView._dracoBabylonGeometry) {
64
- bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView).then(function (data) {
84
+ bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
65
85
  var dracoCompression = _this.dracoCompression || DracoCompression.Default;
66
- return dracoCompression.decodeMeshAsync(data, attributes).then(function (babylonVertexData) {
86
+ return dracoCompression.decodeMeshAsync(data, attributes, dividers).then(function (babylonVertexData) {
67
87
  var babylonGeometry = new Geometry(babylonMesh.name, _this._loader.babylonScene);
68
88
  babylonVertexData.applyToGeometry(babylonGeometry);
69
89
  return babylonGeometry;
70
90
  }).catch(function (error) {
71
- throw new Error(context + ": " + error.message);
91
+ throw new Error("".concat(context, ": ").concat(error.message));
72
92
  });
73
93
  });
74
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,4BAA4B,CAAC;AAM1C;;GAEG;AACH;IAkBI,cAAc;IACd,oCAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,C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KAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,OAAO,CAAC;oBAC3E,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,UAAC,iBAAiB;wBAC7E,IAAM,eAAe,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;wBAClF,iBAAiB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;wBACnD,OAAO,eAAe,CAAC;oBAC3B,CAAC,CAAC,CAAC,KAAK,CAAC,UAAC,KAAK;wBACX,MAAM,IAAI,KAAK,CAAI,OAAO,UAAK,KAAK,CAAC,OAAS,CAAC,CAAC;oBACpD,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;YAED,OAAO,UAAU,CAAC,qBAAqB,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IACL,iCAAC;AAAD,CAAC,AA1FD,IA0FC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { DracoCompression } from \"@babylonjs/core/Meshes/Compression/dracoCompression\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\r\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry\";\r\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\r\n\r\nimport { MeshPrimitiveMode, IKHRDracoMeshCompression } from \"babylonjs-gltf2interface\";\r\nimport { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)\r\n */\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP &&\r\n primitive.mode !== MeshPrimitiveMode.TRIANGLES) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n\r\n // TODO: handle triangle strips\r\n if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);\r\n }\r\n }\r\n\r\n const attributes: { [kind: string]: number } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId == undefined) {\r\n return;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n var bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression.decodeMeshAsync(data, attributes).then((babylonVertexData) => {\r\n const babylonGeometry = new Geometry(babylonMesh.name, this._loader.babylonScene);\r\n babylonVertexData.applyToGeometry(babylonGeometry);\r\n return babylonGeometry;\r\n }).catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));"]}
1
+ {"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/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,CAAC,CAAC,IAAI,CAAC,UAAC,iBAAiB;wBACvF,IAAM,eAAe,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;wBAClF,iBAAiB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;wBACnD,OAAO,eAAe,CAAC;oBAC3B,CAAC,CAAC,CAAC,KAAK,CAAC,UAAC,KAAK;wBACX,MAAM,IAAI,KAAK,CAAC,UAAG,OAAO,eAAK,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC;oBACpD,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;YAED,OAAO,UAAU,CAAC,qBAAqB,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IACL,iCAAC;AAAD,CAAC,AAnHD,IAmHC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { DracoCompression } from \"@babylonjs/core/Meshes/Compression/dracoCompression\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\r\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry\";\r\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\r\n\r\nimport { MeshPrimitiveMode, IKHRDracoMeshCompression, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)\r\n */\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP &&\r\n primitive.mode !== MeshPrimitiveMode.TRIANGLES) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n\r\n // TODO: handle triangle strips\r\n if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);\r\n }\r\n }\r\n\r\n const attributes: {\r\n [kind: string]: number\r\n } = {};\r\n const dividers: {\r\n [kind: string]: number\r\n } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId === undefined || primitive.attributes[name] === undefined) {\r\n return;\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n const accessor = ArrayItem.Get(`${context}/attributes/${name}`, this._loader.gltf.accessors, primitive.attributes[name]);\r\n if (accessor.normalized && accessor.componentType !== AccessorComponentType.FLOAT) {\r\n let divider = 1;\r\n switch (accessor.componentType) {\r\n case AccessorComponentType.BYTE:\r\n divider = 127.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_BYTE:\r\n divider = 255.0;\r\n break;\r\n case AccessorComponentType.SHORT:\r\n divider = 32767.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_SHORT:\r\n divider = 65535.0;\r\n break;\r\n }\r\n dividers[kind] = divider;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n var bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression.decodeMeshAsync(data, attributes, dividers).then((babylonVertexData) => {\r\n const babylonGeometry = new Geometry(babylonMesh.name, this._loader.babylonScene);\r\n babylonVertexData.applyToGeometry(babylonGeometry);\r\n return babylonGeometry;\r\n }).catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));"]}
@@ -59,7 +59,7 @@ var KHR_lights = /** @class */ (function () {
59
59
  }
60
60
  default: {
61
61
  _this._loader.babylonScene._blockEntityCollection = false;
62
- throw new Error(extensionContext + ": Invalid light type (" + light.type + ")");
62
+ throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")"));
63
63
  }
64
64
  }
65
65
  babylonLight._parentContainer = _this._loader._assetContainer;
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAMrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH;IAcI,cAAc;IACd,oBAAY,MAAkB;QAd9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAYxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAA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OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACpF,YAAY,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;gBAC5E,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC/E,YAAY,CAAC,MAAM,GAAG,WAAW,CAAC;gBAElC,KAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAE/C,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;gBAE9D,MAAM,CAAC,WAAW,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACL,iBAAC;AAAD,CAAC,AApFD,IAoFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,UAAU,CAAC,MAAM,CAAC,EAAtB,CAAsB,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight\";\nimport { PointLight } from \"@babylonjs/core/Lights/pointLight\";\nimport { SpotLight } from \"@babylonjs/core/Lights/spotLight\";\nimport { Light } from \"@babylonjs/core/Lights/light\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\n\nimport { IKHRLightsPunctual_LightType, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\nimport { INode } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\n\nconst NAME = \"KHR_lights_punctual\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)\n */\nexport class KHR_lights implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n private _lights?: IKHRLightsPunctual_Light[];\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n delete this._lights;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IKHRLightsPunctual;\n this._lights = extension.lights;\n }\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IKHRLightsPunctual_LightReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n return this._loader.loadNodeAsync(context, node, (babylonMesh) => {\n let babylonLight: Light;\n\n const light = ArrayItem.Get(extensionContext, this._lights, extension.light);\n const name = light.name || babylonMesh.name;\n\n this._loader.babylonScene._blockEntityCollection = !!this._loader._assetContainer;\n\n switch (light.type) {\n case IKHRLightsPunctual_LightType.DIRECTIONAL: {\n babylonLight = new DirectionalLight(name, Vector3.Backward(), this._loader.babylonScene);\n break;\n }\n case IKHRLightsPunctual_LightType.POINT: {\n babylonLight = new PointLight(name, Vector3.Zero(), this._loader.babylonScene);\n break;\n }\n case IKHRLightsPunctual_LightType.SPOT: {\n const babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 1, this._loader.babylonScene);\n babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;\n babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;\n babylonLight = babylonSpotLight;\n break;\n }\n default: {\n this._loader.babylonScene._blockEntityCollection = false;\n throw new Error(`${extensionContext}: Invalid light type (${light.type})`);\n }\n }\n\n babylonLight._parentContainer = this._loader._assetContainer;\n this._loader.babylonScene._blockEntityCollection = false;\n babylonLight.falloffType = Light.FALLOFF_GLTF;\n babylonLight.diffuse = light.color ? Color3.FromArray(light.color) : Color3.White();\n babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;\n babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;\n babylonLight.parent = babylonMesh;\n\n this._loader._babylonLights.push(babylonLight);\n\n GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);\n\n assign(babylonMesh);\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_lights(loader));"]}
1
+ {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAMrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH;IAcI,cAAc;IACd,oBA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AAC,OAAO,CAAC,YAAY,CAAC,sBAAsB,GAAG,KAAK,CAAC;gBACzD,YAAY,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC;gBAC9C,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACpF,YAAY,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;gBAC5E,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC/E,YAAY,CAAC,MAAM,GAAG,WAAW,CAAC;gBAElC,KAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAE/C,UAAU,CAAC,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;gBAE9D,MAAM,CAAC,WAAW,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACL,iBAAC;AAAD,CAAC,AApFD,IAoFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,UAAU,CAAC,MAAM,CAAC,EAAtB,CAAsB,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight\";\nimport { PointLight } from \"@babylonjs/core/Lights/pointLight\";\nimport { SpotLight } from \"@babylonjs/core/Lights/spotLight\";\nimport { Light } from \"@babylonjs/core/Lights/light\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\n\nimport { IKHRLightsPunctual_LightType, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\nimport { INode } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\n\nconst NAME = \"KHR_lights_punctual\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)\n */\nexport class KHR_lights implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n private _lights?: IKHRLightsPunctual_Light[];\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n delete this._lights;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IKHRLightsPunctual;\n this._lights = extension.lights;\n }\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IKHRLightsPunctual_LightReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n return this._loader.loadNodeAsync(context, node, (babylonMesh) => {\n let babylonLight: Light;\n\n const light = ArrayItem.Get(extensionContext, this._lights, extension.light);\n const name = light.name || babylonMesh.name;\n\n this._loader.babylonScene._blockEntityCollection = !!this._loader._assetContainer;\n\n switch (light.type) {\n case IKHRLightsPunctual_LightType.DIRECTIONAL: {\n babylonLight = new DirectionalLight(name, Vector3.Backward(), this._loader.babylonScene);\n break;\n }\n case IKHRLightsPunctual_LightType.POINT: {\n babylonLight = new PointLight(name, Vector3.Zero(), this._loader.babylonScene);\n break;\n }\n case IKHRLightsPunctual_LightType.SPOT: {\n const babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 1, this._loader.babylonScene);\n babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;\n babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;\n babylonLight = babylonSpotLight;\n break;\n }\n default: {\n this._loader.babylonScene._blockEntityCollection = false;\n throw new Error(`${extensionContext}: Invalid light type (${light.type})`);\n }\n }\n\n babylonLight._parentContainer = this._loader._assetContainer;\n this._loader.babylonScene._blockEntityCollection = false;\n babylonLight.falloffType = Light.FALLOFF_GLTF;\n babylonLight.diffuse = light.color ? Color3.FromArray(light.color) : Color3.White();\n babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;\n babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;\n babylonLight.parent = babylonMesh;\n\n this._loader._babylonLights.push(babylonLight);\n\n GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);\n\n assign(babylonMesh);\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_lights(loader));"]}
@@ -35,7 +35,7 @@ var KHR_materials_clearcoat = /** @class */ (function () {
35
35
  };
36
36
  KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) {
37
37
  if (!(babylonMaterial instanceof PBRMaterial)) {
38
- throw new Error(context + ": Material type not supported");
38
+ throw new Error("".concat(context, ": Material type not supported"));
39
39
  }
40
40
  var promises = new Array();
41
41
  babylonMaterial.clearCoat.isEnabled = true;
@@ -48,8 +48,8 @@ var KHR_materials_clearcoat = /** @class */ (function () {
48
48
  babylonMaterial.clearCoat.intensity = 0;
49
49
  }
50
50
  if (properties.clearcoatTexture) {
51
- promises.push(this._loader.loadTextureInfoAsync(context + "/clearcoatTexture", properties.clearcoatTexture, function (texture) {
52
- texture.name = babylonMaterial.name + " (ClearCoat Intensity)";
51
+ promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatTexture"), properties.clearcoatTexture, function (texture) {
52
+ texture.name = "".concat(babylonMaterial.name, " (ClearCoat Intensity)");
53
53
  babylonMaterial.clearCoat.texture = texture;
54
54
  }));
55
55
  }
@@ -61,15 +61,15 @@ var KHR_materials_clearcoat = /** @class */ (function () {
61
61
  }
62
62
  if (properties.clearcoatRoughnessTexture) {
63
63
  properties.clearcoatRoughnessTexture.nonColorData = true;
64
- promises.push(this._loader.loadTextureInfoAsync(context + "/clearcoatRoughnessTexture", properties.clearcoatRoughnessTexture, function (texture) {
65
- texture.name = babylonMaterial.name + " (ClearCoat Roughness)";
64
+ promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatRoughnessTexture"), properties.clearcoatRoughnessTexture, function (texture) {
65
+ texture.name = "".concat(babylonMaterial.name, " (ClearCoat Roughness)");
66
66
  babylonMaterial.clearCoat.textureRoughness = texture;
67
67
  }));
68
68
  }
69
69
  if (properties.clearcoatNormalTexture) {
70
70
  properties.clearcoatNormalTexture.nonColorData = true;
71
- promises.push(this._loader.loadTextureInfoAsync(context + "/clearcoatNormalTexture", properties.clearcoatNormalTexture, function (texture) {
72
- texture.name = babylonMaterial.name + " (ClearCoat Normal)";
71
+ promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatNormalTexture"), properties.clearcoatNormalTexture, function (texture) {
72
+ texture.name = "".concat(babylonMaterial.name, " (ClearCoat Normal)");
73
73
  babylonMaterial.clearCoat.bumpTexture = texture;
74
74
  }));
75
75
  babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem;