{"record":{"id":"0734f5142ac0de5a","repo":"BabylonJS/Babylon.js","slug":"context-camera-perspective-properties-are-miss","errorCode":null,"errorMessage":"${context}: Camera perspective properties are missing","messagePattern":"(.+?): Camera perspective properties are missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":1715,"sourceCode":"\r\n        const promises = new Array<Promise<unknown>>();\r\n\r\n        this.logOpen(`${context} ${camera.name || \"\"}`);\r\n\r\n        this._babylonScene._blockEntityCollection = !!this._assetContainer;\r\n        const babylonCamera = new FreeCamera(camera.name || `camera${camera.index}`, Vector3.Zero(), this._babylonScene, false);\r\n        babylonCamera._parentContainer = this._assetContainer;\r\n        this._babylonScene._blockEntityCollection = false;\r\n        camera._babylonCamera = babylonCamera;\r\n\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","sourceCodeStart":1697,"sourceCodeEnd":1733,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L1697-L1733","documentation":"For a camera of type 'perspective', the glTF spec requires a 'perspective' object (with yfov and znear). When _loadCameraAsync finds camera.perspective missing for a PERSPECTIVE camera, it throws because fov/near/far cannot be populated.","triggerScenarios":"Loading a glTF with a camera entry like { \"type\": \"perspective\" } but no perspective sub-object, or a perspective object omitted by a buggy exporter.","commonSituations":"Hand-edited glTF files; exporters that write the type but drop invalid/missing camera properties; truncated or corrupted asset conversions.","solutions":["Fix the asset so the camera includes a perspective object with yfov, znear (and optionally zfar)","Re-export the scene from the DCC tool and validate the camera definition with glTF-Validator","Edit the glTF JSON to add the missing perspective object or change the camera type to 'orthographic' if that was intended"],"exampleFix":"// before (in .gltf)\n// { \"cameras\": [ { \"type\": \"perspective\" } ] }\n// after\n// { \"cameras\": [ { \"type\": \"perspective\", \"perspective\": { \"yfov\": 0.8, \"znear\": 0.1, \"zfar\": 1000 } } ] }","handlingStrategy":"validation","validationCode":"// Check perspective cameras have a perspective object before loading\nconst badCams = (gltf.cameras ?? []).filter(c => c.type === \"perspective\" && !c.perspective);\nif (badCams.length) throw new Error(`Perspective cameras missing 'perspective': ${badCams.length}`);","typeGuard":"function hasPerspectiveProps(camera) {\n  return camera.type !== \"perspective\" ||\n    (camera.perspective != null &&\n      typeof camera.perspective.yfov === \"number\" &&\n      typeof camera.perspective.znear === \"number\");\n}","tryCatchPattern":"try {\n  await loader.loadAsync(url);\n} catch (e) {\n  if (e.message.includes(\"Camera perspective properties are missing\")) {\n    console.error(\"Add a perspective object (yfov, znear) to the camera or re-export\");\n  } else throw e;\n}","preventionTips":["Validate camera definitions with glTF-Validator before shipping assets","Check exported glTF JSON when cameras render with default properties","Keep DCC export camera settings enabled and complete"],"tags":["gltf","camera","malformed-asset"],"backgroundTag":"gltf-invalid-asset-structure","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}