{"record":{"id":"3bc2907ebbd012bb","repo":"mrdoob/three.js","slug":"three-frustum-setfromprojectionmatrix-invalid-c","errorCode":null,"errorMessage":"THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ${coordinateSystem}","messagePattern":"THREE\\.Frustum\\.setFromProjectionMatrix\\(\\): Invalid coordinate system: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/math/Frustum.js","lineNumber":128,"sourceCode":"\n\t\t\tplanes[ 4 ].setComponents( me2, me6, me10, me14 ).normalize(); // far\n\t\t\tplanes[ 5 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // near\n\n\t\t} else {\n\n\t\t\tplanes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // far\n\n\t\t\tif ( coordinateSystem === WebGLCoordinateSystem ) {\n\n\t\t\t\tplanes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize(); // near\n\n\t\t\t} else if ( coordinateSystem === WebGPUCoordinateSystem ) {\n\n\t\t\t\tplanes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize(); // near\n\n\t\t\t} else {\n\n\t\t\t\tthrow new Error( 'THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ' + coordinateSystem );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\t/**\n\t * Returns `true` if the 3D object's bounding sphere is intersecting this frustum.\n\t *\n\t * Note that the 3D object must have a geometry so that the bounding sphere can be calculated.\n\t *\n\t * @param {Object3D} object - The 3D object to test.\n\t * @return {boolean} Whether the 3D object's bounding sphere is intersecting this frustum or not.\n\t */\n\tintersectsObject( object ) {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/math/Frustum.js#L110-L146","documentation":"Thrown by Frustum.setFromProjectionMatrix() when the coordinateSystem argument is neither WebGLCoordinateSystem nor WebGPUCoordinateSystem. The near plane is computed differently for each (WebGL uses the row-sum plane, WebGPU uses the third row directly) because the two systems use different clip-space z ranges; an unknown system has no valid near-plane formula.","triggerScenarios":"Calling frustum.setFromProjectionMatrix(matrix, coordinateSystem) with a missing, null, or custom coordinateSystem value. Also indirectly when library internals call it with a renderer.coordinateSystem that is non-standard.","commonSituations":"Calling setFromProjectionMatrix without the second argument (it is required). Passing camera.coordinateSystem before a renderer has set it. Custom projection pipelines that introduce a third convention. Stale references after switching renderers.","solutions":["Always pass an explicit, valid coordinateSystem as the second argument, matching the renderer that produced the projection matrix.","If deriving from a renderer, use renderer.coordinateSystem (THREE.WebGLCoordinateSystem or THREE.WebGPUCoordinateSystem).","For manual frustum extraction, pass THREE.WebGLCoordinateSystem unless you knowingly use the WebGPU [0,1] depth convention.","Ensure camera.coordinateSystem is initialized before any code that builds a frustum from its matrix."],"exampleFix":"// before: second argument missing or invalid\nfrustum.setFromProjectionMatrix(camera.projectionMatrix);\n\n// after: pass a valid coordinate system\nfrustum.setFromProjectionMatrix(camera.projectionMatrix, THREE.WebGLCoordinateSystem);","handlingStrategy":"validation","validationCode":"import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from 'three';\n\nfunction buildFrustum(projectionMatrix, coordinateSystem) {\n  if (coordinateSystem !== WebGLCoordinateSystem && coordinateSystem !== WebGPUCoordinateSystem) {\n    throw new Error('coordinateSystem must be WebGL or WebGPU');\n  }\n  return new THREE.Frustum().setFromProjectionMatrix(projectionMatrix, coordinateSystem);\n}","typeGuard":"function isValidCoordinateSystem(cs) {\n  return cs === THREE.WebGLCoordinateSystem || cs === THREE.WebGPUCoordinateSystem;\n}","tryCatchPattern":null,"preventionTips":["Always pass the coordinateSystem argument explicitly.","Source it from renderer.coordinateSystem rather than hardcoding guesses.","Initialize camera.coordinateSystem before extracting frustums from its matrix."],"tags":["threejs","coordinate-system","frustum","matrix","culling"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}