{"record":{"id":"245f731aa088d294","repo":"BabylonJS/Babylon.js","slug":"context-camera-orthographic-properties-are-mis","errorCode":null,"errorMessage":"${context}: Camera orthographic properties are missing","messagePattern":"(.+?): Camera orthographic properties are missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":1725,"sourceCode":"\r\n        // glTF cameras look towards the local -Z axis.\r\n        babylonCamera.setTarget(new Vector3(0, 0, -1));\r\n\r\n        switch (camera.type) {\r\n            case CameraType.PERSPECTIVE: {\r\n                const perspective = camera.perspective;\r\n                if (!perspective) {\r\n                    throw new Error(`${context}: Camera perspective properties are missing`);\r\n                }\r\n\r\n                babylonCamera.fov = perspective.yfov;\r\n                babylonCamera.minZ = perspective.znear;\r\n                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","sourceCodeStart":1707,"sourceCodeEnd":1743,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L1707-L1743","documentation":"When loading a glTF camera of type ORTHOGRAPHIC, the loader requires the camera JSON to contain an `orthographic` sub-object with xmag, ymag, znear, zfar. This error means the glTF declares camera.type == \"orthographic\" but the orthographic properties block is absent or null, so the loader cannot construct ortho bounds. It is a strict glTF schema violation guard.","triggerScenarios":"Parsing a glTF asset whose cameras[i] has type \"orthographic\" but no orthographic property (or it is null); typically produced by a broken exporter or hand-edited/trimmed glTF JSON.","commonSituations":"Hand-authored glTF files, assets post-processed by scripts that strip 'unused' properties, buggy exporters emitting the type string without the required data block, or a file corrupted during transmission.","solutions":["Fix the source glTF: add the orthographic block {xmag, ymag, znear, zfar} to the camera.","Re-export the asset from the original DCC tool with correct camera settings.","Change the camera type to \"perspective\" with a perspective block if an ortho camera was not intended.","Pre-validate the glTF with a schema validator (e.g. glTF-Validator) before loading."],"exampleFix":"// before (broken glTF JSON)\n\"cameras\": [{ \"type\": \"orthographic\", \"name\": \"cam\" }]\n// after\n\"cameras\": [{ \"type\": \"orthographic\", \"orthographic\": { \"xmag\": 1, \"ymag\": 1, \"znear\": 0.1, \"zfar\": 100 }, \"name\": \"cam\" }]","handlingStrategy":"validation","validationCode":"const cam = gltf.cameras?.[i];\nif (cam?.type === \"orthographic\" && !cam.orthographic) {\n  throw new Error(`Camera ${cam.name ?? i}: orthographic properties missing`);\n}","typeGuard":"function hasOrtho(cam: { type: string; orthographic?: unknown }): cam is { type: \"orthographic\"; orthographic: { xmag: number; ymag: number; znear: number; zfar: number } } {\n  return cam.type === \"orthographic\" && !!cam.orthographic;\n}","tryCatchPattern":"try { await SceneLoader.ImportAsync(...); } catch (e) {\n  if ((e as Error).message.includes(\"orthographic properties are missing\")) {\n    // fall back to a default camera or skip the asset\n  }\n}","preventionTips":["Run glTF-Validator on every asset in your pipeline (CI step).","Never hand-strip camera property blocks from glTF JSON.","Re-export cameras from the DCC tool rather than editing JSON by hand."],"tags":["gltf","camera","schema-validation","asset-loading"],"backgroundTag":"gltf-schema-validation-failed","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}