BabylonJS/Babylon.js · critical · Error
Missing arrays in SOG scales data.
Error message
Missing arrays in SOG scales data.
What it means
In SOG version 1 (non-codebook) files, scales are dequantized per-component via linear interpolation between per-axis mins and maxs arrays stored in meta.json. This error means data.scales.mins or data.scales.maxs is missing or is not an array (SOGDataFile types them as number | number[]; a scalar is only valid for shN), so scale values cannot be reconstructed from the 8-bit image data.
Source
Thrown at packages/dev/loaders/src/SPLAT/sog.pure.ts:199
}
// --- Scales
const scales = imageDataArrays[2].bits;
if (data.version === 2) {
if (!data.scales.codebook) {
throw new Error("Missing codebook in SOG version 2 scales data.");
}
for (let i = 0; i < splatCount; i++) {
const index = i * 4;
for (let j = 0; j < 3; j++) {
const sc = data.scales.codebook[scales[index + j]];
const sce = Math.exp(sc);
scale[i * 8 + 3 + j] = sce;
}
}
} else {
if (!Array.isArray(data.scales.mins) || !Array.isArray(data.scales.maxs)) {
throw new Error("Missing arrays in SOG scales data.");
}
for (let i = 0; i < splatCount; i++) {
const index = i * 4;
for (let j = 0; j < 3; j++) {
const sc = scales[index + j];
const lsc = Scalar.Lerp(data.scales.mins[j], data.scales.maxs[j], sc / 255);
const lsce = Math.exp(lsc);
scale[i * 8 + 3 + j] = lsce;
}
}
}
// --- 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.");
View on GitHub (pinned to 0592b347b8)
Solutions
- Add the correct 3-element mins/maxs arrays to the scales entry of meta.json (matching what the encoder used for quantization).
- If the asset is v2, restore version: 2 in meta.json so the codebook path is used and mins/maxs are not required.
- Pre-validate meta.json: Array.isArray(meta.scales.mins) && Array.isArray(meta.scales.maxs) when version !== 2.
Example fix
// before
"scales": { "shape": [100000, 3], "dtype": "uint8", "files": ["scales.webp"] }
// after
"scales": { "shape": [100000, 3], "dtype": "uint8", "files": ["scales.webp"], "mins": [-4.2, -4.2, -4.2], "maxs": [4.2, 4.2, 4.2] } Defensive patterns
Strategy: validation
Validate before calling
function validateV1Scales(meta) {
if (meta.version !== 2 &&
!(Array.isArray(meta.scales?.mins) && meta.scales.mins.length === 3 &&
Array.isArray(meta.scales?.maxs) && meta.scales.maxs.length === 3)) {
throw new Error('v1 SOG asset: meta.scales.mins/maxs (3-element arrays) are required');
}
} Type guard
function hasScalesRanges(meta) {
return Array.isArray(meta.scales?.mins) && Array.isArray(meta.scales?.maxs) &&
meta.scales.mins.length === 3 && meta.scales.maxs.length === 3;
} Try / catch
try {
return await ParseSogMeta(metaOrFiles, rootUrl, scene);
} catch (e) {
if (e.message === 'Missing arrays in SOG scales data.') {
// meta.scales lacks mins/maxs: asset is malformed for its declared version
}
throw e;
} Prevention
- Validate the full meta.json against the SOGDataFile schema (mins/maxs arrays per attribute) before loading.
- Do not strip 'unknown' fields when transforming meta.json — mins/maxs and codebook are required per version.
- Track SOG format version per asset so v1 ranges vs v2 codebooks are not confused.
When it happens
Trigger: Parsing a SOG bundle (ParseSogMeta) whose meta.json omits mins/maxs on the scales entry, or supplies them as a scalar instead of a 3-element array; also fires when a v2-encoded file has its version field missing/reset so the code falls into the v1 branch.
Common situations: Hand-written or trimmed meta.json from an external SOG tool; an encoder bug that emits scalar mins/maxs for scales; version field stripped by a minifier/JSON transform causing v2 data to take the v1 code path.
Related errors
- Missing arrays in SOG sh0 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/4dd4d731e57bd816.
Report an issue: GitHub.