{"record":{"id":"5b51bf4fe97ac691","repo":"BabylonJS/Babylon.js","slug":"context-invalid-camera-type-camera-type","errorCode":null,"errorMessage":"${context}: Invalid camera type (${camera.type})","messagePattern":"(.+?): Invalid camera type \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":1738,"sourceCode":"                babylonCamera.maxZ = perspective.zfar || 0;\r\n                break;\r\n            }\r\n            case CameraType.ORTHOGRAPHIC: {\r\n                if (!camera.orthographic) {\r\n                    throw new Error(`${context}: Camera orthographic properties are missing`);\r\n                }\r\n\r\n                babylonCamera.mode = Camera.ORTHOGRAPHIC_CAMERA;\r\n                babylonCamera.orthoLeft = -camera.orthographic.xmag;\r\n                babylonCamera.orthoRight = camera.orthographic.xmag;\r\n                babylonCamera.orthoBottom = -camera.orthographic.ymag;\r\n                babylonCamera.orthoTop = camera.orthographic.ymag;\r\n                babylonCamera.minZ = camera.orthographic.znear;\r\n                babylonCamera.maxZ = camera.orthographic.zfar;\r\n                break;\r\n            }\r\n            default: {\r\n                throw new Error(`${context}: Invalid camera type (${camera.type})`);\r\n            }\r\n        }\r\n\r\n        GLTFLoader.AddPointerMetadata(babylonCamera, context);\r\n        this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera);\r\n        assign(babylonCamera);\r\n\r\n        this.logClose();\r\n\r\n        return Promise.all(promises).then(() => {\r\n            return babylonCamera;\r\n        });\r\n    }\r\n\r\n    private _loadAnimationsAsync(): Promise<void> {\r\n        this._parent._startPerformanceCounter(\"Load animations\");\r\n\r\n        const animations = this._gltf.animations;\r","sourceCodeStart":1720,"sourceCodeEnd":1756,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L1720-L1756","documentation":"The glTF camera loader only supports \"perspective\" and \"orthographic\" camera types per the glTF 2.0 spec. When camera.type holds any other value, the switch falls to the default branch and throws this error. It protects downstream camera-construction code from unknown types.","triggerScenarios":"Loading a glTF where cameras[i].type is not \"perspective\" or \"orthographic\" — e.g. an empty string, a typo like \"ortho\", or a future/custom type added by a non-conformant exporter.","commonSituations":"Hand-edited glTF files, custom exporter extensions that misuse the type field, corrupted JSON, or assets generated by tools that predate glTF 2.0 camera conventions.","solutions":["Set camera.type to \"perspective\" or \"orthographic\" in the glTF JSON.","Re-export the asset with a spec-compliant exporter.","Remove or replace the invalid camera entry if it is not needed.","Validate the asset with glTF-Validator before loading."],"exampleFix":"// before\n\"cameras\": [{ \"type\": \"ortho\", \"orthographic\": { \"xmag\": 1, \"ymag\": 1, \"znear\": 0.1, \"zfar\": 100 } }]\n// after\n\"cameras\": [{ \"type\": \"orthographic\", \"orthographic\": { \"xmag\": 1, \"ymag\": 1, \"znear\": 0.1, \"zfar\": 100 } }]","handlingStrategy":"validation","validationCode":"for (const cam of gltf.cameras ?? []) {\n  if (cam.type !== \"perspective\" && cam.type !== \"orthographic\") {\n    throw new Error(`Invalid camera type: ${cam.type}`);\n  }\n}","typeGuard":"function isValidCameraType(t: string): t is \"perspective\" | \"orthographic\" {\n  return t === \"perspective\" || t === \"orthographic\";\n}","tryCatchPattern":"try { await loadAsset(); } catch (e) {\n  if (/Invalid camera type/.test((e as Error).message)) {\n    console.warn(\"Skipping asset with non-spec camera type\");\n  }\n}","preventionTips":["Validate assets with glTF-Validator before shipping.","Use only spec-compliant exporters.","Reject unknown camera types at asset-ingestion time."],"tags":["gltf","camera","enum-validation","asset-loading"],"backgroundTag":"invalid-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}