@graphty/graphty-element 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{basisTextureLoader-BqIvxvNl.js → basisTextureLoader-YJHdQGdC.js} +2 -2
- package/dist/{basisTextureLoader-BqIvxvNl.js.map → basisTextureLoader-YJHdQGdC.js.map} +1 -1
- package/dist/{dds-BlAaKjyJ.js → dds-DQLf_hLn.js} +2 -2
- package/dist/{dds-BlAaKjyJ.js.map → dds-DQLf_hLn.js.map} +1 -1
- package/dist/{ddsTextureLoader-D7Jh83wc.js → ddsTextureLoader-lj5EmdyW.js} +3 -3
- package/dist/{ddsTextureLoader-D7Jh83wc.js.map → ddsTextureLoader-lj5EmdyW.js.map} +1 -1
- package/dist/{default.fragment-CSeCDRwv.js → default.fragment-Blpb62wl.js} +6 -6
- package/dist/{default.fragment-CSeCDRwv.js.map → default.fragment-Blpb62wl.js.map} +1 -1
- package/dist/{default.fragment-BNc4beoN.js → default.fragment-BqlvuhH_.js} +6 -6
- package/dist/{default.fragment-BNc4beoN.js.map → default.fragment-BqlvuhH_.js.map} +1 -1
- package/dist/{default.vertex-9pBFrn06.js → default.vertex-BibOEUcC.js} +7 -7
- package/dist/{default.vertex-9pBFrn06.js.map → default.vertex-BibOEUcC.js.map} +1 -1
- package/dist/{default.vertex-DDjK1DRv.js → default.vertex-Dblk9O84.js} +7 -7
- package/dist/{default.vertex-DDjK1DRv.js.map → default.vertex-Dblk9O84.js.map} +1 -1
- package/dist/{defaultUboDeclaration-Ct5CiQ-w.js → defaultUboDeclaration-CO0hcGNU.js} +3 -3
- package/dist/{defaultUboDeclaration-Ct5CiQ-w.js.map → defaultUboDeclaration-CO0hcGNU.js.map} +1 -1
- package/dist/{defaultUboDeclaration-CG47IDRY.js → defaultUboDeclaration-D2cHxVkr.js} +3 -3
- package/dist/{defaultUboDeclaration-CG47IDRY.js.map → defaultUboDeclaration-D2cHxVkr.js.map} +1 -1
- package/dist/{dumpTools-DA1xMSIZ.js → dumpTools-DryVPnxm.js} +4 -4
- package/dist/{dumpTools-DA1xMSIZ.js.map → dumpTools-DryVPnxm.js.map} +1 -1
- package/dist/{envTextureLoader-DdCLpySN.js → envTextureLoader-zUp-sm34.js} +4 -4
- package/dist/{envTextureLoader-DdCLpySN.js.map → envTextureLoader-zUp-sm34.js.map} +1 -1
- package/dist/{exrTextureLoader-CnJSRQ9w.js → exrTextureLoader-CWNwDbqP.js} +2 -2
- package/dist/{exrTextureLoader-CnJSRQ9w.js.map → exrTextureLoader-CWNwDbqP.js.map} +1 -1
- package/dist/graphty.js +1 -1
- package/dist/{greasedLine.fragment-DixuqXus.js → greasedLine.fragment-BtdnWwPJ.js} +2 -2
- package/dist/{greasedLine.fragment-DixuqXus.js.map → greasedLine.fragment-BtdnWwPJ.js.map} +1 -1
- package/dist/{greasedLine.fragment-BZnGGe-r.js → greasedLine.fragment-DakXbZDt.js} +2 -2
- package/dist/{greasedLine.fragment-BZnGGe-r.js.map → greasedLine.fragment-DakXbZDt.js.map} +1 -1
- package/dist/{greasedLine.vertex-BhhwFKPy.js → greasedLine.vertex-DbhEvmnm.js} +3 -3
- package/dist/{greasedLine.vertex-BhhwFKPy.js.map → greasedLine.vertex-DbhEvmnm.js.map} +1 -1
- package/dist/{greasedLine.vertex-DIhgGSOi.js → greasedLine.vertex-Lh32HaiU.js} +4 -4
- package/dist/{greasedLine.vertex-DIhgGSOi.js.map → greasedLine.vertex-Lh32HaiU.js.map} +1 -1
- package/dist/{harmonicsFunctions-B9jTNKTF.js → harmonicsFunctions-Bki1gBZd.js} +3 -3
- package/dist/{harmonicsFunctions-B9jTNKTF.js.map → harmonicsFunctions-Bki1gBZd.js.map} +1 -1
- package/dist/{harmonicsFunctions-D9ZL5yLA.js → harmonicsFunctions-CjRTo-m9.js} +3 -3
- package/dist/{harmonicsFunctions-D9ZL5yLA.js.map → harmonicsFunctions-CjRTo-m9.js.map} +1 -1
- package/dist/{hdrTextureLoader-DreWCvHD.js → hdrTextureLoader-CLKfu37v.js} +2 -2
- package/dist/{hdrTextureLoader-DreWCvHD.js.map → hdrTextureLoader-CLKfu37v.js.map} +1 -1
- package/dist/{helperFunctions-Dh1WD8YN.js → helperFunctions-CQxHHy8r.js} +2 -2
- package/dist/{helperFunctions-Dh1WD8YN.js.map → helperFunctions-CQxHHy8r.js.map} +1 -1
- package/dist/{helperFunctions-ZBnqb-in.js → helperFunctions-TtJlWReK.js} +2 -2
- package/dist/{helperFunctions-ZBnqb-in.js.map → helperFunctions-TtJlWReK.js.map} +1 -1
- package/dist/{iesTextureLoader-JdfAyRK-.js → iesTextureLoader-BcJl2Arq.js} +2 -2
- package/dist/{iesTextureLoader-JdfAyRK-.js.map → iesTextureLoader-BcJl2Arq.js.map} +1 -1
- package/dist/{index-ChGTkj2q.js → index-DM3Dwe0V.js} +16 -16
- package/dist/{index-ChGTkj2q.js.map → index-DM3Dwe0V.js.map} +1 -1
- package/dist/{instancesVertex-evcSIvCA.js → instancesVertex-Dr04ZqKw.js} +2 -2
- package/dist/{instancesVertex-evcSIvCA.js.map → instancesVertex-Dr04ZqKw.js.map} +1 -1
- package/dist/{instancesVertex-BrWNnWxF.js → instancesVertex-DzC88b5Z.js} +2 -2
- package/dist/{instancesVertex-BrWNnWxF.js.map → instancesVertex-DzC88b5Z.js.map} +1 -1
- package/dist/{ktxTextureLoader-Dg1h0a-4.js → ktxTextureLoader-O794CBz4.js} +2 -2
- package/dist/{ktxTextureLoader-Dg1h0a-4.js.map → ktxTextureLoader-O794CBz4.js.map} +1 -1
- package/dist/{logDepthDeclaration-BHUUDd5l.js → logDepthDeclaration--8Jq3fys.js} +2 -2
- package/dist/{logDepthDeclaration-BHUUDd5l.js.map → logDepthDeclaration--8Jq3fys.js.map} +1 -1
- package/dist/{logDepthDeclaration-Bou5AJOP.js → logDepthDeclaration-DcveQRTq.js} +2 -2
- package/dist/{logDepthDeclaration-Bou5AJOP.js.map → logDepthDeclaration-DcveQRTq.js.map} +1 -1
- package/dist/{logDepthVertex-r_niddz9.js → logDepthVertex-BiWlUDke.js} +2 -2
- package/dist/{logDepthVertex-r_niddz9.js.map → logDepthVertex-BiWlUDke.js.map} +1 -1
- package/dist/{logDepthVertex-CCFGLExi.js → logDepthVertex-CYjRNQ1d.js} +2 -2
- package/dist/{logDepthVertex-CCFGLExi.js.map → logDepthVertex-CYjRNQ1d.js.map} +1 -1
- package/dist/{meshUboDeclaration-Dg__Mhmj.js → meshUboDeclaration-BmcefUDK.js} +2 -2
- package/dist/{meshUboDeclaration-Dg__Mhmj.js.map → meshUboDeclaration-BmcefUDK.js.map} +1 -1
- package/dist/{oitFragment-Bn29Ggvj.js → oitFragment-DP-aFNyo.js} +2 -2
- package/dist/{oitFragment-Bn29Ggvj.js.map → oitFragment-DP-aFNyo.js.map} +1 -1
- package/dist/{oitFragment-D6JBEGk0.js → oitFragment-DzgaBzc0.js} +2 -2
- package/dist/{oitFragment-D6JBEGk0.js.map → oitFragment-DzgaBzc0.js.map} +1 -1
- package/dist/{pass.fragment-Cf0ob1Y3.js → pass.fragment-DoZCyELK.js} +2 -2
- package/dist/{pass.fragment-Cf0ob1Y3.js.map → pass.fragment-DoZCyELK.js.map} +1 -1
- package/dist/{pass.fragment-C9O4ZLJL.js → pass.fragment-DxSTcWpC.js} +2 -2
- package/dist/{pass.fragment-C9O4ZLJL.js.map → pass.fragment-DxSTcWpC.js.map} +1 -1
- package/dist/{passCube.fragment-uM4B7TOI.js → passCube.fragment-Dv4FB3Ug.js} +2 -2
- package/dist/{passCube.fragment-uM4B7TOI.js.map → passCube.fragment-Dv4FB3Ug.js.map} +1 -1
- package/dist/{passCube.fragment-Mg8Qj5T9.js → passCube.fragment-nsqY0ZtC.js} +2 -2
- package/dist/{passCube.fragment-Mg8Qj5T9.js.map → passCube.fragment-nsqY0ZtC.js.map} +1 -1
- package/dist/{pbr.fragment-C8Lm3cwF.js → pbr.fragment-B13QduZT.js} +6 -6
- package/dist/{pbr.fragment-C8Lm3cwF.js.map → pbr.fragment-B13QduZT.js.map} +1 -1
- package/dist/{pbr.fragment-siOdCYqI.js → pbr.fragment-B6tx_cvK.js} +6 -6
- package/dist/{pbr.fragment-siOdCYqI.js.map → pbr.fragment-B6tx_cvK.js.map} +1 -1
- package/dist/{pbr.vertex-CmEPCcBW.js → pbr.vertex-CA7bnQjU.js} +7 -7
- package/dist/{pbr.vertex-CmEPCcBW.js.map → pbr.vertex-CA7bnQjU.js.map} +1 -1
- package/dist/{pbr.vertex-Bw_TrGQv.js → pbr.vertex-DW6iNOI2.js} +7 -7
- package/dist/{pbr.vertex-Bw_TrGQv.js.map → pbr.vertex-DW6iNOI2.js.map} +1 -1
- package/dist/{postprocess.vertex-B086G8mM.js → postprocess.vertex-DZzYDZfo.js} +2 -2
- package/dist/{postprocess.vertex-B086G8mM.js.map → postprocess.vertex-DZzYDZfo.js.map} +1 -1
- package/dist/{rgbdDecode.fragment-bNaGtQ-x.js → rgbdDecode.fragment-CAcs2JmP.js} +3 -3
- package/dist/{rgbdDecode.fragment-bNaGtQ-x.js.map → rgbdDecode.fragment-CAcs2JmP.js.map} +1 -1
- package/dist/{rgbdDecode.fragment-koAcppx0.js → rgbdDecode.fragment-E4n4lu8J.js} +3 -3
- package/dist/{rgbdDecode.fragment-koAcppx0.js.map → rgbdDecode.fragment-E4n4lu8J.js.map} +1 -1
- package/dist/{rgbdEncode.fragment-BDHL2P_i.js → rgbdEncode.fragment-CgYUAa43.js} +3 -3
- package/dist/{rgbdEncode.fragment-BDHL2P_i.js.map → rgbdEncode.fragment-CgYUAa43.js.map} +1 -1
- package/dist/{rgbdEncode.fragment-Dw0FS9aH.js → rgbdEncode.fragment-DCdpffcW.js} +3 -3
- package/dist/{rgbdEncode.fragment-Dw0FS9aH.js.map → rgbdEncode.fragment-DCdpffcW.js.map} +1 -1
- package/dist/{tgaTextureLoader-DIfkfgQh.js → tgaTextureLoader-DPWaEGJH.js} +2 -2
- package/dist/{tgaTextureLoader-DIfkfgQh.js.map → tgaTextureLoader-DPWaEGJH.js.map} +1 -1
- package/package.json +9 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dumpTools-DA1xMSIZ.js","sources":["../node_modules/@babylonjs/core/Misc/dumpTools.js"],"sourcesContent":["\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer.js\";\nimport { Tools } from \"./tools.js\";\nimport { Clamp } from \"../Maths/math.scalar.functions.js\";\nimport { EngineStore } from \"../Engines/engineStore.js\";\nlet DumpToolsEngine;\nlet EnginePromise = null;\nasync function _CreateDumpRendererAsync() {\n if (!EnginePromise) {\n EnginePromise = new Promise((resolve, reject) => {\n let canvas;\n let engine = null;\n const options = {\n preserveDrawingBuffer: true,\n depth: false,\n stencil: false,\n alpha: true,\n premultipliedAlpha: false,\n antialias: false,\n failIfMajorPerformanceCaveat: false,\n };\n import(\"../Engines/thinEngine.js\")\n // eslint-disable-next-line github/no-then\n .then(({ ThinEngine: thinEngineClass }) => {\n const engineInstanceCount = EngineStore.Instances.length;\n try {\n canvas = new OffscreenCanvas(100, 100); // will be resized later\n engine = new thinEngineClass(canvas, false, options);\n }\n catch (e) {\n if (engineInstanceCount < EngineStore.Instances.length) {\n // The engine was created by another instance, let's use it\n EngineStore.Instances.pop()?.dispose();\n }\n // The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas\n canvas = document.createElement(\"canvas\");\n engine = new thinEngineClass(canvas, false, options);\n }\n // remove this engine from the list of instances to avoid using it for other purposes\n EngineStore.Instances.pop();\n // However, make sure to dispose it when no other engines are left\n EngineStore.OnEnginesDisposedObservable.add((e) => {\n // guaranteed to run when no other instances are left\n // only dispose if it's not the current engine\n if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {\n // Dump the engine and the associated resources\n Dispose();\n }\n });\n engine.getCaps().parallelShaderCompile = undefined;\n const renderer = new EffectRenderer(engine);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\n import(\"../Shaders/pass.fragment.js\").then(({ passPixelShader }) => {\n if (!engine) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(\"Engine is not defined\");\n return;\n }\n const wrapper = new EffectWrapper({\n engine,\n name: passPixelShader.name,\n fragmentShader: passPixelShader.shader,\n samplerNames: [\"textureSampler\"],\n });\n DumpToolsEngine = {\n canvas,\n engine,\n renderer,\n wrapper,\n };\n resolve(DumpToolsEngine);\n });\n })\n // eslint-disable-next-line github/no-then\n .catch(reject);\n });\n }\n return await EnginePromise;\n}\n/**\n * Dumps the current bound framebuffer\n * @param width defines the rendering width\n * @param height defines the rendering height\n * @param engine defines the hosting engine\n * @param successCallback defines the callback triggered once the data are available\n * @param mimeType defines the mime type of the result\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\n * @returns a void promise\n */\n// Should have \"Async\" in the name but this is a public API and we can't break it now\n// eslint-disable-next-line no-restricted-syntax\nexport async function DumpFramebuffer(width, height, engine, successCallback, mimeType = \"image/png\", fileName, quality) {\n // Read the contents of the framebuffer\n const bufferView = await engine.readPixels(0, 0, width, height);\n const data = new Uint8Array(bufferView.buffer);\n DumpData(width, height, data, successCallback, mimeType, fileName, true, undefined, quality);\n}\n/**\n * Dumps an array buffer\n * @param width defines the rendering width\n * @param height defines the rendering height\n * @param data the data array\n * @param mimeType defines the mime type of the result\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\n * @param invertY true to invert the picture in the Y dimension\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\n * @returns a promise that resolve to the final data\n */\nexport async function DumpDataAsync(width, height, data, mimeType = \"image/png\", fileName, invertY = false, toArrayBuffer = false, quality) {\n return await new Promise((resolve) => {\n DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\n });\n}\n/**\n * Dumps an array buffer\n * @param width defines the rendering width\n * @param height defines the rendering height\n * @param data the data array\n * @param successCallback defines the callback triggered once the data are available\n * @param mimeType defines the mime type of the result\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\n * @param invertY true to invert the picture in the Y dimension\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\n */\nexport function DumpData(width, height, data, successCallback, mimeType = \"image/png\", fileName, invertY = false, toArrayBuffer = false, quality) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\n _CreateDumpRendererAsync().then((renderer) => {\n renderer.engine.setSize(width, height, true);\n // Convert if data are float32\n if (data instanceof Float32Array) {\n const data2 = new Uint8Array(data.length);\n let n = data.length;\n while (n--) {\n const v = data[n];\n data2[n] = Math.round(Clamp(v) * 255);\n }\n data = data2;\n }\n // Create the image\n const texture = renderer.engine.createRawTexture(data, width, height, 5, false, !invertY, 1);\n renderer.renderer.setViewport();\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\n renderer.renderer.draw();\n if (toArrayBuffer) {\n Tools.ToBlob(renderer.canvas, (blob) => {\n const fileReader = new FileReader();\n fileReader.onload = (event) => {\n const arrayBuffer = event.target.result;\n if (successCallback) {\n successCallback(arrayBuffer);\n }\n };\n fileReader.readAsArrayBuffer(blob);\n }, mimeType, quality);\n }\n else {\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\n }\n texture.dispose();\n });\n}\n/**\n * Dispose the dump tools associated resources\n */\nexport function Dispose() {\n if (DumpToolsEngine) {\n DumpToolsEngine.wrapper.dispose();\n DumpToolsEngine.renderer.dispose();\n DumpToolsEngine.engine.dispose();\n }\n else {\n // in cases where the engine is not yet created, we need to wait for it to dispose it\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\n EnginePromise?.then((dumpToolsEngine) => {\n dumpToolsEngine.wrapper.dispose();\n dumpToolsEngine.renderer.dispose();\n dumpToolsEngine.engine.dispose();\n });\n }\n EnginePromise = null;\n DumpToolsEngine = null;\n}\n/**\n * Object containing a set of static utilities functions to dump data from a canvas\n * @deprecated use functions\n */\nexport const DumpTools = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n DumpData,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n DumpDataAsync,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n DumpFramebuffer,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Dispose,\n};\n/**\n * This will be executed automatically for UMD and es5.\n * If esm dev wants the side effects to execute they will have to run it manually\n * Once we build native modules those need to be exported.\n * @internal\n */\nconst InitSideEffects = () => {\n // References the dependencies.\n Tools.DumpData = DumpData;\n Tools.DumpDataAsync = DumpDataAsync;\n Tools.DumpFramebuffer = DumpFramebuffer;\n};\nInitSideEffects();\n//# sourceMappingURL=dumpTools.js.map"],"names":["DumpToolsEngine","EnginePromise","_CreateDumpRendererAsync","resolve","reject","canvas","engine","options","n","thinEngineClass","engineInstanceCount","EngineStore","_a","e","Dispose","renderer","EffectRenderer","passPixelShader","wrapper","EffectWrapper","DumpFramebuffer","width","height","successCallback","mimeType","fileName","quality","bufferView","data","DumpData","DumpDataAsync","invertY","toArrayBuffer","result","data2","v","Clamp","texture","Tools","blob","fileReader","event","arrayBuffer","dumpToolsEngine","DumpTools","InitSideEffects"],"mappings":";AAKA,IAAIA,GACAC,IAAgB;AACpB,eAAe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":"dumpTools-DryVPnxm.js","sources":["../node_modules/@babylonjs/core/Misc/dumpTools.js"],"sourcesContent":["\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer.js\";\nimport { Tools } from \"./tools.js\";\nimport { Clamp } from \"../Maths/math.scalar.functions.js\";\nimport { EngineStore } from \"../Engines/engineStore.js\";\nlet DumpToolsEngine;\nlet EnginePromise = null;\nasync function _CreateDumpRendererAsync() {\n if (!EnginePromise) {\n EnginePromise = new Promise((resolve, reject) => {\n let canvas;\n let engine = null;\n const options = {\n preserveDrawingBuffer: true,\n depth: false,\n stencil: false,\n alpha: true,\n premultipliedAlpha: false,\n antialias: false,\n failIfMajorPerformanceCaveat: false,\n };\n import(\"../Engines/thinEngine.js\")\n // eslint-disable-next-line github/no-then\n .then(({ ThinEngine: thinEngineClass }) => {\n const engineInstanceCount = EngineStore.Instances.length;\n try {\n canvas = new OffscreenCanvas(100, 100); // will be resized later\n engine = new thinEngineClass(canvas, false, options);\n }\n catch (e) {\n if (engineInstanceCount < EngineStore.Instances.length) {\n // The engine was created by another instance, let's use it\n EngineStore.Instances.pop()?.dispose();\n }\n // The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas\n canvas = document.createElement(\"canvas\");\n engine = new thinEngineClass(canvas, false, options);\n }\n // remove this engine from the list of instances to avoid using it for other purposes\n EngineStore.Instances.pop();\n // However, make sure to dispose it when no other engines are left\n EngineStore.OnEnginesDisposedObservable.add((e) => {\n // guaranteed to run when no other instances are left\n // only dispose if it's not the current engine\n if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {\n // Dump the engine and the associated resources\n Dispose();\n }\n });\n engine.getCaps().parallelShaderCompile = undefined;\n const renderer = new EffectRenderer(engine);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\n import(\"../Shaders/pass.fragment.js\").then(({ passPixelShader }) => {\n if (!engine) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(\"Engine is not defined\");\n return;\n }\n const wrapper = new EffectWrapper({\n engine,\n name: passPixelShader.name,\n fragmentShader: passPixelShader.shader,\n samplerNames: [\"textureSampler\"],\n });\n DumpToolsEngine = {\n canvas,\n engine,\n renderer,\n wrapper,\n };\n resolve(DumpToolsEngine);\n });\n })\n // eslint-disable-next-line github/no-then\n .catch(reject);\n });\n }\n return await EnginePromise;\n}\n/**\n * Dumps the current bound framebuffer\n * @param width defines the rendering width\n * @param height defines the rendering height\n * @param engine defines the hosting engine\n * @param successCallback defines the callback triggered once the data are available\n * @param mimeType defines the mime type of the result\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\n * @returns a void promise\n */\n// Should have \"Async\" in the name but this is a public API and we can't break it now\n// eslint-disable-next-line no-restricted-syntax\nexport async function DumpFramebuffer(width, height, engine, successCallback, mimeType = \"image/png\", fileName, quality) {\n // Read the contents of the framebuffer\n const bufferView = await engine.readPixels(0, 0, width, height);\n const data = new Uint8Array(bufferView.buffer);\n DumpData(width, height, data, successCallback, mimeType, fileName, true, undefined, quality);\n}\n/**\n * Dumps an array buffer\n * @param width defines the rendering width\n * @param height defines the rendering height\n * @param data the data array\n * @param mimeType defines the mime type of the result\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\n * @param invertY true to invert the picture in the Y dimension\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\n * @returns a promise that resolve to the final data\n */\nexport async function DumpDataAsync(width, height, data, mimeType = \"image/png\", fileName, invertY = false, toArrayBuffer = false, quality) {\n return await new Promise((resolve) => {\n DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\n });\n}\n/**\n * Dumps an array buffer\n * @param width defines the rendering width\n * @param height defines the rendering height\n * @param data the data array\n * @param successCallback defines the callback triggered once the data are available\n * @param mimeType defines the mime type of the result\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\n * @param invertY true to invert the picture in the Y dimension\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\n */\nexport function DumpData(width, height, data, successCallback, mimeType = \"image/png\", fileName, invertY = false, toArrayBuffer = false, quality) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\n _CreateDumpRendererAsync().then((renderer) => {\n renderer.engine.setSize(width, height, true);\n // Convert if data are float32\n if (data instanceof Float32Array) {\n const data2 = new Uint8Array(data.length);\n let n = data.length;\n while (n--) {\n const v = data[n];\n data2[n] = Math.round(Clamp(v) * 255);\n }\n data = data2;\n }\n // Create the image\n const texture = renderer.engine.createRawTexture(data, width, height, 5, false, !invertY, 1);\n renderer.renderer.setViewport();\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\n renderer.renderer.draw();\n if (toArrayBuffer) {\n Tools.ToBlob(renderer.canvas, (blob) => {\n const fileReader = new FileReader();\n fileReader.onload = (event) => {\n const arrayBuffer = event.target.result;\n if (successCallback) {\n successCallback(arrayBuffer);\n }\n };\n fileReader.readAsArrayBuffer(blob);\n }, mimeType, quality);\n }\n else {\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\n }\n texture.dispose();\n });\n}\n/**\n * Dispose the dump tools associated resources\n */\nexport function Dispose() {\n if (DumpToolsEngine) {\n DumpToolsEngine.wrapper.dispose();\n DumpToolsEngine.renderer.dispose();\n DumpToolsEngine.engine.dispose();\n }\n else {\n // in cases where the engine is not yet created, we need to wait for it to dispose it\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\n EnginePromise?.then((dumpToolsEngine) => {\n dumpToolsEngine.wrapper.dispose();\n dumpToolsEngine.renderer.dispose();\n dumpToolsEngine.engine.dispose();\n });\n }\n EnginePromise = null;\n DumpToolsEngine = null;\n}\n/**\n * Object containing a set of static utilities functions to dump data from a canvas\n * @deprecated use functions\n */\nexport const DumpTools = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n DumpData,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n DumpDataAsync,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n DumpFramebuffer,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Dispose,\n};\n/**\n * This will be executed automatically for UMD and es5.\n * If esm dev wants the side effects to execute they will have to run it manually\n * Once we build native modules those need to be exported.\n * @internal\n */\nconst InitSideEffects = () => {\n // References the dependencies.\n Tools.DumpData = DumpData;\n Tools.DumpDataAsync = DumpDataAsync;\n Tools.DumpFramebuffer = DumpFramebuffer;\n};\nInitSideEffects();\n//# sourceMappingURL=dumpTools.js.map"],"names":["DumpToolsEngine","EnginePromise","_CreateDumpRendererAsync","resolve","reject","canvas","engine","options","n","thinEngineClass","engineInstanceCount","EngineStore","_a","e","Dispose","renderer","EffectRenderer","passPixelShader","wrapper","EffectWrapper","DumpFramebuffer","width","height","successCallback","mimeType","fileName","quality","bufferView","data","DumpData","DumpDataAsync","invertY","toArrayBuffer","result","data2","v","Clamp","texture","Tools","blob","fileReader","event","arrayBuffer","dumpToolsEngine","DumpTools","InitSideEffects"],"mappings":";AAKA,IAAIA,GACAC,IAAgB;AACpB,eAAeC,IAA2B;AACtC,SAAKD,MACDA,IAAgB,IAAI,QAAQ,CAACE,GAASC,MAAW;AAC7C,QAAIC,GACAC,IAAS;AACb,UAAMC,IAAU;AAAA,M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F,IAAAhB,EAAS,SAAS,YAAW,GAC7BA,EAAS,SAAS,mBAAmBA,EAAS,OAAO,GACrDA,EAAS,QAAQ,OAAO,aAAa,kBAAkBsB,CAAO,GAC9DtB,EAAS,SAAS,KAAI,GAClBiB,IACAM,EAAM,OAAOvB,EAAS,QAAQ,CAACwB,MAAS;AACpC,YAAMC,IAAa,IAAI,WAAU;AACjC,MAAAA,EAAW,SAAS,CAACC,MAAU;AAC3B,cAAMC,IAAcD,EAAM,OAAO;AACjC,QAAIlB,KACAA,EAAgBmB,CAAW;AAAA,MAEnD,GACgBF,EAAW,kBAAkBD,CAAI;AAAA,IACjD,GAAef,GAAUE,CAAO,IAGpBY,EAAM,2BAA2BvB,EAAS,QAAQQ,GAAiBC,GAAUC,GAAUC,CAAO,GAElGW,EAAQ,QAAO;AAAA,EACvB,CAAK;AACL;AAIO,SAASvB,IAAU;AACtB,EAAId,KACAA,EAAgB,QAAQ,QAAO,GAC/BA,EAAgB,SAAS,QAAO,GAChCA,EAAgB,OAAO,QAAO,KAK9BC,KAAA,QAAAA,EAAe,KAAK,CAAC0C,MAAoB;AACrC,IAAAA,EAAgB,QAAQ,QAAO,GAC/BA,EAAgB,SAAS,QAAO,GAChCA,EAAgB,OAAO,QAAO;AAAA,EAC1C,IAEI1C,IAAgB,MAChBD,IAAkB;AACtB;AAKY,MAAC4C,IAAY;AAAA;AAAA,EAErB,UAAAf;AAAA;AAAA,EAEA,eAAAC;AAAA;AAAA,EAEA,iBAAAV;AAAA;AAAA,EAEA,SAAAN;AACJ,GAOM+B,IAAkB,MAAM;AAE1B,EAAAP,EAAM,WAAWT,GACjBS,EAAM,gBAAgBR,GACtBQ,EAAM,kBAAkBlB;AAC5B;AACAyB,EAAe;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as B, a as z, V as m, I as O, B as S, e as G, g as V, P as k } from "./index-
|
|
2
|
-
import "./dumpTools-
|
|
1
|
+
import { c as B, a as z, V as m, I as O, B as S, e as G, g as V, P as k } from "./index-DM3Dwe0V.js";
|
|
2
|
+
import "./dumpTools-DryVPnxm.js";
|
|
3
3
|
const R = "image/png", F = 2, D = [134, 22, 135, 150, 246, 214, 150, 54];
|
|
4
4
|
function H(e) {
|
|
5
5
|
const t = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
@@ -108,7 +108,7 @@ async function U(e, t, n, i = R) {
|
|
|
108
108
|
d.textureLOD ? a._features.supportRenderAndCopyToLodForFloatTextures ? d.textureHalfFloatRender && d.textureHalfFloatLinearFiltering ? (r = !0, e.type = 2) : d.textureFloatRender && d.textureFloatLinearFiltering && (r = !0, e.type = 1) : r = !1 : (r = !1, s = n);
|
|
109
109
|
let I = 0;
|
|
110
110
|
if (r)
|
|
111
|
-
a.isWebGPU ? (I = 1, await import("./rgbdDecode.fragment-
|
|
111
|
+
a.isWebGPU ? (I = 1, await import("./rgbdDecode.fragment-CAcs2JmP.js")) : await import("./rgbdDecode.fragment-E4n4lu8J.js"), f = new k("rgbdDecode", "rgbdDecode", null, null, 1, null, 3, a, !1, void 0, e.type, void 0, null, !1, void 0, I), e._isRGBD = !1, e.invertY = !1, c = a.createRenderTargetCubeTexture(e.width, {
|
|
112
112
|
generateDepthBuffer: !1,
|
|
113
113
|
generateMipMaps: !0,
|
|
114
114
|
generateStencilBuffer: !1,
|
|
@@ -235,4 +235,4 @@ class q {
|
|
|
235
235
|
export {
|
|
236
236
|
q as _ENVTextureLoader
|
|
237
237
|
};
|
|
238
|
-
//# sourceMappingURL=envTextureLoader-
|
|
238
|
+
//# sourceMappingURL=envTextureLoader-zUp-sm34.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envTextureLoader-DdCLpySN.js","sources":["../node_modules/@babylonjs/core/Misc/environmentTextureTools.js","../node_modules/@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.js"],"sourcesContent":["import { Tools } from \"./tools.js\";\nimport { Vector3 } from \"../Maths/math.vector.js\";\nimport { ILog2 } from \"../Maths/math.scalar.functions.js\";\nimport { SphericalPolynomial } from \"../Maths/sphericalPolynomial.js\";\nimport { InternalTexture } from \"../Materials/Textures/internalTexture.js\";\nimport { BaseTexture } from \"../Materials/Textures/baseTexture.js\";\n\nimport { Scene } from \"../scene.js\";\nimport { PostProcess } from \"../PostProcesses/postProcess.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { RGBDTextureTools } from \"./rgbdTextureTools.js\";\nimport { DumpDataAsync } from \"../Misc/dumpTools.js\";\nimport \"../Materials/Textures/baseTexture.polynomial.js\";\nconst DefaultEnvironmentTextureImageType = \"image/png\";\nconst CurrentVersion = 2;\n/**\n * Magic number identifying the env file.\n */\nconst MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\n/**\n * Gets the environment info from an env file.\n * @param data The array buffer containing the .env bytes.\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\n */\nexport function GetEnvInfo(data) {\n const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);\n let pos = 0;\n for (let i = 0; i < MagicBytes.length; i++) {\n if (dataView.getUint8(pos++) !== MagicBytes[i]) {\n Logger.Error(\"Not a babylon environment map\");\n return null;\n }\n }\n // Read json manifest - collect characters up to null terminator\n let manifestString = \"\";\n let charCode = 0x00;\n while ((charCode = dataView.getUint8(pos++))) {\n manifestString += String.fromCharCode(charCode);\n }\n let manifest = JSON.parse(manifestString);\n manifest = normalizeEnvInfo(manifest);\n // Extend the header with the position of the payload.\n manifest.binaryDataPosition = pos;\n if (manifest.specular) {\n // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.\n manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;\n }\n return manifest;\n}\n/**\n * Normalizes any supported version of the environment file info to the latest version\n * @param info environment file info on any supported version\n * @returns environment file info in the latest supported version\n * @private\n */\nexport function normalizeEnvInfo(info) {\n if (info.version > CurrentVersion) {\n throw new Error(`Unsupported babylon environment map version \"${info.version}\". Latest supported version is \"${CurrentVersion}\".`);\n }\n if (info.version === 2) {\n return info;\n }\n // Migrate a v1 info to v2\n info = { ...info, version: 2, imageType: DefaultEnvironmentTextureImageType };\n return info;\n}\n/**\n * Creates an environment texture from a loaded cube texture.\n * @param texture defines the cube texture to convert in env file\n * @param options options for the conversion process\n * @returns a promise containing the environment data if successful.\n */\nexport async function CreateEnvTextureAsync(texture, options = {}) {\n const internalTexture = texture.getInternalTexture();\n if (!internalTexture) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return await Promise.reject(\"The cube texture is invalid.\");\n }\n const engine = internalTexture.getEngine();\n if (texture.textureType !== 2 &&\n texture.textureType !== 1 &&\n texture.textureType !== 0 &&\n texture.textureType !== 0 &&\n texture.textureType !== 7 &&\n texture.textureType !== -1) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return await Promise.reject(\"The cube texture should allow HDR (Full Float or Half Float).\");\n }\n let textureType = 1;\n if (!engine.getCaps().textureFloatRender) {\n textureType = 2;\n if (!engine.getCaps().textureHalfFloatRender) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return await Promise.reject(\"Env texture can only be created when the browser supports half float or full float rendering.\");\n }\n }\n // sphericalPolynomial is lazy loaded so simply accessing it should trigger the computation.\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n texture.sphericalPolynomial;\n // Lets keep track of the polynomial promise so we can wait for it to be ready before generating the pixels.\n const sphericalPolynomialPromise = texture.getInternalTexture()?._sphericalPolynomialPromise;\n const cubeWidth = internalTexture.width;\n const hostingScene = new Scene(engine);\n const specularTextures = {};\n const diffuseTextures = {};\n // As we are going to readPixels the faces of the cube, make sure the drawing/update commands for the cube texture are fully sent to the GPU in case it is drawn for the first time in this very frame!\n engine.flushFramebuffer();\n const imageType = options.imageType ?? DefaultEnvironmentTextureImageType;\n // Read and collect all mipmaps data from the cube.\n const mipmapsCount = ILog2(internalTexture.width);\n for (let i = 0; i <= mipmapsCount; i++) {\n const faceWidth = Math.pow(2, mipmapsCount - i);\n // All faces of the cube.\n for (let face = 0; face < 6; face++) {\n // eslint-disable-next-line no-await-in-loop\n specularTextures[i * 6 + face] = await _GetTextureEncodedDataAsync(hostingScene, texture, textureType, face, i, faceWidth, imageType, options.imageQuality);\n }\n }\n // Read and collect all irradiance data from the cube.\n const irradianceTexture = options.disableIrradianceTexture ? null : texture.irradianceTexture;\n if (irradianceTexture) {\n const faceWidth = irradianceTexture.getSize().width;\n // All faces of the cube.\n for (let face = 0; face < 6; face++) {\n // eslint-disable-next-line no-await-in-loop\n diffuseTextures[face] = await _GetTextureEncodedDataAsync(hostingScene, irradianceTexture, textureType, face, 0, faceWidth, imageType, options.imageQuality);\n }\n }\n // We can delete the hosting scene keeping track of all the creation objects\n hostingScene.dispose();\n // Ensure completion of the polynomial creation promise.\n if (sphericalPolynomialPromise) {\n await sphericalPolynomialPromise;\n }\n // Creates the json header for the env texture\n const info = {\n version: CurrentVersion,\n width: cubeWidth,\n imageType,\n irradiance: CreateEnvTextureIrradiance(texture),\n specular: {\n mipmaps: [],\n lodGenerationScale: texture.lodGenerationScale,\n },\n };\n // Sets the specular image data information\n let position = 0;\n for (let i = 0; i <= mipmapsCount; i++) {\n for (let face = 0; face < 6; face++) {\n const byteLength = specularTextures[i * 6 + face].byteLength;\n info.specular.mipmaps.push({\n length: byteLength,\n position: position,\n });\n position += byteLength;\n }\n }\n // Sets the irradiance image data information\n if (irradianceTexture) {\n info.irradiance = info.irradiance || {\n x: [0, 0, 0],\n xx: [0, 0, 0],\n y: [0, 0, 0],\n yy: [0, 0, 0],\n z: [0, 0, 0],\n zz: [0, 0, 0],\n yz: [0, 0, 0],\n zx: [0, 0, 0],\n xy: [0, 0, 0],\n };\n info.irradiance.irradianceTexture = {\n size: irradianceTexture.getSize().width,\n faces: [],\n dominantDirection: irradianceTexture._dominantDirection?.asArray(),\n };\n for (let face = 0; face < 6; face++) {\n const byteLength = diffuseTextures[face].byteLength;\n info.irradiance.irradianceTexture.faces.push({\n length: byteLength,\n position: position,\n });\n position += byteLength;\n }\n }\n // Encode the JSON as an array buffer\n const infoString = JSON.stringify(info);\n const infoBuffer = new ArrayBuffer(infoString.length + 1);\n const infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.\n for (let i = 0, strLen = infoString.length; i < strLen; i++) {\n infoView[i] = infoString.charCodeAt(i);\n }\n // Ends up with a null terminator for easier parsing\n infoView[infoString.length] = 0x00;\n // Computes the final required size and creates the storage\n const totalSize = MagicBytes.length + position + infoBuffer.byteLength;\n const finalBuffer = new ArrayBuffer(totalSize);\n const finalBufferView = new Uint8Array(finalBuffer);\n const dataView = new DataView(finalBuffer);\n // Copy the magic bytes identifying the file in\n let pos = 0;\n for (let i = 0; i < MagicBytes.length; i++) {\n dataView.setUint8(pos++, MagicBytes[i]);\n }\n // Add the json info\n finalBufferView.set(new Uint8Array(infoBuffer), pos);\n pos += infoBuffer.byteLength;\n // Finally inserts the radiance texture data\n for (let i = 0; i <= mipmapsCount; i++) {\n for (let face = 0; face < 6; face++) {\n const dataBuffer = specularTextures[i * 6 + face];\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\n pos += dataBuffer.byteLength;\n }\n }\n // Finally inserts the irradiance texture data\n if (irradianceTexture) {\n for (let face = 0; face < 6; face++) {\n const dataBuffer = diffuseTextures[face];\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\n pos += dataBuffer.byteLength;\n }\n }\n // Voila\n return finalBuffer;\n}\n/**\n * Get the texture encoded data from the current texture\n * @internal\n */\nasync function _GetTextureEncodedDataAsync(hostingScene, texture, textureType, face, i, size, imageType, imageQuality) {\n let faceData = await texture.readPixels(face, i, undefined, false);\n if (faceData && faceData.byteLength === faceData.length) {\n const faceDataFloat = new Float32Array(faceData.byteLength * 4);\n for (let i = 0; i < faceData.byteLength; i++) {\n faceDataFloat[i] = faceData[i] / 255;\n // Gamma to linear\n faceDataFloat[i] = Math.pow(faceDataFloat[i], 2.2);\n }\n faceData = faceDataFloat;\n }\n else if (faceData && texture.gammaSpace) {\n const floatData = faceData;\n for (let i = 0; i < floatData.length; i++) {\n // Gamma to linear\n floatData[i] = Math.pow(floatData[i], 2.2);\n }\n }\n const engine = hostingScene.getEngine();\n const tempTexture = engine.createRawTexture(faceData, size, size, 5, false, true, 1, null, textureType);\n await RGBDTextureTools.EncodeTextureToRGBD(tempTexture, hostingScene, textureType);\n const rgbdEncodedData = await engine._readTexturePixels(tempTexture, size, size);\n const imageEncodedData = await DumpDataAsync(size, size, rgbdEncodedData, imageType, undefined, false, true, imageQuality);\n tempTexture.dispose();\n return imageEncodedData;\n}\n/**\n * Creates a JSON representation of the spherical data.\n * @param texture defines the texture containing the polynomials\n * @returns the JSON representation of the spherical info\n */\nfunction CreateEnvTextureIrradiance(texture) {\n const polynmials = texture.sphericalPolynomial;\n if (polynmials == null) {\n return null;\n }\n return {\n x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],\n y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],\n z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],\n xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],\n yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],\n zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],\n yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],\n zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],\n xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z],\n };\n}\n/**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\nexport function CreateRadianceImageDataArrayBufferViews(data, info) {\n info = normalizeEnvInfo(info);\n const specularInfo = info.specular;\n // Double checks the enclosed info\n let mipmapsCount = Math.log2(info.width);\n mipmapsCount = Math.round(mipmapsCount) + 1;\n if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {\n throw new Error(`Unsupported specular mipmaps number \"${specularInfo.mipmaps.length}\"`);\n }\n const imageData = new Array(mipmapsCount);\n for (let i = 0; i < mipmapsCount; i++) {\n imageData[i] = new Array(6);\n for (let face = 0; face < 6; face++) {\n const imageInfo = specularInfo.mipmaps[i * 6 + face];\n imageData[i][face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition + imageInfo.position, imageInfo.length);\n }\n }\n return imageData;\n}\n/**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\nexport function CreateIrradianceImageDataArrayBufferViews(data, info) {\n info = normalizeEnvInfo(info);\n const imageData = new Array(6);\n const irradianceTexture = info.irradiance?.irradianceTexture;\n if (irradianceTexture) {\n if (irradianceTexture.faces.length !== 6) {\n throw new Error(`Incorrect irradiance texture faces number \"${irradianceTexture.faces.length}\"`);\n }\n for (let face = 0; face < 6; face++) {\n const imageInfo = irradianceTexture.faces[face];\n imageData[face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition + imageInfo.position, imageInfo.length);\n }\n }\n return imageData;\n}\n/**\n * Uploads the texture info contained in the env file to the GPU.\n * @param texture defines the internal texture to upload to\n * @param data defines the data to load\n * @param info defines the texture info retrieved through the GetEnvInfo method\n * @returns a promise\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function UploadEnvLevelsAsync(texture, data, info) {\n info = normalizeEnvInfo(info);\n const specularInfo = info.specular;\n if (!specularInfo) {\n // Nothing else parsed so far\n return Promise.resolve([]);\n }\n texture._lodGenerationScale = specularInfo.lodGenerationScale;\n const promises = [];\n const radianceImageData = CreateRadianceImageDataArrayBufferViews(data, info);\n promises.push(UploadRadianceLevelsAsync(texture, radianceImageData, info.imageType));\n const irradianceTexture = info.irradiance?.irradianceTexture;\n if (irradianceTexture) {\n const irradianceImageData = CreateIrradianceImageDataArrayBufferViews(data, info);\n let dominantDirection = null;\n if (info.irradiance?.irradianceTexture?.dominantDirection) {\n dominantDirection = Vector3.FromArray(info.irradiance.irradianceTexture.dominantDirection);\n }\n promises.push(UploadIrradianceLevelsAsync(texture, irradianceImageData, irradianceTexture.size, info.imageType, dominantDirection));\n }\n return Promise.all(promises);\n}\nasync function _OnImageReadyAsync(image, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture) {\n return await new Promise((resolve, reject) => {\n if (expandTexture) {\n const tempTexture = engine.createTexture(null, true, true, null, 1, null, (message) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(message);\n }, image);\n rgbdPostProcess?.onEffectCreatedObservable.addOnce((effect) => {\n effect.executeWhenCompiled(() => {\n // Uncompress the data to a RTT\n rgbdPostProcess.externalTextureSamplerBinding = true;\n rgbdPostProcess.onApply = (effect) => {\n effect._bindTexture(\"textureSampler\", tempTexture);\n effect.setFloat2(\"scale\", 1, engine._features.needsInvertingBitmap && image instanceof ImageBitmap ? -1 : 1);\n };\n if (!engine.scenes.length) {\n return;\n }\n engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);\n // Cleanup\n engine.restoreDefaultFramebuffer();\n tempTexture.dispose();\n URL.revokeObjectURL(url);\n resolve();\n });\n });\n }\n else {\n engine._uploadImageToTexture(texture, image, face, i);\n // Upload the face to the non lod texture support\n if (generateNonLODTextures) {\n const lodTexture = lodTextures[i];\n if (lodTexture) {\n engine._uploadImageToTexture(lodTexture._texture, image, face, 0);\n }\n }\n resolve();\n }\n });\n}\n/**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param imageType the mime type of the image data\n * @returns a promise\n */\nexport async function UploadRadianceLevelsAsync(texture, imageData, imageType = DefaultEnvironmentTextureImageType) {\n const engine = texture.getEngine();\n texture.format = 5;\n texture.type = 0;\n texture.generateMipMaps = true;\n texture._cachedAnisotropicFilteringLevel = null;\n engine.updateTextureSamplingMode(3, texture);\n await _UploadLevelsAsync(texture, imageData, true, imageType);\n // Flag internal texture as ready in case they are in use.\n texture.isReady = true;\n}\n/**\n * Uploads the levels of image data to the GPU.\n * @param mainTexture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param size defines the size of the texture faces\n * @param imageType the mime type of the image data\n * @param dominantDirection the dominant direction of light in the environment texture, if available\n * @returns a promise\n */\nexport async function UploadIrradianceLevelsAsync(mainTexture, imageData, size, imageType = DefaultEnvironmentTextureImageType, dominantDirection = null) {\n // Gets everything ready.\n const engine = mainTexture.getEngine();\n const texture = new InternalTexture(engine, 5 /* InternalTextureSource.RenderTarget */);\n const baseTexture = new BaseTexture(engine, texture);\n mainTexture._irradianceTexture = baseTexture;\n baseTexture._dominantDirection = dominantDirection;\n texture.isCube = true;\n texture.format = 5;\n texture.type = 0;\n texture.generateMipMaps = true;\n texture._cachedAnisotropicFilteringLevel = null;\n texture.generateMipMaps = true;\n texture.width = size;\n texture.height = size;\n engine.updateTextureSamplingMode(3, texture);\n await _UploadLevelsAsync(texture, [imageData], false, imageType);\n engine.generateMipMapsForCubemap(texture);\n // Flag internal texture as ready in case they are in use.\n texture.isReady = true;\n}\n/**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param canGenerateNonLODTextures defines whether or not to generate non lod textures\n * @param imageType the mime type of the image data\n * @returns a promise\n */\nasync function _UploadLevelsAsync(texture, imageData, canGenerateNonLODTextures, imageType = DefaultEnvironmentTextureImageType) {\n if (!Tools.IsExponentOfTwo(texture.width)) {\n throw new Error(\"Texture size must be a power of two\");\n }\n const mipmapsCount = ILog2(texture.width) + 1;\n // Gets everything ready.\n const engine = texture.getEngine();\n let expandTexture = false;\n let generateNonLODTextures = false;\n let rgbdPostProcess = null;\n let cubeRtt = null;\n let lodTextures = null;\n const caps = engine.getCaps();\n if (!caps.textureLOD) {\n expandTexture = false;\n generateNonLODTextures = canGenerateNonLODTextures;\n }\n else if (!engine._features.supportRenderAndCopyToLodForFloatTextures) {\n expandTexture = false;\n }\n // If half float available we can uncompress the texture\n else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\n expandTexture = true;\n texture.type = 2;\n }\n // If full float available we can uncompress the texture\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\n expandTexture = true;\n texture.type = 1;\n }\n // Expand the texture if possible\n let shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n if (expandTexture) {\n if (engine.isWebGPU) {\n shaderLanguage = 1 /* ShaderLanguage.WGSL */;\n await import(\"../ShadersWGSL/rgbdDecode.fragment.js\");\n }\n else {\n await import(\"../Shaders/rgbdDecode.fragment.js\");\n }\n // Simply run through the decode PP\n rgbdPostProcess = new PostProcess(\"rgbdDecode\", \"rgbdDecode\", null, null, 1, null, 3, engine, false, undefined, texture.type, undefined, null, false, undefined, shaderLanguage);\n texture._isRGBD = false;\n texture.invertY = false;\n cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {\n generateDepthBuffer: false,\n generateMipMaps: true,\n generateStencilBuffer: false,\n samplingMode: 3,\n type: texture.type,\n format: 5,\n });\n }\n else {\n texture._isRGBD = true;\n texture.invertY = true;\n // In case of missing support, applies the same patch than DDS files.\n if (generateNonLODTextures) {\n const mipSlices = 3;\n lodTextures = {};\n const scale = texture._lodGenerationScale;\n const offset = texture._lodGenerationOffset;\n for (let i = 0; i < mipSlices; i++) {\n //compute LOD from even spacing in smoothness (matching shader calculation)\n const smoothness = i / (mipSlices - 1);\n const roughness = 1 - smoothness;\n const minLODIndex = offset; // roughness = 0\n const maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)\n const lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;\n const mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));\n //compute LOD from even spacing in smoothness (matching shader calculation)\n const glTextureFromLod = new InternalTexture(engine, 2 /* InternalTextureSource.Temp */);\n glTextureFromLod.isCube = true;\n glTextureFromLod.invertY = true;\n glTextureFromLod.generateMipMaps = false;\n engine.updateTextureSamplingMode(2, glTextureFromLod);\n // Wrap in a base texture for easy binding.\n const lodTexture = new BaseTexture(null);\n lodTexture._isCube = true;\n lodTexture._texture = glTextureFromLod;\n lodTextures[mipmapIndex] = lodTexture;\n switch (i) {\n case 0:\n texture._lodTextureLow = lodTexture;\n break;\n case 1:\n texture._lodTextureMid = lodTexture;\n break;\n case 2:\n texture._lodTextureHigh = lodTexture;\n break;\n }\n }\n }\n }\n const promises = [];\n // All mipmaps up to provided number of images\n for (let i = 0; i < imageData.length; i++) {\n // All faces\n for (let face = 0; face < 6; face++) {\n // Constructs an image element from image data\n const bytes = imageData[i][face];\n const blob = new Blob([bytes], { type: imageType });\n const url = URL.createObjectURL(blob);\n let promise;\n if (engine._features.forceBitmapOverHTMLImageElement) {\n // eslint-disable-next-line github/no-then\n promise = engine.createImageBitmap(blob, { premultiplyAlpha: \"none\" }).then(async (img) => {\n return await _OnImageReadyAsync(img, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture);\n });\n }\n else {\n const image = new Image();\n image.src = url;\n // Enqueue promise to upload to the texture.\n promise = new Promise((resolve, reject) => {\n image.onload = () => {\n _OnImageReadyAsync(image, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture)\n // eslint-disable-next-line github/no-then\n .then(() => resolve())\n // eslint-disable-next-line github/no-then\n .catch((reason) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(reason);\n });\n };\n image.onerror = (error) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(error);\n };\n });\n }\n promises.push(promise);\n }\n }\n await Promise.all(promises);\n // Fill remaining mipmaps with black textures.\n if (imageData.length < mipmapsCount) {\n let data;\n const size = Math.pow(2, mipmapsCount - 1 - imageData.length);\n const dataLength = size * size * 4;\n switch (texture.type) {\n case 0: {\n data = new Uint8Array(dataLength);\n break;\n }\n case 2: {\n data = new Uint16Array(dataLength);\n break;\n }\n case 1: {\n data = new Float32Array(dataLength);\n break;\n }\n }\n for (let i = imageData.length; i < mipmapsCount; i++) {\n for (let face = 0; face < 6; face++) {\n engine._uploadArrayBufferViewToTexture(cubeRtt?.texture || texture, data, face, i);\n }\n }\n }\n // Release temp RTT.\n if (cubeRtt) {\n const irradiance = texture._irradianceTexture;\n texture._irradianceTexture = null;\n engine._releaseTexture(texture);\n cubeRtt._swapAndDie(texture);\n texture._irradianceTexture = irradiance;\n }\n // Release temp Post Process.\n if (rgbdPostProcess) {\n rgbdPostProcess.dispose();\n }\n // Flag internal texture as ready in case they are in use.\n if (generateNonLODTextures) {\n if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {\n texture._lodTextureHigh._texture.isReady = true;\n }\n if (texture._lodTextureMid && texture._lodTextureMid._texture) {\n texture._lodTextureMid._texture.isReady = true;\n }\n if (texture._lodTextureLow && texture._lodTextureLow._texture) {\n texture._lodTextureLow._texture.isReady = true;\n }\n }\n}\n/**\n * Uploads spherical polynomials information to the texture.\n * @param texture defines the texture we are trying to upload the information to\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\n */\nexport function UploadEnvSpherical(texture, info) {\n info = normalizeEnvInfo(info);\n const irradianceInfo = info.irradiance;\n if (!irradianceInfo) {\n return;\n }\n const sp = new SphericalPolynomial();\n Vector3.FromArrayToRef(irradianceInfo.x, 0, sp.x);\n Vector3.FromArrayToRef(irradianceInfo.y, 0, sp.y);\n Vector3.FromArrayToRef(irradianceInfo.z, 0, sp.z);\n Vector3.FromArrayToRef(irradianceInfo.xx, 0, sp.xx);\n Vector3.FromArrayToRef(irradianceInfo.yy, 0, sp.yy);\n Vector3.FromArrayToRef(irradianceInfo.zz, 0, sp.zz);\n Vector3.FromArrayToRef(irradianceInfo.yz, 0, sp.yz);\n Vector3.FromArrayToRef(irradianceInfo.zx, 0, sp.zx);\n Vector3.FromArrayToRef(irradianceInfo.xy, 0, sp.xy);\n texture._sphericalPolynomial = sp;\n}\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function _UpdateRGBDAsync(internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {\n const proxy = internalTexture\n .getEngine()\n .createRawCubeTexture(null, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);\n // eslint-disable-next-line github/no-then\n const proxyPromise = UploadRadianceLevelsAsync(proxy, data).then(() => internalTexture);\n internalTexture.onRebuildCallback = (_internalTexture) => {\n return {\n proxy: proxyPromise,\n isReady: true,\n isAsync: true,\n };\n };\n internalTexture._source = 13 /* InternalTextureSource.CubeRawRGBD */;\n internalTexture._bufferViewArrayArray = data;\n internalTexture._lodGenerationScale = lodScale;\n internalTexture._lodGenerationOffset = lodOffset;\n internalTexture._sphericalPolynomial = sphericalPolynomial;\n // eslint-disable-next-line github/no-then\n return UploadRadianceLevelsAsync(internalTexture, data).then(() => {\n internalTexture.isReady = true;\n return internalTexture;\n });\n}\n/**\n * Sets of helpers addressing the serialization and deserialization of environment texture\n * stored in a BabylonJS env file.\n * Those files are usually stored as .env files.\n */\nexport const EnvironmentTextureTools = {\n /**\n * Gets the environment info from an env file.\n * @param data The array buffer containing the .env bytes.\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\n */\n GetEnvInfo,\n /**\n * Creates an environment texture from a loaded cube texture.\n * @param texture defines the cube texture to convert in env file\n * @param options options for the conversion process\n * @param options.imageType the mime type for the encoded images, with support for \"image/png\" (default) and \"image/webp\"\n * @param options.imageQuality the image quality of encoded WebP images.\n * @returns a promise containing the environment data if successful.\n */\n CreateEnvTextureAsync,\n /**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\n CreateRadianceImageDataArrayBufferViews,\n /**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\n CreateIrradianceImageDataArrayBufferViews,\n /**\n * Uploads the texture info contained in the env file to the GPU.\n * @param texture defines the internal texture to upload to\n * @param data defines the data to load\n * @param info defines the texture info retrieved through the GetEnvInfo method\n * @returns a promise\n */\n UploadEnvLevelsAsync,\n /**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param imageType the mime type of the image data\n * @returns a promise\n */\n UploadRadianceLevelsAsync,\n /**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param imageType the mime type of the image data\n * @param dominantDirection the dominant direction of light in the environment texture, if available\n * @returns a promise\n */\n UploadIrradianceLevelsAsync,\n /**\n * Uploads spherical polynomials information to the texture.\n * @param texture defines the texture we are trying to upload the information to\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\n */\n UploadEnvSpherical,\n};\n//# sourceMappingURL=environmentTextureTools.js.map","import { GetEnvInfo, UploadEnvLevelsAsync, UploadEnvSpherical } from \"../../../Misc/environmentTextureTools.js\";\n/**\n * Implementation of the ENV Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _ENVTextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = false;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param createPolynomials will be true if polynomials have been requested\n * @param onLoad defines the callback to trigger once the texture is ready\n * @param onError defines the callback to trigger in case of error\n */\n loadCubeData(data, texture, createPolynomials, onLoad, onError) {\n if (Array.isArray(data)) {\n return;\n }\n const info = GetEnvInfo(data);\n if (info) {\n texture.width = info.width;\n texture.height = info.width;\n try {\n UploadEnvSpherical(texture, info);\n // eslint-disable-next-line github/no-then\n UploadEnvLevelsAsync(texture, data, info).then(() => {\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\n }, (reason) => {\n onError?.(\"Can not upload environment levels\", reason);\n });\n }\n catch (e) {\n onError?.(\"Can not upload environment file\", e);\n }\n }\n else if (onError) {\n onError(\"Can not parse the environment file\", null);\n }\n }\n /**\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\n */\n loadData() {\n // eslint-disable-next-line no-throw-literal\n throw \".env not supported in 2d.\";\n }\n}\n//# sourceMappingURL=envTextureLoader.js.map"],"names":["DefaultEnvironmentTextureImageType","CurrentVersion","MagicBytes","GetEnvInfo","data","dataView","pos","i","Logger","manifestString","charCode","manifest","normalizeEnvInfo","info","CreateRadianceImageDataArrayBufferViews","specularInfo","mipmapsCount","imageData","face","imageInfo","CreateIrradianceImageDataArrayBufferViews","irradianceTexture","_a","UploadEnvLevelsAsync","texture","promises","radianceImageData","UploadRadianceLevelsAsync","irradianceImageData","dominantDirection","_c","_b","Vector3","UploadIrradianceLevelsAsync","_OnImageReadyAsync","image","engine","expandTexture","rgbdPostProcess","url","generateNonLODTextures","lodTextures","cubeRtt","resolve","reject","tempTexture","message","effect","lodTexture","imageType","_UploadLevelsAsync","mainTexture","size","InternalTexture","baseTexture","BaseTexture","canGenerateNonLODTextures","Tools","ILog2","caps","shaderLanguage","PostProcess","scale","offset","roughness","minLODIndex","maxLODIndex","lodIndex","mipmapIndex","glTextureFromLod","bytes","blob","promise","img","reason","error","dataLength","irradiance","UploadEnvSpherical","irradianceInfo","sp","SphericalPolynomial","_ENVTextureLoader","createPolynomials","onLoad","onError","e"],"mappings":";;AAaA,MAAMA,IAAqC,aACrCC,IAAiB,GAIjBC,IAA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W,EAAQ,QAAQX,EAAK,OACrBW,EAAQ,SAASX,EAAK;AACtB,UAAI;AACA,QAAAiE,EAAmBtD,GAASX,CAAI,GAEhCU,EAAqBC,GAASpB,GAAMS,CAAI,EAAE,KAAK,MAAM;AACjD,UAAAW,EAAQ,UAAU,IAClBA,EAAQ,mBAAmB,gBAAgBA,CAAO,GAClDA,EAAQ,mBAAmB,MAAK,GAC5B4D,KACAA,EAAM;AAAA,QAE9B,GAAmB,CAACV,MAAW;AACX,UAAAW,KAAA,QAAAA,EAAU,qCAAqCX;AAAA,QACnE,CAAiB;AAAA,MACjB,SACmBY,GAAG;AACN,QAAAD,KAAA,QAAAA,EAAU,mCAAmCC;AAAA,MAC7D;AAAA,IACA,MACa,CAAID,KACLA,EAAQ,sCAAsC,IAAI;AAAA,EAE9D;AAAA;AAAA;AAAA;AAAA,EAII,WAAW;AAEP,UAAM;AAAA,EACd;AACA;","x_google_ignoreList":[0,1]}
|
|
1
|
+
{"version":3,"file":"envTextureLoader-zUp-sm34.js","sources":["../node_modules/@babylonjs/core/Misc/environmentTextureTools.js","../node_modules/@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.js"],"sourcesContent":["import { Tools } from \"./tools.js\";\nimport { Vector3 } from \"../Maths/math.vector.js\";\nimport { ILog2 } from \"../Maths/math.scalar.functions.js\";\nimport { SphericalPolynomial } from \"../Maths/sphericalPolynomial.js\";\nimport { InternalTexture } from \"../Materials/Textures/internalTexture.js\";\nimport { BaseTexture } from \"../Materials/Textures/baseTexture.js\";\n\nimport { Scene } from \"../scene.js\";\nimport { PostProcess } from \"../PostProcesses/postProcess.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { RGBDTextureTools } from \"./rgbdTextureTools.js\";\nimport { DumpDataAsync } from \"../Misc/dumpTools.js\";\nimport \"../Materials/Textures/baseTexture.polynomial.js\";\nconst DefaultEnvironmentTextureImageType = \"image/png\";\nconst CurrentVersion = 2;\n/**\n * Magic number identifying the env file.\n */\nconst MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\n/**\n * Gets the environment info from an env file.\n * @param data The array buffer containing the .env bytes.\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\n */\nexport function GetEnvInfo(data) {\n const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);\n let pos = 0;\n for (let i = 0; i < MagicBytes.length; i++) {\n if (dataView.getUint8(pos++) !== MagicBytes[i]) {\n Logger.Error(\"Not a babylon environment map\");\n return null;\n }\n }\n // Read json manifest - collect characters up to null terminator\n let manifestString = \"\";\n let charCode = 0x00;\n while ((charCode = dataView.getUint8(pos++))) {\n manifestString += String.fromCharCode(charCode);\n }\n let manifest = JSON.parse(manifestString);\n manifest = normalizeEnvInfo(manifest);\n // Extend the header with the position of the payload.\n manifest.binaryDataPosition = pos;\n if (manifest.specular) {\n // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.\n manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;\n }\n return manifest;\n}\n/**\n * Normalizes any supported version of the environment file info to the latest version\n * @param info environment file info on any supported version\n * @returns environment file info in the latest supported version\n * @private\n */\nexport function normalizeEnvInfo(info) {\n if (info.version > CurrentVersion) {\n throw new Error(`Unsupported babylon environment map version \"${info.version}\". Latest supported version is \"${CurrentVersion}\".`);\n }\n if (info.version === 2) {\n return info;\n }\n // Migrate a v1 info to v2\n info = { ...info, version: 2, imageType: DefaultEnvironmentTextureImageType };\n return info;\n}\n/**\n * Creates an environment texture from a loaded cube texture.\n * @param texture defines the cube texture to convert in env file\n * @param options options for the conversion process\n * @returns a promise containing the environment data if successful.\n */\nexport async function CreateEnvTextureAsync(texture, options = {}) {\n const internalTexture = texture.getInternalTexture();\n if (!internalTexture) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return await Promise.reject(\"The cube texture is invalid.\");\n }\n const engine = internalTexture.getEngine();\n if (texture.textureType !== 2 &&\n texture.textureType !== 1 &&\n texture.textureType !== 0 &&\n texture.textureType !== 0 &&\n texture.textureType !== 7 &&\n texture.textureType !== -1) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return await Promise.reject(\"The cube texture should allow HDR (Full Float or Half Float).\");\n }\n let textureType = 1;\n if (!engine.getCaps().textureFloatRender) {\n textureType = 2;\n if (!engine.getCaps().textureHalfFloatRender) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return await Promise.reject(\"Env texture can only be created when the browser supports half float or full float rendering.\");\n }\n }\n // sphericalPolynomial is lazy loaded so simply accessing it should trigger the computation.\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n texture.sphericalPolynomial;\n // Lets keep track of the polynomial promise so we can wait for it to be ready before generating the pixels.\n const sphericalPolynomialPromise = texture.getInternalTexture()?._sphericalPolynomialPromise;\n const cubeWidth = internalTexture.width;\n const hostingScene = new Scene(engine);\n const specularTextures = {};\n const diffuseTextures = {};\n // As we are going to readPixels the faces of the cube, make sure the drawing/update commands for the cube texture are fully sent to the GPU in case it is drawn for the first time in this very frame!\n engine.flushFramebuffer();\n const imageType = options.imageType ?? DefaultEnvironmentTextureImageType;\n // Read and collect all mipmaps data from the cube.\n const mipmapsCount = ILog2(internalTexture.width);\n for (let i = 0; i <= mipmapsCount; i++) {\n const faceWidth = Math.pow(2, mipmapsCount - i);\n // All faces of the cube.\n for (let face = 0; face < 6; face++) {\n // eslint-disable-next-line no-await-in-loop\n specularTextures[i * 6 + face] = await _GetTextureEncodedDataAsync(hostingScene, texture, textureType, face, i, faceWidth, imageType, options.imageQuality);\n }\n }\n // Read and collect all irradiance data from the cube.\n const irradianceTexture = options.disableIrradianceTexture ? null : texture.irradianceTexture;\n if (irradianceTexture) {\n const faceWidth = irradianceTexture.getSize().width;\n // All faces of the cube.\n for (let face = 0; face < 6; face++) {\n // eslint-disable-next-line no-await-in-loop\n diffuseTextures[face] = await _GetTextureEncodedDataAsync(hostingScene, irradianceTexture, textureType, face, 0, faceWidth, imageType, options.imageQuality);\n }\n }\n // We can delete the hosting scene keeping track of all the creation objects\n hostingScene.dispose();\n // Ensure completion of the polynomial creation promise.\n if (sphericalPolynomialPromise) {\n await sphericalPolynomialPromise;\n }\n // Creates the json header for the env texture\n const info = {\n version: CurrentVersion,\n width: cubeWidth,\n imageType,\n irradiance: CreateEnvTextureIrradiance(texture),\n specular: {\n mipmaps: [],\n lodGenerationScale: texture.lodGenerationScale,\n },\n };\n // Sets the specular image data information\n let position = 0;\n for (let i = 0; i <= mipmapsCount; i++) {\n for (let face = 0; face < 6; face++) {\n const byteLength = specularTextures[i * 6 + face].byteLength;\n info.specular.mipmaps.push({\n length: byteLength,\n position: position,\n });\n position += byteLength;\n }\n }\n // Sets the irradiance image data information\n if (irradianceTexture) {\n info.irradiance = info.irradiance || {\n x: [0, 0, 0],\n xx: [0, 0, 0],\n y: [0, 0, 0],\n yy: [0, 0, 0],\n z: [0, 0, 0],\n zz: [0, 0, 0],\n yz: [0, 0, 0],\n zx: [0, 0, 0],\n xy: [0, 0, 0],\n };\n info.irradiance.irradianceTexture = {\n size: irradianceTexture.getSize().width,\n faces: [],\n dominantDirection: irradianceTexture._dominantDirection?.asArray(),\n };\n for (let face = 0; face < 6; face++) {\n const byteLength = diffuseTextures[face].byteLength;\n info.irradiance.irradianceTexture.faces.push({\n length: byteLength,\n position: position,\n });\n position += byteLength;\n }\n }\n // Encode the JSON as an array buffer\n const infoString = JSON.stringify(info);\n const infoBuffer = new ArrayBuffer(infoString.length + 1);\n const infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.\n for (let i = 0, strLen = infoString.length; i < strLen; i++) {\n infoView[i] = infoString.charCodeAt(i);\n }\n // Ends up with a null terminator for easier parsing\n infoView[infoString.length] = 0x00;\n // Computes the final required size and creates the storage\n const totalSize = MagicBytes.length + position + infoBuffer.byteLength;\n const finalBuffer = new ArrayBuffer(totalSize);\n const finalBufferView = new Uint8Array(finalBuffer);\n const dataView = new DataView(finalBuffer);\n // Copy the magic bytes identifying the file in\n let pos = 0;\n for (let i = 0; i < MagicBytes.length; i++) {\n dataView.setUint8(pos++, MagicBytes[i]);\n }\n // Add the json info\n finalBufferView.set(new Uint8Array(infoBuffer), pos);\n pos += infoBuffer.byteLength;\n // Finally inserts the radiance texture data\n for (let i = 0; i <= mipmapsCount; i++) {\n for (let face = 0; face < 6; face++) {\n const dataBuffer = specularTextures[i * 6 + face];\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\n pos += dataBuffer.byteLength;\n }\n }\n // Finally inserts the irradiance texture data\n if (irradianceTexture) {\n for (let face = 0; face < 6; face++) {\n const dataBuffer = diffuseTextures[face];\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\n pos += dataBuffer.byteLength;\n }\n }\n // Voila\n return finalBuffer;\n}\n/**\n * Get the texture encoded data from the current texture\n * @internal\n */\nasync function _GetTextureEncodedDataAsync(hostingScene, texture, textureType, face, i, size, imageType, imageQuality) {\n let faceData = await texture.readPixels(face, i, undefined, false);\n if (faceData && faceData.byteLength === faceData.length) {\n const faceDataFloat = new Float32Array(faceData.byteLength * 4);\n for (let i = 0; i < faceData.byteLength; i++) {\n faceDataFloat[i] = faceData[i] / 255;\n // Gamma to linear\n faceDataFloat[i] = Math.pow(faceDataFloat[i], 2.2);\n }\n faceData = faceDataFloat;\n }\n else if (faceData && texture.gammaSpace) {\n const floatData = faceData;\n for (let i = 0; i < floatData.length; i++) {\n // Gamma to linear\n floatData[i] = Math.pow(floatData[i], 2.2);\n }\n }\n const engine = hostingScene.getEngine();\n const tempTexture = engine.createRawTexture(faceData, size, size, 5, false, true, 1, null, textureType);\n await RGBDTextureTools.EncodeTextureToRGBD(tempTexture, hostingScene, textureType);\n const rgbdEncodedData = await engine._readTexturePixels(tempTexture, size, size);\n const imageEncodedData = await DumpDataAsync(size, size, rgbdEncodedData, imageType, undefined, false, true, imageQuality);\n tempTexture.dispose();\n return imageEncodedData;\n}\n/**\n * Creates a JSON representation of the spherical data.\n * @param texture defines the texture containing the polynomials\n * @returns the JSON representation of the spherical info\n */\nfunction CreateEnvTextureIrradiance(texture) {\n const polynmials = texture.sphericalPolynomial;\n if (polynmials == null) {\n return null;\n }\n return {\n x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],\n y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],\n z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],\n xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],\n yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],\n zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],\n yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],\n zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],\n xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z],\n };\n}\n/**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\nexport function CreateRadianceImageDataArrayBufferViews(data, info) {\n info = normalizeEnvInfo(info);\n const specularInfo = info.specular;\n // Double checks the enclosed info\n let mipmapsCount = Math.log2(info.width);\n mipmapsCount = Math.round(mipmapsCount) + 1;\n if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {\n throw new Error(`Unsupported specular mipmaps number \"${specularInfo.mipmaps.length}\"`);\n }\n const imageData = new Array(mipmapsCount);\n for (let i = 0; i < mipmapsCount; i++) {\n imageData[i] = new Array(6);\n for (let face = 0; face < 6; face++) {\n const imageInfo = specularInfo.mipmaps[i * 6 + face];\n imageData[i][face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition + imageInfo.position, imageInfo.length);\n }\n }\n return imageData;\n}\n/**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\nexport function CreateIrradianceImageDataArrayBufferViews(data, info) {\n info = normalizeEnvInfo(info);\n const imageData = new Array(6);\n const irradianceTexture = info.irradiance?.irradianceTexture;\n if (irradianceTexture) {\n if (irradianceTexture.faces.length !== 6) {\n throw new Error(`Incorrect irradiance texture faces number \"${irradianceTexture.faces.length}\"`);\n }\n for (let face = 0; face < 6; face++) {\n const imageInfo = irradianceTexture.faces[face];\n imageData[face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition + imageInfo.position, imageInfo.length);\n }\n }\n return imageData;\n}\n/**\n * Uploads the texture info contained in the env file to the GPU.\n * @param texture defines the internal texture to upload to\n * @param data defines the data to load\n * @param info defines the texture info retrieved through the GetEnvInfo method\n * @returns a promise\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function UploadEnvLevelsAsync(texture, data, info) {\n info = normalizeEnvInfo(info);\n const specularInfo = info.specular;\n if (!specularInfo) {\n // Nothing else parsed so far\n return Promise.resolve([]);\n }\n texture._lodGenerationScale = specularInfo.lodGenerationScale;\n const promises = [];\n const radianceImageData = CreateRadianceImageDataArrayBufferViews(data, info);\n promises.push(UploadRadianceLevelsAsync(texture, radianceImageData, info.imageType));\n const irradianceTexture = info.irradiance?.irradianceTexture;\n if (irradianceTexture) {\n const irradianceImageData = CreateIrradianceImageDataArrayBufferViews(data, info);\n let dominantDirection = null;\n if (info.irradiance?.irradianceTexture?.dominantDirection) {\n dominantDirection = Vector3.FromArray(info.irradiance.irradianceTexture.dominantDirection);\n }\n promises.push(UploadIrradianceLevelsAsync(texture, irradianceImageData, irradianceTexture.size, info.imageType, dominantDirection));\n }\n return Promise.all(promises);\n}\nasync function _OnImageReadyAsync(image, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture) {\n return await new Promise((resolve, reject) => {\n if (expandTexture) {\n const tempTexture = engine.createTexture(null, true, true, null, 1, null, (message) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(message);\n }, image);\n rgbdPostProcess?.onEffectCreatedObservable.addOnce((effect) => {\n effect.executeWhenCompiled(() => {\n // Uncompress the data to a RTT\n rgbdPostProcess.externalTextureSamplerBinding = true;\n rgbdPostProcess.onApply = (effect) => {\n effect._bindTexture(\"textureSampler\", tempTexture);\n effect.setFloat2(\"scale\", 1, engine._features.needsInvertingBitmap && image instanceof ImageBitmap ? -1 : 1);\n };\n if (!engine.scenes.length) {\n return;\n }\n engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);\n // Cleanup\n engine.restoreDefaultFramebuffer();\n tempTexture.dispose();\n URL.revokeObjectURL(url);\n resolve();\n });\n });\n }\n else {\n engine._uploadImageToTexture(texture, image, face, i);\n // Upload the face to the non lod texture support\n if (generateNonLODTextures) {\n const lodTexture = lodTextures[i];\n if (lodTexture) {\n engine._uploadImageToTexture(lodTexture._texture, image, face, 0);\n }\n }\n resolve();\n }\n });\n}\n/**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param imageType the mime type of the image data\n * @returns a promise\n */\nexport async function UploadRadianceLevelsAsync(texture, imageData, imageType = DefaultEnvironmentTextureImageType) {\n const engine = texture.getEngine();\n texture.format = 5;\n texture.type = 0;\n texture.generateMipMaps = true;\n texture._cachedAnisotropicFilteringLevel = null;\n engine.updateTextureSamplingMode(3, texture);\n await _UploadLevelsAsync(texture, imageData, true, imageType);\n // Flag internal texture as ready in case they are in use.\n texture.isReady = true;\n}\n/**\n * Uploads the levels of image data to the GPU.\n * @param mainTexture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param size defines the size of the texture faces\n * @param imageType the mime type of the image data\n * @param dominantDirection the dominant direction of light in the environment texture, if available\n * @returns a promise\n */\nexport async function UploadIrradianceLevelsAsync(mainTexture, imageData, size, imageType = DefaultEnvironmentTextureImageType, dominantDirection = null) {\n // Gets everything ready.\n const engine = mainTexture.getEngine();\n const texture = new InternalTexture(engine, 5 /* InternalTextureSource.RenderTarget */);\n const baseTexture = new BaseTexture(engine, texture);\n mainTexture._irradianceTexture = baseTexture;\n baseTexture._dominantDirection = dominantDirection;\n texture.isCube = true;\n texture.format = 5;\n texture.type = 0;\n texture.generateMipMaps = true;\n texture._cachedAnisotropicFilteringLevel = null;\n texture.generateMipMaps = true;\n texture.width = size;\n texture.height = size;\n engine.updateTextureSamplingMode(3, texture);\n await _UploadLevelsAsync(texture, [imageData], false, imageType);\n engine.generateMipMapsForCubemap(texture);\n // Flag internal texture as ready in case they are in use.\n texture.isReady = true;\n}\n/**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param canGenerateNonLODTextures defines whether or not to generate non lod textures\n * @param imageType the mime type of the image data\n * @returns a promise\n */\nasync function _UploadLevelsAsync(texture, imageData, canGenerateNonLODTextures, imageType = DefaultEnvironmentTextureImageType) {\n if (!Tools.IsExponentOfTwo(texture.width)) {\n throw new Error(\"Texture size must be a power of two\");\n }\n const mipmapsCount = ILog2(texture.width) + 1;\n // Gets everything ready.\n const engine = texture.getEngine();\n let expandTexture = false;\n let generateNonLODTextures = false;\n let rgbdPostProcess = null;\n let cubeRtt = null;\n let lodTextures = null;\n const caps = engine.getCaps();\n if (!caps.textureLOD) {\n expandTexture = false;\n generateNonLODTextures = canGenerateNonLODTextures;\n }\n else if (!engine._features.supportRenderAndCopyToLodForFloatTextures) {\n expandTexture = false;\n }\n // If half float available we can uncompress the texture\n else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\n expandTexture = true;\n texture.type = 2;\n }\n // If full float available we can uncompress the texture\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\n expandTexture = true;\n texture.type = 1;\n }\n // Expand the texture if possible\n let shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n if (expandTexture) {\n if (engine.isWebGPU) {\n shaderLanguage = 1 /* ShaderLanguage.WGSL */;\n await import(\"../ShadersWGSL/rgbdDecode.fragment.js\");\n }\n else {\n await import(\"../Shaders/rgbdDecode.fragment.js\");\n }\n // Simply run through the decode PP\n rgbdPostProcess = new PostProcess(\"rgbdDecode\", \"rgbdDecode\", null, null, 1, null, 3, engine, false, undefined, texture.type, undefined, null, false, undefined, shaderLanguage);\n texture._isRGBD = false;\n texture.invertY = false;\n cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {\n generateDepthBuffer: false,\n generateMipMaps: true,\n generateStencilBuffer: false,\n samplingMode: 3,\n type: texture.type,\n format: 5,\n });\n }\n else {\n texture._isRGBD = true;\n texture.invertY = true;\n // In case of missing support, applies the same patch than DDS files.\n if (generateNonLODTextures) {\n const mipSlices = 3;\n lodTextures = {};\n const scale = texture._lodGenerationScale;\n const offset = texture._lodGenerationOffset;\n for (let i = 0; i < mipSlices; i++) {\n //compute LOD from even spacing in smoothness (matching shader calculation)\n const smoothness = i / (mipSlices - 1);\n const roughness = 1 - smoothness;\n const minLODIndex = offset; // roughness = 0\n const maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)\n const lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;\n const mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));\n //compute LOD from even spacing in smoothness (matching shader calculation)\n const glTextureFromLod = new InternalTexture(engine, 2 /* InternalTextureSource.Temp */);\n glTextureFromLod.isCube = true;\n glTextureFromLod.invertY = true;\n glTextureFromLod.generateMipMaps = false;\n engine.updateTextureSamplingMode(2, glTextureFromLod);\n // Wrap in a base texture for easy binding.\n const lodTexture = new BaseTexture(null);\n lodTexture._isCube = true;\n lodTexture._texture = glTextureFromLod;\n lodTextures[mipmapIndex] = lodTexture;\n switch (i) {\n case 0:\n texture._lodTextureLow = lodTexture;\n break;\n case 1:\n texture._lodTextureMid = lodTexture;\n break;\n case 2:\n texture._lodTextureHigh = lodTexture;\n break;\n }\n }\n }\n }\n const promises = [];\n // All mipmaps up to provided number of images\n for (let i = 0; i < imageData.length; i++) {\n // All faces\n for (let face = 0; face < 6; face++) {\n // Constructs an image element from image data\n const bytes = imageData[i][face];\n const blob = new Blob([bytes], { type: imageType });\n const url = URL.createObjectURL(blob);\n let promise;\n if (engine._features.forceBitmapOverHTMLImageElement) {\n // eslint-disable-next-line github/no-then\n promise = engine.createImageBitmap(blob, { premultiplyAlpha: \"none\" }).then(async (img) => {\n return await _OnImageReadyAsync(img, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture);\n });\n }\n else {\n const image = new Image();\n image.src = url;\n // Enqueue promise to upload to the texture.\n promise = new Promise((resolve, reject) => {\n image.onload = () => {\n _OnImageReadyAsync(image, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture)\n // eslint-disable-next-line github/no-then\n .then(() => resolve())\n // eslint-disable-next-line github/no-then\n .catch((reason) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(reason);\n });\n };\n image.onerror = (error) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(error);\n };\n });\n }\n promises.push(promise);\n }\n }\n await Promise.all(promises);\n // Fill remaining mipmaps with black textures.\n if (imageData.length < mipmapsCount) {\n let data;\n const size = Math.pow(2, mipmapsCount - 1 - imageData.length);\n const dataLength = size * size * 4;\n switch (texture.type) {\n case 0: {\n data = new Uint8Array(dataLength);\n break;\n }\n case 2: {\n data = new Uint16Array(dataLength);\n break;\n }\n case 1: {\n data = new Float32Array(dataLength);\n break;\n }\n }\n for (let i = imageData.length; i < mipmapsCount; i++) {\n for (let face = 0; face < 6; face++) {\n engine._uploadArrayBufferViewToTexture(cubeRtt?.texture || texture, data, face, i);\n }\n }\n }\n // Release temp RTT.\n if (cubeRtt) {\n const irradiance = texture._irradianceTexture;\n texture._irradianceTexture = null;\n engine._releaseTexture(texture);\n cubeRtt._swapAndDie(texture);\n texture._irradianceTexture = irradiance;\n }\n // Release temp Post Process.\n if (rgbdPostProcess) {\n rgbdPostProcess.dispose();\n }\n // Flag internal texture as ready in case they are in use.\n if (generateNonLODTextures) {\n if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {\n texture._lodTextureHigh._texture.isReady = true;\n }\n if (texture._lodTextureMid && texture._lodTextureMid._texture) {\n texture._lodTextureMid._texture.isReady = true;\n }\n if (texture._lodTextureLow && texture._lodTextureLow._texture) {\n texture._lodTextureLow._texture.isReady = true;\n }\n }\n}\n/**\n * Uploads spherical polynomials information to the texture.\n * @param texture defines the texture we are trying to upload the information to\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\n */\nexport function UploadEnvSpherical(texture, info) {\n info = normalizeEnvInfo(info);\n const irradianceInfo = info.irradiance;\n if (!irradianceInfo) {\n return;\n }\n const sp = new SphericalPolynomial();\n Vector3.FromArrayToRef(irradianceInfo.x, 0, sp.x);\n Vector3.FromArrayToRef(irradianceInfo.y, 0, sp.y);\n Vector3.FromArrayToRef(irradianceInfo.z, 0, sp.z);\n Vector3.FromArrayToRef(irradianceInfo.xx, 0, sp.xx);\n Vector3.FromArrayToRef(irradianceInfo.yy, 0, sp.yy);\n Vector3.FromArrayToRef(irradianceInfo.zz, 0, sp.zz);\n Vector3.FromArrayToRef(irradianceInfo.yz, 0, sp.yz);\n Vector3.FromArrayToRef(irradianceInfo.zx, 0, sp.zx);\n Vector3.FromArrayToRef(irradianceInfo.xy, 0, sp.xy);\n texture._sphericalPolynomial = sp;\n}\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function _UpdateRGBDAsync(internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {\n const proxy = internalTexture\n .getEngine()\n .createRawCubeTexture(null, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);\n // eslint-disable-next-line github/no-then\n const proxyPromise = UploadRadianceLevelsAsync(proxy, data).then(() => internalTexture);\n internalTexture.onRebuildCallback = (_internalTexture) => {\n return {\n proxy: proxyPromise,\n isReady: true,\n isAsync: true,\n };\n };\n internalTexture._source = 13 /* InternalTextureSource.CubeRawRGBD */;\n internalTexture._bufferViewArrayArray = data;\n internalTexture._lodGenerationScale = lodScale;\n internalTexture._lodGenerationOffset = lodOffset;\n internalTexture._sphericalPolynomial = sphericalPolynomial;\n // eslint-disable-next-line github/no-then\n return UploadRadianceLevelsAsync(internalTexture, data).then(() => {\n internalTexture.isReady = true;\n return internalTexture;\n });\n}\n/**\n * Sets of helpers addressing the serialization and deserialization of environment texture\n * stored in a BabylonJS env file.\n * Those files are usually stored as .env files.\n */\nexport const EnvironmentTextureTools = {\n /**\n * Gets the environment info from an env file.\n * @param data The array buffer containing the .env bytes.\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\n */\n GetEnvInfo,\n /**\n * Creates an environment texture from a loaded cube texture.\n * @param texture defines the cube texture to convert in env file\n * @param options options for the conversion process\n * @param options.imageType the mime type for the encoded images, with support for \"image/png\" (default) and \"image/webp\"\n * @param options.imageQuality the image quality of encoded WebP images.\n * @returns a promise containing the environment data if successful.\n */\n CreateEnvTextureAsync,\n /**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\n CreateRadianceImageDataArrayBufferViews,\n /**\n * Creates the ArrayBufferViews used for initializing environment texture image data.\n * @param data the image data\n * @param info parameters that determine what views will be created for accessing the underlying buffer\n * @returns the views described by info providing access to the underlying buffer\n */\n CreateIrradianceImageDataArrayBufferViews,\n /**\n * Uploads the texture info contained in the env file to the GPU.\n * @param texture defines the internal texture to upload to\n * @param data defines the data to load\n * @param info defines the texture info retrieved through the GetEnvInfo method\n * @returns a promise\n */\n UploadEnvLevelsAsync,\n /**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param imageType the mime type of the image data\n * @returns a promise\n */\n UploadRadianceLevelsAsync,\n /**\n * Uploads the levels of image data to the GPU.\n * @param texture defines the internal texture to upload to\n * @param imageData defines the array buffer views of image data [mipmap][face]\n * @param imageType the mime type of the image data\n * @param dominantDirection the dominant direction of light in the environment texture, if available\n * @returns a promise\n */\n UploadIrradianceLevelsAsync,\n /**\n * Uploads spherical polynomials information to the texture.\n * @param texture defines the texture we are trying to upload the information to\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\n */\n UploadEnvSpherical,\n};\n//# sourceMappingURL=environmentTextureTools.js.map","import { GetEnvInfo, UploadEnvLevelsAsync, UploadEnvSpherical } from \"../../../Misc/environmentTextureTools.js\";\n/**\n * Implementation of the ENV Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _ENVTextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = false;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param createPolynomials will be true if polynomials have been requested\n * @param onLoad defines the callback to trigger once the texture is ready\n * @param onError defines the callback to trigger in case of error\n */\n loadCubeData(data, texture, createPolynomials, onLoad, onError) {\n if (Array.isArray(data)) {\n return;\n }\n const info = GetEnvInfo(data);\n if (info) {\n texture.width = info.width;\n texture.height = info.width;\n try {\n UploadEnvSpherical(texture, info);\n // eslint-disable-next-line github/no-then\n UploadEnvLevelsAsync(texture, data, info).then(() => {\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\n }, (reason) => {\n onError?.(\"Can not upload environment levels\", reason);\n });\n }\n catch (e) {\n onError?.(\"Can not upload environment file\", e);\n }\n }\n else if (onError) {\n onError(\"Can not parse the environment file\", null);\n }\n }\n /**\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\n */\n loadData() {\n // eslint-disable-next-line no-throw-literal\n throw \".env not supported in 2d.\";\n }\n}\n//# sourceMappingURL=envTextureLoader.js.map"],"names":["DefaultEnvironmentTextureImageType","CurrentVersion","MagicBytes","GetEnvInfo","data","dataView","pos","i","Logger","manifestString","charCode","manifest","normalizeEnvInfo","info","CreateRadianceImageDataArrayBufferViews","specularInfo","mipmapsCount","imageData","face","imageInfo","CreateIrradianceImageDataArrayBufferViews","irradianceTexture","_a","UploadEnvLevelsAsync","texture","promises","radianceImageData","UploadRadianceLevelsAsync","irradianceImageData","dominantDirection","_c","_b","Vector3","UploadIrradianceLevelsAsync","_OnImageReadyAsync","image","engine","expandTexture","rgbdPostProcess","url","generateNonLODTextures","lodTextures","cubeRtt","resolve","reject","tempTexture","message","effect","lodTexture","imageType","_UploadLevelsAsync","mainTexture","size","InternalTexture","baseTexture","BaseTexture","canGenerateNonLODTextures","Tools","ILog2","caps","shaderLanguage","PostProcess","scale","offset","roughness","minLODIndex","maxLODIndex","lodIndex","mipmapIndex","glTextureFromLod","bytes","blob","promise","img","reason","error","dataLength","irradiance","UploadEnvSpherical","irradianceInfo","sp","SphericalPolynomial","_ENVTextureLoader","createPolynomials","onLoad","onError","e"],"mappings":";;AAaA,MAAMA,IAAqC,aACrCC,IAAiB,GAIjBC,IAAa,CAAC,KAAM,IAAM,KAAM,KAAM,KAAM,KAAM,KAAM,EAAI;AAM3D,SAASC,EAAWC,GAAM;AAC7B,QAAMC,IAAW,IAAI,SAASD,EAAK,QAAQA,EAAK,YAAYA,EAAK,UAAU;AAC3E,MAAIE,IAAM;AACV,WAASC,IAAI,GAAGA,IAAIL,EAAW,QAAQK;AACnC,QAAIF,EAAS,SAASC,GAAK,MAAMJ,EAAWK,CAAC;AACzC,aAAAC,EAAO,MAAM,+BAA+B,GACrC;AAIf,MAAIC,IAAiB,IACjBC,IAAW;AACf,SAAQA,IAAWL,EAAS,SAASC,GAAK;AACtC,IAAAG,KAAkB,OAAO,aAAaC,CAAQ;AAElD,MAAIC,IAAW,K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,IACA,MACa,CAAID,KACLA,EAAQ,sCAAsC,IAAI;AAAA,EAE9D;AAAA;AAAA;AAAA;AAAA,EAII,WAAW;AAEP,UAAM;AAAA,EACd;AACA;","x_google_ignoreList":[0,1]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Sn, c as rn, e as W } from "./index-
|
|
1
|
+
import { C as Sn, c as rn, e as W } from "./index-DM3Dwe0V.js";
|
|
2
2
|
const an = 4, X = 4, sn = 1, N = 2, En = 8, H = 65536, j = H >> 3, xn = 16, C = 14, k = (1 << xn) + 1, V = 1 << C, d = V - 1, K = 59, cn = 63, vn = 2 + cn - K;
|
|
3
3
|
var U;
|
|
4
4
|
(function(n) {
|
|
@@ -738,4 +738,4 @@ class et {
|
|
|
738
738
|
export {
|
|
739
739
|
et as _ExrTextureLoader
|
|
740
740
|
};
|
|
741
|
-
//# sourceMappingURL=exrTextureLoader-
|
|
741
|
+
//# sourceMappingURL=exrTextureLoader-CWNwDbqP.js.map
|