BabylonJS/Babylon.js · error · Error
${context}: Camera orthographic properties are missing
Error message
${context}: Camera orthographic properties are missing What it means
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.
Source
Thrown at packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts:1725
// glTF cameras look towards the local -Z axis.
babylonCamera.setTarget(new Vector3(0, 0, -1));
switch (camera.type) {
case CameraType.PERSPECTIVE: {
const perspective = camera.perspective;
if (!perspective) {
throw new Error(`${context}: Camera perspective properties are missing`);
}
babylonCamera.fov = perspective.yfov;
babylonCamera.minZ = perspective.znear;
babylonCamera.maxZ = perspective.zfar || 0;
break;
}
case CameraType.ORTHOGRAPHIC: {
if (!camera.orthographic) {
throw new Error(`${context}: Camera orthographic properties are missing`);
}
babylonCamera.mode = Camera.ORTHOGRAPHIC_CAMERA;
babylonCamera.orthoLeft = -camera.orthographic.xmag;
babylonCamera.orthoRight = camera.orthographic.xmag;
babylonCamera.orthoBottom = -camera.orthographic.ymag;
babylonCamera.orthoTop = camera.orthographic.ymag;
babylonCamera.minZ = camera.orthographic.znear;
babylonCamera.maxZ = camera.orthographic.zfar;
break;
}
default: {
throw new Error(`${context}: Invalid camera type (${camera.type})`);
}
}
GLTFLoader.AddPointerMetadata(babylonCamera, context);
this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera);
View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before (broken glTF JSON)
"cameras": [{ "type": "orthographic", "name": "cam" }]
// after
"cameras": [{ "type": "orthographic", "orthographic": { "xmag": 1, "ymag": 1, "znear": 0.1, "zfar": 100 }, "name": "cam" }] Defensive patterns
Strategy: validation
Validate before calling
const cam = gltf.cameras?.[i];
if (cam?.type === "orthographic" && !cam.orthographic) {
throw new Error(`Camera ${cam.name ?? i}: orthographic properties missing`);
} Type guard
function hasOrtho(cam: { type: string; orthographic?: unknown }): cam is { type: "orthographic"; orthographic: { xmag: number; ymag: number; znear: number; zfar: number } } {
return cam.type === "orthographic" && !!cam.orthographic;
} Try / catch
try { await SceneLoader.ImportAsync(...); } catch (e) {
if ((e as Error).message.includes("orthographic properties are missing")) {
// fall back to a default camera or skip the asset
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${context}: Invalid camera type (${camera.type})
- ${context}/type: Invalid value ${accessor.type}
- ${context}: Camera perspective properties are missing
- ${context}/target/path: Invalid value (${channel.target.path
- ${context}/target/path: Could not find interpolation propert
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/245f731aa088d294.
Report an issue: GitHub.