BabylonJS/Babylon.js · error · Error
Unknown animation group loading mode value '${animationGroup
Error message
Unknown animation group loading mode value '${animationGroupLoadingMode}' What it means
When loading animations you can specify animationGroupLoadingMode, which must be one of the SceneLoaderAnimationGroupLoadingMode enum values. Any other value falls through the switch's default case and throws.
Source
Thrown at packages/dev/core/src/Loading/sceneLoader.ts:1269
animationGroup.dispose();
}
break;
case SceneLoaderAnimationGroupLoadingMode.Stop:
for (const animationGroup of scene.animationGroups) {
animationGroup.stop();
}
break;
case SceneLoaderAnimationGroupLoadingMode.Sync:
for (const animationGroup of scene.animationGroups) {
animationGroup.reset();
animationGroup.restart();
}
break;
case SceneLoaderAnimationGroupLoadingMode.NoSync:
// nothing to do
break;
default:
throw new Error("Unknown animation group loading mode value '" + animationGroupLoadingMode + "'");
}
}
const startingIndexForNewAnimatables = scene.animatables.length;
const container = await loadAssetContainerCoreAsync(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions);
container.mergeAnimationsTo(scene, scene.animatables.slice(startingIndexForNewAnimatables), targetConverter);
container.dispose();
scene.onAnimationFileImportedObservable.notifyObservers(scene);
}
/**
* Import animations from a file into a scene
* @param source a string that defines the name of the scene file, or starts with "data:" following by the stringified version of the scene, or a File object, or an ArrayBufferView
* @param scene is the instance of BABYLON.Scene to append to
* @param options an object that configures aspects of how the scene is loaded
* @returns A promise that resolves when the animations are imported
View on GitHub (pinned to 0592b347b8)
Solutions
- Use SceneLoaderAnimationGroupLoadingMode members (Sync, SyncAlways, NoSync) instead of raw numbers
- Validate the value is in the enum before calling, or fall back to a known member
- Fix config/JSON values that contain out-of-range numbers
Example fix
// before await SceneLoader.ImportAnimationsAsync(url, '', scene, false, 4); // invalid mode // after await SceneLoader.ImportAnimationsAsync(url, '', scene, false, SceneLoaderAnimationGroupLoadingMode.Sync);
Defensive patterns
Strategy: validation
Validate before calling
const VALID_MODES = [SceneLoaderAnimationGroupLoadingMode.Sync, SceneLoaderAnimationGroupLoadingMode.SyncAlways, SceneLoaderAnimationGroupLoadingMode.NoSync]; if (!VALID_MODES.includes(mode)) mode = SceneLoaderAnimationGroupLoadingMode.Sync;
Type guard
const isValidMode = (m: number): m is SceneLoaderAnimationGroupLoadingMode => Object.values(SceneLoaderAnimationGroupLoadingMode).includes(m as SceneLoaderAnimationGroupLoadingMode);
Try / catch
try {
await SceneLoader.ImportAnimationsAsync(url, '', scene, overwrite, mode);
} catch (e) {
if (e instanceof Error && e.message.includes('Unknown animation group loading mode')) {
console.error('Bad animationGroupLoadingMode, falling back to Sync');
} else throw e;
} Prevention
- Always use enum members, never raw numbers from config
- Validate enum-typed values deserialized from JSON
- Add a unit test for options parsing that asserts valid enum values
When it happens
Trigger: Passing a raw number that isn't a valid enum member (e.g. 4, -1, or a value from a wrong enum) as options.animationGroupLoadingMode to ImportAnimationsAsync/LoadAnimationGroupAsync.
Common situations: Storing the mode in config as an arbitrary number; value came from JSON or an any-typed variable bypassing TypeScript; copying a constant from another enum.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- No scene available to load animations to
- No scene available to load asset container to
- At least one mesh is needed to create the nav mesh.
- Connect failed
- Disconnect failed
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/c41f67e51e61e745.
Report an issue: GitHub.