{"record":{"id":"425b9c96f5b50726","repo":"mrdoob/three.js","slug":"three-nodebuilder-type-type-not-found-in-gen","errorCode":null,"errorMessage":"THREE.NodeBuilder: Type '${type}' not found in generate constant attempt.","messagePattern":"THREE\\.NodeBuilder: Type '(.+?)' not found in generate constant attempt\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nodes/core/NodeBuilder.js","lineNumber":1457,"sourceCode":"\t\t} else if ( typeLength === 3 ) {\n\n\t\t\treturn `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) } )`;\n\n\t\t} else if ( typeLength === 4 && type !== 'mat2' ) {\n\n\t\t\treturn `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) }, ${ generateConst( value.w ) } )`;\n\n\t\t} else if ( typeLength >= 4 && value && ( value.isMatrix2 || value.isMatrix3 || value.isMatrix4 ) ) {\n\n\t\t\treturn `${ this.getType( type ) }( ${ value.elements.map( generateConst ).join( ', ' ) } )`;\n\n\t\t} else if ( typeLength > 4 ) {\n\n\t\t\treturn `${ this.getType( type ) }()`;\n\n\t\t}\n\n\t\tthrow new Error( `THREE.NodeBuilder: Type '${type}' not found in generate constant attempt.` );\n\n\t}\n\n\t/**\n\t * It might be necessary to convert certain data types to different ones\n\t * so this method can be used to hide the conversion.\n\t *\n\t * @param {string} type - The type.\n\t * @return {string} The updated type.\n\t */\n\tgetType( type ) {\n\n\t\tif ( type === 'color' ) return 'vec3';\n\n\t\treturn type;\n\n\t}\n","sourceCodeStart":1439,"sourceCodeEnd":1475,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/nodes/core/NodeBuilder.js#L1439-L1475","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const KNOWN_TYPES = new Set( [ 'float','int','uint','bool','color','vec2','vec3','vec4','ivec2','ivec3','ivec4','uvec2','uvec3','uvec4','mat2','mat3','mat4' ] );\nfunction assertKnownType( type ) {\n  if ( ! KNOWN_TYPES.has( type ) ) throw new TypeError( `generateConst: unknown type '${ type }'` );\n}","typeGuard":"const isKnownScalarType = ( t ) => typeof t === 'string' && /^[iu]?(vec[234]|float|int|uint|bool|color|mat[234])$/.test( t );","tryCatchPattern":null,"preventionTips":["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."],"tags":["node-builder","type-system","internal-invariant"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}