mrdoob/three.js · error · Error
THREE.BatchedMesh: Added geometry missing "${ attributeName
Error message
THREE.BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes. What it means
Thrown by BatchedMesh._validateGeometry() when an added geometry is missing an attribute that the batch's combined geometry already has. The loop iterates the batch's existing attributes and requires every new geometry to provide each one, so all geometries must share the same attribute set.
Source
Thrown at src/objects/BatchedMesh.js:432
}
// Make sure the geometry is compatible with the existing combined geometry attributes
_validateGeometry( geometry ) {
// check to ensure the geometries are using consistent attributes and indices
const batchGeometry = this.geometry;
if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
throw new Error( 'THREE.BatchedMesh: All geometries must consistently have "index".' );
}
for ( const attributeName in batchGeometry.attributes ) {
if ( ! geometry.hasAttribute( attributeName ) ) {
throw new Error( `THREE.BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
}
const srcAttribute = geometry.getAttribute( attributeName );
const dstAttribute = batchGeometry.getAttribute( attributeName );
if ( srcAttribute.itemSize !== dstAttribute.itemSize || srcAttribute.normalized !== dstAttribute.normalized ) {
throw new Error( 'THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.' );
}
}
}
/**
* Validates the instance defined by the given ID.
*View on GitHub (pinned to da05705fa3)
Solutions
- Ensure every geometry has the same set of attributes as the first geometry added to the batch.
- Add missing attributes (e.g. generate uvs/normals) before adding the geometry.
- Remove extra attributes from the batch's first geometry if you do not need them across all members.
Example fix
// before batch.addGeometry( geomWithColor ); batch.addGeometry( geomWithoutColor ); // missing 'color' // after geomWithoutColor.setAttribute( 'color', new Float32BufferAttribute( new Float32Array( count * 3 ), 3 ) ); batch.addGeometry( geomWithoutColor );
Defensive patterns
Strategy: validation
Validate before calling
function assertHasBatchAttributes( batch, geometry ) {
for ( const name in batch.geometry.attributes ) {
if ( ! geometry.hasAttribute( name ) ) {
throw new Error( `Geometry missing attribute '${ name }' required by the batch.` );
}
}
} Type guard
const hasAllBatchAttributes = ( batch, geometry ) => Object.keys( batch.geometry.attributes ).every( ( n ) => geometry.hasAttribute( n ) );
Prevention
- Ensure every geometry shares the batch's full attribute set.
- Generate missing uvs/normals/colors before adding.
- Trim unneeded attributes from the first geometry if not all members have them.
When it happens
Trigger: Adding a geometry that lacks 'uv' or 'normal' or 'color' to a batch whose first geometry had those attributes; mixing geometries with different attribute sets (e.g. a BoxGeometry with uv into a batch started with a geometry that also had color).
Common situations: Batching geometries from different sources (procedural vs. loaded) with inconsistent attributes; adding a geometry that was stripped of some attributes for optimization; forgetting to add a color/uv attribute to a custom geometry.
Related errors
- THREE.BatchedMesh: All attributes must have a consistent ite
- THREE.BatchedMesh: All geometries must consistently have "in
- THREE.BatchedMesh: Invalid geometryId ${geometryId}. Geometr
- THREE.BatchedMesh: Invalid instanceId ${instanceId}. Instanc
- invalid length
AI-assisted analysis of mrdoob/three.js@da05705fa3 (2026-08-12).
Data as JSON: /api/errors/df5ac455b790b434.
Report an issue: GitHub.