BabylonJS/Babylon.js · error
No camera found with uniqueId ${cameraId}.
Error message
No camera found with uniqueId ${cameraId}. What it means
Thrown by the 'screenshot' command when a numeric cameraUniqueId was accepted but scene.cameras contains no camera with that uniqueId. The find on scene.cameras returned undefined, so resolution by explicit id failed.
Source
Thrown at packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts:57
],
executeAsync: async (args) => {
const scene = sceneContext.currentScene;
if (!scene) {
throw new Error("No active scene.");
}
const engine = scene.getEngine();
// Resolve camera: explicit uniqueId, or active/frame-graph camera.
let camera;
if (args.cameraUniqueId) {
const cameraId = parseInt(args.cameraUniqueId, 10);
if (isNaN(cameraId)) {
throw new Error("cameraUniqueId must be a number.");
}
camera = scene.cameras.find((c) => c.uniqueId === cameraId);
if (!camera) {
throw new Error(`No camera found with uniqueId ${cameraId}.`);
}
} else {
camera = scene.frameGraph ? FrameGraphUtils.FindMainCamera(scene.frameGraph) : scene.activeCamera;
}
if (!camera) {
throw new Error("No camera available for screenshot.");
}
const precision = args.precision !== undefined ? Number(args.precision) : 1;
if (!Number.isFinite(precision) || precision <= 0) {
throw new Error("precision must be a finite number greater than 0.");
}
let width: number | undefined;
if (args.width !== undefined) {
width = Number(args.width);
if (!Number.isFinite(width) || width <= 0 || !Number.isInteger(width)) {
View on GitHub (pinned to 0592b347b8)
Solutions
- List the current scene's cameras (query command or scene summary) and use one of their uniqueIds.
- Omit cameraUniqueId to fall back to the active camera or the frame graph's main camera.
- Re-create the camera if the scene was reloaded, then retry with the new uniqueId.
Example fix
// before
await execute("screenshot", { cameraUniqueId: "123" }); // camera disposed
// after
await execute("screenshot", {}); // auto-resolve active camera Defensive patterns
Strategy: validation
Validate before calling
const cam = scene.cameras.find((c) => c.uniqueId === cameraId);
if (!cam) throw new RangeError(`camera uniqueId ${cameraId} not found; valid: ${scene.cameras.map((c) => c.uniqueId).join(", ")}`); Try / catch
try {
await screenshot({ cameraUniqueId: String(id) });
} catch (e) {
if (e instanceof Error && /No camera found with uniqueId/.test(e.message)) {
return screenshot({}); // auto-resolve instead
}
throw e;
} Prevention
- Refresh camera id lists after scene reloads — ids are reassigned.
- Prefer activeCamera or frame-graph main camera unless a specific camera is required.
- Log available camera uniqueIds in your automation for quick recovery.
When it happens
Trigger: Calling screenshot with cameraUniqueId set to a number that matches no camera in the current scene (camera disposed, wrong scene, or id typo).
Common situations: Referencing a camera from a previous scene load after uniqueIds changed; scene hot-reload removed the camera; querying a camera that exists in a different scene instance than sceneContext.currentScene.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- No ${collection.id.replace("query-", "")} found with uniqueI
- cameraUniqueId must be a number.
- No camera available for screenshot.
- Active camera not set
- No camera defined
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/d054bd3a9d6db099.
Report an issue: GitHub.