BabylonJS/Babylon.js · critical · Error
Missing arrays in SOG sh0 data.
Error message
Missing arrays in SOG sh0 data.
What it means
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.
Source
Thrown at packages/dev/loaders/src/SPLAT/sog.pure.ts:229
}
// --- Colors/SH0
const colors = imageDataArrays[4].bits;
if (data.version === 2) {
if (!data.sh0.codebook) {
throw new Error("Missing codebook in SOG version 2 sh0 data.");
}
for (let i = 0; i < splatCount; i++) {
const index = i * 4;
for (let j = 0; j < 3; j++) {
const component = 0.5 + data.sh0.codebook[colors[index + j]] * SH_C0;
rgba[i * 32 + 24 + j] = Math.max(0, Math.min(255, Math.round(255 * component)));
}
rgba[i * 32 + 24 + 3] = colors[index + 3];
}
} else {
if (!Array.isArray(data.sh0.mins) || !Array.isArray(data.sh0.maxs)) {
throw new Error("Missing arrays in SOG sh0 data.");
}
for (let i = 0; i < splatCount; i++) {
const index = i * 4;
for (let j = 0; j < 4; j++) {
const colorsMin = data.sh0.mins[j];
const colorsMax = data.sh0.maxs[j];
const colort = colors[index + j];
const c = Scalar.Lerp(colorsMin, colorsMax, colort / 255);
let csh;
if (j < 3) {
csh = 0.5 + c * SH_C0;
} else {
csh = 1.0 / (1.0 + Math.exp(-c));
}
rgba[i * 32 + 24 + j] = Math.max(0, Math.min(255, Math.round(255 * csh)));
View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before
"sh0": { "shape": [100000, 4], "dtype": "uint8", "files": ["sh0.webp"] }
// after
"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] } Defensive patterns
Strategy: validation
Validate before calling
function validateV1Sh0(meta) {
if (meta.version !== 2 &&
!(Array.isArray(meta.sh0?.mins) && meta.sh0.mins.length === 4 &&
Array.isArray(meta.sh0?.maxs) && meta.sh0.maxs.length === 4)) {
throw new Error('v1 SOG asset: meta.sh0.mins/maxs (4-element arrays) are required');
}
} Type guard
function hasSh0Ranges(meta) {
return Array.isArray(meta.sh0?.mins) && Array.isArray(meta.sh0?.maxs) &&
meta.sh0.mins.length === 4 && meta.sh0.maxs.length === 4;
} Try / catch
try {
return await ParseSogMeta(metaOrFiles, rootUrl, scene);
} catch (e) {
if (e.message === 'Missing arrays in SOG sh0 data.') {
// meta.sh0 lacks mins/maxs: regenerate metadata or fix the version field
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Missing arrays in SOG scales data.
- Missing codebook in SOG version 2 scales data.
- SOG texture contains ${splatTexelCount} texels, but metadata
- Missing codebook in SOG version 2 sh0 data.
- Invalid quaternion mode
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/7b0867d4f29e3ee2.
Report an issue: GitHub.