{"record":{"id":"7b0867d4f29e3ee2","repo":"BabylonJS/Babylon.js","slug":"missing-arrays-in-sog-sh0-data","errorCode":null,"errorMessage":"Missing arrays in SOG sh0 data.","messagePattern":"Missing arrays in SOG sh0 data\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/dev/loaders/src/SPLAT/sog.pure.ts","lineNumber":229,"sourceCode":"    }\r\n\r\n    // --- Colors/SH0\r\n    const colors = imageDataArrays[4].bits;\r\n    if (data.version === 2) {\r\n        if (!data.sh0.codebook) {\r\n            throw new Error(\"Missing codebook in SOG version 2 sh0 data.\");\r\n        }\r\n        for (let i = 0; i < splatCount; i++) {\r\n            const index = i * 4;\r\n            for (let j = 0; j < 3; j++) {\r\n                const component = 0.5 + data.sh0.codebook[colors[index + j]] * SH_C0;\r\n                rgba[i * 32 + 24 + j] = Math.max(0, Math.min(255, Math.round(255 * component)));\r\n            }\r\n            rgba[i * 32 + 24 + 3] = colors[index + 3];\r\n        }\r\n    } else {\r\n        if (!Array.isArray(data.sh0.mins) || !Array.isArray(data.sh0.maxs)) {\r\n            throw new Error(\"Missing arrays in SOG sh0 data.\");\r\n        }\r\n        for (let i = 0; i < splatCount; i++) {\r\n            const index = i * 4;\r\n            for (let j = 0; j < 4; j++) {\r\n                const colorsMin = data.sh0.mins[j];\r\n                const colorsMax = data.sh0.maxs[j];\r\n\r\n                const colort = colors[index + j];\r\n                const c = Scalar.Lerp(colorsMin, colorsMax, colort / 255);\r\n\r\n                let csh;\r\n                if (j < 3) {\r\n                    csh = 0.5 + c * SH_C0;\r\n                } else {\r\n                    csh = 1.0 / (1.0 + Math.exp(-c));\r\n                }\r\n\r\n                rgba[i * 32 + 24 + j] = Math.max(0, Math.min(255, Math.round(255 * csh)));\r","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/SPLAT/sog.pure.ts#L211-L247","documentation":"For SOG version 1, sh0 color components are dequantized by lerping between per-channel mins/maxs arrays (4 elements: 3 color channels + opacity) in meta.json. This error means data.sh0.mins or data.sh0.maxs is missing or not an array, so base colors cannot be reconstructed from the sh0 image bytes.","triggerScenarios":"Parsing a v1 SOG bundle where the sh0 entry of meta.json lacks array mins/maxs, or a v2 asset whose version field was lost, causing the decoder to take the v1 branch that expects those arrays.","commonSituations":"Externally produced SOG files with incomplete metadata; asset conversion scripts that strip mins/maxs; mixing meta.json from one asset with images from another version.","solutions":["Add the 4-element mins/maxs arrays to the sh0 entry of meta.json.","If the asset is v2, restore version: 2 so the codebook path is used.","Pre-validate meta.json sh0.mins/sh0.maxs are arrays when version !== 2."],"exampleFix":"// before\n\"sh0\": { \"shape\": [100000, 4], \"dtype\": \"uint8\", \"files\": [\"sh0.webp\"] }\n// after\n\"sh0\": { \"shape\": [100000, 4], \"dtype\": \"uint8\", \"files\": [\"sh0.webp\"], \"mins\": [-1.5, -1.5, -1.5, -6.0], \"maxs\": [1.5, 1.5, 1.5, 6.0] }","handlingStrategy":"validation","validationCode":"function validateV1Sh0(meta) {\n  if (meta.version !== 2 &&\n      !(Array.isArray(meta.sh0?.mins) && meta.sh0.mins.length === 4 &&\n        Array.isArray(meta.sh0?.maxs) && meta.sh0.maxs.length === 4)) {\n    throw new Error('v1 SOG asset: meta.sh0.mins/maxs (4-element arrays) are required');\n  }\n}","typeGuard":"function hasSh0Ranges(meta) {\n  return Array.isArray(meta.sh0?.mins) && Array.isArray(meta.sh0?.maxs) &&\n         meta.sh0.mins.length === 4 && meta.sh0.maxs.length === 4;\n}","tryCatchPattern":"try {\n  return await ParseSogMeta(metaOrFiles, rootUrl, scene);\n} catch (e) {\n  if (e.message === 'Missing arrays in SOG sh0 data.') {\n    // meta.sh0 lacks mins/maxs: regenerate metadata or fix the version field\n  }\n  throw e;\n}","preventionTips":["Validate sh0 mins/maxs have exactly 4 entries (RGB + opacity) when version is not 2.","Keep asset conversion scripts schema-aware: v1 requires ranges, v2 requires codebooks.","Bundle meta.json with a manifest of the export that produced it to avoid version drift."],"tags":["sog","gaussian-splatting","metadata","quantization","asset-validation"],"backgroundTag":"missing-quantization-range-metadata","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}