BabylonJS/Babylon.js · error · Error

Unknown vector class name ${className}

Error message

Unknown vector class name ${className}

What it means

During FlowGraph deserialization, ParseVector converts serialized arrays into Vector2/Vector3/Vector4/Quaternion/Color3/Color4 based on the className stored in the serialization object. An unrecognized className means the data was written by an incompatible/older version or is corrupted.

Source

Thrown at packages/dev/core/src/FlowGraph/serialization.ts:78

    } else if (className === FlowGraphTypes.Vector3) {
        if (flipHandedness) {
            value[2] *= -1;
        }
        return Vector3.FromArray(value);
    } else if (className === FlowGraphTypes.Vector4) {
        return Vector4.FromArray(value);
    } else if (className === FlowGraphTypes.Quaternion) {
        if (flipHandedness) {
            value[2] *= -1;
            value[3] *= -1;
        }
        return Quaternion.FromArray(value);
    } else if (className === FlowGraphTypes.Color3) {
        return new Color3(value[0], value[1], value[2]);
    } else if (className === FlowGraphTypes.Color4) {
        return new Color4(value[0], value[1], value[2], value[3]);
    } else {
        throw new Error(`Unknown vector class name ${className}`);
    }
}

/**
 * The default function that serializes values in a context object to a serialization object
 * @param key the key where the value should be stored in the serialization object
 * @param value the value to store
 * @param serializationObject the object where the value will be stored
 */
// eslint-disable-next-line @typescript-eslint/naming-convention
export function defaultValueSerializationFunction(key: string, value: any, serializationObject: any) {
    const className = value?.getClassName?.() ?? "";
    if (IsVectorClassName(className) || IsMatrixClassName(className)) {
        serializationObject[key] = {
            value: value.asArray(),
            className,
        };
    } else if (className === FlowGraphTypes.Integer) {

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Correct the className in the serialized data to a supported FlowGraphTypes value
  2. Re-export the flow graph from the same Babylon.js version used to deserialize it
  3. Extend ParseVector to support the new class name if you added a custom type

Example fix

// before (serialized JSON)
{"className": "vector3", "value": [1,2,3]}
// after
{"className": "Vector3", "value": [1,2,3]}
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = ['Vector2','Vector3','Vector4','Quaternion','Color3','Color4'];
if (!KNOWN.includes(className)) throw new Error(`unsupported vector className: ${className}`);

Type guard

function isKnownVectorClassName(c: string): c is 'Vector2'|'Vector3'|'Vector4'|'Quaternion'|'Color3'|'Color4' { return ['Vector2','Vector3','Vector4','Quaternion','Color3','Color4'].includes(c); }

Try / catch

try { value = defaultValueParseFunction(key, serialized); } catch (e) { if (e.message.startsWith('Unknown vector class name')) { console.error('Upgrade Babylon or fix serialized className'); } else { throw e; } }

Prevention

When it happens

Trigger: defaultValueParseFunction encounters a context value whose className is not one of the FlowGraphTypes vector/color names handled by ParseVector.

Common situations: Hand-edited or machine-generated flow graph JSON with a typo like "vector3", deserializing graphs saved from a newer Babylon version with new types, or corrupted serialization payloads.

Related errors


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