BabylonJS/Babylon.js · error

BabylonScenePathToObjectConverter: path "${path}" does not s

Error message

BabylonScenePathToObjectConverter: path "${path}" does not start with the expected prefix "${BABYLON_SCENE_OBJECT_MODEL_PREFIX}".

What it means

BabylonScenePathToObjectConverter.convert() resolves a JSON Pointer referring to a Babylon scene object into an object-info pair for glTF extensions (e.g. BABYLON_scene_objects animation/interpolation targets). It requires every path to begin with the fixed namespace prefix BABYLON_SCENE_OBJECT_MODEL_PREFIX; the library throws this error to fail fast on pointers that were not produced by the Babylon scene-object model. Without this check, an unrelated pointer could be silently misparsed into the wrong collection or instance.

Source

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

 * - `/extensions/BABYLON_scene_objects/meshes/17/visible`
 *
 * Composite path dispatchers (see {@link CompositePathToObjectConverter})
 * route paths starting with the prefix here; everything else continues to be
 * resolved by the standard glTF converter.
 */
export class BabylonScenePathToObjectConverter implements IPathToObjectConverter<IObjectAccessor> {
    public constructor(
        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") {

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Prefix the path with BABYLON_SCENE_OBJECT_MODEL_PREFIX before calling convert(), or obtain the path from the extension's own reference-building APIs instead of hand-writing it.
  2. Verify you are using BabylonScenePathToObjectConverter only for BABYLON_scene_objects pointers; use gltfPathToObjectConverter for generic glTF paths.
  3. Log the offending path and compare it character-by-character against the exported prefix constant (check for missing leading slash or misspelled extension name).

Example fix

// before
converter.convert("/transformNodes/42/position");
// after
converter.convert(`${BABYLON_SCENE_OBJECT_MODEL_PREFIX}transformNodes/42/position`);
Defensive patterns

Strategy: validation

Validate before calling

if (!path.startsWith(BABYLON_SCENE_OBJECT_MODEL_PREFIX)) {
  throw new Error(`Refusing to convert non-Babylon pointer: ${path}`);
}
converter.convert(path);

Type guard

function isBabylonScenePath(path: string): boolean {
  return typeof path === "string" && path.startsWith(BABYLON_SCENE_OBJECT_MODEL_PREFIX);
}

Try / catch

try {
  const info = converter.convert(path);
} catch (e) {
  // path lacks the Babylon prefix; log and skip this reference
}

Prevention

When it happens

Trigger: Calling convert() with a path such as "/nodes/0" or "/meshes/1/translation" instead of one beginning with the Babylon scene-objects prefix (e.g. "/extensions/BABYLON_scene_objects/..."); passing a pointer harvested from a non-Babylon glTF extension or a hand-written string.

Common situations: Mixing up the generic gltfPathToObjectConverter (which accepts any /-separated path) with the Babylon-specific converter; copying a JSON Pointer from another extension (KHR_animation_pointer etc.); typos or wrong casing in the prefix; building paths by string concatenation that drops the namespace segment.

Related errors


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