{"record":{"id":"d054bd3a9d6db099","repo":"BabylonJS/Babylon.js","slug":"no-camera-found-with-uniqueid-cameraid","errorCode":null,"errorMessage":"No camera found with uniqueId ${cameraId}.","messagePattern":"No camera found with uniqueId (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts","lineNumber":57,"sourceCode":"            ],\r\n            executeAsync: async (args) => {\r\n                const scene = sceneContext.currentScene;\r\n                if (!scene) {\r\n                    throw new Error(\"No active scene.\");\r\n                }\r\n\r\n                const engine = scene.getEngine();\r\n\r\n                // Resolve camera: explicit uniqueId, or active/frame-graph camera.\r\n                let camera;\r\n                if (args.cameraUniqueId) {\r\n                    const cameraId = parseInt(args.cameraUniqueId, 10);\r\n                    if (isNaN(cameraId)) {\r\n                        throw new Error(\"cameraUniqueId must be a number.\");\r\n                    }\r\n                    camera = scene.cameras.find((c) => c.uniqueId === cameraId);\r\n                    if (!camera) {\r\n                        throw new Error(`No camera found with uniqueId ${cameraId}.`);\r\n                    }\r\n                } else {\r\n                    camera = scene.frameGraph ? FrameGraphUtils.FindMainCamera(scene.frameGraph) : scene.activeCamera;\r\n                }\r\n\r\n                if (!camera) {\r\n                    throw new Error(\"No camera available for screenshot.\");\r\n                }\r\n\r\n                const precision = args.precision !== undefined ? Number(args.precision) : 1;\r\n                if (!Number.isFinite(precision) || precision <= 0) {\r\n                    throw new Error(\"precision must be a finite number greater than 0.\");\r\n                }\r\n\r\n                let width: number | undefined;\r\n                if (args.width !== undefined) {\r\n                    width = Number(args.width);\r\n                    if (!Number.isFinite(width) || width <= 0 || !Number.isInteger(width)) {\r","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts#L39-L75","documentation":"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.","triggerScenarios":"Calling screenshot with cameraUniqueId set to a number that matches no camera in the current scene (camera disposed, wrong scene, or id typo).","commonSituations":"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.","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."],"exampleFix":"// before\nawait execute(\"screenshot\", { cameraUniqueId: \"123\" }); // camera disposed\n// after\nawait execute(\"screenshot\", {}); // auto-resolve active camera","handlingStrategy":"validation","validationCode":"const cam = scene.cameras.find((c) => c.uniqueId === cameraId);\nif (!cam) throw new RangeError(`camera uniqueId ${cameraId} not found; valid: ${scene.cameras.map((c) => c.uniqueId).join(\", \")}`);","typeGuard":null,"tryCatchPattern":"try {\n  await screenshot({ cameraUniqueId: String(id) });\n} catch (e) {\n  if (e instanceof Error && /No camera found with uniqueId/.test(e.message)) {\n    return screenshot({}); // auto-resolve instead\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["cli","camera","entity-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}