BabylonJS/Babylon.js · error

BabylonScenePathToObjectConverter: no ${collectionName} inst

Error message

BabylonScenePathToObjectConverter: no ${collectionName} instance found with uniqueId ${uniqueId} (path "${path}").

What it means

After validating the id format, convert() looks up the live instance by uniqueId within the named collection via _lookupInstanceByUniqueId. If no instance with that id currently exists in the collection, the library throws — a valid-looking path can still dangle if the target object was disposed, not yet created, or belongs to a different scene/collection.

Source

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

        }

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

        // parseInt would accept "12abc" as 12; require an all-digits id so a malformed path fails
        // loudly instead of binding to the wrong instance.
        if (!/^\d+$/.test(parts[1])) {
            throw new Error(`BabylonScenePathToObjectConverter: invalid uniqueId "${parts[1]}" in path "${path}".`);
        }
        const uniqueId = parseInt(parts[1], 10);
        if (!Number.isFinite(uniqueId) || uniqueId < 0) {
            throw new Error(`BabylonScenePathToObjectConverter: invalid uniqueId "${parts[1]}" in path "${path}".`);
        }

        const instance = this._lookupInstanceByUniqueId(collectionName, uniqueId);
        if (!instance) {
            throw new Error(`BabylonScenePathToObjectConverter: no ${collectionName} instance found with uniqueId ${uniqueId} (path "${path}").`);
        }

        // No property after the id → the ref itself is just a handle to the instance.
        // The accessor's `get` and `getTarget` both return the instance.
        if (parts.length === 2) {
            return {
                object: instance,
                info: this._buildIdentityAccessor(instance),
            };
        }

        // Walk the leaf descriptors for the requested property path. We keep this
        // very simple right now: only one segment after the id is supported, which
        // covers every property the initial leaves expose. Nested paths can be
        // added later by extending the walker.
        if (parts.length > 3) {
            throw new Error(`BabylonScenePathToObjectConverter: nested property paths are not yet supported (path "${path}").`);
        }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Re-derive the pointer from the live object right before converting (use instance.uniqueId of the current scene) rather than reusing a stored path.
  2. Check that the target object exists (e.g. scene.getTransformNodeByUniqueId or the collection's lookup) before calling convert(), and skip/remove dead references.
  3. If pointers must persist, store stable identifiers (names/glTF indices) and rebuild uniqueId-based paths at load time after the scene is fully constructed.
  4. Ensure the resolver runs after the glTF loader has finished creating all scene objects.

Example fix

// before
converter.convert(storedPath); // id from a previous session
// after
const path = `${BABYLON_SCENE_OBJECT_MODEL_PREFIX}transformNodes/${currentNode.uniqueId}/position`;
converter.convert(path);
Defensive patterns

Strategy: try-catch

Validate before calling

const node = scene.getTransformNodeByUniqueId(uniqueId);
if (!node) {
  // skip stale pointer instead of converting
  return null;
}
converter.convert(`${BABYLON_SCENE_OBJECT_MODEL_PREFIX}transformNodes/${uniqueId}/position`);

Type guard

null

Try / catch

try {
  const info = converter.convert(path);
} catch (e) {
  if (String(e).includes("no ")) {
    // dangling instance reference: rebuild the path from live objects or drop it
  }
}

Prevention

When it happens

Trigger: convert() called with a well-formed path like ".../transformNodes/42/position" where no TransformNode with uniqueId 42 exists: the node was disposed before the pointer was resolved, the pointer was serialized from a previous scene/run, the id belongs to another collection type, or resolution happens before the loader finished instantiating objects.

Common situations: Storing JSON Pointers persistently across scene reloads (uniqueIds are per-session, not stable across runs); resolving animation/extension targets during loading before all nodes exist; disposing objects while async processing still references them.

Related errors


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