BabylonJS/Babylon.js · error · Error

Unable to find a compatible match

Error message

Unable to find a compatible match

What it means

NodeMaterialBlock.connectTo tries to auto-match an output of this block to an input of the other block. If at some step no output remains to try (output became null after consuming all sibling outputs), it throws — the blocks have no connectable point pair.

Source

Thrown at packages/dev/core/src/Materials/Node/nodeMaterialBlock.ts:466

            output?: string;
            outputSwizzle?: string;
        }
    ) {
        if (this._outputs.length === 0) {
            return;
        }

        let output = options && options.output ? this.getOutputByName(options.output) : this.getFirstAvailableOutput(other);

        let notFound = true;
        while (notFound) {
            const input = options && options.input ? other.getInputByName(options.input) : other.getFirstAvailableInput(output);

            if (output && input && output.canConnectTo(input)) {
                output.connectTo(input);
                notFound = false;
            } else if (!output) {
                throw new Error("Unable to find a compatible match");
            } else {
                output = this.getSiblingOutput(output);
            }
        }

        return this;
    }

    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    protected _buildBlock(state: NodeMaterialBuildState) {
        // Empty. Must be defined by child nodes
    }

    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    protected _postBuildBlock(state: NodeMaterialBuildState) {
        // Empty. Must be defined by child nodes
    }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Connect explicitly: a.getOutputByName('xyz').connectTo(b.getInputByName('target'))
  2. Verify the blocks have compatible connection types (check canConnectTo / point types)
  3. Ensure the source output isn't already connected; use a new block instance or disconnect first

Example fix

// before
transform.connectTo(vertexOutput); // no compatible free output
// after
// correct chain: transform -> fragment output -> vertex output
transform.getOutputByName('vector').connectTo(fragmentOutput.getInputByName('worldPosition'));
fragmentOutput.connectTo(vertexOutput);
Defensive patterns

Strategy: type-guard

Validate before calling

const out = a.getOutputByName('output');
const inp = b.getInputByName('input');
if (!out || !inp || !out.canConnectTo(inp)) throw new Error(`Cannot connect ${a.name} -> ${b.name}`);
out.connectTo(inp);

Type guard

const connectable = (out: NodeMaterialConnectionPoint | null, inp: NodeMaterialConnectionPoint | null): out is NodeMaterialConnectionPoint =>
  out !== null && inp !== null && out.canConnectTo(inp);

Try / catch

try {
  blockA.connectTo(blockB);
} catch (e) {
  if (e instanceof Error && e.message.includes('Unable to find a compatible match')) {
    console.error('No compatible connection between', blockA.name, 'and', blockB.name);
  } else throw e;
}

Prevention

When it happens

Trigger: blockA.connectTo(blockB) where all of A's outputs are already connected or none can drive any of B's inputs; traversal walks all sibling outputs without finding a canConnectTo match.

Common situations: Chaining blocks with incompatible point types; blocks whose outputs were already consumed; misremembering block connection capabilities vs. the NME graph.

Related errors


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