BabylonJS/Babylon.js · error · Error
Switch should have a single configuration object, the cases
Error message
Switch should have a single configuration object, the cases array
What it means
The flow/switch extraProcessor expects the glTF switch block to declare output flows (the case branches). It throws this error when the declaration op is not flow/switch or when gltfBlock.flows is missing/empty, because it needs to rename each non-default output flow to out_<case> on the serialized block.
Source
Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.ts:1120
const onlyIntegers = cases.value.every((caseValue) => {
// case value should be an integer. Since Number.isInteger(1.0) is true, we need to check if toString has only digits.
return typeof caseValue === "number" && /^-?\d+$/.test(caseValue.toString());
});
if (!onlyIntegers) {
Logger.Warn("Switch cases should be integers. Using empty array instead.");
cases.value = [] as number[];
return { valid: true };
}
// check for duplicates
const uniqueCases = new Set(cases.value);
cases.value = Array.from(uniqueCases) as number[];
}
return { valid: true };
},
extraProcessor(gltfBlock, declaration, _mapping, _arrays, serializedObjects) {
// convert all names of output flow to out_$1 apart from "default"
if (declaration.op !== "flow/switch" || !gltfBlock.flows || Object.keys(gltfBlock.flows).length === 0) {
throw new Error("Switch should have a single configuration object, the cases array");
}
const serializedObject = serializedObjects[0];
serializedObject.signalOutputs.forEach((output) => {
if (output.name !== "default") {
output.name = "out_" + output.name;
}
});
return serializedObjects;
},
},
"flow/while": {
blocks: [FlowGraphBlockNames.WhileLoop],
outputs: {
flows: {
loopBody: { name: "executionFlow" },
},
},
},View on GitHub (pinned to 0592b347b8)
Solutions
- Ensure the flow/switch block defines at least one entry in its "flows" object (plus optional "default")
- Re-export the asset with a compliant KHR_interactivity exporter
- Fix custom declaration mapping so this processor only handles flow/switch
Example fix
// before
{ "op": "flow/switch", "configuration": { "cases": { "value": [0,1] } } } // no flows
// after
{ "op": "flow/switch", "flows": { "0": {}, "1": {} }, "configuration": { "cases": { "value": [0,1] } } } Defensive patterns
Strategy: validation
Validate before calling
function validateSwitchBlock(block) {
return typeof block.flows === "object" && block.flows !== null && Object.keys(block.flows).length > 0;
}
// verify each flow/switch block declares at least one flow before loading Type guard
const hasFlows = (b: { flows?: Record<string, unknown> | null }): b is { flows: Record<string, unknown> } => !!b.flows && Object.keys(b.flows).length > 0; Try / catch
try {
await loader.loadAsync(url);
} catch (e) {
if (e instanceof Error && e.message.includes("Switch should have a single configuration")) {
console.error("flow/switch block is missing its flows (cases) object.");
} else throw e;
} Prevention
- Ensure exporters always emit the flows map for switch blocks
- Validate interactivity JSON schema in the asset pipeline
- Test parse of all interactivity assets after exporter updates
When it happens
Trigger: Loading an interactivity graph with a switch block that has no "flows" object, an empty flows map, or a block mis-mapped so this processor runs against a non-switch declaration.
Common situations: Exporter emitting switch with zero cases; hand-pruned JSON removing flows; custom declaration maps wiring the wrong op to the switch processor.
Related errors
- Receive event should have a single configuration object, the
- MultiGate should have a single configuration object, the num
- Event id should be a number
- Rotation quaternion input not found
- Variable index is not defined for variable interpolation blo
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/aac5f79056eb4c10.
Report an issue: GitHub.