{"record":{"id":"8bc41fa2b38a4344","repo":"mrdoob/three.js","slug":"three-batchedmesh-all-geometries-must-consistentl","errorCode":null,"errorMessage":"THREE.BatchedMesh: All geometries must consistently have \"index\".","messagePattern":"THREE\\.BatchedMesh: All geometries must consistently have \"index\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/objects/BatchedMesh.js","lineNumber":424,"sourceCode":"\n\t\t\t\tgeometry.setIndex( new BufferAttribute( indexArray, 1 ) );\n\n\t\t\t}\n\n\t\t\tthis._geometryInitialized = true;\n\n\t\t}\n\n\t}\n\n\t// Make sure the geometry is compatible with the existing combined geometry attributes\n\t_validateGeometry( geometry ) {\n\n\t\t// check to ensure the geometries are using consistent attributes and indices\n\t\tconst batchGeometry = this.geometry;\n\t\tif ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {\n\n\t\t\tthrow new Error( 'THREE.BatchedMesh: All geometries must consistently have \"index\".' );\n\n\t\t}\n\n\t\tfor ( const attributeName in batchGeometry.attributes ) {\n\n\t\t\tif ( ! geometry.hasAttribute( attributeName ) ) {\n\n\t\t\t\tthrow new Error( `THREE.BatchedMesh: Added geometry missing \"${ attributeName }\". All geometries must have consistent attributes.` );\n\n\t\t\t}\n\n\t\t\tconst srcAttribute = geometry.getAttribute( attributeName );\n\t\t\tconst dstAttribute = batchGeometry.getAttribute( attributeName );\n\t\t\tif ( srcAttribute.itemSize !== dstAttribute.itemSize || srcAttribute.normalized !== dstAttribute.normalized ) {\n\n\t\t\t\tthrow new Error( 'THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.' );\n\n\t\t\t}","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/objects/BatchedMesh.js#L406-L442","documentation":"Thrown by BatchedMesh._validateGeometry() when the added geometry's indexed/non-indexed status differs from the batch's combined geometry. The check is `Boolean(geometry.getIndex()) !== Boolean(batchGeometry.getIndex())` — all geometries in a batch must consistently use an index buffer or consistently omit one.","triggerScenarios":"Mixing indexed geometries (e.g. BoxGeometry, PlaneGeometry) with non-indexed ones (e.g. some custom BufferGeometries) in the same BatchedMesh; adding a geometry after calling addGeometry with a differently-indexed first geometry.","commonSituations":"Batching a heterogeneous set of geometries; loading geometries from different loaders where some are indexed and some are not; converting a geometry to non-indexed (`geometry.toNonIndexed()`) for some but not all batch members.","solutions":["Make all geometries consistent: call `.toNonIndexed()` on every indexed geometry, or call `.setIndex()` to index every non-indexed one.","Decide the batch's convention with the first addGeometry call, then ensure every subsequent geometry matches.","Group indexed and non-indexed geometries into separate BatchedMesh instances."],"exampleFix":"// before\nbatch.addGeometry( indexedBox );\nbatch.addGeometry( nonIndexedGeom );\n\n// after\nbatch.addGeometry( indexedBox );\nbatch.addGeometry( nonIndexedGeom.toNonIndexed ? nonIndexedGeom : nonIndexedGeom );\n// or normalize all to indexed/non-indexed before adding","handlingStrategy":"validation","validationCode":"function assertCompatibleIndexing( batch, geometry ) {\n  if ( Boolean( geometry.getIndex() ) !== Boolean( batch.geometry.getIndex() ) ) {\n    throw new Error( 'Geometry indexing does not match the batch.' );\n  }\n}","typeGuard":"const matchesBatchIndexing = ( batch, geometry ) => Boolean( geometry.getIndex() ) === Boolean( batch.geometry.getIndex() );","tryCatchPattern":null,"preventionTips":["Normalize all geometries to indexed or all to non-indexed before batching.","Establish the batch convention with the first addGeometry call.","Use separate BatchedMesh instances for indexed vs non-indexed sets."],"tags":["batched-mesh","geometry","indexed","validation"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}