BabylonJS/Babylon.js · error
TrailMesh: generator not found with ID
Error message
TrailMesh: generator not found with ID
What it means
TrailMesh.Parse is the deserialization entry point used when a saved scene containing a TrailMesh is loaded. A TrailMesh must be bound to the generator (mesh or TransformNode) it trails; serialization stores only the generator's ID. If neither a mesh nor a transform node with that ID exists in the scene at parse time, the TrailMesh cannot be constructed and this error is thrown.
Source
Thrown at packages/dev/core/src/Meshes/trailMesh.pure.ts:295
* @param serializationObject object to write serialization to
*/
public override serialize(serializationObject: any): void {
super.serialize(serializationObject);
serializationObject.generatorId = this._generator.id;
}
/**
* Parses a serialized trail mesh
* @param parsedMesh the serialized mesh
* @param scene the scene to create the trail mesh in
* @returns the created trail mesh
*/
public static override Parse(parsedMesh: any, scene: Scene): TrailMesh {
const generator = scene.getLastMeshById(parsedMesh.generatorId) ?? scene.getLastTransformNodeById(parsedMesh.generatorId);
if (!generator) {
throw new Error("TrailMesh: generator not found with ID " + parsedMesh.generatorId);
}
const options = {
diameter: parsedMesh.diameter ?? parsedMesh._diameter,
length: parsedMesh._length,
segments: parsedMesh._segments,
sections: parsedMesh._sectionPolygonPointsCount,
doNotTaper: parsedMesh._doNotTaper,
autoStart: parsedMesh._autoStart,
};
return new TrailMesh(parsedMesh.name, generator, scene, options);
}
}
let _Registered = false;
/**
* Register side effects for trailMesh.
* Safe to call multiple times; only the first call has an effect.
View on GitHub (pinned to 0592b347b8)
Solutions
- Keep the generator mesh/TransformNode in the same scene file with the exact generatorId the TrailMesh references.
- Restore the missing generator (re-add it to the .babylon file or recreate it with the matching id) and reload.
- If the generator is intentionally absent, remove the TrailMesh entry from the serialized scene data.
- Log parsedMesh.generatorId and compare against scene.meshes / scene.transformNodes ids to find the missing or mismatched reference.
- Use unique, stable ids for meshes that other objects reference when saving scenes.
Example fix
// before (.babylon JSON)
{ "name": "trail", "type": "TrailMesh", "generatorId": "oldMeshId" } // no mesh with oldMeshId
// after: keep the generator in the scene file and fix the id
{ "name": "generator", "id": "genMesh", ... }
{ "name": "trail", "type": "TrailMesh", "generatorId": "genMesh" } Defensive patterns
Strategy: try-catch
Validate before calling
function trailMeshGeneratorPresent(scene, generatorId) {
return scene.getLastMeshById(generatorId) != null || scene.getLastTransformNodeById(generatorId) != null;
}
// before/while loading the serialized scene, or before parse:
if (!trailMeshGeneratorPresent(scene, parsedMesh.generatorId)) {
console.warn('TrailMesh generator missing:', parsedMesh.generatorId);
} Type guard
function hasGenerator(scene, generatorId) {
return scene.getLastMeshById(generatorId) instanceof BABYLON.AbstractMesh
|| scene.getLastTransformNodeById(generatorId) instanceof BABYLON.TransformNode;
} Try / catch
try {
const trail = TrailMesh.Parse(parsedMesh, scene);
} catch (e) {
if (String(e.message).startsWith('TrailMesh: generator not found')) {
console.warn('Skipping TrailMesh whose generator is missing:', parsedMesh.generatorId);
// recreate generator or skip loading the trail mesh
} else { throw e; }
} Prevention
- Never remove or re-id a mesh that a TrailMesh (or other dependent object) references in a saved scene.
- Keep generator and dependent objects in the same scene file when saving.
- Use stable, unique ids for referenced meshes and transform nodes.
- When trimming .babylon files, remove dependent objects like TrailMesh entries along with their generators.
- Validate serialized references (generatorId) exist in the target scene before loading.
When it happens
Trigger: SceneLoader/Scene.Parse loading a scene whose serialized TrailMesh has a generatorId matching no mesh or transform node in the scene — e.g. the generator mesh was removed from the saved file, its id changed, or parsing order/deferred loading meant the generator did not exist yet.
Common situations: Hand-editing a .babylon file and deleting or re-id'ing the generator mesh; stripping meshes from a saved scene to shrink it while leaving the TrailMesh entry behind; loading a partial scene file into a scene without the generator; saving one scene and loading the TrailMesh into a different scene.
Related errors
- GaussianSplattingPartProxyMesh: compound mesh not found with
- Unknown vector class name ${className}
- Decorator metadata is unavailable; the Symbol.metadata (${St
- Method not implemented.
- SmartAssetSerializer: Invalid asset map — expected an object
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/0dada5fa746d38be.
Report an issue: GitHub.