BabylonJS/Babylon.js · error
Initial size gradient values not found in context.
Error message
Initial size gradient values not found in context.
What it means
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.
Source
Thrown at packages/dev/core/src/Particles/Node/nodeParticleSystemSet.helper.ts:802
_CreateAndConnectInput("Flow Map Strength", flowMapStrength, updateFlowMapBlock.strength);
return updateFlowMapBlock.output;
}
/**
* Creates the group of blocks that represent the particle size update
* @param inputParticle The input particle to update
* @param sizeGradients The size gradients (if any)
* @param context The context of the current conversion
* @returns The output of the group of blocks that represent the particle size update
*/
function _UpdateParticleSizeGradientBlockGroup(
inputParticle: NodeParticleConnectionPoint,
sizeGradients: Array<FactorGradient>,
context: RuntimeConversionContext
): NodeParticleConnectionPoint {
if (context.sizeGradientValue0Output === undefined) {
throw new Error("Initial size gradient values not found in context.");
}
context.ageToLifeTimeRatioBlockGroupOutput = _CreateAgeToLifeTimeRatioBlockGroup(context);
// Generate the gradient
const sizeValueOutput = _CreateGradientBlockGroup(context.ageToLifeTimeRatioBlockGroupOutput, sizeGradients, ParticleRandomBlockLocks.OncePerParticle, "Size", [
context.sizeGradientValue0Output,
]);
// Create the update size
const updateSizeBlock = new UpdateSizeBlock("Size Update");
inputParticle.connectTo(updateSizeBlock.particle);
sizeValueOutput.connectTo(updateSizeBlock.size);
return updateSizeBlock.output;
}
/**
View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before ps.addSizeGradient(0.5, 2, 4); // after ps.addSizeGradient(0, 1, 1); ps.addSizeGradient(0.5, 2, 4);
Defensive patterns
Strategy: validation
Validate before calling
const hasInitialSizeGradient = ps.sizeGradients?.some(g => g.gradient === 0);
if (!hasInitialSizeGradient) throw new Error("Add addSizeGradient(0, ...) before node conversion"); Type guard
function hasSizeGradient0(ps: ParticleSystem): boolean {
return Array.isArray(ps.sizeGradients) && ps.sizeGradients.some(g => g.gradient === 0);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/e3e33dd082a8d458.
Report an issue: GitHub.