BabylonJS/Babylon.js · error

BabylonScenePathToObjectConverter: path "${path}" is missing

Error message

BabylonScenePathToObjectConverter: path "${path}" is missing a collection name.

What it means

After stripping the Babylon namespace prefix, convert() splits the remainder into '/'-separated segments and filters out empty ones. If nothing remains, there is no collection name to resolve, so the library throws. This catches paths that consist solely of the prefix (or prefix plus slashes), which carry no information about which scene-object collection to look up.

Source

Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts:136

        private _scene: Scene,
        private _tree: IBabylonSceneObjectModelTree
    ) {}

    /**
     * @param path the full JSON Pointer (must start with the Babylon prefix)
     * @returns an object-info container holding the resolved instance and accessor
     */
    public convert(path: string): IObjectInfo<IObjectAccessor> {
        if (!path.startsWith(BABYLON_SCENE_OBJECT_MODEL_PREFIX)) {
            throw new Error(`BabylonScenePathToObjectConverter: path "${path}" does not start with the expected prefix "${BABYLON_SCENE_OBJECT_MODEL_PREFIX}".`);
        }

        // Strip the namespace prefix and split. Ignore trailing empty segments
        // so refs of the form "/extensions/BABYLON_scene_objects/transformNodes/42/" parse cleanly.
        const tail = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length);
        const parts = tail.split("/").filter((p) => p.length > 0);
        if (parts.length === 0) {
            throw new Error(`BabylonScenePathToObjectConverter: path "${path}" is missing a collection name.`);
        }

        const collectionName = parts[0];
        const collection = (this._tree as unknown as Record<string, IBabylonObjectCollection<any> | undefined>)[collectionName];
        if (!collection) {
            throw new Error(`BabylonScenePathToObjectConverter: unknown collection "${collectionName}" in path "${path}".`);
        }

        // Handle `<collection>.length` (no instance lookup).
        if (parts.length === 2 && parts[1] === "length") {
            const arr = this._getCollectionArray(collectionName);
            return { object: arr, info: collection.length as AnyAccessor };
        }

        if (parts.length < 2) {
            throw new Error(`BabylonScenePathToObjectConverter: path "${path}" is missing an instance id.`);
        }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Ensure the full pointer includes at least '<collection>/<uniqueId>' after the prefix, e.g. "/extensions/BABYLON_scene_objects/transformNodes/42".
  2. Check the code that builds the path: log the collection and id values before interpolation and confirm neither is empty/undefined.
  3. Add a guard that skips (rather than converts) refs shorter than prefix + two segments.

Example fix

// before
const path = `${BABYLON_SCENE_OBJECT_MODEL_PREFIX}`; // empty tail
// after
const path = `${BABYLON_SCENE_OBJECT_MODEL_PREFIX}transformNodes/${node.uniqueId}/position`;
Defensive patterns

Strategy: validation

Validate before calling

const tail = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length).split("/").filter((p) => p.length > 0);
if (tail.length < 2) {
  throw new Error(`Pointer needs <collection>/<id>: ${path}`);
}
converter.convert(path);

Type guard

function hasCollectionAndId(path: string): boolean {
  const parts = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length).split("/").filter((p) => p.length > 0);
  return parts.length >= 2;
}

Try / catch

try {
  const info = converter.convert(path);
} catch (e) {
  // prefix-only/empty pointer; drop the reference and continue
}

Prevention

When it happens

Trigger: Calling convert() with exactly BABYLON_SCENE_OBJECT_MODEL_PREFIX, the prefix plus a trailing '/', or an empty/prefix-only string produced by a builder that failed to append the collection and id segments.

Common situations: Path-template interpolation where the collection/id variables were empty or undefined (e.g. `${prefix}${collection}/${id}` with undefined values coerced oddly); truncating a pointer during string processing; a serializer emitting the namespace but no payload.

Related errors


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