BabylonJS/Babylon.js · error · Error

Error parsing declarations

Error message

Error parsing declarations

What it means

Thrown by InteractivityGraphToFlowGraphParser._parseDeclarations when a declaration in the glTF KHR_interactivity graph has an operation (`op`) that getMappingForDeclaration cannot resolve to a FlowGraph block mapping. The parser maintains a table of supported operations; any declaration whose op (plus optional extension qualifier) is not in the table aborts loading. This means the asset uses an interactivity operation this Babylon.js version does not support.

Source

Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts:122

        if (!this._interactivityGraph.types) {
            return;
        }
        for (const type of this._interactivityGraph.types) {
            this._types.push(gltfTypeToBabylonType[type.signature]);
        }
    }

    private _parseDeclarations() {
        if (!this._interactivityGraph.declarations) {
            return;
        }
        for (const declaration of this._interactivityGraph.declarations) {
            // make sure we have the mapping for this operation
            const mapping = getMappingForDeclaration(declaration);
            // mapping is defined, because we generate an empty mapping if it's not found
            if (!mapping) {
                Logger.Error(["No mapping found for declaration", declaration]);
                throw new Error("Error parsing declarations");
            }
            this._mappings.push({
                flowGraphMapping: mapping,
                fullOperationName: declaration.extension ? declaration.op + ":" + declaration.extension : declaration.op,
            });
        }
    }

    private _parseVariables() {
        if (!this._interactivityGraph.variables) {
            return;
        }
        for (const variable of this._interactivityGraph.variables) {
            const parsed = this._parseVariable(variable);
            // set the default values here
            this._staticVariables.push(parsed);
        }
    }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Upgrade @babylonjs/core and @babylonjs/loaders to the latest version, which supports more interactivity operations
  2. Inspect the logged declaration to find the unsupported `op` and remove or replace that node in the asset
  3. Check declarationMapper.ts to see which ops are supported and re-export the asset using only supported operations
  4. If the op comes from an unregistered extension, verify the extension is enabled in the loader and has a registered mapping

Example fix

// before: asset declares an unsupported op
{ "op": "interaction/customHover", "extension": "EXT_my_ext" }
// after: upgrade Babylon OR re-export using a supported op, e.g.
{ "op": "core/Pointer/Set" }
Defensive patterns

Strategy: validation

Validate before calling

const supportedOps = new Set(Object.keys(declarationMapperTable)); // from declarationMapper
for (const d of graph.declarations ?? []) {
  if (!getMappingForDeclaration(d)) throw new Error(`Unsupported interactivity op: ${d.op}`);
}

Type guard

function hasMapping(d: IKHRInteractivity_Declaration): boolean {
  return typeof d?.op === 'string' && getMappingForDeclaration(d) != null;
}

Try / catch

try {
  const parser = new InteractivityGraphToFlowGraphParser(graph, gltf);
} catch (e) {
  if (e.message === 'Error parsing declarations') {
    console.warn('Asset uses unsupported interactivity operations; loading without interactivity');
    return null; // fall back to non-interactive load
  }
  throw e;
}

Prevention

When it happens

Trigger: Constructing InteractivityGraphToFlowGraphParser (via the glTF loader with KHR_interactivity enabled) on an asset whose `declarations` array contains an `op` string that has no entry in the declaration mapper table, or whose `extension`-qualified op is unsupported.

Common situations: Assets exported with a newer KHR_interactivity operation set than the installed Babylon.js version; custom/extension operations (op namespaced by an `extension` field) not implemented; typos in op names from hand-edited glTF files.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/0889fb0c8fbd939a. Report an issue: GitHub.