{"record":{"id":"23c7718eeba15fc1","repo":"BabylonJS/Babylon.js","slug":"error-parsing-variables","errorCode":null,"errorMessage":"Error parsing variables","messagePattern":"Error parsing variables","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts","lineNumber":146,"sourceCode":"        }\n    }\n\n    private _parseVariables() {\n        if (!this._interactivityGraph.variables) {\n            return;\n        }\n        for (const variable of this._interactivityGraph.variables) {\n            const parsed = this._parseVariable(variable);\n            // set the default values here\n            this._staticVariables.push(parsed);\n        }\n    }\n\n    private _parseVariable(variable: IKHRInteractivity_Variable, dataTransform?: (value: any, parser: InteractivityGraphToFlowGraphParser) => any) {\n        const type = this._types[variable.type];\n        if (!type) {\n            Logger.Error([\"No type found for variable\", variable]);\n            throw new Error(\"Error parsing variables\");\n        }\n        if (variable.value) {\n            if (variable.value.length !== type.length) {\n                Logger.Error([\"Invalid value length for variable\", variable, type]);\n                throw new Error(\"Error parsing variables\");\n            }\n        }\n        const value = variable.value || [];\n        if (!value.length) {\n            switch (type.flowGraphType) {\n                case FlowGraphTypes.Boolean:\n                    value.push(false);\n                    break;\n                case FlowGraphTypes.Integer:\n                    value.push(0);\n                    break;\n                case FlowGraphTypes.Number:\n                    value.push(NaN);","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts#L128-L164","documentation":"Thrown by _parseVariable when a variable (or event value) references a `type` index that does not exist in the parser's parsed type table. The type table is built from the graph's `types` array signatures; an out-of-range index or an unrecognized signature (which pushed `undefined` into the table) causes this throw.","triggerScenarios":"A variable/event value's `type` index points past the end of the graph's `types` array, or the type at that index has a `signature` not present in gltfTypeToBabylonType (e.g. a newer glTF type like an opaque/declared type not yet supported), so this._types[i] is undefined.","commonSituations":"Assets authored with newer KHR_interactivity type signatures (e.g. string, or declared types) against an older Babylon.js build; hand-edited glTF with a bad type index; exporters writing types arrays incorrectly.","solutions":["Upgrade Babylon.js packages so gltfTypeToBabylonType covers the type signatures used by the asset","Validate that every variable's `type` index is < the length of the graph's `types` array before loading","Check the logged variable in the console to identify which variable/type index failed, then fix the asset","Re-export the asset with an up-to-date exporter that emits supported type signatures"],"exampleFix":"// before: variable references type index out of range\n{ \"variables\": [{ \"type\": 5 }], \"types\": [{ \"signature\": \"float3\" }] }\n// after\n{ \"variables\": [{ \"type\": 0 }], \"types\": [{ \"signature\": \"float3\" }] }","handlingStrategy":"type-guard","validationCode":"const typeCount = graph.types?.length ?? 0;\nfor (const v of graph.variables ?? []) {\n  if (!(v.type >= 0 && v.type < typeCount)) throw new Error(`Variable type index ${v.type} out of range`);\n}","typeGuard":"function hasValidType(v: { type: number }, types: unknown[]): boolean {\n  return Number.isInteger(v.type) && v.type >= 0 && v.type < types.length && types[v.type] != null;\n}","tryCatchPattern":"try {\n  const parser = new InteractivityGraphToFlowGraphParser(graph, gltf);\n} catch (e) {\n  if (e.message === 'Error parsing variables') {\n    console.warn('Interactivity variable references an unknown type; skipping interactivity graph');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Verify every variable/event value type index is within the types array bounds","Use an exporter that only emits type signatures supported by gltfTypeToBabylonType","Upgrade Babylon.js before loading assets authored with newer interactivity types","Run glTF schema validation as part of your asset pipeline"],"tags":["gltf","khr-interactivity","parser","type-resolution"],"backgroundTag":"unknown-type-reference","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}