{"record":{"id":"20c50ff5474b42c5","repo":"BabylonJS/Babylon.js","slug":"failed-to-find-node-name","errorCode":null,"errorMessage":"Failed to find node '${name}'","messagePattern":"Failed to find node '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":424,"sourceCode":"            this._loadData(data);\r\n\r\n            let nodes: Nullable<Array<number>> = null;\r\n\r\n            if (meshesNames) {\r\n                const nodeMap: { [name: string]: number } = {};\r\n                if (this._gltf.nodes) {\r\n                    for (const node of this._gltf.nodes) {\r\n                        if (node.name) {\r\n                            nodeMap[node.name] = node.index;\r\n                        }\r\n                    }\r\n                }\r\n\r\n                const names = meshesNames instanceof Array ? meshesNames : [meshesNames];\r\n                nodes = names.map((name) => {\r\n                    const node = nodeMap[name];\r\n                    if (node === undefined) {\r\n                        throw new Error(`Failed to find node '${name}'`);\r\n                    }\r\n\r\n                    return node;\r\n                });\r\n            }\r\n\r\n            return await this._loadAsync(rootUrl, fileName, nodes, () => {\r\n                return {\r\n                    meshes: this._getMeshes(),\r\n                    particleSystems: [],\r\n                    skeletons: this._getSkeletons(),\r\n                    animationGroups: this._getAnimationGroups(),\r\n                    lights: this._babylonLights,\r\n                    transformNodes: this._getTransformNodes(),\r\n                    geometries: this._getGeometries(),\r\n                    spriteManagers: [],\r\n                };\r\n            });\r","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L406-L442","documentation":"glTFLoader's importMeshAsync resolves mesh names to loader nodes via an internal nodeMap. When a requested name is not present in that map, it throws this error, indicating the glTF asset contains no node with that exact name.","triggerScenarios":"Calling loader.importMeshAsync with meshesNames (a string or array of strings) where one or more names do not match any node in the glTF's 'nodes' array.","commonSituations":"Typos or case-mismatched node names; referencing a mesh name instead of a node name (glTF nodes vs meshes are distinct); the asset was exported with different node names than expected; passing names from a different glTF file.","solutions":["Verify the exact node names in the glTF JSON (check the 'nodes' array 'name' fields) and correct the meshesNames argument","Pass node indices (numbers) instead of names to avoid name-matching issues entirely","Pass null as meshesNames to import all meshes when specific names are not required","Log Object.keys of parsed asset nodes or inspect the file with a glTF validator to confirm names"],"exampleFix":"// before\nloader.importMeshAsync([\"Ship_Hull\"], scene, \"model.glb\", rootUrl);\n// after\nloader.importMeshAsync([\"ShipHull\"], scene, \"model.glb\", rootUrl); // name must match the glTF node 'name' exactly","handlingStrategy":"validation","validationCode":"// Pre-fetch and check the glTF JSON before importMeshAsync\nconst res = await fetch(url);\nconst gltf = await res.json();\nconst nodeNames = new Set((gltf.nodes ?? []).map(n => n.name).filter(Boolean));\nconst requested = Array.isArray(meshesNames) ? meshesNames : [meshesNames];\nconst missing = requested.filter(n => !nodeNames.has(n));\nif (missing.length) throw new Error(`glTF nodes not found: ${missing.join(\", \")}`);","typeGuard":"function hasAllNodes(gltf, names) {\n  const nodeNames = new Set((gltf.nodes ?? []).map(n => n.name).filter(Boolean));\n  return names.every(n => nodeNames.has(n));\n}","tryCatchPattern":"try {\n  await loader.importMeshAsync(names, scene, url, rootUrl);\n} catch (e) {\n  if (e.message.startsWith(\"Failed to find node\")) {\n    console.warn(`Skipping asset, unknown node: ${e.message}`);\n  } else throw e;\n}","preventionTips":["Inspect node names in the glTF JSON before importing by name","Prefer numeric node indices over string names when available","Keep exporter settings stable so names do not change between exports"],"tags":["gltf","loader","name-lookup"],"backgroundTag":"gltf-node-not-found","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}