mrdoob/three.js · error
THREE.NodeBuilder: Type '${type}' not found in generate cons
Error message
THREE.NodeBuilder: Type '${type}' not found in generate constant attempt. What it means
Thrown by NodeBuilder.generateConst() when no branch handles the requested `type`/`value` pair. Scalar types (float/int/uint/bool/color) return earlier; the remaining branches cover typeLength 2, 3, 4 (non-mat2), matrices, and >4. The throw is reached for an unknown/unregistered type (typeLength 0), or for `mat2` with a non-matrix value.
Source
Thrown at src/nodes/core/NodeBuilder.js:1457
} else if ( typeLength === 3 ) {
return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) } )`;
} else if ( typeLength === 4 && type !== 'mat2' ) {
return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) }, ${ generateConst( value.w ) } )`;
} else if ( typeLength >= 4 && value && ( value.isMatrix2 || value.isMatrix3 || value.isMatrix4 ) ) {
return `${ this.getType( type ) }( ${ value.elements.map( generateConst ).join( ', ' ) } )`;
} else if ( typeLength > 4 ) {
return `${ this.getType( type ) }()`;
}
throw new Error( `THREE.NodeBuilder: Type '${type}' not found in generate constant attempt.` );
}
/**
* It might be necessary to convert certain data types to different ones
* so this method can be used to hide the conversion.
*
* @param {string} type - The type.
* @return {string} The updated type.
*/
getType( type ) {
if ( type === 'color' ) return 'vec3';
return type;
}
View on GitHub (pinned to da05705fa3)
Solutions
- Ensure the node's getNodeType()/nodeType returns a built-in type string the builder recognizes (float, vec2/3/4, mat2/3/4, etc.).
- If the value is a matrix, pass an actual Matrix2/3/4 instance rather than a plain object.
- Register/handle the custom type, or convert the node to emit a recognized type before const generation.
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_TYPES = new Set( [ 'float','int','uint','bool','color','vec2','vec3','vec4','ivec2','ivec3','ivec4','uvec2','uvec3','uvec4','mat2','mat3','mat4' ] );
function assertKnownType( type ) {
if ( ! KNOWN_TYPES.has( type ) ) throw new TypeError( `generateConst: unknown type '${ type }'` );
} Type guard
const isKnownScalarType = ( t ) => typeof t === 'string' && /^[iu]?(vec[234]|float|int|uint|bool|color|mat[234])$/.test( t );
Prevention
- Ensure custom nodes return a recognized primitive type from getNodeType().
- Pass Matrix2/3/4 instances, not plain objects, for matrix constants.
- Validate inferred types during node-graph construction, not at render time.
When it happens
Trigger: A node reports a custom/unknown type string that NodeBuilder.getTypeLength() cannot resolve; generating a constant for a struct or array type; passing a plain object instead of a Matrix2/3/4 when the type is a matrix; a node returning an empty/undefined type from getNodeType().
Common situations: Authoring a custom node that returns a non-standard type; type inference failing because getNodeType() returns null/undefined; a uniform or attribute typed with a string the builder does not recognize; corrupt node graph after partial refactors.
Related errors
- THREE.NodeBuilder: Invalid node chaining!
- THREE.NodeBuilder: Invalid active stack removal.
- THREE.NodeBuilder: Uniform "${ type }" not implemented.
- THREE.NodeUtils: Unsupported type: ${type}
AI-assisted analysis of mrdoob/three.js@da05705fa3 (2026-08-12).
Data as JSON: /api/errors/425b9c96f5b50726.
Report an issue: GitHub.