{"record":{"id":"4080a2b34ff1d6d2","repo":"BabylonJS/Babylon.js","slug":"all-images-must-share-the-same-dimensions-image-a","errorCode":null,"errorMessage":"All images must share the same dimensions. Image at index ${index} is ${bitmap.width}x${bitmap.height}, expected ${width}x${height}.","messagePattern":"All images must share the same dimensions\\. Image at index (.+?) is (.+?)x(.+?), expected (.+?)x(.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Materials/Textures/rawTexture2DArray.functions.ts","lineNumber":265,"sourceCode":"                result.value.close();\r\n            }\r\n        }\r\n        throw firstRejection.reason;\r\n    }\r\n\r\n    const bitmaps = results.filter((result): result is PromiseFulfilledResult<ImageBitmap> => result.status === \"fulfilled\").map((result) => result.value) as [\r\n        ImageBitmap,\r\n        ...ImageBitmap[],\r\n    ];\r\n\r\n    try {\r\n        const width = bitmaps[0].width;\r\n        const height = bitmaps[0].height;\r\n\r\n        for (let index = 1; index < bitmaps.length; index++) {\r\n            const bitmap = bitmaps[index];\r\n            if (bitmap.width !== width || bitmap.height !== height) {\r\n                throw new Error(`All images must share the same dimensions. Image at index ${index} is ${bitmap.width}x${bitmap.height}, expected ${width}x${height}.`);\r\n            }\r\n        }\r\n\r\n        const texture = new RawTexture2DArray(\r\n            null,\r\n            width,\r\n            height,\r\n            bitmaps.length,\r\n            Constants.TEXTUREFORMAT_RGBA,\r\n            scene,\r\n            options?.generateMipMaps ?? true,\r\n            options?.invertY ?? false,\r\n            options?.samplingMode,\r\n            options?.textureType\r\n        );\r\n\r\n        try {\r\n            const uploadOptions: IUploadImageToTexture2DArrayLayerOptions = {\r","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Materials/Textures/rawTexture2DArray.functions.ts#L247-L283","documentation":"A 2D array texture requires every layer to share the same width and height. After decoding all images into ImageBitmaps, this error is thrown if any image at index > 0 differs in size from the first one.","triggerScenarios":"Calling CreateTexture2DArrayFromImageUrlsAsync (or the texture2DArray helpers that call it) with a URL list whose images have differing pixel dimensions.","commonSituations":"Mixing PNG slices exported at different resolutions, images resized by a build step, using a mipmap variant URL by mistake in one entry, retina vs non-retina exports mixed together.","solutions":["Resize all source images to identical dimensions before uploading (or at export time).","Request size-consistent variants from the server, or add imageBitmapOptions with resizeWidth/resizeHeight so all bitmaps are normalized.","Log each image's natural size before calling and fix the outliers in the asset pipeline."],"exampleFix":"// before: mixed sizes pass straight through\nawait CreateTexture2DArrayFromImageUrlsAsync(urls, scene);\n// after: normalize decode size\nawait CreateTexture2DArrayFromImageUrlsAsync(urls, scene, {\n  imageBitmapOptions: { resizeWidth: 512, resizeHeight: 512 }\n});","handlingStrategy":"validation","validationCode":"// Normalize all images to one size via imageBitmapOptions\nconst options = { imageBitmapOptions: { resizeWidth: 512, resizeHeight: 512 } };\nawait CreateTexture2DArrayFromImageUrlsAsync(urls, scene, options);","typeGuard":"function allBitmapsSameSize(bitmaps: ImageBitmap[]): boolean {\n  return bitmaps.every(b => b.width === bitmaps[0].width && b.height === bitmaps[0].height);\n}","tryCatchPattern":"try {\n  const tex = await CreateTexture2DArrayFromImageUrlsAsync(urls, scene);\n} catch (e) {\n  if (String(e.message).startsWith(\"All images must share the same dimensions\")) {\n    console.error(\"Fix the asset listed in the error index.\");\n  }\n}","preventionTips":["Resize all array slice images to a fixed resolution at export time.","Decode with imageBitmapOptions resize to enforce uniformity regardless of source size.","Keep retina/non-retina variants in separate sets, never mixed in one array."],"tags":["texture-array","dimension-mismatch","imagebitmap","asset-validation"],"backgroundTag":"layer-dimension-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}