{"record":{"id":"ddaf89d9ffbe2900","repo":"mrdoob/three.js","slug":"three-matrix4-makeperspective-invalid-coordinat","errorCode":null,"errorMessage":"THREE.Matrix4.makePerspective(): Invalid coordinate system: ${coordinateSystem}","messagePattern":"THREE\\.Matrix4\\.makePerspective\\(\\): Invalid coordinate system: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/math/Matrix4.js","lineNumber":1178,"sourceCode":"\n\t\t\tc = near / ( far - near );\n\t\t\td = ( far * near ) / ( far - near );\n\n\t\t} else {\n\n\t\t\tif ( coordinateSystem === WebGLCoordinateSystem ) {\n\n\t\t\t\tc = - ( far + near ) / ( far - near );\n\t\t\t\td = ( - 2 * far * near ) / ( far - near );\n\n\t\t\t} else if ( coordinateSystem === WebGPUCoordinateSystem ) {\n\n\t\t\t\tc = - far / ( far - near );\n\t\t\t\td = ( - far * near ) / ( far - near );\n\n\t\t\t} else {\n\n\t\t\t\tthrow new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );\n\n\t\t\t}\n\n\t\t}\n\n\t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a; \tte[ 12 ] = 0;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b; \tte[ 13 ] = 0;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c; \tte[ 14 ] = d;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = - 1;\tte[ 15 ] = 0;\n\n\t\treturn this;\n\n\t}\n\n\t/**\n\t * Creates a orthographic projection matrix. This is used internally by\n\t * {@link OrthographicCamera#updateProjectionMatrix}.\n","sourceCodeStart":1160,"sourceCodeEnd":1196,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/math/Matrix4.js#L1160-L1196","documentation":"Thrown by Matrix4.makePerspective() when the coordinateSystem argument is neither WebGLCoordinateSystem nor WebGPUCoordinateSystem. The depth coefficients c and d differ between the two (WebGL uses a symmetric -1..1 z remap, WebGPU uses a 0..1 z remap); an unrecognized system has no valid projection formula, so building the matrix is aborted.","triggerScenarios":"Calling matrix.makePerspective(left, right, top, bottom, near, far, coordinateSystem) with a missing/null/custom coordinateSystem. Also when camera internals build a perspective matrix from a non-standard coordinateSystem field.","commonSituations":"Constructing a custom perspective matrix without specifying the coordinate system. Passing the renderer's coordinateSystem before it is initialized. Mixing a WebGPU depth convention with a WebGL-flagged matrix build. Typo'd or undefined constant reference.","solutions":["Pass a valid coordinate system as the last argument: THREE.WebGLCoordinateSystem or THREE.WebGPUCoordinateSystem.","Derive it from the active renderer: renderer.coordinateSystem.","Ensure the referenced constant is imported and defined (not undefined).","Match the system to the renderer that will consume the projection matrix."],"exampleFix":"// before: coordinateSystem omitted/undefined\nproj.makePerspective(-1, 1, 1, -1, 0.1, 100, undefined);\n\n// after: explicit valid system\nproj.makePerspective(-1, 1, 1, -1, 0.1, 100, THREE.WebGLCoordinateSystem);","handlingStrategy":"validation","validationCode":"import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from 'three';\n\nfunction makePerspectiveSafe(m, l, r, t, b, near, far, coordinateSystem) {\n  if (coordinateSystem !== WebGLCoordinateSystem && coordinateSystem !== WebGPUCoordinateSystem) {\n    throw new Error('coordinateSystem must be WebGL or WebGPU');\n  }\n  return m.makePerspective(l, r, t, b, near, far, coordinateSystem);\n}","typeGuard":"function isValidCoordinateSystem(cs) {\n  return cs === THREE.WebGLCoordinateSystem || cs === THREE.WebGPUCoordinateSystem;\n}","tryCatchPattern":null,"preventionTips":["Always pass the coordinateSystem argument; do not rely on a default.","Source it from renderer.coordinateSystem to match the depth convention.","Confirm the constant import resolves to a number (not undefined)."],"tags":["threejs","coordinate-system","matrix4","projection","perspective"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}