{"record":{"id":"16dd27e50e02c750","repo":"BabylonJS/Babylon.js","slug":"extensioncontext-attributes-instance-buffer-ac","errorCode":null,"errorMessage":"${extensionContext}/attributes: Instance buffer accessors do not have the same count.","messagePattern":"(.+?)/attributes: Instance buffer accessors do not have the same count\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.ts","lineNumber":76,"sourceCode":"                return await promise;\r\n            }\r\n\r\n            const promises = new Array<Promise<Nullable<Float32Array>>>();\r\n            let instanceCount = 0;\r\n\r\n            const loadAttribute = (attribute: string) => {\r\n                if (extension.attributes[attribute] == undefined) {\r\n                    promises.push(Promise.resolve(null));\r\n                    return;\r\n                }\r\n\r\n                const accessor = ArrayItem.Get(`${extensionContext}/attributes/${attribute}`, this._loader.gltf.accessors, extension.attributes[attribute]);\r\n                promises.push(this._loader._loadFloatAccessorAsync(`/accessors/${accessor.bufferView}`, accessor));\r\n\r\n                if (instanceCount === 0) {\r\n                    instanceCount = accessor.count;\r\n                } else if (instanceCount !== accessor.count) {\r\n                    throw new Error(`${extensionContext}/attributes: Instance buffer accessors do not have the same count.`);\r\n                }\r\n            };\r\n\r\n            loadAttribute(\"TRANSLATION\");\r\n            loadAttribute(\"ROTATION\");\r\n            loadAttribute(\"SCALE\");\r\n            loadAttribute(\"_COLOR_0\");\r\n\r\n            // eslint-disable-next-line github/no-then\r\n            return await promise.then(async (babylonTransformNode) => {\r\n                const [translationBuffer, rotationBuffer, scaleBuffer, colorBuffer] = await Promise.all(promises);\r\n                const matrices = new Float32Array(instanceCount * 16);\r\n                TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation\r\n                TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation\r\n                TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale\r\n                for (let i = 0; i < instanceCount; ++i) {\r\n                    translationBuffer && Vector3.FromArrayToRef(translationBuffer, i * 3, TmpVectors.Vector3[0]);\r\n                    rotationBuffer && Quaternion.FromArrayToRef(rotationBuffer, i * 4, TmpVectors.Quaternion[0]);\r","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.ts#L58-L94","documentation":"EXT_mesh_gpu_instancing requires all instance attribute accessors (TRANSLATION, ROTATION, SCALE, custom ones) to describe the same number of instances. loadAttribute compares each accessor.count to the first one seen; a mismatch throws, since per-instance buffers of differing lengths cannot be interleaved into an instanced draw.","triggerScenarios":"Loading a glTF whose node's EXT_mesh_gpu_instancing extension declares attributes with accessors of different counts (e.g. 100 translations but 50 rotations).","commonSituations":"Hand-assembled instancing extension blocks where custom attribute accessors were added with a different instance count; tool export bugs; partially updated assets after editing instance data.","solutions":["Regenerate all instance attribute accessors so every one has the same count","Remove the mismatched attribute from extension.attributes","Re-export the instanced asset from the source tool","Validate with glTF-Validator to catch count mismatches before load"],"exampleFix":"// before\n\"attributes\": { \"TRANSLATION\": 5, \"ROTATION\": 6 } // accessor counts differ\n// after: ensure accessors 5 and 6 both have count = N (same instance count)","handlingStrategy":"validation","validationCode":"const ext = node.extensions?.EXT_mesh_gpu_instancing;\nif (ext) {\n  const counts = Object.values(ext.attributes).map(i => gltf.accessors[i].count);\n  if (new Set(counts).size !== 1) throw new Error('Instance accessors have differing counts');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await BABYLON.SceneLoader.LoadAsync('./', 'instanced.gltf', engine);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('same count')) {\n    console.error('Fix instance attribute accessor counts to match');\n  } else throw e;\n}","preventionTips":["Run glTF-Validator on instanced assets before deployment","Generate all instance attributes from one source array so counts match","Delete unused instance attributes instead of leaving mismatched ones"],"tags":["gltf","extension","instancing","validation"],"backgroundTag":"accessor-count-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}