@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
@@ -1 +1 @@
1
- {"version":3,"file":"glTFValidation.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/glTF/glTFValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQnD,SAAS,aAAa,CAAC,IAA0B,EAAE,OAAe,EAAE,QAAgB,EAAE,mBAA0D;IAC5I,IAAM,OAAO,GAAiC;QAC1C,wBAAwB,EAAE,UAAC,GAAG,IAAK,OAAA,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAC,KAAK,IAAK,OAAA,IAAI,UAAU,CAAC,KAAK,CAAC,EAArB,CAAqB,CAAC,EAA/D,CAA+D;KACrG,CAAC;IAEF,IAAI,QAAQ,EAAE;QACV,OAAO,CAAC,GAAG,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;KACvE;IAED,OAAO,CAAC,IAAI,YAAY,WAAW,CAAC;QAChC,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAC5D,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,SAAS,UAAU;IACf,IAAM,wBAAwB,GAA2E,EAAE,CAAC;IAE5G,SAAS,GAAG,UAAC,OAAO;QAChB,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,QAAQ,IAAI,CAAC,EAAE,EAAE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C,CAAC;YACvE,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAvED;;OAEG;IACW,4BAAa,GAAiC;QACxD,GAAG,EAAE,iDAAiD;KACzD,CAAC;IAmEN,qBAAC;CAAA,AAzED,IAyEC;SAzEY,cAAc","sourcesContent":["import * as GLTF2 from 'babylonjs-gltf2interface';\r\nimport { Tools } from '@babylonjs/core/Misc/tools';\r\n\r\ndeclare var GLTFValidator: GLTF2.IGLTFValidator;\r\n\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: any, transfer?: any[]): void;\r\n\r\nfunction validateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<GLTF2.IGLTFValidationResults> {\r\n const options: GLTF2.IGLTFValidationOptions = {\r\n externalResourceFunction: (uri) => getExternalResource(uri).then((value) => new Uint8Array(value))\r\n };\r\n\r\n if (fileName) {\r\n options.uri = (rootUrl === \"file:\" ? fileName : rootUrl + fileName);\r\n }\r\n\r\n return (data instanceof ArrayBuffer)\r\n ? GLTFValidator.validateBytes(new Uint8Array(data), options)\r\n : GLTFValidator.validateString(data, options);\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n */\r\nfunction workerFunc(): void {\r\n const pendingExternalResources: Array<{ resolve: (data: any) => void, reject: (reason: any) => void }> = [];\r\n\r\n onmessage = (message) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"init\": {\r\n importScripts(data.url);\r\n break;\r\n }\r\n case \"validate\": {\r\n validateAsync(data.data, data.rootUrl, data.fileName, (uri) => new Promise((resolve, reject) => {\r\n const index = pendingExternalResources.length;\r\n pendingExternalResources.push({ resolve, reject });\r\n postMessage({ id: \"getExternalResource\", index: index, uri: uri });\r\n })).then((value) => {\r\n postMessage({ id: \"validate.resolve\", value: value });\r\n }, (reason) => {\r\n postMessage({ id: \"validate.reject\", reason: reason });\r\n });\r\n break;\r\n }\r\n case \"getExternalResource.resolve\": {\r\n pendingExternalResources[data.index].resolve(data.value);\r\n break;\r\n }\r\n case \"getExternalResource.reject\": {\r\n pendingExternalResources[data.index].reject(data.reason);\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Configuration for glTF validation\r\n */\r\nexport interface IGLTFValidationConfiguration {\r\n /**\r\n * The url of the glTF validator.\r\n */\r\n url: string;\r\n}\r\n\r\n/**\r\n * glTF validation\r\n */\r\nexport class GLTFValidation {\r\n /**\r\n * The configuration. Defaults to `{ url: \"https://preview.babylonjs.com/gltf_validator.js\" }`.\r\n */\r\n public static Configuration: IGLTFValidationConfiguration = {\r\n url: \"https://preview.babylonjs.com/gltf_validator.js\"\r\n };\r\n\r\n private static _LoadScriptPromise: Promise<void>;\r\n\r\n /**\r\n * Validate a glTF asset using the glTF-Validator.\r\n * @param data The JSON of a glTF or the array buffer of a binary glTF\r\n * @param rootUrl The root url for the glTF\r\n * @param fileName The file name for the glTF\r\n * @param getExternalResource The callback to get external resources for the glTF validator\r\n * @returns A promise that resolves with the glTF validation results once complete\r\n */\r\n public static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<GLTF2.IGLTFValidationResults> {\r\n if (typeof Worker === \"function\") {\r\n return new Promise((resolve, reject) => {\r\n const workerContent = `${validateAsync}(${workerFunc})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n const worker = new Worker(workerBlobUrl);\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (message: MessageEvent) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"getExternalResource\": {\r\n getExternalResource(data.uri).then((value) => {\r\n worker.postMessage({ id: \"getExternalResource.resolve\", index: data.index, value: value }, [value]);\r\n }, (reason) => {\r\n worker.postMessage({ id: \"getExternalResource.reject\", index: data.index, reason: reason });\r\n });\r\n break;\r\n }\r\n case \"validate.resolve\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(data.value);\r\n break;\r\n }\r\n case \"validate.reject\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(data.reason);\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n worker.postMessage({ id: \"init\", url: this.Configuration.url });\r\n worker.postMessage({ id: \"validate\", data: data, rootUrl: rootUrl, fileName: fileName });\r\n });\r\n }\r\n else {\r\n if (!this._LoadScriptPromise) {\r\n this._LoadScriptPromise = Tools.LoadScriptAsync(this.Configuration.url);\r\n }\r\n\r\n return this._LoadScriptPromise.then(() => {\r\n return validateAsync(data, rootUrl, fileName, getExternalResource);\r\n });\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"glTFValidation.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/glTF/glTFValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQnD,SAAS,aAAa,CAAC,IAA0B,EAAE,OAAe,EAAE,QAAgB,EAAE,mBAA0D;IAC5I,IAAM,OAAO,GAAiC;QAC1C,wBAAwB,EAAE,UAAC,GAAG,IAAK,OAAA,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAC,KAAK,IAAK,OAAA,IAAI,UAAU,CAAC,KAAK,CAAC,EAArB,CAAqB,CAAC,EAA/D,CAA+D;KACrG,CAAC;IAEF,IAAI,QAAQ,EAAE;QACV,OAAO,CAAC,GAAG,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;KACvE;IAED,OAAO,CAAC,IA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E,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC7F,CAAC,CAAC,CAAC;SACN;aACI;YACD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;gBAC1B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;aAC3E;YAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;gBAChC,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAvED;;OAEG;IACW,4BAAa,GAAiC;QACxD,GAAG,EAAE,iDAAiD;KACzD,CAAC;IAmEN,qBAAC;CAAA,AAzED,IAyEC;SAzEY,cAAc","sourcesContent":["import * as GLTF2 from 'babylonjs-gltf2interface';\r\nimport { Tools } from '@babylonjs/core/Misc/tools';\r\n\r\ndeclare var GLTFValidator: GLTF2.IGLTFValidator;\r\n\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: any, transfer?: any[]): void;\r\n\r\nfunction validateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<GLTF2.IGLTFValidationResults> {\r\n const options: GLTF2.IGLTFValidationOptions = {\r\n externalResourceFunction: (uri) => getExternalResource(uri).then((value) => new Uint8Array(value))\r\n };\r\n\r\n if (fileName) {\r\n options.uri = (rootUrl === \"file:\" ? fileName : rootUrl + fileName);\r\n }\r\n\r\n return (data instanceof ArrayBuffer)\r\n ? GLTFValidator.validateBytes(new Uint8Array(data), options)\r\n : GLTFValidator.validateString(data, options);\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n */\r\nfunction workerFunc(): void {\r\n const pendingExternalResources: Array<{ resolve: (data: any) => void, reject: (reason: any) => void }> = [];\r\n\r\n onmessage = (message) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"init\": {\r\n importScripts(data.url);\r\n break;\r\n }\r\n case \"validate\": {\r\n validateAsync(data.data, data.rootUrl, data.fileName, (uri) => new Promise((resolve, reject) => {\r\n const index = pendingExternalResources.length;\r\n pendingExternalResources.push({ resolve, reject });\r\n postMessage({ id: \"getExternalResource\", index: index, uri: uri });\r\n })).then((value) => {\r\n postMessage({ id: \"validate.resolve\", value: value });\r\n }, (reason) => {\r\n postMessage({ id: \"validate.reject\", reason: reason });\r\n });\r\n break;\r\n }\r\n case \"getExternalResource.resolve\": {\r\n pendingExternalResources[data.index].resolve(data.value);\r\n break;\r\n }\r\n case \"getExternalResource.reject\": {\r\n pendingExternalResources[data.index].reject(data.reason);\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Configuration for glTF validation\r\n */\r\nexport interface IGLTFValidationConfiguration {\r\n /**\r\n * The url of the glTF validator.\r\n */\r\n url: string;\r\n}\r\n\r\n/**\r\n * glTF validation\r\n */\r\nexport class GLTFValidation {\r\n /**\r\n * The configuration. Defaults to `{ url: \"https://preview.babylonjs.com/gltf_validator.js\" }`.\r\n */\r\n public static Configuration: IGLTFValidationConfiguration = {\r\n url: \"https://preview.babylonjs.com/gltf_validator.js\"\r\n };\r\n\r\n private static _LoadScriptPromise: Promise<void>;\r\n\r\n /**\r\n * Validate a glTF asset using the glTF-Validator.\r\n * @param data The JSON of a glTF or the array buffer of a binary glTF\r\n * @param rootUrl The root url for the glTF\r\n * @param fileName The file name for the glTF\r\n * @param getExternalResource The callback to get external resources for the glTF validator\r\n * @returns A promise that resolves with the glTF validation results once complete\r\n */\r\n public static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<GLTF2.IGLTFValidationResults> {\r\n if (typeof Worker === \"function\") {\r\n return new Promise((resolve, reject) => {\r\n const workerContent = `${validateAsync}(${workerFunc})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n const worker = new Worker(workerBlobUrl);\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (message: MessageEvent) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"getExternalResource\": {\r\n getExternalResource(data.uri).then((value) => {\r\n worker.postMessage({ id: \"getExternalResource.resolve\", index: data.index, value: value }, [value]);\r\n }, (reason) => {\r\n worker.postMessage({ id: \"getExternalResource.reject\", index: data.index, reason: reason });\r\n });\r\n break;\r\n }\r\n case \"validate.resolve\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(data.value);\r\n break;\r\n }\r\n case \"validate.reject\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(data.reason);\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n worker.postMessage({ id: \"init\", url: this.Configuration.url });\r\n worker.postMessage({ id: \"validate\", data: data, rootUrl: rootUrl, fileName: fileName });\r\n });\r\n }\r\n else {\r\n if (!this._LoadScriptPromise) {\r\n this._LoadScriptPromise = Tools.LoadScriptAsync(this.Configuration.url);\r\n }\r\n\r\n return this._LoadScriptPromise.then(() => {\r\n return validateAsync(data, rootUrl, fileName, getExternalResource);\r\n });\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "name": "@babylonjs/loaders",
6
6
  "description": "The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.",
7
- "version": "5.0.0-beta.1",
7
+ "version": "5.0.0-beta.10",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -194,8 +194,8 @@
194
194
  ],
195
195
  "license": "Apache-2.0",
196
196
  "dependencies": {
197
- "babylonjs-gltf2interface": "5.0.0-beta.1",
198
- "@babylonjs/core": "5.0.0-beta.1",
197
+ "babylonjs-gltf2interface": "5.0.0-beta.10",
198
+ "@babylonjs/core": "5.0.0-beta.10",
199
199
  "tslib": "^2.3.1"
200
200
  },
201
201
  "engines": {