{"record":{"id":"e3e33dd082a8d458","repo":"BabylonJS/Babylon.js","slug":"initial-size-gradient-values-not-found-in-context","errorCode":null,"errorMessage":"Initial size gradient values not found in context.","messagePattern":"Initial size gradient values not found in context\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Particles/Node/nodeParticleSystemSet.helper.ts","lineNumber":802,"sourceCode":"    _CreateAndConnectInput(\"Flow Map Strength\", flowMapStrength, updateFlowMapBlock.strength);\r\n\r\n    return updateFlowMapBlock.output;\r\n}\r\n\r\n/**\r\n * Creates the group of blocks that represent the particle size update\r\n * @param inputParticle The input particle to update\r\n * @param sizeGradients The size gradients (if any)\r\n * @param context The context of the current conversion\r\n * @returns The output of the group of blocks that represent the particle size update\r\n */\r\nfunction _UpdateParticleSizeGradientBlockGroup(\r\n    inputParticle: NodeParticleConnectionPoint,\r\n    sizeGradients: Array<FactorGradient>,\r\n    context: RuntimeConversionContext\r\n): NodeParticleConnectionPoint {\r\n    if (context.sizeGradientValue0Output === undefined) {\r\n        throw new Error(\"Initial size gradient values not found in context.\");\r\n    }\r\n\r\n    context.ageToLifeTimeRatioBlockGroupOutput = _CreateAgeToLifeTimeRatioBlockGroup(context);\r\n\r\n    // Generate the gradient\r\n    const sizeValueOutput = _CreateGradientBlockGroup(context.ageToLifeTimeRatioBlockGroupOutput, sizeGradients, ParticleRandomBlockLocks.OncePerParticle, \"Size\", [\r\n        context.sizeGradientValue0Output,\r\n    ]);\r\n\r\n    // Create the update size\r\n    const updateSizeBlock = new UpdateSizeBlock(\"Size Update\");\r\n    inputParticle.connectTo(updateSizeBlock.particle);\r\n    sizeValueOutput.connectTo(updateSizeBlock.size);\r\n\r\n    return updateSizeBlock.output;\r\n}\r\n\r\n/**\r","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Particles/Node/nodeParticleSystemSet.helper.ts#L784-L820","documentation":"During legacy-to-node particle system conversion, size gradients over particle lifetime are expressed with a gradient block whose starting values come from a block group computed earlier and stored in the shared RuntimeConversionContext. If context.sizeGradientValue0Output is undefined, the helper cannot wire the gradient's initial size values and throws. This is an internal consistency check in the converter.","triggerScenarios":"Calling _UpdateParticleSizeGradientBlockGroup (during nodeParticleSystemSet conversion) for a system with sizeGradients when context.sizeGradientValue0Output was never populated — the initial size-gradient (index 0) block group creation step was skipped or ran out of order.","commonSituations":"Converting a ParticleSystem with size gradients defined but missing the gradient at factor 0 (e.g. gradients added starting at 0.5), or custom/hand-edited serialization data that omits the initial size gradient entry.","solutions":["Define a size gradient at factor 0 (addSizeGradient(0, ...)) so the conversion creates the initial-value output before processing gradients.","Verify the conversion pipeline runs _UpdateParticleBlockGroup in the expected order; don't invoke the size-gradient helper standalone with a fresh context.","Upgrade Babylon.js if the source system is valid but the converter still throws."],"exampleFix":"// before\nps.addSizeGradient(0.5, 2, 4);\n// after\nps.addSizeGradient(0, 1, 1);\nps.addSizeGradient(0.5, 2, 4);","handlingStrategy":"validation","validationCode":"const hasInitialSizeGradient = ps.sizeGradients?.some(g => g.gradient === 0);\nif (!hasInitialSizeGradient) throw new Error(\"Add addSizeGradient(0, ...) before node conversion\");","typeGuard":"function hasSizeGradient0(ps: ParticleSystem): boolean {\n  return Array.isArray(ps.sizeGradients) && ps.sizeGradients.some(g => g.gradient === 0);\n}","tryCatchPattern":null,"preventionTips":["Always add a size gradient at factor 0.","Test legacy-to-node conversion on your particle assets in CI.","Don't call _UpdateParticleSizeGradientBlockGroup standalone with a fresh context."],"tags":["node-particle-system","conversion","size-gradient"],"backgroundTag":"missing-conversion-context-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}