BabylonJS/Babylon.js · error

Cannot get isInf of ${a}

Error message

Cannot get isInf of ${a}

What it means

The IsInf (is infinity) flow graph block's _polymorphicIsInf requires its input to pass isNumeric() — a plain number or FlowGraphInteger. It then checks !isFinite(value). Any other value type (boolean, string, vector, quaternion) is rejected with 'Cannot get isInf of ...' because infinity is only meaningful for numbers.

Source

Thrown at packages/dev/core/src/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.ts:875

        } else {
            throw new Error(`Cannot get NaN of ${a}`);
        }
    }
}

/**
 * Is Inf block.
 */
export class FlowGraphIsInfinityBlock extends FlowGraphUnaryOperationBlock<FlowGraphNumber, boolean> {
    constructor(config?: IFlowGraphBlockConfiguration) {
        super(RichTypeAny, RichTypeBoolean, (a) => this._polymorphicIsInf(a), FlowGraphBlockNames.IsInfinity, config);
    }

    private _polymorphicIsInf(a: FlowGraphNumber) {
        if (isNumeric(a)) {
            return !isFinite(getNumericValue(a));
        } else {
            throw new Error(`Cannot get isInf of ${a}`);
        }
    }
}

/**
 * Convert degrees to radians block.
 */
export class FlowGraphDegToRadBlock extends FlowGraphUnaryOperationBlock<FlowGraphMathOperationType, FlowGraphMathOperationType> {
    /**
     * Constructs a new instance of the flow graph math block.
     * @param config - Optional configuration for the flow graph block.
     */
    constructor(config?: IFlowGraphBlockConfiguration) {
        super(RichTypeAny, RichTypeAny, (a) => this._polymorphicDegToRad(a), FlowGraphBlockNames.DegToRad, config);
    }

    private _degToRad(a: number) {
        return (a * Math.PI) / 180;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Ensure the input connection produces a number; add an extraction or conversion block (Number(...)) before the IsInf block.
  2. If you need to test vectors/matrix results, decompose into components and test each numeric component.
  3. Fix the upstream wiring so the correct numeric output port feeds the block.

Example fix

// before: vector into IsInf
isInfBlock.value.connect(vecDivideBlock.output); // throws

// after: numeric component
const x = new FlowGraphGetXBlock();
x.value.connect(vecDivideBlock.output);
isInfBlock.value.connect(x.output);
Defensive patterns

Strategy: type-guard

Validate before calling

// before IsInf block runs
function validIsInfInput(v) {
  return typeof v === 'number' || (typeof v === 'object' && v !== null && 'value' in v);
}
if (!validIsInfInput(isInfInput)) throw new TypeError('IsInf input must be a number or FlowGraphInteger');

Type guard

function isNumericValue(v): v is number | FlowGraphInteger {
  return typeof v === 'number' || (typeof v === 'object' && v !== null && 'value' in v);
}

Try / catch

try {
  result = isInfBlock.evaluate(context);
} catch (e) {
  if (e.message.startsWith('Cannot get isInf of')) {
    result = false; // treat non-numeric as not-infinite
  } else { throw e; }
}

Prevention

When it happens

Trigger: Connecting a non-numeric value (boolean, string, Vector2/3/4, Quaternion) into the IsInf block input and executing the flow graph; note FlowGraphInteger is accepted by isNumeric even though integer infinity is unusual.

Common situations: Wiring a division result that was expected to be numeric but is a vector (e.g. matrix divide branch output); testing a string against Infinity; accidental connection of a boolean logic output.

Related errors


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