BabylonJS/Babylon.js · error

Path ${path} is invalid - no length accessor

Error message

Path ${path} is invalid - no length accessor

What it means

GLTFPathToObjectConverter.convert() resolves a glTF Object Model JSON Pointer against the loader's info tree. When the last path segment is `.length`, the library expects the current info level to either expose a dedicated `length` accessor or to be a typed array (`__array__`) whose length can be computed. This throw fires when the path ends in `.length` on a level that is an array container (`__array__`) but defines no `length` accessor, so the loader cannot compute a length for it.

Source

Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts:100

        //if the last part has ".length" in it, separate that as an extra part
        if (parts[parts.length - 1].includes(".length")) {
            const lastPart = parts[parts.length - 1];
            const split = lastPart.split(".");
            parts.pop();
            parts.push(...split);
        }

        let ignoreObjectTree = false;

        for (const part of parts) {
            const isLength = part === "length";
            if (isLength) {
                // For .length, check if the current level has a 'length' accessor
                if (infoTree.length) {
                    infoTree = infoTree.length;
                } else if (infoTree.__array__) {
                    // Fallback: length of an array that doesn't have explicit length accessor
                    throw new Error(`Path ${path} is invalid - no length accessor`);
                } else {
                    throw new Error(`Path ${path} is invalid`);
                }
                // Set target to the current object tree (the array itself)
                // Only update target if objectTree is defined, otherwise keep the last valid target
                if (objectTree !== undefined) {
                    target = objectTree;
                }
                continue;
            }
            if (infoTree.__ignoreObjectTree__) {
                ignoreObjectTree = true;
            }
            if (infoTree.__array__) {
                infoTree = infoTree.__array__;
            } else {
                infoTree = infoTree[part];
                if (!infoTree) {

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Use a pointer without the `.length` suffix, or point at a property that the Babylon glTF object model defines a `length` accessor for
  2. Check the Babylon glTF Object Model docs to confirm the array supports a length pointer
  3. If you own the info tree definition (extension author), add a `length` accessor entry to the array's info tree
  4. Upgrade Babylon.js - support for implicit array lengths has changed across versions

Example fix

// before
converter.convert("/nodes.length"); // throws if no length accessor defined
// after
const hasLength = "/nodes.length" in supportedPointers; // or use a concrete property
converter.convert("/nodes/0/translation");
Defensive patterns

Strategy: validation

Validate before calling

const supportedLengthPointers = ["/nodes.length", "/meshes.length", "/materials.length", "/animations.length"];
if (path.endsWith(".length") && !supportedLengthPointers.includes(path)) {
    throw new Error(`Refusing to bind unsupported length pointer: ${path}`);
}

Type guard

function isKnownArrayRoot(path: string, gltf: any): boolean {
    const root = path.replace(/^\//, "").replace(/\.length$/, "");
    return Array.isArray(gltf?.[root]);
}

Try / catch

try {
    accessor = converter.convert(path);
} catch (e) {
    if (String(e.message).includes("no length accessor")) {
        accessor = null; // fall back to manual array.length lookup
    } else throw e;
}

Prevention

When it happens

Trigger: Calling convert() (directly or via KHR_animation_pointer / KHR_interactivity property resolution) with a pointer such as `/nodes.length` where the info tree entry for `nodes` is marked `__array__` but has no `length` info defined, or `.length` applied to a non-array property.

Common situations: A glTF asset's interactivity/animation graph references an array length pointer that the Babylon object model definition does not implement; using a `.length` pointer on an extension-defined array that has no length metadata.

Related errors


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