diff --git a/packages/dev/core/src/Materials/effect.functions.ts b/packages/dev/core/src/Materials/effect.functions.ts index 30cdcb510e2..e7ea41a41b8 100644 --- a/packages/dev/core/src/Materials/effect.functions.ts +++ b/packages/dev/core/src/Materials/effect.functions.ts @@ -336,7 +336,7 @@ export const _retryWithInterval = (condition: () => boolean, onSuccess: () => vo maxTimeout -= step; if (maxTimeout < 0) { clearInterval(int); - onError?.(); + onError?.(new Error("Timeout")); } }, step); }; diff --git a/packages/dev/core/src/Misc/rgbdTextureTools.ts b/packages/dev/core/src/Misc/rgbdTextureTools.ts index eb29012a37d..f4c1513f3e2 100644 --- a/packages/dev/core/src/Misc/rgbdTextureTools.ts +++ b/packages/dev/core/src/Misc/rgbdTextureTools.ts @@ -52,9 +52,9 @@ export class RGBDTextureTools { internalTexture.isReady = false; if (isWebGPU) { - await Promise.all([import("../ShadersWGSL/rgbdDecode.fragment"), import("../ShadersWGSL/rgbdEncode.fragment")]); + await import("../ShadersWGSL/rgbdDecode.fragment"); } else { - await Promise.all([import("../Shaders/rgbdDecode.fragment"), import("../Shaders/rgbdEncode.fragment")]); + await import("../Shaders/rgbdDecode.fragment"); } // Expand the texture if possible @@ -130,7 +130,12 @@ export class RGBDTextureTools { * @param outputTextureType type of the texture in which the encoding is performed * @returns a promise with the internalTexture having its texture replaced by the result of the processing */ - public static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE): Promise { + public static async EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE): Promise { + if (!scene.getEngine().isWebGPU) { + await import("../Shaders/rgbdEncode.fragment"); + } else { + await import("../ShadersWGSL/rgbdEncode.fragment"); + } return ApplyPostProcess("rgbdEncode", internalTexture, scene, outputTextureType, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA); } }