BabylonJS/Babylon.js · error

nodeIndex not found in configuration

Error message

nodeIndex not found in configuration

What it means

KHR_node_selectability attaches pick handlers by reading a numeric nodeIndex from the glTF block configuration and creating a 'pickedMesh_<index>' user variable. If the configuration block lacks a valid numeric nodeIndex, the extension cannot wire the selection logic and throws.

Source

Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/KHR_node_selectability.pure.ts:126

                isVariable: true,
            },
            {
                input: "object",
                output: "pickedMesh",
                inputBlockIndex: 2,
                outputBlockIndex: 0,
                isVariable: true,
            },
        ],
        extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {
            // add the glTF to the configuration of the last serialized object
            const serializedObject = serializedObjects[serializedObjects.length - 1];
            serializedObject.config = serializedObject.config || {};
            serializedObject.config.glTF = globalGLTF;
            // find the listener nodeIndex value
            const nodeIndex = gltfBlock.configuration?.["nodeIndex"]?.value?.[0];
            if (nodeIndex === undefined || typeof nodeIndex !== "number") {
                throw new Error("nodeIndex not found in configuration");
            }
            const variableName = "pickedMesh_" + nodeIndex;
            // find the nodeIndex value
            serializedObjects[1].config.variable = variableName;
            context._userVariables[variableName] = {
                className: "Mesh",
                id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
                uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
            };
            return serializedObjects;
        },
    });

    AddObjectAccessorToKey("/nodes/{}/extensions/KHR_node_selectability/selectable", {
        get: (node: INode) => {
            const tn = node._babylonTransformNode as any;
            if (tn && tn.isPickable !== undefined) {
                return tn.isPickable;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Add configuration.nodeIndex = { value: [<node index>] } to the offending block in the glTF.
  2. Re-export the asset with correct KHR_node_selectability data.
  3. Remove the extension if mesh selection is not required.

Example fix

// before
"configuration": null
// after
"configuration": { "nodeIndex": { "value": [12] } }
Defensive patterns

Strategy: validation

Validate before calling

const idx = selectBlock?.configuration?.nodeIndex?.value?.[0];
if (typeof idx !== 'number') throw new Error('KHR_node_selectability block missing numeric nodeIndex');

Type guard

function isSelectableBlock(block: any): boolean {
  return typeof block?.configuration?.['nodeIndex']?.value?.[0] === 'number';
}

Try / catch

try { await loader.loadAsync(url); } catch (e) {
  if (e.message.includes('nodeIndex not found')) {
    // proceed without selection handlers or repair the asset
  } else throw e;
}

Prevention

When it happens

Trigger: Loading a glTF whose KHR_node_selectability serialized blocks are missing configuration['nodeIndex'] (or it is not a number) during extraProcessor.

Common situations: Assets written by hand or by exporters that don't populate block configuration; post-processing pipelines that rewrite NodeMaterial JSON and lose configuration entries.

Related errors


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